Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 1 | /* |
Matthias Fuchs | be27079 | 2008-10-28 13:37:00 +0100 | [diff] [blame] | 2 | * (Cg) Copyright 2007-2008 |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 3 | * Matthias Fuchs, esd gmbh, matthias.fuchs@esd-electronics.com. |
| 4 | * Based on board/amcc/sequoia/sequoia.c |
| 5 | * |
| 6 | * (C) Copyright 2006 |
| 7 | * Stefan Roese, DENX Software Engineering, sr@denx.de. |
| 8 | * |
| 9 | * (C) Copyright 2006 |
| 10 | * Jacqueline Pira-Ferriol, AMCC/IBM, jpira-ferriol@fr.ibm.com |
| 11 | * Alain Saurel, AMCC/IBM, alain.saurel@fr.ibm.com |
| 12 | * |
| 13 | * This program is free software; you can redistribute it and/or |
| 14 | * modify it under the terms of the GNU General Public License as |
| 15 | * published by the Free Software Foundation; either version 2 of |
| 16 | * the License, or (at your option) any later version. |
| 17 | * |
| 18 | * This program is distributed in the hope that it will be useful, |
| 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 21 | * GNU General Public License for more details. |
| 22 | * |
| 23 | * You should have received a copy of the GNU General Public License |
| 24 | * along with this program; if not, write to the Free Software |
| 25 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 26 | * MA 02111-1307 USA |
| 27 | */ |
| 28 | |
| 29 | #include <common.h> |
| 30 | #include <libfdt.h> |
| 31 | #include <fdt_support.h> |
| 32 | #include <ppc440.h> |
| 33 | #include <asm/processor.h> |
| 34 | #include <asm/io.h> |
Matthias Fuchs | 034394a | 2008-03-30 18:52:44 +0200 | [diff] [blame] | 35 | #include <asm/bitops.h> |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 36 | #include <command.h> |
| 37 | #include <i2c.h> |
| 38 | #ifdef CONFIG_RESET_PHY_R |
| 39 | #include <miiphy.h> |
| 40 | #endif |
| 41 | #include <serial.h> |
| 42 | #include "fpga.h" |
| 43 | #include "pmc440.h" |
| 44 | |
| 45 | DECLARE_GLOBAL_DATA_PTR; |
| 46 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 47 | extern flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS]; /* info for FLASH chips */ |
Matthias Fuchs | be27079 | 2008-10-28 13:37:00 +0100 | [diff] [blame] | 48 | extern void __ft_board_setup(void *blob, bd_t *bd); |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 49 | |
| 50 | ulong flash_get_size(ulong base, int banknum); |
| 51 | int pci_is_66mhz(void); |
Matthias Fuchs | be27079 | 2008-10-28 13:37:00 +0100 | [diff] [blame] | 52 | int is_monarch(void); |
Matthias Fuchs | 034394a | 2008-03-30 18:52:44 +0200 | [diff] [blame] | 53 | int bootstrap_eeprom_read(unsigned dev_addr, unsigned offset, |
| 54 | uchar *buffer, unsigned cnt); |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 55 | |
| 56 | struct serial_device *default_serial_console(void) |
| 57 | { |
| 58 | uchar buf[4]; |
| 59 | ulong delay; |
| 60 | int i; |
| 61 | ulong val; |
| 62 | |
| 63 | /* |
| 64 | * Use default console on P4 when strapping jumper |
| 65 | * is installed (bootstrap option != 'H'). |
| 66 | */ |
Stefan Roese | d1c3b27 | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 67 | mfsdr(SDR0_PINSTP, val); |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 68 | if (((val & 0xf0000000) >> 29) != 7) |
| 69 | return &serial1_device; |
| 70 | |
| 71 | ulong scratchreg = in_be32((void*)GPIO0_ISR3L); |
| 72 | if (!(scratchreg & 0x80)) { |
| 73 | /* mark scratchreg valid */ |
| 74 | scratchreg = (scratchreg & 0xffffff00) | 0x80; |
| 75 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 76 | i = bootstrap_eeprom_read(CONFIG_SYS_I2C_BOOT_EEPROM_ADDR, |
Matthias Fuchs | 034394a | 2008-03-30 18:52:44 +0200 | [diff] [blame] | 77 | 0x10, buf, 4); |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 78 | if ((i != -1) && (buf[0] == 0x19) && (buf[1] == 0x75)) { |
| 79 | scratchreg |= buf[2]; |
| 80 | |
| 81 | /* bringup delay for console */ |
| 82 | for (delay=0; delay<(1000 * (ulong)buf[3]); delay++) { |
| 83 | udelay(1000); |
| 84 | } |
| 85 | } else |
| 86 | scratchreg |= 0x01; |
| 87 | out_be32((void*)GPIO0_ISR3L, scratchreg); |
| 88 | } |
| 89 | |
| 90 | if (scratchreg & 0x01) |
| 91 | return &serial1_device; |
| 92 | else |
| 93 | return &serial0_device; |
| 94 | } |
| 95 | |
| 96 | int board_early_init_f(void) |
| 97 | { |
| 98 | u32 sdr0_cust0; |
| 99 | u32 sdr0_pfc1, sdr0_pfc2; |
| 100 | u32 reg; |
| 101 | |
| 102 | /* general EBC configuration (disable EBC timeouts) */ |
Stefan Roese | d1c3b27 | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 103 | mtdcr(EBC0_CFGADDR, EBC0_CFG); |
| 104 | mtdcr(EBC0_CFGDATA, 0xf8400000); |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 105 | |
Matthias Fuchs | 034394a | 2008-03-30 18:52:44 +0200 | [diff] [blame] | 106 | /* |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 107 | * Setup the GPIO pins |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 108 | * TODO: setup GPIOs via CONFIG_SYS_4xx_GPIO_TABLE in board's config file |
Matthias Fuchs | 034394a | 2008-03-30 18:52:44 +0200 | [diff] [blame] | 109 | */ |
Matthias Fuchs | bb57ad4 | 2009-02-20 10:19:19 +0100 | [diff] [blame] | 110 | out_be32((void *)GPIO0_OR, 0x40000102); |
| 111 | out_be32((void *)GPIO0_TCR, 0x4c90011f); |
| 112 | out_be32((void *)GPIO0_OSRL, 0x28051400); |
| 113 | out_be32((void *)GPIO0_OSRH, 0x55005000); |
| 114 | out_be32((void *)GPIO0_TSRL, 0x08051400); |
| 115 | out_be32((void *)GPIO0_TSRH, 0x55005000); |
| 116 | out_be32((void *)GPIO0_ISR1L, 0x54000000); |
| 117 | out_be32((void *)GPIO0_ISR1H, 0x00000000); |
| 118 | out_be32((void *)GPIO0_ISR2L, 0x44000000); |
| 119 | out_be32((void *)GPIO0_ISR2H, 0x00000100); |
| 120 | out_be32((void *)GPIO0_ISR3L, 0x00000000); |
| 121 | out_be32((void *)GPIO0_ISR3H, 0x00000000); |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 122 | |
Matthias Fuchs | bb57ad4 | 2009-02-20 10:19:19 +0100 | [diff] [blame] | 123 | out_be32((void *)GPIO1_OR, 0x80002408); |
| 124 | out_be32((void *)GPIO1_TCR, 0xd6003c08); |
| 125 | out_be32((void *)GPIO1_OSRL, 0x0a5a0000); |
| 126 | out_be32((void *)GPIO1_OSRH, 0x00000000); |
| 127 | out_be32((void *)GPIO1_TSRL, 0x00000000); |
| 128 | out_be32((void *)GPIO1_TSRH, 0x00000000); |
| 129 | out_be32((void *)GPIO1_ISR1L, 0x00005555); |
| 130 | out_be32((void *)GPIO1_ISR1H, 0x40000000); |
| 131 | out_be32((void *)GPIO1_ISR2L, 0x04010000); |
| 132 | out_be32((void *)GPIO1_ISR2H, 0x00000000); |
| 133 | out_be32((void *)GPIO1_ISR3L, 0x01400000); |
| 134 | out_be32((void *)GPIO1_ISR3H, 0x00000000); |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 135 | |
| 136 | /* patch PLB:PCI divider for 66MHz PCI */ |
Stefan Roese | d1c3b27 | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 137 | mfcpr(CPR0_SPCID, reg); |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 138 | if (pci_is_66mhz() && (reg != 0x02000000)) { |
Stefan Roese | d1c3b27 | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 139 | mtcpr(CPR0_SPCID, 0x02000000); /* 133MHZ : 2 for 66MHz PCI */ |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 140 | |
Stefan Roese | d1c3b27 | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 141 | mfcpr(CPR0_ICFG, reg); |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 142 | reg |= CPR0_ICFG_RLI_MASK; |
Stefan Roese | d1c3b27 | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 143 | mtcpr(CPR0_ICFG, reg); |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 144 | |
Matthias Fuchs | 58ea142 | 2009-07-22 17:27:56 +0200 | [diff] [blame] | 145 | mtspr(SPRN_DBCR0, 0x20000000); /* do chip reset */ |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 146 | } |
| 147 | |
Matthias Fuchs | 034394a | 2008-03-30 18:52:44 +0200 | [diff] [blame] | 148 | /* |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 149 | * Setup the interrupt controller polarities, triggers, etc. |
Matthias Fuchs | 034394a | 2008-03-30 18:52:44 +0200 | [diff] [blame] | 150 | */ |
Stefan Roese | 952e776 | 2009-09-24 09:55:50 +0200 | [diff] [blame] | 151 | mtdcr(UIC0SR, 0xffffffff); /* clear all */ |
| 152 | mtdcr(UIC0ER, 0x00000000); /* disable all */ |
| 153 | mtdcr(UIC0CR, 0x00000005); /* ATI & UIC1 crit are critical */ |
| 154 | mtdcr(UIC0PR, 0xfffff7ef); |
| 155 | mtdcr(UIC0TR, 0x00000000); |
| 156 | mtdcr(UIC0VR, 0x00000000); /* int31 highest, base=0x000 */ |
| 157 | mtdcr(UIC0SR, 0xffffffff); /* clear all */ |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 158 | |
Stefan Roese | 952e776 | 2009-09-24 09:55:50 +0200 | [diff] [blame] | 159 | mtdcr(UIC1SR, 0xffffffff); /* clear all */ |
| 160 | mtdcr(UIC1ER, 0x00000000); /* disable all */ |
| 161 | mtdcr(UIC1CR, 0x00000000); /* all non-critical */ |
| 162 | mtdcr(UIC1PR, 0xffffc7f5); |
| 163 | mtdcr(UIC1TR, 0x00000000); |
| 164 | mtdcr(UIC1VR, 0x00000000); /* int31 highest, base=0x000 */ |
| 165 | mtdcr(UIC1SR, 0xffffffff); /* clear all */ |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 166 | |
Stefan Roese | 952e776 | 2009-09-24 09:55:50 +0200 | [diff] [blame] | 167 | mtdcr(UIC2SR, 0xffffffff); /* clear all */ |
| 168 | mtdcr(UIC2ER, 0x00000000); /* disable all */ |
| 169 | mtdcr(UIC2CR, 0x00000000); /* all non-critical */ |
| 170 | mtdcr(UIC2PR, 0x27ffffff); |
| 171 | mtdcr(UIC2TR, 0x00000000); |
| 172 | mtdcr(UIC2VR, 0x00000000); /* int31 highest, base=0x000 */ |
| 173 | mtdcr(UIC2SR, 0xffffffff); /* clear all */ |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 174 | |
| 175 | /* select Ethernet pins */ |
| 176 | mfsdr(SDR0_PFC1, sdr0_pfc1); |
Matthias Fuchs | 034394a | 2008-03-30 18:52:44 +0200 | [diff] [blame] | 177 | sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_SELECT_MASK) | |
| 178 | SDR0_PFC1_SELECT_CONFIG_4; |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 179 | mfsdr(SDR0_PFC2, sdr0_pfc2); |
Matthias Fuchs | 034394a | 2008-03-30 18:52:44 +0200 | [diff] [blame] | 180 | sdr0_pfc2 = (sdr0_pfc2 & ~SDR0_PFC2_SELECT_MASK) | |
| 181 | SDR0_PFC2_SELECT_CONFIG_4; |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 182 | |
| 183 | /* enable 2nd IIC */ |
| 184 | sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_SIS_MASK) | SDR0_PFC1_SIS_IIC1_SEL; |
| 185 | |
| 186 | mtsdr(SDR0_PFC2, sdr0_pfc2); |
| 187 | mtsdr(SDR0_PFC1, sdr0_pfc1); |
| 188 | |
| 189 | /* setup NAND FLASH */ |
| 190 | mfsdr(SDR0_CUST0, sdr0_cust0); |
| 191 | sdr0_cust0 = SDR0_CUST0_MUX_NDFC_SEL | |
| 192 | SDR0_CUST0_NDFC_ENABLE | |
| 193 | SDR0_CUST0_NDFC_BW_8_BIT | |
| 194 | SDR0_CUST0_NDFC_ARE_MASK | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 195 | (0x80000000 >> (28 + CONFIG_SYS_NAND_CS)); |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 196 | mtsdr(SDR0_CUST0, sdr0_cust0); |
| 197 | |
| 198 | return 0; |
| 199 | } |
| 200 | |
Matthias Fuchs | be27079 | 2008-10-28 13:37:00 +0100 | [diff] [blame] | 201 | #if defined(CONFIG_MISC_INIT_F) |
| 202 | int misc_init_f(void) |
| 203 | { |
| 204 | struct pci_controller hose; |
| 205 | hose.first_busno = 0; |
| 206 | hose.last_busno = 0; |
| 207 | hose.region_count = 0; |
| 208 | |
| 209 | if (getenv("pciearly") && (!is_monarch())) { |
| 210 | printf("PCI: early target init\n"); |
Niklaus Giger | ddc922f | 2009-10-04 20:04:20 +0200 | [diff] [blame] | 211 | pci_setup_indirect(&hose, PCIL0_CFGADR, PCIL0_CFGDATA); |
Matthias Fuchs | be27079 | 2008-10-28 13:37:00 +0100 | [diff] [blame] | 212 | pci_target_init(&hose); |
| 213 | } |
| 214 | return 0; |
| 215 | } |
| 216 | #endif |
| 217 | |
Matthias Fuchs | 034394a | 2008-03-30 18:52:44 +0200 | [diff] [blame] | 218 | /* |
| 219 | * misc_init_r. |
| 220 | */ |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 221 | int misc_init_r(void) |
| 222 | { |
| 223 | uint pbcr; |
| 224 | int size_val = 0; |
| 225 | u32 reg; |
| 226 | unsigned long usb2d0cr = 0; |
| 227 | unsigned long usb2phy0cr, usb2h0cr = 0; |
| 228 | unsigned long sdr0_pfc1; |
Matthias Fuchs | be27079 | 2008-10-28 13:37:00 +0100 | [diff] [blame] | 229 | unsigned long sdr0_srst0, sdr0_srst1; |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 230 | char *act = getenv("usbact"); |
| 231 | |
| 232 | /* |
| 233 | * FLASH stuff... |
| 234 | */ |
| 235 | |
| 236 | /* Re-do sizing to get full correct info */ |
| 237 | |
| 238 | /* adjust flash start and offset */ |
| 239 | gd->bd->bi_flashstart = 0 - gd->bd->bi_flashsize; |
| 240 | gd->bd->bi_flashoffset = 0; |
| 241 | |
| 242 | #if defined(CONFIG_NAND_U_BOOT) || defined(CONFIG_NAND_SPL) |
Stefan Roese | d1c3b27 | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 243 | mtdcr(EBC0_CFGADDR, PB2CR); |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 244 | #else |
Stefan Roese | d1c3b27 | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 245 | mtdcr(EBC0_CFGADDR, PB0CR); |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 246 | #endif |
Stefan Roese | d1c3b27 | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 247 | pbcr = mfdcr(EBC0_CFGDATA); |
Matthias Fuchs | 034394a | 2008-03-30 18:52:44 +0200 | [diff] [blame] | 248 | size_val = ffs(gd->bd->bi_flashsize) - 21; |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 249 | pbcr = (pbcr & 0x0001ffff) | gd->bd->bi_flashstart | (size_val << 17); |
| 250 | #if defined(CONFIG_NAND_U_BOOT) || defined(CONFIG_NAND_SPL) |
Stefan Roese | d1c3b27 | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 251 | mtdcr(EBC0_CFGADDR, PB2CR); |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 252 | #else |
Stefan Roese | d1c3b27 | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 253 | mtdcr(EBC0_CFGADDR, PB0CR); |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 254 | #endif |
Stefan Roese | d1c3b27 | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 255 | mtdcr(EBC0_CFGDATA, pbcr); |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 256 | |
| 257 | /* |
| 258 | * Re-check to get correct base address |
| 259 | */ |
| 260 | flash_get_size(gd->bd->bi_flashstart, 0); |
| 261 | |
Jean-Christophe PLAGNIOL-VILLARD | 5a1aceb | 2008-09-10 22:48:04 +0200 | [diff] [blame] | 262 | #ifdef CONFIG_ENV_IS_IN_FLASH |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 263 | /* Monitor protection ON by default */ |
| 264 | (void)flash_protect(FLAG_PROTECT_SET, |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 265 | -CONFIG_SYS_MONITOR_LEN, |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 266 | 0xffffffff, |
| 267 | &flash_info[0]); |
| 268 | |
| 269 | /* Env protection ON by default */ |
| 270 | (void)flash_protect(FLAG_PROTECT_SET, |
Jean-Christophe PLAGNIOL-VILLARD | 0e8d158 | 2008-09-10 22:48:06 +0200 | [diff] [blame] | 271 | CONFIG_ENV_ADDR_REDUND, |
| 272 | CONFIG_ENV_ADDR_REDUND + 2*CONFIG_ENV_SECT_SIZE - 1, |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 273 | &flash_info[0]); |
| 274 | #endif |
| 275 | |
| 276 | /* |
| 277 | * USB suff... |
| 278 | */ |
Matthias Fuchs | be27079 | 2008-10-28 13:37:00 +0100 | [diff] [blame] | 279 | if ((act == NULL || strcmp(act, "host") == 0) && |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 280 | !(in_be32((void*)GPIO0_IR) & GPIO0_USB_PRSNT)){ |
| 281 | /* SDR Setting */ |
| 282 | mfsdr(SDR0_PFC1, sdr0_pfc1); |
| 283 | mfsdr(SDR0_USB2D0CR, usb2d0cr); |
| 284 | mfsdr(SDR0_USB2PHY0CR, usb2phy0cr); |
| 285 | mfsdr(SDR0_USB2H0CR, usb2h0cr); |
| 286 | |
| 287 | usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_XOCLK_MASK; |
Matthias Fuchs | 034394a | 2008-03-30 18:52:44 +0200 | [diff] [blame] | 288 | usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_XOCLK_EXTERNAL; |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 289 | usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_WDINT_MASK; |
Matthias Fuchs | 034394a | 2008-03-30 18:52:44 +0200 | [diff] [blame] | 290 | usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_WDINT_16BIT_30MHZ; |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 291 | usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_DVBUS_MASK; |
Matthias Fuchs | 034394a | 2008-03-30 18:52:44 +0200 | [diff] [blame] | 292 | usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_DVBUS_PURDIS; |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 293 | usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_DWNSTR_MASK; |
Matthias Fuchs | 034394a | 2008-03-30 18:52:44 +0200 | [diff] [blame] | 294 | usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_DWNSTR_HOST; |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 295 | usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_UTMICN_MASK; |
Matthias Fuchs | 034394a | 2008-03-30 18:52:44 +0200 | [diff] [blame] | 296 | usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_UTMICN_HOST; |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 297 | |
Matthias Fuchs | 034394a | 2008-03-30 18:52:44 +0200 | [diff] [blame] | 298 | /* |
| 299 | * An 8-bit/60MHz interface is the only possible alternative |
| 300 | * when connecting the Device to the PHY |
| 301 | */ |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 302 | usb2h0cr = usb2h0cr &~SDR0_USB2H0CR_WDINT_MASK; |
Matthias Fuchs | 034394a | 2008-03-30 18:52:44 +0200 | [diff] [blame] | 303 | usb2h0cr = usb2h0cr | SDR0_USB2H0CR_WDINT_16BIT_30MHZ; |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 304 | |
| 305 | usb2d0cr = usb2d0cr &~SDR0_USB2D0CR_USB2DEV_EBC_SEL_MASK; |
| 306 | sdr0_pfc1 = sdr0_pfc1 &~SDR0_PFC1_UES_MASK; |
| 307 | |
| 308 | mtsdr(SDR0_PFC1, sdr0_pfc1); |
| 309 | mtsdr(SDR0_USB2D0CR, usb2d0cr); |
| 310 | mtsdr(SDR0_USB2PHY0CR, usb2phy0cr); |
| 311 | mtsdr(SDR0_USB2H0CR, usb2h0cr); |
| 312 | |
Matthias Fuchs | be27079 | 2008-10-28 13:37:00 +0100 | [diff] [blame] | 313 | /* |
| 314 | * Take USB out of reset: |
| 315 | * -Initial status = all cores are in reset |
| 316 | * -deassert reset to OPB1, P4OPB0, OPB2, PLB42OPB1 OPB2PLB40 cores |
| 317 | * -wait 1 ms |
| 318 | * -deassert reset to PHY |
| 319 | * -wait 1 ms |
| 320 | * -deassert reset to HOST |
| 321 | * -wait 4 ms |
| 322 | * -deassert all other resets |
| 323 | */ |
| 324 | mfsdr(SDR0_SRST1, sdr0_srst1); |
| 325 | sdr0_srst1 &= ~(SDR0_SRST1_OPBA1 | \ |
| 326 | SDR0_SRST1_P4OPB0 | \ |
| 327 | SDR0_SRST1_OPBA2 | \ |
| 328 | SDR0_SRST1_PLB42OPB1 | \ |
| 329 | SDR0_SRST1_OPB2PLB40); |
| 330 | mtsdr(SDR0_SRST1, sdr0_srst1); |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 331 | udelay(1000); |
Matthias Fuchs | be27079 | 2008-10-28 13:37:00 +0100 | [diff] [blame] | 332 | |
| 333 | mfsdr(SDR0_SRST1, sdr0_srst1); |
| 334 | sdr0_srst1 &= ~SDR0_SRST1_USB20PHY; |
| 335 | mtsdr(SDR0_SRST1, sdr0_srst1); |
| 336 | udelay(1000); |
| 337 | |
| 338 | mfsdr(SDR0_SRST0, sdr0_srst0); |
| 339 | sdr0_srst0 &= ~SDR0_SRST0_USB2H; |
| 340 | mtsdr(SDR0_SRST0, sdr0_srst0); |
| 341 | udelay(4000); |
| 342 | |
| 343 | /* finally all the other resets */ |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 344 | mtsdr(SDR0_SRST1, 0x00000000); |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 345 | mtsdr(SDR0_SRST0, 0x00000000); |
| 346 | |
Matthias Fuchs | be27079 | 2008-10-28 13:37:00 +0100 | [diff] [blame] | 347 | if (!(in_be32((void*)GPIO0_IR) & GPIO0_USB_PRSNT)) { |
| 348 | /* enable power on USB socket */ |
| 349 | out_be32((void*)GPIO1_OR, |
| 350 | in_be32((void*)GPIO1_OR) & ~GPIO1_USB_PWR_N); |
| 351 | } |
| 352 | |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 353 | printf("USB: Host\n"); |
| 354 | |
Matthias Fuchs | 034394a | 2008-03-30 18:52:44 +0200 | [diff] [blame] | 355 | } else if ((strcmp(act, "dev") == 0) || |
| 356 | (in_be32((void*)GPIO0_IR) & GPIO0_USB_PRSNT)) { |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 357 | mfsdr(SDR0_USB2PHY0CR, usb2phy0cr); |
| 358 | |
| 359 | usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_XOCLK_MASK; |
Matthias Fuchs | 034394a | 2008-03-30 18:52:44 +0200 | [diff] [blame] | 360 | usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_XOCLK_EXTERNAL; |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 361 | usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_DVBUS_MASK; |
Matthias Fuchs | 034394a | 2008-03-30 18:52:44 +0200 | [diff] [blame] | 362 | usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_DVBUS_PURDIS; |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 363 | usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_DWNSTR_MASK; |
Matthias Fuchs | 034394a | 2008-03-30 18:52:44 +0200 | [diff] [blame] | 364 | usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_DWNSTR_HOST; |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 365 | usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_UTMICN_MASK; |
Matthias Fuchs | 034394a | 2008-03-30 18:52:44 +0200 | [diff] [blame] | 366 | usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_UTMICN_HOST; |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 367 | mtsdr(SDR0_USB2PHY0CR, usb2phy0cr); |
| 368 | |
| 369 | udelay (1000); |
| 370 | mtsdr(SDR0_SRST1, 0x672c6000); |
| 371 | |
| 372 | udelay (1000); |
| 373 | mtsdr(SDR0_SRST0, 0x00000080); |
| 374 | |
| 375 | udelay (1000); |
| 376 | mtsdr(SDR0_SRST1, 0x60206000); |
| 377 | |
| 378 | *(unsigned int *)(0xe0000350) = 0x00000001; |
| 379 | |
| 380 | udelay (1000); |
| 381 | mtsdr(SDR0_SRST1, 0x60306000); |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 382 | |
| 383 | /* SDR Setting */ |
| 384 | mfsdr(SDR0_USB2PHY0CR, usb2phy0cr); |
| 385 | mfsdr(SDR0_USB2H0CR, usb2h0cr); |
| 386 | mfsdr(SDR0_USB2D0CR, usb2d0cr); |
| 387 | mfsdr(SDR0_PFC1, sdr0_pfc1); |
| 388 | |
| 389 | usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_XOCLK_MASK; |
Matthias Fuchs | 034394a | 2008-03-30 18:52:44 +0200 | [diff] [blame] | 390 | usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_XOCLK_EXTERNAL; |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 391 | usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_WDINT_MASK; |
Matthias Fuchs | 034394a | 2008-03-30 18:52:44 +0200 | [diff] [blame] | 392 | usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_WDINT_8BIT_60MHZ; |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 393 | usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_DVBUS_MASK; |
Matthias Fuchs | 034394a | 2008-03-30 18:52:44 +0200 | [diff] [blame] | 394 | usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_DVBUS_PUREN; |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 395 | usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_DWNSTR_MASK; |
Matthias Fuchs | 034394a | 2008-03-30 18:52:44 +0200 | [diff] [blame] | 396 | usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_DWNSTR_DEV; |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 397 | usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_UTMICN_MASK; |
Matthias Fuchs | 034394a | 2008-03-30 18:52:44 +0200 | [diff] [blame] | 398 | usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_UTMICN_DEV; |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 399 | |
| 400 | usb2h0cr = usb2h0cr &~SDR0_USB2H0CR_WDINT_MASK; |
Matthias Fuchs | 034394a | 2008-03-30 18:52:44 +0200 | [diff] [blame] | 401 | usb2h0cr = usb2h0cr | SDR0_USB2H0CR_WDINT_8BIT_60MHZ; |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 402 | |
| 403 | usb2d0cr = usb2d0cr &~SDR0_USB2D0CR_USB2DEV_EBC_SEL_MASK; |
| 404 | |
| 405 | sdr0_pfc1 = sdr0_pfc1 &~SDR0_PFC1_UES_MASK; |
Matthias Fuchs | 034394a | 2008-03-30 18:52:44 +0200 | [diff] [blame] | 406 | sdr0_pfc1 = sdr0_pfc1 | SDR0_PFC1_UES_EBCHR_SEL; |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 407 | |
| 408 | mtsdr(SDR0_USB2H0CR, usb2h0cr); |
| 409 | mtsdr(SDR0_USB2PHY0CR, usb2phy0cr); |
| 410 | mtsdr(SDR0_USB2D0CR, usb2d0cr); |
| 411 | mtsdr(SDR0_PFC1, sdr0_pfc1); |
| 412 | |
| 413 | /*clear resets*/ |
| 414 | udelay(1000); |
| 415 | mtsdr(SDR0_SRST1, 0x00000000); |
| 416 | udelay(1000); |
| 417 | mtsdr(SDR0_SRST0, 0x00000000); |
| 418 | |
| 419 | printf("USB: Device\n"); |
| 420 | } |
| 421 | |
| 422 | /* |
| 423 | * Clear PLB4A0_ACR[WRP] |
| 424 | * This fix will make the MAL burst disabling patch for the Linux |
| 425 | * EMAC driver obsolete. |
| 426 | */ |
Stefan Roese | d1c3b27 | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 427 | reg = mfdcr(PLB4_ACR) & ~PLB4_ACR_WRP; |
| 428 | mtdcr(PLB4_ACR, reg); |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 429 | |
| 430 | #ifdef CONFIG_FPGA |
| 431 | pmc440_init_fpga(); |
| 432 | #endif |
| 433 | |
| 434 | /* turn off POST LED */ |
| 435 | out_be32((void*)GPIO1_OR, in_be32((void*)GPIO1_OR) & ~GPIO1_POST_N); |
| 436 | /* turn on RUN LED */ |
| 437 | out_be32((void*)GPIO0_OR, in_be32((void*)GPIO0_OR) & ~GPIO0_LED_RUN_N); |
| 438 | return 0; |
| 439 | } |
| 440 | |
| 441 | int is_monarch(void) |
| 442 | { |
| 443 | if (in_be32((void*)GPIO1_IR) & GPIO1_NONMONARCH) |
| 444 | return 0; |
| 445 | |
| 446 | return 1; |
| 447 | } |
| 448 | |
| 449 | int pci_is_66mhz(void) |
| 450 | { |
| 451 | if (in_be32((void*)GPIO1_IR) & GPIO1_M66EN) |
| 452 | return 1; |
| 453 | return 0; |
| 454 | } |
| 455 | |
| 456 | int board_revision(void) |
| 457 | { |
| 458 | return (int)((in_be32((void*)GPIO1_IR) & GPIO1_HWID_MASK) >> 4); |
| 459 | } |
| 460 | |
| 461 | int checkboard(void) |
| 462 | { |
| 463 | puts("Board: esd GmbH - PMC440"); |
| 464 | |
| 465 | gd->board_type = board_revision(); |
| 466 | printf(", Rev 1.%ld, ", gd->board_type); |
| 467 | |
| 468 | if (!is_monarch()) { |
| 469 | puts("non-"); |
| 470 | } |
| 471 | |
| 472 | printf("monarch, PCI=%s MHz\n", pci_is_66mhz() ? "66" : "33"); |
| 473 | return (0); |
| 474 | } |
| 475 | |
| 476 | |
| 477 | #if defined(CONFIG_PCI) && defined(CONFIG_PCI_PNP) |
| 478 | /* |
| 479 | * Assign interrupts to PCI devices. Some OSs rely on this. |
| 480 | */ |
Stefan Roese | a760b02 | 2009-11-12 16:41:09 +0100 | [diff] [blame^] | 481 | void board_pci_fixup_irq(struct pci_controller *hose, pci_dev_t dev) |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 482 | { |
| 483 | unsigned char int_line[] = {IRQ_PCIC, IRQ_PCID, IRQ_PCIA, IRQ_PCIB}; |
| 484 | |
| 485 | pci_hose_write_config_byte(hose, dev, PCI_INTERRUPT_LINE, |
| 486 | int_line[PCI_DEV(dev) & 0x03]); |
| 487 | } |
| 488 | #endif |
| 489 | |
Matthias Fuchs | 034394a | 2008-03-30 18:52:44 +0200 | [diff] [blame] | 490 | /* |
Matthias Fuchs | a6cc6c3 | 2008-03-30 18:52:06 +0200 | [diff] [blame] | 491 | * pci_target_init |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 492 | * |
Matthias Fuchs | a6cc6c3 | 2008-03-30 18:52:06 +0200 | [diff] [blame] | 493 | * The bootstrap configuration provides default settings for the pci |
| 494 | * inbound map (PIM). But the bootstrap config choices are limited and |
| 495 | * may not be sufficient for a given board. |
| 496 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 497 | #if defined(CONFIG_PCI) && defined(CONFIG_SYS_PCI_TARGET_INIT) |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 498 | void pci_target_init(struct pci_controller *hose) |
| 499 | { |
Matthias Fuchs | a6cc6c3 | 2008-03-30 18:52:06 +0200 | [diff] [blame] | 500 | char *ptmla_str, *ptmms_str; |
| 501 | |
| 502 | /* |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 503 | * Set up Direct MMIO registers |
Matthias Fuchs | a6cc6c3 | 2008-03-30 18:52:06 +0200 | [diff] [blame] | 504 | */ |
| 505 | /* |
| 506 | * PowerPC440EPX PCI Master configuration. |
| 507 | * Map one 1Gig range of PLB/processor addresses to PCI memory space. |
| 508 | * PLB address 0x80000000-0xBFFFFFFF |
| 509 | * ==> PCI address 0x80000000-0xBFFFFFFF |
| 510 | * Use byte reversed out routines to handle endianess. |
| 511 | * Make this region non-prefetchable. |
| 512 | */ |
Niklaus Giger | ddc922f | 2009-10-04 20:04:20 +0200 | [diff] [blame] | 513 | out32r(PCIL0_PMM0MA, 0x00000000); /* PMM0 Mask/Attribute */ |
Matthias Fuchs | a6cc6c3 | 2008-03-30 18:52:06 +0200 | [diff] [blame] | 514 | /* - disabled b4 setting */ |
Niklaus Giger | ddc922f | 2009-10-04 20:04:20 +0200 | [diff] [blame] | 515 | out32r(PCIL0_PMM0LA, CONFIG_SYS_PCI_MEMBASE); /* PMM0 Local Address */ |
| 516 | out32r(PCIL0_PMM0PCILA, CONFIG_SYS_PCI_MEMBASE); /* PMM0 PCI Low Address */ |
| 517 | out32r(PCIL0_PMM0PCIHA, 0x00000000); /* PMM0 PCI High Address */ |
| 518 | out32r(PCIL0_PMM0MA, 0xc0000001); /* 1G + No prefetching, */ |
Matthias Fuchs | a6cc6c3 | 2008-03-30 18:52:06 +0200 | [diff] [blame] | 519 | /* and enable region */ |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 520 | |
| 521 | if (!is_monarch()) { |
Matthias Fuchs | a6cc6c3 | 2008-03-30 18:52:06 +0200 | [diff] [blame] | 522 | ptmla_str = getenv("ptm1la"); |
| 523 | ptmms_str = getenv("ptm1ms"); |
| 524 | if(NULL != ptmla_str && NULL != ptmms_str ) { |
Niklaus Giger | ddc922f | 2009-10-04 20:04:20 +0200 | [diff] [blame] | 525 | out32r(PCIL0_PTM1MS, |
Matthias Fuchs | a6cc6c3 | 2008-03-30 18:52:06 +0200 | [diff] [blame] | 526 | simple_strtoul(ptmms_str, NULL, 16)); |
Niklaus Giger | ddc922f | 2009-10-04 20:04:20 +0200 | [diff] [blame] | 527 | out32r(PCIL0_PTM1LA, |
Matthias Fuchs | a6cc6c3 | 2008-03-30 18:52:06 +0200 | [diff] [blame] | 528 | simple_strtoul(ptmla_str, NULL, 16)); |
| 529 | } else { |
| 530 | /* BAR1: default top 64MB of RAM */ |
Niklaus Giger | ddc922f | 2009-10-04 20:04:20 +0200 | [diff] [blame] | 531 | out32r(PCIL0_PTM1MS, 0xfc000001); |
| 532 | out32r(PCIL0_PTM1LA, 0x0c000000); |
Matthias Fuchs | a6cc6c3 | 2008-03-30 18:52:06 +0200 | [diff] [blame] | 533 | } |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 534 | } else { |
Matthias Fuchs | a6cc6c3 | 2008-03-30 18:52:06 +0200 | [diff] [blame] | 535 | /* BAR1: default: complete 256MB RAM */ |
Niklaus Giger | ddc922f | 2009-10-04 20:04:20 +0200 | [diff] [blame] | 536 | out32r(PCIL0_PTM1MS, 0xf0000001); |
| 537 | out32r(PCIL0_PTM1LA, 0x00000000); |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 538 | } |
| 539 | |
Matthias Fuchs | a6cc6c3 | 2008-03-30 18:52:06 +0200 | [diff] [blame] | 540 | ptmla_str = getenv("ptm2la"); /* Local Addr. Reg */ |
| 541 | ptmms_str = getenv("ptm2ms"); /* Memory Size/Attribute */ |
| 542 | if(NULL != ptmla_str && NULL != ptmms_str ) { |
Niklaus Giger | ddc922f | 2009-10-04 20:04:20 +0200 | [diff] [blame] | 543 | out32r(PCIL0_PTM2MS, simple_strtoul(ptmms_str, NULL, 16)); |
| 544 | out32r(PCIL0_PTM2LA, simple_strtoul(ptmla_str, NULL, 16)); |
Matthias Fuchs | a6cc6c3 | 2008-03-30 18:52:06 +0200 | [diff] [blame] | 545 | } else { |
Matthias Fuchs | be27079 | 2008-10-28 13:37:00 +0100 | [diff] [blame] | 546 | /* BAR2: default: 4MB FPGA */ |
Niklaus Giger | ddc922f | 2009-10-04 20:04:20 +0200 | [diff] [blame] | 547 | out32r(PCIL0_PTM2MS, 0xffc00001); /* Memory Size/Attribute */ |
| 548 | out32r(PCIL0_PTM2LA, 0xef000000); /* Local Addr. Reg */ |
Matthias Fuchs | a6cc6c3 | 2008-03-30 18:52:06 +0200 | [diff] [blame] | 549 | } |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 550 | |
| 551 | if (is_monarch()) { |
| 552 | /* BAR2: map FPGA registers behind system memory at 1GB */ |
Matthias Fuchs | be27079 | 2008-10-28 13:37:00 +0100 | [diff] [blame] | 553 | pci_hose_write_config_dword(hose, 0, PCI_BASE_ADDRESS_2, 0x40000008); |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 554 | } |
| 555 | |
Matthias Fuchs | a6cc6c3 | 2008-03-30 18:52:06 +0200 | [diff] [blame] | 556 | /* |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 557 | * Set up Configuration registers |
Matthias Fuchs | a6cc6c3 | 2008-03-30 18:52:06 +0200 | [diff] [blame] | 558 | */ |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 559 | |
| 560 | /* Program the board's vendor id */ |
Matthias Fuchs | be27079 | 2008-10-28 13:37:00 +0100 | [diff] [blame] | 561 | pci_hose_write_config_word(hose, 0, PCI_SUBSYSTEM_VENDOR_ID, |
| 562 | CONFIG_SYS_PCI_SUBSYS_VENDORID); |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 563 | |
Stefan Roese | 02e3892 | 2008-03-31 12:20:48 +0200 | [diff] [blame] | 564 | /* disabled for PMC405 backward compatibility */ |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 565 | /* Configure command register as bus master */ |
Matthias Fuchs | 034394a | 2008-03-30 18:52:44 +0200 | [diff] [blame] | 566 | /* pci_write_config_word(0, PCI_COMMAND, PCI_COMMAND_MASTER); */ |
| 567 | |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 568 | |
| 569 | /* 240nS PCI clock */ |
Matthias Fuchs | be27079 | 2008-10-28 13:37:00 +0100 | [diff] [blame] | 570 | pci_hose_write_config_word(hose, 0, PCI_LATENCY_TIMER, 1); |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 571 | |
| 572 | /* No error reporting */ |
Matthias Fuchs | be27079 | 2008-10-28 13:37:00 +0100 | [diff] [blame] | 573 | pci_hose_write_config_word(hose, 0, PCI_ERREN, 0); |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 574 | |
| 575 | pci_write_config_dword(0, PCI_BRDGOPT2, 0x00000101); |
| 576 | |
| 577 | if (!is_monarch()) { |
| 578 | /* Program the board's subsystem id/classcode */ |
Matthias Fuchs | be27079 | 2008-10-28 13:37:00 +0100 | [diff] [blame] | 579 | pci_hose_write_config_word(hose, 0, PCI_SUBSYSTEM_ID, |
| 580 | CONFIG_SYS_PCI_SUBSYS_ID_NONMONARCH); |
| 581 | pci_hose_write_config_word(hose, 0, PCI_CLASS_SUB_CODE, |
| 582 | CONFIG_SYS_PCI_CLASSCODE_NONMONARCH); |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 583 | |
| 584 | /* PCI configuration done: release ERREADY */ |
Matthias Fuchs | a6cc6c3 | 2008-03-30 18:52:06 +0200 | [diff] [blame] | 585 | out_be32((void*)GPIO1_OR, |
| 586 | in_be32((void*)GPIO1_OR) | GPIO1_PPC_EREADY); |
| 587 | out_be32((void*)GPIO1_TCR, |
| 588 | in_be32((void*)GPIO1_TCR) | GPIO1_PPC_EREADY); |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 589 | } else { |
| 590 | /* Program the board's subsystem id/classcode */ |
Matthias Fuchs | be27079 | 2008-10-28 13:37:00 +0100 | [diff] [blame] | 591 | pci_hose_write_config_word(hose, 0, PCI_SUBSYSTEM_ID, |
| 592 | CONFIG_SYS_PCI_SUBSYS_ID_MONARCH); |
| 593 | pci_hose_write_config_word(hose, 0, PCI_CLASS_SUB_CODE, |
| 594 | CONFIG_SYS_PCI_CLASSCODE_MONARCH); |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 595 | } |
Matthias Fuchs | be27079 | 2008-10-28 13:37:00 +0100 | [diff] [blame] | 596 | |
| 597 | /* enable host configuration */ |
| 598 | pci_hose_write_config_dword(hose, 0, PCI_BRDGOPT2, 0x00000101); |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 599 | } |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 600 | #endif /* defined(CONFIG_PCI) && defined(CONFIG_SYS_PCI_TARGET_INIT) */ |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 601 | |
Matthias Fuchs | 034394a | 2008-03-30 18:52:44 +0200 | [diff] [blame] | 602 | /* |
| 603 | * pci_master_init |
| 604 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 605 | #if defined(CONFIG_PCI) && defined(CONFIG_SYS_PCI_MASTER_INIT) |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 606 | void pci_master_init(struct pci_controller *hose) |
| 607 | { |
| 608 | unsigned short temp_short; |
| 609 | |
Matthias Fuchs | 034394a | 2008-03-30 18:52:44 +0200 | [diff] [blame] | 610 | /* |
| 611 | * Write the PowerPC440 EP PCI Configuration regs. |
| 612 | * Enable PowerPC440 EP to be a master on the PCI bus (PMM). |
| 613 | * Enable PowerPC440 EP to act as a PCI memory target (PTM). |
| 614 | */ |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 615 | if (is_monarch()) { |
| 616 | pci_read_config_word(0, PCI_COMMAND, &temp_short); |
| 617 | pci_write_config_word(0, PCI_COMMAND, |
| 618 | temp_short | PCI_COMMAND_MASTER | |
| 619 | PCI_COMMAND_MEMORY); |
| 620 | } |
| 621 | } |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 622 | #endif /* defined(CONFIG_PCI) && defined(CONFIG_SYS_PCI_MASTER_INIT) */ |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 623 | |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 624 | static void wait_for_pci_ready(void) |
| 625 | { |
| 626 | int i; |
| 627 | char *s = getenv("pcidelay"); |
Matthias Fuchs | be27079 | 2008-10-28 13:37:00 +0100 | [diff] [blame] | 628 | /* |
| 629 | * We have our own handling of the pcidelay variable. |
| 630 | * Using CONFIG_PCI_BOOTDELAY enables pausing for host |
| 631 | * and adapter devices. For adapter devices we do not |
| 632 | * want this. |
| 633 | */ |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 634 | if (s) { |
| 635 | int ms = simple_strtoul(s, NULL, 10); |
| 636 | printf("PCI: Waiting for %d ms\n", ms); |
| 637 | for (i=0; i<ms; i++) |
| 638 | udelay(1000); |
| 639 | } |
| 640 | |
| 641 | if (!(in_be32((void*)GPIO1_IR) & GPIO1_PPC_EREADY)) { |
| 642 | printf("PCI: Waiting for EREADY (CTRL-C to skip) ... "); |
| 643 | while (1) { |
| 644 | if (ctrlc()) { |
| 645 | puts("abort\n"); |
| 646 | break; |
| 647 | } |
| 648 | if (in_be32((void*)GPIO1_IR) & GPIO1_PPC_EREADY) { |
| 649 | printf("done\n"); |
| 650 | break; |
| 651 | } |
| 652 | } |
| 653 | } |
| 654 | } |
| 655 | |
Matthias Fuchs | 034394a | 2008-03-30 18:52:44 +0200 | [diff] [blame] | 656 | /* |
Stefan Roese | 9a81c61 | 2009-10-29 16:54:52 +0100 | [diff] [blame] | 657 | * Override weak is_pci_host() |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 658 | * |
Matthias Fuchs | 034394a | 2008-03-30 18:52:44 +0200 | [diff] [blame] | 659 | * This routine is called to determine if a pci scan should be |
| 660 | * performed. With various hardware environments (especially cPCI and |
| 661 | * PPMC) it's insufficient to depend on the state of the arbiter enable |
| 662 | * bit in the strap register, or generic host/adapter assumptions. |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 663 | * |
Matthias Fuchs | 034394a | 2008-03-30 18:52:44 +0200 | [diff] [blame] | 664 | * Rather than hard-code a bad assumption in the general 440 code, the |
| 665 | * 440 pci code requires the board to decide at runtime. |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 666 | * |
Matthias Fuchs | 034394a | 2008-03-30 18:52:44 +0200 | [diff] [blame] | 667 | * Return 0 for adapter mode, non-zero for host (monarch) mode. |
| 668 | */ |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 669 | #if defined(CONFIG_PCI) |
| 670 | int is_pci_host(struct pci_controller *hose) |
| 671 | { |
| 672 | char *s = getenv("pciscan"); |
| 673 | if (s == NULL) |
| 674 | if (is_monarch()) { |
| 675 | wait_for_pci_ready(); |
| 676 | return 1; |
| 677 | } else |
| 678 | return 0; |
| 679 | else if (!strcmp(s, "yes")) |
| 680 | return 1; |
| 681 | |
| 682 | return 0; |
| 683 | } |
| 684 | #endif /* defined(CONFIG_PCI) */ |
Matthias Fuchs | 034394a | 2008-03-30 18:52:44 +0200 | [diff] [blame] | 685 | |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 686 | #if defined(CONFIG_POST) |
| 687 | /* |
| 688 | * Returns 1 if keys pressed to start the power-on long-running tests |
| 689 | * Called from board_init_f(). |
| 690 | */ |
| 691 | int post_hotkeys_pressed(void) |
| 692 | { |
| 693 | return 0; /* No hotkeys supported */ |
| 694 | } |
| 695 | #endif /* CONFIG_POST */ |
| 696 | |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 697 | #ifdef CONFIG_RESET_PHY_R |
| 698 | void reset_phy(void) |
| 699 | { |
Matthias Fuchs | 5b67a14 | 2008-12-10 15:12:56 +0100 | [diff] [blame] | 700 | char *s; |
| 701 | unsigned short val_method, val_behavior; |
| 702 | |
| 703 | /* special LED setup for NGCC/CANDES */ |
| 704 | if ((s = getenv("bd_type")) && |
| 705 | ((!strcmp(s, "ngcc")) || (!strcmp(s, "candes")))) { |
| 706 | val_method = 0x0e0a; |
| 707 | val_behavior = 0x0cf2; |
| 708 | } else { |
| 709 | /* PMC440 standard type */ |
| 710 | val_method = 0x0e10; |
| 711 | val_behavior = 0x0cf0; |
| 712 | } |
| 713 | |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 714 | if (miiphy_write("ppc_4xx_eth0", CONFIG_PHY_ADDR, 0x1f, 0x0001) == 0) { |
| 715 | miiphy_write("ppc_4xx_eth0", CONFIG_PHY_ADDR, 0x11, 0x0010); |
Matthias Fuchs | 5b67a14 | 2008-12-10 15:12:56 +0100 | [diff] [blame] | 716 | miiphy_write("ppc_4xx_eth0", CONFIG_PHY_ADDR, 0x11, val_behavior); |
| 717 | miiphy_write("ppc_4xx_eth0", CONFIG_PHY_ADDR, 0x10, val_method); |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 718 | miiphy_write("ppc_4xx_eth0", CONFIG_PHY_ADDR, 0x1f, 0x0000); |
| 719 | } |
| 720 | |
| 721 | if (miiphy_write("ppc_4xx_eth1", CONFIG_PHY1_ADDR, 0x1f, 0x0001) == 0) { |
| 722 | miiphy_write("ppc_4xx_eth1", CONFIG_PHY1_ADDR, 0x11, 0x0010); |
Matthias Fuchs | 5b67a14 | 2008-12-10 15:12:56 +0100 | [diff] [blame] | 723 | miiphy_write("ppc_4xx_eth1", CONFIG_PHY1_ADDR, 0x11, val_behavior); |
| 724 | miiphy_write("ppc_4xx_eth1", CONFIG_PHY1_ADDR, 0x10, val_method); |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 725 | miiphy_write("ppc_4xx_eth1", CONFIG_PHY1_ADDR, 0x1f, 0x0000); |
| 726 | } |
| 727 | } |
| 728 | #endif |
| 729 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 730 | #if defined(CONFIG_SYS_EEPROM_WREN) |
Matthias Fuchs | 034394a | 2008-03-30 18:52:44 +0200 | [diff] [blame] | 731 | /* |
| 732 | * Input: <dev_addr> I2C address of EEPROM device to enable. |
| 733 | * <state> -1: deliver current state |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 734 | * 0: disable write |
| 735 | * 1: enable write |
Matthias Fuchs | 034394a | 2008-03-30 18:52:44 +0200 | [diff] [blame] | 736 | * Returns: -1: wrong device address |
| 737 | * 0: dis-/en- able done |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 738 | * 0/1: current state if <state> was -1. |
| 739 | */ |
| 740 | int eeprom_write_enable(unsigned dev_addr, int state) |
| 741 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 742 | if ((CONFIG_SYS_I2C_EEPROM_ADDR != dev_addr) && |
| 743 | (CONFIG_SYS_I2C_BOOT_EEPROM_ADDR != dev_addr)) { |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 744 | return -1; |
| 745 | } else { |
| 746 | switch (state) { |
| 747 | case 1: |
| 748 | /* Enable write access, clear bit GPIO_SINT2. */ |
Matthias Fuchs | bb57ad4 | 2009-02-20 10:19:19 +0100 | [diff] [blame] | 749 | out_be32((void *)GPIO0_OR, |
| 750 | in_be32((void *)GPIO0_OR) & ~GPIO0_EP_EEP); |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 751 | state = 0; |
| 752 | break; |
| 753 | case 0: |
| 754 | /* Disable write access, set bit GPIO_SINT2. */ |
Matthias Fuchs | bb57ad4 | 2009-02-20 10:19:19 +0100 | [diff] [blame] | 755 | out_be32((void *)GPIO0_OR, |
| 756 | in_be32((void *)GPIO0_OR) | GPIO0_EP_EEP); |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 757 | state = 0; |
| 758 | break; |
| 759 | default: |
| 760 | /* Read current status back. */ |
Matthias Fuchs | bb57ad4 | 2009-02-20 10:19:19 +0100 | [diff] [blame] | 761 | state = (0 == (in_be32((void *)GPIO0_OR) |
| 762 | & GPIO0_EP_EEP)); |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 763 | break; |
| 764 | } |
| 765 | } |
| 766 | return state; |
| 767 | } |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 768 | #endif /* #if defined(CONFIG_SYS_EEPROM_WREN) */ |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 769 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 770 | #define CONFIG_SYS_BOOT_EEPROM_PAGE_WRITE_BITS 3 |
Matthias Fuchs | 034394a | 2008-03-30 18:52:44 +0200 | [diff] [blame] | 771 | int bootstrap_eeprom_write(unsigned dev_addr, unsigned offset, |
| 772 | uchar *buffer, unsigned cnt) |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 773 | { |
| 774 | unsigned end = offset + cnt; |
| 775 | unsigned blk_off; |
| 776 | int rcode = 0; |
| 777 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 778 | #if defined(CONFIG_SYS_EEPROM_WREN) |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 779 | eeprom_write_enable(dev_addr, 1); |
| 780 | #endif |
Matthias Fuchs | 034394a | 2008-03-30 18:52:44 +0200 | [diff] [blame] | 781 | /* |
| 782 | * Write data until done or would cross a write page boundary. |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 783 | * We must write the address again when changing pages |
| 784 | * because the address counter only increments within a page. |
| 785 | */ |
| 786 | |
| 787 | while (offset < end) { |
| 788 | unsigned alen, len; |
| 789 | unsigned maxlen; |
| 790 | uchar addr[2]; |
| 791 | |
| 792 | blk_off = offset & 0xFF; /* block offset */ |
| 793 | |
| 794 | addr[0] = offset >> 8; /* block number */ |
| 795 | addr[1] = blk_off; /* block offset */ |
| 796 | alen = 2; |
| 797 | addr[0] |= dev_addr; /* insert device address */ |
| 798 | |
| 799 | len = end - offset; |
| 800 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 801 | #define BOOT_EEPROM_PAGE_SIZE (1 << CONFIG_SYS_BOOT_EEPROM_PAGE_WRITE_BITS) |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 802 | #define BOOT_EEPROM_PAGE_OFFSET(x) ((x) & (BOOT_EEPROM_PAGE_SIZE - 1)) |
| 803 | |
Matthias Fuchs | 034394a | 2008-03-30 18:52:44 +0200 | [diff] [blame] | 804 | maxlen = BOOT_EEPROM_PAGE_SIZE - |
| 805 | BOOT_EEPROM_PAGE_OFFSET(blk_off); |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 806 | if (maxlen > I2C_RXTX_LEN) |
| 807 | maxlen = I2C_RXTX_LEN; |
| 808 | |
| 809 | if (len > maxlen) |
| 810 | len = maxlen; |
| 811 | |
| 812 | if (i2c_write (addr[0], offset, alen-1, buffer, len) != 0) |
| 813 | rcode = 1; |
| 814 | |
| 815 | buffer += len; |
| 816 | offset += len; |
| 817 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 818 | #if defined(CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS) |
| 819 | udelay(CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS * 1000); |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 820 | #endif |
| 821 | } |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 822 | #if defined(CONFIG_SYS_EEPROM_WREN) |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 823 | eeprom_write_enable(dev_addr, 0); |
| 824 | #endif |
| 825 | return rcode; |
| 826 | } |
| 827 | |
Matthias Fuchs | 034394a | 2008-03-30 18:52:44 +0200 | [diff] [blame] | 828 | int bootstrap_eeprom_read (unsigned dev_addr, unsigned offset, |
| 829 | uchar *buffer, unsigned cnt) |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 830 | { |
| 831 | unsigned end = offset + cnt; |
| 832 | unsigned blk_off; |
| 833 | int rcode = 0; |
| 834 | |
Matthias Fuchs | 034394a | 2008-03-30 18:52:44 +0200 | [diff] [blame] | 835 | /* |
| 836 | * Read data until done or would cross a page boundary. |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 837 | * We must write the address again when changing pages |
| 838 | * because the next page may be in a different device. |
| 839 | */ |
| 840 | while (offset < end) { |
| 841 | unsigned alen, len; |
| 842 | unsigned maxlen; |
| 843 | uchar addr[2]; |
| 844 | |
| 845 | blk_off = offset & 0xFF; /* block offset */ |
| 846 | |
| 847 | addr[0] = offset >> 8; /* block number */ |
| 848 | addr[1] = blk_off; /* block offset */ |
| 849 | alen = 2; |
| 850 | |
| 851 | addr[0] |= dev_addr; /* insert device address */ |
| 852 | |
| 853 | len = end - offset; |
| 854 | |
| 855 | maxlen = 0x100 - blk_off; |
| 856 | if (maxlen > I2C_RXTX_LEN) |
| 857 | maxlen = I2C_RXTX_LEN; |
| 858 | if (len > maxlen) |
| 859 | len = maxlen; |
| 860 | |
| 861 | if (i2c_read (addr[0], offset, alen-1, buffer, len) != 0) |
| 862 | rcode = 1; |
| 863 | buffer += len; |
| 864 | offset += len; |
| 865 | } |
| 866 | |
| 867 | return rcode; |
| 868 | } |
| 869 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 870 | #if defined(CONFIG_USB_OHCI_NEW) && defined(CONFIG_SYS_USB_OHCI_BOARD_INIT) |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 871 | int usb_board_init(void) |
| 872 | { |
| 873 | char *act = getenv("usbact"); |
| 874 | int i; |
| 875 | |
Matthias Fuchs | be27079 | 2008-10-28 13:37:00 +0100 | [diff] [blame] | 876 | if ((act == NULL || strcmp(act, "host") == 0) && |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 877 | !(in_be32((void*)GPIO0_IR) & GPIO0_USB_PRSNT)) |
| 878 | /* enable power on USB socket */ |
Matthias Fuchs | 034394a | 2008-03-30 18:52:44 +0200 | [diff] [blame] | 879 | out_be32((void*)GPIO1_OR, |
| 880 | in_be32((void*)GPIO1_OR) & ~GPIO1_USB_PWR_N); |
Matthias Fuchs | 72c5d52 | 2007-12-28 17:07:14 +0100 | [diff] [blame] | 881 | |
| 882 | for (i=0; i<1000; i++) |
| 883 | udelay(1000); |
| 884 | |
| 885 | return 0; |
| 886 | } |
| 887 | |
| 888 | int usb_board_stop(void) |
| 889 | { |
| 890 | /* disable power on USB socket */ |
| 891 | out_be32((void*)GPIO1_OR, in_be32((void*)GPIO1_OR) | GPIO1_USB_PWR_N); |
| 892 | return 0; |
| 893 | } |
| 894 | |
| 895 | int usb_board_init_fail(void) |
| 896 | { |
| 897 | usb_board_stop(); |
| 898 | return 0; |
| 899 | } |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 900 | #endif /* defined(CONFIG_USB_OHCI) && defined(CONFIG_SYS_USB_OHCI_BOARD_INIT) */ |
Matthias Fuchs | be27079 | 2008-10-28 13:37:00 +0100 | [diff] [blame] | 901 | |
| 902 | #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) |
| 903 | void ft_board_setup(void *blob, bd_t *bd) |
| 904 | { |
| 905 | int rc; |
| 906 | |
| 907 | __ft_board_setup(blob, bd); |
| 908 | |
| 909 | /* |
| 910 | * Disable PCI in non-monarch mode. |
| 911 | */ |
| 912 | if (!is_monarch()) { |
| 913 | rc = fdt_find_and_setprop(blob, "/plb/pci@1ec000000", "status", |
| 914 | "disabled", sizeof("disabled"), 1); |
| 915 | if (rc) { |
| 916 | printf("Unable to update property status in PCI node, err=%s\n", |
| 917 | fdt_strerror(rc)); |
| 918 | } |
| 919 | } |
| 920 | } |
| 921 | #endif /* defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) */ |