4 * Daniel Engström, Omicron Ceti AB <daniel@omicron.se>.
6 * See file CREDITS for list of people who contributed to this
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of
12 * the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
27 #include <asm/ic/sc520.h>
32 DECLARE_GLOBAL_DATA_PTR;
34 #undef SC520_CDP_DEBUG
36 #ifdef SC520_CDP_DEBUG
37 #define PRINTF(fmt,args...) printf (fmt ,##args)
39 #define PRINTF(fmt,args...)
42 /* ------------------------------------------------------------------------- */
47 * We first set up all IRQs to be non-pci, edge triggered,
48 * when we later enumerate the pci bus and pci_sc520_fixup_irq() gets
49 * called we reallocate irqs to the pci bus with sc520_pci_set_irq()
50 * as needed. Whe choose the irqs to gram from a configurable list
51 * inside pci_sc520_fixup_irq() (If this list contains stupid irq's
52 * such as 0 thngas will not work)
55 static void irq_init(void)
57 /* disable global interrupt mode */
58 sc520_mmcr->picicr = 0x40;
60 /* set all irqs to edge */
61 sc520_mmcr->pic_mode[0] = 0x00;
62 sc520_mmcr->pic_mode[1] = 0x00;
63 sc520_mmcr->pic_mode[2] = 0x00;
65 /* active low polarity on PIC interrupt pins,
66 * active high polarity on all other irq pins */
67 sc520_mmcr->intpinpol = 0x0000;
69 /* set irq number mapping */
70 sc520_mmcr->gp_tmr_int_map[0] = SC520_IRQ_DISABLED; /* disable GP timer 0 INT */
71 sc520_mmcr->gp_tmr_int_map[1] = SC520_IRQ_DISABLED; /* disable GP timer 1 INT */
72 sc520_mmcr->gp_tmr_int_map[2] = SC520_IRQ_DISABLED; /* disable GP timer 2 INT */
73 sc520_mmcr->pit_int_map[0] = SC520_IRQ0; /* Set PIT timer 0 INT to IRQ0 */
74 sc520_mmcr->pit_int_map[1] = SC520_IRQ_DISABLED; /* disable PIT timer 1 INT */
75 sc520_mmcr->pit_int_map[2] = SC520_IRQ_DISABLED; /* disable PIT timer 2 INT */
76 sc520_mmcr->pci_int_map[0] = SC520_IRQ_DISABLED; /* disable PCI INT A */
77 sc520_mmcr->pci_int_map[1] = SC520_IRQ_DISABLED; /* disable PCI INT B */
78 sc520_mmcr->pci_int_map[2] = SC520_IRQ_DISABLED; /* disable PCI INT C */
79 sc520_mmcr->pci_int_map[3] = SC520_IRQ_DISABLED; /* disable PCI INT D */
80 sc520_mmcr->dmabcintmap = SC520_IRQ_DISABLED; /* disable DMA INT */
81 sc520_mmcr->ssimap = SC520_IRQ_DISABLED; /* disable Synchronius serial INT */
82 sc520_mmcr->wdtmap = SC520_IRQ_DISABLED; /* disable Watchdog INT */
83 sc520_mmcr->rtcmap = SC520_IRQ8; /* Set RTC int to 8 */
84 sc520_mmcr->wpvmap = SC520_IRQ_DISABLED; /* disable write protect INT */
85 sc520_mmcr->icemap = SC520_IRQ1; /* Set ICE Debug Serielport INT to IRQ1 */
86 sc520_mmcr->ferrmap = SC520_IRQ13; /* Set FP error INT to IRQ13 */
88 if (CONFIG_SYS_USE_SIO_UART) {
89 sc520_mmcr->uart_int_map[0] = SC520_IRQ_DISABLED; /* disable internal UART1 INT */
90 sc520_mmcr->uart_int_map[1] = SC520_IRQ_DISABLED; /* disable internal UART2 INT */
91 sc520_mmcr->gp_int_map[3] = SC520_IRQ3; /* Set GPIRQ3 (ISA IRQ3) to IRQ3 */
92 sc520_mmcr->gp_int_map[4] = SC520_IRQ4; /* Set GPIRQ4 (ISA IRQ4) to IRQ4 */
94 sc520_mmcr->uart_int_map[0] = SC520_IRQ4; /* Set internal UART2 INT to IRQ4 */
95 sc520_mmcr->uart_int_map[1] = SC520_IRQ3; /* Set internal UART2 INT to IRQ3 */
96 sc520_mmcr->gp_int_map[3] = SC520_IRQ_DISABLED; /* disable GPIRQ3 (ISA IRQ3) */
97 sc520_mmcr->gp_int_map[4] = SC520_IRQ_DISABLED; /* disable GPIRQ4 (ISA IRQ4) */
100 sc520_mmcr->gp_int_map[1] = SC520_IRQ1; /* Set GPIRQ1 (SIO IRQ1) to IRQ1 */
101 sc520_mmcr->gp_int_map[5] = SC520_IRQ5; /* Set GPIRQ5 (ISA IRQ5) to IRQ5 */
102 sc520_mmcr->gp_int_map[6] = SC520_IRQ6; /* Set GPIRQ6 (ISA IRQ6) to IRQ6 */
103 sc520_mmcr->gp_int_map[7] = SC520_IRQ7; /* Set GPIRQ7 (ISA IRQ7) to IRQ7 */
104 sc520_mmcr->gp_int_map[8] = SC520_IRQ8; /* Set GPIRQ8 (SIO IRQ8) to IRQ8 */
105 sc520_mmcr->gp_int_map[9] = SC520_IRQ9; /* Set GPIRQ9 (ISA IRQ2) to IRQ9 */
106 sc520_mmcr->gp_int_map[0] = SC520_IRQ11; /* Set GPIRQ0 (ISA IRQ11) to IRQ10 */
107 sc520_mmcr->gp_int_map[2] = SC520_IRQ12; /* Set GPIRQ2 (ISA IRQ12) to IRQ12 */
108 sc520_mmcr->gp_int_map[10] = SC520_IRQ14; /* Set GPIRQ10 (ISA IRQ14) to IRQ14 */
110 sc520_mmcr->pcihostmap = 0x11f; /* Map PCI hostbridge INT to NMI */
111 sc520_mmcr->eccmap = 0x100; /* Map SDRAM ECC failure INT to NMI */
114 static void silence_uart(int port)
119 void setup_ali_sio(int uart_primary)
123 ali512x_set_fdc(ALI_ENABLED, 0x3f2, 6, 0);
124 ali512x_set_pp(ALI_ENABLED, 0x278, 7, 3);
125 ali512x_set_uart(ALI_ENABLED, ALI_UART1, uart_primary?0x3f8:0x3e8, 4);
126 ali512x_set_uart(ALI_ENABLED, ALI_UART2, uart_primary?0x2f8:0x2e8, 3);
127 ali512x_set_rtc(ALI_DISABLED, 0, 0);
128 ali512x_set_kbc(ALI_ENABLED, 1, 12);
129 ali512x_set_cio(ALI_ENABLED);
132 ali512x_cio_function(12, 1, 0, 0);
133 ali512x_cio_function(13, 1, 0, 0);
135 /* SSI chip select pins */
136 ali512x_cio_function(14, 0, 0, 0); /* SSI_CS */
137 ali512x_cio_function(15, 0, 0, 0); /* SSI_MV */
138 ali512x_cio_function(16, 0, 0, 0); /* SSI_SPI# */
141 ali512x_cio_function(20, 0, 0, 1);
142 ali512x_cio_function(21, 0, 0, 1);
143 ali512x_cio_function(22, 0, 0, 1);
144 ali512x_cio_function(23, 0, 0, 1);
148 /* set up the ISA bus timing and system address mappings */
149 static void bus_init(void)
152 /* set up the GP IO pins */
153 sc520_mmcr->piopfs31_16 = 0xf7ff; /* set the GPIO pin function 31-16 reg */
154 sc520_mmcr->piopfs15_0 = 0xffff; /* set the GPIO pin function 15-0 reg */
155 sc520_mmcr->cspfs = 0xf8; /* set the CS pin function reg */
156 sc520_mmcr->clksel = 0x70;
158 sc520_mmcr->gpcsrt = 1; /* set the GP CS offset */
159 sc520_mmcr->gpcspw = 3; /* set the GP CS pulse width */
160 sc520_mmcr->gpcsoff = 1; /* set the GP CS offset */
161 sc520_mmcr->gprdw = 3; /* set the RD pulse width */
162 sc520_mmcr->gprdoff = 1; /* set the GP RD offset */
163 sc520_mmcr->gpwrw = 3; /* set the GP WR pulse width */
164 sc520_mmcr->gpwroff = 1; /* set the GP WR offset */
166 sc520_mmcr->bootcsctl = 0x1823; /* set up timing of BOOTCS */
167 sc520_mmcr->romcs1ctl = 0x1823; /* set up timing of ROMCS1 */
168 sc520_mmcr->romcs2ctl = 0x1823; /* set up timing of ROMCS2 */
170 /* adjust the memory map:
171 * by default the first 256MB (0x00000000 - 0x0fffffff) is mapped to SDRAM
172 * and 256MB to 1G-128k (0x1000000 - 0x37ffffff) is mapped to PCI mmio
173 * we need to map 1G-128k - 1G (0x38000000 - 0x3fffffff) to CS1 */
176 /* SRAM = GPCS3 128k @ d0000-effff*/
177 sc520_mmcr->par[2] = 0x4e00400d;
179 /* IDE0 = GPCS6 1f0-1f7 */
180 sc520_mmcr->par[3] = 0x380801f0;
182 /* IDE1 = GPCS7 3f6 */
183 sc520_mmcr->par[4] = 0x3c0003f6;
185 sc520_mmcr->par[12] = 0x8bffe800;
187 sc520_mmcr->par[13] = 0xcbfff000;
189 sc520_mmcr->par[14] = 0xabfff800;
191 sc520_mmcr->par[15] = 0x30000640;
193 sc520_mmcr->adddecctl = 0;
195 asm ("wbinvd\n"); /* Flush cache, req. after setting the unchached attribute ona PAR */
197 if (CONFIG_SYS_USE_SIO_UART) {
198 sc520_mmcr->adddecctl = sc520_mmcr->adddecctl | UART2_DIS | UART1_DIS;
201 sc520_mmcr->adddecctl = sc520_mmcr->adddecctl & ~(UART2_DIS|UART1_DIS);
223 * PAR1 PCI ROM mapping
237 * PAR15 Port 0x680 LED display
241 * Miscelaneous platform dependent initialisations
250 /* max drive current on SDRAM */
251 sc520_mmcr->dsctl = 0x0100;
253 /* enter debug mode after next reset (only if jumper is also set) */
254 sc520_mmcr->rescfg = 0x08;
255 /* configure the software timer to 33.333MHz */
256 sc520_mmcr->swtmrcfg = 0;
257 gd->bus_clk = 33333000;
268 void show_boot_progress(int val)
270 if (val < -32) val = -1; /* let things compatible */
271 outb(val&0xff, 0x80);
272 outb((val&0xff00)>>8, 0x680);
276 int last_stage_init(void)
282 major |= ali512x_cio_in(23)?2:0;
283 major |= ali512x_cio_in(22)?1:0;
284 minor |= ali512x_cio_in(21)?2:0;
285 minor |= ali512x_cio_in(20)?1:0;
287 printf("AMD SC520 CDP revision %d.%d\n", major, minor);
293 void ssi_chip_select(int dev)
296 /* Spunk board: SPI EEPROM is active-low, MW EEPROM and AUX are active high */
298 case 1: /* SPI EEPROM */
299 ali512x_cio_out(16, 0);
302 case 2: /* MW EEPROM */
303 ali512x_cio_out(15, 1);
307 ali512x_cio_out(14, 1);
311 ali512x_cio_out(16, 1);
312 ali512x_cio_out(15, 0);
313 ali512x_cio_out(14, 0);
317 printf("Illegal SSI device requested: %d\n", dev);
321 void spi_eeprom_probe(int x)
325 int spi_eeprom_read(int x, int offset, uchar *buffer, int len)
330 int spi_eeprom_write(int x, int offset, uchar *buffer, int len)
335 void spi_init_f(void)
337 #ifdef CONFIG_SYS_SC520_CDP_USE_SPI
340 #ifdef CONFIG_SYS_SC520_CDP_USE_MW
345 ssize_t spi_read(uchar *addr, int alen, uchar *buffer, int len)
352 for (i=0;i<alen;i++) {
357 #ifdef CONFIG_SYS_SC520_CDP_USE_SPI
358 res = spi_eeprom_read(1, offset, buffer, len);
360 #ifdef CONFIG_SYS_SC520_CDP_USE_MW
361 res = mw_eeprom_read(2, offset, buffer, len);
363 #if !defined(CONFIG_SYS_SC520_CDP_USE_SPI) && !defined(CONFIG_SYS_SC520_CDP_USE_MW)
369 ssize_t spi_write(uchar *addr, int alen, uchar *buffer, int len)
376 for (i=0;i<alen;i++) {
381 #ifdef CONFIG_SYS_SC520_CDP_USE_SPI
382 res = spi_eeprom_write(1, offset, buffer, len);
384 #ifdef CONFIG_SYS_SC520_CDP_USE_MW
385 res = mw_eeprom_write(2, offset, buffer, len);
387 #if !defined(CONFIG_SYS_SC520_CDP_USE_SPI) && !defined(CONFIG_SYS_SC520_CDP_USE_MW)
393 int board_eth_init(bd_t *bis)
395 return pci_eth_init(bis);