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