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