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