Message ID | 20210729201100.3994-4-linux.amoon@gmail.com (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | Add Reset controller to Ethernet PHY | expand |
Context | Check | Description |
---|---|---|
netdev/cover_letter | success | Link |
netdev/fixes_present | success | Link |
netdev/patch_count | success | Link |
netdev/tree_selection | success | Guessed tree name to be net-next |
netdev/subject_prefix | success | Link |
netdev/cc_maintainers | success | CCed 15 of 15 maintainers |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Link |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | success | Errors and warnings before: 0 this patch: 0 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | Link |
netdev/checkpatch | warning | WARNING: line length of 84 exceeds 80 columns |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 0 this patch: 0 |
netdev/header_inline | success | Link |
> @@ -465,6 +478,13 @@ static int meson8b_dwmac_probe(struct platform_device *pdev) > goto err_remove_config_dt; > } > > + dwmac->eth_reset = devm_reset_control_get_exclusive(dwmac->dev, "ethreset"); > + if (IS_ERR_OR_NULL(dwmac->eth_reset)) { > + dev_err(dwmac->dev, "Failed to get Ethernet reset\n"); > + ret = PTR_ERR(dwmac->eth_reset); > + goto err_remove_config_dt; > + } > + Hi Anand Since this is a new property, you need to handle it not being in the DT blob. You probably need to use devm_reset_control_get_optinal_exclusive() Andrew
Hi Anand, On Thu, Jul 29, 2021 at 10:11 PM Anand Moon <linux.amoon@gmail.com> wrote: > > Add reset controller for Ethernet phy reset on every boot for > Amlogic SoC. I think this description does not match what's going on inside the SoC: - for all SoCs earlier than GXL the PHY is external so the reset for the PHY is a GPIO - the reset line you are passing in the .dts belongs to the Ethernet controller on SoCs earlier than GXL - I *believe* that the rset line which you're passing in the .dts belongs to the Ethernet controller AND the built-in MDIO mux on GXL and newer, see also [0] - from how the PRG_ETH registers work I doubt that these are connected to a reset line (as they're managing mostly delays and protocol - so I don't see what would be reset). This is speculation though. Best regards, Martin [0] https://lore.kernel.org/linux-amlogic/553e127c-9839-d15b-d435-c01f18c7be48@gmail.com/
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c index c7a6588d9398..8b3b5e8c2a8a 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c @@ -17,6 +17,7 @@ #include <linux/of_net.h> #include <linux/mfd/syscon.h> #include <linux/platform_device.h> +#include <linux/reset.h> #include <linux/stmmac.h> #include "stmmac_platform.h" @@ -95,6 +96,7 @@ struct meson8b_dwmac { u32 tx_delay_ns; u32 rx_delay_ps; struct clk *timing_adj_clk; + struct reset_control *eth_reset; }; struct meson8b_dwmac_clk_configs { @@ -384,6 +386,17 @@ static int meson8b_init_prg_eth(struct meson8b_dwmac *dwmac) meson8b_dwmac_mask_bits(dwmac, PRG_ETH0, PRG_ETH0_TX_AND_PHY_REF_CLK, PRG_ETH0_TX_AND_PHY_REF_CLK); + /* Make sure the Ethernet PHY is properly reseted, as U-Boot may leave + * it at deasserted state, and thus it may fail to reset EMAC. + * + * This assumes the driver has exclusive access to the EPHY reset. + */ + ret = reset_control_reset(dwmac->eth_reset); + if (ret) { + dev_err(dwmac->dev, "Cannot reset internal PHY\n"); + return ret; + } + return 0; } @@ -465,6 +478,13 @@ static int meson8b_dwmac_probe(struct platform_device *pdev) goto err_remove_config_dt; } + dwmac->eth_reset = devm_reset_control_get_exclusive(dwmac->dev, "ethreset"); + if (IS_ERR_OR_NULL(dwmac->eth_reset)) { + dev_err(dwmac->dev, "Failed to get Ethernet reset\n"); + ret = PTR_ERR(dwmac->eth_reset); + goto err_remove_config_dt; + } + ret = meson8b_init_rgmii_delays(dwmac); if (ret) goto err_remove_config_dt;
Add reset controller for Ethernet phy reset on every boot for Amlogic SoC. Cc: Jerome Brunet <jbrunet@baylibre.com> Cc: Neil Armstrong <narmstrong@baylibre.com> Cc: Martin Blumenstingl <martin.blumenstingl@googlemail.com> Signed-off-by: Anand Moon <linux.amoon@gmail.com> --- .../ethernet/stmicro/stmmac/dwmac-meson8b.c | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+)