wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 1 | /* |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 2 | * |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 3 | * (C) Copyright 2002 |
| 4 | * Daniel Engström, Omicron Ceti AB <daniel@omicron.se>. |
| 5 | * |
| 6 | * See file CREDITS for list of people who contributed to this |
| 7 | * project. |
| 8 | * |
| 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. |
| 13 | * |
| 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. |
| 18 | * |
| 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, |
| 22 | * MA 02111-1307 USA |
| 23 | */ |
| 24 | |
| 25 | #include <common.h> |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 26 | #include <asm/io.h> |
| 27 | #include <asm/ic/sc520.h> |
Graeme Russ | e6d4f43 | 2009-02-24 21:12:35 +1100 | [diff] [blame] | 28 | #include <ali512x.h> |
wdenk | 0a65855 | 2003-08-05 17:43:17 +0000 | [diff] [blame] | 29 | #include <spi.h> |
Ben Warren | b794a93 | 2008-08-31 10:08:43 -0700 | [diff] [blame] | 30 | #include <netdev.h> |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 31 | |
Wolfgang Denk | 6405a15 | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 32 | DECLARE_GLOBAL_DATA_PTR; |
| 33 | |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 34 | #undef SC520_CDP_DEBUG |
| 35 | |
| 36 | #ifdef SC520_CDP_DEBUG |
| 37 | #define PRINTF(fmt,args...) printf (fmt ,##args) |
| 38 | #else |
| 39 | #define PRINTF(fmt,args...) |
| 40 | #endif |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 41 | |
| 42 | /* ------------------------------------------------------------------------- */ |
| 43 | |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 44 | |
| 45 | /* |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 46 | * Theory: |
| 47 | * We first set up all IRQs to be non-pci, edge triggered, |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 48 | * when we later enumerate the pci bus and pci_sc520_fixup_irq() gets |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 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) |
| 53 | */ |
| 54 | |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 55 | static void irq_init(void) |
| 56 | { |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 57 | /* disable global interrupt mode */ |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 58 | sc520_mmcr->picicr = 0x40; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 59 | |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 60 | /* set all irqs to edge */ |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 61 | sc520_mmcr->pic_mode[0] = 0x00; |
| 62 | sc520_mmcr->pic_mode[1] = 0x00; |
| 63 | sc520_mmcr->pic_mode[2] = 0x00; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 64 | |
| 65 | /* active low polarity on PIC interrupt pins, |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 66 | * active high polarity on all other irq pins */ |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 67 | sc520_mmcr->intpinpol = 0x0000; |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 68 | |
| 69 | /* set irq number mapping */ |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 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 */ |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 87 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 88 | if (CONFIG_SYS_USE_SIO_UART) { |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 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 */ |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 93 | } else { |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 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) */ |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 98 | } |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 99 | |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 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 */ |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 109 | |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 110 | sc520_mmcr->pcihostmap = 0x11f; /* Map PCI hostbridge INT to NMI */ |
| 111 | sc520_mmcr->eccmap = 0x100; /* Map SDRAM ECC failure INT to NMI */ |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 112 | } |
| 113 | |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 114 | static void silence_uart(int port) |
| 115 | { |
| 116 | outb(0, port+1); |
| 117 | } |
| 118 | |
| 119 | void setup_ali_sio(int uart_primary) |
| 120 | { |
| 121 | ali512x_init(); |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 122 | |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 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); |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 130 | |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 131 | /* IrDa pins */ |
| 132 | ali512x_cio_function(12, 1, 0, 0); |
| 133 | ali512x_cio_function(13, 1, 0, 0); |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 134 | |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 135 | /* SSI chip select pins */ |
| 136 | ali512x_cio_function(14, 0, 0, 0); /* SSI_CS */ |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 137 | ali512x_cio_function(15, 0, 0, 0); /* SSI_MV */ |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 138 | ali512x_cio_function(16, 0, 0, 0); /* SSI_SPI# */ |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 139 | |
| 140 | /* Board REV pins */ |
| 141 | ali512x_cio_function(20, 0, 0, 1); |
| 142 | ali512x_cio_function(21, 0, 0, 1); |
| 143 | ali512x_cio_function(22, 0, 0, 1); |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 144 | ali512x_cio_function(23, 0, 0, 1); |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 145 | } |
| 146 | |
| 147 | |
| 148 | /* set up the ISA bus timing and system address mappings */ |
| 149 | static void bus_init(void) |
| 150 | { |
| 151 | |
| 152 | /* set up the GP IO pins */ |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 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; |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 157 | |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 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 */ |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 165 | |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 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 */ |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 169 | |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 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 |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 173 | * we need to map 1G-128k - 1G (0x38000000 - 0x3fffffff) to CS1 */ |
| 174 | |
| 175 | |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 176 | /* SRAM = GPCS3 128k @ d0000-effff*/ |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 177 | sc520_mmcr->par[2] = 0x4e00400d; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 178 | |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 179 | /* IDE0 = GPCS6 1f0-1f7 */ |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 180 | sc520_mmcr->par[3] = 0x380801f0; |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 181 | |
| 182 | /* IDE1 = GPCS7 3f6 */ |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 183 | sc520_mmcr->par[4] = 0x3c0003f6; |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 184 | /* bootcs */ |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 185 | sc520_mmcr->par[12] = 0x8bffe800; |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 186 | /* romcs2 */ |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 187 | sc520_mmcr->par[13] = 0xcbfff000; |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 188 | /* romcs1 */ |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 189 | sc520_mmcr->par[14] = 0xabfff800; |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 190 | /* 680 LEDS */ |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 191 | sc520_mmcr->par[15] = 0x30000640; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 192 | |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 193 | sc520_mmcr->adddecctl = 0; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 194 | |
| 195 | asm ("wbinvd\n"); /* Flush cache, req. after setting the unchached attribute ona PAR */ |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 196 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 197 | if (CONFIG_SYS_USE_SIO_UART) { |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 198 | sc520_mmcr->adddecctl = sc520_mmcr->adddecctl | UART2_DIS | UART1_DIS; |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 199 | setup_ali_sio(1); |
| 200 | } else { |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 201 | sc520_mmcr->adddecctl = sc520_mmcr->adddecctl & ~(UART2_DIS|UART1_DIS); |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 202 | setup_ali_sio(0); |
| 203 | silence_uart(0x3e8); |
| 204 | silence_uart(0x2e8); |
| 205 | } |
| 206 | |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 207 | } |
| 208 | |
| 209 | /* GPCS usage |
| 210 | * GPCS0 PIO27 (NMI) |
| 211 | * GPCS1 ROMCS1 |
| 212 | * GPCS2 ROMCS2 |
| 213 | * GPCS3 SRAMCS PAR2 |
| 214 | * GPCS4 unused PAR3 |
| 215 | * GPCS5 unused PAR4 |
| 216 | * GPCS6 IDE |
| 217 | * GPCS7 IDE |
| 218 | */ |
| 219 | |
| 220 | |
| 221 | /* par usage: |
| 222 | * PAR0 legacy_video |
| 223 | * PAR1 PCI ROM mapping |
| 224 | * PAR2 SRAM |
| 225 | * PAR3 IDE |
| 226 | * PAR4 IDE |
| 227 | * PAR5 legacy_video |
| 228 | * PAR6 legacy_video |
| 229 | * PAR7 legacy_video |
| 230 | * PAR8 legacy_video |
| 231 | * PAR9 legacy_video |
| 232 | * PAR10 legacy_video |
| 233 | * PAR11 ISAROM |
| 234 | * PAR12 BOOTCS |
| 235 | * PAR13 ROMCS1 |
| 236 | * PAR14 ROMCS2 |
| 237 | * PAR15 Port 0x680 LED display |
| 238 | */ |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 239 | |
| 240 | /* |
| 241 | * Miscelaneous platform dependent initialisations |
| 242 | */ |
| 243 | |
| 244 | int board_init(void) |
| 245 | { |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 246 | init_sc520(); |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 247 | bus_init(); |
| 248 | irq_init(); |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 249 | |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 250 | /* max drive current on SDRAM */ |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 251 | sc520_mmcr->dsctl = 0x0100; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 252 | |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 253 | /* enter debug mode after next reset (only if jumper is also set) */ |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 254 | sc520_mmcr->rescfg = 0x08; |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 255 | /* configure the software timer to 33.333MHz */ |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 256 | sc520_mmcr->swtmrcfg = 0; |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 257 | gd->bus_clk = 33333000; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 258 | |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 259 | return 0; |
| 260 | } |
| 261 | |
| 262 | int dram_init(void) |
| 263 | { |
| 264 | init_sc520_dram(); |
| 265 | return 0; |
| 266 | } |
| 267 | |
| 268 | void show_boot_progress(int val) |
| 269 | { |
Heiko Schocher | 633e03a | 2007-06-22 19:11:54 +0200 | [diff] [blame] | 270 | if (val < -32) val = -1; /* let things compatible */ |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 271 | outb(val&0xff, 0x80); |
| 272 | outb((val&0xff00)>>8, 0x680); |
| 273 | } |
| 274 | |
| 275 | |
| 276 | int last_stage_init(void) |
| 277 | { |
| 278 | int minor; |
| 279 | int major; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 280 | |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 281 | major = minor = 0; |
| 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; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 286 | |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 287 | printf("AMD SC520 CDP revision %d.%d\n", major, minor); |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 288 | |
wdenk | 2029f4d | 2002-11-21 23:11:29 +0000 | [diff] [blame] | 289 | return 0; |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 290 | } |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 291 | |
| 292 | |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 293 | void ssi_chip_select(int dev) |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 294 | { |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 295 | |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 296 | /* Spunk board: SPI EEPROM is active-low, MW EEPROM and AUX are active high */ |
| 297 | switch (dev) { |
| 298 | case 1: /* SPI EEPROM */ |
| 299 | ali512x_cio_out(16, 0); |
| 300 | break; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 301 | |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 302 | case 2: /* MW EEPROM */ |
| 303 | ali512x_cio_out(15, 1); |
| 304 | break; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 305 | |
| 306 | case 3: /* AUX */ |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 307 | ali512x_cio_out(14, 1); |
| 308 | break; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 309 | |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 310 | case 0: |
| 311 | ali512x_cio_out(16, 1); |
| 312 | ali512x_cio_out(15, 0); |
| 313 | ali512x_cio_out(14, 0); |
| 314 | break; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 315 | |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 316 | default: |
| 317 | printf("Illegal SSI device requested: %d\n", dev); |
| 318 | } |
| 319 | } |
| 320 | |
wdenk | 0a65855 | 2003-08-05 17:43:17 +0000 | [diff] [blame] | 321 | void spi_eeprom_probe(int x) |
| 322 | { |
| 323 | } |
| 324 | |
Graeme Russ | 2fe2a97 | 2008-09-07 07:08:42 +1000 | [diff] [blame] | 325 | int spi_eeprom_read(int x, int offset, uchar *buffer, int len) |
wdenk | 0a65855 | 2003-08-05 17:43:17 +0000 | [diff] [blame] | 326 | { |
| 327 | return 0; |
| 328 | } |
| 329 | |
Graeme Russ | 2fe2a97 | 2008-09-07 07:08:42 +1000 | [diff] [blame] | 330 | int spi_eeprom_write(int x, int offset, uchar *buffer, int len) |
wdenk | 0a65855 | 2003-08-05 17:43:17 +0000 | [diff] [blame] | 331 | { |
| 332 | return 0; |
| 333 | } |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 334 | |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 335 | void spi_init_f(void) |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 336 | { |
Graeme Russ | 27a2bf4 | 2009-02-24 21:12:20 +1100 | [diff] [blame] | 337 | #ifdef CONFIG_SYS_SC520_CDP_USE_SPI |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 338 | spi_eeprom_probe(1); |
| 339 | #endif |
Graeme Russ | 27a2bf4 | 2009-02-24 21:12:20 +1100 | [diff] [blame] | 340 | #ifdef CONFIG_SYS_SC520_CDP_USE_MW |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 341 | mw_eeprom_probe(2); |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 342 | #endif |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 343 | } |
| 344 | |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 345 | ssize_t spi_read(uchar *addr, int alen, uchar *buffer, int len) |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 346 | { |
| 347 | int offset; |
| 348 | int i; |
| 349 | ssize_t res; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 350 | |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 351 | offset = 0; |
| 352 | for (i=0;i<alen;i++) { |
| 353 | offset <<= 8; |
| 354 | offset |= addr[i]; |
| 355 | } |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 356 | |
Graeme Russ | 27a2bf4 | 2009-02-24 21:12:20 +1100 | [diff] [blame] | 357 | #ifdef CONFIG_SYS_SC520_CDP_USE_SPI |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 358 | res = spi_eeprom_read(1, offset, buffer, len); |
| 359 | #endif |
Graeme Russ | 27a2bf4 | 2009-02-24 21:12:20 +1100 | [diff] [blame] | 360 | #ifdef CONFIG_SYS_SC520_CDP_USE_MW |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 361 | res = mw_eeprom_read(2, offset, buffer, len); |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 362 | #endif |
Graeme Russ | 27a2bf4 | 2009-02-24 21:12:20 +1100 | [diff] [blame] | 363 | #if !defined(CONFIG_SYS_SC520_CDP_USE_SPI) && !defined(CONFIG_SYS_SC520_CDP_USE_MW) |
wdenk | 0a65855 | 2003-08-05 17:43:17 +0000 | [diff] [blame] | 364 | res = 0; |
| 365 | #endif |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 366 | return res; |
| 367 | } |
| 368 | |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 369 | ssize_t spi_write(uchar *addr, int alen, uchar *buffer, int len) |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 370 | { |
| 371 | int offset; |
| 372 | int i; |
| 373 | ssize_t res; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 374 | |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 375 | offset = 0; |
| 376 | for (i=0;i<alen;i++) { |
| 377 | offset <<= 8; |
| 378 | offset |= addr[i]; |
| 379 | } |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 380 | |
Graeme Russ | 27a2bf4 | 2009-02-24 21:12:20 +1100 | [diff] [blame] | 381 | #ifdef CONFIG_SYS_SC520_CDP_USE_SPI |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 382 | res = spi_eeprom_write(1, offset, buffer, len); |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 383 | #endif |
Graeme Russ | 27a2bf4 | 2009-02-24 21:12:20 +1100 | [diff] [blame] | 384 | #ifdef CONFIG_SYS_SC520_CDP_USE_MW |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 385 | res = mw_eeprom_write(2, offset, buffer, len); |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 386 | #endif |
Graeme Russ | 27a2bf4 | 2009-02-24 21:12:20 +1100 | [diff] [blame] | 387 | #if !defined(CONFIG_SYS_SC520_CDP_USE_SPI) && !defined(CONFIG_SYS_SC520_CDP_USE_MW) |
wdenk | 0a65855 | 2003-08-05 17:43:17 +0000 | [diff] [blame] | 388 | res = 0; |
| 389 | #endif |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 390 | return res; |
| 391 | } |
Ben Warren | b794a93 | 2008-08-31 10:08:43 -0700 | [diff] [blame] | 392 | |
| 393 | int board_eth_init(bd_t *bis) |
| 394 | { |
| 395 | return pci_eth_init(bis); |
| 396 | } |