Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 2 | /* |
Kumar Gala | 6a6d948 | 2009-07-28 21:49:52 -0500 | [diff] [blame] | 3 | * Copyright (C) Freescale Semiconductor, Inc. 2006. |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
| 7 | #include <ioports.h> |
| 8 | #include <mpc83xx.h> |
| 9 | #include <i2c.h> |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 10 | #include <miiphy.h> |
Timur Tabi | 3e1d49a | 2008-02-08 13:15:55 -0600 | [diff] [blame] | 11 | #include <vsc7385.h> |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 12 | #ifdef CONFIG_PCI |
| 13 | #include <asm/mpc8349_pci.h> |
| 14 | #include <pci.h> |
| 15 | #endif |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 16 | #include <spd_sdram.h> |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 17 | #include <asm/mmu.h> |
Kim Phillips | 3204c7c | 2007-12-20 15:57:28 -0600 | [diff] [blame] | 18 | #if defined(CONFIG_OF_LIBFDT) |
Masahiro Yamada | 75f82d0 | 2018-03-05 01:20:11 +0900 | [diff] [blame] | 19 | #include <linux/libfdt.h> |
Kim Phillips | 774e1b5 | 2006-11-01 00:10:40 -0600 | [diff] [blame] | 20 | #endif |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 21 | |
Mario Six | 9486710 | 2019-01-21 09:17:54 +0100 | [diff] [blame] | 22 | #include "../../../arch/powerpc/cpu/mpc83xx/hrcw/hrcw.h" |
Mario Six | 1faf95d | 2019-01-21 09:18:03 +0100 | [diff] [blame] | 23 | #include "../../../arch/powerpc/cpu/mpc83xx/elbc/elbc.h" |
Mario Six | 9486710 | 2019-01-21 09:17:54 +0100 | [diff] [blame] | 24 | |
Simon Glass | 39f90ba | 2017-03-31 08:40:25 -0600 | [diff] [blame] | 25 | DECLARE_GLOBAL_DATA_PTR; |
| 26 | |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 27 | #ifndef CONFIG_SPD_EEPROM |
| 28 | /************************************************************************* |
| 29 | * fixed sdram init -- doesn't use serial presence detect. |
| 30 | ************************************************************************/ |
| 31 | int fixed_sdram(void) |
| 32 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 33 | volatile immap_t *im = (immap_t *) CONFIG_SYS_IMMR; |
Joe Hershberger | 5ade390 | 2011-10-11 23:57:31 -0500 | [diff] [blame] | 34 | /* The size of RAM, in bytes */ |
| 35 | u32 ddr_size = CONFIG_SYS_DDR_SIZE << 20; |
| 36 | u32 ddr_size_log2 = __ilog2(ddr_size); |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 37 | |
| 38 | im->sysconf.ddrlaw[0].ar = |
| 39 | LAWAR_EN | ((ddr_size_log2 - 1) & LAWAR_SIZE); |
Mario Six | 805cac1 | 2019-01-21 09:18:16 +0100 | [diff] [blame] | 40 | im->sysconf.ddrlaw[0].bar = CONFIG_SYS_SDRAM_BASE & 0xfffff000; |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 41 | |
Mario Six | 805cac1 | 2019-01-21 09:18:16 +0100 | [diff] [blame] | 42 | #if ((CONFIG_SYS_SDRAM_BASE & 0x00FFFFFF) != 0) |
Joe Hershberger | 5ade390 | 2011-10-11 23:57:31 -0500 | [diff] [blame] | 43 | #warning Chip select bounds is only configurable in 16MB increments |
| 44 | #endif |
| 45 | im->ddr.csbnds[0].csbnds = |
Mario Six | 805cac1 | 2019-01-21 09:18:16 +0100 | [diff] [blame] | 46 | ((CONFIG_SYS_SDRAM_BASE >> CSBNDS_SA_SHIFT) & CSBNDS_SA) | |
| 47 | (((CONFIG_SYS_SDRAM_BASE + ddr_size - 1) >> |
Joe Hershberger | 5ade390 | 2011-10-11 23:57:31 -0500 | [diff] [blame] | 48 | CSBNDS_EA_SHIFT) & CSBNDS_EA); |
| 49 | im->ddr.cs_config[0] = CONFIG_SYS_DDR_CS0_CONFIG; |
| 50 | |
| 51 | /* Only one CS for DDR */ |
| 52 | im->ddr.cs_config[1] = 0; |
| 53 | im->ddr.cs_config[2] = 0; |
| 54 | im->ddr.cs_config[3] = 0; |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 55 | |
| 56 | debug("cs0_bnds = 0x%08x\n", im->ddr.csbnds[0].csbnds); |
| 57 | debug("cs0_config = 0x%08x\n", im->ddr.cs_config[0]); |
| 58 | |
| 59 | debug("DDR:bar=0x%08x\n", im->sysconf.ddrlaw[0].bar); |
| 60 | debug("DDR:ar=0x%08x\n", im->sysconf.ddrlaw[0].ar); |
| 61 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 62 | im->ddr.timing_cfg_1 = CONFIG_SYS_DDR_TIMING_1; |
| 63 | im->ddr.timing_cfg_2 = CONFIG_SYS_DDR_TIMING_2;/* Was "2 << TIMING_CFG2_WR_DATA_DELAY_SHIFT" */ |
Kim Phillips | 3b9c20f | 2007-08-16 22:52:48 -0500 | [diff] [blame] | 64 | im->ddr.sdram_cfg = SDRAM_CFG_SREN | SDRAM_CFG_SDRAM_TYPE_DDR1; |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 65 | im->ddr.sdram_mode = |
| 66 | (0x0000 << SDRAM_MODE_ESD_SHIFT) | (0x0032 << SDRAM_MODE_SD_SHIFT); |
| 67 | im->ddr.sdram_interval = |
| 68 | (0x0410 << SDRAM_INTERVAL_REFINT_SHIFT) | (0x0100 << |
| 69 | SDRAM_INTERVAL_BSTOPRE_SHIFT); |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 70 | im->ddr.sdram_clk_cntl = CONFIG_SYS_DDR_SDRAM_CLK_CNTL; |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 71 | |
| 72 | udelay(200); |
| 73 | |
| 74 | im->ddr.sdram_cfg |= SDRAM_CFG_MEM_EN; |
| 75 | |
| 76 | debug("DDR:timing_cfg_1=0x%08x\n", im->ddr.timing_cfg_1); |
| 77 | debug("DDR:timing_cfg_2=0x%08x\n", im->ddr.timing_cfg_2); |
| 78 | debug("DDR:sdram_mode=0x%08x\n", im->ddr.sdram_mode); |
| 79 | debug("DDR:sdram_interval=0x%08x\n", im->ddr.sdram_interval); |
| 80 | debug("DDR:sdram_cfg=0x%08x\n", im->ddr.sdram_cfg); |
| 81 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 82 | return CONFIG_SYS_DDR_SIZE; |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 83 | } |
| 84 | #endif |
| 85 | |
| 86 | #ifdef CONFIG_PCI |
| 87 | /* |
| 88 | * Initialize PCI Devices, report devices found |
| 89 | */ |
| 90 | #ifndef CONFIG_PCI_PNP |
| 91 | static struct pci_config_table pci_mpc83xxmitx_config_table[] = { |
| 92 | { |
| 93 | PCI_ANY_ID, |
| 94 | PCI_ANY_ID, |
| 95 | PCI_ANY_ID, |
| 96 | PCI_ANY_ID, |
| 97 | 0x0f, |
| 98 | PCI_ANY_ID, |
| 99 | pci_cfgfunc_config_device, |
| 100 | { |
| 101 | PCI_ENET0_IOADDR, |
| 102 | PCI_ENET0_MEMADDR, |
| 103 | PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER} |
| 104 | }, |
| 105 | {} |
| 106 | } |
| 107 | #endif |
| 108 | |
| 109 | volatile static struct pci_controller hose[] = { |
| 110 | { |
| 111 | #ifndef CONFIG_PCI_PNP |
| 112 | config_table:pci_mpc83xxmitx_config_table, |
| 113 | #endif |
| 114 | }, |
| 115 | { |
| 116 | #ifndef CONFIG_PCI_PNP |
| 117 | config_table:pci_mpc83xxmitx_config_table, |
| 118 | #endif |
| 119 | } |
| 120 | }; |
| 121 | #endif /* CONFIG_PCI */ |
| 122 | |
Simon Glass | d35f338 | 2017-04-06 12:47:05 -0600 | [diff] [blame] | 123 | int dram_init(void) |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 124 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 125 | volatile immap_t *im = (immap_t *) CONFIG_SYS_IMMR; |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 126 | u32 msize = 0; |
| 127 | #ifdef CONFIG_DDR_ECC |
| 128 | volatile ddr83xx_t *ddr = &im->ddr; |
| 129 | #endif |
| 130 | |
| 131 | if ((im->sysconf.immrbar & IMMRBAR_BASE_ADDR) != (u32) im) |
Simon Glass | 39f90ba | 2017-03-31 08:40:25 -0600 | [diff] [blame] | 132 | return -ENXIO; |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 133 | |
| 134 | /* DDR SDRAM - Main SODIMM */ |
Mario Six | c9f9277 | 2019-01-21 09:18:15 +0100 | [diff] [blame] | 135 | im->sysconf.ddrlaw[0].bar = CONFIG_SYS_SDRAM_BASE & LAWBAR_BAR; |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 136 | #ifdef CONFIG_SPD_EEPROM |
| 137 | msize = spd_sdram(); |
| 138 | #else |
| 139 | msize = fixed_sdram(); |
| 140 | #endif |
| 141 | |
| 142 | #ifdef CONFIG_DDR_ECC |
| 143 | if (ddr->sdram_cfg & SDRAM_CFG_ECC_EN) |
| 144 | /* Unlike every other board, on the 83xx spd_sdram() returns |
| 145 | megabytes instead of just bytes. That's why we need to |
| 146 | multiple by 1MB when calling ddr_enable_ecc(). */ |
| 147 | ddr_enable_ecc(msize * 1048576); |
| 148 | #endif |
| 149 | |
Timur Tabi | 3ff1118 | 2007-01-31 15:54:20 -0600 | [diff] [blame] | 150 | /* return total bus RAM size(bytes) */ |
Simon Glass | 39f90ba | 2017-03-31 08:40:25 -0600 | [diff] [blame] | 151 | gd->ram_size = msize * 1024 * 1024; |
| 152 | |
| 153 | return 0; |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 154 | } |
| 155 | |
| 156 | int checkboard(void) |
| 157 | { |
Mario Six | 5bb7f75 | 2019-01-21 09:17:44 +0100 | [diff] [blame] | 158 | #ifdef CONFIG_TARGET_MPC8349ITX |
Timur Tabi | ab34754 | 2006-11-03 19:15:00 -0600 | [diff] [blame] | 159 | puts("Board: Freescale MPC8349E-mITX\n"); |
Timur Tabi | 435e3a7 | 2007-01-31 15:54:29 -0600 | [diff] [blame] | 160 | #else |
| 161 | puts("Board: Freescale MPC8349E-mITX-GP\n"); |
| 162 | #endif |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 163 | |
| 164 | return 0; |
| 165 | } |
| 166 | |
Timur Tabi | ab34754 | 2006-11-03 19:15:00 -0600 | [diff] [blame] | 167 | /* |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 168 | * Implement a work-around for a hardware problem with compact |
| 169 | * flash. |
| 170 | * |
| 171 | * Program the UPM if compact flash is enabled. |
| 172 | */ |
| 173 | int misc_init_f(void) |
| 174 | { |
Timur Tabi | 3e1d49a | 2008-02-08 13:15:55 -0600 | [diff] [blame] | 175 | #ifdef CONFIG_VSC7385_ENET |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 176 | volatile u32 *vsc7385_cpuctrl; |
| 177 | |
| 178 | /* 0x1c0c0 is the VSC7385 CPU Control (CPUCTRL) Register. The power up |
| 179 | default of VSC7385 L1_IRQ and L2_IRQ requests are active high. That |
| 180 | means it is 0 when the IRQ is not active. This makes the wire-AND |
| 181 | logic always assert IRQ7 to CPU even if there is no request from the |
| 182 | switch. Since the compact flash and the switch share the same IRQ, |
| 183 | the Linux kernel will think that the compact flash is requesting irq |
| 184 | and get stuck when it tries to clear the IRQ. Thus we need to set |
| 185 | the L2_IRQ0 and L2_IRQ1 to active low. |
| 186 | |
| 187 | The following code sets the L1_IRQ and L2_IRQ polarity to active low. |
| 188 | Without this code, compact flash will not work in Linux because |
| 189 | unlike U-Boot, Linux uses the IRQ, so this code is necessary if we |
| 190 | don't enable compact flash for U-Boot. |
| 191 | */ |
| 192 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 193 | vsc7385_cpuctrl = (volatile u32 *)(CONFIG_SYS_VSC7385_BASE + 0x1c0c0); |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 194 | *vsc7385_cpuctrl |= 0x0c; |
Timur Tabi | 435e3a7 | 2007-01-31 15:54:29 -0600 | [diff] [blame] | 195 | #endif |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 196 | |
| 197 | #ifdef CONFIG_COMPACT_FLASH |
| 198 | /* UPM Table Configuration Code */ |
| 199 | static uint UPMATable[] = { |
| 200 | 0xcffffc00, 0x0fffff00, 0x0fafff00, 0x0fafff00, |
| 201 | 0x0faffd00, 0x0faffc04, 0x0ffffc00, 0x3ffffc01, |
| 202 | 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00, |
| 203 | 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00, |
| 204 | 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfff7fc00, |
| 205 | 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01, |
| 206 | 0xcffffc00, 0x0fffff00, 0x0ff3ff00, 0x0ff3ff00, |
| 207 | 0x0ff3fe00, 0x0ffffc00, 0x3ffffc05, 0xfffffc00, |
| 208 | 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00, |
| 209 | 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00, |
| 210 | 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00, |
| 211 | 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01, |
| 212 | 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00, |
| 213 | 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00, |
| 214 | 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01, |
| 215 | 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01 |
| 216 | }; |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 217 | volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR; |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 218 | |
Becky Bruce | 0d4cee1 | 2010-06-17 11:37:20 -0500 | [diff] [blame] | 219 | set_lbc_br(3, CONFIG_SYS_BR3_PRELIM); |
| 220 | set_lbc_or(3, CONFIG_SYS_OR3_PRELIM); |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 221 | |
| 222 | /* Program the MAMR. RFEN=0, OP=00, UWPL=1, AM=000, DS=01, G0CL=000, |
| 223 | GPL4=0, RLF=0001, WLF=0001, TLF=0001, MAD=000000 |
| 224 | */ |
Becky Bruce | 0d4cee1 | 2010-06-17 11:37:20 -0500 | [diff] [blame] | 225 | immap->im_lbc.mamr = 0x08404440; |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 226 | |
| 227 | upmconfig(0, UPMATable, sizeof(UPMATable) / sizeof(UPMATable[0])); |
| 228 | |
| 229 | puts("UPMA: Configured for compact flash\n"); |
| 230 | #endif |
| 231 | |
| 232 | return 0; |
| 233 | } |
| 234 | |
Timur Tabi | ab34754 | 2006-11-03 19:15:00 -0600 | [diff] [blame] | 235 | /* |
Timur Tabi | 3e1d49a | 2008-02-08 13:15:55 -0600 | [diff] [blame] | 236 | * Miscellaneous late-boot configurations |
| 237 | * |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 238 | * Make sure the EEPROM has the HRCW correctly programmed. |
| 239 | * Make sure the RTC is correctly programmed. |
| 240 | * |
| 241 | * The MPC8349E-mITX can be configured to load the HRCW from |
| 242 | * EEPROM instead of flash. This is controlled via jumpers |
| 243 | * LGPL0, 1, and 3. Normally, these jumpers are set to 000 (all |
| 244 | * jumpered), but if they're set to 001 or 010, then the HRCW is |
| 245 | * read from the "I2C EEPROM". |
| 246 | * |
| 247 | * This function makes sure that the I2C EEPROM is programmed |
| 248 | * correctly. |
Timur Tabi | 3e1d49a | 2008-02-08 13:15:55 -0600 | [diff] [blame] | 249 | * |
| 250 | * If a VSC7385 microcode image is present, then upload it. |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 251 | */ |
| 252 | int misc_init_r(void) |
| 253 | { |
| 254 | int rc = 0; |
| 255 | |
Heiko Schocher | f285074 | 2012-10-24 13:48:22 +0200 | [diff] [blame] | 256 | #if defined(CONFIG_SYS_I2C) |
Sam Song | b7bf05c | 2006-12-14 19:03:21 +0800 | [diff] [blame] | 257 | unsigned int orig_bus = i2c_get_bus_num(); |
Timur Tabi | ab34754 | 2006-11-03 19:15:00 -0600 | [diff] [blame] | 258 | u8 i2c_data; |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 259 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 260 | #ifdef CONFIG_SYS_I2C_RTC_ADDR |
Timur Tabi | ff0215a | 2006-11-28 12:09:35 -0600 | [diff] [blame] | 261 | u8 ds1339_data[17]; |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 262 | #endif |
| 263 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 264 | #ifdef CONFIG_SYS_I2C_EEPROM_ADDR |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 265 | static u8 eeprom_data[] = /* HRCW data */ |
| 266 | { |
Timur Tabi | 435e3a7 | 2007-01-31 15:54:29 -0600 | [diff] [blame] | 267 | 0xAA, 0x55, 0xAA, /* Preamble */ |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 268 | 0x7C, /* ACS=0, BYTE_EN=1111, CONT=1 */ |
| 269 | 0x02, 0x40, /* RCWL ADDR=0x0_0900 */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 270 | (CONFIG_SYS_HRCW_LOW >> 24) & 0xFF, |
| 271 | (CONFIG_SYS_HRCW_LOW >> 16) & 0xFF, |
| 272 | (CONFIG_SYS_HRCW_LOW >> 8) & 0xFF, |
| 273 | CONFIG_SYS_HRCW_LOW & 0xFF, |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 274 | 0x7C, /* ACS=0, BYTE_EN=1111, CONT=1 */ |
Timur Tabi | 435e3a7 | 2007-01-31 15:54:29 -0600 | [diff] [blame] | 275 | 0x02, 0x41, /* RCWH ADDR=0x0_0904 */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 276 | (CONFIG_SYS_HRCW_HIGH >> 24) & 0xFF, |
| 277 | (CONFIG_SYS_HRCW_HIGH >> 16) & 0xFF, |
| 278 | (CONFIG_SYS_HRCW_HIGH >> 8) & 0xFF, |
| 279 | CONFIG_SYS_HRCW_HIGH & 0xFF |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 280 | }; |
| 281 | |
| 282 | u8 data[sizeof(eeprom_data)]; |
Timur Tabi | ab34754 | 2006-11-03 19:15:00 -0600 | [diff] [blame] | 283 | #endif |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 284 | |
Timur Tabi | ab34754 | 2006-11-03 19:15:00 -0600 | [diff] [blame] | 285 | printf("Board revision: "); |
Timur Tabi | c0b114a | 2006-10-31 21:23:16 -0600 | [diff] [blame] | 286 | i2c_set_bus_num(1); |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 287 | if (i2c_read(CONFIG_SYS_I2C_8574A_ADDR2, 0, 0, &i2c_data, sizeof(i2c_data)) == 0) |
Timur Tabi | ab34754 | 2006-11-03 19:15:00 -0600 | [diff] [blame] | 288 | printf("%u.%u (PCF8475A)\n", (i2c_data & 0x02) >> 1, i2c_data & 0x01); |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 289 | else if (i2c_read(CONFIG_SYS_I2C_8574_ADDR2, 0, 0, &i2c_data, sizeof(i2c_data)) == 0) |
Timur Tabi | ab34754 | 2006-11-03 19:15:00 -0600 | [diff] [blame] | 290 | printf("%u.%u (PCF8475)\n", (i2c_data & 0x02) >> 1, i2c_data & 0x01); |
| 291 | else { |
| 292 | printf("Unknown\n"); |
| 293 | rc = 1; |
| 294 | } |
| 295 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 296 | #ifdef CONFIG_SYS_I2C_EEPROM_ADDR |
Timur Tabi | ab34754 | 2006-11-03 19:15:00 -0600 | [diff] [blame] | 297 | i2c_set_bus_num(0); |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 298 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 299 | if (i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, 0, 2, data, sizeof(data)) == 0) { |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 300 | if (memcmp(data, eeprom_data, sizeof(data)) != 0) { |
| 301 | if (i2c_write |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 302 | (CONFIG_SYS_I2C_EEPROM_ADDR, 0, 2, eeprom_data, |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 303 | sizeof(eeprom_data)) != 0) { |
| 304 | puts("Failure writing the HRCW to EEPROM via I2C.\n"); |
| 305 | rc = 1; |
| 306 | } |
| 307 | } |
| 308 | } else { |
| 309 | puts("Failure reading the HRCW from EEPROM via I2C.\n"); |
| 310 | rc = 1; |
| 311 | } |
| 312 | #endif |
| 313 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 314 | #ifdef CONFIG_SYS_I2C_RTC_ADDR |
Timur Tabi | ab34754 | 2006-11-03 19:15:00 -0600 | [diff] [blame] | 315 | i2c_set_bus_num(1); |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 316 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 317 | if (i2c_read(CONFIG_SYS_I2C_RTC_ADDR, 0, 1, ds1339_data, sizeof(ds1339_data)) |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 318 | == 0) { |
| 319 | |
| 320 | /* Work-around for MPC8349E-mITX bug #13601. |
| 321 | If the RTC does not contain valid register values, the DS1339 |
| 322 | Linux driver will not work. |
| 323 | */ |
| 324 | |
| 325 | /* Make sure status register bits 6-2 are zero */ |
| 326 | ds1339_data[0x0f] &= ~0x7c; |
| 327 | |
| 328 | /* Check for a valid day register value */ |
| 329 | ds1339_data[0x03] &= ~0xf8; |
| 330 | if (ds1339_data[0x03] == 0) { |
| 331 | ds1339_data[0x03] = 1; |
| 332 | } |
| 333 | |
| 334 | /* Check for a valid date register value */ |
| 335 | ds1339_data[0x04] &= ~0xc0; |
| 336 | if ((ds1339_data[0x04] == 0) || |
| 337 | ((ds1339_data[0x04] & 0x0f) > 9) || |
| 338 | (ds1339_data[0x04] >= 0x32)) { |
| 339 | ds1339_data[0x04] = 1; |
| 340 | } |
| 341 | |
| 342 | /* Check for a valid month register value */ |
| 343 | ds1339_data[0x05] &= ~0x60; |
| 344 | |
| 345 | if ((ds1339_data[0x05] == 0) || |
| 346 | ((ds1339_data[0x05] & 0x0f) > 9) || |
| 347 | ((ds1339_data[0x05] >= 0x13) |
| 348 | && (ds1339_data[0x05] <= 0x19))) { |
| 349 | ds1339_data[0x05] = 1; |
| 350 | } |
| 351 | |
| 352 | /* Enable Oscillator and rate select */ |
| 353 | ds1339_data[0x0e] = 0x1c; |
| 354 | |
| 355 | /* Work-around for MPC8349E-mITX bug #13330. |
| 356 | Ensure that the RTC control register contains the value 0x1c. |
| 357 | This affects SATA performance. |
| 358 | */ |
| 359 | |
| 360 | if (i2c_write |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 361 | (CONFIG_SYS_I2C_RTC_ADDR, 0, 1, ds1339_data, |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 362 | sizeof(ds1339_data))) { |
| 363 | puts("Failure writing to the RTC via I2C.\n"); |
| 364 | rc = 1; |
| 365 | } |
| 366 | } else { |
| 367 | puts("Failure reading from the RTC via I2C.\n"); |
| 368 | rc = 1; |
| 369 | } |
| 370 | #endif |
| 371 | |
| 372 | i2c_set_bus_num(orig_bus); |
| 373 | #endif |
| 374 | |
Timur Tabi | 3e1d49a | 2008-02-08 13:15:55 -0600 | [diff] [blame] | 375 | #ifdef CONFIG_VSC7385_IMAGE |
| 376 | if (vsc7385_upload_firmware((void *) CONFIG_VSC7385_IMAGE, |
| 377 | CONFIG_VSC7385_IMAGE_SIZE)) { |
| 378 | puts("Failure uploading VSC7385 microcode.\n"); |
| 379 | rc = 1; |
| 380 | } |
| 381 | #endif |
| 382 | |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 383 | return rc; |
| 384 | } |
Kim Phillips | 774e1b5 | 2006-11-01 00:10:40 -0600 | [diff] [blame] | 385 | |
Kim Phillips | 2141681 | 2007-08-15 22:30:33 -0500 | [diff] [blame] | 386 | #if defined(CONFIG_OF_BOARD_SETUP) |
Simon Glass | 2aec3cc | 2014-10-23 18:58:47 -0600 | [diff] [blame] | 387 | int ft_board_setup(void *blob, bd_t *bd) |
Kim Phillips | 774e1b5 | 2006-11-01 00:10:40 -0600 | [diff] [blame] | 388 | { |
Kim Phillips | 2141681 | 2007-08-15 22:30:33 -0500 | [diff] [blame] | 389 | ft_cpu_setup(blob, bd); |
| 390 | #ifdef CONFIG_PCI |
| 391 | ft_pci_setup(blob, bd); |
| 392 | #endif |
Simon Glass | 2aec3cc | 2014-10-23 18:58:47 -0600 | [diff] [blame] | 393 | |
| 394 | return 0; |
Kim Phillips | 774e1b5 | 2006-11-01 00:10:40 -0600 | [diff] [blame] | 395 | } |
| 396 | #endif |