Alex Marginean | 7a910c1 | 2019-07-03 12:11:40 +0300 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * ENETC ethernet controller driver |
Vladimir Oltean | 10c6fe4 | 2021-06-29 20:53:15 +0300 | [diff] [blame] | 4 | * Copyright 2017-2021 NXP |
Alex Marginean | 7a910c1 | 2019-07-03 12:11:40 +0300 | [diff] [blame] | 5 | */ |
| 6 | |
Alex Marginean | 7a910c1 | 2019-07-03 12:11:40 +0300 | [diff] [blame] | 7 | #include <dm.h> |
| 8 | #include <errno.h> |
Simon Glass | 2dc9c34 | 2020-05-10 11:40:01 -0600 | [diff] [blame] | 9 | #include <fdt_support.h> |
Simon Glass | 9bc1564 | 2020-02-03 07:36:16 -0700 | [diff] [blame] | 10 | #include <malloc.h> |
Alex Marginean | 7a910c1 | 2019-07-03 12:11:40 +0300 | [diff] [blame] | 11 | #include <memalign.h> |
Simon Glass | 274e0b0 | 2020-05-10 11:39:56 -0600 | [diff] [blame] | 12 | #include <net.h> |
| 13 | #include <asm/cache.h> |
Alex Marginean | 7a910c1 | 2019-07-03 12:11:40 +0300 | [diff] [blame] | 14 | #include <asm/io.h> |
| 15 | #include <pci.h> |
Alex Marginean | 0215539 | 2019-07-03 12:11:41 +0300 | [diff] [blame] | 16 | #include <miiphy.h> |
Simon Glass | c06c1be | 2020-05-10 11:40:08 -0600 | [diff] [blame] | 17 | #include <linux/bug.h> |
Simon Glass | dbd7954 | 2020-05-10 11:40:11 -0600 | [diff] [blame] | 18 | #include <linux/delay.h> |
Alex Marginean | 7a910c1 | 2019-07-03 12:11:40 +0300 | [diff] [blame] | 19 | |
| 20 | #include "fsl_enetc.h" |
| 21 | |
Alex Marginean | 805b859 | 2019-12-10 16:55:39 +0200 | [diff] [blame] | 22 | #define ENETC_DRIVER_NAME "enetc_eth" |
| 23 | |
Siarhei Yasinski | 25b798e | 2022-08-31 10:57:37 +0000 | [diff] [blame] | 24 | static int enetc_remove(struct udevice *dev); |
| 25 | |
Alex Marginean | 805b859 | 2019-12-10 16:55:39 +0200 | [diff] [blame] | 26 | /* |
| 27 | * sets the MAC address in IERB registers, this setting is persistent and |
| 28 | * carried over to Linux. |
| 29 | */ |
| 30 | static void enetc_set_ierb_primary_mac(struct udevice *dev, int devfn, |
| 31 | const u8 *enetaddr) |
| 32 | { |
| 33 | #ifdef CONFIG_ARCH_LS1028A |
| 34 | /* |
| 35 | * LS1028A is the only part with IERB at this time and there are plans to change |
| 36 | * its structure, keep this LS1028A specific for now |
| 37 | */ |
| 38 | #define IERB_BASE 0x1f0800000ULL |
| 39 | #define IERB_PFMAC(pf, vf, n) (IERB_BASE + 0x8000 + (pf) * 0x100 + (vf) * 8 \ |
| 40 | + (n) * 4) |
| 41 | |
| 42 | static int ierb_fn_to_pf[] = {0, 1, 2, -1, -1, -1, 3}; |
| 43 | |
| 44 | u16 lower = *(const u16 *)(enetaddr + 4); |
| 45 | u32 upper = *(const u32 *)enetaddr; |
| 46 | |
| 47 | if (ierb_fn_to_pf[devfn] < 0) |
| 48 | return; |
| 49 | |
| 50 | out_le32(IERB_PFMAC(ierb_fn_to_pf[devfn], 0, 0), upper); |
| 51 | out_le32(IERB_PFMAC(ierb_fn_to_pf[devfn], 0, 1), (u32)lower); |
| 52 | #endif |
| 53 | } |
| 54 | |
| 55 | /* sets up primary MAC addresses in DT/IERB */ |
| 56 | void fdt_fixup_enetc_mac(void *blob) |
| 57 | { |
Simon Glass | b75b15b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 58 | struct pci_child_plat *ppdata; |
Alex Marginean | 805b859 | 2019-12-10 16:55:39 +0200 | [diff] [blame] | 59 | struct eth_pdata *pdata; |
| 60 | struct udevice *dev; |
| 61 | struct uclass *uc; |
| 62 | char path[256]; |
| 63 | int offset; |
| 64 | int devfn; |
| 65 | |
| 66 | uclass_get(UCLASS_ETH, &uc); |
| 67 | uclass_foreach_dev(dev, uc) { |
| 68 | if (!dev->driver || !dev->driver->name || |
| 69 | strcmp(dev->driver->name, ENETC_DRIVER_NAME)) |
| 70 | continue; |
| 71 | |
Simon Glass | fa20e93 | 2020-12-03 16:55:20 -0700 | [diff] [blame] | 72 | pdata = dev_get_plat(dev); |
Simon Glass | 71fa5b4 | 2020-12-03 16:55:18 -0700 | [diff] [blame] | 73 | ppdata = dev_get_parent_plat(dev); |
Alex Marginean | 805b859 | 2019-12-10 16:55:39 +0200 | [diff] [blame] | 74 | devfn = PCI_FUNC(ppdata->devfn); |
| 75 | |
| 76 | enetc_set_ierb_primary_mac(dev, devfn, pdata->enetaddr); |
| 77 | |
| 78 | snprintf(path, 256, "/soc/pcie@1f0000000/ethernet@%x,%x", |
| 79 | PCI_DEV(ppdata->devfn), PCI_FUNC(ppdata->devfn)); |
| 80 | offset = fdt_path_offset(blob, path); |
| 81 | if (offset < 0) |
| 82 | continue; |
| 83 | fdt_setprop(blob, offset, "mac-address", pdata->enetaddr, 6); |
| 84 | } |
| 85 | } |
| 86 | |
Alex Marginean | 7a910c1 | 2019-07-03 12:11:40 +0300 | [diff] [blame] | 87 | /* |
| 88 | * Bind the device: |
| 89 | * - set a more explicit name on the interface |
| 90 | */ |
| 91 | static int enetc_bind(struct udevice *dev) |
| 92 | { |
| 93 | char name[16]; |
| 94 | static int eth_num_devices; |
| 95 | |
| 96 | /* |
| 97 | * prefer using PCI function numbers to number interfaces, but these |
| 98 | * are only available if dts nodes are present. For PCI they are |
| 99 | * optional, handle that case too. Just in case some nodes are present |
| 100 | * and some are not, use different naming scheme - enetc-N based on |
| 101 | * PCI function # and enetc#N based on interface count |
| 102 | */ |
Simon Glass | a7ece58 | 2020-12-19 10:40:14 -0700 | [diff] [blame] | 103 | if (ofnode_valid(dev_ofnode(dev))) |
Alex Marginean | 7a910c1 | 2019-07-03 12:11:40 +0300 | [diff] [blame] | 104 | sprintf(name, "enetc-%u", PCI_FUNC(pci_get_devfn(dev))); |
| 105 | else |
| 106 | sprintf(name, "enetc#%u", eth_num_devices++); |
| 107 | device_set_name(dev, name); |
| 108 | |
| 109 | return 0; |
| 110 | } |
| 111 | |
Alex Marginean | 38882ae | 2019-07-03 12:11:42 +0300 | [diff] [blame] | 112 | /* MDIO wrappers, we're using these to drive internal MDIO to get to serdes */ |
| 113 | static int enetc_mdio_read(struct mii_dev *bus, int addr, int devad, int reg) |
| 114 | { |
| 115 | struct enetc_mdio_priv priv; |
| 116 | |
| 117 | priv.regs_base = bus->priv; |
| 118 | return enetc_mdio_read_priv(&priv, addr, devad, reg); |
| 119 | } |
| 120 | |
| 121 | static int enetc_mdio_write(struct mii_dev *bus, int addr, int devad, int reg, |
| 122 | u16 val) |
| 123 | { |
| 124 | struct enetc_mdio_priv priv; |
| 125 | |
| 126 | priv.regs_base = bus->priv; |
| 127 | return enetc_mdio_write_priv(&priv, addr, devad, reg, val); |
| 128 | } |
| 129 | |
| 130 | /* only interfaces that can pin out through serdes have internal MDIO */ |
| 131 | static bool enetc_has_imdio(struct udevice *dev) |
| 132 | { |
| 133 | struct enetc_priv *priv = dev_get_priv(dev); |
| 134 | |
| 135 | return !!(priv->imdio.priv); |
| 136 | } |
| 137 | |
| 138 | /* set up serdes for SGMII */ |
| 139 | static int enetc_init_sgmii(struct udevice *dev) |
| 140 | { |
| 141 | struct enetc_priv *priv = dev_get_priv(dev); |
Alex Marginean | 41a7ac5 | 2019-07-15 11:48:47 +0300 | [diff] [blame] | 142 | bool is2500 = false; |
| 143 | u16 reg; |
Alex Marginean | 38882ae | 2019-07-03 12:11:42 +0300 | [diff] [blame] | 144 | |
| 145 | if (!enetc_has_imdio(dev)) |
| 146 | return 0; |
| 147 | |
Simon Glass | fada3f9 | 2022-09-17 09:00:09 -0600 | [diff] [blame] | 148 | if (priv->uclass_id == PHY_INTERFACE_MODE_2500BASEX) |
Alex Marginean | 41a7ac5 | 2019-07-15 11:48:47 +0300 | [diff] [blame] | 149 | is2500 = true; |
| 150 | |
| 151 | /* |
| 152 | * Set to SGMII mode, for 1Gbps enable AN, for 2.5Gbps set fixed speed. |
| 153 | * Although fixed speed is 1Gbps, we could be running at 2.5Gbps based |
| 154 | * on PLL configuration. Setting 1G for 2.5G here is counter intuitive |
| 155 | * but intentional. |
| 156 | */ |
| 157 | reg = ENETC_PCS_IF_MODE_SGMII; |
| 158 | reg |= is2500 ? ENETC_PCS_IF_MODE_SPEED_1G : ENETC_PCS_IF_MODE_SGMII_AN; |
Alex Marginean | 38882ae | 2019-07-03 12:11:42 +0300 | [diff] [blame] | 159 | enetc_mdio_write(&priv->imdio, ENETC_PCS_PHY_ADDR, MDIO_DEVAD_NONE, |
Alex Marginean | 41a7ac5 | 2019-07-15 11:48:47 +0300 | [diff] [blame] | 160 | ENETC_PCS_IF_MODE, reg); |
Alex Marginean | 38882ae | 2019-07-03 12:11:42 +0300 | [diff] [blame] | 161 | |
| 162 | /* Dev ability - SGMII */ |
| 163 | enetc_mdio_write(&priv->imdio, ENETC_PCS_PHY_ADDR, MDIO_DEVAD_NONE, |
| 164 | ENETC_PCS_DEV_ABILITY, ENETC_PCS_DEV_ABILITY_SGMII); |
| 165 | |
| 166 | /* Adjust link timer for SGMII */ |
| 167 | enetc_mdio_write(&priv->imdio, ENETC_PCS_PHY_ADDR, MDIO_DEVAD_NONE, |
| 168 | ENETC_PCS_LINK_TIMER1, ENETC_PCS_LINK_TIMER1_VAL); |
| 169 | enetc_mdio_write(&priv->imdio, ENETC_PCS_PHY_ADDR, MDIO_DEVAD_NONE, |
| 170 | ENETC_PCS_LINK_TIMER2, ENETC_PCS_LINK_TIMER2_VAL); |
| 171 | |
Alex Marginean | 41a7ac5 | 2019-07-15 11:48:47 +0300 | [diff] [blame] | 172 | reg = ENETC_PCS_CR_DEF_VAL; |
| 173 | reg |= is2500 ? ENETC_PCS_CR_RST : ENETC_PCS_CR_RESET_AN; |
Alex Marginean | 38882ae | 2019-07-03 12:11:42 +0300 | [diff] [blame] | 174 | /* restart PCS AN */ |
| 175 | enetc_mdio_write(&priv->imdio, ENETC_PCS_PHY_ADDR, MDIO_DEVAD_NONE, |
Alex Marginean | 41a7ac5 | 2019-07-15 11:48:47 +0300 | [diff] [blame] | 176 | ENETC_PCS_CR, reg); |
Alex Marginean | 38882ae | 2019-07-03 12:11:42 +0300 | [diff] [blame] | 177 | |
| 178 | return 0; |
| 179 | } |
| 180 | |
| 181 | /* set up MAC for RGMII */ |
Vladimir Oltean | 14ca0c3 | 2021-06-29 20:53:16 +0300 | [diff] [blame] | 182 | static void enetc_init_rgmii(struct udevice *dev, struct phy_device *phydev) |
Alex Marginean | 38882ae | 2019-07-03 12:11:42 +0300 | [diff] [blame] | 183 | { |
| 184 | struct enetc_priv *priv = dev_get_priv(dev); |
Vladimir Oltean | 14ca0c3 | 2021-06-29 20:53:16 +0300 | [diff] [blame] | 185 | u32 old_val, val; |
Alex Marginean | 38882ae | 2019-07-03 12:11:42 +0300 | [diff] [blame] | 186 | |
Vladimir Oltean | 14ca0c3 | 2021-06-29 20:53:16 +0300 | [diff] [blame] | 187 | old_val = val = enetc_read_port(priv, ENETC_PM_IF_MODE); |
Alex Marginean | 38882ae | 2019-07-03 12:11:42 +0300 | [diff] [blame] | 188 | |
Vladimir Oltean | 14ca0c3 | 2021-06-29 20:53:16 +0300 | [diff] [blame] | 189 | /* disable unreliable RGMII in-band signaling and force the MAC into |
| 190 | * the speed negotiated by the PHY. |
| 191 | */ |
| 192 | val &= ~ENETC_PM_IF_MODE_AN_ENA; |
| 193 | |
| 194 | if (phydev->speed == SPEED_1000) { |
| 195 | val &= ~ENETC_PM_IFM_SSP_MASK; |
| 196 | val |= ENETC_PM_IFM_SSP_1000; |
| 197 | } else if (phydev->speed == SPEED_100) { |
| 198 | val &= ~ENETC_PM_IFM_SSP_MASK; |
| 199 | val |= ENETC_PM_IFM_SSP_100; |
| 200 | } else if (phydev->speed == SPEED_10) { |
| 201 | val &= ~ENETC_PM_IFM_SSP_MASK; |
| 202 | val |= ENETC_PM_IFM_SSP_10; |
| 203 | } |
| 204 | |
| 205 | if (phydev->duplex == DUPLEX_FULL) |
| 206 | val |= ENETC_PM_IFM_FULL_DPX; |
| 207 | else |
| 208 | val &= ~ENETC_PM_IFM_FULL_DPX; |
| 209 | |
| 210 | if (val == old_val) |
| 211 | return; |
| 212 | |
| 213 | enetc_write_port(priv, ENETC_PM_IF_MODE, val); |
Alex Marginean | 38882ae | 2019-07-03 12:11:42 +0300 | [diff] [blame] | 214 | } |
| 215 | |
Alex Marginean | afad2d0 | 2020-01-10 23:32:20 +0200 | [diff] [blame] | 216 | /* set up MAC configuration for the given interface type */ |
Vladimir Oltean | 14ca0c3 | 2021-06-29 20:53:16 +0300 | [diff] [blame] | 217 | static void enetc_setup_mac_iface(struct udevice *dev, |
| 218 | struct phy_device *phydev) |
Alex Marginean | 38882ae | 2019-07-03 12:11:42 +0300 | [diff] [blame] | 219 | { |
| 220 | struct enetc_priv *priv = dev_get_priv(dev); |
| 221 | u32 if_mode; |
| 222 | |
Simon Glass | fada3f9 | 2022-09-17 09:00:09 -0600 | [diff] [blame] | 223 | switch (priv->uclass_id) { |
Alex Marginean | afad2d0 | 2020-01-10 23:32:20 +0200 | [diff] [blame] | 224 | case PHY_INTERFACE_MODE_RGMII: |
| 225 | case PHY_INTERFACE_MODE_RGMII_ID: |
| 226 | case PHY_INTERFACE_MODE_RGMII_RXID: |
| 227 | case PHY_INTERFACE_MODE_RGMII_TXID: |
Vladimir Oltean | 14ca0c3 | 2021-06-29 20:53:16 +0300 | [diff] [blame] | 228 | enetc_init_rgmii(dev, phydev); |
Alex Marginean | afad2d0 | 2020-01-10 23:32:20 +0200 | [diff] [blame] | 229 | break; |
Alex Marginean | afad2d0 | 2020-01-10 23:32:20 +0200 | [diff] [blame] | 230 | case PHY_INTERFACE_MODE_USXGMII: |
Vladimir Oltean | 6a6e402 | 2021-09-18 15:32:34 +0300 | [diff] [blame] | 231 | case PHY_INTERFACE_MODE_10GBASER: |
Alex Marginean | afad2d0 | 2020-01-10 23:32:20 +0200 | [diff] [blame] | 232 | /* set ifmode to (US)XGMII */ |
| 233 | if_mode = enetc_read_port(priv, ENETC_PM_IF_MODE); |
| 234 | if_mode &= ~ENETC_PM_IF_IFMODE_MASK; |
| 235 | enetc_write_port(priv, ENETC_PM_IF_MODE, if_mode); |
| 236 | break; |
| 237 | }; |
| 238 | } |
| 239 | |
| 240 | /* set up serdes for SXGMII */ |
| 241 | static int enetc_init_sxgmii(struct udevice *dev) |
| 242 | { |
| 243 | struct enetc_priv *priv = dev_get_priv(dev); |
Alex Marginean | 38882ae | 2019-07-03 12:11:42 +0300 | [diff] [blame] | 244 | |
| 245 | if (!enetc_has_imdio(dev)) |
| 246 | return 0; |
| 247 | |
| 248 | /* Dev ability - SXGMII */ |
| 249 | enetc_mdio_write(&priv->imdio, ENETC_PCS_PHY_ADDR, ENETC_PCS_DEVAD_REPL, |
| 250 | ENETC_PCS_DEV_ABILITY, ENETC_PCS_DEV_ABILITY_SXGMII); |
| 251 | |
| 252 | /* Restart PCS AN */ |
| 253 | enetc_mdio_write(&priv->imdio, ENETC_PCS_PHY_ADDR, ENETC_PCS_DEVAD_REPL, |
| 254 | ENETC_PCS_CR, |
Alex Marginean | 41a7ac5 | 2019-07-15 11:48:47 +0300 | [diff] [blame] | 255 | ENETC_PCS_CR_RST | ENETC_PCS_CR_RESET_AN); |
Alex Marginean | 38882ae | 2019-07-03 12:11:42 +0300 | [diff] [blame] | 256 | |
| 257 | return 0; |
| 258 | } |
| 259 | |
| 260 | /* Apply protocol specific configuration to MAC, serdes as needed */ |
| 261 | static void enetc_start_pcs(struct udevice *dev) |
| 262 | { |
| 263 | struct enetc_priv *priv = dev_get_priv(dev); |
Alex Marginean | 38882ae | 2019-07-03 12:11:42 +0300 | [diff] [blame] | 264 | |
Alex Marginean | d4be768 | 2019-11-25 17:57:27 +0200 | [diff] [blame] | 265 | /* register internal MDIO for debug purposes */ |
Alex Marginean | 38882ae | 2019-07-03 12:11:42 +0300 | [diff] [blame] | 266 | if (enetc_read_port(priv, ENETC_PCAPR0) & ENETC_PCAPRO_MDIO) { |
Alex Marginean | 38882ae | 2019-07-03 12:11:42 +0300 | [diff] [blame] | 267 | priv->imdio.read = enetc_mdio_read; |
| 268 | priv->imdio.write = enetc_mdio_write; |
| 269 | priv->imdio.priv = priv->port_regs + ENETC_PM_IMDIO_BASE; |
Vladimir Oltean | dcd21cc | 2021-09-27 14:21:48 +0300 | [diff] [blame] | 270 | strlcpy(priv->imdio.name, dev->name, MDIO_NAME_LEN); |
Alex Marginean | d4be768 | 2019-11-25 17:57:27 +0200 | [diff] [blame] | 271 | if (!miiphy_get_dev_by_name(priv->imdio.name)) |
| 272 | mdio_register(&priv->imdio); |
Alex Marginean | 38882ae | 2019-07-03 12:11:42 +0300 | [diff] [blame] | 273 | } |
| 274 | |
Simon Glass | a7ece58 | 2020-12-19 10:40:14 -0700 | [diff] [blame] | 275 | if (!ofnode_valid(dev_ofnode(dev))) { |
Alex Marginean | 38882ae | 2019-07-03 12:11:42 +0300 | [diff] [blame] | 276 | enetc_dbg(dev, "no enetc ofnode found, skipping PCS set-up\n"); |
| 277 | return; |
| 278 | } |
| 279 | |
Simon Glass | fada3f9 | 2022-09-17 09:00:09 -0600 | [diff] [blame] | 280 | priv->uclass_id = dev_read_phy_mode(dev); |
| 281 | if (priv->uclass_id == PHY_INTERFACE_MODE_NA) { |
Alex Marginean | 38882ae | 2019-07-03 12:11:42 +0300 | [diff] [blame] | 282 | enetc_dbg(dev, |
| 283 | "phy-mode property not found, defaulting to SGMII\n"); |
Simon Glass | fada3f9 | 2022-09-17 09:00:09 -0600 | [diff] [blame] | 284 | priv->uclass_id = PHY_INTERFACE_MODE_SGMII; |
Marek Behún | bc19477 | 2022-04-07 00:33:01 +0200 | [diff] [blame] | 285 | } |
Alex Marginean | 38882ae | 2019-07-03 12:11:42 +0300 | [diff] [blame] | 286 | |
Simon Glass | fada3f9 | 2022-09-17 09:00:09 -0600 | [diff] [blame] | 287 | switch (priv->uclass_id) { |
Alex Marginean | 38882ae | 2019-07-03 12:11:42 +0300 | [diff] [blame] | 288 | case PHY_INTERFACE_MODE_SGMII: |
Vladimir Oltean | 6caef97 | 2021-09-18 15:32:35 +0300 | [diff] [blame] | 289 | case PHY_INTERFACE_MODE_2500BASEX: |
Alex Marginean | 38882ae | 2019-07-03 12:11:42 +0300 | [diff] [blame] | 290 | enetc_init_sgmii(dev); |
| 291 | break; |
Alex Marginean | ed0460c | 2019-11-14 18:28:38 +0200 | [diff] [blame] | 292 | case PHY_INTERFACE_MODE_USXGMII: |
Vladimir Oltean | 6a6e402 | 2021-09-18 15:32:34 +0300 | [diff] [blame] | 293 | case PHY_INTERFACE_MODE_10GBASER: |
Alex Marginean | 38882ae | 2019-07-03 12:11:42 +0300 | [diff] [blame] | 294 | enetc_init_sxgmii(dev); |
| 295 | break; |
| 296 | }; |
| 297 | } |
| 298 | |
Alex Marginean | 0215539 | 2019-07-03 12:11:41 +0300 | [diff] [blame] | 299 | /* Configure the actual/external ethernet PHY, if one is found */ |
Vladimir Oltean | 10c6fe4 | 2021-06-29 20:53:15 +0300 | [diff] [blame] | 300 | static int enetc_config_phy(struct udevice *dev) |
Alex Marginean | 0215539 | 2019-07-03 12:11:41 +0300 | [diff] [blame] | 301 | { |
| 302 | struct enetc_priv *priv = dev_get_priv(dev); |
Alex Marginean | 0215539 | 2019-07-03 12:11:41 +0300 | [diff] [blame] | 303 | int supported; |
| 304 | |
Alex Marginean | 602e00f | 2019-11-25 17:15:13 +0200 | [diff] [blame] | 305 | priv->phy = dm_eth_phy_connect(dev); |
Alex Marginean | 602e00f | 2019-11-25 17:15:13 +0200 | [diff] [blame] | 306 | if (!priv->phy) |
Vladimir Oltean | 10c6fe4 | 2021-06-29 20:53:15 +0300 | [diff] [blame] | 307 | return -ENODEV; |
Alex Marginean | 0215539 | 2019-07-03 12:11:41 +0300 | [diff] [blame] | 308 | |
Alex Marginean | b93375c | 2019-11-14 18:58:45 +0200 | [diff] [blame] | 309 | supported = PHY_GBIT_FEATURES | SUPPORTED_2500baseX_Full; |
| 310 | priv->phy->supported &= supported; |
| 311 | priv->phy->advertising &= supported; |
Alex Marginean | 602e00f | 2019-11-25 17:15:13 +0200 | [diff] [blame] | 312 | |
Vladimir Oltean | 10c6fe4 | 2021-06-29 20:53:15 +0300 | [diff] [blame] | 313 | return phy_config(priv->phy); |
Alex Marginean | 0215539 | 2019-07-03 12:11:41 +0300 | [diff] [blame] | 314 | } |
| 315 | |
Alex Marginean | 7a910c1 | 2019-07-03 12:11:40 +0300 | [diff] [blame] | 316 | /* |
| 317 | * Probe ENETC driver: |
| 318 | * - initialize port and station interface BARs |
| 319 | */ |
| 320 | static int enetc_probe(struct udevice *dev) |
| 321 | { |
| 322 | struct enetc_priv *priv = dev_get_priv(dev); |
Siarhei Yasinski | 25b798e | 2022-08-31 10:57:37 +0000 | [diff] [blame] | 323 | int res; |
Alex Marginean | 7a910c1 | 2019-07-03 12:11:40 +0300 | [diff] [blame] | 324 | |
Simon Glass | 2e4938b | 2022-09-06 20:27:17 -0600 | [diff] [blame] | 325 | if (ofnode_valid(dev_ofnode(dev)) && !ofnode_is_enabled(dev_ofnode(dev))) { |
Alex Marginean | 7a910c1 | 2019-07-03 12:11:40 +0300 | [diff] [blame] | 326 | enetc_dbg(dev, "interface disabled\n"); |
| 327 | return -ENODEV; |
| 328 | } |
| 329 | |
| 330 | priv->enetc_txbd = memalign(ENETC_BD_ALIGN, |
| 331 | sizeof(struct enetc_tx_bd) * ENETC_BD_CNT); |
| 332 | priv->enetc_rxbd = memalign(ENETC_BD_ALIGN, |
| 333 | sizeof(union enetc_rx_bd) * ENETC_BD_CNT); |
| 334 | |
| 335 | if (!priv->enetc_txbd || !priv->enetc_rxbd) { |
| 336 | /* free should be able to handle NULL, just free all pointers */ |
| 337 | free(priv->enetc_txbd); |
| 338 | free(priv->enetc_rxbd); |
| 339 | |
| 340 | return -ENOMEM; |
| 341 | } |
| 342 | |
| 343 | /* initialize register */ |
Andrew Scull | 6520c82 | 2022-04-21 16:11:13 +0000 | [diff] [blame] | 344 | priv->regs_base = dm_pci_map_bar(dev, PCI_BASE_ADDRESS_0, 0, 0, PCI_REGION_TYPE, 0); |
Alex Marginean | 7a910c1 | 2019-07-03 12:11:40 +0300 | [diff] [blame] | 345 | if (!priv->regs_base) { |
| 346 | enetc_dbg(dev, "failed to map BAR0\n"); |
| 347 | return -EINVAL; |
| 348 | } |
| 349 | priv->port_regs = priv->regs_base + ENETC_PORT_REGS_OFF; |
| 350 | |
| 351 | dm_pci_clrset_config16(dev, PCI_COMMAND, 0, PCI_COMMAND_MEMORY); |
| 352 | |
Alex Marginean | c905c21 | 2019-11-14 18:58:46 +0200 | [diff] [blame] | 353 | enetc_start_pcs(dev); |
Alex Marginean | c905c21 | 2019-11-14 18:58:46 +0200 | [diff] [blame] | 354 | |
Siarhei Yasinski | 25b798e | 2022-08-31 10:57:37 +0000 | [diff] [blame] | 355 | res = enetc_config_phy(dev); |
| 356 | if(res) |
| 357 | enetc_remove(dev); |
| 358 | return res; |
Alex Marginean | 7a910c1 | 2019-07-03 12:11:40 +0300 | [diff] [blame] | 359 | } |
| 360 | |
| 361 | /* |
| 362 | * Remove the driver from an interface: |
| 363 | * - free up allocated memory |
| 364 | */ |
| 365 | static int enetc_remove(struct udevice *dev) |
| 366 | { |
| 367 | struct enetc_priv *priv = dev_get_priv(dev); |
| 368 | |
Michael Walle | 3f66e8e | 2022-05-31 18:36:16 +0200 | [diff] [blame] | 369 | if (miiphy_get_dev_by_name(priv->imdio.name)) |
| 370 | mdio_unregister(&priv->imdio); |
| 371 | |
Alex Marginean | 7a910c1 | 2019-07-03 12:11:40 +0300 | [diff] [blame] | 372 | free(priv->enetc_txbd); |
| 373 | free(priv->enetc_rxbd); |
| 374 | |
| 375 | return 0; |
| 376 | } |
| 377 | |
Michael Walle | 1d3e24f | 2019-12-20 14:16:48 +0100 | [diff] [blame] | 378 | /* |
| 379 | * LS1028A is the only part with IERB at this time and there are plans to |
| 380 | * change its structure, keep this LS1028A specific for now. |
| 381 | */ |
| 382 | #define LS1028A_IERB_BASE 0x1f0800000ULL |
| 383 | #define LS1028A_IERB_PSIPMAR0(pf, vf) (LS1028A_IERB_BASE + 0x8000 \ |
| 384 | + (pf) * 0x100 + (vf) * 8) |
| 385 | #define LS1028A_IERB_PSIPMAR1(pf, vf) (LS1028A_IERB_PSIPMAR0(pf, vf) + 4) |
| 386 | |
| 387 | static int enetc_ls1028a_write_hwaddr(struct udevice *dev) |
| 388 | { |
Simon Glass | b75b15b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 389 | struct pci_child_plat *ppdata = dev_get_parent_plat(dev); |
Michael Walle | 1d3e24f | 2019-12-20 14:16:48 +0100 | [diff] [blame] | 390 | const int devfn_to_pf[] = {0, 1, 2, -1, -1, -1, 3}; |
Simon Glass | fa20e93 | 2020-12-03 16:55:20 -0700 | [diff] [blame] | 391 | struct eth_pdata *plat = dev_get_plat(dev); |
Michael Walle | 1d3e24f | 2019-12-20 14:16:48 +0100 | [diff] [blame] | 392 | int devfn = PCI_FUNC(ppdata->devfn); |
| 393 | u8 *addr = plat->enetaddr; |
| 394 | u32 lower, upper; |
| 395 | int pf; |
| 396 | |
| 397 | if (devfn >= ARRAY_SIZE(devfn_to_pf)) |
| 398 | return 0; |
| 399 | |
| 400 | pf = devfn_to_pf[devfn]; |
| 401 | if (pf < 0) |
| 402 | return 0; |
| 403 | |
| 404 | lower = *(const u16 *)(addr + 4); |
| 405 | upper = *(const u32 *)addr; |
| 406 | |
| 407 | out_le32(LS1028A_IERB_PSIPMAR0(pf, 0), upper); |
| 408 | out_le32(LS1028A_IERB_PSIPMAR1(pf, 0), lower); |
| 409 | |
| 410 | return 0; |
| 411 | } |
| 412 | |
Michael Walle | 8c7188e | 2019-12-20 14:16:47 +0100 | [diff] [blame] | 413 | static int enetc_write_hwaddr(struct udevice *dev) |
Alex Marginean | 7a910c1 | 2019-07-03 12:11:40 +0300 | [diff] [blame] | 414 | { |
Simon Glass | fa20e93 | 2020-12-03 16:55:20 -0700 | [diff] [blame] | 415 | struct eth_pdata *plat = dev_get_plat(dev); |
Michael Walle | 8c7188e | 2019-12-20 14:16:47 +0100 | [diff] [blame] | 416 | struct enetc_priv *priv = dev_get_priv(dev); |
| 417 | u8 *addr = plat->enetaddr; |
| 418 | |
Michael Walle | 1d3e24f | 2019-12-20 14:16:48 +0100 | [diff] [blame] | 419 | if (IS_ENABLED(CONFIG_ARCH_LS1028A)) |
| 420 | return enetc_ls1028a_write_hwaddr(dev); |
| 421 | |
Alex Marginean | 7a910c1 | 2019-07-03 12:11:40 +0300 | [diff] [blame] | 422 | u16 lower = *(const u16 *)(addr + 4); |
| 423 | u32 upper = *(const u32 *)addr; |
| 424 | |
| 425 | enetc_write_port(priv, ENETC_PSIPMAR0, upper); |
| 426 | enetc_write_port(priv, ENETC_PSIPMAR1, lower); |
Michael Walle | 8c7188e | 2019-12-20 14:16:47 +0100 | [diff] [blame] | 427 | |
| 428 | return 0; |
Alex Marginean | 7a910c1 | 2019-07-03 12:11:40 +0300 | [diff] [blame] | 429 | } |
| 430 | |
| 431 | /* Configure port parameters (# of rings, frame size, enable port) */ |
| 432 | static void enetc_enable_si_port(struct enetc_priv *priv) |
| 433 | { |
| 434 | u32 val; |
| 435 | |
| 436 | /* set Rx/Tx BDR count */ |
| 437 | val = ENETC_PSICFGR_SET_TXBDR(ENETC_TX_BDR_CNT); |
| 438 | val |= ENETC_PSICFGR_SET_RXBDR(ENETC_RX_BDR_CNT); |
| 439 | enetc_write_port(priv, ENETC_PSICFGR(0), val); |
| 440 | /* set Rx max frame size */ |
| 441 | enetc_write_port(priv, ENETC_PM_MAXFRM, ENETC_RX_MAXFRM_SIZE); |
| 442 | /* enable MAC port */ |
| 443 | enetc_write_port(priv, ENETC_PM_CC, ENETC_PM_CC_RX_TX_EN); |
| 444 | /* enable port */ |
| 445 | enetc_write_port(priv, ENETC_PMR, ENETC_PMR_SI0_EN); |
| 446 | /* set SI cache policy */ |
| 447 | enetc_write(priv, ENETC_SICAR0, |
| 448 | ENETC_SICAR_RD_CFG | ENETC_SICAR_WR_CFG); |
| 449 | /* enable SI */ |
| 450 | enetc_write(priv, ENETC_SIMR, ENETC_SIMR_EN); |
| 451 | } |
| 452 | |
| 453 | /* returns DMA address for a given buffer index */ |
| 454 | static inline u64 enetc_rxb_address(struct udevice *dev, int i) |
| 455 | { |
| 456 | return cpu_to_le64(dm_pci_virt_to_mem(dev, net_rx_packets[i])); |
| 457 | } |
| 458 | |
| 459 | /* |
| 460 | * Setup a single Tx BD Ring (ID = 0): |
| 461 | * - set Tx buffer descriptor address |
| 462 | * - set the BD count |
| 463 | * - initialize the producer and consumer index |
| 464 | */ |
| 465 | static void enetc_setup_tx_bdr(struct udevice *dev) |
| 466 | { |
| 467 | struct enetc_priv *priv = dev_get_priv(dev); |
| 468 | struct bd_ring *tx_bdr = &priv->tx_bdr; |
| 469 | u64 tx_bd_add = (u64)priv->enetc_txbd; |
| 470 | |
| 471 | /* used later to advance to the next Tx BD */ |
| 472 | tx_bdr->bd_count = ENETC_BD_CNT; |
| 473 | tx_bdr->next_prod_idx = 0; |
| 474 | tx_bdr->next_cons_idx = 0; |
| 475 | tx_bdr->cons_idx = priv->regs_base + |
| 476 | ENETC_BDR(TX, ENETC_TX_BDR_ID, ENETC_TBCIR); |
| 477 | tx_bdr->prod_idx = priv->regs_base + |
| 478 | ENETC_BDR(TX, ENETC_TX_BDR_ID, ENETC_TBPIR); |
| 479 | |
| 480 | /* set Tx BD address */ |
| 481 | enetc_bdr_write(priv, TX, ENETC_TX_BDR_ID, ENETC_TBBAR0, |
| 482 | lower_32_bits(tx_bd_add)); |
| 483 | enetc_bdr_write(priv, TX, ENETC_TX_BDR_ID, ENETC_TBBAR1, |
| 484 | upper_32_bits(tx_bd_add)); |
| 485 | /* set Tx 8 BD count */ |
| 486 | enetc_bdr_write(priv, TX, ENETC_TX_BDR_ID, ENETC_TBLENR, |
| 487 | tx_bdr->bd_count); |
| 488 | |
| 489 | /* reset both producer/consumer indexes */ |
| 490 | enetc_write_reg(tx_bdr->cons_idx, tx_bdr->next_cons_idx); |
| 491 | enetc_write_reg(tx_bdr->prod_idx, tx_bdr->next_prod_idx); |
| 492 | |
| 493 | /* enable TX ring */ |
| 494 | enetc_bdr_write(priv, TX, ENETC_TX_BDR_ID, ENETC_TBMR, ENETC_TBMR_EN); |
| 495 | } |
| 496 | |
| 497 | /* |
| 498 | * Setup a single Rx BD Ring (ID = 0): |
| 499 | * - set Rx buffer descriptors address (one descriptor per buffer) |
| 500 | * - set buffer size as max frame size |
| 501 | * - enable Rx ring |
| 502 | * - reset consumer and producer indexes |
| 503 | * - set buffer for each descriptor |
| 504 | */ |
| 505 | static void enetc_setup_rx_bdr(struct udevice *dev) |
| 506 | { |
| 507 | struct enetc_priv *priv = dev_get_priv(dev); |
| 508 | struct bd_ring *rx_bdr = &priv->rx_bdr; |
| 509 | u64 rx_bd_add = (u64)priv->enetc_rxbd; |
| 510 | int i; |
| 511 | |
| 512 | /* used later to advance to the next BD produced by ENETC HW */ |
| 513 | rx_bdr->bd_count = ENETC_BD_CNT; |
| 514 | rx_bdr->next_prod_idx = 0; |
| 515 | rx_bdr->next_cons_idx = 0; |
| 516 | rx_bdr->cons_idx = priv->regs_base + |
| 517 | ENETC_BDR(RX, ENETC_RX_BDR_ID, ENETC_RBCIR); |
| 518 | rx_bdr->prod_idx = priv->regs_base + |
| 519 | ENETC_BDR(RX, ENETC_RX_BDR_ID, ENETC_RBPIR); |
| 520 | |
| 521 | /* set Rx BD address */ |
| 522 | enetc_bdr_write(priv, RX, ENETC_RX_BDR_ID, ENETC_RBBAR0, |
| 523 | lower_32_bits(rx_bd_add)); |
| 524 | enetc_bdr_write(priv, RX, ENETC_RX_BDR_ID, ENETC_RBBAR1, |
| 525 | upper_32_bits(rx_bd_add)); |
| 526 | /* set Rx BD count (multiple of 8) */ |
| 527 | enetc_bdr_write(priv, RX, ENETC_RX_BDR_ID, ENETC_RBLENR, |
| 528 | rx_bdr->bd_count); |
| 529 | /* set Rx buffer size */ |
| 530 | enetc_bdr_write(priv, RX, ENETC_RX_BDR_ID, ENETC_RBBSR, PKTSIZE_ALIGN); |
| 531 | |
| 532 | /* fill Rx BD */ |
| 533 | memset(priv->enetc_rxbd, 0, |
| 534 | rx_bdr->bd_count * sizeof(union enetc_rx_bd)); |
| 535 | for (i = 0; i < rx_bdr->bd_count; i++) { |
| 536 | priv->enetc_rxbd[i].w.addr = enetc_rxb_address(dev, i); |
| 537 | /* each RX buffer must be aligned to 64B */ |
| 538 | WARN_ON(priv->enetc_rxbd[i].w.addr & (ARCH_DMA_MINALIGN - 1)); |
| 539 | } |
| 540 | |
| 541 | /* reset producer (ENETC owned) and consumer (SW owned) index */ |
| 542 | enetc_write_reg(rx_bdr->cons_idx, rx_bdr->next_cons_idx); |
| 543 | enetc_write_reg(rx_bdr->prod_idx, rx_bdr->next_prod_idx); |
| 544 | |
| 545 | /* enable Rx ring */ |
| 546 | enetc_bdr_write(priv, RX, ENETC_RX_BDR_ID, ENETC_RBMR, ENETC_RBMR_EN); |
| 547 | } |
| 548 | |
| 549 | /* |
| 550 | * Start ENETC interface: |
| 551 | * - perform FLR |
| 552 | * - enable access to port and SI registers |
| 553 | * - set mac address |
| 554 | * - setup TX/RX buffer descriptors |
| 555 | * - enable Tx/Rx rings |
| 556 | */ |
| 557 | static int enetc_start(struct udevice *dev) |
| 558 | { |
Alex Marginean | 7a910c1 | 2019-07-03 12:11:40 +0300 | [diff] [blame] | 559 | struct enetc_priv *priv = dev_get_priv(dev); |
| 560 | |
| 561 | /* reset and enable the PCI device */ |
| 562 | dm_pci_flr(dev); |
| 563 | dm_pci_clrset_config16(dev, PCI_COMMAND, 0, |
| 564 | PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER); |
| 565 | |
Alex Marginean | 7a910c1 | 2019-07-03 12:11:40 +0300 | [diff] [blame] | 566 | enetc_enable_si_port(priv); |
| 567 | |
| 568 | /* setup Tx/Rx buffer descriptors */ |
| 569 | enetc_setup_tx_bdr(dev); |
| 570 | enetc_setup_rx_bdr(dev); |
| 571 | |
Vladimir Oltean | 14ca0c3 | 2021-06-29 20:53:16 +0300 | [diff] [blame] | 572 | enetc_setup_mac_iface(dev, priv->phy); |
| 573 | |
Vladimir Oltean | 1936308 | 2021-06-29 20:53:17 +0300 | [diff] [blame] | 574 | return phy_startup(priv->phy); |
Alex Marginean | 7a910c1 | 2019-07-03 12:11:40 +0300 | [diff] [blame] | 575 | } |
| 576 | |
| 577 | /* |
| 578 | * Stop the network interface: |
| 579 | * - just quiesce it, we can wipe all configuration as _start starts from |
| 580 | * scratch each time |
| 581 | */ |
| 582 | static void enetc_stop(struct udevice *dev) |
| 583 | { |
| 584 | /* FLR is sufficient to quiesce the device */ |
| 585 | dm_pci_flr(dev); |
Alex Marginean | d4be768 | 2019-11-25 17:57:27 +0200 | [diff] [blame] | 586 | /* leave the BARs accessible after we stop, this is needed to use |
| 587 | * internal MDIO in command line. |
| 588 | */ |
| 589 | dm_pci_clrset_config16(dev, PCI_COMMAND, 0, PCI_COMMAND_MEMORY); |
Alex Marginean | 7a910c1 | 2019-07-03 12:11:40 +0300 | [diff] [blame] | 590 | } |
| 591 | |
| 592 | /* |
| 593 | * ENETC transmit packet: |
| 594 | * - check if Tx BD ring is full |
| 595 | * - set buffer/packet address (dma address) |
| 596 | * - set final fragment flag |
| 597 | * - try while producer index equals consumer index or timeout |
| 598 | */ |
| 599 | static int enetc_send(struct udevice *dev, void *packet, int length) |
| 600 | { |
| 601 | struct enetc_priv *priv = dev_get_priv(dev); |
| 602 | struct bd_ring *txr = &priv->tx_bdr; |
| 603 | void *nv_packet = (void *)packet; |
| 604 | int tries = ENETC_POLL_TRIES; |
| 605 | u32 pi, ci; |
| 606 | |
| 607 | pi = txr->next_prod_idx; |
| 608 | ci = enetc_read_reg(txr->cons_idx) & ENETC_BDR_IDX_MASK; |
| 609 | /* Tx ring is full when */ |
| 610 | if (((pi + 1) % txr->bd_count) == ci) { |
| 611 | enetc_dbg(dev, "Tx BDR full\n"); |
| 612 | return -ETIMEDOUT; |
| 613 | } |
| 614 | enetc_dbg(dev, "TxBD[%d]send: pkt_len=%d, buff @0x%x%08x\n", pi, length, |
| 615 | upper_32_bits((u64)nv_packet), lower_32_bits((u64)nv_packet)); |
| 616 | |
| 617 | /* prepare Tx BD */ |
| 618 | memset(&priv->enetc_txbd[pi], 0x0, sizeof(struct enetc_tx_bd)); |
| 619 | priv->enetc_txbd[pi].addr = |
| 620 | cpu_to_le64(dm_pci_virt_to_mem(dev, nv_packet)); |
| 621 | priv->enetc_txbd[pi].buf_len = cpu_to_le16(length); |
| 622 | priv->enetc_txbd[pi].frm_len = cpu_to_le16(length); |
| 623 | priv->enetc_txbd[pi].flags = cpu_to_le16(ENETC_TXBD_FLAGS_F); |
| 624 | dmb(); |
| 625 | /* send frame: increment producer index */ |
| 626 | pi = (pi + 1) % txr->bd_count; |
| 627 | txr->next_prod_idx = pi; |
| 628 | enetc_write_reg(txr->prod_idx, pi); |
| 629 | while ((--tries >= 0) && |
| 630 | (pi != (enetc_read_reg(txr->cons_idx) & ENETC_BDR_IDX_MASK))) |
| 631 | udelay(10); |
| 632 | |
| 633 | return tries > 0 ? 0 : -ETIMEDOUT; |
| 634 | } |
| 635 | |
| 636 | /* |
| 637 | * Receive frame: |
| 638 | * - wait for the next BD to get ready bit set |
| 639 | * - clean up the descriptor |
| 640 | * - move on and indicate to HW that the cleaned BD is available for Rx |
| 641 | */ |
| 642 | static int enetc_recv(struct udevice *dev, int flags, uchar **packetp) |
| 643 | { |
| 644 | struct enetc_priv *priv = dev_get_priv(dev); |
| 645 | struct bd_ring *rxr = &priv->rx_bdr; |
| 646 | int tries = ENETC_POLL_TRIES; |
| 647 | int pi = rxr->next_prod_idx; |
| 648 | int ci = rxr->next_cons_idx; |
| 649 | u32 status; |
| 650 | int len; |
| 651 | u8 rdy; |
| 652 | |
| 653 | do { |
| 654 | dmb(); |
| 655 | status = le32_to_cpu(priv->enetc_rxbd[pi].r.lstatus); |
| 656 | /* check if current BD is ready to be consumed */ |
| 657 | rdy = ENETC_RXBD_STATUS_R(status); |
| 658 | } while (--tries >= 0 && !rdy); |
| 659 | |
| 660 | if (!rdy) |
| 661 | return -EAGAIN; |
| 662 | |
| 663 | dmb(); |
| 664 | len = le16_to_cpu(priv->enetc_rxbd[pi].r.buf_len); |
| 665 | *packetp = (uchar *)enetc_rxb_address(dev, pi); |
| 666 | enetc_dbg(dev, "RxBD[%d]: len=%d err=%d pkt=0x%x%08x\n", pi, len, |
| 667 | ENETC_RXBD_STATUS_ERRORS(status), |
| 668 | upper_32_bits((u64)*packetp), lower_32_bits((u64)*packetp)); |
| 669 | |
| 670 | /* BD clean up and advance to next in ring */ |
| 671 | memset(&priv->enetc_rxbd[pi], 0, sizeof(union enetc_rx_bd)); |
| 672 | priv->enetc_rxbd[pi].w.addr = enetc_rxb_address(dev, pi); |
| 673 | rxr->next_prod_idx = (pi + 1) % rxr->bd_count; |
| 674 | ci = (ci + 1) % rxr->bd_count; |
| 675 | rxr->next_cons_idx = ci; |
| 676 | dmb(); |
| 677 | /* free up the slot in the ring for HW */ |
| 678 | enetc_write_reg(rxr->cons_idx, ci); |
| 679 | |
| 680 | return len; |
| 681 | } |
| 682 | |
| 683 | static const struct eth_ops enetc_ops = { |
| 684 | .start = enetc_start, |
| 685 | .send = enetc_send, |
| 686 | .recv = enetc_recv, |
| 687 | .stop = enetc_stop, |
Michael Walle | 8c7188e | 2019-12-20 14:16:47 +0100 | [diff] [blame] | 688 | .write_hwaddr = enetc_write_hwaddr, |
Alex Marginean | 7a910c1 | 2019-07-03 12:11:40 +0300 | [diff] [blame] | 689 | }; |
| 690 | |
| 691 | U_BOOT_DRIVER(eth_enetc) = { |
Alex Marginean | 805b859 | 2019-12-10 16:55:39 +0200 | [diff] [blame] | 692 | .name = ENETC_DRIVER_NAME, |
Alex Marginean | 7a910c1 | 2019-07-03 12:11:40 +0300 | [diff] [blame] | 693 | .id = UCLASS_ETH, |
| 694 | .bind = enetc_bind, |
| 695 | .probe = enetc_probe, |
| 696 | .remove = enetc_remove, |
| 697 | .ops = &enetc_ops, |
Simon Glass | 8a2b47f | 2020-12-03 16:55:17 -0700 | [diff] [blame] | 698 | .priv_auto = sizeof(struct enetc_priv), |
Simon Glass | 71fa5b4 | 2020-12-03 16:55:18 -0700 | [diff] [blame] | 699 | .plat_auto = sizeof(struct eth_pdata), |
Alex Marginean | 7a910c1 | 2019-07-03 12:11:40 +0300 | [diff] [blame] | 700 | }; |
| 701 | |
| 702 | static struct pci_device_id enetc_ids[] = { |
| 703 | { PCI_DEVICE(PCI_VENDOR_ID_FREESCALE, PCI_DEVICE_ID_ENETC_ETH) }, |
| 704 | {} |
| 705 | }; |
| 706 | |
| 707 | U_BOOT_PCI_DEVICE(eth_enetc, enetc_ids); |