blob: 4c44b2414c0fba4f05fdebef3b597c97f6801f3c [file] [log] [blame]
wdenk2262cfe2002-11-18 00:14:45 +00001/*
wdenk8bde7f72003-06-27 21:31:46 +00002 *
wdenk2262cfe2002-11-18 00:14:45 +00003 * (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>
wdenk2262cfe2002-11-18 00:14:45 +000026#include <asm/io.h>
27#include <asm/ic/sc520.h>
Graeme Russece444b2009-02-24 21:12:35 +110028#include <ali512x.h>
wdenkbdccc4f2003-08-05 17:43:17 +000029#include <spi.h>
Ben Warrene3090532008-08-31 10:08:43 -070030#include <netdev.h>
wdenk7a8e9bed2003-05-31 18:35:21 +000031
Wolfgang Denkd87080b2006-03-31 18:32:53 +020032DECLARE_GLOBAL_DATA_PTR;
33
wdenk7a8e9bed2003-05-31 18:35:21 +000034#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
wdenk2262cfe2002-11-18 00:14:45 +000041
42/* ------------------------------------------------------------------------- */
43
wdenk8bde7f72003-06-27 21:31:46 +000044
45/*
wdenk7a8e9bed2003-05-31 18:35:21 +000046 * Theory:
47 * We first set up all IRQs to be non-pci, edge triggered,
wdenk8bde7f72003-06-27 21:31:46 +000048 * when we later enumerate the pci bus and pci_sc520_fixup_irq() gets
wdenk7a8e9bed2003-05-31 18:35:21 +000049 * 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
wdenk2262cfe2002-11-18 00:14:45 +000055static void irq_init(void)
56{
wdenk2262cfe2002-11-18 00:14:45 +000057 /* disable global interrupt mode */
Graeme Russed7a1b62009-08-23 12:59:56 +100058 sc520_mmcr->picicr = 0x40;
wdenk8bde7f72003-06-27 21:31:46 +000059
wdenk7a8e9bed2003-05-31 18:35:21 +000060 /* set all irqs to edge */
Graeme Russed7a1b62009-08-23 12:59:56 +100061 sc520_mmcr->pic_mode[0] = 0x00;
62 sc520_mmcr->pic_mode[1] = 0x00;
63 sc520_mmcr->pic_mode[2] = 0x00;
wdenk8bde7f72003-06-27 21:31:46 +000064
65 /* active low polarity on PIC interrupt pins,
wdenk7a8e9bed2003-05-31 18:35:21 +000066 * active high polarity on all other irq pins */
Graeme Russed7a1b62009-08-23 12:59:56 +100067 sc520_mmcr->intpinpol = 0x0000;
wdenk2262cfe2002-11-18 00:14:45 +000068
69 /* set irq number mapping */
Graeme Russed7a1b62009-08-23 12:59:56 +100070 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 */
wdenk8bde7f72003-06-27 21:31:46 +000087
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020088 if (CONFIG_SYS_USE_SIO_UART) {
Graeme Russed7a1b62009-08-23 12:59:56 +100089 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 */
wdenk2262cfe2002-11-18 00:14:45 +000093 } else {
Graeme Russed7a1b62009-08-23 12:59:56 +100094 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) */
wdenk2262cfe2002-11-18 00:14:45 +000098 }
wdenk8bde7f72003-06-27 21:31:46 +000099
Graeme Russed7a1b62009-08-23 12:59:56 +1000100 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 */
wdenk8bde7f72003-06-27 21:31:46 +0000109
Graeme Russed7a1b62009-08-23 12:59:56 +1000110 sc520_mmcr->pcihostmap = 0x11f; /* Map PCI hostbridge INT to NMI */
111 sc520_mmcr->eccmap = 0x100; /* Map SDRAM ECC failure INT to NMI */
wdenk2262cfe2002-11-18 00:14:45 +0000112}
113
wdenk2262cfe2002-11-18 00:14:45 +0000114static void silence_uart(int port)
115{
116 outb(0, port+1);
117}
118
119void setup_ali_sio(int uart_primary)
120{
121 ali512x_init();
wdenk8bde7f72003-06-27 21:31:46 +0000122
wdenk2262cfe2002-11-18 00:14:45 +0000123 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);
wdenk8bde7f72003-06-27 21:31:46 +0000130
wdenk2262cfe2002-11-18 00:14:45 +0000131 /* IrDa pins */
132 ali512x_cio_function(12, 1, 0, 0);
133 ali512x_cio_function(13, 1, 0, 0);
wdenk8bde7f72003-06-27 21:31:46 +0000134
wdenk2262cfe2002-11-18 00:14:45 +0000135 /* SSI chip select pins */
136 ali512x_cio_function(14, 0, 0, 0); /* SSI_CS */
wdenk8bde7f72003-06-27 21:31:46 +0000137 ali512x_cio_function(15, 0, 0, 0); /* SSI_MV */
wdenk7a8e9bed2003-05-31 18:35:21 +0000138 ali512x_cio_function(16, 0, 0, 0); /* SSI_SPI# */
wdenk2262cfe2002-11-18 00:14:45 +0000139
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);
wdenk8bde7f72003-06-27 21:31:46 +0000144 ali512x_cio_function(23, 0, 0, 1);
wdenk2262cfe2002-11-18 00:14:45 +0000145}
146
147
148/* set up the ISA bus timing and system address mappings */
149static void bus_init(void)
150{
151
152 /* set up the GP IO pins */
Graeme Russed7a1b62009-08-23 12:59:56 +1000153 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;
wdenk2262cfe2002-11-18 00:14:45 +0000157
Graeme Russed7a1b62009-08-23 12:59:56 +1000158 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 */
wdenk8bde7f72003-06-27 21:31:46 +0000165
Graeme Russed7a1b62009-08-23 12:59:56 +1000166 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 */
wdenk8bde7f72003-06-27 21:31:46 +0000169
wdenk2262cfe2002-11-18 00:14:45 +0000170 /* 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
wdenk8bde7f72003-06-27 21:31:46 +0000173 * we need to map 1G-128k - 1G (0x38000000 - 0x3fffffff) to CS1 */
174
175
wdenk2262cfe2002-11-18 00:14:45 +0000176 /* SRAM = GPCS3 128k @ d0000-effff*/
Graeme Russed7a1b62009-08-23 12:59:56 +1000177 sc520_mmcr->par[2] = 0x4e00400d;
wdenk8bde7f72003-06-27 21:31:46 +0000178
wdenk2262cfe2002-11-18 00:14:45 +0000179 /* IDE0 = GPCS6 1f0-1f7 */
Graeme Russed7a1b62009-08-23 12:59:56 +1000180 sc520_mmcr->par[3] = 0x380801f0;
wdenk2262cfe2002-11-18 00:14:45 +0000181
182 /* IDE1 = GPCS7 3f6 */
Graeme Russed7a1b62009-08-23 12:59:56 +1000183 sc520_mmcr->par[4] = 0x3c0003f6;
wdenk2262cfe2002-11-18 00:14:45 +0000184 /* bootcs */
Graeme Russed7a1b62009-08-23 12:59:56 +1000185 sc520_mmcr->par[12] = 0x8bffe800;
wdenk2262cfe2002-11-18 00:14:45 +0000186 /* romcs2 */
Graeme Russed7a1b62009-08-23 12:59:56 +1000187 sc520_mmcr->par[13] = 0xcbfff000;
wdenk2262cfe2002-11-18 00:14:45 +0000188 /* romcs1 */
Graeme Russed7a1b62009-08-23 12:59:56 +1000189 sc520_mmcr->par[14] = 0xabfff800;
wdenk2262cfe2002-11-18 00:14:45 +0000190 /* 680 LEDS */
Graeme Russed7a1b62009-08-23 12:59:56 +1000191 sc520_mmcr->par[15] = 0x30000640;
wdenk8bde7f72003-06-27 21:31:46 +0000192
Graeme Russed7a1b62009-08-23 12:59:56 +1000193 sc520_mmcr->adddecctl = 0;
wdenk8bde7f72003-06-27 21:31:46 +0000194
195 asm ("wbinvd\n"); /* Flush cache, req. after setting the unchached attribute ona PAR */
wdenk2262cfe2002-11-18 00:14:45 +0000196
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200197 if (CONFIG_SYS_USE_SIO_UART) {
Graeme Russed7a1b62009-08-23 12:59:56 +1000198 sc520_mmcr->adddecctl = sc520_mmcr->adddecctl | UART2_DIS | UART1_DIS;
wdenk2262cfe2002-11-18 00:14:45 +0000199 setup_ali_sio(1);
200 } else {
Graeme Russed7a1b62009-08-23 12:59:56 +1000201 sc520_mmcr->adddecctl = sc520_mmcr->adddecctl & ~(UART2_DIS|UART1_DIS);
wdenk2262cfe2002-11-18 00:14:45 +0000202 setup_ali_sio(0);
203 silence_uart(0x3e8);
204 silence_uart(0x2e8);
205 }
206
207}
208
wdenk7a8e9bed2003-05-31 18:35:21 +0000209/* 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 */
wdenk2262cfe2002-11-18 00:14:45 +0000219
220
wdenk7a8e9bed2003-05-31 18:35:21 +0000221/* 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 */
239
wdenk8bde7f72003-06-27 21:31:46 +0000240/*
wdenk2262cfe2002-11-18 00:14:45 +0000241 * Miscelaneous platform dependent initialisations
242 */
243
244int board_init(void)
245{
wdenk8bde7f72003-06-27 21:31:46 +0000246 init_sc520();
wdenk2262cfe2002-11-18 00:14:45 +0000247 bus_init();
248 irq_init();
wdenk8bde7f72003-06-27 21:31:46 +0000249
wdenk2262cfe2002-11-18 00:14:45 +0000250 /* max drive current on SDRAM */
Graeme Russed7a1b62009-08-23 12:59:56 +1000251 sc520_mmcr->dsctl = 0x0100;
wdenk8bde7f72003-06-27 21:31:46 +0000252
wdenk2262cfe2002-11-18 00:14:45 +0000253 /* enter debug mode after next reset (only if jumper is also set) */
Graeme Russed7a1b62009-08-23 12:59:56 +1000254 sc520_mmcr->rescfg = 0x08;
wdenk2262cfe2002-11-18 00:14:45 +0000255 /* configure the software timer to 33.333MHz */
Graeme Russed7a1b62009-08-23 12:59:56 +1000256 sc520_mmcr->swtmrcfg = 0;
wdenk2262cfe2002-11-18 00:14:45 +0000257 gd->bus_clk = 33333000;
wdenk8bde7f72003-06-27 21:31:46 +0000258
wdenk2262cfe2002-11-18 00:14:45 +0000259 return 0;
260}
261
262int dram_init(void)
263{
264 init_sc520_dram();
265 return 0;
266}
267
268void show_boot_progress(int val)
269{
Heiko Schocher566a4942007-06-22 19:11:54 +0200270 if (val < -32) val = -1; /* let things compatible */
wdenk2262cfe2002-11-18 00:14:45 +0000271 outb(val&0xff, 0x80);
272 outb((val&0xff00)>>8, 0x680);
273}
274
275
276int last_stage_init(void)
277{
278 int minor;
279 int major;
wdenk8bde7f72003-06-27 21:31:46 +0000280
wdenk2262cfe2002-11-18 00:14:45 +0000281 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;
wdenk8bde7f72003-06-27 21:31:46 +0000286
wdenk2262cfe2002-11-18 00:14:45 +0000287 printf("AMD SC520 CDP revision %d.%d\n", major, minor);
wdenk8bde7f72003-06-27 21:31:46 +0000288
wdenkea909b72002-11-21 23:11:29 +0000289 return 0;
wdenk2262cfe2002-11-18 00:14:45 +0000290}
wdenk7a8e9bed2003-05-31 18:35:21 +0000291
292
wdenk8bde7f72003-06-27 21:31:46 +0000293void ssi_chip_select(int dev)
wdenk7a8e9bed2003-05-31 18:35:21 +0000294{
wdenk8bde7f72003-06-27 21:31:46 +0000295
wdenk7a8e9bed2003-05-31 18:35:21 +0000296 /* 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;
wdenk8bde7f72003-06-27 21:31:46 +0000301
wdenk7a8e9bed2003-05-31 18:35:21 +0000302 case 2: /* MW EEPROM */
303 ali512x_cio_out(15, 1);
304 break;
wdenk8bde7f72003-06-27 21:31:46 +0000305
306 case 3: /* AUX */
wdenk7a8e9bed2003-05-31 18:35:21 +0000307 ali512x_cio_out(14, 1);
308 break;
wdenk8bde7f72003-06-27 21:31:46 +0000309
wdenk7a8e9bed2003-05-31 18:35:21 +0000310 case 0:
311 ali512x_cio_out(16, 1);
312 ali512x_cio_out(15, 0);
313 ali512x_cio_out(14, 0);
314 break;
wdenk8bde7f72003-06-27 21:31:46 +0000315
wdenk7a8e9bed2003-05-31 18:35:21 +0000316 default:
317 printf("Illegal SSI device requested: %d\n", dev);
318 }
319}
320
wdenkbdccc4f2003-08-05 17:43:17 +0000321void spi_eeprom_probe(int x)
322{
323}
324
Graeme Russ3ef96de2008-09-07 07:08:42 +1000325int spi_eeprom_read(int x, int offset, uchar *buffer, int len)
wdenkbdccc4f2003-08-05 17:43:17 +0000326{
327 return 0;
328}
329
Graeme Russ3ef96de2008-09-07 07:08:42 +1000330int spi_eeprom_write(int x, int offset, uchar *buffer, int len)
wdenkbdccc4f2003-08-05 17:43:17 +0000331{
332 return 0;
333}
wdenk7a8e9bed2003-05-31 18:35:21 +0000334
wdenk8bde7f72003-06-27 21:31:46 +0000335void spi_init_f(void)
wdenk7a8e9bed2003-05-31 18:35:21 +0000336{
Graeme Russ6d83e3a2009-02-24 21:12:20 +1100337#ifdef CONFIG_SYS_SC520_CDP_USE_SPI
wdenk8bde7f72003-06-27 21:31:46 +0000338 spi_eeprom_probe(1);
339#endif
Graeme Russ6d83e3a2009-02-24 21:12:20 +1100340#ifdef CONFIG_SYS_SC520_CDP_USE_MW
wdenk7a8e9bed2003-05-31 18:35:21 +0000341 mw_eeprom_probe(2);
wdenk8bde7f72003-06-27 21:31:46 +0000342#endif
wdenk7a8e9bed2003-05-31 18:35:21 +0000343}
344
wdenk8bde7f72003-06-27 21:31:46 +0000345ssize_t spi_read(uchar *addr, int alen, uchar *buffer, int len)
wdenk7a8e9bed2003-05-31 18:35:21 +0000346{
347 int offset;
348 int i;
349 ssize_t res;
wdenk8bde7f72003-06-27 21:31:46 +0000350
wdenk7a8e9bed2003-05-31 18:35:21 +0000351 offset = 0;
352 for (i=0;i<alen;i++) {
353 offset <<= 8;
354 offset |= addr[i];
355 }
wdenk8bde7f72003-06-27 21:31:46 +0000356
Graeme Russ6d83e3a2009-02-24 21:12:20 +1100357#ifdef CONFIG_SYS_SC520_CDP_USE_SPI
wdenk8bde7f72003-06-27 21:31:46 +0000358 res = spi_eeprom_read(1, offset, buffer, len);
359#endif
Graeme Russ6d83e3a2009-02-24 21:12:20 +1100360#ifdef CONFIG_SYS_SC520_CDP_USE_MW
wdenk7a8e9bed2003-05-31 18:35:21 +0000361 res = mw_eeprom_read(2, offset, buffer, len);
wdenk8bde7f72003-06-27 21:31:46 +0000362#endif
Graeme Russ6d83e3a2009-02-24 21:12:20 +1100363#if !defined(CONFIG_SYS_SC520_CDP_USE_SPI) && !defined(CONFIG_SYS_SC520_CDP_USE_MW)
wdenkbdccc4f2003-08-05 17:43:17 +0000364 res = 0;
365#endif
wdenk7a8e9bed2003-05-31 18:35:21 +0000366 return res;
367}
368
wdenk8bde7f72003-06-27 21:31:46 +0000369ssize_t spi_write(uchar *addr, int alen, uchar *buffer, int len)
wdenk7a8e9bed2003-05-31 18:35:21 +0000370{
371 int offset;
372 int i;
373 ssize_t res;
wdenk8bde7f72003-06-27 21:31:46 +0000374
wdenk7a8e9bed2003-05-31 18:35:21 +0000375 offset = 0;
376 for (i=0;i<alen;i++) {
377 offset <<= 8;
378 offset |= addr[i];
379 }
wdenk8bde7f72003-06-27 21:31:46 +0000380
Graeme Russ6d83e3a2009-02-24 21:12:20 +1100381#ifdef CONFIG_SYS_SC520_CDP_USE_SPI
wdenk7a8e9bed2003-05-31 18:35:21 +0000382 res = spi_eeprom_write(1, offset, buffer, len);
wdenk8bde7f72003-06-27 21:31:46 +0000383#endif
Graeme Russ6d83e3a2009-02-24 21:12:20 +1100384#ifdef CONFIG_SYS_SC520_CDP_USE_MW
wdenk7a8e9bed2003-05-31 18:35:21 +0000385 res = mw_eeprom_write(2, offset, buffer, len);
wdenk8bde7f72003-06-27 21:31:46 +0000386#endif
Graeme Russ6d83e3a2009-02-24 21:12:20 +1100387#if !defined(CONFIG_SYS_SC520_CDP_USE_SPI) && !defined(CONFIG_SYS_SC520_CDP_USE_MW)
wdenkbdccc4f2003-08-05 17:43:17 +0000388 res = 0;
389#endif
wdenk7a8e9bed2003-05-31 18:35:21 +0000390 return res;
391}
Ben Warrene3090532008-08-31 10:08:43 -0700392
393int board_eth_init(bd_t *bis)
394{
395 return pci_eth_init(bis);
396}