Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2016, NVIDIA CORPORATION. |
| 4 | * |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 5 | * Portions based on U-Boot's rtl8169.c. |
| 6 | */ |
| 7 | |
| 8 | /* |
| 9 | * This driver supports the Synopsys Designware Ethernet QOS (Quality Of |
| 10 | * Service) IP block. The IP supports multiple options for bus type, clocking/ |
| 11 | * reset structure, and feature list. |
| 12 | * |
| 13 | * The driver is written such that generic core logic is kept separate from |
| 14 | * configuration-specific logic. Code that interacts with configuration- |
| 15 | * specific resources is split out into separate functions to avoid polluting |
| 16 | * common code. If/when this driver is enhanced to support multiple |
| 17 | * configurations, the core code should be adapted to call all configuration- |
| 18 | * specific functions through function pointers, with the definition of those |
| 19 | * function pointers being supplied by struct udevice_id eqos_ids[]'s .data |
| 20 | * field. |
| 21 | * |
| 22 | * The following configurations are currently supported: |
| 23 | * tegra186: |
| 24 | * NVIDIA's Tegra186 chip. This configuration uses an AXI master/DMA bus, an |
| 25 | * AHB slave/register bus, contains the DMA, MTL, and MAC sub-blocks, and |
| 26 | * supports a single RGMII PHY. This configuration also has SW control over |
| 27 | * all clock and reset signals to the HW block. |
| 28 | */ |
Patrick Delaunay | 9e6ed38 | 2020-09-09 18:30:06 +0200 | [diff] [blame] | 29 | |
Patrick Delaunay | 5787284 | 2021-07-20 20:15:29 +0200 | [diff] [blame] | 30 | #define LOG_CATEGORY UCLASS_ETH |
| 31 | |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 32 | #include <clk.h> |
Simon Glass | 6333448 | 2019-11-14 12:57:39 -0700 | [diff] [blame] | 33 | #include <cpu_func.h> |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 34 | #include <dm.h> |
| 35 | #include <errno.h> |
Patrick Delaunay | 4172927 | 2022-06-30 11:09:41 +0200 | [diff] [blame] | 36 | #include <eth_phy.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 37 | #include <log.h> |
Simon Glass | 9bc1564 | 2020-02-03 07:36:16 -0700 | [diff] [blame] | 38 | #include <malloc.h> |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 39 | #include <memalign.h> |
| 40 | #include <miiphy.h> |
| 41 | #include <net.h> |
| 42 | #include <netdev.h> |
| 43 | #include <phy.h> |
| 44 | #include <reset.h> |
| 45 | #include <wait_bit.h> |
Simon Glass | 274e0b0 | 2020-05-10 11:39:56 -0600 | [diff] [blame] | 46 | #include <asm/cache.h> |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 47 | #include <asm/gpio.h> |
| 48 | #include <asm/io.h> |
Fugang Duan | dd455e6 | 2020-05-03 22:41:18 +0800 | [diff] [blame] | 49 | #ifdef CONFIG_ARCH_IMX8M |
| 50 | #include <asm/arch/clock.h> |
| 51 | #include <asm/mach-imx/sys_proto.h> |
| 52 | #endif |
Philip Oberfichtner | abed372 | 2024-05-07 11:42:37 +0200 | [diff] [blame] | 53 | #include <linux/bitfield.h> |
Simon Glass | dbd7954 | 2020-05-10 11:40:11 -0600 | [diff] [blame] | 54 | #include <linux/delay.h> |
Simon Glass | bdd5f81 | 2023-09-14 18:21:46 -0600 | [diff] [blame] | 55 | #include <linux/printk.h> |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 56 | |
Peng Fan | c0a5995 | 2022-07-26 16:41:14 +0800 | [diff] [blame] | 57 | #include "dwc_eth_qos.h" |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 58 | |
| 59 | /* |
| 60 | * TX and RX descriptors are 16 bytes. This causes problems with the cache |
| 61 | * maintenance on CPUs where the cache-line size exceeds the size of these |
| 62 | * descriptors. What will happen is that when the driver receives a packet |
| 63 | * it will be immediately requeued for the hardware to reuse. The CPU will |
| 64 | * therefore need to flush the cache-line containing the descriptor, which |
| 65 | * will cause all other descriptors in the same cache-line to be flushed |
| 66 | * along with it. If one of those descriptors had been written to by the |
| 67 | * device those changes (and the associated packet) will be lost. |
| 68 | * |
| 69 | * To work around this, we make use of non-cached memory if available. If |
| 70 | * descriptors are mapped uncached there's no need to manually flush them |
| 71 | * or invalidate them. |
| 72 | * |
| 73 | * Note that this only applies to descriptors. The packet data buffers do |
| 74 | * not have the same constraints since they are 1536 bytes large, so they |
| 75 | * are unlikely to share cache-lines. |
| 76 | */ |
Marek Vasut | 8907773 | 2021-01-07 11:12:16 +0100 | [diff] [blame] | 77 | static void *eqos_alloc_descs(struct eqos_priv *eqos, unsigned int num) |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 78 | { |
Marek Vasut | 3e8a1be | 2022-10-09 17:51:46 +0200 | [diff] [blame] | 79 | return memalign(ARCH_DMA_MINALIGN, num * eqos->desc_size); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 80 | } |
| 81 | |
| 82 | static void eqos_free_descs(void *descs) |
| 83 | { |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 84 | free(descs); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 85 | } |
| 86 | |
Marek Vasut | 8907773 | 2021-01-07 11:12:16 +0100 | [diff] [blame] | 87 | static struct eqos_desc *eqos_get_desc(struct eqos_priv *eqos, |
| 88 | unsigned int num, bool rx) |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 89 | { |
Marek Vasut | 90cc13a | 2022-10-09 17:51:45 +0200 | [diff] [blame] | 90 | return (rx ? eqos->rx_descs : eqos->tx_descs) + |
| 91 | (num * eqos->desc_size); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 92 | } |
| 93 | |
Peng Fan | c0a5995 | 2022-07-26 16:41:14 +0800 | [diff] [blame] | 94 | void eqos_inval_desc_generic(void *desc) |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 95 | { |
Marek Vasut | 3e8a1be | 2022-10-09 17:51:46 +0200 | [diff] [blame] | 96 | unsigned long start = (unsigned long)desc & ~(ARCH_DMA_MINALIGN - 1); |
Marek Vasut | 8907773 | 2021-01-07 11:12:16 +0100 | [diff] [blame] | 97 | unsigned long end = ALIGN(start + sizeof(struct eqos_desc), |
| 98 | ARCH_DMA_MINALIGN); |
Christophe Roullier | 6beb780 | 2019-05-17 15:08:44 +0200 | [diff] [blame] | 99 | |
| 100 | invalidate_dcache_range(start, end); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 101 | } |
| 102 | |
Peng Fan | c0a5995 | 2022-07-26 16:41:14 +0800 | [diff] [blame] | 103 | void eqos_flush_desc_generic(void *desc) |
Christophe Roullier | 6beb780 | 2019-05-17 15:08:44 +0200 | [diff] [blame] | 104 | { |
Marek Vasut | 3e8a1be | 2022-10-09 17:51:46 +0200 | [diff] [blame] | 105 | unsigned long start = (unsigned long)desc & ~(ARCH_DMA_MINALIGN - 1); |
Marek Vasut | 8907773 | 2021-01-07 11:12:16 +0100 | [diff] [blame] | 106 | unsigned long end = ALIGN(start + sizeof(struct eqos_desc), |
| 107 | ARCH_DMA_MINALIGN); |
Christophe Roullier | 6beb780 | 2019-05-17 15:08:44 +0200 | [diff] [blame] | 108 | |
| 109 | flush_dcache_range(start, end); |
Christophe Roullier | 6beb780 | 2019-05-17 15:08:44 +0200 | [diff] [blame] | 110 | } |
| 111 | |
Marek Vasut | 7b6fec2 | 2023-03-06 15:53:45 +0100 | [diff] [blame] | 112 | static void eqos_inval_buffer_tegra186(void *buf, size_t size) |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 113 | { |
| 114 | unsigned long start = (unsigned long)buf & ~(ARCH_DMA_MINALIGN - 1); |
| 115 | unsigned long end = ALIGN(start + size, ARCH_DMA_MINALIGN); |
| 116 | |
| 117 | invalidate_dcache_range(start, end); |
| 118 | } |
| 119 | |
Peng Fan | c0a5995 | 2022-07-26 16:41:14 +0800 | [diff] [blame] | 120 | void eqos_inval_buffer_generic(void *buf, size_t size) |
Christophe Roullier | 6beb780 | 2019-05-17 15:08:44 +0200 | [diff] [blame] | 121 | { |
| 122 | unsigned long start = rounddown((unsigned long)buf, ARCH_DMA_MINALIGN); |
| 123 | unsigned long end = roundup((unsigned long)buf + size, |
| 124 | ARCH_DMA_MINALIGN); |
| 125 | |
| 126 | invalidate_dcache_range(start, end); |
| 127 | } |
| 128 | |
| 129 | static void eqos_flush_buffer_tegra186(void *buf, size_t size) |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 130 | { |
| 131 | flush_cache((unsigned long)buf, size); |
| 132 | } |
| 133 | |
Peng Fan | c0a5995 | 2022-07-26 16:41:14 +0800 | [diff] [blame] | 134 | void eqos_flush_buffer_generic(void *buf, size_t size) |
Christophe Roullier | 6beb780 | 2019-05-17 15:08:44 +0200 | [diff] [blame] | 135 | { |
| 136 | unsigned long start = rounddown((unsigned long)buf, ARCH_DMA_MINALIGN); |
| 137 | unsigned long end = roundup((unsigned long)buf + size, |
| 138 | ARCH_DMA_MINALIGN); |
| 139 | |
| 140 | flush_dcache_range(start, end); |
| 141 | } |
| 142 | |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 143 | static int eqos_mdio_wait_idle(struct eqos_priv *eqos) |
| 144 | { |
Álvaro Fernández Rojas | 918de03 | 2018-01-23 17:14:55 +0100 | [diff] [blame] | 145 | return wait_for_bit_le32(&eqos->mac_regs->mdio_address, |
| 146 | EQOS_MAC_MDIO_ADDRESS_GB, false, |
| 147 | 1000000, true); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 148 | } |
| 149 | |
Philip Oberfichtner | abed372 | 2024-05-07 11:42:37 +0200 | [diff] [blame] | 150 | /* Bitmask common for mdio_read and mdio_write */ |
| 151 | #define EQOS_MDIO_BITFIELD(pa, rda, cr) \ |
| 152 | FIELD_PREP(EQOS_MAC_MDIO_ADDRESS_PA_MASK, pa) | \ |
| 153 | FIELD_PREP(EQOS_MAC_MDIO_ADDRESS_RDA_MASK, rda) | \ |
| 154 | FIELD_PREP(EQOS_MAC_MDIO_ADDRESS_CR_MASK, cr) | \ |
| 155 | EQOS_MAC_MDIO_ADDRESS_GB |
| 156 | |
| 157 | static u32 eqos_mdio_bitfield(struct eqos_priv *eqos, int addr, int devad, int reg) |
| 158 | { |
| 159 | int cr = eqos->config->config_mac_mdio; |
| 160 | bool c22 = devad == MDIO_DEVAD_NONE ? true : false; |
| 161 | |
| 162 | if (c22) |
| 163 | return EQOS_MDIO_BITFIELD(addr, reg, cr); |
| 164 | else |
| 165 | return EQOS_MDIO_BITFIELD(addr, devad, cr) | |
| 166 | EQOS_MAC_MDIO_ADDRESS_C45E; |
| 167 | } |
| 168 | |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 169 | static int eqos_mdio_read(struct mii_dev *bus, int mdio_addr, int mdio_devad, |
| 170 | int mdio_reg) |
| 171 | { |
| 172 | struct eqos_priv *eqos = bus->priv; |
| 173 | u32 val; |
| 174 | int ret; |
| 175 | |
| 176 | debug("%s(dev=%p, addr=%x, reg=%d):\n", __func__, eqos->dev, mdio_addr, |
| 177 | mdio_reg); |
| 178 | |
| 179 | ret = eqos_mdio_wait_idle(eqos); |
| 180 | if (ret) { |
Heinrich Schuchardt | ccb51b4 | 2024-04-02 10:39:34 +0200 | [diff] [blame] | 181 | pr_err("MDIO not idle at entry\n"); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 182 | return ret; |
| 183 | } |
| 184 | |
| 185 | val = readl(&eqos->mac_regs->mdio_address); |
Philip Oberfichtner | abed372 | 2024-05-07 11:42:37 +0200 | [diff] [blame] | 186 | val &= EQOS_MAC_MDIO_ADDRESS_SKAP; |
| 187 | |
| 188 | val |= eqos_mdio_bitfield(eqos, mdio_addr, mdio_devad, mdio_reg) | |
| 189 | FIELD_PREP(EQOS_MAC_MDIO_ADDRESS_GOC_MASK, |
| 190 | EQOS_MAC_MDIO_ADDRESS_GOC_READ); |
| 191 | |
| 192 | if (val & EQOS_MAC_MDIO_ADDRESS_C45E) { |
| 193 | writel(FIELD_PREP(EQOS_MAC_MDIO_DATA_RA_MASK, mdio_reg), |
| 194 | &eqos->mac_regs->mdio_data); |
| 195 | } |
| 196 | |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 197 | writel(val, &eqos->mac_regs->mdio_address); |
| 198 | |
Christophe Roullier | 6beb780 | 2019-05-17 15:08:44 +0200 | [diff] [blame] | 199 | udelay(eqos->config->mdio_wait); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 200 | |
| 201 | ret = eqos_mdio_wait_idle(eqos); |
| 202 | if (ret) { |
Heinrich Schuchardt | ccb51b4 | 2024-04-02 10:39:34 +0200 | [diff] [blame] | 203 | pr_err("MDIO read didn't complete\n"); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 204 | return ret; |
| 205 | } |
| 206 | |
| 207 | val = readl(&eqos->mac_regs->mdio_data); |
| 208 | val &= EQOS_MAC_MDIO_DATA_GD_MASK; |
| 209 | |
| 210 | debug("%s: val=%x\n", __func__, val); |
| 211 | |
| 212 | return val; |
| 213 | } |
| 214 | |
| 215 | static int eqos_mdio_write(struct mii_dev *bus, int mdio_addr, int mdio_devad, |
| 216 | int mdio_reg, u16 mdio_val) |
| 217 | { |
| 218 | struct eqos_priv *eqos = bus->priv; |
Philip Oberfichtner | abed372 | 2024-05-07 11:42:37 +0200 | [diff] [blame] | 219 | u32 v_addr; |
| 220 | u32 v_data; |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 221 | int ret; |
| 222 | |
| 223 | debug("%s(dev=%p, addr=%x, reg=%d, val=%x):\n", __func__, eqos->dev, |
| 224 | mdio_addr, mdio_reg, mdio_val); |
| 225 | |
| 226 | ret = eqos_mdio_wait_idle(eqos); |
| 227 | if (ret) { |
Heinrich Schuchardt | ccb51b4 | 2024-04-02 10:39:34 +0200 | [diff] [blame] | 228 | pr_err("MDIO not idle at entry\n"); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 229 | return ret; |
| 230 | } |
| 231 | |
Philip Oberfichtner | abed372 | 2024-05-07 11:42:37 +0200 | [diff] [blame] | 232 | v_addr = readl(&eqos->mac_regs->mdio_address); |
| 233 | v_addr &= EQOS_MAC_MDIO_ADDRESS_SKAP; |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 234 | |
Philip Oberfichtner | abed372 | 2024-05-07 11:42:37 +0200 | [diff] [blame] | 235 | v_addr |= eqos_mdio_bitfield(eqos, mdio_addr, mdio_devad, mdio_reg) | |
| 236 | FIELD_PREP(EQOS_MAC_MDIO_ADDRESS_GOC_MASK, |
| 237 | EQOS_MAC_MDIO_ADDRESS_GOC_WRITE); |
| 238 | |
| 239 | v_data = mdio_val; |
| 240 | if (v_addr & EQOS_MAC_MDIO_ADDRESS_C45E) |
| 241 | v_data |= FIELD_PREP(EQOS_MAC_MDIO_DATA_RA_MASK, mdio_reg); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 242 | |
Philip Oberfichtner | abed372 | 2024-05-07 11:42:37 +0200 | [diff] [blame] | 243 | writel(v_data, &eqos->mac_regs->mdio_data); |
| 244 | writel(v_addr, &eqos->mac_regs->mdio_address); |
Christophe Roullier | 6beb780 | 2019-05-17 15:08:44 +0200 | [diff] [blame] | 245 | udelay(eqos->config->mdio_wait); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 246 | |
| 247 | ret = eqos_mdio_wait_idle(eqos); |
| 248 | if (ret) { |
Heinrich Schuchardt | ccb51b4 | 2024-04-02 10:39:34 +0200 | [diff] [blame] | 249 | pr_err("MDIO read didn't complete\n"); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 250 | return ret; |
| 251 | } |
| 252 | |
| 253 | return 0; |
| 254 | } |
| 255 | |
| 256 | static int eqos_start_clks_tegra186(struct udevice *dev) |
| 257 | { |
Fugang Duan | 37aae5f | 2020-05-03 22:41:17 +0800 | [diff] [blame] | 258 | #ifdef CONFIG_CLK |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 259 | struct eqos_priv *eqos = dev_get_priv(dev); |
| 260 | int ret; |
| 261 | |
| 262 | debug("%s(dev=%p):\n", __func__, dev); |
| 263 | |
| 264 | ret = clk_enable(&eqos->clk_slave_bus); |
| 265 | if (ret < 0) { |
Heinrich Schuchardt | ccb51b4 | 2024-04-02 10:39:34 +0200 | [diff] [blame] | 266 | pr_err("clk_enable(clk_slave_bus) failed: %d\n", ret); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 267 | goto err; |
| 268 | } |
| 269 | |
| 270 | ret = clk_enable(&eqos->clk_master_bus); |
| 271 | if (ret < 0) { |
Heinrich Schuchardt | ccb51b4 | 2024-04-02 10:39:34 +0200 | [diff] [blame] | 272 | pr_err("clk_enable(clk_master_bus) failed: %d\n", ret); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 273 | goto err_disable_clk_slave_bus; |
| 274 | } |
| 275 | |
| 276 | ret = clk_enable(&eqos->clk_rx); |
| 277 | if (ret < 0) { |
Heinrich Schuchardt | ccb51b4 | 2024-04-02 10:39:34 +0200 | [diff] [blame] | 278 | pr_err("clk_enable(clk_rx) failed: %d\n", ret); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 279 | goto err_disable_clk_master_bus; |
| 280 | } |
| 281 | |
| 282 | ret = clk_enable(&eqos->clk_ptp_ref); |
| 283 | if (ret < 0) { |
Heinrich Schuchardt | ccb51b4 | 2024-04-02 10:39:34 +0200 | [diff] [blame] | 284 | pr_err("clk_enable(clk_ptp_ref) failed: %d\n", ret); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 285 | goto err_disable_clk_rx; |
| 286 | } |
| 287 | |
| 288 | ret = clk_set_rate(&eqos->clk_ptp_ref, 125 * 1000 * 1000); |
| 289 | if (ret < 0) { |
Heinrich Schuchardt | ccb51b4 | 2024-04-02 10:39:34 +0200 | [diff] [blame] | 290 | pr_err("clk_set_rate(clk_ptp_ref) failed: %d\n", ret); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 291 | goto err_disable_clk_ptp_ref; |
| 292 | } |
| 293 | |
| 294 | ret = clk_enable(&eqos->clk_tx); |
| 295 | if (ret < 0) { |
Heinrich Schuchardt | ccb51b4 | 2024-04-02 10:39:34 +0200 | [diff] [blame] | 296 | pr_err("clk_enable(clk_tx) failed: %d\n", ret); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 297 | goto err_disable_clk_ptp_ref; |
| 298 | } |
Fugang Duan | 37aae5f | 2020-05-03 22:41:17 +0800 | [diff] [blame] | 299 | #endif |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 300 | |
| 301 | debug("%s: OK\n", __func__); |
| 302 | return 0; |
| 303 | |
Fugang Duan | 37aae5f | 2020-05-03 22:41:17 +0800 | [diff] [blame] | 304 | #ifdef CONFIG_CLK |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 305 | err_disable_clk_ptp_ref: |
| 306 | clk_disable(&eqos->clk_ptp_ref); |
| 307 | err_disable_clk_rx: |
| 308 | clk_disable(&eqos->clk_rx); |
| 309 | err_disable_clk_master_bus: |
| 310 | clk_disable(&eqos->clk_master_bus); |
| 311 | err_disable_clk_slave_bus: |
| 312 | clk_disable(&eqos->clk_slave_bus); |
| 313 | err: |
| 314 | debug("%s: FAILED: %d\n", __func__, ret); |
| 315 | return ret; |
Fugang Duan | 37aae5f | 2020-05-03 22:41:17 +0800 | [diff] [blame] | 316 | #endif |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 317 | } |
| 318 | |
Patrick Delaunay | 1bc6ce7 | 2021-07-20 20:09:56 +0200 | [diff] [blame] | 319 | static int eqos_stop_clks_tegra186(struct udevice *dev) |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 320 | { |
Fugang Duan | 37aae5f | 2020-05-03 22:41:17 +0800 | [diff] [blame] | 321 | #ifdef CONFIG_CLK |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 322 | struct eqos_priv *eqos = dev_get_priv(dev); |
| 323 | |
| 324 | debug("%s(dev=%p):\n", __func__, dev); |
| 325 | |
| 326 | clk_disable(&eqos->clk_tx); |
| 327 | clk_disable(&eqos->clk_ptp_ref); |
| 328 | clk_disable(&eqos->clk_rx); |
| 329 | clk_disable(&eqos->clk_master_bus); |
| 330 | clk_disable(&eqos->clk_slave_bus); |
Fugang Duan | 37aae5f | 2020-05-03 22:41:17 +0800 | [diff] [blame] | 331 | #endif |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 332 | |
| 333 | debug("%s: OK\n", __func__); |
Patrick Delaunay | 1bc6ce7 | 2021-07-20 20:09:56 +0200 | [diff] [blame] | 334 | return 0; |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 335 | } |
| 336 | |
| 337 | static int eqos_start_resets_tegra186(struct udevice *dev) |
| 338 | { |
| 339 | struct eqos_priv *eqos = dev_get_priv(dev); |
| 340 | int ret; |
| 341 | |
| 342 | debug("%s(dev=%p):\n", __func__, dev); |
| 343 | |
| 344 | ret = dm_gpio_set_value(&eqos->phy_reset_gpio, 1); |
| 345 | if (ret < 0) { |
Heinrich Schuchardt | ccb51b4 | 2024-04-02 10:39:34 +0200 | [diff] [blame] | 346 | pr_err("dm_gpio_set_value(phy_reset, assert) failed: %d\n", ret); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 347 | return ret; |
| 348 | } |
| 349 | |
| 350 | udelay(2); |
| 351 | |
| 352 | ret = dm_gpio_set_value(&eqos->phy_reset_gpio, 0); |
| 353 | if (ret < 0) { |
Heinrich Schuchardt | ccb51b4 | 2024-04-02 10:39:34 +0200 | [diff] [blame] | 354 | pr_err("dm_gpio_set_value(phy_reset, deassert) failed: %d\n", ret); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 355 | return ret; |
| 356 | } |
| 357 | |
| 358 | ret = reset_assert(&eqos->reset_ctl); |
| 359 | if (ret < 0) { |
Heinrich Schuchardt | ccb51b4 | 2024-04-02 10:39:34 +0200 | [diff] [blame] | 360 | pr_err("reset_assert() failed: %d\n", ret); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 361 | return ret; |
| 362 | } |
| 363 | |
| 364 | udelay(2); |
| 365 | |
| 366 | ret = reset_deassert(&eqos->reset_ctl); |
| 367 | if (ret < 0) { |
Heinrich Schuchardt | ccb51b4 | 2024-04-02 10:39:34 +0200 | [diff] [blame] | 368 | pr_err("reset_deassert() failed: %d\n", ret); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 369 | return ret; |
| 370 | } |
| 371 | |
| 372 | debug("%s: OK\n", __func__); |
| 373 | return 0; |
| 374 | } |
| 375 | |
| 376 | static int eqos_stop_resets_tegra186(struct udevice *dev) |
| 377 | { |
| 378 | struct eqos_priv *eqos = dev_get_priv(dev); |
| 379 | |
| 380 | reset_assert(&eqos->reset_ctl); |
| 381 | dm_gpio_set_value(&eqos->phy_reset_gpio, 1); |
| 382 | |
Christophe Roullier | 6beb780 | 2019-05-17 15:08:44 +0200 | [diff] [blame] | 383 | return 0; |
| 384 | } |
| 385 | |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 386 | static int eqos_calibrate_pads_tegra186(struct udevice *dev) |
| 387 | { |
| 388 | struct eqos_priv *eqos = dev_get_priv(dev); |
| 389 | int ret; |
| 390 | |
| 391 | debug("%s(dev=%p):\n", __func__, dev); |
| 392 | |
| 393 | setbits_le32(&eqos->tegra186_regs->sdmemcomppadctrl, |
| 394 | EQOS_SDMEMCOMPPADCTRL_PAD_E_INPUT_OR_E_PWRD); |
| 395 | |
| 396 | udelay(1); |
| 397 | |
| 398 | setbits_le32(&eqos->tegra186_regs->auto_cal_config, |
| 399 | EQOS_AUTO_CAL_CONFIG_START | EQOS_AUTO_CAL_CONFIG_ENABLE); |
| 400 | |
Álvaro Fernández Rojas | 918de03 | 2018-01-23 17:14:55 +0100 | [diff] [blame] | 401 | ret = wait_for_bit_le32(&eqos->tegra186_regs->auto_cal_status, |
| 402 | EQOS_AUTO_CAL_STATUS_ACTIVE, true, 10, false); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 403 | if (ret) { |
Heinrich Schuchardt | ccb51b4 | 2024-04-02 10:39:34 +0200 | [diff] [blame] | 404 | pr_err("calibrate didn't start\n"); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 405 | goto failed; |
| 406 | } |
| 407 | |
Álvaro Fernández Rojas | 918de03 | 2018-01-23 17:14:55 +0100 | [diff] [blame] | 408 | ret = wait_for_bit_le32(&eqos->tegra186_regs->auto_cal_status, |
| 409 | EQOS_AUTO_CAL_STATUS_ACTIVE, false, 10, false); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 410 | if (ret) { |
Heinrich Schuchardt | ccb51b4 | 2024-04-02 10:39:34 +0200 | [diff] [blame] | 411 | pr_err("calibrate didn't finish\n"); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 412 | goto failed; |
| 413 | } |
| 414 | |
| 415 | ret = 0; |
| 416 | |
| 417 | failed: |
| 418 | clrbits_le32(&eqos->tegra186_regs->sdmemcomppadctrl, |
| 419 | EQOS_SDMEMCOMPPADCTRL_PAD_E_INPUT_OR_E_PWRD); |
| 420 | |
| 421 | debug("%s: returns %d\n", __func__, ret); |
| 422 | |
| 423 | return ret; |
| 424 | } |
| 425 | |
| 426 | static int eqos_disable_calibration_tegra186(struct udevice *dev) |
| 427 | { |
| 428 | struct eqos_priv *eqos = dev_get_priv(dev); |
| 429 | |
| 430 | debug("%s(dev=%p):\n", __func__, dev); |
| 431 | |
| 432 | clrbits_le32(&eqos->tegra186_regs->auto_cal_config, |
| 433 | EQOS_AUTO_CAL_CONFIG_ENABLE); |
| 434 | |
| 435 | return 0; |
| 436 | } |
| 437 | |
| 438 | static ulong eqos_get_tick_clk_rate_tegra186(struct udevice *dev) |
| 439 | { |
Fugang Duan | 37aae5f | 2020-05-03 22:41:17 +0800 | [diff] [blame] | 440 | #ifdef CONFIG_CLK |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 441 | struct eqos_priv *eqos = dev_get_priv(dev); |
| 442 | |
| 443 | return clk_get_rate(&eqos->clk_slave_bus); |
Fugang Duan | 37aae5f | 2020-05-03 22:41:17 +0800 | [diff] [blame] | 444 | #else |
| 445 | return 0; |
| 446 | #endif |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 447 | } |
| 448 | |
| 449 | static int eqos_set_full_duplex(struct udevice *dev) |
| 450 | { |
| 451 | struct eqos_priv *eqos = dev_get_priv(dev); |
| 452 | |
| 453 | debug("%s(dev=%p):\n", __func__, dev); |
| 454 | |
| 455 | setbits_le32(&eqos->mac_regs->configuration, EQOS_MAC_CONFIGURATION_DM); |
| 456 | |
| 457 | return 0; |
| 458 | } |
| 459 | |
| 460 | static int eqos_set_half_duplex(struct udevice *dev) |
| 461 | { |
| 462 | struct eqos_priv *eqos = dev_get_priv(dev); |
| 463 | |
| 464 | debug("%s(dev=%p):\n", __func__, dev); |
| 465 | |
| 466 | clrbits_le32(&eqos->mac_regs->configuration, EQOS_MAC_CONFIGURATION_DM); |
| 467 | |
| 468 | /* WAR: Flush TX queue when switching to half-duplex */ |
| 469 | setbits_le32(&eqos->mtl_regs->txq0_operation_mode, |
| 470 | EQOS_MTL_TXQ0_OPERATION_MODE_FTQ); |
| 471 | |
| 472 | return 0; |
| 473 | } |
| 474 | |
| 475 | static int eqos_set_gmii_speed(struct udevice *dev) |
| 476 | { |
| 477 | struct eqos_priv *eqos = dev_get_priv(dev); |
| 478 | |
| 479 | debug("%s(dev=%p):\n", __func__, dev); |
| 480 | |
| 481 | clrbits_le32(&eqos->mac_regs->configuration, |
| 482 | EQOS_MAC_CONFIGURATION_PS | EQOS_MAC_CONFIGURATION_FES); |
| 483 | |
| 484 | return 0; |
| 485 | } |
| 486 | |
| 487 | static int eqos_set_mii_speed_100(struct udevice *dev) |
| 488 | { |
| 489 | struct eqos_priv *eqos = dev_get_priv(dev); |
| 490 | |
| 491 | debug("%s(dev=%p):\n", __func__, dev); |
| 492 | |
| 493 | setbits_le32(&eqos->mac_regs->configuration, |
| 494 | EQOS_MAC_CONFIGURATION_PS | EQOS_MAC_CONFIGURATION_FES); |
| 495 | |
| 496 | return 0; |
| 497 | } |
| 498 | |
| 499 | static int eqos_set_mii_speed_10(struct udevice *dev) |
| 500 | { |
| 501 | struct eqos_priv *eqos = dev_get_priv(dev); |
| 502 | |
| 503 | debug("%s(dev=%p):\n", __func__, dev); |
| 504 | |
| 505 | clrsetbits_le32(&eqos->mac_regs->configuration, |
| 506 | EQOS_MAC_CONFIGURATION_FES, EQOS_MAC_CONFIGURATION_PS); |
| 507 | |
| 508 | return 0; |
| 509 | } |
| 510 | |
| 511 | static int eqos_set_tx_clk_speed_tegra186(struct udevice *dev) |
| 512 | { |
Fugang Duan | 37aae5f | 2020-05-03 22:41:17 +0800 | [diff] [blame] | 513 | #ifdef CONFIG_CLK |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 514 | struct eqos_priv *eqos = dev_get_priv(dev); |
| 515 | ulong rate; |
| 516 | int ret; |
| 517 | |
| 518 | debug("%s(dev=%p):\n", __func__, dev); |
| 519 | |
| 520 | switch (eqos->phy->speed) { |
| 521 | case SPEED_1000: |
| 522 | rate = 125 * 1000 * 1000; |
| 523 | break; |
| 524 | case SPEED_100: |
| 525 | rate = 25 * 1000 * 1000; |
| 526 | break; |
| 527 | case SPEED_10: |
| 528 | rate = 2.5 * 1000 * 1000; |
| 529 | break; |
| 530 | default: |
Heinrich Schuchardt | ccb51b4 | 2024-04-02 10:39:34 +0200 | [diff] [blame] | 531 | pr_err("invalid speed %d\n", eqos->phy->speed); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 532 | return -EINVAL; |
| 533 | } |
| 534 | |
| 535 | ret = clk_set_rate(&eqos->clk_tx, rate); |
| 536 | if (ret < 0) { |
Heinrich Schuchardt | ccb51b4 | 2024-04-02 10:39:34 +0200 | [diff] [blame] | 537 | pr_err("clk_set_rate(tx_clk, %lu) failed: %d\n", rate, ret); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 538 | return ret; |
| 539 | } |
Fugang Duan | 37aae5f | 2020-05-03 22:41:17 +0800 | [diff] [blame] | 540 | #endif |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 541 | |
| 542 | return 0; |
| 543 | } |
| 544 | |
| 545 | static int eqos_adjust_link(struct udevice *dev) |
| 546 | { |
| 547 | struct eqos_priv *eqos = dev_get_priv(dev); |
| 548 | int ret; |
| 549 | bool en_calibration; |
| 550 | |
| 551 | debug("%s(dev=%p):\n", __func__, dev); |
| 552 | |
| 553 | if (eqos->phy->duplex) |
| 554 | ret = eqos_set_full_duplex(dev); |
| 555 | else |
| 556 | ret = eqos_set_half_duplex(dev); |
| 557 | if (ret < 0) { |
Heinrich Schuchardt | ccb51b4 | 2024-04-02 10:39:34 +0200 | [diff] [blame] | 558 | pr_err("eqos_set_*_duplex() failed: %d\n", ret); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 559 | return ret; |
| 560 | } |
| 561 | |
| 562 | switch (eqos->phy->speed) { |
| 563 | case SPEED_1000: |
| 564 | en_calibration = true; |
| 565 | ret = eqos_set_gmii_speed(dev); |
| 566 | break; |
| 567 | case SPEED_100: |
| 568 | en_calibration = true; |
| 569 | ret = eqos_set_mii_speed_100(dev); |
| 570 | break; |
| 571 | case SPEED_10: |
| 572 | en_calibration = false; |
| 573 | ret = eqos_set_mii_speed_10(dev); |
| 574 | break; |
| 575 | default: |
Heinrich Schuchardt | ccb51b4 | 2024-04-02 10:39:34 +0200 | [diff] [blame] | 576 | pr_err("invalid speed %d\n", eqos->phy->speed); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 577 | return -EINVAL; |
| 578 | } |
| 579 | if (ret < 0) { |
Heinrich Schuchardt | ccb51b4 | 2024-04-02 10:39:34 +0200 | [diff] [blame] | 580 | pr_err("eqos_set_*mii_speed*() failed: %d\n", ret); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 581 | return ret; |
| 582 | } |
| 583 | |
| 584 | if (en_calibration) { |
Christophe Roullier | 6beb780 | 2019-05-17 15:08:44 +0200 | [diff] [blame] | 585 | ret = eqos->config->ops->eqos_calibrate_pads(dev); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 586 | if (ret < 0) { |
Heinrich Schuchardt | ccb51b4 | 2024-04-02 10:39:34 +0200 | [diff] [blame] | 587 | pr_err("eqos_calibrate_pads() failed: %d\n", |
Christophe Roullier | 6beb780 | 2019-05-17 15:08:44 +0200 | [diff] [blame] | 588 | ret); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 589 | return ret; |
| 590 | } |
| 591 | } else { |
Christophe Roullier | 6beb780 | 2019-05-17 15:08:44 +0200 | [diff] [blame] | 592 | ret = eqos->config->ops->eqos_disable_calibration(dev); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 593 | if (ret < 0) { |
Heinrich Schuchardt | ccb51b4 | 2024-04-02 10:39:34 +0200 | [diff] [blame] | 594 | pr_err("eqos_disable_calibration() failed: %d\n", |
Christophe Roullier | 6beb780 | 2019-05-17 15:08:44 +0200 | [diff] [blame] | 595 | ret); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 596 | return ret; |
| 597 | } |
| 598 | } |
Christophe Roullier | 6beb780 | 2019-05-17 15:08:44 +0200 | [diff] [blame] | 599 | ret = eqos->config->ops->eqos_set_tx_clk_speed(dev); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 600 | if (ret < 0) { |
Heinrich Schuchardt | ccb51b4 | 2024-04-02 10:39:34 +0200 | [diff] [blame] | 601 | pr_err("eqos_set_tx_clk_speed() failed: %d\n", ret); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 602 | return ret; |
| 603 | } |
| 604 | |
| 605 | return 0; |
| 606 | } |
| 607 | |
| 608 | static int eqos_write_hwaddr(struct udevice *dev) |
| 609 | { |
Simon Glass | fa20e93 | 2020-12-03 16:55:20 -0700 | [diff] [blame] | 610 | struct eth_pdata *plat = dev_get_plat(dev); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 611 | struct eqos_priv *eqos = dev_get_priv(dev); |
| 612 | uint32_t val; |
| 613 | |
| 614 | /* |
| 615 | * This function may be called before start() or after stop(). At that |
| 616 | * time, on at least some configurations of the EQoS HW, all clocks to |
| 617 | * the EQoS HW block will be stopped, and a reset signal applied. If |
| 618 | * any register access is attempted in this state, bus timeouts or CPU |
| 619 | * hangs may occur. This check prevents that. |
| 620 | * |
| 621 | * A simple solution to this problem would be to not implement |
| 622 | * write_hwaddr(), since start() always writes the MAC address into HW |
| 623 | * anyway. However, it is desirable to implement write_hwaddr() to |
| 624 | * support the case of SW that runs subsequent to U-Boot which expects |
| 625 | * the MAC address to already be programmed into the EQoS registers, |
| 626 | * which must happen irrespective of whether the U-Boot user (or |
| 627 | * scripts) actually made use of the EQoS device, and hence |
| 628 | * irrespective of whether start() was ever called. |
| 629 | * |
| 630 | * Note that this requirement by subsequent SW is not valid for |
| 631 | * Tegra186, and is likely not valid for any non-PCI instantiation of |
| 632 | * the EQoS HW block. This function is implemented solely as |
| 633 | * future-proofing with the expectation the driver will eventually be |
| 634 | * ported to some system where the expectation above is true. |
| 635 | */ |
| 636 | if (!eqos->config->reg_access_always_ok && !eqos->reg_access_ok) |
| 637 | return 0; |
| 638 | |
| 639 | /* Update the MAC address */ |
| 640 | val = (plat->enetaddr[5] << 8) | |
| 641 | (plat->enetaddr[4]); |
| 642 | writel(val, &eqos->mac_regs->address0_high); |
| 643 | val = (plat->enetaddr[3] << 24) | |
| 644 | (plat->enetaddr[2] << 16) | |
| 645 | (plat->enetaddr[1] << 8) | |
| 646 | (plat->enetaddr[0]); |
| 647 | writel(val, &eqos->mac_regs->address0_low); |
| 648 | |
| 649 | return 0; |
| 650 | } |
| 651 | |
Ye Li | 3fb1a0e | 2020-05-03 22:41:20 +0800 | [diff] [blame] | 652 | static int eqos_read_rom_hwaddr(struct udevice *dev) |
| 653 | { |
Simon Glass | fa20e93 | 2020-12-03 16:55:20 -0700 | [diff] [blame] | 654 | struct eth_pdata *pdata = dev_get_plat(dev); |
Peng Fan | bf69a7b9 | 2022-07-26 16:41:17 +0800 | [diff] [blame] | 655 | struct eqos_priv *eqos = dev_get_priv(dev); |
| 656 | int ret; |
| 657 | |
| 658 | ret = eqos->config->ops->eqos_get_enetaddr(dev); |
| 659 | if (ret < 0) |
| 660 | return ret; |
Ye Li | 3fb1a0e | 2020-05-03 22:41:20 +0800 | [diff] [blame] | 661 | |
Ye Li | 3fb1a0e | 2020-05-03 22:41:20 +0800 | [diff] [blame] | 662 | return !is_valid_ethaddr(pdata->enetaddr); |
| 663 | } |
| 664 | |
Ye Li | 2f2aa48 | 2022-07-26 16:41:16 +0800 | [diff] [blame] | 665 | static int eqos_get_phy_addr(struct eqos_priv *priv, struct udevice *dev) |
| 666 | { |
| 667 | struct ofnode_phandle_args phandle_args; |
| 668 | int reg; |
| 669 | |
| 670 | if (dev_read_phandle_with_args(dev, "phy-handle", NULL, 0, 0, |
| 671 | &phandle_args)) { |
| 672 | debug("Failed to find phy-handle"); |
| 673 | return -ENODEV; |
| 674 | } |
| 675 | |
| 676 | priv->phy_of_node = phandle_args.node; |
| 677 | |
| 678 | reg = ofnode_read_u32_default(phandle_args.node, "reg", 0); |
| 679 | |
| 680 | return reg; |
| 681 | } |
| 682 | |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 683 | static int eqos_start(struct udevice *dev) |
| 684 | { |
| 685 | struct eqos_priv *eqos = dev_get_priv(dev); |
| 686 | int ret, i; |
| 687 | ulong rate; |
| 688 | u32 val, tx_fifo_sz, rx_fifo_sz, tqs, rqs, pbl; |
| 689 | ulong last_rx_desc; |
Marek Vasut | 8907773 | 2021-01-07 11:12:16 +0100 | [diff] [blame] | 690 | ulong desc_pad; |
Ley Foon Tan | 963db38 | 2022-12-09 14:33:14 +0800 | [diff] [blame] | 691 | ulong addr64; |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 692 | |
| 693 | debug("%s(dev=%p):\n", __func__, dev); |
| 694 | |
| 695 | eqos->tx_desc_idx = 0; |
| 696 | eqos->rx_desc_idx = 0; |
| 697 | |
Christophe Roullier | 6beb780 | 2019-05-17 15:08:44 +0200 | [diff] [blame] | 698 | ret = eqos->config->ops->eqos_start_resets(dev); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 699 | if (ret < 0) { |
Heinrich Schuchardt | ccb51b4 | 2024-04-02 10:39:34 +0200 | [diff] [blame] | 700 | pr_err("eqos_start_resets() failed: %d\n", ret); |
Marek Vasut | 30b28c4 | 2021-11-13 03:23:52 +0100 | [diff] [blame] | 701 | goto err; |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 702 | } |
| 703 | |
| 704 | udelay(10); |
| 705 | |
| 706 | eqos->reg_access_ok = true; |
| 707 | |
Marek Vasut | e66825a | 2023-03-06 15:53:46 +0100 | [diff] [blame] | 708 | /* |
| 709 | * Assert the SWR first, the actually reset the MAC and to latch in |
| 710 | * e.g. i.MX8M Plus GPR[1] content, which selects interface mode. |
| 711 | */ |
| 712 | setbits_le32(&eqos->dma_regs->mode, EQOS_DMA_MODE_SWR); |
| 713 | |
Álvaro Fernández Rojas | 918de03 | 2018-01-23 17:14:55 +0100 | [diff] [blame] | 714 | ret = wait_for_bit_le32(&eqos->dma_regs->mode, |
Christophe Roullier | 6beb780 | 2019-05-17 15:08:44 +0200 | [diff] [blame] | 715 | EQOS_DMA_MODE_SWR, false, |
| 716 | eqos->config->swr_wait, false); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 717 | if (ret) { |
Heinrich Schuchardt | ccb51b4 | 2024-04-02 10:39:34 +0200 | [diff] [blame] | 718 | pr_err("EQOS_DMA_MODE_SWR stuck\n"); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 719 | goto err_stop_resets; |
| 720 | } |
| 721 | |
Christophe Roullier | 6beb780 | 2019-05-17 15:08:44 +0200 | [diff] [blame] | 722 | ret = eqos->config->ops->eqos_calibrate_pads(dev); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 723 | if (ret < 0) { |
Heinrich Schuchardt | ccb51b4 | 2024-04-02 10:39:34 +0200 | [diff] [blame] | 724 | pr_err("eqos_calibrate_pads() failed: %d\n", ret); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 725 | goto err_stop_resets; |
| 726 | } |
Sumit Garg | ab973c9 | 2023-02-01 19:28:53 +0530 | [diff] [blame] | 727 | |
| 728 | if (eqos->config->ops->eqos_get_tick_clk_rate) { |
| 729 | rate = eqos->config->ops->eqos_get_tick_clk_rate(dev); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 730 | |
Sumit Garg | ab973c9 | 2023-02-01 19:28:53 +0530 | [diff] [blame] | 731 | val = (rate / 1000000) - 1; |
| 732 | writel(val, &eqos->mac_regs->us_tic_counter); |
| 733 | } |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 734 | |
Christophe Roullier | 6beb780 | 2019-05-17 15:08:44 +0200 | [diff] [blame] | 735 | /* |
| 736 | * if PHY was already connected and configured, |
| 737 | * don't need to reconnect/reconfigure again |
| 738 | */ |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 739 | if (!eqos->phy) { |
Ye Li | ad122b7 | 2020-05-03 22:41:15 +0800 | [diff] [blame] | 740 | int addr = -1; |
Elmar Psilog | dd65ba2 | 2023-02-20 16:03:15 +0100 | [diff] [blame] | 741 | ofnode fixed_node; |
| 742 | |
| 743 | if (IS_ENABLED(CONFIG_PHY_FIXED)) { |
| 744 | fixed_node = ofnode_find_subnode(dev_ofnode(dev), |
| 745 | "fixed-link"); |
| 746 | if (ofnode_valid(fixed_node)) |
| 747 | eqos->phy = fixed_phy_create(dev_ofnode(dev)); |
| 748 | } |
| 749 | |
| 750 | if (!eqos->phy) { |
| 751 | addr = eqos_get_phy_addr(eqos, dev); |
| 752 | eqos->phy = phy_connect(eqos->mii, addr, dev, |
| 753 | eqos->config->interface(dev)); |
| 754 | } |
| 755 | |
Christophe Roullier | 6beb780 | 2019-05-17 15:08:44 +0200 | [diff] [blame] | 756 | if (!eqos->phy) { |
Heinrich Schuchardt | ccb51b4 | 2024-04-02 10:39:34 +0200 | [diff] [blame] | 757 | pr_err("phy_connect() failed\n"); |
Jonas Karlman | 3c0a544 | 2023-10-01 19:17:17 +0000 | [diff] [blame] | 758 | ret = -ENODEV; |
Christophe Roullier | 6beb780 | 2019-05-17 15:08:44 +0200 | [diff] [blame] | 759 | goto err_stop_resets; |
| 760 | } |
Patrick Delaunay | 5c8db37 | 2020-03-18 10:50:16 +0100 | [diff] [blame] | 761 | |
| 762 | if (eqos->max_speed) { |
| 763 | ret = phy_set_supported(eqos->phy, eqos->max_speed); |
| 764 | if (ret) { |
Heinrich Schuchardt | ccb51b4 | 2024-04-02 10:39:34 +0200 | [diff] [blame] | 765 | pr_err("phy_set_supported() failed: %d\n", ret); |
Patrick Delaunay | 5c8db37 | 2020-03-18 10:50:16 +0100 | [diff] [blame] | 766 | goto err_shutdown_phy; |
| 767 | } |
| 768 | } |
| 769 | |
Ye Li | 2f2aa48 | 2022-07-26 16:41:16 +0800 | [diff] [blame] | 770 | eqos->phy->node = eqos->phy_of_node; |
Christophe Roullier | 6beb780 | 2019-05-17 15:08:44 +0200 | [diff] [blame] | 771 | ret = phy_config(eqos->phy); |
| 772 | if (ret < 0) { |
Heinrich Schuchardt | ccb51b4 | 2024-04-02 10:39:34 +0200 | [diff] [blame] | 773 | pr_err("phy_config() failed: %d\n", ret); |
Christophe Roullier | 6beb780 | 2019-05-17 15:08:44 +0200 | [diff] [blame] | 774 | goto err_shutdown_phy; |
| 775 | } |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 776 | } |
Christophe Roullier | 6beb780 | 2019-05-17 15:08:44 +0200 | [diff] [blame] | 777 | |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 778 | ret = phy_startup(eqos->phy); |
| 779 | if (ret < 0) { |
Heinrich Schuchardt | ccb51b4 | 2024-04-02 10:39:34 +0200 | [diff] [blame] | 780 | pr_err("phy_startup() failed: %d\n", ret); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 781 | goto err_shutdown_phy; |
| 782 | } |
| 783 | |
| 784 | if (!eqos->phy->link) { |
Heinrich Schuchardt | ccb51b4 | 2024-04-02 10:39:34 +0200 | [diff] [blame] | 785 | pr_err("No link\n"); |
Jonas Karlman | 3c0a544 | 2023-10-01 19:17:17 +0000 | [diff] [blame] | 786 | ret = -EAGAIN; |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 787 | goto err_shutdown_phy; |
| 788 | } |
| 789 | |
| 790 | ret = eqos_adjust_link(dev); |
| 791 | if (ret < 0) { |
Heinrich Schuchardt | ccb51b4 | 2024-04-02 10:39:34 +0200 | [diff] [blame] | 792 | pr_err("eqos_adjust_link() failed: %d\n", ret); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 793 | goto err_shutdown_phy; |
| 794 | } |
| 795 | |
| 796 | /* Configure MTL */ |
| 797 | |
| 798 | /* Enable Store and Forward mode for TX */ |
| 799 | /* Program Tx operating mode */ |
| 800 | setbits_le32(&eqos->mtl_regs->txq0_operation_mode, |
| 801 | EQOS_MTL_TXQ0_OPERATION_MODE_TSF | |
| 802 | (EQOS_MTL_TXQ0_OPERATION_MODE_TXQEN_ENABLED << |
| 803 | EQOS_MTL_TXQ0_OPERATION_MODE_TXQEN_SHIFT)); |
| 804 | |
| 805 | /* Transmit Queue weight */ |
| 806 | writel(0x10, &eqos->mtl_regs->txq0_quantum_weight); |
| 807 | |
| 808 | /* Enable Store and Forward mode for RX, since no jumbo frame */ |
| 809 | setbits_le32(&eqos->mtl_regs->rxq0_operation_mode, |
Daniil Stas | 470c06c | 2021-05-30 13:34:09 +0000 | [diff] [blame] | 810 | EQOS_MTL_RXQ0_OPERATION_MODE_RSF); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 811 | |
| 812 | /* Transmit/Receive queue fifo size; use all RAM for 1 queue */ |
| 813 | val = readl(&eqos->mac_regs->hw_feature1); |
| 814 | tx_fifo_sz = (val >> EQOS_MAC_HW_FEATURE1_TXFIFOSIZE_SHIFT) & |
| 815 | EQOS_MAC_HW_FEATURE1_TXFIFOSIZE_MASK; |
| 816 | rx_fifo_sz = (val >> EQOS_MAC_HW_FEATURE1_RXFIFOSIZE_SHIFT) & |
| 817 | EQOS_MAC_HW_FEATURE1_RXFIFOSIZE_MASK; |
| 818 | |
Sumit Garg | 4d5c965 | 2023-02-01 19:28:54 +0530 | [diff] [blame] | 819 | /* r/tx_fifo_sz is encoded as log2(n / 128). Undo that by shifting */ |
| 820 | tx_fifo_sz = 128 << tx_fifo_sz; |
| 821 | rx_fifo_sz = 128 << rx_fifo_sz; |
| 822 | |
| 823 | /* Allow platform to override TX/RX fifo size */ |
| 824 | if (eqos->tx_fifo_sz) |
| 825 | tx_fifo_sz = eqos->tx_fifo_sz; |
| 826 | if (eqos->rx_fifo_sz) |
| 827 | rx_fifo_sz = eqos->rx_fifo_sz; |
| 828 | |
| 829 | /* r/tqs is encoded as (n / 256) - 1 */ |
| 830 | tqs = tx_fifo_sz / 256 - 1; |
| 831 | rqs = rx_fifo_sz / 256 - 1; |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 832 | |
| 833 | clrsetbits_le32(&eqos->mtl_regs->txq0_operation_mode, |
| 834 | EQOS_MTL_TXQ0_OPERATION_MODE_TQS_MASK << |
| 835 | EQOS_MTL_TXQ0_OPERATION_MODE_TQS_SHIFT, |
| 836 | tqs << EQOS_MTL_TXQ0_OPERATION_MODE_TQS_SHIFT); |
| 837 | clrsetbits_le32(&eqos->mtl_regs->rxq0_operation_mode, |
| 838 | EQOS_MTL_RXQ0_OPERATION_MODE_RQS_MASK << |
| 839 | EQOS_MTL_RXQ0_OPERATION_MODE_RQS_SHIFT, |
| 840 | rqs << EQOS_MTL_RXQ0_OPERATION_MODE_RQS_SHIFT); |
| 841 | |
| 842 | /* Flow control used only if each channel gets 4KB or more FIFO */ |
| 843 | if (rqs >= ((4096 / 256) - 1)) { |
| 844 | u32 rfd, rfa; |
| 845 | |
| 846 | setbits_le32(&eqos->mtl_regs->rxq0_operation_mode, |
| 847 | EQOS_MTL_RXQ0_OPERATION_MODE_EHFC); |
| 848 | |
| 849 | /* |
| 850 | * Set Threshold for Activating Flow Contol space for min 2 |
| 851 | * frames ie, (1500 * 1) = 1500 bytes. |
| 852 | * |
| 853 | * Set Threshold for Deactivating Flow Contol for space of |
| 854 | * min 1 frame (frame size 1500bytes) in receive fifo |
| 855 | */ |
| 856 | if (rqs == ((4096 / 256) - 1)) { |
| 857 | /* |
| 858 | * This violates the above formula because of FIFO size |
| 859 | * limit therefore overflow may occur inspite of this. |
| 860 | */ |
| 861 | rfd = 0x3; /* Full-3K */ |
| 862 | rfa = 0x1; /* Full-1.5K */ |
| 863 | } else if (rqs == ((8192 / 256) - 1)) { |
| 864 | rfd = 0x6; /* Full-4K */ |
| 865 | rfa = 0xa; /* Full-6K */ |
| 866 | } else if (rqs == ((16384 / 256) - 1)) { |
| 867 | rfd = 0x6; /* Full-4K */ |
| 868 | rfa = 0x12; /* Full-10K */ |
| 869 | } else { |
| 870 | rfd = 0x6; /* Full-4K */ |
| 871 | rfa = 0x1E; /* Full-16K */ |
| 872 | } |
| 873 | |
| 874 | clrsetbits_le32(&eqos->mtl_regs->rxq0_operation_mode, |
| 875 | (EQOS_MTL_RXQ0_OPERATION_MODE_RFD_MASK << |
| 876 | EQOS_MTL_RXQ0_OPERATION_MODE_RFD_SHIFT) | |
| 877 | (EQOS_MTL_RXQ0_OPERATION_MODE_RFA_MASK << |
| 878 | EQOS_MTL_RXQ0_OPERATION_MODE_RFA_SHIFT), |
| 879 | (rfd << |
| 880 | EQOS_MTL_RXQ0_OPERATION_MODE_RFD_SHIFT) | |
| 881 | (rfa << |
| 882 | EQOS_MTL_RXQ0_OPERATION_MODE_RFA_SHIFT)); |
| 883 | } |
| 884 | |
| 885 | /* Configure MAC */ |
| 886 | |
| 887 | clrsetbits_le32(&eqos->mac_regs->rxq_ctrl0, |
| 888 | EQOS_MAC_RXQ_CTRL0_RXQ0EN_MASK << |
| 889 | EQOS_MAC_RXQ_CTRL0_RXQ0EN_SHIFT, |
Christophe Roullier | 6beb780 | 2019-05-17 15:08:44 +0200 | [diff] [blame] | 890 | eqos->config->config_mac << |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 891 | EQOS_MAC_RXQ_CTRL0_RXQ0EN_SHIFT); |
| 892 | |
Fugang Duan | 37aae5f | 2020-05-03 22:41:17 +0800 | [diff] [blame] | 893 | /* Multicast and Broadcast Queue Enable */ |
| 894 | setbits_le32(&eqos->mac_regs->unused_0a4, |
| 895 | 0x00100000); |
| 896 | /* enable promise mode */ |
| 897 | setbits_le32(&eqos->mac_regs->unused_004[1], |
| 898 | 0x1); |
| 899 | |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 900 | /* Set TX flow control parameters */ |
| 901 | /* Set Pause Time */ |
| 902 | setbits_le32(&eqos->mac_regs->q0_tx_flow_ctrl, |
| 903 | 0xffff << EQOS_MAC_Q0_TX_FLOW_CTRL_PT_SHIFT); |
| 904 | /* Assign priority for TX flow control */ |
| 905 | clrbits_le32(&eqos->mac_regs->txq_prty_map0, |
| 906 | EQOS_MAC_TXQ_PRTY_MAP0_PSTQ0_MASK << |
| 907 | EQOS_MAC_TXQ_PRTY_MAP0_PSTQ0_SHIFT); |
| 908 | /* Assign priority for RX flow control */ |
| 909 | clrbits_le32(&eqos->mac_regs->rxq_ctrl2, |
| 910 | EQOS_MAC_RXQ_CTRL2_PSRQ0_MASK << |
| 911 | EQOS_MAC_RXQ_CTRL2_PSRQ0_SHIFT); |
| 912 | /* Enable flow control */ |
| 913 | setbits_le32(&eqos->mac_regs->q0_tx_flow_ctrl, |
| 914 | EQOS_MAC_Q0_TX_FLOW_CTRL_TFE); |
| 915 | setbits_le32(&eqos->mac_regs->rx_flow_ctrl, |
| 916 | EQOS_MAC_RX_FLOW_CTRL_RFE); |
| 917 | |
| 918 | clrsetbits_le32(&eqos->mac_regs->configuration, |
| 919 | EQOS_MAC_CONFIGURATION_GPSLCE | |
| 920 | EQOS_MAC_CONFIGURATION_WD | |
| 921 | EQOS_MAC_CONFIGURATION_JD | |
| 922 | EQOS_MAC_CONFIGURATION_JE, |
| 923 | EQOS_MAC_CONFIGURATION_CST | |
| 924 | EQOS_MAC_CONFIGURATION_ACS); |
| 925 | |
| 926 | eqos_write_hwaddr(dev); |
| 927 | |
| 928 | /* Configure DMA */ |
| 929 | |
| 930 | /* Enable OSP mode */ |
| 931 | setbits_le32(&eqos->dma_regs->ch0_tx_control, |
| 932 | EQOS_DMA_CH0_TX_CONTROL_OSP); |
| 933 | |
| 934 | /* RX buffer size. Must be a multiple of bus width */ |
| 935 | clrsetbits_le32(&eqos->dma_regs->ch0_rx_control, |
| 936 | EQOS_DMA_CH0_RX_CONTROL_RBSZ_MASK << |
| 937 | EQOS_DMA_CH0_RX_CONTROL_RBSZ_SHIFT, |
| 938 | EQOS_MAX_PACKET_SIZE << |
| 939 | EQOS_DMA_CH0_RX_CONTROL_RBSZ_SHIFT); |
| 940 | |
Marek Vasut | 8907773 | 2021-01-07 11:12:16 +0100 | [diff] [blame] | 941 | desc_pad = (eqos->desc_size - sizeof(struct eqos_desc)) / |
| 942 | eqos->config->axi_bus_width; |
| 943 | |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 944 | setbits_le32(&eqos->dma_regs->ch0_control, |
Marek Vasut | 8907773 | 2021-01-07 11:12:16 +0100 | [diff] [blame] | 945 | EQOS_DMA_CH0_CONTROL_PBLX8 | |
| 946 | (desc_pad << EQOS_DMA_CH0_CONTROL_DSL_SHIFT)); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 947 | |
| 948 | /* |
| 949 | * Burst length must be < 1/2 FIFO size. |
| 950 | * FIFO size in tqs is encoded as (n / 256) - 1. |
| 951 | * Each burst is n * 8 (PBLX8) * 16 (AXI width) == 128 bytes. |
| 952 | * Half of n * 256 is n * 128, so pbl == tqs, modulo the -1. |
| 953 | */ |
| 954 | pbl = tqs + 1; |
| 955 | if (pbl > 32) |
| 956 | pbl = 32; |
| 957 | clrsetbits_le32(&eqos->dma_regs->ch0_tx_control, |
| 958 | EQOS_DMA_CH0_TX_CONTROL_TXPBL_MASK << |
| 959 | EQOS_DMA_CH0_TX_CONTROL_TXPBL_SHIFT, |
| 960 | pbl << EQOS_DMA_CH0_TX_CONTROL_TXPBL_SHIFT); |
| 961 | |
| 962 | clrsetbits_le32(&eqos->dma_regs->ch0_rx_control, |
| 963 | EQOS_DMA_CH0_RX_CONTROL_RXPBL_MASK << |
| 964 | EQOS_DMA_CH0_RX_CONTROL_RXPBL_SHIFT, |
| 965 | 8 << EQOS_DMA_CH0_RX_CONTROL_RXPBL_SHIFT); |
| 966 | |
| 967 | /* DMA performance configuration */ |
| 968 | val = (2 << EQOS_DMA_SYSBUS_MODE_RD_OSR_LMT_SHIFT) | |
| 969 | EQOS_DMA_SYSBUS_MODE_EAME | EQOS_DMA_SYSBUS_MODE_BLEN16 | |
| 970 | EQOS_DMA_SYSBUS_MODE_BLEN8 | EQOS_DMA_SYSBUS_MODE_BLEN4; |
| 971 | writel(val, &eqos->dma_regs->sysbus_mode); |
| 972 | |
| 973 | /* Set up descriptors */ |
| 974 | |
Marek Vasut | 90cc13a | 2022-10-09 17:51:45 +0200 | [diff] [blame] | 975 | memset(eqos->tx_descs, 0, eqos->desc_size * EQOS_DESCRIPTORS_TX); |
| 976 | memset(eqos->rx_descs, 0, eqos->desc_size * EQOS_DESCRIPTORS_RX); |
Marek Vasut | 8907773 | 2021-01-07 11:12:16 +0100 | [diff] [blame] | 977 | |
| 978 | for (i = 0; i < EQOS_DESCRIPTORS_TX; i++) { |
| 979 | struct eqos_desc *tx_desc = eqos_get_desc(eqos, i, false); |
| 980 | eqos->config->ops->eqos_flush_desc(tx_desc); |
| 981 | } |
| 982 | |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 983 | for (i = 0; i < EQOS_DESCRIPTORS_RX; i++) { |
Marek Vasut | 8907773 | 2021-01-07 11:12:16 +0100 | [diff] [blame] | 984 | struct eqos_desc *rx_desc = eqos_get_desc(eqos, i, true); |
Ley Foon Tan | 963db38 | 2022-12-09 14:33:14 +0800 | [diff] [blame] | 985 | |
| 986 | addr64 = (ulong)(eqos->rx_dma_buf + (i * EQOS_MAX_PACKET_SIZE)); |
| 987 | rx_desc->des0 = lower_32_bits(addr64); |
| 988 | rx_desc->des1 = upper_32_bits(addr64); |
Marek Vasut | d54c98e | 2020-03-23 02:02:57 +0100 | [diff] [blame] | 989 | rx_desc->des3 = EQOS_DESC3_OWN | EQOS_DESC3_BUF1V; |
Fugang Duan | 37aae5f | 2020-05-03 22:41:17 +0800 | [diff] [blame] | 990 | mb(); |
Marek Vasut | 873f8e4 | 2020-03-23 02:09:01 +0100 | [diff] [blame] | 991 | eqos->config->ops->eqos_flush_desc(rx_desc); |
Ley Foon Tan | 963db38 | 2022-12-09 14:33:14 +0800 | [diff] [blame] | 992 | eqos->config->ops->eqos_inval_buffer((void *)addr64, EQOS_MAX_PACKET_SIZE); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 993 | } |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 994 | |
Ley Foon Tan | 963db38 | 2022-12-09 14:33:14 +0800 | [diff] [blame] | 995 | addr64 = (ulong)eqos_get_desc(eqos, 0, false); |
| 996 | writel(upper_32_bits(addr64), &eqos->dma_regs->ch0_txdesc_list_haddress); |
| 997 | writel(lower_32_bits(addr64), &eqos->dma_regs->ch0_txdesc_list_address); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 998 | writel(EQOS_DESCRIPTORS_TX - 1, |
| 999 | &eqos->dma_regs->ch0_txdesc_ring_length); |
| 1000 | |
Ley Foon Tan | 963db38 | 2022-12-09 14:33:14 +0800 | [diff] [blame] | 1001 | addr64 = (ulong)eqos_get_desc(eqos, 0, true); |
| 1002 | writel(upper_32_bits(addr64), &eqos->dma_regs->ch0_rxdesc_list_haddress); |
| 1003 | writel(lower_32_bits(addr64), &eqos->dma_regs->ch0_rxdesc_list_address); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1004 | writel(EQOS_DESCRIPTORS_RX - 1, |
| 1005 | &eqos->dma_regs->ch0_rxdesc_ring_length); |
| 1006 | |
| 1007 | /* Enable everything */ |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1008 | setbits_le32(&eqos->dma_regs->ch0_tx_control, |
| 1009 | EQOS_DMA_CH0_TX_CONTROL_ST); |
| 1010 | setbits_le32(&eqos->dma_regs->ch0_rx_control, |
| 1011 | EQOS_DMA_CH0_RX_CONTROL_SR); |
Fugang Duan | 37aae5f | 2020-05-03 22:41:17 +0800 | [diff] [blame] | 1012 | setbits_le32(&eqos->mac_regs->configuration, |
| 1013 | EQOS_MAC_CONFIGURATION_TE | EQOS_MAC_CONFIGURATION_RE); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1014 | |
| 1015 | /* TX tail pointer not written until we need to TX a packet */ |
| 1016 | /* |
| 1017 | * Point RX tail pointer at last descriptor. Ideally, we'd point at the |
| 1018 | * first descriptor, implying all descriptors were available. However, |
| 1019 | * that's not distinguishable from none of the descriptors being |
| 1020 | * available. |
| 1021 | */ |
Marek Vasut | 8907773 | 2021-01-07 11:12:16 +0100 | [diff] [blame] | 1022 | last_rx_desc = (ulong)eqos_get_desc(eqos, EQOS_DESCRIPTORS_RX - 1, true); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1023 | writel(last_rx_desc, &eqos->dma_regs->ch0_rxdesc_tail_pointer); |
| 1024 | |
| 1025 | eqos->started = true; |
| 1026 | |
| 1027 | debug("%s: OK\n", __func__); |
| 1028 | return 0; |
| 1029 | |
| 1030 | err_shutdown_phy: |
| 1031 | phy_shutdown(eqos->phy); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1032 | err_stop_resets: |
Christophe Roullier | 6beb780 | 2019-05-17 15:08:44 +0200 | [diff] [blame] | 1033 | eqos->config->ops->eqos_stop_resets(dev); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1034 | err: |
Heinrich Schuchardt | ccb51b4 | 2024-04-02 10:39:34 +0200 | [diff] [blame] | 1035 | pr_err("FAILED: %d\n", ret); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1036 | return ret; |
| 1037 | } |
| 1038 | |
Patrick Delaunay | 6864a599 | 2019-08-01 11:29:02 +0200 | [diff] [blame] | 1039 | static void eqos_stop(struct udevice *dev) |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1040 | { |
| 1041 | struct eqos_priv *eqos = dev_get_priv(dev); |
| 1042 | int i; |
| 1043 | |
| 1044 | debug("%s(dev=%p):\n", __func__, dev); |
| 1045 | |
| 1046 | if (!eqos->started) |
| 1047 | return; |
| 1048 | eqos->started = false; |
| 1049 | eqos->reg_access_ok = false; |
| 1050 | |
| 1051 | /* Disable TX DMA */ |
| 1052 | clrbits_le32(&eqos->dma_regs->ch0_tx_control, |
| 1053 | EQOS_DMA_CH0_TX_CONTROL_ST); |
| 1054 | |
| 1055 | /* Wait for TX all packets to drain out of MTL */ |
| 1056 | for (i = 0; i < 1000000; i++) { |
| 1057 | u32 val = readl(&eqos->mtl_regs->txq0_debug); |
| 1058 | u32 trcsts = (val >> EQOS_MTL_TXQ0_DEBUG_TRCSTS_SHIFT) & |
| 1059 | EQOS_MTL_TXQ0_DEBUG_TRCSTS_MASK; |
| 1060 | u32 txqsts = val & EQOS_MTL_TXQ0_DEBUG_TXQSTS; |
| 1061 | if ((trcsts != 1) && (!txqsts)) |
| 1062 | break; |
| 1063 | } |
| 1064 | |
| 1065 | /* Turn off MAC TX and RX */ |
| 1066 | clrbits_le32(&eqos->mac_regs->configuration, |
| 1067 | EQOS_MAC_CONFIGURATION_TE | EQOS_MAC_CONFIGURATION_RE); |
| 1068 | |
| 1069 | /* Wait for all RX packets to drain out of MTL */ |
| 1070 | for (i = 0; i < 1000000; i++) { |
| 1071 | u32 val = readl(&eqos->mtl_regs->rxq0_debug); |
| 1072 | u32 prxq = (val >> EQOS_MTL_RXQ0_DEBUG_PRXQ_SHIFT) & |
| 1073 | EQOS_MTL_RXQ0_DEBUG_PRXQ_MASK; |
| 1074 | u32 rxqsts = (val >> EQOS_MTL_RXQ0_DEBUG_RXQSTS_SHIFT) & |
| 1075 | EQOS_MTL_RXQ0_DEBUG_RXQSTS_MASK; |
| 1076 | if ((!prxq) && (!rxqsts)) |
| 1077 | break; |
| 1078 | } |
| 1079 | |
| 1080 | /* Turn off RX DMA */ |
| 1081 | clrbits_le32(&eqos->dma_regs->ch0_rx_control, |
| 1082 | EQOS_DMA_CH0_RX_CONTROL_SR); |
| 1083 | |
| 1084 | if (eqos->phy) { |
| 1085 | phy_shutdown(eqos->phy); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1086 | } |
Christophe Roullier | 6beb780 | 2019-05-17 15:08:44 +0200 | [diff] [blame] | 1087 | eqos->config->ops->eqos_stop_resets(dev); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1088 | |
| 1089 | debug("%s: OK\n", __func__); |
| 1090 | } |
| 1091 | |
Patrick Delaunay | 6864a599 | 2019-08-01 11:29:02 +0200 | [diff] [blame] | 1092 | static int eqos_send(struct udevice *dev, void *packet, int length) |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1093 | { |
| 1094 | struct eqos_priv *eqos = dev_get_priv(dev); |
| 1095 | struct eqos_desc *tx_desc; |
| 1096 | int i; |
| 1097 | |
| 1098 | debug("%s(dev=%p, packet=%p, length=%d):\n", __func__, dev, packet, |
| 1099 | length); |
| 1100 | |
| 1101 | memcpy(eqos->tx_dma_buf, packet, length); |
Christophe Roullier | 6beb780 | 2019-05-17 15:08:44 +0200 | [diff] [blame] | 1102 | eqos->config->ops->eqos_flush_buffer(eqos->tx_dma_buf, length); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1103 | |
Marek Vasut | 8907773 | 2021-01-07 11:12:16 +0100 | [diff] [blame] | 1104 | tx_desc = eqos_get_desc(eqos, eqos->tx_desc_idx, false); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1105 | eqos->tx_desc_idx++; |
| 1106 | eqos->tx_desc_idx %= EQOS_DESCRIPTORS_TX; |
| 1107 | |
Ley Foon Tan | 963db38 | 2022-12-09 14:33:14 +0800 | [diff] [blame] | 1108 | tx_desc->des0 = lower_32_bits((ulong)eqos->tx_dma_buf); |
| 1109 | tx_desc->des1 = upper_32_bits((ulong)eqos->tx_dma_buf); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1110 | tx_desc->des2 = length; |
| 1111 | /* |
| 1112 | * Make sure that if HW sees the _OWN write below, it will see all the |
| 1113 | * writes to the rest of the descriptor too. |
| 1114 | */ |
| 1115 | mb(); |
| 1116 | tx_desc->des3 = EQOS_DESC3_OWN | EQOS_DESC3_FD | EQOS_DESC3_LD | length; |
Christophe Roullier | 6beb780 | 2019-05-17 15:08:44 +0200 | [diff] [blame] | 1117 | eqos->config->ops->eqos_flush_desc(tx_desc); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1118 | |
Marek Vasut | 8907773 | 2021-01-07 11:12:16 +0100 | [diff] [blame] | 1119 | writel((ulong)eqos_get_desc(eqos, eqos->tx_desc_idx, false), |
Marek Vasut | f4f1f4d | 2020-03-23 02:03:50 +0100 | [diff] [blame] | 1120 | &eqos->dma_regs->ch0_txdesc_tail_pointer); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1121 | |
| 1122 | for (i = 0; i < 1000000; i++) { |
Christophe Roullier | 6beb780 | 2019-05-17 15:08:44 +0200 | [diff] [blame] | 1123 | eqos->config->ops->eqos_inval_desc(tx_desc); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1124 | if (!(readl(&tx_desc->des3) & EQOS_DESC3_OWN)) |
| 1125 | return 0; |
| 1126 | udelay(1); |
| 1127 | } |
| 1128 | |
| 1129 | debug("%s: TX timeout\n", __func__); |
| 1130 | |
| 1131 | return -ETIMEDOUT; |
| 1132 | } |
| 1133 | |
Patrick Delaunay | 6864a599 | 2019-08-01 11:29:02 +0200 | [diff] [blame] | 1134 | static int eqos_recv(struct udevice *dev, int flags, uchar **packetp) |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1135 | { |
| 1136 | struct eqos_priv *eqos = dev_get_priv(dev); |
| 1137 | struct eqos_desc *rx_desc; |
| 1138 | int length; |
| 1139 | |
Marek Vasut | 8907773 | 2021-01-07 11:12:16 +0100 | [diff] [blame] | 1140 | rx_desc = eqos_get_desc(eqos, eqos->rx_desc_idx, true); |
Marek Vasut | c4db844 | 2020-03-23 02:09:21 +0100 | [diff] [blame] | 1141 | eqos->config->ops->eqos_inval_desc(rx_desc); |
Jonas Karlman | e2c4546 | 2023-10-01 19:17:18 +0000 | [diff] [blame] | 1142 | if (rx_desc->des3 & EQOS_DESC3_OWN) |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1143 | return -EAGAIN; |
Jonas Karlman | e2c4546 | 2023-10-01 19:17:18 +0000 | [diff] [blame] | 1144 | |
| 1145 | debug("%s(dev=%p, flags=%x):\n", __func__, dev, flags); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1146 | |
| 1147 | *packetp = eqos->rx_dma_buf + |
| 1148 | (eqos->rx_desc_idx * EQOS_MAX_PACKET_SIZE); |
| 1149 | length = rx_desc->des3 & 0x7fff; |
| 1150 | debug("%s: *packetp=%p, length=%d\n", __func__, *packetp, length); |
| 1151 | |
Christophe Roullier | 6beb780 | 2019-05-17 15:08:44 +0200 | [diff] [blame] | 1152 | eqos->config->ops->eqos_inval_buffer(*packetp, length); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1153 | |
| 1154 | return length; |
| 1155 | } |
| 1156 | |
Patrick Delaunay | 6864a599 | 2019-08-01 11:29:02 +0200 | [diff] [blame] | 1157 | static int eqos_free_pkt(struct udevice *dev, uchar *packet, int length) |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1158 | { |
| 1159 | struct eqos_priv *eqos = dev_get_priv(dev); |
Marek Vasut | 3e8a1be | 2022-10-09 17:51:46 +0200 | [diff] [blame] | 1160 | u32 idx, idx_mask = eqos->desc_per_cacheline - 1; |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1161 | uchar *packet_expected; |
Patrice Chotard | 7b1baf3 | 2024-04-05 18:15:29 +0200 | [diff] [blame] | 1162 | struct eqos_desc *rx_desc = NULL; |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1163 | |
| 1164 | debug("%s(packet=%p, length=%d)\n", __func__, packet, length); |
| 1165 | |
| 1166 | packet_expected = eqos->rx_dma_buf + |
| 1167 | (eqos->rx_desc_idx * EQOS_MAX_PACKET_SIZE); |
| 1168 | if (packet != packet_expected) { |
| 1169 | debug("%s: Unexpected packet (expected %p)\n", __func__, |
| 1170 | packet_expected); |
| 1171 | return -EINVAL; |
| 1172 | } |
| 1173 | |
Fugang Duan | 37aae5f | 2020-05-03 22:41:17 +0800 | [diff] [blame] | 1174 | eqos->config->ops->eqos_inval_buffer(packet, length); |
| 1175 | |
Marek Vasut | 3e8a1be | 2022-10-09 17:51:46 +0200 | [diff] [blame] | 1176 | if ((eqos->rx_desc_idx & idx_mask) == idx_mask) { |
| 1177 | for (idx = eqos->rx_desc_idx - idx_mask; |
| 1178 | idx <= eqos->rx_desc_idx; |
| 1179 | idx++) { |
Ley Foon Tan | 963db38 | 2022-12-09 14:33:14 +0800 | [diff] [blame] | 1180 | ulong addr64; |
| 1181 | |
Marek Vasut | 3e8a1be | 2022-10-09 17:51:46 +0200 | [diff] [blame] | 1182 | rx_desc = eqos_get_desc(eqos, idx, true); |
| 1183 | rx_desc->des0 = 0; |
Ley Foon Tan | 963db38 | 2022-12-09 14:33:14 +0800 | [diff] [blame] | 1184 | rx_desc->des1 = 0; |
Marek Vasut | 3e8a1be | 2022-10-09 17:51:46 +0200 | [diff] [blame] | 1185 | mb(); |
| 1186 | eqos->config->ops->eqos_flush_desc(rx_desc); |
| 1187 | eqos->config->ops->eqos_inval_buffer(packet, length); |
Ley Foon Tan | 963db38 | 2022-12-09 14:33:14 +0800 | [diff] [blame] | 1188 | addr64 = (ulong)(eqos->rx_dma_buf + (idx * EQOS_MAX_PACKET_SIZE)); |
| 1189 | rx_desc->des0 = lower_32_bits(addr64); |
| 1190 | rx_desc->des1 = upper_32_bits(addr64); |
Marek Vasut | 3e8a1be | 2022-10-09 17:51:46 +0200 | [diff] [blame] | 1191 | rx_desc->des2 = 0; |
| 1192 | /* |
| 1193 | * Make sure that if HW sees the _OWN write below, |
| 1194 | * it will see all the writes to the rest of the |
| 1195 | * descriptor too. |
| 1196 | */ |
| 1197 | mb(); |
| 1198 | rx_desc->des3 = EQOS_DESC3_OWN | EQOS_DESC3_BUF1V; |
| 1199 | eqos->config->ops->eqos_flush_desc(rx_desc); |
| 1200 | } |
| 1201 | writel((ulong)rx_desc, &eqos->dma_regs->ch0_rxdesc_tail_pointer); |
| 1202 | } |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1203 | |
| 1204 | eqos->rx_desc_idx++; |
| 1205 | eqos->rx_desc_idx %= EQOS_DESCRIPTORS_RX; |
| 1206 | |
| 1207 | return 0; |
| 1208 | } |
| 1209 | |
| 1210 | static int eqos_probe_resources_core(struct udevice *dev) |
| 1211 | { |
| 1212 | struct eqos_priv *eqos = dev_get_priv(dev); |
Marek Vasut | 3e8a1be | 2022-10-09 17:51:46 +0200 | [diff] [blame] | 1213 | unsigned int desc_step; |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1214 | int ret; |
| 1215 | |
| 1216 | debug("%s(dev=%p):\n", __func__, dev); |
| 1217 | |
Marek Vasut | 3e8a1be | 2022-10-09 17:51:46 +0200 | [diff] [blame] | 1218 | /* Maximum distance between neighboring descriptors, in Bytes. */ |
| 1219 | desc_step = sizeof(struct eqos_desc) + |
| 1220 | EQOS_DMA_CH0_CONTROL_DSL_MASK * eqos->config->axi_bus_width; |
| 1221 | if (desc_step < ARCH_DMA_MINALIGN) { |
| 1222 | /* |
| 1223 | * The EQoS hardware implementation cannot place one descriptor |
| 1224 | * per cacheline, it is necessary to place multiple descriptors |
| 1225 | * per cacheline in memory and do cache management carefully. |
| 1226 | */ |
| 1227 | eqos->desc_size = BIT(fls(desc_step) - 1); |
| 1228 | } else { |
| 1229 | eqos->desc_size = ALIGN(sizeof(struct eqos_desc), |
| 1230 | (unsigned int)ARCH_DMA_MINALIGN); |
| 1231 | } |
| 1232 | eqos->desc_per_cacheline = ARCH_DMA_MINALIGN / eqos->desc_size; |
Marek Vasut | 90cc13a | 2022-10-09 17:51:45 +0200 | [diff] [blame] | 1233 | |
| 1234 | eqos->tx_descs = eqos_alloc_descs(eqos, EQOS_DESCRIPTORS_TX); |
| 1235 | if (!eqos->tx_descs) { |
| 1236 | debug("%s: eqos_alloc_descs(tx) failed\n", __func__); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1237 | ret = -ENOMEM; |
| 1238 | goto err; |
| 1239 | } |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1240 | |
Marek Vasut | 90cc13a | 2022-10-09 17:51:45 +0200 | [diff] [blame] | 1241 | eqos->rx_descs = eqos_alloc_descs(eqos, EQOS_DESCRIPTORS_RX); |
| 1242 | if (!eqos->rx_descs) { |
| 1243 | debug("%s: eqos_alloc_descs(rx) failed\n", __func__); |
| 1244 | ret = -ENOMEM; |
| 1245 | goto err_free_tx_descs; |
| 1246 | } |
| 1247 | |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1248 | eqos->tx_dma_buf = memalign(EQOS_BUFFER_ALIGN, EQOS_MAX_PACKET_SIZE); |
| 1249 | if (!eqos->tx_dma_buf) { |
| 1250 | debug("%s: memalign(tx_dma_buf) failed\n", __func__); |
| 1251 | ret = -ENOMEM; |
| 1252 | goto err_free_descs; |
| 1253 | } |
Christophe Roullier | 6beb780 | 2019-05-17 15:08:44 +0200 | [diff] [blame] | 1254 | debug("%s: tx_dma_buf=%p\n", __func__, eqos->tx_dma_buf); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1255 | |
| 1256 | eqos->rx_dma_buf = memalign(EQOS_BUFFER_ALIGN, EQOS_RX_BUFFER_SIZE); |
| 1257 | if (!eqos->rx_dma_buf) { |
| 1258 | debug("%s: memalign(rx_dma_buf) failed\n", __func__); |
| 1259 | ret = -ENOMEM; |
| 1260 | goto err_free_tx_dma_buf; |
| 1261 | } |
Christophe Roullier | 6beb780 | 2019-05-17 15:08:44 +0200 | [diff] [blame] | 1262 | debug("%s: rx_dma_buf=%p\n", __func__, eqos->rx_dma_buf); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1263 | |
Marek Vasut | e8e5c2b | 2020-03-23 02:09:55 +0100 | [diff] [blame] | 1264 | eqos->config->ops->eqos_inval_buffer(eqos->rx_dma_buf, |
| 1265 | EQOS_MAX_PACKET_SIZE * EQOS_DESCRIPTORS_RX); |
| 1266 | |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1267 | debug("%s: OK\n", __func__); |
| 1268 | return 0; |
| 1269 | |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1270 | err_free_tx_dma_buf: |
| 1271 | free(eqos->tx_dma_buf); |
| 1272 | err_free_descs: |
Marek Vasut | 90cc13a | 2022-10-09 17:51:45 +0200 | [diff] [blame] | 1273 | eqos_free_descs(eqos->rx_descs); |
| 1274 | err_free_tx_descs: |
| 1275 | eqos_free_descs(eqos->tx_descs); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1276 | err: |
| 1277 | |
| 1278 | debug("%s: returns %d\n", __func__, ret); |
| 1279 | return ret; |
| 1280 | } |
| 1281 | |
| 1282 | static int eqos_remove_resources_core(struct udevice *dev) |
| 1283 | { |
| 1284 | struct eqos_priv *eqos = dev_get_priv(dev); |
| 1285 | |
| 1286 | debug("%s(dev=%p):\n", __func__, dev); |
| 1287 | |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1288 | free(eqos->rx_dma_buf); |
| 1289 | free(eqos->tx_dma_buf); |
Marek Vasut | 90cc13a | 2022-10-09 17:51:45 +0200 | [diff] [blame] | 1290 | eqos_free_descs(eqos->rx_descs); |
| 1291 | eqos_free_descs(eqos->tx_descs); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1292 | |
| 1293 | debug("%s: OK\n", __func__); |
| 1294 | return 0; |
| 1295 | } |
| 1296 | |
| 1297 | static int eqos_probe_resources_tegra186(struct udevice *dev) |
| 1298 | { |
| 1299 | struct eqos_priv *eqos = dev_get_priv(dev); |
| 1300 | int ret; |
| 1301 | |
| 1302 | debug("%s(dev=%p):\n", __func__, dev); |
| 1303 | |
| 1304 | ret = reset_get_by_name(dev, "eqos", &eqos->reset_ctl); |
| 1305 | if (ret) { |
Heinrich Schuchardt | ccb51b4 | 2024-04-02 10:39:34 +0200 | [diff] [blame] | 1306 | pr_err("reset_get_by_name(rst) failed: %d\n", ret); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1307 | return ret; |
| 1308 | } |
| 1309 | |
| 1310 | ret = gpio_request_by_name(dev, "phy-reset-gpios", 0, |
| 1311 | &eqos->phy_reset_gpio, |
| 1312 | GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE); |
| 1313 | if (ret) { |
Heinrich Schuchardt | ccb51b4 | 2024-04-02 10:39:34 +0200 | [diff] [blame] | 1314 | pr_err("gpio_request_by_name(phy reset) failed: %d\n", ret); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1315 | goto err_free_reset_eqos; |
| 1316 | } |
| 1317 | |
| 1318 | ret = clk_get_by_name(dev, "slave_bus", &eqos->clk_slave_bus); |
| 1319 | if (ret) { |
Heinrich Schuchardt | ccb51b4 | 2024-04-02 10:39:34 +0200 | [diff] [blame] | 1320 | pr_err("clk_get_by_name(slave_bus) failed: %d\n", ret); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1321 | goto err_free_gpio_phy_reset; |
| 1322 | } |
| 1323 | |
| 1324 | ret = clk_get_by_name(dev, "master_bus", &eqos->clk_master_bus); |
| 1325 | if (ret) { |
Heinrich Schuchardt | ccb51b4 | 2024-04-02 10:39:34 +0200 | [diff] [blame] | 1326 | pr_err("clk_get_by_name(master_bus) failed: %d\n", ret); |
Sean Anderson | d318eb3 | 2023-12-16 14:38:42 -0500 | [diff] [blame] | 1327 | goto err_free_gpio_phy_reset; |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1328 | } |
| 1329 | |
| 1330 | ret = clk_get_by_name(dev, "rx", &eqos->clk_rx); |
| 1331 | if (ret) { |
Heinrich Schuchardt | ccb51b4 | 2024-04-02 10:39:34 +0200 | [diff] [blame] | 1332 | pr_err("clk_get_by_name(rx) failed: %d\n", ret); |
Sean Anderson | d318eb3 | 2023-12-16 14:38:42 -0500 | [diff] [blame] | 1333 | goto err_free_gpio_phy_reset; |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1334 | } |
| 1335 | |
| 1336 | ret = clk_get_by_name(dev, "ptp_ref", &eqos->clk_ptp_ref); |
| 1337 | if (ret) { |
Heinrich Schuchardt | ccb51b4 | 2024-04-02 10:39:34 +0200 | [diff] [blame] | 1338 | pr_err("clk_get_by_name(ptp_ref) failed: %d\n", ret); |
Sean Anderson | d318eb3 | 2023-12-16 14:38:42 -0500 | [diff] [blame] | 1339 | goto err_free_gpio_phy_reset; |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1340 | } |
| 1341 | |
| 1342 | ret = clk_get_by_name(dev, "tx", &eqos->clk_tx); |
| 1343 | if (ret) { |
Heinrich Schuchardt | ccb51b4 | 2024-04-02 10:39:34 +0200 | [diff] [blame] | 1344 | pr_err("clk_get_by_name(tx) failed: %d\n", ret); |
Sean Anderson | d318eb3 | 2023-12-16 14:38:42 -0500 | [diff] [blame] | 1345 | goto err_free_gpio_phy_reset; |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1346 | } |
| 1347 | |
| 1348 | debug("%s: OK\n", __func__); |
| 1349 | return 0; |
| 1350 | |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1351 | err_free_gpio_phy_reset: |
| 1352 | dm_gpio_free(dev, &eqos->phy_reset_gpio); |
| 1353 | err_free_reset_eqos: |
| 1354 | reset_free(&eqos->reset_ctl); |
| 1355 | |
| 1356 | debug("%s: returns %d\n", __func__, ret); |
| 1357 | return ret; |
| 1358 | } |
| 1359 | |
Marek Behún | bc19477 | 2022-04-07 00:33:01 +0200 | [diff] [blame] | 1360 | static phy_interface_t eqos_get_interface_tegra186(const struct udevice *dev) |
Christophe Roullier | 6beb780 | 2019-05-17 15:08:44 +0200 | [diff] [blame] | 1361 | { |
| 1362 | return PHY_INTERFACE_MODE_MII; |
| 1363 | } |
| 1364 | |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1365 | static int eqos_remove_resources_tegra186(struct udevice *dev) |
| 1366 | { |
| 1367 | struct eqos_priv *eqos = dev_get_priv(dev); |
| 1368 | |
| 1369 | debug("%s(dev=%p):\n", __func__, dev); |
| 1370 | |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1371 | dm_gpio_free(dev, &eqos->phy_reset_gpio); |
| 1372 | reset_free(&eqos->reset_ctl); |
| 1373 | |
| 1374 | debug("%s: OK\n", __func__); |
| 1375 | return 0; |
| 1376 | } |
| 1377 | |
| 1378 | static int eqos_probe(struct udevice *dev) |
| 1379 | { |
| 1380 | struct eqos_priv *eqos = dev_get_priv(dev); |
| 1381 | int ret; |
| 1382 | |
| 1383 | debug("%s(dev=%p):\n", __func__, dev); |
| 1384 | |
| 1385 | eqos->dev = dev; |
| 1386 | eqos->config = (void *)dev_get_driver_data(dev); |
| 1387 | |
Masahiro Yamada | a89b4de | 2020-07-17 14:36:48 +0900 | [diff] [blame] | 1388 | eqos->regs = dev_read_addr(dev); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1389 | if (eqos->regs == FDT_ADDR_T_NONE) { |
Heinrich Schuchardt | ccb51b4 | 2024-04-02 10:39:34 +0200 | [diff] [blame] | 1390 | pr_err("dev_read_addr() failed\n"); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1391 | return -ENODEV; |
| 1392 | } |
| 1393 | eqos->mac_regs = (void *)(eqos->regs + EQOS_MAC_REGS_BASE); |
| 1394 | eqos->mtl_regs = (void *)(eqos->regs + EQOS_MTL_REGS_BASE); |
| 1395 | eqos->dma_regs = (void *)(eqos->regs + EQOS_DMA_REGS_BASE); |
| 1396 | eqos->tegra186_regs = (void *)(eqos->regs + EQOS_TEGRA186_REGS_BASE); |
| 1397 | |
Rasmus Villemoes | 2a9e76d | 2022-05-11 16:58:41 +0200 | [diff] [blame] | 1398 | eqos->max_speed = dev_read_u32_default(dev, "max-speed", 0); |
| 1399 | |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1400 | ret = eqos_probe_resources_core(dev); |
| 1401 | if (ret < 0) { |
Heinrich Schuchardt | ccb51b4 | 2024-04-02 10:39:34 +0200 | [diff] [blame] | 1402 | pr_err("eqos_probe_resources_core() failed: %d\n", ret); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1403 | return ret; |
| 1404 | } |
| 1405 | |
Christophe Roullier | 6beb780 | 2019-05-17 15:08:44 +0200 | [diff] [blame] | 1406 | ret = eqos->config->ops->eqos_probe_resources(dev); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1407 | if (ret < 0) { |
Heinrich Schuchardt | ccb51b4 | 2024-04-02 10:39:34 +0200 | [diff] [blame] | 1408 | pr_err("eqos_probe_resources() failed: %d\n", ret); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1409 | goto err_remove_resources_core; |
| 1410 | } |
| 1411 | |
Marek Vasut | 30b28c4 | 2021-11-13 03:23:52 +0100 | [diff] [blame] | 1412 | ret = eqos->config->ops->eqos_start_clks(dev); |
| 1413 | if (ret < 0) { |
Heinrich Schuchardt | ccb51b4 | 2024-04-02 10:39:34 +0200 | [diff] [blame] | 1414 | pr_err("eqos_start_clks() failed: %d\n", ret); |
Marek Vasut | 30b28c4 | 2021-11-13 03:23:52 +0100 | [diff] [blame] | 1415 | goto err_remove_resources_tegra; |
| 1416 | } |
| 1417 | |
Ye Li | ad122b7 | 2020-05-03 22:41:15 +0800 | [diff] [blame] | 1418 | #ifdef CONFIG_DM_ETH_PHY |
| 1419 | eqos->mii = eth_phy_get_mdio_bus(dev); |
| 1420 | #endif |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1421 | if (!eqos->mii) { |
Ye Li | ad122b7 | 2020-05-03 22:41:15 +0800 | [diff] [blame] | 1422 | eqos->mii = mdio_alloc(); |
| 1423 | if (!eqos->mii) { |
Heinrich Schuchardt | ccb51b4 | 2024-04-02 10:39:34 +0200 | [diff] [blame] | 1424 | pr_err("mdio_alloc() failed\n"); |
Ye Li | ad122b7 | 2020-05-03 22:41:15 +0800 | [diff] [blame] | 1425 | ret = -ENOMEM; |
Marek Vasut | 30b28c4 | 2021-11-13 03:23:52 +0100 | [diff] [blame] | 1426 | goto err_stop_clks; |
Ye Li | ad122b7 | 2020-05-03 22:41:15 +0800 | [diff] [blame] | 1427 | } |
| 1428 | eqos->mii->read = eqos_mdio_read; |
| 1429 | eqos->mii->write = eqos_mdio_write; |
| 1430 | eqos->mii->priv = eqos; |
| 1431 | strcpy(eqos->mii->name, dev->name); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1432 | |
Ye Li | ad122b7 | 2020-05-03 22:41:15 +0800 | [diff] [blame] | 1433 | ret = mdio_register(eqos->mii); |
| 1434 | if (ret < 0) { |
Heinrich Schuchardt | ccb51b4 | 2024-04-02 10:39:34 +0200 | [diff] [blame] | 1435 | pr_err("mdio_register() failed: %d\n", ret); |
Ye Li | ad122b7 | 2020-05-03 22:41:15 +0800 | [diff] [blame] | 1436 | goto err_free_mdio; |
| 1437 | } |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1438 | } |
| 1439 | |
Ye Li | ad122b7 | 2020-05-03 22:41:15 +0800 | [diff] [blame] | 1440 | #ifdef CONFIG_DM_ETH_PHY |
| 1441 | eth_phy_set_mdio_bus(dev, eqos->mii); |
| 1442 | #endif |
| 1443 | |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1444 | debug("%s: OK\n", __func__); |
| 1445 | return 0; |
| 1446 | |
| 1447 | err_free_mdio: |
| 1448 | mdio_free(eqos->mii); |
Marek Vasut | 30b28c4 | 2021-11-13 03:23:52 +0100 | [diff] [blame] | 1449 | err_stop_clks: |
| 1450 | eqos->config->ops->eqos_stop_clks(dev); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1451 | err_remove_resources_tegra: |
Christophe Roullier | 6beb780 | 2019-05-17 15:08:44 +0200 | [diff] [blame] | 1452 | eqos->config->ops->eqos_remove_resources(dev); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1453 | err_remove_resources_core: |
| 1454 | eqos_remove_resources_core(dev); |
| 1455 | |
| 1456 | debug("%s: returns %d\n", __func__, ret); |
| 1457 | return ret; |
| 1458 | } |
| 1459 | |
| 1460 | static int eqos_remove(struct udevice *dev) |
| 1461 | { |
| 1462 | struct eqos_priv *eqos = dev_get_priv(dev); |
| 1463 | |
| 1464 | debug("%s(dev=%p):\n", __func__, dev); |
| 1465 | |
| 1466 | mdio_unregister(eqos->mii); |
| 1467 | mdio_free(eqos->mii); |
Marek Vasut | 30b28c4 | 2021-11-13 03:23:52 +0100 | [diff] [blame] | 1468 | eqos->config->ops->eqos_stop_clks(dev); |
Christophe Roullier | 6beb780 | 2019-05-17 15:08:44 +0200 | [diff] [blame] | 1469 | eqos->config->ops->eqos_remove_resources(dev); |
| 1470 | |
Rasmus Villemoes | 50fe526 | 2022-05-11 16:12:50 +0200 | [diff] [blame] | 1471 | eqos_remove_resources_core(dev); |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1472 | |
| 1473 | debug("%s: OK\n", __func__); |
| 1474 | return 0; |
| 1475 | } |
| 1476 | |
Peng Fan | c0a5995 | 2022-07-26 16:41:14 +0800 | [diff] [blame] | 1477 | int eqos_null_ops(struct udevice *dev) |
Patrick Delaunay | 1bc6ce7 | 2021-07-20 20:09:56 +0200 | [diff] [blame] | 1478 | { |
| 1479 | return 0; |
| 1480 | } |
| 1481 | |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1482 | static const struct eth_ops eqos_ops = { |
| 1483 | .start = eqos_start, |
| 1484 | .stop = eqos_stop, |
| 1485 | .send = eqos_send, |
| 1486 | .recv = eqos_recv, |
| 1487 | .free_pkt = eqos_free_pkt, |
| 1488 | .write_hwaddr = eqos_write_hwaddr, |
Ye Li | 3fb1a0e | 2020-05-03 22:41:20 +0800 | [diff] [blame] | 1489 | .read_rom_hwaddr = eqos_read_rom_hwaddr, |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1490 | }; |
| 1491 | |
Christophe Roullier | 6beb780 | 2019-05-17 15:08:44 +0200 | [diff] [blame] | 1492 | static struct eqos_ops eqos_tegra186_ops = { |
Marek Vasut | 8907773 | 2021-01-07 11:12:16 +0100 | [diff] [blame] | 1493 | .eqos_inval_desc = eqos_inval_desc_generic, |
| 1494 | .eqos_flush_desc = eqos_flush_desc_generic, |
Christophe Roullier | 6beb780 | 2019-05-17 15:08:44 +0200 | [diff] [blame] | 1495 | .eqos_inval_buffer = eqos_inval_buffer_tegra186, |
| 1496 | .eqos_flush_buffer = eqos_flush_buffer_tegra186, |
| 1497 | .eqos_probe_resources = eqos_probe_resources_tegra186, |
| 1498 | .eqos_remove_resources = eqos_remove_resources_tegra186, |
| 1499 | .eqos_stop_resets = eqos_stop_resets_tegra186, |
| 1500 | .eqos_start_resets = eqos_start_resets_tegra186, |
| 1501 | .eqos_stop_clks = eqos_stop_clks_tegra186, |
| 1502 | .eqos_start_clks = eqos_start_clks_tegra186, |
| 1503 | .eqos_calibrate_pads = eqos_calibrate_pads_tegra186, |
| 1504 | .eqos_disable_calibration = eqos_disable_calibration_tegra186, |
| 1505 | .eqos_set_tx_clk_speed = eqos_set_tx_clk_speed_tegra186, |
Patrice Chotard | 088d3ca | 2022-08-02 10:55:25 +0200 | [diff] [blame] | 1506 | .eqos_get_enetaddr = eqos_null_ops, |
Christophe Roullier | 6beb780 | 2019-05-17 15:08:44 +0200 | [diff] [blame] | 1507 | .eqos_get_tick_clk_rate = eqos_get_tick_clk_rate_tegra186 |
| 1508 | }; |
| 1509 | |
Patrick Delaunay | 6808390 | 2020-06-08 11:27:19 +0200 | [diff] [blame] | 1510 | static const struct eqos_config __maybe_unused eqos_tegra186_config = { |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1511 | .reg_access_always_ok = false, |
Christophe Roullier | 6beb780 | 2019-05-17 15:08:44 +0200 | [diff] [blame] | 1512 | .mdio_wait = 10, |
| 1513 | .swr_wait = 10, |
| 1514 | .config_mac = EQOS_MAC_RXQ_CTRL0_RXQ0EN_ENABLED_DCB, |
| 1515 | .config_mac_mdio = EQOS_MAC_MDIO_ADDRESS_CR_20_35, |
Marek Vasut | 8907773 | 2021-01-07 11:12:16 +0100 | [diff] [blame] | 1516 | .axi_bus_width = EQOS_AXI_WIDTH_128, |
Christophe Roullier | 6beb780 | 2019-05-17 15:08:44 +0200 | [diff] [blame] | 1517 | .interface = eqos_get_interface_tegra186, |
| 1518 | .ops = &eqos_tegra186_ops |
| 1519 | }; |
| 1520 | |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1521 | static const struct udevice_id eqos_ids[] = { |
Patrick Delaunay | 6808390 | 2020-06-08 11:27:19 +0200 | [diff] [blame] | 1522 | #if IS_ENABLED(CONFIG_DWC_ETH_QOS_TEGRA186) |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1523 | { |
| 1524 | .compatible = "nvidia,tegra186-eqos", |
| 1525 | .data = (ulong)&eqos_tegra186_config |
| 1526 | }, |
Patrick Delaunay | 6808390 | 2020-06-08 11:27:19 +0200 | [diff] [blame] | 1527 | #endif |
| 1528 | #if IS_ENABLED(CONFIG_DWC_ETH_QOS_STM32) |
Christophe Roullier | 6beb780 | 2019-05-17 15:08:44 +0200 | [diff] [blame] | 1529 | { |
Christophe Roullier | 25a1686 | 2024-03-26 13:07:31 +0100 | [diff] [blame] | 1530 | .compatible = "st,stm32mp13-dwmac", |
| 1531 | .data = (ulong)&eqos_stm32mp13_config |
| 1532 | }, |
| 1533 | { |
Patrick Delaunay | a0466f6 | 2020-05-14 15:00:23 +0200 | [diff] [blame] | 1534 | .compatible = "st,stm32mp1-dwmac", |
Marek Vasut | 944ba37 | 2024-03-26 13:07:23 +0100 | [diff] [blame] | 1535 | .data = (ulong)&eqos_stm32mp15_config |
Christophe Roullier | 6beb780 | 2019-05-17 15:08:44 +0200 | [diff] [blame] | 1536 | }, |
Patrick Delaunay | 6808390 | 2020-06-08 11:27:19 +0200 | [diff] [blame] | 1537 | #endif |
| 1538 | #if IS_ENABLED(CONFIG_DWC_ETH_QOS_IMX) |
Fugang Duan | 37aae5f | 2020-05-03 22:41:17 +0800 | [diff] [blame] | 1539 | { |
Marek Vasut | 7af1138 | 2022-02-26 04:36:37 +0100 | [diff] [blame] | 1540 | .compatible = "nxp,imx8mp-dwmac-eqos", |
Fugang Duan | 37aae5f | 2020-05-03 22:41:17 +0800 | [diff] [blame] | 1541 | .data = (ulong)&eqos_imx_config |
| 1542 | }, |
Sébastien Szymanski | 28b7fc4 | 2023-10-17 11:44:58 +0200 | [diff] [blame] | 1543 | { |
| 1544 | .compatible = "nxp,imx93-dwmac-eqos", |
| 1545 | .data = (ulong)&eqos_imx_config |
| 1546 | }, |
Patrick Delaunay | 6808390 | 2020-06-08 11:27:19 +0200 | [diff] [blame] | 1547 | #endif |
Jonas Karlman | 098ee4f | 2023-10-01 19:17:19 +0000 | [diff] [blame] | 1548 | #if IS_ENABLED(CONFIG_DWC_ETH_QOS_ROCKCHIP) |
| 1549 | { |
| 1550 | .compatible = "rockchip,rk3568-gmac", |
| 1551 | .data = (ulong)&eqos_rockchip_config |
| 1552 | }, |
Jonas Karlman | 1b61570 | 2023-10-01 19:17:20 +0000 | [diff] [blame] | 1553 | { |
| 1554 | .compatible = "rockchip,rk3588-gmac", |
| 1555 | .data = (ulong)&eqos_rockchip_config |
| 1556 | }, |
Jonas Karlman | 098ee4f | 2023-10-01 19:17:19 +0000 | [diff] [blame] | 1557 | #endif |
Sumit Garg | 7c3be94 | 2023-02-01 19:28:55 +0530 | [diff] [blame] | 1558 | #if IS_ENABLED(CONFIG_DWC_ETH_QOS_QCOM) |
| 1559 | { |
| 1560 | .compatible = "qcom,qcs404-ethqos", |
| 1561 | .data = (ulong)&eqos_qcom_config |
| 1562 | }, |
| 1563 | #endif |
Yanhong Wang | 1f502ee | 2023-06-15 17:36:43 +0800 | [diff] [blame] | 1564 | #if IS_ENABLED(CONFIG_DWC_ETH_QOS_STARFIVE) |
| 1565 | { |
| 1566 | .compatible = "starfive,jh7110-dwmac", |
| 1567 | .data = (ulong)&eqos_jh7110_config |
| 1568 | }, |
| 1569 | #endif |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1570 | { } |
| 1571 | }; |
| 1572 | |
| 1573 | U_BOOT_DRIVER(eth_eqos) = { |
| 1574 | .name = "eth_eqos", |
| 1575 | .id = UCLASS_ETH, |
Fugang Duan | 37aae5f | 2020-05-03 22:41:17 +0800 | [diff] [blame] | 1576 | .of_match = of_match_ptr(eqos_ids), |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1577 | .probe = eqos_probe, |
| 1578 | .remove = eqos_remove, |
| 1579 | .ops = &eqos_ops, |
Simon Glass | 8a2b47f | 2020-12-03 16:55:17 -0700 | [diff] [blame] | 1580 | .priv_auto = sizeof(struct eqos_priv), |
Simon Glass | 71fa5b4 | 2020-12-03 16:55:18 -0700 | [diff] [blame] | 1581 | .plat_auto = sizeof(struct eth_pdata), |
Stephen Warren | 5070960 | 2016-10-21 14:46:47 -0600 | [diff] [blame] | 1582 | }; |