Stefan Roese | 3e1f1b3 | 2005-08-01 16:49:12 +0200 | [diff] [blame] | 1 | /* |
Stefan Roese | c769864 | 2007-06-01 15:19:29 +0200 | [diff] [blame] | 2 | * (C) Copyright 2005-2007 |
Stefan Roese | 3e1f1b3 | 2005-08-01 16:49:12 +0200 | [diff] [blame] | 3 | * Stefan Roese, DENX Software Engineering, sr@denx.de. |
| 4 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
Stefan Roese | 3e1f1b3 | 2005-08-01 16:49:12 +0200 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <common.h> |
| 9 | #include <asm/processor.h> |
Stefan Roese | de21eab | 2010-09-16 14:30:37 +0200 | [diff] [blame] | 10 | #include <asm/ppc4xx-gpio.h> |
Stefan Roese | 3e1f1b3 | 2005-08-01 16:49:12 +0200 | [diff] [blame] | 11 | #include <spd_sdram.h> |
Stefan Roese | 247e9d7 | 2010-09-09 19:18:00 +0200 | [diff] [blame] | 12 | #include <asm/ppc440.h> |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 13 | #include "bamboo.h" |
Stefan Roese | 3e1f1b3 | 2005-08-01 16:49:12 +0200 | [diff] [blame] | 14 | |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 15 | void ext_bus_cntlr_init(void); |
| 16 | void configure_ppc440ep_pins(void); |
Stefan Roese | 797d857 | 2005-08-11 17:56:56 +0200 | [diff] [blame] | 17 | int is_nand_selected(void); |
Stefan Roese | 3e1f1b3 | 2005-08-01 16:49:12 +0200 | [diff] [blame] | 18 | |
Eugene OBrien | c59d1a0 | 2007-07-31 10:24:56 +0200 | [diff] [blame] | 19 | /************************************************************************* |
| 20 | * |
| 21 | * Bamboo has one bank onboard sdram (plus DIMM) |
| 22 | * |
| 23 | * Fixed memory is composed of : |
| 24 | * MT46V16M16TG-75 from Micron (x 2), 256Mb, 16 M x16, DDR266, |
| 25 | * 13 row add bits, 10 column add bits (but 12 row used only). |
| 26 | * ECC device: MT46V16M8TG-75 from Micron (x 1), 128Mb, x8, DDR266, |
| 27 | * 12 row add bits, 10 column add bits. |
| 28 | * Prepare a subset (only the used ones) of SPD data |
| 29 | * |
| 30 | * Note : if the ECC is enabled (SDRAM_ECC_ENABLE) the size of |
| 31 | * the corresponding bank is divided by 2 due to number of Row addresses |
| 32 | * 12 in the ECC module |
| 33 | * |
| 34 | * Assumes: 64 MB, ECC, non-registered |
| 35 | * PLB @ 133 MHz |
| 36 | * |
| 37 | ************************************************************************/ |
| 38 | const unsigned char cfg_simulate_spd_eeprom[128] = { |
| 39 | 0x80, /* number of SPD bytes used: 128 */ |
| 40 | 0x08, /* total number bytes in SPD device = 256 */ |
| 41 | 0x07, /* DDR ram */ |
| 42 | #ifdef CONFIG_DDR_ECC |
| 43 | 0x0C, /* num Row Addr: 12 */ |
| 44 | #else |
| 45 | 0x0D, /* num Row Addr: 13 */ |
| 46 | #endif |
| 47 | 0x09, /* numColAddr: 9 */ |
| 48 | 0x01, /* numBanks: 1 */ |
| 49 | 0x20, /* Module data width: 32 bits */ |
| 50 | 0x00, /* Module data width continued: +0 */ |
| 51 | 0x04, /* 2.5 Volt */ |
| 52 | 0x75, /* SDRAM Cycle Time (cas latency 2.5) = 7.5 ns */ |
Eugene O'Brien | c8fd200 | 2007-10-23 08:29:10 +0200 | [diff] [blame] | 53 | 0x00, /* SDRAM Access from clock */ |
Eugene OBrien | c59d1a0 | 2007-07-31 10:24:56 +0200 | [diff] [blame] | 54 | #ifdef CONFIG_DDR_ECC |
| 55 | 0x02, /* ECC ON : 02 OFF : 00 */ |
| 56 | #else |
| 57 | 0x00, /* ECC ON : 02 OFF : 00 */ |
| 58 | #endif |
Eugene O'Brien | c8fd200 | 2007-10-23 08:29:10 +0200 | [diff] [blame] | 59 | 0x82, /* refresh Rate Type: Normal (7.8us) + Self refresh */ |
Eugene OBrien | c59d1a0 | 2007-07-31 10:24:56 +0200 | [diff] [blame] | 60 | 0, |
| 61 | 0, |
| 62 | 0x01, /* wcsbc = 1 */ |
| 63 | 0, |
| 64 | 0, |
| 65 | 0x0C, /* casBit (2,2.5) */ |
| 66 | 0, |
| 67 | 0, |
| 68 | 0x00, /* not registered: 0 registered : 0x02*/ |
| 69 | 0, |
| 70 | 0xA0, /* SDRAM Cycle Time (cas latency 2) = 10 ns */ |
| 71 | 0, |
| 72 | 0x00, /* SDRAM Cycle Time (cas latency 1.5) = N.A */ |
| 73 | 0, |
| 74 | 0x50, /* tRpNs = 20 ns */ |
| 75 | 0, |
| 76 | 0x50, /* tRcdNs = 20 ns */ |
| 77 | 45, /* tRasNs */ |
| 78 | #ifdef CONFIG_DDR_ECC |
| 79 | 0x08, /* bankSizeID: 32MB */ |
| 80 | #else |
| 81 | 0x10, /* bankSizeID: 64MB */ |
| 82 | #endif |
| 83 | 0, |
| 84 | 0, |
| 85 | 0, |
| 86 | 0, |
| 87 | 0, |
| 88 | 0, |
| 89 | 0, |
| 90 | 0, |
| 91 | 0, |
| 92 | 0, |
| 93 | 0, |
| 94 | 0, |
| 95 | 0, |
| 96 | 0, |
| 97 | 0, |
| 98 | 0, |
| 99 | 0, |
| 100 | 0, |
| 101 | 0, |
| 102 | 0, |
| 103 | 0, |
| 104 | 0, |
| 105 | 0, |
| 106 | 0, |
| 107 | 0, |
| 108 | 0, |
| 109 | 0, |
| 110 | 0, |
| 111 | 0, |
| 112 | 0, |
| 113 | 0, |
| 114 | 0, |
| 115 | 0, |
| 116 | 0, |
| 117 | 0, |
| 118 | 0, |
| 119 | 0, |
| 120 | 0, |
| 121 | 0, |
| 122 | 0, |
| 123 | 0, |
| 124 | 0, |
| 125 | 0, |
| 126 | 0, |
| 127 | 0, |
| 128 | 0, |
| 129 | 0, |
| 130 | 0, |
| 131 | 0, |
| 132 | 0, |
| 133 | 0, |
| 134 | 0, |
| 135 | 0, |
| 136 | 0, |
| 137 | 0, |
| 138 | 0, |
| 139 | 0, |
| 140 | 0, |
| 141 | 0, |
| 142 | 0, |
| 143 | 0, |
| 144 | 0, |
| 145 | 0, |
| 146 | 0, |
| 147 | 0, |
| 148 | 0, |
| 149 | 0, |
| 150 | 0, |
| 151 | 0, |
| 152 | 0, |
| 153 | 0, |
| 154 | 0, |
| 155 | 0, |
| 156 | 0, |
| 157 | 0, |
| 158 | 0, |
| 159 | 0, |
| 160 | 0, |
| 161 | 0, |
| 162 | 0, |
| 163 | 0, |
| 164 | 0, |
| 165 | 0, |
| 166 | 0, |
| 167 | 0, |
| 168 | 0, |
| 169 | 0, |
| 170 | 0, |
| 171 | 0, |
| 172 | 0, |
| 173 | 0, |
| 174 | 0, |
| 175 | 0, |
| 176 | 0, |
| 177 | 0, |
| 178 | 0 |
| 179 | }; |
Stefan Roese | c45d1e3 | 2005-11-15 16:04:58 +0100 | [diff] [blame] | 180 | |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 181 | #if 0 |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 182 | { /* GPIO Alternate1 Alternate2 Alternate3 */ |
| 183 | { |
| 184 | /* GPIO Core 0 */ |
| 185 | { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_0 -> EBC_ADDR(7) DMA_REQ(2) */ |
| 186 | { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_1 -> EBC_ADDR(6) DMA_ACK(2) */ |
| 187 | { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_2 -> EBC_ADDR(5) DMA_EOT/TC(2) */ |
| 188 | { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_3 -> EBC_ADDR(4) DMA_REQ(3) */ |
| 189 | { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_4 -> EBC_ADDR(3) DMA_ACK(3) */ |
| 190 | { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_5 ................. */ |
| 191 | { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_6 -> EBC_CS_N(1) */ |
| 192 | { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_7 -> EBC_CS_N(2) */ |
| 193 | { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_8 -> EBC_CS_N(3) */ |
| 194 | { GPIO0_BASE, GPIO_DIS, GPIO_ALT1 }, /* GPIO0_9 -> EBC_CS_N(4) */ |
| 195 | { GPIO0_BASE, GPIO_OUT, GPIO_ALT1 }, /* GPIO0_10 -> EBC_CS_N(5) */ |
| 196 | { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_11 -> EBC_BUS_ERR */ |
| 197 | { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_12 -> ZII_p0Rxd(0) */ |
| 198 | { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_13 -> ZII_p0Rxd(1) */ |
| 199 | { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_14 -> ZII_p0Rxd(2) */ |
| 200 | { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_15 -> ZII_p0Rxd(3) */ |
| 201 | { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_16 -> ZII_p0Txd(0) */ |
| 202 | { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_17 -> ZII_p0Txd(1) */ |
| 203 | { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_18 -> ZII_p0Txd(2) */ |
| 204 | { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_19 -> ZII_p0Txd(3) */ |
| 205 | { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_20 -> ZII_p0Rx_er */ |
| 206 | { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_21 -> ZII_p0Rx_dv */ |
| 207 | { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_22 -> ZII_p0RxCrs */ |
| 208 | { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_23 -> ZII_p0Tx_er */ |
| 209 | { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_24 -> ZII_p0Tx_en */ |
| 210 | { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_25 -> ZII_p0Col */ |
| 211 | { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_26 -> USB2D_RXVALID */ |
| 212 | { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_27 -> EXT_EBC_REQ USB2D_RXERROR */ |
| 213 | { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_28 -> USB2D_TXVALID */ |
| 214 | { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_29 -> EBC_EXT_HDLA USB2D_PAD_SUSPNDM */ |
| 215 | { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_30 -> EBC_EXT_ACK USB2D_XCVRSELECT */ |
| 216 | { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_31 -> EBC_EXR_BUSREQ USB2D_TERMSELECT */ |
| 217 | }, |
| 218 | { |
| 219 | /* GPIO Core 1 */ |
| 220 | { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_0 -> USB2D_OPMODE0 */ |
| 221 | { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_1 -> USB2D_OPMODE1 */ |
| 222 | { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_2 -> UART0_DCD_N UART1_DSR_CTS_N UART2_SOUT */ |
| 223 | { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_3 -> UART0_8PIN_DSR_N UART1_RTS_DTR_N UART2_SIN */ |
| 224 | { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_4 -> UART0_8PIN_CTS_N UART3_SIN */ |
| 225 | { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_5 -> UART0_RTS_N */ |
| 226 | { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_6 -> UART0_DTR_N UART1_SOUT */ |
| 227 | { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_7 -> UART0_RI_N UART1_SIN */ |
| 228 | { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_8 -> UIC_IRQ(0) */ |
| 229 | { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_9 -> UIC_IRQ(1) */ |
| 230 | { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_10 -> UIC_IRQ(2) */ |
| 231 | { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_11 -> UIC_IRQ(3) */ |
| 232 | { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_12 -> UIC_IRQ(4) DMA_ACK(1) */ |
| 233 | { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_13 -> UIC_IRQ(6) DMA_EOT/TC(1) */ |
| 234 | { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_14 -> UIC_IRQ(7) DMA_REQ(0) */ |
| 235 | { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_15 -> UIC_IRQ(8) DMA_ACK(0) */ |
| 236 | { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_16 -> UIC_IRQ(9) DMA_EOT/TC(0) */ |
| 237 | { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_17 -> - */ |
| 238 | { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_18 -> | */ |
| 239 | { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_19 -> | */ |
| 240 | { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_20 -> | */ |
| 241 | { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_21 -> | */ |
| 242 | { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_22 -> | */ |
| 243 | { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_23 -> \ Can be unselected thru TraceSelect Bit */ |
| 244 | { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_24 -> / in PowerPC440EP Chip */ |
| 245 | { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_25 -> | */ |
| 246 | { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_26 -> | */ |
| 247 | { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_27 -> | */ |
| 248 | { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_28 -> | */ |
| 249 | { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_29 -> | */ |
| 250 | { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_30 -> | */ |
| 251 | { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_31 -> - */ |
| 252 | } |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 253 | }; |
| 254 | #endif |
Stefan Roese | 3e1f1b3 | 2005-08-01 16:49:12 +0200 | [diff] [blame] | 255 | |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 256 | /*----------------------------------------------------------------------------+ |
| 257 | | EBC Devices Characteristics |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 258 | | Peripheral Bank Access Parameters - EBC0_BnAP |
| 259 | | Peripheral Bank Configuration Register - EBC0_BnCR |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 260 | +----------------------------------------------------------------------------*/ |
| 261 | /* Small Flash */ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 262 | #define EBC0_BNAP_SMALL_FLASH \ |
| 263 | EBC0_BNAP_BME_DISABLED | \ |
| 264 | EBC0_BNAP_TWT_ENCODE(6) | \ |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 265 | EBC0_BNAP_CSN_ENCODE(0) | \ |
| 266 | EBC0_BNAP_OEN_ENCODE(1) | \ |
| 267 | EBC0_BNAP_WBN_ENCODE(1) | \ |
| 268 | EBC0_BNAP_WBF_ENCODE(3) | \ |
| 269 | EBC0_BNAP_TH_ENCODE(1) | \ |
| 270 | EBC0_BNAP_RE_ENABLED | \ |
| 271 | EBC0_BNAP_SOR_DELAYED | \ |
| 272 | EBC0_BNAP_BEM_WRITEONLY | \ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 273 | EBC0_BNAP_PEN_DISABLED |
Stefan Roese | 3e1f1b3 | 2005-08-01 16:49:12 +0200 | [diff] [blame] | 274 | |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 275 | #define EBC0_BNCR_SMALL_FLASH_CS0 \ |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 276 | EBC0_BNCR_BAS_ENCODE(0xFFF00000) | \ |
| 277 | EBC0_BNCR_BS_1MB | \ |
| 278 | EBC0_BNCR_BU_RW | \ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 279 | EBC0_BNCR_BW_8BIT |
Stefan Roese | 3e1f1b3 | 2005-08-01 16:49:12 +0200 | [diff] [blame] | 280 | |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 281 | #define EBC0_BNCR_SMALL_FLASH_CS4 \ |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 282 | EBC0_BNCR_BAS_ENCODE(0x87F00000) | \ |
| 283 | EBC0_BNCR_BS_1MB | \ |
| 284 | EBC0_BNCR_BU_RW | \ |
Stefan Roese | 797d857 | 2005-08-11 17:56:56 +0200 | [diff] [blame] | 285 | EBC0_BNCR_BW_8BIT |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 286 | |
| 287 | /* Large Flash or SRAM */ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 288 | #define EBC0_BNAP_LARGE_FLASH_OR_SRAM \ |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 289 | EBC0_BNAP_BME_DISABLED | \ |
| 290 | EBC0_BNAP_TWT_ENCODE(8) | \ |
| 291 | EBC0_BNAP_CSN_ENCODE(0) | \ |
| 292 | EBC0_BNAP_OEN_ENCODE(1) | \ |
| 293 | EBC0_BNAP_WBN_ENCODE(1) | \ |
| 294 | EBC0_BNAP_WBF_ENCODE(1) | \ |
| 295 | EBC0_BNAP_TH_ENCODE(2) | \ |
| 296 | EBC0_BNAP_SOR_DELAYED | \ |
| 297 | EBC0_BNAP_BEM_RW | \ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 298 | EBC0_BNAP_PEN_DISABLED |
| 299 | |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 300 | #define EBC0_BNCR_LARGE_FLASH_OR_SRAM_CS0 \ |
| 301 | EBC0_BNCR_BAS_ENCODE(0xFF800000) | \ |
| 302 | EBC0_BNCR_BS_8MB | \ |
| 303 | EBC0_BNCR_BU_RW | \ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 304 | EBC0_BNCR_BW_16BIT |
| 305 | |
| 306 | |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 307 | #define EBC0_BNCR_LARGE_FLASH_OR_SRAM_CS4 \ |
| 308 | EBC0_BNCR_BAS_ENCODE(0x87800000) | \ |
| 309 | EBC0_BNCR_BS_8MB | \ |
| 310 | EBC0_BNCR_BU_RW | \ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 311 | EBC0_BNCR_BW_16BIT |
Stefan Roese | 3e1f1b3 | 2005-08-01 16:49:12 +0200 | [diff] [blame] | 312 | |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 313 | /* NVRAM - FPGA */ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 314 | #define EBC0_BNAP_NVRAM_FPGA \ |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 315 | EBC0_BNAP_BME_DISABLED | \ |
| 316 | EBC0_BNAP_TWT_ENCODE(9) | \ |
| 317 | EBC0_BNAP_CSN_ENCODE(0) | \ |
| 318 | EBC0_BNAP_OEN_ENCODE(1) | \ |
| 319 | EBC0_BNAP_WBN_ENCODE(1) | \ |
| 320 | EBC0_BNAP_WBF_ENCODE(0) | \ |
| 321 | EBC0_BNAP_TH_ENCODE(2) | \ |
| 322 | EBC0_BNAP_RE_ENABLED | \ |
| 323 | EBC0_BNAP_SOR_DELAYED | \ |
| 324 | EBC0_BNAP_BEM_WRITEONLY | \ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 325 | EBC0_BNAP_PEN_DISABLED |
Stefan Roese | 3e1f1b3 | 2005-08-01 16:49:12 +0200 | [diff] [blame] | 326 | |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 327 | #define EBC0_BNCR_NVRAM_FPGA_CS5 \ |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 328 | EBC0_BNCR_BAS_ENCODE(0x80000000) | \ |
| 329 | EBC0_BNCR_BS_1MB | \ |
| 330 | EBC0_BNCR_BU_RW | \ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 331 | EBC0_BNCR_BW_8BIT |
Stefan Roese | 3e1f1b3 | 2005-08-01 16:49:12 +0200 | [diff] [blame] | 332 | |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 333 | /* Nand Flash */ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 334 | #define EBC0_BNAP_NAND_FLASH \ |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 335 | EBC0_BNAP_BME_DISABLED | \ |
| 336 | EBC0_BNAP_TWT_ENCODE(3) | \ |
| 337 | EBC0_BNAP_CSN_ENCODE(0) | \ |
| 338 | EBC0_BNAP_OEN_ENCODE(0) | \ |
| 339 | EBC0_BNAP_WBN_ENCODE(0) | \ |
| 340 | EBC0_BNAP_WBF_ENCODE(0) | \ |
| 341 | EBC0_BNAP_TH_ENCODE(1) | \ |
| 342 | EBC0_BNAP_RE_ENABLED | \ |
| 343 | EBC0_BNAP_SOR_NOT_DELAYED | \ |
| 344 | EBC0_BNAP_BEM_RW | \ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 345 | EBC0_BNAP_PEN_DISABLED |
| 346 | |
| 347 | |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 348 | #define EBC0_BNCR_NAND_FLASH_CS0 0xB8400000 |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 349 | |
| 350 | /* NAND0 */ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 351 | #define EBC0_BNCR_NAND_FLASH_CS1 \ |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 352 | EBC0_BNCR_BAS_ENCODE(0x90000000) | \ |
| 353 | EBC0_BNCR_BS_1MB | \ |
| 354 | EBC0_BNCR_BU_RW | \ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 355 | EBC0_BNCR_BW_32BIT |
| 356 | /* NAND1 - Bank2 */ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 357 | #define EBC0_BNCR_NAND_FLASH_CS2 \ |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 358 | EBC0_BNCR_BAS_ENCODE(0x94000000) | \ |
| 359 | EBC0_BNCR_BS_1MB | \ |
| 360 | EBC0_BNCR_BU_RW | \ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 361 | EBC0_BNCR_BW_32BIT |
| 362 | |
| 363 | /* NAND1 - Bank3 */ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 364 | #define EBC0_BNCR_NAND_FLASH_CS3 \ |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 365 | EBC0_BNCR_BAS_ENCODE(0x94000000) | \ |
| 366 | EBC0_BNCR_BS_1MB | \ |
| 367 | EBC0_BNCR_BU_RW | \ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 368 | EBC0_BNCR_BW_32BIT |
| 369 | |
| 370 | int board_early_init_f(void) |
| 371 | { |
| 372 | ext_bus_cntlr_init(); |
Stefan Roese | 3e1f1b3 | 2005-08-01 16:49:12 +0200 | [diff] [blame] | 373 | |
| 374 | /*-------------------------------------------------------------------- |
| 375 | * Setup the interrupt controller polarities, triggers, etc. |
| 376 | *-------------------------------------------------------------------*/ |
Stefan Roese | 707fd36 | 2009-09-24 09:55:50 +0200 | [diff] [blame] | 377 | mtdcr(UIC0SR, 0xffffffff); /* clear all */ |
| 378 | mtdcr(UIC0ER, 0x00000000); /* disable all */ |
| 379 | mtdcr(UIC0CR, 0x00000009); /* ATI & UIC1 crit are critical */ |
| 380 | mtdcr(UIC0PR, 0xfffffe13); /* per ref-board manual */ |
| 381 | mtdcr(UIC0TR, 0x01c00008); /* per ref-board manual */ |
| 382 | mtdcr(UIC0VR, 0x00000001); /* int31 highest, base=0x000 */ |
| 383 | mtdcr(UIC0SR, 0xffffffff); /* clear all */ |
Stefan Roese | 3e1f1b3 | 2005-08-01 16:49:12 +0200 | [diff] [blame] | 384 | |
Stefan Roese | 707fd36 | 2009-09-24 09:55:50 +0200 | [diff] [blame] | 385 | mtdcr(UIC1SR, 0xffffffff); /* clear all */ |
| 386 | mtdcr(UIC1ER, 0x00000000); /* disable all */ |
| 387 | mtdcr(UIC1CR, 0x00000000); /* all non-critical */ |
| 388 | mtdcr(UIC1PR, 0xffffe0ff); /* per ref-board manual */ |
| 389 | mtdcr(UIC1TR, 0x00ffc000); /* per ref-board manual */ |
| 390 | mtdcr(UIC1VR, 0x00000001); /* int31 highest, base=0x000 */ |
| 391 | mtdcr(UIC1SR, 0xffffffff); /* clear all */ |
Stefan Roese | 3e1f1b3 | 2005-08-01 16:49:12 +0200 | [diff] [blame] | 392 | |
| 393 | /*-------------------------------------------------------------------- |
| 394 | * Setup the GPIO pins |
| 395 | *-------------------------------------------------------------------*/ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 396 | out32(GPIO0_OSRL, 0x00000400); |
| 397 | out32(GPIO0_OSRH, 0x00000000); |
| 398 | out32(GPIO0_TSRL, 0x00000400); |
| 399 | out32(GPIO0_TSRH, 0x00000000); |
| 400 | out32(GPIO0_ISR1L, 0x00000000); |
| 401 | out32(GPIO0_ISR1H, 0x00000000); |
| 402 | out32(GPIO0_ISR2L, 0x00000000); |
| 403 | out32(GPIO0_ISR2H, 0x00000000); |
| 404 | out32(GPIO0_ISR3L, 0x00000000); |
| 405 | out32(GPIO0_ISR3H, 0x00000000); |
Stefan Roese | 3e1f1b3 | 2005-08-01 16:49:12 +0200 | [diff] [blame] | 406 | |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 407 | out32(GPIO1_OSRL, 0x0C380000); |
| 408 | out32(GPIO1_OSRH, 0x00000000); |
| 409 | out32(GPIO1_TSRL, 0x0C380000); |
| 410 | out32(GPIO1_TSRH, 0x00000000); |
| 411 | out32(GPIO1_ISR1L, 0x0FC30000); |
| 412 | out32(GPIO1_ISR1H, 0x00000000); |
| 413 | out32(GPIO1_ISR2L, 0x0C010000); |
| 414 | out32(GPIO1_ISR2H, 0x00000000); |
| 415 | out32(GPIO1_ISR3L, 0x01400000); |
| 416 | out32(GPIO1_ISR3H, 0x00000000); |
Stefan Roese | 3e1f1b3 | 2005-08-01 16:49:12 +0200 | [diff] [blame] | 417 | |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 418 | configure_ppc440ep_pins(); |
Stefan Roese | 3e1f1b3 | 2005-08-01 16:49:12 +0200 | [diff] [blame] | 419 | |
| 420 | return 0; |
| 421 | } |
Stefan Roese | 797d857 | 2005-08-11 17:56:56 +0200 | [diff] [blame] | 422 | |
Stefan Roese | 3e1f1b3 | 2005-08-01 16:49:12 +0200 | [diff] [blame] | 423 | int checkboard(void) |
| 424 | { |
Wolfgang Denk | 5c1cfee | 2011-05-04 10:32:28 +0000 | [diff] [blame] | 425 | char buf[64]; |
| 426 | int i = getenv_f("serial#", buf, sizeof(buf)); |
Stefan Roese | 3e1f1b3 | 2005-08-01 16:49:12 +0200 | [diff] [blame] | 427 | |
| 428 | printf("Board: Bamboo - AMCC PPC440EP Evaluation Board"); |
Wolfgang Denk | 5c1cfee | 2011-05-04 10:32:28 +0000 | [diff] [blame] | 429 | if (i > 0) { |
Stefan Roese | 3e1f1b3 | 2005-08-01 16:49:12 +0200 | [diff] [blame] | 430 | puts(", serial# "); |
Wolfgang Denk | 5c1cfee | 2011-05-04 10:32:28 +0000 | [diff] [blame] | 431 | puts(buf); |
Stefan Roese | 3e1f1b3 | 2005-08-01 16:49:12 +0200 | [diff] [blame] | 432 | } |
| 433 | putc('\n'); |
| 434 | |
Stefan Roese | 3e1f1b3 | 2005-08-01 16:49:12 +0200 | [diff] [blame] | 435 | return (0); |
| 436 | } |
| 437 | |
Stefan Roese | 3e1f1b3 | 2005-08-01 16:49:12 +0200 | [diff] [blame] | 438 | |
Simon Glass | b4de3f3 | 2017-03-31 08:40:24 -0600 | [diff] [blame^] | 439 | phys_size_t initdram(void) |
Stefan Roese | 3e1f1b3 | 2005-08-01 16:49:12 +0200 | [diff] [blame] | 440 | { |
Masahiro Yamada | 04cfea5 | 2016-09-06 22:17:38 +0900 | [diff] [blame] | 441 | return spd_sdram(); |
Stefan Roese | 3e1f1b3 | 2005-08-01 16:49:12 +0200 | [diff] [blame] | 442 | } |
| 443 | |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 444 | /*----------------------------------------------------------------------------+ |
| 445 | | is_powerpc440ep_pass1. |
| 446 | +----------------------------------------------------------------------------*/ |
| 447 | int is_powerpc440ep_pass1(void) |
| 448 | { |
| 449 | unsigned long pvr; |
| 450 | |
| 451 | pvr = get_pvr(); |
| 452 | |
| 453 | if (pvr == PVR_POWERPC_440EP_PASS1) |
York Sun | 4a59809 | 2013-04-01 11:29:11 -0700 | [diff] [blame] | 454 | return true; |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 455 | else if (pvr == PVR_POWERPC_440EP_PASS2) |
York Sun | 4a59809 | 2013-04-01 11:29:11 -0700 | [diff] [blame] | 456 | return false; |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 457 | else { |
| 458 | printf("brdutil error 3\n"); |
| 459 | for (;;) |
| 460 | ; |
| 461 | } |
| 462 | |
York Sun | 4a59809 | 2013-04-01 11:29:11 -0700 | [diff] [blame] | 463 | return false; |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 464 | } |
| 465 | |
| 466 | /*----------------------------------------------------------------------------+ |
| 467 | | is_nand_selected. |
| 468 | +----------------------------------------------------------------------------*/ |
| 469 | int is_nand_selected(void) |
| 470 | { |
Stefan Roese | 797d857 | 2005-08-11 17:56:56 +0200 | [diff] [blame] | 471 | #ifdef CONFIG_BAMBOO_NAND |
York Sun | 4a59809 | 2013-04-01 11:29:11 -0700 | [diff] [blame] | 472 | return true; |
Stefan Roese | 797d857 | 2005-08-11 17:56:56 +0200 | [diff] [blame] | 473 | #else |
York Sun | 4a59809 | 2013-04-01 11:29:11 -0700 | [diff] [blame] | 474 | return false; |
Stefan Roese | 797d857 | 2005-08-11 17:56:56 +0200 | [diff] [blame] | 475 | #endif |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 476 | } |
| 477 | |
| 478 | /*----------------------------------------------------------------------------+ |
| 479 | | config_on_ebc_cs4_is_small_flash => from EPLD |
| 480 | +----------------------------------------------------------------------------*/ |
| 481 | unsigned char config_on_ebc_cs4_is_small_flash(void) |
| 482 | { |
| 483 | /* Not implemented yet => returns constant value */ |
York Sun | 4a59809 | 2013-04-01 11:29:11 -0700 | [diff] [blame] | 484 | return true; |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 485 | } |
| 486 | |
| 487 | /*----------------------------------------------------------------------------+ |
| 488 | | Ext_bus_cntlr_init. |
| 489 | | Initialize the external bus controller |
| 490 | +----------------------------------------------------------------------------*/ |
| 491 | void ext_bus_cntlr_init(void) |
| 492 | { |
| 493 | unsigned long sdr0_pstrp0, sdr0_sdstp1; |
| 494 | unsigned long bootstrap_settings, boot_selection, ebc_boot_size; |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 495 | int computed_boot_device = BOOT_DEVICE_UNKNOWN; |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 496 | unsigned long ebc0_cs0_bnap_value = 0, ebc0_cs0_bncr_value = 0; |
| 497 | unsigned long ebc0_cs1_bnap_value = 0, ebc0_cs1_bncr_value = 0; |
| 498 | unsigned long ebc0_cs2_bnap_value = 0, ebc0_cs2_bncr_value = 0; |
| 499 | unsigned long ebc0_cs3_bnap_value = 0, ebc0_cs3_bncr_value = 0; |
| 500 | unsigned long ebc0_cs4_bnap_value = 0, ebc0_cs4_bncr_value = 0; |
| 501 | |
| 502 | |
| 503 | /*-------------------------------------------------------------------------+ |
| 504 | | |
| 505 | | PART 1 : Initialize EBC Bank 5 |
| 506 | | ============================== |
| 507 | | Bank5 is always associated to the NVRAM/EPLD. |
| 508 | | It has to be initialized prior to other banks settings computation since |
| 509 | | some board registers values may be needed |
| 510 | | |
| 511 | +-------------------------------------------------------------------------*/ |
| 512 | /* NVRAM - FPGA */ |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 513 | mtebc(PB5AP, EBC0_BNAP_NVRAM_FPGA); |
| 514 | mtebc(PB5CR, EBC0_BNCR_NVRAM_FPGA_CS5); |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 515 | |
| 516 | /*-------------------------------------------------------------------------+ |
| 517 | | |
| 518 | | PART 2 : Determine which boot device was selected |
| 519 | | ========================================= |
| 520 | | |
| 521 | | Read Pin Strap Register in PPC440EP |
| 522 | | In case of boot from IIC, read Serial Device Strap Register1 |
| 523 | | |
| 524 | | Result can either be : |
| 525 | | - Boot from EBC 8bits => SMALL FLASH |
| 526 | | - Boot from EBC 16bits => Large Flash or SRAM |
| 527 | | - Boot from NAND Flash |
| 528 | | - Boot from PCI |
| 529 | | |
| 530 | +-------------------------------------------------------------------------*/ |
| 531 | /* Read Pin Strap Register in PPC440EP */ |
Stefan Roese | 95ca5fa | 2010-09-11 09:31:43 +0200 | [diff] [blame] | 532 | mfsdr(SDR0_PINSTP, sdr0_pstrp0); |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 533 | bootstrap_settings = sdr0_pstrp0 & SDR0_PSTRP0_BOOTSTRAP_MASK; |
| 534 | |
| 535 | /*-------------------------------------------------------------------------+ |
| 536 | | PPC440EP Pass1 |
| 537 | +-------------------------------------------------------------------------*/ |
York Sun | 4a59809 | 2013-04-01 11:29:11 -0700 | [diff] [blame] | 538 | if (is_powerpc440ep_pass1() == true) { |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 539 | switch(bootstrap_settings) { |
| 540 | case SDR0_PSTRP0_BOOTSTRAP_SETTINGS0: |
| 541 | /* Default Strap Settings 0 : CPU 400 - PLB 133 - Boot EBC 8 bit 33MHz */ |
| 542 | /* Boot from Small Flash */ |
| 543 | computed_boot_device = BOOT_FROM_SMALL_FLASH; |
| 544 | break; |
| 545 | case SDR0_PSTRP0_BOOTSTRAP_SETTINGS1: |
| 546 | /* Default Strap Settings 1 : CPU 533 - PLB 133 - Boot PCI 66MHz */ |
| 547 | /* Boot from PCI */ |
| 548 | computed_boot_device = BOOT_FROM_PCI; |
| 549 | break; |
| 550 | |
| 551 | case SDR0_PSTRP0_BOOTSTRAP_SETTINGS2: |
| 552 | /* Default Strap Settings 2 : CPU 500 - PLB 100 - Boot NDFC16 66MHz */ |
| 553 | /* Boot from Nand Flash */ |
| 554 | computed_boot_device = BOOT_FROM_NAND_FLASH0; |
| 555 | break; |
| 556 | |
| 557 | case SDR0_PSTRP0_BOOTSTRAP_SETTINGS3: |
| 558 | /* Default Strap Settings 3 : CPU 333 - PLB 133 - Boot EBC 8 bit 66MHz */ |
| 559 | /* Boot from Small Flash */ |
| 560 | computed_boot_device = BOOT_FROM_SMALL_FLASH; |
| 561 | break; |
| 562 | |
| 563 | case SDR0_PSTRP0_BOOTSTRAP_IIC_A8_EN: |
| 564 | case SDR0_PSTRP0_BOOTSTRAP_IIC_A4_EN: |
| 565 | /* Boot Settings in IIC EEprom address 0xA8 or 0xA4 */ |
| 566 | /* Read Serial Device Strap Register1 in PPC440EP */ |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 567 | mfsdr(SDR0_SDSTP1, sdr0_sdstp1); |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 568 | boot_selection = sdr0_sdstp1 & SDR0_SDSTP1_BOOT_SEL_MASK; |
| 569 | ebc_boot_size = sdr0_sdstp1 & SDR0_SDSTP1_EBC_ROM_BS_MASK; |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 570 | |
| 571 | switch(boot_selection) { |
| 572 | case SDR0_SDSTP1_BOOT_SEL_EBC: |
| 573 | switch(ebc_boot_size) { |
| 574 | case SDR0_SDSTP1_EBC_ROM_BS_16BIT: |
| 575 | computed_boot_device = BOOT_FROM_LARGE_FLASH_OR_SRAM; |
| 576 | break; |
| 577 | case SDR0_SDSTP1_EBC_ROM_BS_8BIT: |
| 578 | computed_boot_device = BOOT_FROM_SMALL_FLASH; |
| 579 | break; |
| 580 | } |
| 581 | break; |
| 582 | |
| 583 | case SDR0_SDSTP1_BOOT_SEL_PCI: |
| 584 | computed_boot_device = BOOT_FROM_PCI; |
| 585 | break; |
| 586 | |
| 587 | case SDR0_SDSTP1_BOOT_SEL_NDFC: |
| 588 | computed_boot_device = BOOT_FROM_NAND_FLASH0; |
| 589 | break; |
| 590 | } |
| 591 | break; |
| 592 | } |
| 593 | } |
| 594 | |
| 595 | /*-------------------------------------------------------------------------+ |
| 596 | | PPC440EP Pass2 |
| 597 | +-------------------------------------------------------------------------*/ |
| 598 | else { |
| 599 | switch(bootstrap_settings) { |
| 600 | case SDR0_PSTRP0_BOOTSTRAP_SETTINGS0: |
| 601 | /* Default Strap Settings 0 : CPU 400 - PLB 133 - Boot EBC 8 bit 33MHz */ |
| 602 | /* Boot from Small Flash */ |
| 603 | computed_boot_device = BOOT_FROM_SMALL_FLASH; |
| 604 | break; |
| 605 | case SDR0_PSTRP0_BOOTSTRAP_SETTINGS1: |
| 606 | /* Default Strap Settings 1 : CPU 333 - PLB 133 - Boot PCI 66MHz */ |
| 607 | /* Boot from PCI */ |
| 608 | computed_boot_device = BOOT_FROM_PCI; |
| 609 | break; |
| 610 | |
| 611 | case SDR0_PSTRP0_BOOTSTRAP_SETTINGS2: |
| 612 | /* Default Strap Settings 2 : CPU 400 - PLB 100 - Boot NDFC16 33MHz */ |
| 613 | /* Boot from Nand Flash */ |
| 614 | computed_boot_device = BOOT_FROM_NAND_FLASH0; |
| 615 | break; |
| 616 | |
| 617 | case SDR0_PSTRP0_BOOTSTRAP_SETTINGS3: |
| 618 | /* Default Strap Settings 3 : CPU 400 - PLB 100 - Boot EBC 16 bit 33MHz */ |
| 619 | /* Boot from Large Flash or SRAM */ |
| 620 | computed_boot_device = BOOT_FROM_LARGE_FLASH_OR_SRAM; |
| 621 | break; |
| 622 | |
| 623 | case SDR0_PSTRP0_BOOTSTRAP_SETTINGS4: |
| 624 | /* Default Strap Settings 4 : CPU 333 - PLB 133 - Boot EBC 16 bit 66MHz */ |
| 625 | /* Boot from Large Flash or SRAM */ |
| 626 | computed_boot_device = BOOT_FROM_LARGE_FLASH_OR_SRAM; |
| 627 | break; |
| 628 | |
| 629 | case SDR0_PSTRP0_BOOTSTRAP_SETTINGS6: |
| 630 | /* Default Strap Settings 6 : CPU 400 - PLB 100 - Boot PCI 33MHz */ |
| 631 | /* Boot from PCI */ |
| 632 | computed_boot_device = BOOT_FROM_PCI; |
| 633 | break; |
| 634 | |
| 635 | case SDR0_PSTRP0_BOOTSTRAP_IIC_A8_EN: |
| 636 | case SDR0_PSTRP0_BOOTSTRAP_IIC_A4_EN: |
| 637 | /* Default Strap Settings 5-7 */ |
| 638 | /* Boot Settings in IIC EEprom address 0xA8 or 0xA4 */ |
| 639 | /* Read Serial Device Strap Register1 in PPC440EP */ |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 640 | mfsdr(SDR0_SDSTP1, sdr0_sdstp1); |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 641 | boot_selection = sdr0_sdstp1 & SDR0_SDSTP1_BOOT_SEL_MASK; |
| 642 | ebc_boot_size = sdr0_sdstp1 & SDR0_SDSTP1_EBC_ROM_BS_MASK; |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 643 | |
| 644 | switch(boot_selection) { |
| 645 | case SDR0_SDSTP1_BOOT_SEL_EBC: |
| 646 | switch(ebc_boot_size) { |
| 647 | case SDR0_SDSTP1_EBC_ROM_BS_16BIT: |
| 648 | computed_boot_device = BOOT_FROM_LARGE_FLASH_OR_SRAM; |
| 649 | break; |
| 650 | case SDR0_SDSTP1_EBC_ROM_BS_8BIT: |
| 651 | computed_boot_device = BOOT_FROM_SMALL_FLASH; |
| 652 | break; |
| 653 | } |
| 654 | break; |
| 655 | |
| 656 | case SDR0_SDSTP1_BOOT_SEL_PCI: |
| 657 | computed_boot_device = BOOT_FROM_PCI; |
| 658 | break; |
| 659 | |
| 660 | case SDR0_SDSTP1_BOOT_SEL_NDFC: |
| 661 | computed_boot_device = BOOT_FROM_NAND_FLASH0; |
| 662 | break; |
| 663 | } |
| 664 | break; |
| 665 | } |
| 666 | } |
| 667 | |
| 668 | /*-------------------------------------------------------------------------+ |
| 669 | | |
| 670 | | PART 3 : Compute EBC settings depending on selected boot device |
| 671 | | ====== ====================================================== |
| 672 | | |
| 673 | | Resulting EBC init will be among following configurations : |
| 674 | | |
| 675 | | - Boot from EBC 8bits => boot from SMALL FLASH selected |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 676 | | EBC-CS0 = Small Flash |
| 677 | | EBC-CS1,2,3 = NAND Flash or |
| 678 | | Exp.Slot depending on Soft Config |
| 679 | | EBC-CS4 = SRAM/Large Flash or |
| 680 | | Large Flash/SRAM depending on jumpers |
| 681 | | EBC-CS5 = NVRAM / EPLD |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 682 | | |
| 683 | | - Boot from EBC 16bits => boot from Large Flash or SRAM selected |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 684 | | EBC-CS0 = SRAM/Large Flash or |
| 685 | | Large Flash/SRAM depending on jumpers |
| 686 | | EBC-CS1,2,3 = NAND Flash or |
| 687 | | Exp.Slot depending on Software Configuration |
| 688 | | EBC-CS4 = Small Flash |
| 689 | | EBC-CS5 = NVRAM / EPLD |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 690 | | |
| 691 | | - Boot from NAND Flash |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 692 | | EBC-CS0 = NAND Flash0 |
| 693 | | EBC-CS1,2,3 = NAND Flash1 |
| 694 | | EBC-CS4 = SRAM/Large Flash or |
| 695 | | Large Flash/SRAM depending on jumpers |
| 696 | | EBC-CS5 = NVRAM / EPLD |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 697 | | |
| 698 | | - Boot from PCI |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 699 | | EBC-CS0 = ... |
| 700 | | EBC-CS1,2,3 = NAND Flash or |
| 701 | | Exp.Slot depending on Software Configuration |
| 702 | | EBC-CS4 = SRAM/Large Flash or |
| 703 | | Large Flash/SRAM or |
| 704 | | Small Flash depending on jumpers |
| 705 | | EBC-CS5 = NVRAM / EPLD |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 706 | | |
| 707 | +-------------------------------------------------------------------------*/ |
| 708 | |
| 709 | switch(computed_boot_device) { |
| 710 | /*------------------------------------------------------------------------- */ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 711 | case BOOT_FROM_SMALL_FLASH: |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 712 | /*------------------------------------------------------------------------- */ |
| 713 | ebc0_cs0_bnap_value = EBC0_BNAP_SMALL_FLASH; |
| 714 | ebc0_cs0_bncr_value = EBC0_BNCR_SMALL_FLASH_CS0; |
York Sun | 4a59809 | 2013-04-01 11:29:11 -0700 | [diff] [blame] | 715 | if ((is_nand_selected()) == true) { |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 716 | /* NAND Flash */ |
| 717 | ebc0_cs1_bnap_value = EBC0_BNAP_NAND_FLASH; |
| 718 | ebc0_cs1_bncr_value = EBC0_BNCR_NAND_FLASH_CS1; |
Stefan Roese | 797d857 | 2005-08-11 17:56:56 +0200 | [diff] [blame] | 719 | ebc0_cs2_bnap_value = EBC0_BNAP_NAND_FLASH; |
| 720 | ebc0_cs2_bncr_value = EBC0_BNCR_NAND_FLASH_CS2; |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 721 | ebc0_cs3_bnap_value = 0; |
| 722 | ebc0_cs3_bncr_value = 0; |
| 723 | } else { |
| 724 | /* Expansion Slot */ |
| 725 | ebc0_cs1_bnap_value = 0; |
| 726 | ebc0_cs1_bncr_value = 0; |
| 727 | ebc0_cs2_bnap_value = 0; |
| 728 | ebc0_cs2_bncr_value = 0; |
| 729 | ebc0_cs3_bnap_value = 0; |
| 730 | ebc0_cs3_bncr_value = 0; |
| 731 | } |
| 732 | ebc0_cs4_bnap_value = EBC0_BNAP_LARGE_FLASH_OR_SRAM; |
| 733 | ebc0_cs4_bncr_value = EBC0_BNCR_LARGE_FLASH_OR_SRAM_CS4; |
| 734 | |
| 735 | break; |
| 736 | |
| 737 | /*------------------------------------------------------------------------- */ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 738 | case BOOT_FROM_LARGE_FLASH_OR_SRAM: |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 739 | /*------------------------------------------------------------------------- */ |
| 740 | ebc0_cs0_bnap_value = EBC0_BNAP_LARGE_FLASH_OR_SRAM; |
| 741 | ebc0_cs0_bncr_value = EBC0_BNCR_LARGE_FLASH_OR_SRAM_CS0; |
York Sun | 4a59809 | 2013-04-01 11:29:11 -0700 | [diff] [blame] | 742 | if ((is_nand_selected()) == true) { |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 743 | /* NAND Flash */ |
| 744 | ebc0_cs1_bnap_value = EBC0_BNAP_NAND_FLASH; |
| 745 | ebc0_cs1_bncr_value = EBC0_BNCR_NAND_FLASH_CS1; |
| 746 | ebc0_cs2_bnap_value = 0; |
| 747 | ebc0_cs2_bncr_value = 0; |
| 748 | ebc0_cs3_bnap_value = 0; |
| 749 | ebc0_cs3_bncr_value = 0; |
| 750 | } else { |
| 751 | /* Expansion Slot */ |
| 752 | ebc0_cs1_bnap_value = 0; |
| 753 | ebc0_cs1_bncr_value = 0; |
| 754 | ebc0_cs2_bnap_value = 0; |
| 755 | ebc0_cs2_bncr_value = 0; |
| 756 | ebc0_cs3_bnap_value = 0; |
| 757 | ebc0_cs3_bncr_value = 0; |
| 758 | } |
| 759 | ebc0_cs4_bnap_value = EBC0_BNAP_SMALL_FLASH; |
| 760 | ebc0_cs4_bncr_value = EBC0_BNCR_SMALL_FLASH_CS4; |
| 761 | |
| 762 | break; |
| 763 | |
| 764 | /*------------------------------------------------------------------------- */ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 765 | case BOOT_FROM_NAND_FLASH0: |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 766 | /*------------------------------------------------------------------------- */ |
Stefan Roese | c769864 | 2007-06-01 15:19:29 +0200 | [diff] [blame] | 767 | ebc0_cs0_bnap_value = EBC0_BNAP_NAND_FLASH; |
| 768 | ebc0_cs0_bncr_value = EBC0_BNCR_NAND_FLASH_CS1; |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 769 | |
Stefan Roese | c769864 | 2007-06-01 15:19:29 +0200 | [diff] [blame] | 770 | ebc0_cs1_bnap_value = 0; |
| 771 | ebc0_cs1_bncr_value = 0; |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 772 | ebc0_cs2_bnap_value = 0; |
| 773 | ebc0_cs2_bncr_value = 0; |
| 774 | ebc0_cs3_bnap_value = 0; |
| 775 | ebc0_cs3_bncr_value = 0; |
| 776 | |
| 777 | /* Large Flash or SRAM */ |
| 778 | ebc0_cs4_bnap_value = EBC0_BNAP_LARGE_FLASH_OR_SRAM; |
| 779 | ebc0_cs4_bncr_value = EBC0_BNCR_LARGE_FLASH_OR_SRAM_CS4; |
| 780 | |
| 781 | break; |
| 782 | |
| 783 | /*------------------------------------------------------------------------- */ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 784 | case BOOT_FROM_PCI: |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 785 | /*------------------------------------------------------------------------- */ |
| 786 | ebc0_cs0_bnap_value = 0; |
| 787 | ebc0_cs0_bncr_value = 0; |
| 788 | |
York Sun | 4a59809 | 2013-04-01 11:29:11 -0700 | [diff] [blame] | 789 | if ((is_nand_selected()) == true) { |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 790 | /* NAND Flash */ |
| 791 | ebc0_cs1_bnap_value = EBC0_BNAP_NAND_FLASH; |
| 792 | ebc0_cs1_bncr_value = EBC0_BNCR_NAND_FLASH_CS1; |
| 793 | ebc0_cs2_bnap_value = 0; |
| 794 | ebc0_cs2_bncr_value = 0; |
| 795 | ebc0_cs3_bnap_value = 0; |
| 796 | ebc0_cs3_bncr_value = 0; |
| 797 | } else { |
| 798 | /* Expansion Slot */ |
| 799 | ebc0_cs1_bnap_value = 0; |
| 800 | ebc0_cs1_bncr_value = 0; |
| 801 | ebc0_cs2_bnap_value = 0; |
| 802 | ebc0_cs2_bncr_value = 0; |
| 803 | ebc0_cs3_bnap_value = 0; |
| 804 | ebc0_cs3_bncr_value = 0; |
| 805 | } |
| 806 | |
York Sun | 4a59809 | 2013-04-01 11:29:11 -0700 | [diff] [blame] | 807 | if ((config_on_ebc_cs4_is_small_flash()) == true) { |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 808 | /* Small Flash */ |
| 809 | ebc0_cs4_bnap_value = EBC0_BNAP_SMALL_FLASH; |
| 810 | ebc0_cs4_bncr_value = EBC0_BNCR_SMALL_FLASH_CS4; |
| 811 | } else { |
| 812 | /* Large Flash or SRAM */ |
| 813 | ebc0_cs4_bnap_value = EBC0_BNAP_LARGE_FLASH_OR_SRAM; |
| 814 | ebc0_cs4_bncr_value = EBC0_BNCR_LARGE_FLASH_OR_SRAM_CS4; |
| 815 | } |
| 816 | |
| 817 | break; |
| 818 | |
| 819 | /*------------------------------------------------------------------------- */ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 820 | case BOOT_DEVICE_UNKNOWN: |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 821 | /*------------------------------------------------------------------------- */ |
| 822 | /* Error */ |
| 823 | break; |
| 824 | |
| 825 | } |
| 826 | |
| 827 | |
| 828 | /*-------------------------------------------------------------------------+ |
| 829 | | Initialize EBC CONFIG |
| 830 | +-------------------------------------------------------------------------*/ |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 831 | mtdcr(EBC0_CFGADDR, EBC0_CFG); |
| 832 | mtdcr(EBC0_CFGDATA, EBC0_CFG_EBTC_DRIVEN | |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 833 | EBC0_CFG_PTD_ENABLED | |
| 834 | EBC0_CFG_RTC_2048PERCLK | |
| 835 | EBC0_CFG_EMPL_LOW | |
| 836 | EBC0_CFG_EMPH_LOW | |
| 837 | EBC0_CFG_CSTC_DRIVEN | |
| 838 | EBC0_CFG_BPF_ONEDW | |
| 839 | EBC0_CFG_EMS_8BIT | |
| 840 | EBC0_CFG_PME_DISABLED | |
| 841 | EBC0_CFG_PMT_ENCODE(0) ); |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 842 | |
| 843 | /*-------------------------------------------------------------------------+ |
| 844 | | Initialize EBC Bank 0-4 |
| 845 | +-------------------------------------------------------------------------*/ |
| 846 | /* EBC Bank0 */ |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 847 | mtebc(PB0AP, ebc0_cs0_bnap_value); |
| 848 | mtebc(PB0CR, ebc0_cs0_bncr_value); |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 849 | /* EBC Bank1 */ |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 850 | mtebc(PB1AP, ebc0_cs1_bnap_value); |
| 851 | mtebc(PB1CR, ebc0_cs1_bncr_value); |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 852 | /* EBC Bank2 */ |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 853 | mtebc(PB2AP, ebc0_cs2_bnap_value); |
| 854 | mtebc(PB2CR, ebc0_cs2_bncr_value); |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 855 | /* EBC Bank3 */ |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 856 | mtebc(PB3AP, ebc0_cs3_bnap_value); |
| 857 | mtebc(PB3CR, ebc0_cs3_bncr_value); |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 858 | /* EBC Bank4 */ |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 859 | mtebc(PB4AP, ebc0_cs4_bnap_value); |
| 860 | mtebc(PB4CR, ebc0_cs4_bncr_value); |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 861 | |
| 862 | return; |
| 863 | } |
| 864 | |
| 865 | |
| 866 | /*----------------------------------------------------------------------------+ |
| 867 | | get_uart_configuration. |
| 868 | +----------------------------------------------------------------------------*/ |
| 869 | uart_config_nb_t get_uart_configuration(void) |
| 870 | { |
Stefan Roese | 797d857 | 2005-08-11 17:56:56 +0200 | [diff] [blame] | 871 | return (L4); |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 872 | } |
| 873 | |
| 874 | /*----------------------------------------------------------------------------+ |
| 875 | | set_phy_configuration_through_fpga => to EPLD |
| 876 | +----------------------------------------------------------------------------*/ |
| 877 | void set_phy_configuration_through_fpga(zmii_config_t config) |
| 878 | { |
| 879 | |
| 880 | unsigned long fpga_selection_reg; |
| 881 | |
| 882 | fpga_selection_reg = in8(FPGA_SELECTION_1_REG) & ~FPGA_SEL_1_REG_PHY_MASK; |
| 883 | |
| 884 | switch(config) |
| 885 | { |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 886 | case ZMII_CONFIGURATION_IS_MII: |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 887 | fpga_selection_reg = fpga_selection_reg | FPGA_SEL_1_REG_MII; |
| 888 | break; |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 889 | case ZMII_CONFIGURATION_IS_RMII: |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 890 | fpga_selection_reg = fpga_selection_reg | FPGA_SEL_1_REG_RMII; |
| 891 | break; |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 892 | case ZMII_CONFIGURATION_IS_SMII: |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 893 | fpga_selection_reg = fpga_selection_reg | FPGA_SEL_1_REG_SMII; |
| 894 | break; |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 895 | case ZMII_CONFIGURATION_UNKNOWN: |
| 896 | default: |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 897 | break; |
| 898 | } |
| 899 | out8(FPGA_SELECTION_1_REG,fpga_selection_reg); |
| 900 | |
| 901 | } |
| 902 | |
| 903 | /*----------------------------------------------------------------------------+ |
| 904 | | scp_selection_in_fpga. |
| 905 | +----------------------------------------------------------------------------*/ |
| 906 | void scp_selection_in_fpga(void) |
| 907 | { |
| 908 | unsigned long fpga_selection_2_reg; |
| 909 | |
| 910 | fpga_selection_2_reg = in8(FPGA_SELECTION_2_REG) & ~FPGA_SEL2_REG_IIC1_SCP_SEL_MASK; |
| 911 | fpga_selection_2_reg |= FPGA_SEL2_REG_SEL_SCP; |
| 912 | out8(FPGA_SELECTION_2_REG,fpga_selection_2_reg); |
| 913 | } |
| 914 | |
| 915 | /*----------------------------------------------------------------------------+ |
| 916 | | iic1_selection_in_fpga. |
| 917 | +----------------------------------------------------------------------------*/ |
| 918 | void iic1_selection_in_fpga(void) |
| 919 | { |
| 920 | unsigned long fpga_selection_2_reg; |
| 921 | |
| 922 | fpga_selection_2_reg = in8(FPGA_SELECTION_2_REG) & ~FPGA_SEL2_REG_IIC1_SCP_SEL_MASK; |
| 923 | fpga_selection_2_reg |= FPGA_SEL2_REG_SEL_IIC1; |
| 924 | out8(FPGA_SELECTION_2_REG,fpga_selection_2_reg); |
| 925 | } |
| 926 | |
| 927 | /*----------------------------------------------------------------------------+ |
| 928 | | dma_a_b_selection_in_fpga. |
| 929 | +----------------------------------------------------------------------------*/ |
| 930 | void dma_a_b_selection_in_fpga(void) |
| 931 | { |
| 932 | unsigned long fpga_selection_2_reg; |
| 933 | |
| 934 | fpga_selection_2_reg = in8(FPGA_SELECTION_2_REG) | FPGA_SEL2_REG_SEL_DMA_A_B; |
| 935 | out8(FPGA_SELECTION_2_REG,fpga_selection_2_reg); |
| 936 | } |
| 937 | |
| 938 | /*----------------------------------------------------------------------------+ |
| 939 | | dma_a_b_unselect_in_fpga. |
| 940 | +----------------------------------------------------------------------------*/ |
| 941 | void dma_a_b_unselect_in_fpga(void) |
| 942 | { |
| 943 | unsigned long fpga_selection_2_reg; |
| 944 | |
| 945 | fpga_selection_2_reg = in8(FPGA_SELECTION_2_REG) & ~FPGA_SEL2_REG_SEL_DMA_A_B; |
| 946 | out8(FPGA_SELECTION_2_REG,fpga_selection_2_reg); |
| 947 | } |
| 948 | |
| 949 | /*----------------------------------------------------------------------------+ |
| 950 | | dma_c_d_selection_in_fpga. |
| 951 | +----------------------------------------------------------------------------*/ |
| 952 | void dma_c_d_selection_in_fpga(void) |
| 953 | { |
| 954 | unsigned long fpga_selection_2_reg; |
| 955 | |
| 956 | fpga_selection_2_reg = in8(FPGA_SELECTION_2_REG) | FPGA_SEL2_REG_SEL_DMA_C_D; |
| 957 | out8(FPGA_SELECTION_2_REG,fpga_selection_2_reg); |
| 958 | } |
| 959 | |
| 960 | /*----------------------------------------------------------------------------+ |
| 961 | | dma_c_d_unselect_in_fpga. |
| 962 | +----------------------------------------------------------------------------*/ |
| 963 | void dma_c_d_unselect_in_fpga(void) |
Stefan Roese | 3e1f1b3 | 2005-08-01 16:49:12 +0200 | [diff] [blame] | 964 | { |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 965 | unsigned long fpga_selection_2_reg; |
Stefan Roese | 3e1f1b3 | 2005-08-01 16:49:12 +0200 | [diff] [blame] | 966 | |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 967 | fpga_selection_2_reg = in8(FPGA_SELECTION_2_REG) & ~FPGA_SEL2_REG_SEL_DMA_C_D; |
| 968 | out8(FPGA_SELECTION_2_REG,fpga_selection_2_reg); |
Stefan Roese | 3e1f1b3 | 2005-08-01 16:49:12 +0200 | [diff] [blame] | 969 | } |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 970 | |
| 971 | /*----------------------------------------------------------------------------+ |
| 972 | | usb2_device_selection_in_fpga. |
| 973 | +----------------------------------------------------------------------------*/ |
| 974 | void usb2_device_selection_in_fpga(void) |
| 975 | { |
| 976 | unsigned long fpga_selection_1_reg; |
| 977 | |
| 978 | fpga_selection_1_reg = in8(FPGA_SELECTION_1_REG) | FPGA_SEL_1_REG_USB2_DEV_SEL; |
| 979 | out8(FPGA_SELECTION_1_REG,fpga_selection_1_reg); |
| 980 | } |
| 981 | |
| 982 | /*----------------------------------------------------------------------------+ |
| 983 | | usb2_device_reset_through_fpga. |
| 984 | +----------------------------------------------------------------------------*/ |
| 985 | void usb2_device_reset_through_fpga(void) |
| 986 | { |
| 987 | /* Perform soft Reset pulse */ |
| 988 | unsigned long fpga_reset_reg; |
| 989 | int i; |
| 990 | |
| 991 | fpga_reset_reg = in8(FPGA_RESET_REG); |
| 992 | out8(FPGA_RESET_REG,fpga_reset_reg | FPGA_RESET_REG_RESET_USB20_DEV); |
| 993 | for (i=0; i<500; i++) |
| 994 | udelay(1000); |
| 995 | out8(FPGA_RESET_REG,fpga_reset_reg); |
| 996 | } |
| 997 | |
| 998 | /*----------------------------------------------------------------------------+ |
| 999 | | usb2_host_selection_in_fpga. |
| 1000 | +----------------------------------------------------------------------------*/ |
| 1001 | void usb2_host_selection_in_fpga(void) |
| 1002 | { |
| 1003 | unsigned long fpga_selection_1_reg; |
| 1004 | |
| 1005 | fpga_selection_1_reg = in8(FPGA_SELECTION_1_REG) | FPGA_SEL_1_REG_USB2_HOST_SEL; |
| 1006 | out8(FPGA_SELECTION_1_REG,fpga_selection_1_reg); |
| 1007 | } |
| 1008 | |
| 1009 | /*----------------------------------------------------------------------------+ |
| 1010 | | ndfc_selection_in_fpga. |
| 1011 | +----------------------------------------------------------------------------*/ |
| 1012 | void ndfc_selection_in_fpga(void) |
| 1013 | { |
| 1014 | unsigned long fpga_selection_1_reg; |
| 1015 | |
| 1016 | fpga_selection_1_reg = in8(FPGA_SELECTION_1_REG) &~FPGA_SEL_1_REG_NF_SELEC_MASK; |
| 1017 | fpga_selection_1_reg |= FPGA_SEL_1_REG_NF0_SEL_BY_NFCS1; |
Stefan Roese | 797d857 | 2005-08-11 17:56:56 +0200 | [diff] [blame] | 1018 | fpga_selection_1_reg |= FPGA_SEL_1_REG_NF1_SEL_BY_NFCS2; |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1019 | out8(FPGA_SELECTION_1_REG,fpga_selection_1_reg); |
| 1020 | } |
| 1021 | |
| 1022 | /*----------------------------------------------------------------------------+ |
| 1023 | | uart_selection_in_fpga. |
| 1024 | +----------------------------------------------------------------------------*/ |
| 1025 | void uart_selection_in_fpga(uart_config_nb_t uart_config) |
| 1026 | { |
| 1027 | /* FPGA register */ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1028 | unsigned char fpga_selection_3_reg; |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1029 | |
| 1030 | /* Read FPGA Reagister */ |
| 1031 | fpga_selection_3_reg = in8(FPGA_SELECTION_3_REG); |
| 1032 | |
| 1033 | switch (uart_config) |
| 1034 | { |
| 1035 | case L1: |
| 1036 | /* ----------------------------------------------------------------------- */ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1037 | /* L1 configuration: UART0 = 8 pins */ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1038 | /* ----------------------------------------------------------------------- */ |
| 1039 | /* Configure FPGA */ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1040 | fpga_selection_3_reg = fpga_selection_3_reg & ~FPGA_SEL3_REG_SEL_UART_CONFIG_MASK; |
| 1041 | fpga_selection_3_reg = fpga_selection_3_reg | FPGA_SEL3_REG_SEL_UART_CONFIG1; |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1042 | out8(FPGA_SELECTION_3_REG, fpga_selection_3_reg); |
| 1043 | |
| 1044 | break; |
| 1045 | |
| 1046 | case L2: |
| 1047 | /* ----------------------------------------------------------------------- */ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1048 | /* L2 configuration: UART0 = 4 pins */ |
| 1049 | /* UART1 = 4 pins */ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1050 | /* ----------------------------------------------------------------------- */ |
| 1051 | /* Configure FPGA */ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1052 | fpga_selection_3_reg = fpga_selection_3_reg & ~FPGA_SEL3_REG_SEL_UART_CONFIG_MASK; |
| 1053 | fpga_selection_3_reg = fpga_selection_3_reg | FPGA_SEL3_REG_SEL_UART_CONFIG2; |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1054 | out8(FPGA_SELECTION_3_REG, fpga_selection_3_reg); |
| 1055 | |
| 1056 | break; |
| 1057 | |
| 1058 | case L3: |
| 1059 | /* ----------------------------------------------------------------------- */ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1060 | /* L3 configuration: UART0 = 4 pins */ |
| 1061 | /* UART1 = 2 pins */ |
| 1062 | /* UART2 = 2 pins */ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1063 | /* ----------------------------------------------------------------------- */ |
| 1064 | /* Configure FPGA */ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1065 | fpga_selection_3_reg = fpga_selection_3_reg & ~FPGA_SEL3_REG_SEL_UART_CONFIG_MASK; |
| 1066 | fpga_selection_3_reg = fpga_selection_3_reg | FPGA_SEL3_REG_SEL_UART_CONFIG3; |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1067 | out8(FPGA_SELECTION_3_REG, fpga_selection_3_reg); |
| 1068 | break; |
| 1069 | |
| 1070 | case L4: |
| 1071 | /* Configure FPGA */ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1072 | fpga_selection_3_reg = fpga_selection_3_reg & ~FPGA_SEL3_REG_SEL_UART_CONFIG_MASK; |
| 1073 | fpga_selection_3_reg = fpga_selection_3_reg | FPGA_SEL3_REG_SEL_UART_CONFIG4; |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1074 | out8(FPGA_SELECTION_3_REG, fpga_selection_3_reg); |
| 1075 | |
| 1076 | break; |
| 1077 | |
| 1078 | default: |
| 1079 | /* Unsupported UART configuration number */ |
| 1080 | for (;;) |
| 1081 | ; |
| 1082 | break; |
| 1083 | |
| 1084 | } |
| 1085 | } |
| 1086 | |
| 1087 | |
| 1088 | /*----------------------------------------------------------------------------+ |
| 1089 | | init_default_gpio |
| 1090 | +----------------------------------------------------------------------------*/ |
Eugene OBrien | c59d1a0 | 2007-07-31 10:24:56 +0200 | [diff] [blame] | 1091 | void init_default_gpio(gpio_param_s (*gpio_tab)[GPIO_MAX]) |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1092 | { |
| 1093 | int i; |
| 1094 | |
| 1095 | /* Init GPIO0 */ |
| 1096 | for(i=0; i<GPIO_MAX; i++) |
| 1097 | { |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1098 | gpio_tab[GPIO0][i].add = GPIO0_BASE; |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1099 | gpio_tab[GPIO0][i].in_out = GPIO_DIS; |
| 1100 | gpio_tab[GPIO0][i].alt_nb = GPIO_SEL; |
| 1101 | } |
| 1102 | |
| 1103 | /* Init GPIO1 */ |
| 1104 | for(i=0; i<GPIO_MAX; i++) |
| 1105 | { |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1106 | gpio_tab[GPIO1][i].add = GPIO1_BASE; |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1107 | gpio_tab[GPIO1][i].in_out = GPIO_DIS; |
| 1108 | gpio_tab[GPIO1][i].alt_nb = GPIO_SEL; |
| 1109 | } |
| 1110 | |
| 1111 | /* EBC_CS_N(5) - GPIO0_10 */ |
| 1112 | gpio_tab[GPIO0][10].in_out = GPIO_OUT; |
| 1113 | gpio_tab[GPIO0][10].alt_nb = GPIO_ALT1; |
| 1114 | |
| 1115 | /* EBC_CS_N(4) - GPIO0_9 */ |
| 1116 | gpio_tab[GPIO0][9].in_out = GPIO_OUT; |
| 1117 | gpio_tab[GPIO0][9].alt_nb = GPIO_ALT1; |
| 1118 | } |
| 1119 | |
| 1120 | /*----------------------------------------------------------------------------+ |
| 1121 | | update_uart_ios |
| 1122 | +------------------------------------------------------------------------------ |
| 1123 | | |
| 1124 | | Set UART Configuration in PowerPC440EP |
| 1125 | | |
| 1126 | | +---------------------------------------------------------------------+ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1127 | | | Configuartion | Connector | Nb of pins | Pins | Associated | |
| 1128 | | | Number | Port Name | available | naming | CORE | |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1129 | | +-----------------+---------------+------------+--------+-------------+ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1130 | | | L1 | Port_A | 8 | UART | UART core 0 | |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1131 | | +-----------------+---------------+------------+--------+-------------+ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1132 | | | L2 | Port_A | 4 | UART1 | UART core 0 | |
| 1133 | | | (L2D) | Port_B | 4 | UART2 | UART core 1 | |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1134 | | +-----------------+---------------+------------+--------+-------------+ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1135 | | | L3 | Port_A | 4 | UART1 | UART core 0 | |
| 1136 | | | (L3D) | Port_B | 2 | UART2 | UART core 1 | |
| 1137 | | | | Port_C | 2 | UART3 | UART core 2 | |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1138 | | +-----------------+---------------+------------+--------+-------------+ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1139 | | | | Port_A | 2 | UART1 | UART core 0 | |
| 1140 | | | L4 | Port_B | 2 | UART2 | UART core 1 | |
| 1141 | | | (L4D) | Port_C | 2 | UART3 | UART core 2 | |
| 1142 | | | | Port_D | 2 | UART4 | UART core 3 | |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1143 | | +-----------------+---------------+------------+--------+-------------+ |
| 1144 | | |
| 1145 | | Involved GPIOs |
| 1146 | | |
| 1147 | | +------------------------------------------------------------------------------+ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1148 | | | GPIO | Aternate 1 | I/O | Alternate 2 | I/O | Alternate 3 | I/O | |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1149 | | +---------+------------------+-----+-----------------+-----+-------------+-----+ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1150 | | | GPIO1_2 | UART0_DCD_N | I | UART1_DSR_CTS_N | I | UART2_SOUT | O | |
| 1151 | | | GPIO1_3 | UART0_8PIN_DSR_N | I | UART1_RTS_DTR_N | O | UART2_SIN | I | |
| 1152 | | | GPIO1_4 | UART0_8PIN_CTS_N | I | NA | NA | UART3_SIN | I | |
| 1153 | | | GPIO1_5 | UART0_RTS_N | O | NA | NA | UART3_SOUT | O | |
| 1154 | | | GPIO1_6 | UART0_DTR_N | O | UART1_SOUT | O | NA | NA | |
| 1155 | | | GPIO1_7 | UART0_RI_N | I | UART1_SIN | I | NA | NA | |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1156 | | +------------------------------------------------------------------------------+ |
| 1157 | | |
| 1158 | | |
| 1159 | +----------------------------------------------------------------------------*/ |
| 1160 | |
Eugene OBrien | c59d1a0 | 2007-07-31 10:24:56 +0200 | [diff] [blame] | 1161 | void update_uart_ios(uart_config_nb_t uart_config, gpio_param_s (*gpio_tab)[GPIO_MAX]) |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1162 | { |
| 1163 | switch (uart_config) |
| 1164 | { |
| 1165 | case L1: |
| 1166 | /* ----------------------------------------------------------------------- */ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1167 | /* L1 configuration: UART0 = 8 pins */ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1168 | /* ----------------------------------------------------------------------- */ |
| 1169 | /* Update GPIO Configuration Table */ |
| 1170 | gpio_tab[GPIO1][2].in_out = GPIO_IN; |
| 1171 | gpio_tab[GPIO1][2].alt_nb = GPIO_ALT1; |
| 1172 | |
| 1173 | gpio_tab[GPIO1][3].in_out = GPIO_IN; |
| 1174 | gpio_tab[GPIO1][3].alt_nb = GPIO_ALT1; |
| 1175 | |
| 1176 | gpio_tab[GPIO1][4].in_out = GPIO_IN; |
| 1177 | gpio_tab[GPIO1][4].alt_nb = GPIO_ALT1; |
| 1178 | |
| 1179 | gpio_tab[GPIO1][5].in_out = GPIO_OUT; |
| 1180 | gpio_tab[GPIO1][5].alt_nb = GPIO_ALT1; |
| 1181 | |
| 1182 | gpio_tab[GPIO1][6].in_out = GPIO_OUT; |
| 1183 | gpio_tab[GPIO1][6].alt_nb = GPIO_ALT1; |
| 1184 | |
| 1185 | gpio_tab[GPIO1][7].in_out = GPIO_IN; |
| 1186 | gpio_tab[GPIO1][7].alt_nb = GPIO_ALT1; |
| 1187 | |
| 1188 | break; |
| 1189 | |
| 1190 | case L2: |
| 1191 | /* ----------------------------------------------------------------------- */ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1192 | /* L2 configuration: UART0 = 4 pins */ |
| 1193 | /* UART1 = 4 pins */ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1194 | /* ----------------------------------------------------------------------- */ |
| 1195 | /* Update GPIO Configuration Table */ |
| 1196 | gpio_tab[GPIO1][2].in_out = GPIO_IN; |
| 1197 | gpio_tab[GPIO1][2].alt_nb = GPIO_ALT2; |
| 1198 | |
| 1199 | gpio_tab[GPIO1][3].in_out = GPIO_OUT; |
| 1200 | gpio_tab[GPIO1][3].alt_nb = GPIO_ALT2; |
| 1201 | |
| 1202 | gpio_tab[GPIO1][4].in_out = GPIO_IN; |
| 1203 | gpio_tab[GPIO1][4].alt_nb = GPIO_ALT1; |
| 1204 | |
| 1205 | gpio_tab[GPIO1][5].in_out = GPIO_OUT; |
| 1206 | gpio_tab[GPIO1][5].alt_nb = GPIO_ALT1; |
| 1207 | |
| 1208 | gpio_tab[GPIO1][6].in_out = GPIO_OUT; |
| 1209 | gpio_tab[GPIO1][6].alt_nb = GPIO_ALT2; |
| 1210 | |
| 1211 | gpio_tab[GPIO1][7].in_out = GPIO_IN; |
| 1212 | gpio_tab[GPIO1][7].alt_nb = GPIO_ALT2; |
| 1213 | |
| 1214 | break; |
| 1215 | |
| 1216 | case L3: |
| 1217 | /* ----------------------------------------------------------------------- */ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1218 | /* L3 configuration: UART0 = 4 pins */ |
| 1219 | /* UART1 = 2 pins */ |
| 1220 | /* UART2 = 2 pins */ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1221 | /* ----------------------------------------------------------------------- */ |
| 1222 | /* Update GPIO Configuration Table */ |
| 1223 | gpio_tab[GPIO1][2].in_out = GPIO_OUT; |
| 1224 | gpio_tab[GPIO1][2].alt_nb = GPIO_ALT3; |
| 1225 | |
| 1226 | gpio_tab[GPIO1][3].in_out = GPIO_IN; |
| 1227 | gpio_tab[GPIO1][3].alt_nb = GPIO_ALT3; |
| 1228 | |
| 1229 | gpio_tab[GPIO1][4].in_out = GPIO_IN; |
| 1230 | gpio_tab[GPIO1][4].alt_nb = GPIO_ALT1; |
| 1231 | |
| 1232 | gpio_tab[GPIO1][5].in_out = GPIO_OUT; |
| 1233 | gpio_tab[GPIO1][5].alt_nb = GPIO_ALT1; |
| 1234 | |
| 1235 | gpio_tab[GPIO1][6].in_out = GPIO_OUT; |
| 1236 | gpio_tab[GPIO1][6].alt_nb = GPIO_ALT2; |
| 1237 | |
| 1238 | gpio_tab[GPIO1][7].in_out = GPIO_IN; |
| 1239 | gpio_tab[GPIO1][7].alt_nb = GPIO_ALT2; |
| 1240 | |
| 1241 | break; |
| 1242 | |
| 1243 | case L4: |
| 1244 | /* ----------------------------------------------------------------------- */ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1245 | /* L4 configuration: UART0 = 2 pins */ |
| 1246 | /* UART1 = 2 pins */ |
| 1247 | /* UART2 = 2 pins */ |
| 1248 | /* UART3 = 2 pins */ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1249 | /* ----------------------------------------------------------------------- */ |
| 1250 | /* Update GPIO Configuration Table */ |
| 1251 | gpio_tab[GPIO1][2].in_out = GPIO_OUT; |
| 1252 | gpio_tab[GPIO1][2].alt_nb = GPIO_ALT3; |
| 1253 | |
| 1254 | gpio_tab[GPIO1][3].in_out = GPIO_IN; |
| 1255 | gpio_tab[GPIO1][3].alt_nb = GPIO_ALT3; |
| 1256 | |
| 1257 | gpio_tab[GPIO1][4].in_out = GPIO_IN; |
| 1258 | gpio_tab[GPIO1][4].alt_nb = GPIO_ALT3; |
| 1259 | |
| 1260 | gpio_tab[GPIO1][5].in_out = GPIO_OUT; |
| 1261 | gpio_tab[GPIO1][5].alt_nb = GPIO_ALT3; |
| 1262 | |
| 1263 | gpio_tab[GPIO1][6].in_out = GPIO_OUT; |
| 1264 | gpio_tab[GPIO1][6].alt_nb = GPIO_ALT2; |
| 1265 | |
| 1266 | gpio_tab[GPIO1][7].in_out = GPIO_IN; |
| 1267 | gpio_tab[GPIO1][7].alt_nb = GPIO_ALT2; |
| 1268 | |
| 1269 | break; |
| 1270 | |
| 1271 | default: |
| 1272 | /* Unsupported UART configuration number */ |
| 1273 | printf("ERROR - Unsupported UART configuration number.\n\n"); |
| 1274 | for (;;) |
| 1275 | ; |
| 1276 | break; |
| 1277 | |
| 1278 | } |
| 1279 | |
| 1280 | /* Set input Selection Register on Alt_Receive for UART Input Core */ |
| 1281 | out32(GPIO1_IS1L, (in32(GPIO1_IS1L) | 0x0FC30000)); |
| 1282 | out32(GPIO1_IS2L, (in32(GPIO1_IS2L) | 0x0C030000)); |
| 1283 | out32(GPIO1_IS3L, (in32(GPIO1_IS3L) | 0x03C00000)); |
| 1284 | } |
| 1285 | |
| 1286 | /*----------------------------------------------------------------------------+ |
| 1287 | | update_ndfc_ios(void). |
| 1288 | +----------------------------------------------------------------------------*/ |
Eugene OBrien | c59d1a0 | 2007-07-31 10:24:56 +0200 | [diff] [blame] | 1289 | void update_ndfc_ios(gpio_param_s (*gpio_tab)[GPIO_MAX]) |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1290 | { |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1291 | /* Update GPIO Configuration Table */ |
| 1292 | gpio_tab[GPIO0][6].in_out = GPIO_OUT; /* EBC_CS_N(1) */ |
| 1293 | gpio_tab[GPIO0][6].alt_nb = GPIO_ALT1; |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1294 | |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1295 | gpio_tab[GPIO0][7].in_out = GPIO_OUT; /* EBC_CS_N(2) */ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1296 | gpio_tab[GPIO0][7].alt_nb = GPIO_ALT1; |
| 1297 | |
Stefan Roese | c769864 | 2007-06-01 15:19:29 +0200 | [diff] [blame] | 1298 | #if 0 |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1299 | gpio_tab[GPIO0][7].in_out = GPIO_OUT; /* EBC_CS_N(3) */ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1300 | gpio_tab[GPIO0][7].alt_nb = GPIO_ALT1; |
Stefan Roese | 3e1f1b3 | 2005-08-01 16:49:12 +0200 | [diff] [blame] | 1301 | #endif |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1302 | } |
| 1303 | |
| 1304 | /*----------------------------------------------------------------------------+ |
| 1305 | | update_zii_ios(void). |
| 1306 | +----------------------------------------------------------------------------*/ |
Eugene OBrien | c59d1a0 | 2007-07-31 10:24:56 +0200 | [diff] [blame] | 1307 | void update_zii_ios(gpio_param_s (*gpio_tab)[GPIO_MAX]) |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1308 | { |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1309 | /* Update GPIO Configuration Table */ |
| 1310 | gpio_tab[GPIO0][12].in_out = GPIO_IN; /* ZII_p0Rxd(0) */ |
| 1311 | gpio_tab[GPIO0][12].alt_nb = GPIO_ALT1; |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1312 | |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1313 | gpio_tab[GPIO0][13].in_out = GPIO_IN; /* ZII_p0Rxd(1) */ |
| 1314 | gpio_tab[GPIO0][13].alt_nb = GPIO_ALT1; |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1315 | |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1316 | gpio_tab[GPIO0][14].in_out = GPIO_IN; /* ZII_p0Rxd(2) */ |
| 1317 | gpio_tab[GPIO0][14].alt_nb = GPIO_ALT1; |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1318 | |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1319 | gpio_tab[GPIO0][15].in_out = GPIO_IN; /* ZII_p0Rxd(3) */ |
| 1320 | gpio_tab[GPIO0][15].alt_nb = GPIO_ALT1; |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1321 | |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1322 | gpio_tab[GPIO0][16].in_out = GPIO_OUT; /* ZII_p0Txd(0) */ |
| 1323 | gpio_tab[GPIO0][16].alt_nb = GPIO_ALT1; |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1324 | |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1325 | gpio_tab[GPIO0][17].in_out = GPIO_OUT; /* ZII_p0Txd(1) */ |
| 1326 | gpio_tab[GPIO0][17].alt_nb = GPIO_ALT1; |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1327 | |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1328 | gpio_tab[GPIO0][18].in_out = GPIO_OUT; /* ZII_p0Txd(2) */ |
| 1329 | gpio_tab[GPIO0][18].alt_nb = GPIO_ALT1; |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1330 | |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1331 | gpio_tab[GPIO0][19].in_out = GPIO_OUT; /* ZII_p0Txd(3) */ |
| 1332 | gpio_tab[GPIO0][19].alt_nb = GPIO_ALT1; |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1333 | |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1334 | gpio_tab[GPIO0][20].in_out = GPIO_IN; /* ZII_p0Rx_er */ |
| 1335 | gpio_tab[GPIO0][20].alt_nb = GPIO_ALT1; |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1336 | |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1337 | gpio_tab[GPIO0][21].in_out = GPIO_IN; /* ZII_p0Rx_dv */ |
| 1338 | gpio_tab[GPIO0][21].alt_nb = GPIO_ALT1; |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1339 | |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1340 | gpio_tab[GPIO0][22].in_out = GPIO_IN; /* ZII_p0Crs */ |
| 1341 | gpio_tab[GPIO0][22].alt_nb = GPIO_ALT1; |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1342 | |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1343 | gpio_tab[GPIO0][23].in_out = GPIO_OUT; /* ZII_p0Tx_er */ |
| 1344 | gpio_tab[GPIO0][23].alt_nb = GPIO_ALT1; |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1345 | |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1346 | gpio_tab[GPIO0][24].in_out = GPIO_OUT; /* ZII_p0Tx_en */ |
| 1347 | gpio_tab[GPIO0][24].alt_nb = GPIO_ALT1; |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1348 | |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1349 | gpio_tab[GPIO0][25].in_out = GPIO_IN; /* ZII_p0Col */ |
| 1350 | gpio_tab[GPIO0][25].alt_nb = GPIO_ALT1; |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1351 | |
| 1352 | } |
| 1353 | |
| 1354 | /*----------------------------------------------------------------------------+ |
| 1355 | | update_uic_0_3_irq_ios(). |
| 1356 | +----------------------------------------------------------------------------*/ |
Eugene OBrien | c59d1a0 | 2007-07-31 10:24:56 +0200 | [diff] [blame] | 1357 | void update_uic_0_3_irq_ios(gpio_param_s (*gpio_tab)[GPIO_MAX]) |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1358 | { |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1359 | gpio_tab[GPIO1][8].in_out = GPIO_IN; /* UIC_IRQ(0) */ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1360 | gpio_tab[GPIO1][8].alt_nb = GPIO_ALT1; |
| 1361 | |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1362 | gpio_tab[GPIO1][9].in_out = GPIO_IN; /* UIC_IRQ(1) */ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1363 | gpio_tab[GPIO1][9].alt_nb = GPIO_ALT1; |
| 1364 | |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1365 | gpio_tab[GPIO1][10].in_out = GPIO_IN; /* UIC_IRQ(2) */ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1366 | gpio_tab[GPIO1][10].alt_nb = GPIO_ALT1; |
| 1367 | |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1368 | gpio_tab[GPIO1][11].in_out = GPIO_IN; /* UIC_IRQ(3) */ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1369 | gpio_tab[GPIO1][11].alt_nb = GPIO_ALT1; |
| 1370 | } |
| 1371 | |
| 1372 | /*----------------------------------------------------------------------------+ |
| 1373 | | update_uic_4_9_irq_ios(). |
| 1374 | +----------------------------------------------------------------------------*/ |
Eugene OBrien | c59d1a0 | 2007-07-31 10:24:56 +0200 | [diff] [blame] | 1375 | void update_uic_4_9_irq_ios(gpio_param_s (*gpio_tab)[GPIO_MAX]) |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1376 | { |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1377 | gpio_tab[GPIO1][12].in_out = GPIO_IN; /* UIC_IRQ(4) */ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1378 | gpio_tab[GPIO1][12].alt_nb = GPIO_ALT1; |
| 1379 | |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1380 | gpio_tab[GPIO1][13].in_out = GPIO_IN; /* UIC_IRQ(6) */ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1381 | gpio_tab[GPIO1][13].alt_nb = GPIO_ALT1; |
| 1382 | |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1383 | gpio_tab[GPIO1][14].in_out = GPIO_IN; /* UIC_IRQ(7) */ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1384 | gpio_tab[GPIO1][14].alt_nb = GPIO_ALT1; |
| 1385 | |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1386 | gpio_tab[GPIO1][15].in_out = GPIO_IN; /* UIC_IRQ(8) */ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1387 | gpio_tab[GPIO1][15].alt_nb = GPIO_ALT1; |
| 1388 | |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1389 | gpio_tab[GPIO1][16].in_out = GPIO_IN; /* UIC_IRQ(9) */ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1390 | gpio_tab[GPIO1][16].alt_nb = GPIO_ALT1; |
| 1391 | } |
| 1392 | |
| 1393 | /*----------------------------------------------------------------------------+ |
| 1394 | | update_dma_a_b_ios(). |
| 1395 | +----------------------------------------------------------------------------*/ |
Eugene OBrien | c59d1a0 | 2007-07-31 10:24:56 +0200 | [diff] [blame] | 1396 | void update_dma_a_b_ios(gpio_param_s (*gpio_tab)[GPIO_MAX]) |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1397 | { |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1398 | gpio_tab[GPIO1][12].in_out = GPIO_OUT; /* DMA_ACK(1) */ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1399 | gpio_tab[GPIO1][12].alt_nb = GPIO_ALT2; |
| 1400 | |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1401 | gpio_tab[GPIO1][13].in_out = GPIO_BI; /* DMA_EOT/TC(1) */ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1402 | gpio_tab[GPIO1][13].alt_nb = GPIO_ALT2; |
| 1403 | |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1404 | gpio_tab[GPIO1][14].in_out = GPIO_IN; /* DMA_REQ(0) */ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1405 | gpio_tab[GPIO1][14].alt_nb = GPIO_ALT2; |
| 1406 | |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1407 | gpio_tab[GPIO1][15].in_out = GPIO_OUT; /* DMA_ACK(0) */ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1408 | gpio_tab[GPIO1][15].alt_nb = GPIO_ALT2; |
| 1409 | |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1410 | gpio_tab[GPIO1][16].in_out = GPIO_BI; /* DMA_EOT/TC(0) */ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1411 | gpio_tab[GPIO1][16].alt_nb = GPIO_ALT2; |
| 1412 | } |
| 1413 | |
| 1414 | /*----------------------------------------------------------------------------+ |
| 1415 | | update_dma_c_d_ios(). |
| 1416 | +----------------------------------------------------------------------------*/ |
Eugene OBrien | c59d1a0 | 2007-07-31 10:24:56 +0200 | [diff] [blame] | 1417 | void update_dma_c_d_ios(gpio_param_s (*gpio_tab)[GPIO_MAX]) |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1418 | { |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1419 | gpio_tab[GPIO0][0].in_out = GPIO_IN; /* DMA_REQ(2) */ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1420 | gpio_tab[GPIO0][0].alt_nb = GPIO_ALT2; |
| 1421 | |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1422 | gpio_tab[GPIO0][1].in_out = GPIO_OUT; /* DMA_ACK(2) */ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1423 | gpio_tab[GPIO0][1].alt_nb = GPIO_ALT2; |
| 1424 | |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1425 | gpio_tab[GPIO0][2].in_out = GPIO_BI; /* DMA_EOT/TC(2) */ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1426 | gpio_tab[GPIO0][2].alt_nb = GPIO_ALT2; |
| 1427 | |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1428 | gpio_tab[GPIO0][3].in_out = GPIO_IN; /* DMA_REQ(3) */ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1429 | gpio_tab[GPIO0][3].alt_nb = GPIO_ALT2; |
| 1430 | |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1431 | gpio_tab[GPIO0][4].in_out = GPIO_OUT; /* DMA_ACK(3) */ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1432 | gpio_tab[GPIO0][4].alt_nb = GPIO_ALT2; |
| 1433 | |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1434 | gpio_tab[GPIO0][5].in_out = GPIO_BI; /* DMA_EOT/TC(3) */ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1435 | gpio_tab[GPIO0][5].alt_nb = GPIO_ALT2; |
| 1436 | |
| 1437 | } |
| 1438 | |
| 1439 | /*----------------------------------------------------------------------------+ |
| 1440 | | update_ebc_master_ios(). |
| 1441 | +----------------------------------------------------------------------------*/ |
Eugene OBrien | c59d1a0 | 2007-07-31 10:24:56 +0200 | [diff] [blame] | 1442 | void update_ebc_master_ios(gpio_param_s (*gpio_tab)[GPIO_MAX]) |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1443 | { |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1444 | gpio_tab[GPIO0][27].in_out = GPIO_IN; /* EXT_EBC_REQ */ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1445 | gpio_tab[GPIO0][27].alt_nb = GPIO_ALT1; |
| 1446 | |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1447 | gpio_tab[GPIO0][29].in_out = GPIO_OUT; /* EBC_EXT_HDLA */ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1448 | gpio_tab[GPIO0][29].alt_nb = GPIO_ALT1; |
| 1449 | |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1450 | gpio_tab[GPIO0][30].in_out = GPIO_OUT; /* EBC_EXT_ACK */ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1451 | gpio_tab[GPIO0][30].alt_nb = GPIO_ALT1; |
| 1452 | |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1453 | gpio_tab[GPIO0][31].in_out = GPIO_OUT; /* EBC_EXR_BUSREQ */ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1454 | gpio_tab[GPIO0][31].alt_nb = GPIO_ALT1; |
| 1455 | } |
| 1456 | |
| 1457 | /*----------------------------------------------------------------------------+ |
| 1458 | | update_usb2_device_ios(). |
| 1459 | +----------------------------------------------------------------------------*/ |
Eugene OBrien | c59d1a0 | 2007-07-31 10:24:56 +0200 | [diff] [blame] | 1460 | void update_usb2_device_ios(gpio_param_s (*gpio_tab)[GPIO_MAX]) |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1461 | { |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1462 | gpio_tab[GPIO0][26].in_out = GPIO_IN; /* USB2D_RXVALID */ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1463 | gpio_tab[GPIO0][26].alt_nb = GPIO_ALT2; |
| 1464 | |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1465 | gpio_tab[GPIO0][27].in_out = GPIO_IN; /* USB2D_RXERROR */ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1466 | gpio_tab[GPIO0][27].alt_nb = GPIO_ALT2; |
| 1467 | |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1468 | gpio_tab[GPIO0][28].in_out = GPIO_OUT; /* USB2D_TXVALID */ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1469 | gpio_tab[GPIO0][28].alt_nb = GPIO_ALT2; |
| 1470 | |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1471 | gpio_tab[GPIO0][29].in_out = GPIO_OUT; /* USB2D_PAD_SUSPNDM */ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1472 | gpio_tab[GPIO0][29].alt_nb = GPIO_ALT2; |
| 1473 | |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1474 | gpio_tab[GPIO0][30].in_out = GPIO_OUT; /* USB2D_XCVRSELECT */ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1475 | gpio_tab[GPIO0][30].alt_nb = GPIO_ALT2; |
| 1476 | |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1477 | gpio_tab[GPIO0][31].in_out = GPIO_OUT; /* USB2D_TERMSELECT */ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1478 | gpio_tab[GPIO0][31].alt_nb = GPIO_ALT2; |
| 1479 | |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1480 | gpio_tab[GPIO1][0].in_out = GPIO_OUT; /* USB2D_OPMODE0 */ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1481 | gpio_tab[GPIO1][0].alt_nb = GPIO_ALT1; |
| 1482 | |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1483 | gpio_tab[GPIO1][1].in_out = GPIO_OUT; /* USB2D_OPMODE1 */ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1484 | gpio_tab[GPIO1][1].alt_nb = GPIO_ALT1; |
| 1485 | |
| 1486 | } |
| 1487 | |
| 1488 | /*----------------------------------------------------------------------------+ |
| 1489 | | update_pci_patch_ios(). |
| 1490 | +----------------------------------------------------------------------------*/ |
Eugene OBrien | c59d1a0 | 2007-07-31 10:24:56 +0200 | [diff] [blame] | 1491 | void update_pci_patch_ios(gpio_param_s (*gpio_tab)[GPIO_MAX]) |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1492 | { |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1493 | gpio_tab[GPIO0][29].in_out = GPIO_OUT; /* EBC_EXT_HDLA */ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1494 | gpio_tab[GPIO0][29].alt_nb = GPIO_ALT1; |
| 1495 | } |
| 1496 | |
| 1497 | /*----------------------------------------------------------------------------+ |
Eugene OBrien | c59d1a0 | 2007-07-31 10:24:56 +0200 | [diff] [blame] | 1498 | | set_chip_gpio_configuration(unsigned char gpio_core, |
| 1499 | | gpio_param_s (*gpio_tab)[GPIO_MAX]) |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1500 | | Put the core impacted by clock modification and sharing in reset. |
| 1501 | | Config the select registers to resolve the sharing depending of the config. |
| 1502 | | Configure the GPIO registers. |
| 1503 | | |
| 1504 | +----------------------------------------------------------------------------*/ |
Eugene OBrien | c59d1a0 | 2007-07-31 10:24:56 +0200 | [diff] [blame] | 1505 | void set_chip_gpio_configuration(unsigned char gpio_core, gpio_param_s (*gpio_tab)[GPIO_MAX]) |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1506 | { |
| 1507 | unsigned char i=0, j=0, reg_offset = 0; |
| 1508 | unsigned long gpio_reg, gpio_core_add; |
| 1509 | |
| 1510 | /* GPIO config of the GPIOs 0 to 31 */ |
| 1511 | for (i=0; i<GPIO_MAX; i++, j++) |
| 1512 | { |
| 1513 | if (i == GPIO_MAX/2) |
| 1514 | { |
| 1515 | reg_offset = 4; |
| 1516 | j = i-16; |
| 1517 | } |
| 1518 | |
| 1519 | gpio_core_add = gpio_tab[gpio_core][i].add; |
| 1520 | |
| 1521 | if ( (gpio_tab[gpio_core][i].in_out == GPIO_IN) || |
| 1522 | (gpio_tab[gpio_core][i].in_out == GPIO_BI )) |
| 1523 | { |
| 1524 | switch (gpio_tab[gpio_core][i].alt_nb) |
| 1525 | { |
| 1526 | case GPIO_SEL: |
| 1527 | break; |
| 1528 | |
| 1529 | case GPIO_ALT1: |
| 1530 | gpio_reg = in32(GPIO_IS1(gpio_core_add+reg_offset)) & ~(GPIO_MASK >> (j*2)); |
| 1531 | gpio_reg = gpio_reg | (GPIO_IN_SEL >> (j*2)); |
| 1532 | out32(GPIO_IS1(gpio_core_add+reg_offset), gpio_reg); |
| 1533 | break; |
| 1534 | |
| 1535 | case GPIO_ALT2: |
| 1536 | gpio_reg = in32(GPIO_IS2(gpio_core_add+reg_offset)) & ~(GPIO_MASK >> (j*2)); |
| 1537 | gpio_reg = gpio_reg | (GPIO_IN_SEL >> (j*2)); |
| 1538 | out32(GPIO_IS2(gpio_core_add+reg_offset), gpio_reg); |
| 1539 | break; |
| 1540 | |
| 1541 | case GPIO_ALT3: |
| 1542 | gpio_reg = in32(GPIO_IS3(gpio_core_add+reg_offset)) & ~(GPIO_MASK >> (j*2)); |
| 1543 | gpio_reg = gpio_reg | (GPIO_IN_SEL >> (j*2)); |
| 1544 | out32(GPIO_IS3(gpio_core_add+reg_offset), gpio_reg); |
| 1545 | break; |
| 1546 | } |
| 1547 | } |
| 1548 | if ( (gpio_tab[gpio_core][i].in_out == GPIO_OUT) || |
| 1549 | (gpio_tab[gpio_core][i].in_out == GPIO_BI )) |
| 1550 | { |
| 1551 | |
| 1552 | switch (gpio_tab[gpio_core][i].alt_nb) |
| 1553 | { |
| 1554 | case GPIO_SEL: |
| 1555 | break; |
| 1556 | case GPIO_ALT1: |
| 1557 | gpio_reg = in32(GPIO_OS(gpio_core_add+reg_offset)) & ~(GPIO_MASK >> (j*2)); |
| 1558 | gpio_reg = gpio_reg | (GPIO_ALT1_SEL >> (j*2)); |
| 1559 | out32(GPIO_OS(gpio_core_add+reg_offset), gpio_reg); |
| 1560 | gpio_reg = in32(GPIO_TS(gpio_core_add+reg_offset)) & ~(GPIO_MASK >> (j*2)); |
| 1561 | gpio_reg = gpio_reg | (GPIO_ALT1_SEL >> (j*2)); |
| 1562 | out32(GPIO_TS(gpio_core_add+reg_offset), gpio_reg); |
| 1563 | break; |
| 1564 | case GPIO_ALT2: |
| 1565 | gpio_reg = in32(GPIO_OS(gpio_core_add+reg_offset)) & ~(GPIO_MASK >> (j*2)); |
| 1566 | gpio_reg = gpio_reg | (GPIO_ALT2_SEL >> (j*2)); |
| 1567 | out32(GPIO_OS(gpio_core_add+reg_offset), gpio_reg); |
| 1568 | gpio_reg = in32(GPIO_TS(gpio_core_add+reg_offset)) & ~(GPIO_MASK >> (j*2)); |
| 1569 | gpio_reg = gpio_reg | (GPIO_ALT2_SEL >> (j*2)); |
| 1570 | out32(GPIO_TS(gpio_core_add+reg_offset), gpio_reg); |
| 1571 | break; |
| 1572 | case GPIO_ALT3: |
| 1573 | gpio_reg = in32(GPIO_OS(gpio_core_add+reg_offset)) & ~(GPIO_MASK >> (j*2)); |
| 1574 | gpio_reg = gpio_reg | (GPIO_ALT3_SEL >> (j*2)); |
| 1575 | out32(GPIO_OS(gpio_core_add+reg_offset), gpio_reg); |
| 1576 | gpio_reg = in32(GPIO_TS(gpio_core_add+reg_offset)) & ~(GPIO_MASK >> (j*2)); |
| 1577 | gpio_reg = gpio_reg | (GPIO_ALT3_SEL >> (j*2)); |
| 1578 | out32(GPIO_TS(gpio_core_add+reg_offset), gpio_reg); |
| 1579 | break; |
| 1580 | } |
| 1581 | } |
| 1582 | } |
| 1583 | } |
| 1584 | |
| 1585 | /*----------------------------------------------------------------------------+ |
| 1586 | | force_bup_core_selection. |
| 1587 | +----------------------------------------------------------------------------*/ |
| 1588 | void force_bup_core_selection(core_selection_t *core_select_P, config_validity_t *config_val_P) |
| 1589 | { |
| 1590 | /* Pointer invalid */ |
| 1591 | if (core_select_P == NULL) |
| 1592 | { |
| 1593 | printf("Configuration invalid pointer 1\n"); |
| 1594 | for (;;) |
| 1595 | ; |
| 1596 | } |
| 1597 | |
| 1598 | /* L4 Selection */ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1599 | *(core_select_P+UART_CORE0) = CORE_SELECTED; |
| 1600 | *(core_select_P+UART_CORE1) = CORE_SELECTED; |
| 1601 | *(core_select_P+UART_CORE2) = CORE_SELECTED; |
| 1602 | *(core_select_P+UART_CORE3) = CORE_SELECTED; |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1603 | |
| 1604 | /* RMII Selection */ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1605 | *(core_select_P+RMII_SEL) = CORE_SELECTED; |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1606 | |
| 1607 | /* External Interrupt 0-9 selection */ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1608 | *(core_select_P+UIC_0_3) = CORE_SELECTED; |
| 1609 | *(core_select_P+UIC_4_9) = CORE_SELECTED; |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1610 | |
Stefan Roese | 797d857 | 2005-08-11 17:56:56 +0200 | [diff] [blame] | 1611 | *(core_select_P+SCP_CORE) = CORE_SELECTED; |
| 1612 | *(core_select_P+DMA_CHANNEL_CD) = CORE_SELECTED; |
| 1613 | *(core_select_P+PACKET_REJ_FUNC_AVAIL) = CORE_SELECTED; |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1614 | *(core_select_P+USB1_DEVICE) = CORE_SELECTED; |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1615 | |
Stefan Roese | 797d857 | 2005-08-11 17:56:56 +0200 | [diff] [blame] | 1616 | if (is_nand_selected()) { |
| 1617 | *(core_select_P+NAND_FLASH) = CORE_SELECTED; |
| 1618 | } |
| 1619 | |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1620 | *config_val_P = CONFIG_IS_VALID; |
| 1621 | |
| 1622 | } |
| 1623 | |
| 1624 | /*----------------------------------------------------------------------------+ |
| 1625 | | configure_ppc440ep_pins. |
| 1626 | +----------------------------------------------------------------------------*/ |
| 1627 | void configure_ppc440ep_pins(void) |
| 1628 | { |
| 1629 | uart_config_nb_t uart_configuration; |
| 1630 | config_validity_t config_val = CONFIG_IS_INVALID; |
| 1631 | |
| 1632 | /* Create Core Selection Table */ |
| 1633 | core_selection_t ppc440ep_core_selection[MAX_CORE_SELECT_NB] = |
| 1634 | { |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1635 | CORE_NOT_SELECTED, /* IIC_CORE, */ |
| 1636 | CORE_NOT_SELECTED, /* SPC_CORE, */ |
| 1637 | CORE_NOT_SELECTED, /* DMA_CHANNEL_AB, */ |
| 1638 | CORE_NOT_SELECTED, /* UIC_4_9, */ |
| 1639 | CORE_NOT_SELECTED, /* USB2_HOST, */ |
| 1640 | CORE_NOT_SELECTED, /* DMA_CHANNEL_CD, */ |
| 1641 | CORE_NOT_SELECTED, /* USB2_DEVICE, */ |
| 1642 | CORE_NOT_SELECTED, /* PACKET_REJ_FUNC_AVAIL, */ |
| 1643 | CORE_NOT_SELECTED, /* USB1_DEVICE, */ |
| 1644 | CORE_NOT_SELECTED, /* EBC_MASTER, */ |
| 1645 | CORE_NOT_SELECTED, /* NAND_FLASH, */ |
| 1646 | CORE_NOT_SELECTED, /* UART_CORE0, */ |
| 1647 | CORE_NOT_SELECTED, /* UART_CORE1, */ |
| 1648 | CORE_NOT_SELECTED, /* UART_CORE2, */ |
| 1649 | CORE_NOT_SELECTED, /* UART_CORE3, */ |
| 1650 | CORE_NOT_SELECTED, /* MII_SEL, */ |
| 1651 | CORE_NOT_SELECTED, /* RMII_SEL, */ |
| 1652 | CORE_NOT_SELECTED, /* SMII_SEL, */ |
| 1653 | CORE_NOT_SELECTED, /* PACKET_REJ_FUNC_EN */ |
| 1654 | CORE_NOT_SELECTED, /* UIC_0_3 */ |
| 1655 | CORE_NOT_SELECTED, /* USB1_HOST */ |
| 1656 | CORE_NOT_SELECTED /* PCI_PATCH */ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1657 | }; |
| 1658 | |
Eugene OBrien | c59d1a0 | 2007-07-31 10:24:56 +0200 | [diff] [blame] | 1659 | gpio_param_s gpio_tab[GPIO_GROUP_MAX][GPIO_MAX]; |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1660 | |
| 1661 | /* Table Default Initialisation + FPGA Access */ |
Eugene OBrien | c59d1a0 | 2007-07-31 10:24:56 +0200 | [diff] [blame] | 1662 | init_default_gpio(gpio_tab); |
| 1663 | set_chip_gpio_configuration(GPIO0, gpio_tab); |
| 1664 | set_chip_gpio_configuration(GPIO1, gpio_tab); |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1665 | |
| 1666 | /* Update Table */ |
| 1667 | force_bup_core_selection(ppc440ep_core_selection, &config_val); |
| 1668 | #if 0 /* test-only */ |
| 1669 | /* If we are running PIBS 1, force known configuration */ |
| 1670 | update_core_selection_table(ppc440ep_core_selection, &config_val); |
| 1671 | #endif |
| 1672 | |
| 1673 | /*----------------------------------------------------------------------------+ |
| 1674 | | SDR + ios table update + fpga initialization |
| 1675 | +----------------------------------------------------------------------------*/ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1676 | unsigned long sdr0_pfc1 = 0; |
| 1677 | unsigned long sdr0_usb0 = 0; |
| 1678 | unsigned long sdr0_mfr = 0; |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1679 | |
| 1680 | /* PCI Always selected */ |
| 1681 | |
| 1682 | /* I2C Selection */ |
| 1683 | if (ppc440ep_core_selection[IIC_CORE] == CORE_SELECTED) |
| 1684 | { |
| 1685 | sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_SIS_MASK) | SDR0_PFC1_SIS_IIC1_SEL; |
| 1686 | iic1_selection_in_fpga(); |
| 1687 | } |
| 1688 | |
| 1689 | /* SCP Selection */ |
| 1690 | if (ppc440ep_core_selection[SCP_CORE] == CORE_SELECTED) |
| 1691 | { |
| 1692 | sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_SIS_MASK) | SDR0_PFC1_SIS_SCP_SEL; |
| 1693 | scp_selection_in_fpga(); |
| 1694 | } |
| 1695 | |
| 1696 | /* UIC 0:3 Selection */ |
| 1697 | if (ppc440ep_core_selection[UIC_0_3] == CORE_SELECTED) |
| 1698 | { |
Eugene OBrien | c59d1a0 | 2007-07-31 10:24:56 +0200 | [diff] [blame] | 1699 | update_uic_0_3_irq_ios(gpio_tab); |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1700 | dma_a_b_unselect_in_fpga(); |
| 1701 | } |
| 1702 | |
| 1703 | /* UIC 4:9 Selection */ |
| 1704 | if (ppc440ep_core_selection[UIC_4_9] == CORE_SELECTED) |
| 1705 | { |
| 1706 | sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_DIS_MASK) | SDR0_PFC1_DIS_UICIRQ5_SEL; |
Eugene OBrien | c59d1a0 | 2007-07-31 10:24:56 +0200 | [diff] [blame] | 1707 | update_uic_4_9_irq_ios(gpio_tab); |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1708 | } |
| 1709 | |
| 1710 | /* DMA AB Selection */ |
| 1711 | if (ppc440ep_core_selection[DMA_CHANNEL_AB] == CORE_SELECTED) |
| 1712 | { |
| 1713 | sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_DIS_MASK) | SDR0_PFC1_DIS_DMAR_SEL; |
Eugene OBrien | c59d1a0 | 2007-07-31 10:24:56 +0200 | [diff] [blame] | 1714 | update_dma_a_b_ios(gpio_tab); |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1715 | dma_a_b_selection_in_fpga(); |
| 1716 | } |
| 1717 | |
| 1718 | /* DMA CD Selection */ |
| 1719 | if (ppc440ep_core_selection[DMA_CHANNEL_CD] == CORE_SELECTED) |
| 1720 | { |
Eugene OBrien | c59d1a0 | 2007-07-31 10:24:56 +0200 | [diff] [blame] | 1721 | update_dma_c_d_ios(gpio_tab); |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1722 | dma_c_d_selection_in_fpga(); |
| 1723 | } |
| 1724 | |
| 1725 | /* EBC Master Selection */ |
| 1726 | if (ppc440ep_core_selection[EBC_MASTER] == CORE_SELECTED) |
| 1727 | { |
| 1728 | sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_ERE_MASK) | SDR0_PFC1_ERE_EXTR_SEL; |
| 1729 | sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_UES_MASK) | SDR0_PFC1_UES_EBCHR_SEL; |
Eugene OBrien | c59d1a0 | 2007-07-31 10:24:56 +0200 | [diff] [blame] | 1730 | update_ebc_master_ios(gpio_tab); |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1731 | } |
| 1732 | |
| 1733 | /* PCI Patch Enable */ |
| 1734 | if (ppc440ep_core_selection[PCI_PATCH] == CORE_SELECTED) |
| 1735 | { |
| 1736 | sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_UES_MASK) | SDR0_PFC1_UES_EBCHR_SEL; |
Eugene OBrien | c59d1a0 | 2007-07-31 10:24:56 +0200 | [diff] [blame] | 1737 | update_pci_patch_ios(gpio_tab); |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1738 | } |
| 1739 | |
| 1740 | /* USB2 Host Selection - Not Implemented in PowerPC 440EP Pass1 */ |
| 1741 | if (ppc440ep_core_selection[USB2_HOST] == CORE_SELECTED) |
| 1742 | { |
| 1743 | /* Not Implemented in PowerPC 440EP Pass1-Pass2 */ |
| 1744 | printf("Invalid configuration => USB2 Host selected\n"); |
| 1745 | for (;;) |
| 1746 | ; |
| 1747 | /*usb2_host_selection_in_fpga(); */ |
| 1748 | } |
| 1749 | |
| 1750 | /* USB2.0 Device Selection */ |
| 1751 | if (ppc440ep_core_selection[USB2_DEVICE] == CORE_SELECTED) |
| 1752 | { |
Eugene OBrien | c59d1a0 | 2007-07-31 10:24:56 +0200 | [diff] [blame] | 1753 | update_usb2_device_ios(gpio_tab); |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1754 | sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_UES_MASK) | SDR0_PFC1_UES_USB2D_SEL; |
| 1755 | sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_UPR_MASK) | SDR0_PFC1_UPR_DISABLE; |
| 1756 | |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 1757 | mfsdr(SDR0_USB0, sdr0_usb0); |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1758 | sdr0_usb0 = sdr0_usb0 &~SDR0_USB0_USB_DEVSEL_MASK; |
| 1759 | sdr0_usb0 = sdr0_usb0 | SDR0_USB0_USB20D_DEVSEL; |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 1760 | mtsdr(SDR0_USB0, sdr0_usb0); |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1761 | |
| 1762 | usb2_device_selection_in_fpga(); |
| 1763 | } |
| 1764 | |
| 1765 | /* USB1.1 Device Selection */ |
| 1766 | if (ppc440ep_core_selection[USB1_DEVICE] == CORE_SELECTED) |
| 1767 | { |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 1768 | mfsdr(SDR0_USB0, sdr0_usb0); |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1769 | sdr0_usb0 = sdr0_usb0 &~SDR0_USB0_USB_DEVSEL_MASK; |
| 1770 | sdr0_usb0 = sdr0_usb0 | SDR0_USB0_USB11D_DEVSEL; |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 1771 | mtsdr(SDR0_USB0, sdr0_usb0); |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1772 | } |
| 1773 | |
| 1774 | /* USB1.1 Host Selection */ |
| 1775 | if (ppc440ep_core_selection[USB1_HOST] == CORE_SELECTED) |
| 1776 | { |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 1777 | mfsdr(SDR0_USB0, sdr0_usb0); |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1778 | sdr0_usb0 = sdr0_usb0 &~SDR0_USB0_LEEN_MASK; |
| 1779 | sdr0_usb0 = sdr0_usb0 | SDR0_USB0_LEEN_ENABLE; |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 1780 | mtsdr(SDR0_USB0, sdr0_usb0); |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1781 | } |
| 1782 | |
| 1783 | /* NAND Flash Selection */ |
| 1784 | if (ppc440ep_core_selection[NAND_FLASH] == CORE_SELECTED) |
| 1785 | { |
Eugene OBrien | c59d1a0 | 2007-07-31 10:24:56 +0200 | [diff] [blame] | 1786 | update_ndfc_ios(gpio_tab); |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 1787 | mtsdr(SDR0_CUST0, SDR0_CUST0_MUX_NDFC_SEL | |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1788 | SDR0_CUST0_NDFC_ENABLE | |
| 1789 | SDR0_CUST0_NDFC_BW_8_BIT | |
| 1790 | SDR0_CUST0_NDFC_ARE_MASK | |
Stefan Roese | 797d857 | 2005-08-11 17:56:56 +0200 | [diff] [blame] | 1791 | SDR0_CUST0_CHIPSELGAT_EN1 | |
| 1792 | SDR0_CUST0_CHIPSELGAT_EN2); |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1793 | ndfc_selection_in_fpga(); |
| 1794 | } |
| 1795 | else |
| 1796 | { |
| 1797 | /* Set Mux on EMAC */ |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 1798 | mtsdr(SDR0_CUST0, SDR0_CUST0_MUX_EMAC_SEL); |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1799 | } |
| 1800 | |
| 1801 | /* MII Selection */ |
| 1802 | if (ppc440ep_core_selection[MII_SEL] == CORE_SELECTED) |
| 1803 | { |
Eugene OBrien | c59d1a0 | 2007-07-31 10:24:56 +0200 | [diff] [blame] | 1804 | update_zii_ios(gpio_tab); |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 1805 | mfsdr(SDR0_MFR, sdr0_mfr); |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1806 | sdr0_mfr = (sdr0_mfr & ~SDR0_MFR_ZMII_MODE_MASK) | SDR0_MFR_ZMII_MODE_MII; |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 1807 | mtsdr(SDR0_MFR, sdr0_mfr); |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1808 | |
| 1809 | set_phy_configuration_through_fpga(ZMII_CONFIGURATION_IS_MII); |
| 1810 | } |
| 1811 | |
| 1812 | /* RMII Selection */ |
| 1813 | if (ppc440ep_core_selection[RMII_SEL] == CORE_SELECTED) |
| 1814 | { |
Eugene OBrien | c59d1a0 | 2007-07-31 10:24:56 +0200 | [diff] [blame] | 1815 | update_zii_ios(gpio_tab); |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 1816 | mfsdr(SDR0_MFR, sdr0_mfr); |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1817 | sdr0_mfr = (sdr0_mfr & ~SDR0_MFR_ZMII_MODE_MASK) | SDR0_MFR_ZMII_MODE_RMII_10M; |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 1818 | mtsdr(SDR0_MFR, sdr0_mfr); |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1819 | |
| 1820 | set_phy_configuration_through_fpga(ZMII_CONFIGURATION_IS_RMII); |
| 1821 | } |
| 1822 | |
| 1823 | /* SMII Selection */ |
| 1824 | if (ppc440ep_core_selection[SMII_SEL] == CORE_SELECTED) |
| 1825 | { |
Eugene OBrien | c59d1a0 | 2007-07-31 10:24:56 +0200 | [diff] [blame] | 1826 | update_zii_ios(gpio_tab); |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 1827 | mfsdr(SDR0_MFR, sdr0_mfr); |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1828 | sdr0_mfr = (sdr0_mfr & ~SDR0_MFR_ZMII_MODE_MASK) | SDR0_MFR_ZMII_MODE_SMII; |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 1829 | mtsdr(SDR0_MFR, sdr0_mfr); |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1830 | |
| 1831 | set_phy_configuration_through_fpga(ZMII_CONFIGURATION_IS_SMII); |
| 1832 | } |
| 1833 | |
| 1834 | /* UART Selection */ |
| 1835 | uart_configuration = get_uart_configuration(); |
| 1836 | switch (uart_configuration) |
| 1837 | { |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1838 | case L1: /* L1 Selection */ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1839 | /* UART0 8 pins Only */ |
| 1840 | /*sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U0ME_MASK) | SDR0_PFC1_U0ME_DSR_DTR; */ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1841 | sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U0ME_MASK) |SDR0_PFC1_U0ME_CTS_RTS; /* Chip Pb */ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1842 | sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U0IM_MASK) | SDR0_PFC1_U0IM_8PINS; |
| 1843 | break; |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1844 | case L2: /* L2 Selection */ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1845 | /* UART0 and UART1 4 pins */ |
| 1846 | sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U0ME_MASK) | SDR0_PFC1_U1ME_DSR_DTR; |
| 1847 | sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U0IM_MASK) | SDR0_PFC1_U0IM_4PINS; |
| 1848 | sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U1ME_MASK) | SDR0_PFC1_U1ME_DSR_DTR; |
| 1849 | break; |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1850 | case L3: /* L3 Selection */ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1851 | /* UART0 4 pins, UART1 and UART2 2 pins */ |
| 1852 | sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U0ME_MASK) | SDR0_PFC1_U1ME_DSR_DTR; |
| 1853 | sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U0IM_MASK) | SDR0_PFC1_U0IM_4PINS; |
| 1854 | sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U1ME_MASK) | SDR0_PFC1_U1ME_DSR_DTR; |
| 1855 | break; |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1856 | case L4: /* L4 Selection */ |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1857 | /* UART0, UART1, UART2 and UART3 2 pins */ |
| 1858 | sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U0ME_MASK) | SDR0_PFC1_U0ME_DSR_DTR; |
| 1859 | sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U0IM_MASK) | SDR0_PFC1_U0IM_4PINS; |
| 1860 | sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U1ME_MASK) | SDR0_PFC1_U1ME_DSR_DTR; |
| 1861 | break; |
| 1862 | } |
Eugene OBrien | c59d1a0 | 2007-07-31 10:24:56 +0200 | [diff] [blame] | 1863 | update_uart_ios(uart_configuration, gpio_tab); |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1864 | |
| 1865 | /* UART Selection in all cases */ |
| 1866 | uart_selection_in_fpga(uart_configuration); |
| 1867 | |
| 1868 | /* Packet Reject Function Available */ |
| 1869 | if (ppc440ep_core_selection[PACKET_REJ_FUNC_AVAIL] == CORE_SELECTED) |
| 1870 | { |
| 1871 | /* Set UPR Bit in SDR0_PFC1 Register */ |
| 1872 | sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_UPR_MASK) | SDR0_PFC1_UPR_ENABLE; |
| 1873 | } |
| 1874 | |
| 1875 | /* Packet Reject Function Enable */ |
| 1876 | if (ppc440ep_core_selection[PACKET_REJ_FUNC_EN] == CORE_SELECTED) |
| 1877 | { |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 1878 | mfsdr(SDR0_MFR, sdr0_mfr); |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1879 | sdr0_mfr = (sdr0_mfr & ~SDR0_MFR_PKT_REJ_MASK) | SDR0_MFR_PKT_REJ_EN;; |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 1880 | mtsdr(SDR0_MFR, sdr0_mfr); |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1881 | } |
| 1882 | |
| 1883 | /* Perform effective access to hardware */ |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 1884 | mtsdr(SDR0_PFC1, sdr0_pfc1); |
Eugene OBrien | c59d1a0 | 2007-07-31 10:24:56 +0200 | [diff] [blame] | 1885 | set_chip_gpio_configuration(GPIO0, gpio_tab); |
| 1886 | set_chip_gpio_configuration(GPIO1, gpio_tab); |
Stefan Roese | 363330b | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 1887 | |
| 1888 | /* USB2.0 Device Reset must be done after GPIO setting */ |
| 1889 | if (ppc440ep_core_selection[USB2_DEVICE] == CORE_SELECTED) |
| 1890 | usb2_device_reset_through_fpga(); |
| 1891 | |
| 1892 | } |