Marek Vasut | 426ca62 | 2024-03-26 13:07:22 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | /* |
| 3 | * Copyright (C) 2024, Marek Vasut <marex@denx.de> |
| 4 | * |
| 5 | * This is code moved from drivers/net/dwc_eth_qos.c , which is: |
| 6 | * Copyright (c) 2016, NVIDIA CORPORATION. |
| 7 | */ |
| 8 | |
| 9 | #include <common.h> |
| 10 | #include <asm/cache.h> |
| 11 | #include <asm/gpio.h> |
| 12 | #include <asm/io.h> |
| 13 | #include <clk.h> |
| 14 | #include <cpu_func.h> |
| 15 | #include <dm.h> |
| 16 | #include <dm/device_compat.h> |
| 17 | #include <errno.h> |
| 18 | #include <eth_phy.h> |
| 19 | #include <log.h> |
| 20 | #include <malloc.h> |
| 21 | #include <memalign.h> |
| 22 | #include <miiphy.h> |
| 23 | #include <net.h> |
| 24 | #include <netdev.h> |
| 25 | #include <phy.h> |
Christophe Roullier | 033dc76 | 2024-03-26 13:07:30 +0100 | [diff] [blame] | 26 | #include <regmap.h> |
Marek Vasut | 426ca62 | 2024-03-26 13:07:22 +0100 | [diff] [blame] | 27 | #include <reset.h> |
Marek Vasut | 7595bfc | 2024-03-26 13:07:24 +0100 | [diff] [blame] | 28 | #include <syscon.h> |
Marek Vasut | 426ca62 | 2024-03-26 13:07:22 +0100 | [diff] [blame] | 29 | #include <wait_bit.h> |
Marek Vasut | 577f46b | 2024-03-26 13:07:26 +0100 | [diff] [blame] | 30 | #include <linux/bitfield.h> |
Marek Vasut | 426ca62 | 2024-03-26 13:07:22 +0100 | [diff] [blame] | 31 | #include <linux/delay.h> |
| 32 | |
| 33 | #include "dwc_eth_qos.h" |
| 34 | |
Marek Vasut | 7595bfc | 2024-03-26 13:07:24 +0100 | [diff] [blame] | 35 | /* SYSCFG registers */ |
| 36 | #define SYSCFG_PMCSETR 0x04 |
Christophe Roullier | 033dc76 | 2024-03-26 13:07:30 +0100 | [diff] [blame] | 37 | #define SYSCFG_PMCCLRR_MP13 0x08 |
| 38 | #define SYSCFG_PMCCLRR_MP15 0x44 |
| 39 | |
| 40 | #define SYSCFG_PMCSETR_ETH1_MASK GENMASK(23, 16) |
| 41 | #define SYSCFG_PMCSETR_ETH2_MASK GENMASK(31, 24) |
Marek Vasut | 7595bfc | 2024-03-26 13:07:24 +0100 | [diff] [blame] | 42 | |
| 43 | #define SYSCFG_PMCSETR_ETH_CLK_SEL BIT(16) |
| 44 | #define SYSCFG_PMCSETR_ETH_REF_CLK_SEL BIT(17) |
| 45 | |
Christophe Roullier | 033dc76 | 2024-03-26 13:07:30 +0100 | [diff] [blame] | 46 | /* STM32MP15xx specific bit */ |
Marek Vasut | 7595bfc | 2024-03-26 13:07:24 +0100 | [diff] [blame] | 47 | #define SYSCFG_PMCSETR_ETH_SELMII BIT(20) |
| 48 | |
| 49 | #define SYSCFG_PMCSETR_ETH_SEL_MASK GENMASK(23, 21) |
Marek Vasut | 577f46b | 2024-03-26 13:07:26 +0100 | [diff] [blame] | 50 | #define SYSCFG_PMCSETR_ETH_SEL_GMII_MII 0x0 |
| 51 | #define SYSCFG_PMCSETR_ETH_SEL_RGMII 0x1 |
| 52 | #define SYSCFG_PMCSETR_ETH_SEL_RMII 0x4 |
Marek Vasut | 7595bfc | 2024-03-26 13:07:24 +0100 | [diff] [blame] | 53 | |
Marek Vasut | 426ca62 | 2024-03-26 13:07:22 +0100 | [diff] [blame] | 54 | static ulong eqos_get_tick_clk_rate_stm32(struct udevice *dev) |
| 55 | { |
Marek Vasut | b14101c | 2024-03-26 13:07:25 +0100 | [diff] [blame] | 56 | struct eqos_priv __maybe_unused *eqos = dev_get_priv(dev); |
| 57 | |
| 58 | if (!CONFIG_IS_ENABLED(CLK)) |
| 59 | return 0; |
Marek Vasut | 426ca62 | 2024-03-26 13:07:22 +0100 | [diff] [blame] | 60 | |
| 61 | return clk_get_rate(&eqos->clk_master_bus); |
Marek Vasut | 426ca62 | 2024-03-26 13:07:22 +0100 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | static int eqos_start_clks_stm32(struct udevice *dev) |
| 65 | { |
Marek Vasut | b14101c | 2024-03-26 13:07:25 +0100 | [diff] [blame] | 66 | struct eqos_priv __maybe_unused *eqos = dev_get_priv(dev); |
Marek Vasut | 426ca62 | 2024-03-26 13:07:22 +0100 | [diff] [blame] | 67 | int ret; |
| 68 | |
Marek Vasut | b14101c | 2024-03-26 13:07:25 +0100 | [diff] [blame] | 69 | if (!CONFIG_IS_ENABLED(CLK)) |
| 70 | return 0; |
| 71 | |
Marek Vasut | 5a1640e | 2024-03-26 13:07:28 +0100 | [diff] [blame] | 72 | dev_dbg(dev, "%s:\n", __func__); |
Marek Vasut | 426ca62 | 2024-03-26 13:07:22 +0100 | [diff] [blame] | 73 | |
| 74 | ret = clk_enable(&eqos->clk_master_bus); |
| 75 | if (ret < 0) { |
Marek Vasut | 5a1640e | 2024-03-26 13:07:28 +0100 | [diff] [blame] | 76 | dev_err(dev, "clk_enable(clk_master_bus) failed: %d\n", ret); |
Marek Vasut | 426ca62 | 2024-03-26 13:07:22 +0100 | [diff] [blame] | 77 | goto err; |
| 78 | } |
| 79 | |
| 80 | ret = clk_enable(&eqos->clk_rx); |
| 81 | if (ret < 0) { |
Marek Vasut | 5a1640e | 2024-03-26 13:07:28 +0100 | [diff] [blame] | 82 | dev_err(dev, "clk_enable(clk_rx) failed: %d\n", ret); |
Marek Vasut | 426ca62 | 2024-03-26 13:07:22 +0100 | [diff] [blame] | 83 | goto err_disable_clk_master_bus; |
| 84 | } |
| 85 | |
| 86 | ret = clk_enable(&eqos->clk_tx); |
| 87 | if (ret < 0) { |
Marek Vasut | 5a1640e | 2024-03-26 13:07:28 +0100 | [diff] [blame] | 88 | dev_err(dev, "clk_enable(clk_tx) failed: %d\n", ret); |
Marek Vasut | 426ca62 | 2024-03-26 13:07:22 +0100 | [diff] [blame] | 89 | goto err_disable_clk_rx; |
| 90 | } |
| 91 | |
| 92 | if (clk_valid(&eqos->clk_ck) && !eqos->clk_ck_enabled) { |
| 93 | ret = clk_enable(&eqos->clk_ck); |
| 94 | if (ret < 0) { |
Marek Vasut | 5a1640e | 2024-03-26 13:07:28 +0100 | [diff] [blame] | 95 | dev_err(dev, "clk_enable(clk_ck) failed: %d\n", ret); |
Marek Vasut | 426ca62 | 2024-03-26 13:07:22 +0100 | [diff] [blame] | 96 | goto err_disable_clk_tx; |
| 97 | } |
| 98 | eqos->clk_ck_enabled = true; |
| 99 | } |
Marek Vasut | 426ca62 | 2024-03-26 13:07:22 +0100 | [diff] [blame] | 100 | |
Marek Vasut | 5a1640e | 2024-03-26 13:07:28 +0100 | [diff] [blame] | 101 | dev_dbg(dev, "%s: OK\n", __func__); |
Marek Vasut | 426ca62 | 2024-03-26 13:07:22 +0100 | [diff] [blame] | 102 | return 0; |
| 103 | |
Marek Vasut | 426ca62 | 2024-03-26 13:07:22 +0100 | [diff] [blame] | 104 | err_disable_clk_tx: |
| 105 | clk_disable(&eqos->clk_tx); |
| 106 | err_disable_clk_rx: |
| 107 | clk_disable(&eqos->clk_rx); |
| 108 | err_disable_clk_master_bus: |
| 109 | clk_disable(&eqos->clk_master_bus); |
| 110 | err: |
Marek Vasut | 5a1640e | 2024-03-26 13:07:28 +0100 | [diff] [blame] | 111 | dev_dbg(dev, "%s: FAILED: %d\n", __func__, ret); |
| 112 | |
Marek Vasut | 426ca62 | 2024-03-26 13:07:22 +0100 | [diff] [blame] | 113 | return ret; |
Marek Vasut | 426ca62 | 2024-03-26 13:07:22 +0100 | [diff] [blame] | 114 | } |
| 115 | |
| 116 | static int eqos_stop_clks_stm32(struct udevice *dev) |
| 117 | { |
Marek Vasut | b14101c | 2024-03-26 13:07:25 +0100 | [diff] [blame] | 118 | struct eqos_priv __maybe_unused *eqos = dev_get_priv(dev); |
| 119 | |
| 120 | if (!CONFIG_IS_ENABLED(CLK)) |
| 121 | return 0; |
Marek Vasut | 426ca62 | 2024-03-26 13:07:22 +0100 | [diff] [blame] | 122 | |
Marek Vasut | 5a1640e | 2024-03-26 13:07:28 +0100 | [diff] [blame] | 123 | dev_dbg(dev, "%s:\n", __func__); |
Marek Vasut | 426ca62 | 2024-03-26 13:07:22 +0100 | [diff] [blame] | 124 | |
| 125 | clk_disable(&eqos->clk_tx); |
| 126 | clk_disable(&eqos->clk_rx); |
| 127 | clk_disable(&eqos->clk_master_bus); |
Marek Vasut | 426ca62 | 2024-03-26 13:07:22 +0100 | [diff] [blame] | 128 | |
Marek Vasut | 5a1640e | 2024-03-26 13:07:28 +0100 | [diff] [blame] | 129 | dev_dbg(dev, "%s: OK\n", __func__); |
| 130 | |
Marek Vasut | 426ca62 | 2024-03-26 13:07:22 +0100 | [diff] [blame] | 131 | return 0; |
| 132 | } |
| 133 | |
Marek Vasut | 7595bfc | 2024-03-26 13:07:24 +0100 | [diff] [blame] | 134 | static int eqos_probe_syscfg_stm32(struct udevice *dev, |
| 135 | phy_interface_t interface_type) |
| 136 | { |
Marek Vasut | e77fa87 | 2024-03-26 13:07:29 +0100 | [diff] [blame] | 137 | /* Ethernet 50MHz RMII clock selection. */ |
| 138 | const bool eth_ref_clk_sel = dev_read_bool(dev, "st,eth-ref-clk-sel"); |
Christophe Roullier | 033dc76 | 2024-03-26 13:07:30 +0100 | [diff] [blame] | 139 | /* SoC is STM32MP13xx with two ethernet MACs */ |
| 140 | const bool is_mp13 = device_is_compatible(dev, "st,stm32mp13-dwmac"); |
Marek Vasut | e77fa87 | 2024-03-26 13:07:29 +0100 | [diff] [blame] | 141 | /* Gigabit Ethernet 125MHz clock selection. */ |
| 142 | const bool eth_clk_sel = dev_read_bool(dev, "st,eth-clk-sel"); |
Marek Vasut | 6c4b245 | 2024-03-26 13:07:32 +0100 | [diff] [blame^] | 143 | /* Ethernet clock source is RCC. */ |
| 144 | const bool ext_phyclk = dev_read_bool(dev, "st,ext-phyclk"); |
Christophe Roullier | 033dc76 | 2024-03-26 13:07:30 +0100 | [diff] [blame] | 145 | struct regmap *regmap; |
| 146 | u32 regmap_mask; |
Marek Vasut | 7595bfc | 2024-03-26 13:07:24 +0100 | [diff] [blame] | 147 | u32 value; |
| 148 | |
Christophe Roullier | 033dc76 | 2024-03-26 13:07:30 +0100 | [diff] [blame] | 149 | regmap = syscon_regmap_lookup_by_phandle(dev, "st,syscon"); |
| 150 | if (IS_ERR(regmap)) |
| 151 | return PTR_ERR(regmap); |
| 152 | |
| 153 | regmap_mask = dev_read_u32_index_default(dev, "st,syscon", 2, |
| 154 | SYSCFG_PMCSETR_ETH1_MASK); |
Marek Vasut | 7595bfc | 2024-03-26 13:07:24 +0100 | [diff] [blame] | 155 | |
| 156 | switch (interface_type) { |
| 157 | case PHY_INTERFACE_MODE_MII: |
Marek Vasut | 5a1640e | 2024-03-26 13:07:28 +0100 | [diff] [blame] | 158 | dev_dbg(dev, "PHY_INTERFACE_MODE_MII\n"); |
Marek Vasut | 577f46b | 2024-03-26 13:07:26 +0100 | [diff] [blame] | 159 | value = FIELD_PREP(SYSCFG_PMCSETR_ETH_SEL_MASK, |
| 160 | SYSCFG_PMCSETR_ETH_SEL_GMII_MII); |
Marek Vasut | 6c4b245 | 2024-03-26 13:07:32 +0100 | [diff] [blame^] | 161 | /* |
| 162 | * STM32MP15xx supports both MII and GMII, STM32MP13xx MII only. |
| 163 | * SYSCFG_PMCSETR ETH_SELMII is present only on STM32MP15xx and |
| 164 | * acts as a selector between 0:GMII and 1:MII. As STM32MP13xx |
| 165 | * supports only MII, ETH_SELMII is not present. |
| 166 | */ |
Christophe Roullier | 033dc76 | 2024-03-26 13:07:30 +0100 | [diff] [blame] | 167 | if (!is_mp13) /* Select MII mode on STM32MP15xx */ |
| 168 | value |= SYSCFG_PMCSETR_ETH_SELMII; |
Marek Vasut | 7595bfc | 2024-03-26 13:07:24 +0100 | [diff] [blame] | 169 | break; |
Christophe Roullier | 033dc76 | 2024-03-26 13:07:30 +0100 | [diff] [blame] | 170 | case PHY_INTERFACE_MODE_GMII: /* STM32MP15xx only */ |
Marek Vasut | 5a1640e | 2024-03-26 13:07:28 +0100 | [diff] [blame] | 171 | dev_dbg(dev, "PHY_INTERFACE_MODE_GMII\n"); |
Marek Vasut | 577f46b | 2024-03-26 13:07:26 +0100 | [diff] [blame] | 172 | value = FIELD_PREP(SYSCFG_PMCSETR_ETH_SEL_MASK, |
| 173 | SYSCFG_PMCSETR_ETH_SEL_GMII_MII); |
Marek Vasut | 6c4b245 | 2024-03-26 13:07:32 +0100 | [diff] [blame^] | 174 | /* |
| 175 | * If eth_clk_sel is set, use internal ETH_CLKx clock from RCC, |
| 176 | * otherwise use external clock from IO pin (requires matching |
| 177 | * GPIO block AF setting of that pin). |
| 178 | */ |
| 179 | if (eth_clk_sel || ext_phyclk) |
Marek Vasut | 577f46b | 2024-03-26 13:07:26 +0100 | [diff] [blame] | 180 | value |= SYSCFG_PMCSETR_ETH_CLK_SEL; |
Marek Vasut | 7595bfc | 2024-03-26 13:07:24 +0100 | [diff] [blame] | 181 | break; |
| 182 | case PHY_INTERFACE_MODE_RMII: |
Marek Vasut | 5a1640e | 2024-03-26 13:07:28 +0100 | [diff] [blame] | 183 | dev_dbg(dev, "PHY_INTERFACE_MODE_RMII\n"); |
Marek Vasut | 577f46b | 2024-03-26 13:07:26 +0100 | [diff] [blame] | 184 | value = FIELD_PREP(SYSCFG_PMCSETR_ETH_SEL_MASK, |
| 185 | SYSCFG_PMCSETR_ETH_SEL_RMII); |
Marek Vasut | 6c4b245 | 2024-03-26 13:07:32 +0100 | [diff] [blame^] | 186 | /* |
| 187 | * If eth_ref_clk_sel is set, use internal clock from RCC, |
| 188 | * otherwise use external clock from ETHn_RX_CLK/ETHn_REF_CLK |
| 189 | * IO pin (requires matching GPIO block AF setting of that |
| 190 | * pin). |
| 191 | */ |
| 192 | if (eth_ref_clk_sel || ext_phyclk) |
Marek Vasut | 577f46b | 2024-03-26 13:07:26 +0100 | [diff] [blame] | 193 | value |= SYSCFG_PMCSETR_ETH_REF_CLK_SEL; |
Marek Vasut | 7595bfc | 2024-03-26 13:07:24 +0100 | [diff] [blame] | 194 | break; |
| 195 | case PHY_INTERFACE_MODE_RGMII: |
| 196 | case PHY_INTERFACE_MODE_RGMII_ID: |
| 197 | case PHY_INTERFACE_MODE_RGMII_RXID: |
| 198 | case PHY_INTERFACE_MODE_RGMII_TXID: |
Marek Vasut | 5a1640e | 2024-03-26 13:07:28 +0100 | [diff] [blame] | 199 | dev_dbg(dev, "PHY_INTERFACE_MODE_RGMII\n"); |
Marek Vasut | 577f46b | 2024-03-26 13:07:26 +0100 | [diff] [blame] | 200 | value = FIELD_PREP(SYSCFG_PMCSETR_ETH_SEL_MASK, |
| 201 | SYSCFG_PMCSETR_ETH_SEL_RGMII); |
Marek Vasut | 6c4b245 | 2024-03-26 13:07:32 +0100 | [diff] [blame^] | 202 | /* |
| 203 | * If eth_clk_sel is set, use internal ETH_CLKx clock from RCC, |
| 204 | * otherwise use external clock from ETHx_CLK125 pin (requires |
| 205 | * matching GPIO block AF setting of that pin). |
| 206 | */ |
| 207 | if (eth_clk_sel || ext_phyclk) |
Marek Vasut | 577f46b | 2024-03-26 13:07:26 +0100 | [diff] [blame] | 208 | value |= SYSCFG_PMCSETR_ETH_CLK_SEL; |
Marek Vasut | 7595bfc | 2024-03-26 13:07:24 +0100 | [diff] [blame] | 209 | break; |
| 210 | default: |
Marek Vasut | 5a1640e | 2024-03-26 13:07:28 +0100 | [diff] [blame] | 211 | dev_dbg(dev, "Do not manage %d interface\n", |
| 212 | interface_type); |
Marek Vasut | 7595bfc | 2024-03-26 13:07:24 +0100 | [diff] [blame] | 213 | /* Do not manage others interfaces */ |
| 214 | return -EINVAL; |
| 215 | } |
| 216 | |
Christophe Roullier | 033dc76 | 2024-03-26 13:07:30 +0100 | [diff] [blame] | 217 | /* Shift value at correct ethernet MAC offset in SYSCFG_PMCSETR */ |
| 218 | value <<= ffs(regmap_mask) - ffs(SYSCFG_PMCSETR_ETH1_MASK); |
Marek Vasut | 7595bfc | 2024-03-26 13:07:24 +0100 | [diff] [blame] | 219 | |
Christophe Roullier | 033dc76 | 2024-03-26 13:07:30 +0100 | [diff] [blame] | 220 | /* Update PMCCLRR (clear register) */ |
| 221 | regmap_write(regmap, is_mp13 ? |
| 222 | SYSCFG_PMCCLRR_MP13 : SYSCFG_PMCCLRR_MP15, |
| 223 | regmap_mask); |
| 224 | |
| 225 | return regmap_update_bits(regmap, SYSCFG_PMCSETR, regmap_mask, value); |
Marek Vasut | 7595bfc | 2024-03-26 13:07:24 +0100 | [diff] [blame] | 226 | } |
| 227 | |
Marek Vasut | 426ca62 | 2024-03-26 13:07:22 +0100 | [diff] [blame] | 228 | static int eqos_probe_resources_stm32(struct udevice *dev) |
| 229 | { |
| 230 | struct eqos_priv *eqos = dev_get_priv(dev); |
Marek Vasut | 426ca62 | 2024-03-26 13:07:22 +0100 | [diff] [blame] | 231 | phy_interface_t interface; |
Marek Vasut | 7595bfc | 2024-03-26 13:07:24 +0100 | [diff] [blame] | 232 | int ret; |
Marek Vasut | 426ca62 | 2024-03-26 13:07:22 +0100 | [diff] [blame] | 233 | |
Marek Vasut | 5a1640e | 2024-03-26 13:07:28 +0100 | [diff] [blame] | 234 | dev_dbg(dev, "%s:\n", __func__); |
Marek Vasut | 426ca62 | 2024-03-26 13:07:22 +0100 | [diff] [blame] | 235 | |
| 236 | interface = eqos->config->interface(dev); |
| 237 | |
| 238 | if (interface == PHY_INTERFACE_MODE_NA) { |
Marek Vasut | 5a1640e | 2024-03-26 13:07:28 +0100 | [diff] [blame] | 239 | dev_err(dev, "Invalid PHY interface\n"); |
Marek Vasut | 426ca62 | 2024-03-26 13:07:22 +0100 | [diff] [blame] | 240 | return -EINVAL; |
| 241 | } |
| 242 | |
Marek Vasut | 7595bfc | 2024-03-26 13:07:24 +0100 | [diff] [blame] | 243 | ret = eqos_probe_syscfg_stm32(dev, interface); |
Marek Vasut | 426ca62 | 2024-03-26 13:07:22 +0100 | [diff] [blame] | 244 | if (ret) |
| 245 | return -EINVAL; |
| 246 | |
| 247 | ret = clk_get_by_name(dev, "stmmaceth", &eqos->clk_master_bus); |
| 248 | if (ret) { |
Marek Vasut | 5a1640e | 2024-03-26 13:07:28 +0100 | [diff] [blame] | 249 | dev_err(dev, "clk_get_by_name(master_bus) failed: %d\n", ret); |
Marek Vasut | 426ca62 | 2024-03-26 13:07:22 +0100 | [diff] [blame] | 250 | goto err_probe; |
| 251 | } |
| 252 | |
| 253 | ret = clk_get_by_name(dev, "mac-clk-rx", &eqos->clk_rx); |
| 254 | if (ret) { |
Marek Vasut | 5a1640e | 2024-03-26 13:07:28 +0100 | [diff] [blame] | 255 | dev_err(dev, "clk_get_by_name(rx) failed: %d\n", ret); |
Marek Vasut | 426ca62 | 2024-03-26 13:07:22 +0100 | [diff] [blame] | 256 | goto err_probe; |
| 257 | } |
| 258 | |
| 259 | ret = clk_get_by_name(dev, "mac-clk-tx", &eqos->clk_tx); |
| 260 | if (ret) { |
Marek Vasut | 5a1640e | 2024-03-26 13:07:28 +0100 | [diff] [blame] | 261 | dev_err(dev, "clk_get_by_name(tx) failed: %d\n", ret); |
Marek Vasut | 426ca62 | 2024-03-26 13:07:22 +0100 | [diff] [blame] | 262 | goto err_probe; |
| 263 | } |
| 264 | |
| 265 | /* Get ETH_CLK clocks (optional) */ |
| 266 | ret = clk_get_by_name(dev, "eth-ck", &eqos->clk_ck); |
| 267 | if (ret) |
Marek Vasut | 5a1640e | 2024-03-26 13:07:28 +0100 | [diff] [blame] | 268 | dev_warn(dev, "No phy clock provided %d\n", ret); |
Marek Vasut | 426ca62 | 2024-03-26 13:07:22 +0100 | [diff] [blame] | 269 | |
Marek Vasut | 5a1640e | 2024-03-26 13:07:28 +0100 | [diff] [blame] | 270 | dev_dbg(dev, "%s: OK\n", __func__); |
| 271 | |
Marek Vasut | 426ca62 | 2024-03-26 13:07:22 +0100 | [diff] [blame] | 272 | return 0; |
| 273 | |
| 274 | err_probe: |
| 275 | |
Marek Vasut | 5a1640e | 2024-03-26 13:07:28 +0100 | [diff] [blame] | 276 | dev_dbg(dev, "%s: returns %d\n", __func__, ret); |
| 277 | |
Marek Vasut | 426ca62 | 2024-03-26 13:07:22 +0100 | [diff] [blame] | 278 | return ret; |
| 279 | } |
| 280 | |
| 281 | static int eqos_remove_resources_stm32(struct udevice *dev) |
| 282 | { |
Marek Vasut | 5a1640e | 2024-03-26 13:07:28 +0100 | [diff] [blame] | 283 | dev_dbg(dev, "%s:\n", __func__); |
Marek Vasut | 426ca62 | 2024-03-26 13:07:22 +0100 | [diff] [blame] | 284 | |
| 285 | return 0; |
| 286 | } |
| 287 | |
| 288 | static struct eqos_ops eqos_stm32_ops = { |
| 289 | .eqos_inval_desc = eqos_inval_desc_generic, |
| 290 | .eqos_flush_desc = eqos_flush_desc_generic, |
| 291 | .eqos_inval_buffer = eqos_inval_buffer_generic, |
| 292 | .eqos_flush_buffer = eqos_flush_buffer_generic, |
| 293 | .eqos_probe_resources = eqos_probe_resources_stm32, |
| 294 | .eqos_remove_resources = eqos_remove_resources_stm32, |
| 295 | .eqos_stop_resets = eqos_null_ops, |
| 296 | .eqos_start_resets = eqos_null_ops, |
| 297 | .eqos_stop_clks = eqos_stop_clks_stm32, |
| 298 | .eqos_start_clks = eqos_start_clks_stm32, |
| 299 | .eqos_calibrate_pads = eqos_null_ops, |
| 300 | .eqos_disable_calibration = eqos_null_ops, |
| 301 | .eqos_set_tx_clk_speed = eqos_null_ops, |
| 302 | .eqos_get_enetaddr = eqos_null_ops, |
| 303 | .eqos_get_tick_clk_rate = eqos_get_tick_clk_rate_stm32 |
| 304 | }; |
| 305 | |
Christophe Roullier | 25a1686 | 2024-03-26 13:07:31 +0100 | [diff] [blame] | 306 | struct eqos_config __maybe_unused eqos_stm32mp13_config = { |
| 307 | .reg_access_always_ok = false, |
| 308 | .mdio_wait = 10000, |
| 309 | .swr_wait = 50, |
| 310 | .config_mac = EQOS_MAC_RXQ_CTRL0_RXQ0EN_ENABLED_DCB, |
| 311 | .config_mac_mdio = EQOS_MAC_MDIO_ADDRESS_CR_250_300, |
| 312 | .axi_bus_width = EQOS_AXI_WIDTH_32, |
| 313 | .interface = dev_read_phy_mode, |
| 314 | .ops = &eqos_stm32_ops |
| 315 | }; |
| 316 | |
Marek Vasut | 944ba37 | 2024-03-26 13:07:23 +0100 | [diff] [blame] | 317 | struct eqos_config __maybe_unused eqos_stm32mp15_config = { |
Marek Vasut | 426ca62 | 2024-03-26 13:07:22 +0100 | [diff] [blame] | 318 | .reg_access_always_ok = false, |
| 319 | .mdio_wait = 10000, |
| 320 | .swr_wait = 50, |
| 321 | .config_mac = EQOS_MAC_RXQ_CTRL0_RXQ0EN_ENABLED_AV, |
| 322 | .config_mac_mdio = EQOS_MAC_MDIO_ADDRESS_CR_250_300, |
| 323 | .axi_bus_width = EQOS_AXI_WIDTH_64, |
| 324 | .interface = dev_read_phy_mode, |
| 325 | .ops = &eqos_stm32_ops |
| 326 | }; |