Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Dirk Eibach | b355f17 | 2015-10-28 11:46:32 +0100 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2014 |
Mario Six | b489358 | 2018-03-06 08:04:58 +0100 | [diff] [blame] | 4 | * Dirk Eibach, Guntermann & Drunck GmbH, dirk.eibach@gdsys.cc |
Dirk Eibach | b355f17 | 2015-10-28 11:46:32 +0100 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
Simon Glass | 0af6e2d | 2019-08-01 09:46:52 -0600 | [diff] [blame] | 8 | #include <env.h> |
Dirk Eibach | b355f17 | 2015-10-28 11:46:32 +0100 | [diff] [blame] | 9 | #include <hwconfig.h> |
| 10 | #include <i2c.h> |
| 11 | #include <spi.h> |
Masahiro Yamada | 75f82d0 | 2018-03-05 01:20:11 +0900 | [diff] [blame] | 12 | #include <linux/libfdt.h> |
Dirk Eibach | b355f17 | 2015-10-28 11:46:32 +0100 | [diff] [blame] | 13 | #include <fdt_support.h> |
| 14 | #include <pci.h> |
| 15 | #include <mpc83xx.h> |
| 16 | #include <fsl_esdhc.h> |
| 17 | #include <asm/io.h> |
| 18 | #include <asm/fsl_serdes.h> |
| 19 | #include <asm/fsl_mpc83xx_serdes.h> |
| 20 | |
| 21 | #include "mpc8308.h" |
| 22 | |
| 23 | #include <gdsys_fpga.h> |
| 24 | |
| 25 | #include "../common/adv7611.h" |
| 26 | #include "../common/ch7301.h" |
Dirk Eibach | e9539ed | 2016-03-16 09:20:11 +0100 | [diff] [blame] | 27 | #include "../common/dp501.h" |
Dirk Eibach | b355f17 | 2015-10-28 11:46:32 +0100 | [diff] [blame] | 28 | #include "../common/ioep-fpga.h" |
| 29 | #include "../common/mclink.h" |
| 30 | #include "../common/osd.h" |
| 31 | #include "../common/phy.h" |
Dirk Eibach | 9459433 | 2015-10-28 11:46:36 +0100 | [diff] [blame] | 32 | #include "../common/fanctrl.h" |
Dirk Eibach | b355f17 | 2015-10-28 11:46:32 +0100 | [diff] [blame] | 33 | |
| 34 | #include <pca953x.h> |
| 35 | #include <pca9698.h> |
| 36 | |
| 37 | #include <miiphy.h> |
| 38 | |
Dirk Eibach | b355f17 | 2015-10-28 11:46:32 +0100 | [diff] [blame] | 39 | #define MAX_MUX_CHANNELS 2 |
| 40 | |
| 41 | enum { |
| 42 | MCFPGA_DONE = 1 << 0, |
| 43 | MCFPGA_INIT_N = 1 << 1, |
| 44 | MCFPGA_PROGRAM_N = 1 << 2, |
| 45 | MCFPGA_UPDATE_ENABLE_N = 1 << 3, |
| 46 | MCFPGA_RESET_N = 1 << 4, |
| 47 | }; |
| 48 | |
| 49 | enum { |
| 50 | GPIO_MDC = 1 << 14, |
| 51 | GPIO_MDIO = 1 << 15, |
| 52 | }; |
| 53 | |
Mario Six | 3809c47 | 2019-03-29 10:18:06 +0100 | [diff] [blame] | 54 | uint mclink_fpgacount; |
Dirk Eibach | b355f17 | 2015-10-28 11:46:32 +0100 | [diff] [blame] | 55 | struct ihs_fpga *fpga_ptr[] = CONFIG_SYS_FPGA_PTR; |
| 56 | |
| 57 | struct { |
| 58 | u8 bus; |
| 59 | u8 addr; |
| 60 | } strider_fans[] = CONFIG_STRIDER_FANS; |
| 61 | |
| 62 | int fpga_set_reg(u32 fpga, u16 *reg, off_t regoff, u16 data) |
| 63 | { |
| 64 | int res; |
| 65 | |
| 66 | switch (fpga) { |
| 67 | case 0: |
| 68 | out_le16(reg, data); |
| 69 | break; |
| 70 | default: |
| 71 | res = mclink_send(fpga - 1, regoff, data); |
| 72 | if (res < 0) { |
| 73 | printf("mclink_send reg %02lx data %04x returned %d\n", |
| 74 | regoff, data, res); |
| 75 | return res; |
| 76 | } |
| 77 | break; |
| 78 | } |
| 79 | |
| 80 | return 0; |
| 81 | } |
| 82 | |
| 83 | int fpga_get_reg(u32 fpga, u16 *reg, off_t regoff, u16 *data) |
| 84 | { |
| 85 | int res; |
| 86 | |
| 87 | switch (fpga) { |
| 88 | case 0: |
| 89 | *data = in_le16(reg); |
| 90 | break; |
| 91 | default: |
| 92 | if (fpga > mclink_fpgacount) |
| 93 | return -EINVAL; |
| 94 | res = mclink_receive(fpga - 1, regoff, data); |
| 95 | if (res < 0) { |
| 96 | printf("mclink_receive reg %02lx returned %d\n", |
| 97 | regoff, res); |
| 98 | return res; |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | return 0; |
| 103 | } |
| 104 | |
| 105 | int checkboard(void) |
| 106 | { |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 107 | char *s = env_get("serial#"); |
Dirk Eibach | b355f17 | 2015-10-28 11:46:32 +0100 | [diff] [blame] | 108 | bool hw_type_cat = pca9698_get_value(0x20, 18); |
| 109 | |
| 110 | puts("Board: "); |
| 111 | |
| 112 | printf("Strider %s", hw_type_cat ? "CAT" : "Fiber"); |
| 113 | |
Mario Six | 3809c47 | 2019-03-29 10:18:06 +0100 | [diff] [blame] | 114 | if (s) { |
Dirk Eibach | b355f17 | 2015-10-28 11:46:32 +0100 | [diff] [blame] | 115 | puts(", serial# "); |
| 116 | puts(s); |
| 117 | } |
| 118 | |
| 119 | puts("\n"); |
| 120 | |
| 121 | return 0; |
| 122 | } |
| 123 | |
Dirk Eibach | b355f17 | 2015-10-28 11:46:32 +0100 | [diff] [blame] | 124 | int last_stage_init(void) |
| 125 | { |
| 126 | int slaves; |
Mario Six | 3809c47 | 2019-03-29 10:18:06 +0100 | [diff] [blame] | 127 | uint k; |
| 128 | uint mux_ch; |
| 129 | uchar mclink_controllers_dvi[] = { 0x3c, 0x3d, 0x3e }; |
Dirk Eibach | e9539ed | 2016-03-16 09:20:11 +0100 | [diff] [blame] | 130 | #ifdef CONFIG_STRIDER_CPU |
Mario Six | 3809c47 | 2019-03-29 10:18:06 +0100 | [diff] [blame] | 131 | uchar mclink_controllers_dp[] = { 0x24, 0x25, 0x26 }; |
Dirk Eibach | e9539ed | 2016-03-16 09:20:11 +0100 | [diff] [blame] | 132 | #endif |
Dirk Eibach | b355f17 | 2015-10-28 11:46:32 +0100 | [diff] [blame] | 133 | bool hw_type_cat = pca9698_get_value(0x20, 18); |
Dirk Eibach | 3c6a509 | 2016-06-02 09:05:41 +0200 | [diff] [blame] | 134 | #ifdef CONFIG_STRIDER_CON_DP |
| 135 | bool is_dh = pca9698_get_value(0x20, 25); |
| 136 | #endif |
Mario Six | 3809c47 | 2019-03-29 10:18:06 +0100 | [diff] [blame] | 137 | bool ch0_sgmii2_present; |
Dirk Eibach | b355f17 | 2015-10-28 11:46:32 +0100 | [diff] [blame] | 138 | |
| 139 | /* Turn on Analog Devices ADV7611 */ |
| 140 | pca9698_direction_output(0x20, 8, 0); |
| 141 | |
| 142 | /* Turn on Parade DP501 */ |
Dirk Eibach | e9539ed | 2016-03-16 09:20:11 +0100 | [diff] [blame] | 143 | pca9698_direction_output(0x20, 10, 1); |
Dirk Eibach | 3c6a509 | 2016-06-02 09:05:41 +0200 | [diff] [blame] | 144 | pca9698_direction_output(0x20, 11, 1); |
Dirk Eibach | b355f17 | 2015-10-28 11:46:32 +0100 | [diff] [blame] | 145 | |
| 146 | ch0_sgmii2_present = !pca9698_get_value(0x20, 37); |
| 147 | |
| 148 | /* wait for FPGA done, then reset FPGA */ |
Dirk Eibach | e9539ed | 2016-03-16 09:20:11 +0100 | [diff] [blame] | 149 | for (k = 0; k < ARRAY_SIZE(mclink_controllers_dvi); ++k) { |
Mario Six | 3809c47 | 2019-03-29 10:18:06 +0100 | [diff] [blame] | 150 | uint ctr = 0; |
| 151 | uchar *mclink_controllers = mclink_controllers_dvi; |
Dirk Eibach | b355f17 | 2015-10-28 11:46:32 +0100 | [diff] [blame] | 152 | |
Dirk Eibach | e9539ed | 2016-03-16 09:20:11 +0100 | [diff] [blame] | 153 | #ifdef CONFIG_STRIDER_CPU |
| 154 | if (i2c_probe(mclink_controllers[k])) { |
| 155 | mclink_controllers = mclink_controllers_dp; |
| 156 | if (i2c_probe(mclink_controllers[k])) |
| 157 | continue; |
| 158 | } |
| 159 | #else |
Dirk Eibach | b355f17 | 2015-10-28 11:46:32 +0100 | [diff] [blame] | 160 | if (i2c_probe(mclink_controllers[k])) |
| 161 | continue; |
Dirk Eibach | e9539ed | 2016-03-16 09:20:11 +0100 | [diff] [blame] | 162 | #endif |
Dirk Eibach | b355f17 | 2015-10-28 11:46:32 +0100 | [diff] [blame] | 163 | while (!(pca953x_get_val(mclink_controllers[k]) |
| 164 | & MCFPGA_DONE)) { |
Mario Six | 3809c47 | 2019-03-29 10:18:06 +0100 | [diff] [blame] | 165 | mdelay(100); |
Dirk Eibach | b355f17 | 2015-10-28 11:46:32 +0100 | [diff] [blame] | 166 | if (ctr++ > 5) { |
| 167 | printf("no done for mclink_controller %d\n", k); |
| 168 | break; |
| 169 | } |
| 170 | } |
| 171 | |
| 172 | pca953x_set_dir(mclink_controllers[k], MCFPGA_RESET_N, 0); |
| 173 | pca953x_set_val(mclink_controllers[k], MCFPGA_RESET_N, 0); |
| 174 | udelay(10); |
| 175 | pca953x_set_val(mclink_controllers[k], MCFPGA_RESET_N, |
| 176 | MCFPGA_RESET_N); |
| 177 | } |
| 178 | |
| 179 | if (hw_type_cat) { |
Joe Hershberger | 1fbcbed | 2016-08-08 11:28:38 -0500 | [diff] [blame] | 180 | int retval; |
| 181 | struct mii_dev *mdiodev = mdio_alloc(); |
Mario Six | 3809c47 | 2019-03-29 10:18:06 +0100 | [diff] [blame] | 182 | |
Joe Hershberger | 1fbcbed | 2016-08-08 11:28:38 -0500 | [diff] [blame] | 183 | if (!mdiodev) |
| 184 | return -ENOMEM; |
| 185 | strncpy(mdiodev->name, bb_miiphy_buses[0].name, MDIO_NAME_LEN); |
| 186 | mdiodev->read = bb_miiphy_read; |
| 187 | mdiodev->write = bb_miiphy_write; |
| 188 | |
| 189 | retval = mdio_register(mdiodev); |
| 190 | if (retval < 0) |
| 191 | return retval; |
Dirk Eibach | b355f17 | 2015-10-28 11:46:32 +0100 | [diff] [blame] | 192 | for (mux_ch = 0; mux_ch < MAX_MUX_CHANNELS; ++mux_ch) { |
| 193 | if ((mux_ch == 1) && !ch0_sgmii2_present) |
| 194 | continue; |
| 195 | |
| 196 | setup_88e1514(bb_miiphy_buses[0].name, mux_ch); |
| 197 | } |
| 198 | } |
| 199 | |
| 200 | /* give slave-PLLs and Parade DP501 some time to be up and running */ |
Mario Six | 3809c47 | 2019-03-29 10:18:06 +0100 | [diff] [blame] | 201 | mdelay(500); |
Dirk Eibach | b355f17 | 2015-10-28 11:46:32 +0100 | [diff] [blame] | 202 | |
| 203 | mclink_fpgacount = CONFIG_SYS_MCLINK_MAX; |
| 204 | slaves = mclink_probe(); |
| 205 | mclink_fpgacount = 0; |
| 206 | |
| 207 | ioep_fpga_print_info(0); |
| 208 | |
| 209 | if (!adv7611_probe(0)) |
| 210 | printf(" Advantiv ADV7611 HDMI Receiver\n"); |
| 211 | |
| 212 | #ifdef CONFIG_STRIDER_CON |
| 213 | if (ioep_fpga_has_osd(0)) |
| 214 | osd_probe(0); |
| 215 | #endif |
| 216 | |
Dirk Eibach | 3c6a509 | 2016-06-02 09:05:41 +0200 | [diff] [blame] | 217 | #ifdef CONFIG_STRIDER_CON_DP |
| 218 | if (ioep_fpga_has_osd(0)) { |
| 219 | osd_probe(0); |
| 220 | if (is_dh) |
| 221 | osd_probe(4); |
| 222 | } |
| 223 | #endif |
| 224 | |
Dirk Eibach | b355f17 | 2015-10-28 11:46:32 +0100 | [diff] [blame] | 225 | #ifdef CONFIG_STRIDER_CPU |
| 226 | ch7301_probe(0, false); |
Dirk Eibach | e9539ed | 2016-03-16 09:20:11 +0100 | [diff] [blame] | 227 | dp501_probe(0, false); |
Dirk Eibach | b355f17 | 2015-10-28 11:46:32 +0100 | [diff] [blame] | 228 | #endif |
| 229 | |
| 230 | if (slaves <= 0) |
| 231 | return 0; |
| 232 | |
| 233 | mclink_fpgacount = slaves; |
| 234 | |
Dirk Eibach | e9539ed | 2016-03-16 09:20:11 +0100 | [diff] [blame] | 235 | #ifdef CONFIG_STRIDER_CPU |
| 236 | /* get ADV7611 out of reset, power up DP501, give some time to wakeup */ |
| 237 | for (k = 1; k <= slaves; ++k) |
| 238 | FPGA_SET_REG(k, extended_control, 0x10); /* enable video */ |
| 239 | |
Mario Six | 3809c47 | 2019-03-29 10:18:06 +0100 | [diff] [blame] | 240 | mdelay(500); |
Dirk Eibach | e9539ed | 2016-03-16 09:20:11 +0100 | [diff] [blame] | 241 | #endif |
| 242 | |
Dirk Eibach | b355f17 | 2015-10-28 11:46:32 +0100 | [diff] [blame] | 243 | for (k = 1; k <= slaves; ++k) { |
| 244 | ioep_fpga_print_info(k); |
| 245 | #ifdef CONFIG_STRIDER_CON |
| 246 | if (ioep_fpga_has_osd(k)) |
| 247 | osd_probe(k); |
| 248 | #endif |
Dirk Eibach | 3c6a509 | 2016-06-02 09:05:41 +0200 | [diff] [blame] | 249 | #ifdef CONFIG_STRIDER_CON_DP |
| 250 | if (ioep_fpga_has_osd(k)) { |
| 251 | osd_probe(k); |
| 252 | if (is_dh) |
| 253 | osd_probe(k + 4); |
| 254 | } |
| 255 | #endif |
Dirk Eibach | b355f17 | 2015-10-28 11:46:32 +0100 | [diff] [blame] | 256 | #ifdef CONFIG_STRIDER_CPU |
Dirk Eibach | b355f17 | 2015-10-28 11:46:32 +0100 | [diff] [blame] | 257 | if (!adv7611_probe(k)) |
| 258 | printf(" Advantiv ADV7611 HDMI Receiver\n"); |
| 259 | ch7301_probe(k, false); |
Dirk Eibach | e9539ed | 2016-03-16 09:20:11 +0100 | [diff] [blame] | 260 | dp501_probe(k, false); |
Dirk Eibach | b355f17 | 2015-10-28 11:46:32 +0100 | [diff] [blame] | 261 | #endif |
| 262 | if (hw_type_cat) { |
Joe Hershberger | 1fbcbed | 2016-08-08 11:28:38 -0500 | [diff] [blame] | 263 | int retval; |
| 264 | struct mii_dev *mdiodev = mdio_alloc(); |
Mario Six | 3809c47 | 2019-03-29 10:18:06 +0100 | [diff] [blame] | 265 | |
Joe Hershberger | 1fbcbed | 2016-08-08 11:28:38 -0500 | [diff] [blame] | 266 | if (!mdiodev) |
| 267 | return -ENOMEM; |
| 268 | strncpy(mdiodev->name, bb_miiphy_buses[k].name, |
| 269 | MDIO_NAME_LEN); |
| 270 | mdiodev->read = bb_miiphy_read; |
| 271 | mdiodev->write = bb_miiphy_write; |
| 272 | |
| 273 | retval = mdio_register(mdiodev); |
| 274 | if (retval < 0) |
| 275 | return retval; |
Dirk Eibach | b355f17 | 2015-10-28 11:46:32 +0100 | [diff] [blame] | 276 | setup_88e1514(bb_miiphy_buses[k].name, 0); |
| 277 | } |
| 278 | } |
| 279 | |
| 280 | for (k = 0; k < ARRAY_SIZE(strider_fans); ++k) { |
| 281 | i2c_set_bus_num(strider_fans[k].bus); |
| 282 | init_fan_controller(strider_fans[k].addr); |
| 283 | } |
| 284 | |
| 285 | return 0; |
| 286 | } |
| 287 | |
| 288 | /* |
| 289 | * provide access to fpga gpios (for I2C bitbang) |
| 290 | * (these may look all too simple but make iocon.h much more readable) |
| 291 | */ |
Mario Six | 3809c47 | 2019-03-29 10:18:06 +0100 | [diff] [blame] | 292 | void fpga_gpio_set(uint bus, int pin) |
Dirk Eibach | b355f17 | 2015-10-28 11:46:32 +0100 | [diff] [blame] | 293 | { |
| 294 | FPGA_SET_REG(bus, gpio.set, pin); |
| 295 | } |
| 296 | |
Mario Six | 3809c47 | 2019-03-29 10:18:06 +0100 | [diff] [blame] | 297 | void fpga_gpio_clear(uint bus, int pin) |
Dirk Eibach | b355f17 | 2015-10-28 11:46:32 +0100 | [diff] [blame] | 298 | { |
| 299 | FPGA_SET_REG(bus, gpio.clear, pin); |
| 300 | } |
| 301 | |
Mario Six | 3809c47 | 2019-03-29 10:18:06 +0100 | [diff] [blame] | 302 | int fpga_gpio_get(uint bus, int pin) |
Dirk Eibach | b355f17 | 2015-10-28 11:46:32 +0100 | [diff] [blame] | 303 | { |
| 304 | u16 val; |
| 305 | |
| 306 | FPGA_GET_REG(bus, gpio.read, &val); |
| 307 | |
| 308 | return val & pin; |
| 309 | } |
| 310 | |
Dirk Eibach | 3c6a509 | 2016-06-02 09:05:41 +0200 | [diff] [blame] | 311 | #ifdef CONFIG_STRIDER_CON_DP |
Mario Six | 3809c47 | 2019-03-29 10:18:06 +0100 | [diff] [blame] | 312 | void fpga_control_set(uint bus, int pin) |
Dirk Eibach | 3c6a509 | 2016-06-02 09:05:41 +0200 | [diff] [blame] | 313 | { |
| 314 | u16 val; |
| 315 | |
| 316 | FPGA_GET_REG(bus, control, &val); |
| 317 | FPGA_SET_REG(bus, control, val | pin); |
| 318 | } |
| 319 | |
Mario Six | 3809c47 | 2019-03-29 10:18:06 +0100 | [diff] [blame] | 320 | void fpga_control_clear(uint bus, int pin) |
Dirk Eibach | 3c6a509 | 2016-06-02 09:05:41 +0200 | [diff] [blame] | 321 | { |
| 322 | u16 val; |
| 323 | |
| 324 | FPGA_GET_REG(bus, control, &val); |
| 325 | FPGA_SET_REG(bus, control, val & ~pin); |
| 326 | } |
| 327 | #endif |
| 328 | |
Dirk Eibach | b355f17 | 2015-10-28 11:46:32 +0100 | [diff] [blame] | 329 | void mpc8308_init(void) |
| 330 | { |
| 331 | pca9698_direction_output(0x20, 26, 1); |
| 332 | } |
| 333 | |
Mario Six | 3809c47 | 2019-03-29 10:18:06 +0100 | [diff] [blame] | 334 | void mpc8308_set_fpga_reset(uint state) |
Dirk Eibach | b355f17 | 2015-10-28 11:46:32 +0100 | [diff] [blame] | 335 | { |
| 336 | pca9698_set_value(0x20, 26, state ? 0 : 1); |
| 337 | } |
| 338 | |
| 339 | void mpc8308_setup_hw(void) |
| 340 | { |
| 341 | immap_t *immr = (immap_t *)CONFIG_SYS_IMMR; |
| 342 | |
| 343 | /* |
| 344 | * set "startup-finished"-gpios |
| 345 | */ |
Mario Six | 3809c47 | 2019-03-29 10:18:06 +0100 | [diff] [blame] | 346 | setbits_be32(&immr->gpio[0].dir, BIT(31 - 11) | BIT(31 - 12)); |
Mario Six | ae0feaa | 2019-03-29 10:18:07 +0100 | [diff] [blame] | 347 | setbits_gpio0_out(BIT(31 - 12)); |
Dirk Eibach | b355f17 | 2015-10-28 11:46:32 +0100 | [diff] [blame] | 348 | } |
| 349 | |
Mario Six | 3809c47 | 2019-03-29 10:18:06 +0100 | [diff] [blame] | 350 | int mpc8308_get_fpga_done(uint fpga) |
Dirk Eibach | b355f17 | 2015-10-28 11:46:32 +0100 | [diff] [blame] | 351 | { |
| 352 | return pca9698_get_value(0x20, 20); |
| 353 | } |
| 354 | |
| 355 | #ifdef CONFIG_FSL_ESDHC |
| 356 | int board_mmc_init(bd_t *bd) |
| 357 | { |
| 358 | immap_t *immr = (immap_t *)CONFIG_SYS_IMMR; |
| 359 | sysconf83xx_t *sysconf = &immr->sysconf; |
| 360 | |
| 361 | /* Enable cache snooping in eSDHC system configuration register */ |
| 362 | out_be32(&sysconf->sdhccr, 0x02000000); |
| 363 | |
| 364 | return fsl_esdhc_mmc_init(bd); |
| 365 | } |
| 366 | #endif |
| 367 | |
| 368 | static struct pci_region pcie_regions_0[] = { |
| 369 | { |
| 370 | .bus_start = CONFIG_SYS_PCIE1_MEM_BASE, |
| 371 | .phys_start = CONFIG_SYS_PCIE1_MEM_PHYS, |
| 372 | .size = CONFIG_SYS_PCIE1_MEM_SIZE, |
| 373 | .flags = PCI_REGION_MEM, |
| 374 | }, |
| 375 | { |
| 376 | .bus_start = CONFIG_SYS_PCIE1_IO_BASE, |
| 377 | .phys_start = CONFIG_SYS_PCIE1_IO_PHYS, |
| 378 | .size = CONFIG_SYS_PCIE1_IO_SIZE, |
| 379 | .flags = PCI_REGION_IO, |
| 380 | }, |
| 381 | }; |
| 382 | |
| 383 | void pci_init_board(void) |
| 384 | { |
| 385 | immap_t *immr = (immap_t *)CONFIG_SYS_IMMR; |
| 386 | sysconf83xx_t *sysconf = &immr->sysconf; |
| 387 | law83xx_t *pcie_law = sysconf->pcielaw; |
| 388 | struct pci_region *pcie_reg[] = { pcie_regions_0 }; |
| 389 | |
| 390 | fsl_setup_serdes(CONFIG_FSL_SERDES1, FSL_SERDES_PROTO_PEX, |
| 391 | FSL_SERDES_CLK_100, FSL_SERDES_VDD_1V); |
| 392 | |
| 393 | /* Deassert the resets in the control register */ |
| 394 | out_be32(&sysconf->pecr1, 0xE0008000); |
| 395 | udelay(2000); |
| 396 | |
| 397 | /* Configure PCI Express Local Access Windows */ |
| 398 | out_be32(&pcie_law[0].bar, CONFIG_SYS_PCIE1_BASE & LAWBAR_BAR); |
| 399 | out_be32(&pcie_law[0].ar, LBLAWAR_EN | LBLAWAR_512MB); |
| 400 | |
| 401 | mpc83xx_pcie_init(1, pcie_reg); |
| 402 | } |
| 403 | |
| 404 | ulong board_flash_get_legacy(ulong base, int banknum, flash_info_t *info) |
| 405 | { |
| 406 | info->portwidth = FLASH_CFI_16BIT; |
| 407 | info->chipwidth = FLASH_CFI_BY16; |
| 408 | info->interface = FLASH_CFI_X16; |
| 409 | return 1; |
| 410 | } |
| 411 | |
| 412 | #if defined(CONFIG_OF_BOARD_SETUP) |
| 413 | int ft_board_setup(void *blob, bd_t *bd) |
| 414 | { |
| 415 | ft_cpu_setup(blob, bd); |
Sriram Dash | 9fd465c | 2016-09-16 17:12:15 +0530 | [diff] [blame] | 416 | fsl_fdt_fixup_dr_usb(blob, bd); |
Dirk Eibach | b355f17 | 2015-10-28 11:46:32 +0100 | [diff] [blame] | 417 | fdt_fixup_esdhc(blob, bd); |
| 418 | |
| 419 | return 0; |
| 420 | } |
| 421 | #endif |
| 422 | |
| 423 | /* |
| 424 | * FPGA MII bitbang implementation |
| 425 | */ |
| 426 | |
| 427 | struct fpga_mii { |
Mario Six | 3809c47 | 2019-03-29 10:18:06 +0100 | [diff] [blame] | 428 | uint fpga; |
Dirk Eibach | b355f17 | 2015-10-28 11:46:32 +0100 | [diff] [blame] | 429 | int mdio; |
| 430 | } fpga_mii[] = { |
| 431 | { 0, 1}, |
| 432 | { 1, 1}, |
| 433 | { 2, 1}, |
| 434 | { 3, 1}, |
| 435 | }; |
| 436 | |
| 437 | static int mii_dummy_init(struct bb_miiphy_bus *bus) |
| 438 | { |
| 439 | return 0; |
| 440 | } |
| 441 | |
| 442 | static int mii_mdio_active(struct bb_miiphy_bus *bus) |
| 443 | { |
| 444 | struct fpga_mii *fpga_mii = bus->priv; |
| 445 | |
| 446 | if (fpga_mii->mdio) |
| 447 | FPGA_SET_REG(fpga_mii->fpga, gpio.set, GPIO_MDIO); |
| 448 | else |
| 449 | FPGA_SET_REG(fpga_mii->fpga, gpio.clear, GPIO_MDIO); |
| 450 | |
| 451 | return 0; |
| 452 | } |
| 453 | |
| 454 | static int mii_mdio_tristate(struct bb_miiphy_bus *bus) |
| 455 | { |
| 456 | struct fpga_mii *fpga_mii = bus->priv; |
| 457 | |
| 458 | FPGA_SET_REG(fpga_mii->fpga, gpio.set, GPIO_MDIO); |
| 459 | |
| 460 | return 0; |
| 461 | } |
| 462 | |
| 463 | static int mii_set_mdio(struct bb_miiphy_bus *bus, int v) |
| 464 | { |
| 465 | struct fpga_mii *fpga_mii = bus->priv; |
| 466 | |
| 467 | if (v) |
| 468 | FPGA_SET_REG(fpga_mii->fpga, gpio.set, GPIO_MDIO); |
| 469 | else |
| 470 | FPGA_SET_REG(fpga_mii->fpga, gpio.clear, GPIO_MDIO); |
| 471 | |
| 472 | fpga_mii->mdio = v; |
| 473 | |
| 474 | return 0; |
| 475 | } |
| 476 | |
| 477 | static int mii_get_mdio(struct bb_miiphy_bus *bus, int *v) |
| 478 | { |
| 479 | u16 gpio; |
| 480 | struct fpga_mii *fpga_mii = bus->priv; |
| 481 | |
| 482 | FPGA_GET_REG(fpga_mii->fpga, gpio.read, &gpio); |
| 483 | |
| 484 | *v = ((gpio & GPIO_MDIO) != 0); |
| 485 | |
| 486 | return 0; |
| 487 | } |
| 488 | |
| 489 | static int mii_set_mdc(struct bb_miiphy_bus *bus, int v) |
| 490 | { |
| 491 | struct fpga_mii *fpga_mii = bus->priv; |
| 492 | |
| 493 | if (v) |
| 494 | FPGA_SET_REG(fpga_mii->fpga, gpio.set, GPIO_MDC); |
| 495 | else |
| 496 | FPGA_SET_REG(fpga_mii->fpga, gpio.clear, GPIO_MDC); |
| 497 | |
| 498 | return 0; |
| 499 | } |
| 500 | |
| 501 | static int mii_delay(struct bb_miiphy_bus *bus) |
| 502 | { |
| 503 | udelay(1); |
| 504 | |
| 505 | return 0; |
| 506 | } |
| 507 | |
| 508 | struct bb_miiphy_bus bb_miiphy_buses[] = { |
| 509 | { |
| 510 | .name = "board0", |
| 511 | .init = mii_dummy_init, |
| 512 | .mdio_active = mii_mdio_active, |
| 513 | .mdio_tristate = mii_mdio_tristate, |
| 514 | .set_mdio = mii_set_mdio, |
| 515 | .get_mdio = mii_get_mdio, |
| 516 | .set_mdc = mii_set_mdc, |
| 517 | .delay = mii_delay, |
| 518 | .priv = &fpga_mii[0], |
| 519 | }, |
| 520 | { |
| 521 | .name = "board1", |
| 522 | .init = mii_dummy_init, |
| 523 | .mdio_active = mii_mdio_active, |
| 524 | .mdio_tristate = mii_mdio_tristate, |
| 525 | .set_mdio = mii_set_mdio, |
| 526 | .get_mdio = mii_get_mdio, |
| 527 | .set_mdc = mii_set_mdc, |
| 528 | .delay = mii_delay, |
| 529 | .priv = &fpga_mii[1], |
| 530 | }, |
| 531 | { |
| 532 | .name = "board2", |
| 533 | .init = mii_dummy_init, |
| 534 | .mdio_active = mii_mdio_active, |
| 535 | .mdio_tristate = mii_mdio_tristate, |
| 536 | .set_mdio = mii_set_mdio, |
| 537 | .get_mdio = mii_get_mdio, |
| 538 | .set_mdc = mii_set_mdc, |
| 539 | .delay = mii_delay, |
| 540 | .priv = &fpga_mii[2], |
| 541 | }, |
| 542 | { |
| 543 | .name = "board3", |
| 544 | .init = mii_dummy_init, |
| 545 | .mdio_active = mii_mdio_active, |
| 546 | .mdio_tristate = mii_mdio_tristate, |
| 547 | .set_mdio = mii_set_mdio, |
| 548 | .get_mdio = mii_get_mdio, |
| 549 | .set_mdc = mii_set_mdc, |
| 550 | .delay = mii_delay, |
| 551 | .priv = &fpga_mii[3], |
| 552 | }, |
| 553 | }; |
| 554 | |
Mario Six | 3809c47 | 2019-03-29 10:18:06 +0100 | [diff] [blame] | 555 | int bb_miiphy_buses_num = ARRAY_SIZE(bb_miiphy_buses); |