wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 1 | /* |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 2 | * |
wdenk | abda5ca | 2003-05-31 18:35:21 +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> |
Ben Warren | 052a5ea | 2008-08-31 20:37:00 -0700 | [diff] [blame] | 26 | #include <netdev.h> |
Graeme Russ | ca2ec4f | 2009-08-23 12:59:54 +1000 | [diff] [blame] | 27 | #include <ds1722.h> |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 28 | #include <asm/io.h> |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 29 | #include <asm/ic/sc520.h> |
Graeme Russ | ca2ec4f | 2009-08-23 12:59:54 +1000 | [diff] [blame] | 30 | #include <asm/ic/ssi.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; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 33 | |
| 34 | /* |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 35 | * Theory: |
| 36 | * We first set up all IRQs to be non-pci, edge triggered, |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 37 | * when we later enumerate the pci bus and pci_sc520_fixup_irq() gets |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 38 | * called we reallocate irqs to the pci bus with sc520_pci_set_irq() |
| 39 | * as needed. Whe choose the irqs to gram from a configurable list |
| 40 | * inside pci_sc520_fixup_irq() (If this list contains stupid irq's |
| 41 | * such as 0 thngas will not work) |
| 42 | */ |
| 43 | |
| 44 | static void irq_init(void) |
| 45 | { |
| 46 | /* disable global interrupt mode */ |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 47 | sc520_mmcr->picicr = 0x40; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 48 | |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 49 | /* set all irqs to edge */ |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 50 | sc520_mmcr->pic_mode[0] = 0x00; |
| 51 | sc520_mmcr->pic_mode[1] = 0x00; |
| 52 | sc520_mmcr->pic_mode[2] = 0x00; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 53 | |
| 54 | /* active low polarity on PIC interrupt pins, |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 55 | * active high polarity on all other irq pins */ |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 56 | sc520_mmcr->intpinpol = 0x0000; |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 57 | |
| 58 | /* set irq number mapping */ |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 59 | sc520_mmcr->gp_tmr_int_map[0] = SC520_IRQ_DISABLED; /* disable GP timer 0 INT */ |
| 60 | sc520_mmcr->gp_tmr_int_map[1] = SC520_IRQ_DISABLED; /* disable GP timer 1 INT */ |
| 61 | sc520_mmcr->gp_tmr_int_map[2] = SC520_IRQ_DISABLED; /* disable GP timer 2 INT */ |
| 62 | sc520_mmcr->pit_int_map[0] = SC520_IRQ0; /* Set PIT timer 0 INT to IRQ0 */ |
| 63 | sc520_mmcr->pit_int_map[1] = SC520_IRQ_DISABLED; /* disable PIT timer 1 INT */ |
| 64 | sc520_mmcr->pit_int_map[2] = SC520_IRQ_DISABLED; /* disable PIT timer 2 INT */ |
| 65 | sc520_mmcr->pci_int_map[0] = SC520_IRQ_DISABLED; /* disable PCI INT A */ |
| 66 | sc520_mmcr->pci_int_map[1] = SC520_IRQ_DISABLED; /* disable PCI INT B */ |
| 67 | sc520_mmcr->pci_int_map[2] = SC520_IRQ_DISABLED; /* disable PCI INT C */ |
| 68 | sc520_mmcr->pci_int_map[3] = SC520_IRQ_DISABLED; /* disable PCI INT D */ |
| 69 | sc520_mmcr->dmabcintmap = SC520_IRQ_DISABLED; /* disable DMA INT */ |
| 70 | sc520_mmcr->ssimap = SC520_IRQ6; /* Set Synchronius serial INT to IRQ6*/ |
| 71 | sc520_mmcr->wdtmap = SC520_IRQ_DISABLED; /* disable Watchdog INT */ |
| 72 | sc520_mmcr->rtcmap = SC520_IRQ8; /* Set RTC int to 8 */ |
| 73 | sc520_mmcr->wpvmap = SC520_IRQ_DISABLED; /* disable write protect INT */ |
| 74 | sc520_mmcr->icemap = SC520_IRQ1; /* Set ICE Debug Serielport INT to IRQ1 */ |
| 75 | sc520_mmcr->ferrmap = SC520_IRQ13; /* Set FP error INT to IRQ13 */ |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 76 | |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 77 | |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 78 | sc520_mmcr->uart_int_map[0] = SC520_IRQ4; /* Set internal UART1 INT to IRQ4 */ |
| 79 | sc520_mmcr->uart_int_map[1] = SC520_IRQ3; /* Set internal UART2 INT to IRQ3 */ |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 80 | |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 81 | sc520_mmcr->gp_int_map[0] = SC520_IRQ7; /* Set GPIRQ0 (PC-Card AUX IRQ) to IRQ7 */ |
| 82 | sc520_mmcr->gp_int_map[1] = SC520_IRQ14; /* Set GPIRQ1 (CF IRQ) to IRQ14 */ |
| 83 | sc520_mmcr->gp_int_map[3] = SC520_IRQ5; /* Set GPIRQ3 ( CAN IRQ ) ti IRQ5 */ |
| 84 | sc520_mmcr->gp_int_map[4] = SC520_IRQ_DISABLED; /* disbale GIRQ4 ( IRR IRQ ) */ |
| 85 | sc520_mmcr->gp_int_map[5] = SC520_IRQ_DISABLED; /* disable GPIRQ5 */ |
| 86 | sc520_mmcr->gp_int_map[6] = SC520_IRQ_DISABLED; /* disable GPIRQ6 */ |
| 87 | sc520_mmcr->gp_int_map[7] = SC520_IRQ_DISABLED; /* disable GPIRQ7 */ |
| 88 | sc520_mmcr->gp_int_map[8] = SC520_IRQ_DISABLED; /* disable GPIRQ8 */ |
| 89 | sc520_mmcr->gp_int_map[9] = SC520_IRQ_DISABLED; /* disable GPIRQ9 */ |
| 90 | sc520_mmcr->gp_int_map[2] = SC520_IRQ_DISABLED; /* disable GPIRQ2 */ |
| 91 | sc520_mmcr->gp_int_map[10] = SC520_IRQ_DISABLED; /* disable GPIRQ10 */ |
| 92 | |
| 93 | sc520_mmcr->pcihostmap = 0x11f; /* Map PCI hostbridge INT to NMI */ |
| 94 | sc520_mmcr->eccmap = 0x100; /* Map SDRAM ECC failure INT to NMI */ |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 95 | |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 96 | } |
| 97 | |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 98 | /* set up the ISA bus timing and system address mappings */ |
| 99 | static void bus_init(void) |
| 100 | { |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 101 | /* versions |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 102 | * 0 Hyglo versions 0.95 and 0.96 (large baords) |
| 103 | * ?? Hyglo version 0.97 (small board) |
| 104 | * 10 Spunk board |
| 105 | */ |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 106 | int version = sc520_mmcr->sysinfo; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 107 | |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 108 | if (version) { |
| 109 | /* set up the GP IO pins (for the Spunk board) */ |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 110 | sc520_mmcr->piopfs31_16 = 0xfff0; /* set the GPIO pin function 31-16 reg */ |
| 111 | sc520_mmcr->piopfs15_0 = 0x000f; /* set the GPIO pin function 15-0 reg */ |
| 112 | sc520_mmcr->piodir31_16 = 0x000f; /* set the GPIO direction 31-16 reg */ |
| 113 | sc520_mmcr->piodir15_0 = 0x1ff0; /* set the GPIO direction 15-0 reg */ |
| 114 | sc520_mmcr->cspfs = 0xc0; /* set the CS pin function reg */ |
| 115 | sc520_mmcr->clksel = 0x70; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 116 | |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 117 | sc520_mmcr->pioclr31_16 = 0x0003; /* reset SSI chip-selects */ |
| 118 | sc520_mmcr->pioset31_16 = 0x000c; |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 119 | |
| 120 | } else { |
| 121 | /* set up the GP IO pins (for the Hyglo board) */ |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 122 | sc520_mmcr->piopfs31_16 = 0xffc0; /* set the GPIO pin function 31-16 reg */ |
| 123 | sc520_mmcr->piopfs15_0 = 0x1e7f; /* set the GPIO pin function 15-0 reg */ |
| 124 | sc520_mmcr->piodir31_16 = 0x003f; /* set the GPIO direction 31-16 reg */ |
| 125 | sc520_mmcr->piodir15_0 = 0xe180; /* set the GPIO direction 15-0 reg */ |
| 126 | sc520_mmcr->cspfs = 0x00; /* set the CS pin function reg */ |
| 127 | sc520_mmcr->clksel = 0x70; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 128 | |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 129 | sc520_mmcr->pioclr15_0 = 0x0180; /* reset SSI chip-selects */ |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 130 | } |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 131 | |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 132 | sc520_mmcr->gpcsrt = 1; /* set the GP CS offset */ |
| 133 | sc520_mmcr->gpcspw = 3; /* set the GP CS pulse width */ |
| 134 | sc520_mmcr->gpcsoff = 1; /* set the GP CS offset */ |
| 135 | sc520_mmcr->gprdw = 3; /* set the RD pulse width */ |
| 136 | sc520_mmcr->gprdoff = 1; /* set the GP RD offset */ |
| 137 | sc520_mmcr->gpwrw = 3; /* set the GP WR pulse width */ |
| 138 | sc520_mmcr->gpwroff = 1; /* set the GP WR offset */ |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 139 | |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 140 | sc520_mmcr->bootcsctl = 0x0407; /* set up timing of BOOTCS */ |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 141 | |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 142 | /* adjust the memory map: |
| 143 | * by default the first 256MB (0x00000000 - 0x0fffffff) is mapped to SDRAM |
| 144 | * and 256MB to 1G-128k (0x1000000 - 0x37ffffff) is mapped to PCI mmio |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 145 | * we need to map 1G-128k - 1G (0x38000000 - 0x3fffffff) to CS1 */ |
| 146 | |
| 147 | |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 148 | /* bootcs */ |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 149 | sc520_mmcr->par[12] = 0x8bffe800; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 150 | |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 151 | /* IDE0 = GPCS6 1f0-1f7 */ |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 152 | sc520_mmcr->par[3] = 0x380801f0; |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 153 | |
| 154 | /* IDE1 = GPCS7 3f6 */ |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 155 | sc520_mmcr->par[4] = 0x3c0003f6; |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 156 | |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 157 | asm ("wbinvd\n"); /* Flush cache, req. after setting the unchached attribute ona PAR */ |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 158 | |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 159 | sc520_mmcr->adddecctl = sc520_mmcr->adddecctl & ~(UART2_DIS|UART1_DIS); |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 160 | |
| 161 | } |
| 162 | |
| 163 | |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 164 | /* par usage: |
| 165 | * PAR0 (legacy_video) |
| 166 | * PAR1 (PCI ROM mapping) |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 167 | * PAR2 |
| 168 | * PAR3 IDE |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 169 | * PAR4 IDE |
| 170 | * PAR5 (legacy_video) |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 171 | * PAR6 |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 172 | * PAR7 (legacy_video) |
| 173 | * PAR8 (legacy_video) |
| 174 | * PAR9 (legacy_video) |
| 175 | * PAR10 |
| 176 | * PAR11 (ISAROM) |
| 177 | * PAR12 BOOTCS |
| 178 | * PAR13 |
| 179 | * PAR14 |
| 180 | * PAR15 |
| 181 | */ |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 182 | |
| 183 | /* |
| 184 | * Miscelaneous platform dependent initialisations |
| 185 | */ |
| 186 | |
| 187 | int board_init(void) |
| 188 | { |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 189 | init_sc520(); |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 190 | bus_init(); |
| 191 | irq_init(); |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 192 | |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 193 | /* max drive current on SDRAM */ |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 194 | sc520_mmcr->dsctl = 0x0100; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 195 | |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 196 | /* enter debug mode after next reset (only if jumper is also set) */ |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 197 | sc520_mmcr->rescfg = 0x08; |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 198 | /* configure the software timer to 33.000MHz */ |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 199 | sc520_mmcr->swtmrcfg = 1; |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 200 | gd->bus_clk = 33000000; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 201 | |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 202 | return 0; |
| 203 | } |
| 204 | |
| 205 | int dram_init(void) |
| 206 | { |
| 207 | init_sc520_dram(); |
| 208 | return 0; |
| 209 | } |
| 210 | |
| 211 | void show_boot_progress(int val) |
| 212 | { |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 213 | int version = sc520_mmcr->sysinfo; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 214 | |
Heiko Schocher | 633e03a | 2007-06-22 19:11:54 +0200 | [diff] [blame] | 215 | if (val < -32) val = -1; /* let things compatible */ |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 216 | if (version == 0) { |
| 217 | /* PIO31-PIO16 Data */ |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 218 | sc520_mmcr->piodata31_16 = (sc520_mmcr->piodata31_16 & 0xffc0) | ((val&0x7e)>>1); /* 0x1f8 >> 3 */ |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 219 | |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 220 | /* PIO0-PIO15 Data */ |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 221 | sc520_mmcr->piodata15_0 = (sc520_mmcr->piodata15_0 & 0x1fff)| ((val&0x7)<<13); |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 222 | } else { |
| 223 | /* newer boards use PIO4-PIO12 */ |
| 224 | /* PIO0-PIO15 Data */ |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 225 | #if 0 |
| 226 | val = (val & 0x007) | ((val & 0x038) << 3) | ((val & 0x1c0) >> 3); |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 227 | #else |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 228 | val = (val & 0x007) | ((val & 0x07e) << 2); |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 229 | #endif |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 230 | sc520_mmcr->piodata15_0 = (sc520_mmcr->piodata15_0 & 0xe00f) | ((val&0x01ff)<<4); |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 231 | } |
| 232 | } |
| 233 | |
| 234 | |
| 235 | int last_stage_init(void) |
| 236 | { |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 237 | |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 238 | int version = sc520_mmcr->sysinfo; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 239 | |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 240 | printf("Omicron Ceti SC520 Spunk revision %x\n", version); |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 241 | |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 242 | #if 0 |
| 243 | if (version) { |
| 244 | int x, y; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 245 | |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 246 | printf("eeprom probe %d\n", spi_eeprom_probe(1)); |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 247 | |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 248 | spi_eeprom_read(1, 0, (u8*)&x, 2); |
| 249 | spi_eeprom_read(1, 1, (u8*)&y, 2); |
| 250 | printf("eeprom bytes %04x%04x\n", x, y); |
| 251 | x ^= 0xffff; |
| 252 | y ^= 0xffff; |
| 253 | spi_eeprom_write(1, 0, (u8*)&x, 2); |
| 254 | spi_eeprom_write(1, 1, (u8*)&y, 2); |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 255 | |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 256 | spi_eeprom_read(1, 0, (u8*)&x, 2); |
| 257 | spi_eeprom_read(1, 1, (u8*)&y, 2); |
| 258 | printf("eeprom bytes %04x%04x\n", x, y); |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 259 | |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 260 | } else { |
| 261 | int x, y; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 262 | |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 263 | printf("eeprom probe %d\n", mw_eeprom_probe(1)); |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 264 | |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 265 | mw_eeprom_read(1, 0, (u8*)&x, 2); |
| 266 | mw_eeprom_read(1, 1, (u8*)&y, 2); |
| 267 | printf("eeprom bytes %04x%04x\n", x, y); |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 268 | |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 269 | x ^= 0xffff; |
| 270 | y ^= 0xffff; |
| 271 | mw_eeprom_write(1, 0, (u8*)&x, 2); |
| 272 | mw_eeprom_write(1, 1, (u8*)&y, 2); |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 273 | |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 274 | mw_eeprom_read(1, 0, (u8*)&x, 2); |
| 275 | mw_eeprom_read(1, 1, (u8*)&y, 2); |
| 276 | printf("eeprom bytes %04x%04x\n", x, y); |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 277 | |
| 278 | |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 279 | } |
| 280 | #endif |
| 281 | |
| 282 | ds1722_probe(2); |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 283 | |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 284 | return 0; |
| 285 | } |
| 286 | |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 287 | void ssi_chip_select(int dev) |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 288 | { |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 289 | int version = sc520_mmcr->sysinfo; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 290 | |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 291 | if (version) { |
| 292 | /* Spunk board: EEPROM and CAN are actove-low, TEMP and AUX are active high */ |
| 293 | switch (dev) { |
| 294 | case 1: /* EEPROM */ |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 295 | sc520_mmcr->pioclr31_16 = 0x0004; |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 296 | break; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 297 | |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 298 | case 2: /* Temp Probe */ |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 299 | sc520_mmcr->pioset31_16 = 0x0002; |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 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 3: /* CAN */ |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 303 | sc520_mmcr->pioclr31_16 = 0x0008; |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 304 | break; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 305 | |
| 306 | case 4: /* AUX */ |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 307 | sc520_mmcr->pioset31_16 = 0x0001; |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 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: |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 311 | sc520_mmcr->pioclr31_16 = 0x0003; |
| 312 | sc520_mmcr->pioset31_16 = 0x000c; |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 313 | break; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 314 | |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 315 | default: |
| 316 | printf("Illegal SSI device requested: %d\n", dev); |
| 317 | } |
| 318 | } else { |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 319 | |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 320 | /* Globox board: Both EEPROM and TEMP are active-high */ |
| 321 | |
| 322 | switch (dev) { |
| 323 | case 1: /* EEPROM */ |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 324 | sc520_mmcr->pioset15_0 = 0x0100; |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 325 | break; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 326 | |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 327 | case 2: /* Temp Probe */ |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 328 | sc520_mmcr->pioset15_0 = 0x0080; |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 329 | break; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 330 | |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 331 | case 0: |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 332 | sc520_mmcr->pioclr15_0 = 0x0180; |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 333 | break; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 334 | |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 335 | default: |
| 336 | printf("Illegal SSI device requested: %d\n", dev); |
| 337 | } |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 338 | } |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 339 | } |
| 340 | |
Graeme Russ | ca2ec4f | 2009-08-23 12:59:54 +1000 | [diff] [blame] | 341 | void spi_eeprom_probe(int x) |
| 342 | { |
| 343 | } |
| 344 | |
| 345 | int spi_eeprom_read(int x, int offset, uchar *buffer, int len) |
| 346 | { |
| 347 | return 0; |
| 348 | } |
| 349 | |
| 350 | int spi_eeprom_write(int x, int offset, uchar *buffer, int len) |
| 351 | { |
| 352 | return 0; |
| 353 | } |
| 354 | |
| 355 | void mw_eeprom_probe(int x) |
| 356 | { |
| 357 | } |
| 358 | |
| 359 | int mw_eeprom_read(int x, int offset, uchar *buffer, int len) |
| 360 | { |
| 361 | return 0; |
| 362 | } |
| 363 | |
| 364 | int mw_eeprom_write(int x, int offset, uchar *buffer, int len) |
| 365 | { |
| 366 | return 0; |
| 367 | } |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 368 | |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 369 | void spi_init_f(void) |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 370 | { |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 371 | sc520_mmcr->sysinfo ? spi_eeprom_probe(1) : mw_eeprom_probe(1); |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 372 | |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 373 | } |
| 374 | |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 375 | ssize_t spi_read(uchar *addr, int alen, uchar *buffer, int len) |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 376 | { |
| 377 | int offset; |
| 378 | int i; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 379 | |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 380 | offset = 0; |
| 381 | for (i=0;i<alen;i++) { |
| 382 | offset <<= 8; |
| 383 | offset |= addr[i]; |
| 384 | } |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 385 | |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 386 | return sc520_mmcr->sysinfo ? |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 387 | spi_eeprom_read(1, offset, buffer, len) : |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 388 | mw_eeprom_read(1, offset, buffer, len); |
| 389 | } |
| 390 | |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 391 | ssize_t spi_write(uchar *addr, int alen, uchar *buffer, int len) |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 392 | { |
| 393 | int offset; |
| 394 | int i; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 395 | |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 396 | offset = 0; |
| 397 | for (i=0;i<alen;i++) { |
| 398 | offset <<= 8; |
| 399 | offset |= addr[i]; |
| 400 | } |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 401 | |
Graeme Russ | 1d977dc | 2009-08-23 12:59:56 +1000 | [diff] [blame] | 402 | return sc520_mmcr->sysinfo ? |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 403 | spi_eeprom_write(1, offset, buffer, len) : |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 404 | mw_eeprom_write(1, offset, buffer, len); |
| 405 | } |
Ben Warren | 052a5ea | 2008-08-31 20:37:00 -0700 | [diff] [blame] | 406 | |
| 407 | int board_eth_init(bd_t *bis) |
| 408 | { |
| 409 | return pci_eth_init(bis); |
| 410 | } |