arm64: qcom: sa8775p-ride: enable the first ethernet port
Subsystems (9)
cover arm64: qcom: sa8775p-ride: enable the first ethernet port
From: Bartosz Golaszewski <[email protected]>
There are three ethernet ports on sa8775p-ride. This series contains changes required to enable one of the two 1Gb ports (the third one is 10Gb). We need to add a new driver for the internal SerDes PHY, introduce several extensions to the MAC driver (while at it: tweak coding style a bit etc.) and finally add the relevant DT nodes.
Bartosz Golaszewski (26):
phy: qualcomm: fix indentation in Makefile
dt-bindings: phy: describe the Qualcomm SGMII PHY
phy: qcom: add the SGMII SerDes PHY driver
arm64: defconfig: enable the SerDes PHY for Qualcomm DWMAC
net: stmmac: dwmac-qcom-ethqos: shrink clock code with devres
net: stmmac: dwmac-qcom-ethqos: rename a label in probe()
net: stmmac: dwmac-qcom-ethqos: tweak the order of local variables
net: stmmac: dwmac-qcom-ethqos: use a helper variable for &pdev->dev
net: stmmac: dwmac-qcom-ethqos: add missing include
net: stmmac: dwmac-qcom-ethqos: add a newline between headers
net: stmmac: dwmac-qcom-ethqos: remove stray space
net: stmmac: dwmac-qcom-ethqos: add support for the optional serdes
phy
net: stmmac: dwmac-qcom-ethqos: make the rgmii clock optional
net: stmmac: dwmac-qcom-ethqos: add optional phyaux clock
net: stmmac: dwmac-qcom-ethqos: add support for the optional
phy-supply
net: stmmac: dwmac-qcom-ethqos: prepare the driver for more PHY modes
net: stmmac: dwmac-qcom-ethqos: add support for SGMII
net: stmmac: add new switch to struct plat_stmmacenet_data
dt-bindings: net: snps,dwmac: add compatible for sa8775p ethqos
dt-bindings: net: qcom,ethqos: add description for sa8775p
net: stmmac: dwmac-qcom-ethqos: add support for emac4 on sa8775p
platforms
arm64: dts: qcom: sa8775p-ride: add the SGMII PHY node
arm64: dts: qcom: sa8775p: add the first 1Gb ethernet interface
arm64: dts: qcom: sa8775p-ride: enable the SerDes PHY
arm64: dts: qcom: sa8775p-ride: add pin functions for ethernet0
arm64: dts: qcom: sa8775p-ride: enable ethernet0
.../devicetree/bindings/net/qcom,ethqos.yaml | 14 +- .../devicetree/bindings/net/snps,dwmac.yaml | 3 + .../phy/qcom,sa8775p-dwmac-sgmii-phy.yaml | 52 ++ arch/arm64/boot/dts/qcom/sa8775p-ride.dts | 109 +++++ arch/arm64/boot/dts/qcom/sa8775p.dtsi | 39 ++ arch/arm64/configs/defconfig | 1 + .../stmicro/stmmac/dwmac-qcom-ethqos.c | 273 ++++++++--- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +- drivers/phy/qualcomm/Kconfig | 9 + drivers/phy/qualcomm/Makefile | 3 +- drivers/phy/qualcomm/phy-qcom-sgmii-eth.c | 446 ++++++++++++++++++ include/linux/stmmac.h | 1 + 12 files changed, 890 insertions(+), 62 deletions(-) create mode 100644 Documentation/devicetree/bindings/phy/qcom,sa8775p-dwmac-sgmii-phy.yaml create mode 100644 drivers/phy/qualcomm/phy-qcom-sgmii-eth.c
Signature · 1 line
2.39.2
PATCH 1/26 phy: qualcomm: fix indentation in Makefile
From: Bartosz Golaszewski <[email protected]>
Align all entries in Makefile.
--- drivers/phy/qualcomm/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/phy/qualcomm/Makefile +1 -1
@@ -20,4 +20,4 @@ obj-$(CONFIG_PHY_QCOM_USB_HSIC) += phy-qcom-usb-hsic.o obj-$(CONFIG_PHY_QCOM_USB_HS_28NM) += phy-qcom-usb-hs-28nm.o obj-$(CONFIG_PHY_QCOM_USB_SS) += phy-qcom-usb-ss.o obj-$(CONFIG_PHY_QCOM_USB_SNPS_FEMTO_V2)+= phy-qcom-snps-femto-v2.o -obj-$(CONFIG_PHY_QCOM_IPQ806X_USB) += phy-qcom-ipq806x-usb.o +obj-$(CONFIG_PHY_QCOM_IPQ806X_USB) += phy-qcom-ipq806x-usb.o
Signature · 1 line
2.39.2
PATCH 2/26 dt-bindings: phy: describe the Qualcomm SGMII PHY
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
Describe the SGMII/SerDes PHY present on the sa8775p platforms.
--- .../phy/qcom,sa8775p-dwmac-sgmii-phy.yaml | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/qcom,sa8775p-dwmac-sgmii-phy.yaml
Documentation/devicetree/bindings/phy/qcom,sa8775p-dwmac-sgmii-phy.yaml new file +52 -0
@@ -0,0 +1,52 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/phy/qcom,sa8775p-dwmac-sgmii-phy.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Qualcomm SerDes/SGMII ethernet PHY controller + +maintainers: + - Bartosz Golaszewski <[email protected]> + +description: + The SerDes PHY sits between the MAC and the external PHY and provides + separate Rx Tx lines. + +properties: + compatible: + const: qcom,sa8775p-dwmac-sgmii-phy + + reg: + items: + - description: serdes + + clocks: + maxItems: 1 + + clock-names: + const: sgmi_ref + + "#phy-cells": + const: 0 + +additionalProperties: false + +required: + - compatible + - reg + - "#phy-cells" + - clocks + - clock-names + +examples: + - | + #include <dt-bindings/clock/qcom,sa8775p-gcc.h> + serdes_phy: phy@8901000 { + compatible = "qcom,sa8775p-dwmac-sgmii-phy"; + reg = <0x08901000 0xe10>; + clocks = <&gcc GCC_SGMI_CLKREF_EN>; + clock-names = "sgmi_ref"; + #phy-cells = <0>; + status = "disabled"; + };
Signature · 1 line
2.39.2
PATCH 3/26 phy: qcom: add the SGMII SerDes PHY driver
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
Implement support for the SGMII/SerDes PHY present on various Qualcomm platforms.
--- drivers/phy/qualcomm/Kconfig | 9 + drivers/phy/qualcomm/Makefile | 1 + drivers/phy/qualcomm/phy-qcom-sgmii-eth.c | 446 ++++++++++++++++++++++ 3 files changed, 456 insertions(+) create mode 100644 drivers/phy/qualcomm/phy-qcom-sgmii-eth.c
drivers/phy/qualcomm/Kconfig +9 -0
@@ -188,3 +188,12 @@ config PHY_QCOM_IPQ806X_USB This option enables support for the Synopsis PHYs present inside the Qualcomm USB3.0 DWC3 controller on ipq806x SoC. This driver supports both HS and SS PHY controllers. + +config PHY_QCOM_SGMII_ETH + tristate "Qualcomm DWMAC SGMII SerDes/PHY driver" + depends on OF && (ARCH_QCOM || COMPILE_TEST) + depends on HAS_IOMEM + select GENERIC_PHY + help + Enable this to support the internal SerDes/SGMII PHY on various + Qualcomm chipsets.
drivers/phy/qualcomm/Makefile +1 -0
@@ -21,3 +21,4 @@ obj-$(CONFIG_PHY_QCOM_USB_HS_28NM) += phy-qcom-usb-hs-28nm.o obj-$(CONFIG_PHY_QCOM_USB_SS) += phy-qcom-usb-ss.o obj-$(CONFIG_PHY_QCOM_USB_SNPS_FEMTO_V2)+= phy-qcom-snps-femto-v2.o obj-$(CONFIG_PHY_QCOM_IPQ806X_USB) += phy-qcom-ipq806x-usb.o +obj-$(CONFIG_PHY_QCOM_SGMII_ETH) += phy-qcom-sgmii-eth.o
drivers/phy/qualcomm/phy-qcom-sgmii-eth.c new file +446 -0
446 lines not on this page · raw message
Signature · 1 line
2.39.2
PATCH 4/26 arm64: defconfig: enable the SerDes PHY for Qualcomm DWMAC
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
Enable the SGMII/SerDes PHY driver. This module is required to enable ethernet on sa8775p platforms.
--- arch/arm64/configs/defconfig | 1 + 1 file changed, 1 insertion(+)
arch/arm64/configs/defconfig +1 -0
@@ -1367,6 +1367,7 @@ CONFIG_PHY_QCOM_USB_HS=m CONFIG_PHY_QCOM_USB_SNPS_FEMTO_V2=m CONFIG_PHY_QCOM_USB_HS_28NM=m CONFIG_PHY_QCOM_USB_SS=m +CONFIG_PHY_QCOM_SGMII_ETH=m CONFIG_PHY_R8A779F0_ETHERNET_SERDES=y CONFIG_PHY_RCAR_GEN3_PCIE=y CONFIG_PHY_RCAR_GEN3_USB2=y
Signature · 1 line
2.39.2
PATCH 5/26 net: stmmac: dwmac-qcom-ethqos: shrink clock code with devres
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
We can use a devm action to completely drop the remove callback and use stmmac_pltfr_remove() directly for remove. We can also drop one of the goto labels.
--- .../stmicro/stmmac/dwmac-qcom-ethqos.c | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +11 -13
@@ -586,6 +586,11 @@ static int ethqos_clks_config(void *priv, bool enabled)return ret; } +static void ethqos_clks_disable (void *data) +{ +ethqos_clks_config (data, false); +} +static int qcom_ethqos_probe (struct platform_device *pdev) {struct device_node *np = pdev->dev.of_node;
@@ -636,6 +641,10 @@ static int qcom_ethqos_probe(struct platform_device *pdev)if (ret) goto err_mem; + ret =devm_add_action_or_reset (&pdev->dev, ethqos_clks_disable, ethqos); +if (ret) + goto err_mem; + ethqos->speed =SPEED_1000 ;ethqos_update_rgmii_clk (ethqos,SPEED_1000 );ethqos_set_func_clk_en (ethqos);
@@ -653,27 +662,16 @@ static int qcom_ethqos_probe(struct platform_device *pdev) ret =stmmac_dvr_probe (&pdev->dev, plat_dat, &stmmac_res);if (ret) - goto err_clk; + goto err_mem;return ret; -err_clk: -ethqos_clks_config (ethqos, false); - err_mem:stmmac_remove_config_dt (pdev, plat_dat);return ret; } -static void qcom_ethqos_remove (struct platform_device *pdev) -{ -struct qcom_ethqos *ethqos =get_stmmac_bsp_priv (&pdev->dev); - -stmmac_pltfr_remove (pdev); -ethqos_clks_config (ethqos, false); -} -static const struct of_device_id qcom_ethqos_match[] = { { .compatible ="qcom,qcs404-ethqos" , .data = &emac_v2_3_0_data}, { .compatible ="qcom,sc8280xp-ethqos" , .data = &emac_v3_0_0_data},
@@ -684,7 +682,7 @@ MODULE_DEVICE_TABLE(of, qcom_ethqos_match);static struct platform_driver qcom_ethqos_driver = { .probe = qcom_ethqos_probe, - .remove_new = qcom_ethqos_remove, + .remove_new = stmmac_pltfr_remove, .driver = { .name ="qcom-ethqos" , .pm = &stmmac_pltfr_pm_ops,
Signature · 1 line
2.39.2
PATCH 6/26 net: stmmac: dwmac-qcom-ethqos: rename a label in probe()
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
The err_mem label's name is unclear. It actually should be reached on any error after stmmac_probe_config_dt() succeeds. Name it after the cleanup action that needs to be called before exiting.
--- .../ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +7 -7
@@ -615,14 +615,14 @@ static int qcom_ethqos_probe(struct platform_device *pdev) ethqos =devm_kzalloc (&pdev->dev,sizeof (*ethqos),GFP_KERNEL );if (!ethqos) { ret = -ENOMEM ; - goto err_mem; + goto out_config_dt; } ethqos->pdev = pdev; ethqos->rgmii_base =devm_platform_ioremap_resource_byname (pdev,"rgmii" );if (IS_ERR (ethqos->rgmii_base)) { ret =PTR_ERR (ethqos->rgmii_base); - goto err_mem; + goto out_config_dt; } data =of_device_get_match_data (&pdev->dev);
@@ -634,16 +634,16 @@ static int qcom_ethqos_probe(struct platform_device *pdev) ethqos->rgmii_clk =devm_clk_get (&pdev->dev,"rgmii" );if (IS_ERR (ethqos->rgmii_clk)) { ret =PTR_ERR (ethqos->rgmii_clk); - goto err_mem; + goto out_config_dt; } ret =ethqos_clks_config (ethqos, true);if (ret) - goto err_mem; + goto out_config_dt; ret =devm_add_action_or_reset (&pdev->dev, ethqos_clks_disable, ethqos);if (ret) - goto err_mem; + goto out_config_dt; ethqos->speed =SPEED_1000 ;ethqos_update_rgmii_clk (ethqos,SPEED_1000 );
@@ -662,11 +662,11 @@ static int qcom_ethqos_probe(struct platform_device *pdev) ret =stmmac_dvr_probe (&pdev->dev, plat_dat, &stmmac_res);if (ret) - goto err_mem; + goto out_config_dt;return ret; -err_mem: +out_config_dt:stmmac_remove_config_dt (pdev, plat_dat);return ret;
Signature · 1 line
2.39.2
PATCH 7/26 net: stmmac: dwmac-qcom-ethqos: tweak the order of local variables
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
Make sure we follow the reverse-xmas tree convention.
--- drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +1 -1
@@ -594,9 +594,9 @@ static void ethqos_clks_disable(void *data)static int qcom_ethqos_probe (struct platform_device *pdev) {struct device_node *np = pdev->dev.of_node; +const struct ethqos_emac_driver_data *data;struct plat_stmmacenet_data *plat_dat;struct stmmac_resources stmmac_res; -const struct ethqos_emac_driver_data *data;struct qcom_ethqos *ethqos;int ret;
Signature · 1 line
2.39.2
PATCH 8/26 net: stmmac: dwmac-qcom-ethqos: use a helper variable for &pdev->dev
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
Shrink code and avoid line breaks by using a helper variable for &pdev->dev.
--- .../stmicro/stmmac/dwmac-qcom-ethqos.c | 48 ++++++++++--------- 1 file changed, 26 insertions(+), 22 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +26 -22
@@ -123,25 +123,26 @@ static void rgmii_updatel(struct qcom_ethqos *ethqos,static void rgmii_dump (void *priv) {struct qcom_ethqos *ethqos = priv; +struct device *dev = ðqos->pdev->dev; -dev_dbg (ðqos->pdev->dev,"Rgmii register dump\n" ); -dev_dbg (ðqos->pdev->dev,"RGMII_IO_MACRO_CONFIG: %x\n" , +dev_dbg (dev,"Rgmii register dump\n" ); +dev_dbg (dev,"RGMII_IO_MACRO_CONFIG: %x\n" ,rgmii_readl (ethqos,RGMII_IO_MACRO_CONFIG )); -dev_dbg (ðqos->pdev->dev,"SDCC_HC_REG_DLL_CONFIG: %x\n" , +dev_dbg (dev,"SDCC_HC_REG_DLL_CONFIG: %x\n" ,rgmii_readl (ethqos,SDCC_HC_REG_DLL_CONFIG )); -dev_dbg (ðqos->pdev->dev,"SDCC_HC_REG_DDR_CONFIG: %x\n" , +dev_dbg (dev,"SDCC_HC_REG_DDR_CONFIG: %x\n" ,rgmii_readl (ethqos,SDCC_HC_REG_DDR_CONFIG )); -dev_dbg (ðqos->pdev->dev,"SDCC_HC_REG_DLL_CONFIG2: %x\n" , +dev_dbg (dev,"SDCC_HC_REG_DLL_CONFIG2: %x\n" ,rgmii_readl (ethqos,SDCC_HC_REG_DLL_CONFIG2 )); -dev_dbg (ðqos->pdev->dev,"SDC4_STATUS: %x\n" , +dev_dbg (dev,"SDC4_STATUS: %x\n" ,rgmii_readl (ethqos,SDC4_STATUS )); -dev_dbg (ðqos->pdev->dev,"SDCC_USR_CTL: %x\n" , +dev_dbg (dev,"SDCC_USR_CTL: %x\n" ,rgmii_readl (ethqos,SDCC_USR_CTL )); -dev_dbg (ðqos->pdev->dev,"RGMII_IO_MACRO_CONFIG2: %x\n" , +dev_dbg (dev,"RGMII_IO_MACRO_CONFIG2: %x\n" ,rgmii_readl (ethqos,RGMII_IO_MACRO_CONFIG2 )); -dev_dbg (ðqos->pdev->dev,"RGMII_IO_MACRO_DEBUG1: %x\n" , +dev_dbg (dev,"RGMII_IO_MACRO_DEBUG1: %x\n" ,rgmii_readl (ethqos,RGMII_IO_MACRO_DEBUG1 )); -dev_dbg (ðqos->pdev->dev,"EMAC_SYSTEM_LOW_POWER_DEBUG: %x\n" , +dev_dbg (dev,"EMAC_SYSTEM_LOW_POWER_DEBUG: %x\n" ,rgmii_readl (ethqos,EMAC_SYSTEM_LOW_POWER_DEBUG )); }
@@ -242,6 +243,7 @@ static const struct ethqos_emac_driver_data emac_v3_0_0_data = {static int ethqos_dll_configure (struct qcom_ethqos *ethqos) { +struct device *dev = ðqos->pdev->dev;unsigned int val;int retry =1000 ;
@@ -279,7 +281,7 @@ static int ethqos_dll_configure(struct qcom_ethqos *ethqos) retry--; }while (retry >0 );if (!retry) -dev_err (ðqos->pdev->dev,"Clear CK_OUT_EN timedout\n" ); +dev_err (dev,"Clear CK_OUT_EN timedout\n" );/* Set CK_OUT_EN */ rgmii_updatel(ethqos, SDCC_DLL_CONFIG_CK_OUT_EN,
@@ -296,7 +298,7 @@ static int ethqos_dll_configure(struct qcom_ethqos *ethqos) retry--; }while (retry >0 );if (!retry) -dev_err (ðqos->pdev->dev,"Set CK_OUT_EN timedout\n" ); +dev_err (dev,"Set CK_OUT_EN timedout\n" );/* Set DDR_CAL_EN */ rgmii_updatel(ethqos, SDCC_DLL_CONFIG2_DDR_CAL_EN,
@@ -322,12 +324,13 @@ static int ethqos_dll_configure(struct qcom_ethqos *ethqos)static int ethqos_rgmii_macro_init (struct qcom_ethqos *ethqos) { +struct device *dev = ðqos->pdev->dev;int phase_shift;int phy_mode;int loopback;/* Determine if the PHY adds a 2 ns TX delay or the MAC handles it */ - phy_mode =device_get_phy_mode (ðqos->pdev->dev); + phy_mode =device_get_phy_mode (dev);if (phy_mode ==PHY_INTERFACE_MODE_RGMII_ID || phy_mode ==PHY_INTERFACE_MODE_RGMII_TXID ) phase_shift =0 ;
@@ -468,7 +471,7 @@ static int ethqos_rgmii_macro_init(struct qcom_ethqos *ethqos) loopback, RGMII_IO_MACRO_CONFIG);break ;default : -dev_err (ðqos->pdev->dev, +dev_err (dev,"Invalid speed %d\n" , ethqos->speed);return -EINVAL ; }
@@ -478,6 +481,7 @@ static int ethqos_rgmii_macro_init(struct qcom_ethqos *ethqos)static int ethqos_configure (struct qcom_ethqos *ethqos) { +struct device *dev = ðqos->pdev->dev;volatile unsigned int dll_lock;unsigned int i, retry =1000 ;
@@ -540,8 +544,7 @@ static int ethqos_configure(struct qcom_ethqos *ethqos) retry--; }while (retry >0 );if (!retry) -dev_err (ðqos->pdev->dev, -"Timeout while waiting for DLL lock\n" ); +dev_err (dev,"Timeout while waiting for DLL lock\n" ); }if (ethqos->speed ==SPEED_1000 )
@@ -597,6 +600,7 @@ static int qcom_ethqos_probe(struct platform_device *pdev)const struct ethqos_emac_driver_data *data;struct plat_stmmacenet_data *plat_dat;struct stmmac_resources stmmac_res; +struct device *dev = &pdev->dev;struct qcom_ethqos *ethqos;int ret;
@@ -606,13 +610,13 @@ static int qcom_ethqos_probe(struct platform_device *pdev) plat_dat =stmmac_probe_config_dt (pdev, stmmac_res.mac);if (IS_ERR (plat_dat)) { -dev_err (&pdev->dev,"dt configuration failed\n" ); +dev_err (dev,"dt configuration failed\n" );return PTR_ERR (plat_dat); } plat_dat->clks_config = ethqos_clks_config; - ethqos =devm_kzalloc (&pdev->dev,sizeof (*ethqos),GFP_KERNEL ); + ethqos =devm_kzalloc (dev,sizeof (*ethqos),GFP_KERNEL );if (!ethqos) { ret = -ENOMEM ; goto out_config_dt;
@@ -625,13 +629,13 @@ static int qcom_ethqos_probe(struct platform_device *pdev) goto out_config_dt; } - data =of_device_get_match_data (&pdev->dev); + data =of_device_get_match_data (dev); ethqos->por = data->por; ethqos->num_por = data->num_por; ethqos->rgmii_config_loopback_en = data->rgmii_config_loopback_en; ethqos->has_emac3 = data->has_emac3; - ethqos->rgmii_clk =devm_clk_get (&pdev->dev,"rgmii" ); + ethqos->rgmii_clk =devm_clk_get (dev,"rgmii" );if (IS_ERR (ethqos->rgmii_clk)) { ret =PTR_ERR (ethqos->rgmii_clk); goto out_config_dt;
@@ -641,7 +645,7 @@ static int qcom_ethqos_probe(struct platform_device *pdev)if (ret) goto out_config_dt; - ret =devm_add_action_or_reset (&pdev->dev, ethqos_clks_disable, ethqos); + ret =devm_add_action_or_reset (dev, ethqos_clks_disable, ethqos);if (ret) goto out_config_dt;
@@ -660,7 +664,7 @@ static int qcom_ethqos_probe(struct platform_device *pdev)if (of_device_is_compatible (np,"qcom,qcs404-ethqos" )) plat_dat->rx_clk_runs_in_lpi =1 ; - ret =stmmac_dvr_probe (&pdev->dev, plat_dat, &stmmac_res); + ret =stmmac_dvr_probe (dev, plat_dat, &stmmac_res);if (ret) goto out_config_dt;
Signature · 1 line
2.39.2
PATCH 9/26 net: stmmac: dwmac-qcom-ethqos: add missing include
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
device_get_phy_mode() is declared in linux/property.h but this header is not included.
--- drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +1 -0
@@ -6,6 +6,7 @@#include <linux/of_device.h> #include <linux/platform_device.h> #include <linux/phy.h> +#include <linux/property.h> #include "stmmac.h" #include "stmmac_platform.h"
Signature · 1 line
2.39.2
PATCH 10/26 net: stmmac: dwmac-qcom-ethqos: add a newline between headers
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
Typically we use a newline between global and local headers so add it here as well.
--- drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +1 -0
@@ -7,6 +7,7 @@#include <linux/platform_device.h> #include <linux/phy.h> #include <linux/property.h> +#include "stmmac.h" #include "stmmac_platform.h"
Signature · 1 line
2.39.2
PATCH 11/26 net: stmmac: dwmac-qcom-ethqos: remove stray space
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
There's an unnecessary space in the rgmii_updatel() function, remove it.
--- drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +1 -1
@@ -117,7 +117,7 @@ static void rgmii_updatel(struct qcom_ethqos *ethqos, {unsigned int temp; - temp =rgmii_readl (ethqos, offset); + temp =rgmii_readl (ethqos, offset); temp = (temp & ~(mask)) | val;rgmii_writel (ethqos, temp, offset); }
Signature · 1 line
2.39.2
PATCH 12/26 net: stmmac: dwmac-qcom-ethqos: add support for the optional serdes phy
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
On sa8775p platforms, there's a SGMII SerDes PHY between the MAC and external PHY that we need to enable and configure.
--- .../stmicro/stmmac/dwmac-qcom-ethqos.c | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+)
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +37 -0
@@ -6,6 +6,7 @@#include <linux/of_device.h> #include <linux/platform_device.h> #include <linux/phy.h> +#include <linux/phy/phy.h> #include <linux/property.h> #include "stmmac.h"
@@ -93,6 +94,7 @@ struct qcom_ethqos {unsigned int rgmii_clk_rate;struct clk *rgmii_clk; +struct phy *serdes_phy;unsigned int speed;const struct ethqos_emac_por *por;
@@ -566,6 +568,30 @@ static void ethqos_fix_mac_speed(void *priv, unsigned int speed)ethqos_configure (ethqos); } +static int qcom_ethqos_serdes_powerup (struct net_device *ndev,void *priv) +{ +struct qcom_ethqos *ethqos = priv; +int ret; + + ret =phy_set_speed (ethqos->serdes_phy, ethqos->speed); +if (ret) +return ret; + + ret =phy_init (ethqos->serdes_phy); +if (ret) +return ret; + +return phy_power_on (ethqos->serdes_phy); +} + +static void qcom_ethqos_serdes_powerdown (struct net_device *ndev,void *priv) +{ +struct qcom_ethqos *ethqos = priv; + +phy_power_off (ethqos->serdes_phy); +phy_exit (ethqos->serdes_phy); +} +static int ethqos_clks_config (void *priv,bool enabled) {struct qcom_ethqos *ethqos = priv;
@@ -651,6 +677,12 @@ static int qcom_ethqos_probe(struct platform_device *pdev)if (ret) goto out_config_dt; + ethqos->serdes_phy =devm_phy_optional_get (dev,"serdes" ); +if (IS_ERR (ethqos->serdes_phy)) { + ret =PTR_ERR (ethqos->serdes_phy); + goto out_config_dt; + } + ethqos->speed =SPEED_1000 ;ethqos_update_rgmii_clk (ethqos,SPEED_1000 );ethqos_set_func_clk_en (ethqos);
@@ -666,6 +698,11 @@ static int qcom_ethqos_probe(struct platform_device *pdev)if (of_device_is_compatible (np,"qcom,qcs404-ethqos" )) plat_dat->rx_clk_runs_in_lpi =1 ; +if (ethqos->serdes_phy) { + plat_dat->serdes_powerup = qcom_ethqos_serdes_powerup; + plat_dat->serdes_powerdown = qcom_ethqos_serdes_powerdown; + } + ret =stmmac_dvr_probe (dev, plat_dat, &stmmac_res);if (ret) goto out_config_dt;
Signature · 1 line
2.39.2
PATCH 13/26 net: stmmac: dwmac-qcom-ethqos: make the rgmii clock optional
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
On sa8775p there's no RGMII clock so make it optional in the driver.
--- drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +1 -1
@@ -663,7 +663,7 @@ static int qcom_ethqos_probe(struct platform_device *pdev) ethqos->rgmii_config_loopback_en = data->rgmii_config_loopback_en; ethqos->has_emac3 = data->has_emac3; - ethqos->rgmii_clk =devm_clk_get (dev,"rgmii" ); + ethqos->rgmii_clk =devm_clk_get_optional (dev,"rgmii" );if (IS_ERR (ethqos->rgmii_clk)) { ret =PTR_ERR (ethqos->rgmii_clk); goto out_config_dt;
Signature · 1 line
2.39.2
PATCH 14/26 net: stmmac: dwmac-qcom-ethqos: add optional phyaux clock
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
On sa8775p we don't use the RGMII clock but have an additional PHYAUX clock so add support for it to the driver.
--- .../ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +15 -0
@@ -94,6 +94,7 @@ struct qcom_ethqos {unsigned int rgmii_clk_rate;struct clk *rgmii_clk; +struct clk *phyaux_clk;struct phy *serdes_phy;unsigned int speed;
@@ -604,6 +605,13 @@ static int ethqos_clks_config(void *priv, bool enabled)return ret; } + ret =clk_prepare_enable (ethqos->phyaux_clk); +if (ret) { +clk_disable_unprepare (ethqos->rgmii_clk); +dev_err (ðqos->pdev->dev,"phyaux enable failed\n" ); +return ret; + } +/* Enable functional clock to prevent DMA reset to timeout due * to lacking PHY clock after the hardware block has been power * cycled. The actual configuration will be adjusted once
@@ -611,6 +619,7 @@ static int ethqos_clks_config(void *priv, bool enabled)*/ ethqos_set_func_clk_en (ethqos); }else { +clk_disable_unprepare (ethqos->phyaux_clk);clk_disable_unprepare (ethqos->rgmii_clk); }
@@ -669,6 +678,12 @@ static int qcom_ethqos_probe(struct platform_device *pdev) goto out_config_dt; } + ethqos->phyaux_clk =devm_clk_get_optional (dev,"phyaux" ); +if (IS_ERR (ethqos->phyaux_clk)) { + ret =PTR_ERR (ethqos->phyaux_clk); + goto out_config_dt; + } + ret =ethqos_clks_config (ethqos, true);if (ret) goto out_config_dt;
Signature · 1 line
2.39.2
PATCH 15/26 net: stmmac: dwmac-qcom-ethqos: add support for the optional phy-supply
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
On sa8775p-ride we need to enable the power supply for the external PHY.
--- drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +5 -0
@@ -8,6 +8,7 @@#include <linux/phy.h> #include <linux/phy/phy.h> #include <linux/property.h> +#include <linux/regulator/consumer.h> #include "stmmac.h" #include "stmmac_platform.h"
@@ -692,6 +693,10 @@ static int qcom_ethqos_probe(struct platform_device *pdev)if (ret) goto out_config_dt; + ret =devm_regulator_get_enable_optional (dev,"phy" ); +if (ret <0 && ret != -ENODEV ) + goto out_config_dt; + ethqos->serdes_phy =devm_phy_optional_get (dev,"serdes" );if (IS_ERR (ethqos->serdes_phy)) { ret =PTR_ERR (ethqos->serdes_phy);
Signature · 1 line
2.39.2
PATCH 16/26 net: stmmac: dwmac-qcom-ethqos: prepare the driver for more PHY modes
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
In preparation for supporting SGMII, let's make the code a bit more generic. Add a new callback for MAC configuration so that we can assign a different variant of it in the future.
--- .../stmicro/stmmac/dwmac-qcom-ethqos.c | 31 ++++++++++++++++--- 1 file changed, 26 insertions(+), 5 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +26 -5
@@ -92,12 +92,14 @@ struct ethqos_emac_driver_data {struct qcom_ethqos {struct platform_device *pdev;void __iomem *rgmii_base; +int (*configure_func)(struct qcom_ethqos *ethqos);unsigned int rgmii_clk_rate;struct clk *rgmii_clk;struct clk *phyaux_clk;struct phy *serdes_phy;unsigned int speed; +int phy_mode;const struct ethqos_emac_por *por;unsigned int num_por;
@@ -332,13 +334,11 @@ static int ethqos_rgmii_macro_init(struct qcom_ethqos *ethqos) {struct device *dev = ðqos->pdev->dev;int phase_shift; -int phy_mode;int loopback;/* Determine if the PHY adds a 2 ns TX delay or the MAC handles it */ - phy_mode =device_get_phy_mode (dev); -if (phy_mode ==PHY_INTERFACE_MODE_RGMII_ID || - phy_mode ==PHY_INTERFACE_MODE_RGMII_TXID ) +if (ethqos->phy_mode ==PHY_INTERFACE_MODE_RGMII_ID || + ethqos->phy_mode ==PHY_INTERFACE_MODE_RGMII_TXID ) phase_shift =0 ;else phase_shift =RGMII_CONFIG2_TX_CLK_PHASE_SHIFT_EN ;
@@ -485,7 +485,7 @@ static int ethqos_rgmii_macro_init(struct qcom_ethqos *ethqos)return 0 ; } -static int ethqos_configure (struct qcom_ethqos *ethqos) +static int ethqos_configure_rgmii (struct qcom_ethqos *ethqos) {struct device *dev = ðqos->pdev->dev;volatile unsigned int dll_lock;
@@ -561,6 +561,11 @@ static int ethqos_configure(struct qcom_ethqos *ethqos)return 0 ; } +static int ethqos_configure (struct qcom_ethqos *ethqos) +{ +return ethqos->configure_func (ethqos); +} +static void ethqos_fix_mac_speed (void *priv,unsigned int speed) {struct qcom_ethqos *ethqos = priv;
@@ -660,6 +665,22 @@ static int qcom_ethqos_probe(struct platform_device *pdev) goto out_config_dt; } + ethqos->phy_mode =device_get_phy_mode (dev); +switch (ethqos->phy_mode) { +case PHY_INTERFACE_MODE_RGMII : +case PHY_INTERFACE_MODE_RGMII_ID : +case PHY_INTERFACE_MODE_RGMII_RXID : +case PHY_INTERFACE_MODE_RGMII_TXID : + ethqos->configure_func = ethqos_configure_rgmii; +break ; +case -ENODEV : + ret = -ENODEV ; + goto out_config_dt; +default : + ret = -EINVAL ; + goto out_config_dt; + } + ethqos->pdev = pdev; ethqos->rgmii_base =devm_platform_ioremap_resource_byname (pdev,"rgmii" );if (IS_ERR (ethqos->rgmii_base)) {
Signature · 1 line
2.39.2
PATCH 17/26 net: stmmac: dwmac-qcom-ethqos: add support for SGMII
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
On sa8775p the MAC is connected to the external PHY over SGMII so add support for it to the driver.
--- .../stmicro/stmmac/dwmac-qcom-ethqos.c | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+)
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +37 -0
@@ -76,6 +76,10 @@#define RGMII_CONFIG2_DATA_DIVIDE_CLK_SEL BIT(6)#define RGMII_CONFIG2_TX_CLK_PHASE_SHIFT_EN BIT(5) +/* MAC_CTRL_REG bits */ +#define ETHQOS_MAC_CTRL_SPEED_MODE BIT(14) +#define ETHQOS_MAC_CTRL_PORT_SEL BIT(15) +struct ethqos_emac_por {unsigned int offset;unsigned int value;
@@ -92,6 +96,7 @@ struct ethqos_emac_driver_data {struct qcom_ethqos {struct platform_device *pdev;void __iomem *rgmii_base; +void __iomem *mac_base;int (*configure_func)(struct qcom_ethqos *ethqos);unsigned int rgmii_clk_rate;
@@ -561,6 +566,33 @@ static int ethqos_configure_rgmii(struct qcom_ethqos *ethqos)return 0 ; } +static int ethqos_configure_sgmii (struct qcom_ethqos *ethqos) +{ +int val; + + val =readl (ethqos->mac_base +MAC_CTRL_REG ); + +switch (ethqos->speed) { +case SPEED_1000 : + val &= ~ETHQOS_MAC_CTRL_PORT_SEL ; +rgmii_updatel (ethqos,RGMII_CONFIG2_RGMII_CLK_SEL_CFG , +RGMII_CONFIG2_RGMII_CLK_SEL_CFG , +RGMII_IO_MACRO_CONFIG2 ); +break ; +case SPEED_100 : + val |=ETHQOS_MAC_CTRL_PORT_SEL |ETHQOS_MAC_CTRL_SPEED_MODE ; +break ; +case SPEED_10 : + val |=ETHQOS_MAC_CTRL_PORT_SEL ; + val &= ~ETHQOS_MAC_CTRL_SPEED_MODE ; +break ; + } + +writel (val, ethqos->mac_base +MAC_CTRL_REG ); + +return val; +} +static int ethqos_configure (struct qcom_ethqos *ethqos) {return ethqos->configure_func (ethqos);
@@ -673,6 +705,9 @@ static int qcom_ethqos_probe(struct platform_device *pdev)case PHY_INTERFACE_MODE_RGMII_TXID : ethqos->configure_func = ethqos_configure_rgmii;break ; +case PHY_INTERFACE_MODE_SGMII : + ethqos->configure_func = ethqos_configure_sgmii; +break ;case -ENODEV : ret = -ENODEV ; goto out_config_dt;
@@ -688,6 +723,8 @@ static int qcom_ethqos_probe(struct platform_device *pdev) goto out_config_dt; } + ethqos->mac_base = stmmac_res.addr; + data =of_device_get_match_data (dev); ethqos->por = data->por; ethqos->num_por = data->num_por;
Signature · 1 line
2.39.2
PATCH 18/26 net: stmmac: add new switch to struct plat_stmmacenet_data
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
On some platforms, the PCS can be integrated in the MAC so the driver will not see any PCS link activity. Add a switch that allows the platform drivers to let the core code know.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +- include/linux/stmmac.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1 -1
@@ -5793,7 +5793,7 @@ static void stmmac_common_interrupt(struct stmmac_priv *priv) }/* PCS link status */ -if (priv->hw->pcs) { +if (priv->hw->pcs && !priv->plat->has_integrated_pcs) {if (priv->xstats.pcs_link)netif_carrier_on (priv->dev);else
include/linux/stmmac.h +1 -0
@@ -293,5 +293,6 @@ struct plat_stmmacenet_data {bool sph_disable;bool serdes_up_after_phy_linkup;const struct dwmac4_addrs *dwmac4_addrs; + bool has_integrated_pcs; };#endif
Signature · 1 line
2.39.2
PATCH 19/26 dt-bindings: net: snps,dwmac: add compatible for sa8775p ethqos
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
Add the compatible string for the MAC controller on sa8775p platforms.
--- Documentation/devicetree/bindings/net/snps,dwmac.yaml | 3 +++ 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/net/snps,dwmac.yaml +3 -0
@@ -67,6 +67,7 @@ properties: - loongson,ls2k-dwmac - loongson,ls7a-dwmac - qcom,qcs404-ethqos + - qcom,sa8775p-ethqos - qcom,sc8280xp-ethqos - qcom,sm8150-ethqos - renesas,r9a06g032-gmac
@@ -582,6 +583,7 @@ allOf: - ingenic,x1600-mac - ingenic,x1830-mac - ingenic,x2000-mac + - qcom,sa8775p-ethqos - qcom,sc8280xp-ethqos - snps,dwmac-3.50a - snps,dwmac-4.10a
@@ -638,6 +640,7 @@ allOf: - ingenic,x1830-mac - ingenic,x2000-mac - qcom,qcs404-ethqos + - qcom,sa8775p-ethqos - qcom,sc8280xp-ethqos - qcom,sm8150-ethqos - snps,dwmac-4.00
Signature · 1 line
2.39.2
PATCH 20/26 dt-bindings: net: qcom,ethqos: add description for sa8775p
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
Add the compatible for the MAC controller on sa8775p platforms. This MAC works with a single interrupt so add minItems to the interrupts property. The fourth clock's name is different here so change it. Enable relevant PHY properties.
--- .../devicetree/bindings/net/qcom,ethqos.yaml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/net/qcom,ethqos.yaml +13 -1
@@ -20,6 +20,7 @@ properties: compatible: enum: - qcom,qcs404-ethqos + - qcom,sa8775p-ethqos - qcom,sc8280xp-ethqos - qcom,sm8150-ethqos
@@ -32,11 +33,13 @@ properties: - const: rgmii interrupts: + minItems: 1 items: - description: Combined signal for various interrupt events - description: The interrupt that occurs when Rx exits the LPI state interrupt-names: + minItems: 1 items: - const: macirq - const: eth_lpi
@@ -49,11 +52,20 @@ properties: - const: stmmaceth - const: pclk - const: ptp_ref - - const: rgmii + - enum: + - rgmii + - phyaux iommus: maxItems: 1 + phys: true + + phy-supply: true + + phy-names: + const: serdes + required: - compatible - clocks
Signature · 1 line
2.39.2
PATCH 21/26 net: stmmac: dwmac-qcom-ethqos: add support for emac4 on sa8775p platforms
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
sa8775p uses EMAC version 4, add the relevant defines, rename the has_emac3 switch to has_emac_ge_3 (has emac greater-or-equal than 3) and add the new compatible.
--- .../stmicro/stmmac/dwmac-qcom-ethqos.c | 64 +++++++++++++++---- 1 file changed, 50 insertions(+), 14 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +50 -14
@@ -89,7 +89,8 @@ struct ethqos_emac_driver_data {const struct ethqos_emac_por *por;unsigned int num_por;bool rgmii_config_loopback_en; -bool has_emac3; +bool has_emac_ge_3; +bool has_integrated_pcs;struct dwmac4_addrs dwmac4_addrs; };
@@ -109,7 +110,7 @@ struct qcom_ethqos {const struct ethqos_emac_por *por;unsigned int num_por;bool rgmii_config_loopback_en; -bool has_emac3; +bool has_emac_ge_3; };static int rgmii_readl (struct qcom_ethqos *ethqos,unsigned int offset)
@@ -203,7 +204,7 @@ static const struct ethqos_emac_driver_data emac_v2_3_0_data = { .por = emac_v2_3_0_por, .num_por = ARRAY_SIZE(emac_v2_3_0_por), .rgmii_config_loopback_en = true, - .has_emac3 = false, + .has_emac_ge_3 = false, };static const struct ethqos_emac_por emac_v2_1_0_por[] = {
@@ -219,7 +220,7 @@ static const struct ethqos_emac_driver_data emac_v2_1_0_data = { .por = emac_v2_1_0_por, .num_por = ARRAY_SIZE(emac_v2_1_0_por), .rgmii_config_loopback_en = false, - .has_emac3 = false, + .has_emac_ge_3 = false, };static const struct ethqos_emac_por emac_v3_0_0_por[] = {
@@ -235,7 +236,40 @@ static const struct ethqos_emac_driver_data emac_v3_0_0_data = { .por = emac_v3_0_0_por, .num_por = ARRAY_SIZE(emac_v3_0_0_por), .rgmii_config_loopback_en = false, - .has_emac3 = true, + .has_emac_ge_3 = true, + .dwmac4_addrs = { + .dma_chan = 0x00008100, + .dma_chan_offset = 0x1000, + .mtl_chan = 0x00008000, + .mtl_chan_offset = 0x1000, + .mtl_ets_ctrl = 0x00008010, + .mtl_ets_ctrl_offset = 0x1000, + .mtl_txq_weight = 0x00008018, + .mtl_txq_weight_offset = 0x1000, + .mtl_send_slp_cred = 0x0000801c, + .mtl_send_slp_cred_offset = 0x1000, + .mtl_high_cred = 0x00008020, + .mtl_high_cred_offset = 0x1000, + .mtl_low_cred = 0x00008024, + .mtl_low_cred_offset = 0x1000, + }, +}; + +static const struct ethqos_emac_por emac_v4_0_0_por[] = { + { .offset =RGMII_IO_MACRO_CONFIG , .value =0x40c01343 }, + { .offset =SDCC_HC_REG_DLL_CONFIG , .value =0x2004642c }, + { .offset =SDCC_HC_REG_DDR_CONFIG , .value =0x80040800 }, + { .offset =SDCC_HC_REG_DLL_CONFIG2 , .value =0x00200000 }, + { .offset =SDCC_USR_CTL , .value =0x00010800 }, + { .offset =RGMII_IO_MACRO_CONFIG2 , .value =0x00002060 }, +}; + +static const struct ethqos_emac_driver_data emac_v4_0_0_data = { + .por = emac_v4_0_0_por, + .num_por =ARRAY_SIZE (emac_v3_0_0_por), + .rgmii_config_loopback_en = false, + .has_emac_ge_3 = true, + .has_integrated_pcs = true, .dwmac4_addrs = { .dma_chan =0x00008100 , .dma_chan_offset =0x1000 ,
@@ -276,7 +310,7 @@ static int ethqos_dll_configure(struct qcom_ethqos *ethqos)rgmii_updatel (ethqos,SDCC_DLL_CONFIG_DLL_EN ,SDCC_DLL_CONFIG_DLL_EN ,SDCC_HC_REG_DLL_CONFIG ); -if (!ethqos->has_emac3) { +if (!ethqos->has_emac_ge_3) {rgmii_updatel (ethqos,SDCC_DLL_MCLK_GATING_EN ,0 ,SDCC_HC_REG_DLL_CONFIG );
@@ -317,7 +351,7 @@ static int ethqos_dll_configure(struct qcom_ethqos *ethqos)rgmii_updatel (ethqos,SDCC_DLL_CONFIG2_DDR_CAL_EN ,SDCC_DLL_CONFIG2_DDR_CAL_EN ,SDCC_HC_REG_DLL_CONFIG2 ); -if (!ethqos->has_emac3) { +if (!ethqos->has_emac_ge_3) {rgmii_updatel (ethqos,SDCC_DLL_CONFIG2_DLL_CLOCK_DIS ,0 ,SDCC_HC_REG_DLL_CONFIG2 );
@@ -387,7 +421,7 @@ static int ethqos_rgmii_macro_init(struct qcom_ethqos *ethqos)/* PRG_RCLK_DLY = TCXO period * TCXO_CYCLES_CNT / 2 * RX delay ns, * in practice this becomes PRG_RCLK_DLY = 52 * 4 / 2 * RX delay ns */ -if (ethqos->has_emac3) { +if (ethqos->has_emac_ge_3) {/* 0.9 ns */ rgmii_updatel (ethqos,SDCC_DDR_CONFIG_PRG_RCLK_DLY ,115 ,SDCC_HC_REG_DDR_CONFIG );
@@ -422,7 +456,7 @@ static int ethqos_rgmii_macro_init(struct qcom_ethqos *ethqos)rgmii_updatel (ethqos,RGMII_CONFIG2_RSVD_CONFIG15 ,0 ,RGMII_IO_MACRO_CONFIG2 ); -if (ethqos->has_emac3) +if (ethqos->has_emac_ge_3)rgmii_updatel (ethqos,RGMII_CONFIG2_RX_PROG_SWAP ,RGMII_CONFIG2_RX_PROG_SWAP ,RGMII_IO_MACRO_CONFIG2 );
@@ -462,7 +496,7 @@ static int ethqos_rgmii_macro_init(struct qcom_ethqos *ethqos) RGMII_IO_MACRO_CONFIG);rgmii_updatel (ethqos,RGMII_CONFIG2_RSVD_CONFIG15 ,0 ,RGMII_IO_MACRO_CONFIG2 ); -if (ethqos->has_emac3) +if (ethqos->has_emac_ge_3)rgmii_updatel (ethqos,RGMII_CONFIG2_RX_PROG_SWAP ,RGMII_CONFIG2_RX_PROG_SWAP ,RGMII_IO_MACRO_CONFIG2 );
@@ -512,7 +546,7 @@ static int ethqos_configure_rgmii(struct qcom_ethqos *ethqos)rgmii_updatel (ethqos,SDCC_DLL_CONFIG_PDN ,SDCC_DLL_CONFIG_PDN ,SDCC_HC_REG_DLL_CONFIG ); -if (ethqos->has_emac3) { +if (ethqos->has_emac_ge_3) {if (ethqos->speed ==SPEED_1000 ) {rgmii_writel (ethqos,0x1800000 ,SDCC_TEST_CTL );rgmii_writel (ethqos,0x2C010800 ,SDCC_USR_CTL );
@@ -542,7 +576,7 @@ static int ethqos_configure_rgmii(struct qcom_ethqos *ethqos) SDCC_HC_REG_DLL_CONFIG);/* Set USR_CTL bit 26 with mask of 3 bits */ -if (!ethqos->has_emac3) +if (!ethqos->has_emac_ge_3)rgmii_updatel (ethqos,GENMASK (26 ,24 ),BIT (26 ),SDCC_USR_CTL );
@@ -729,7 +763,7 @@ static int qcom_ethqos_probe(struct platform_device *pdev) ethqos->por = data->por; ethqos->num_por = data->num_por; ethqos->rgmii_config_loopback_en = data->rgmii_config_loopback_en; - ethqos->has_emac3 = data->has_emac3; + ethqos->has_emac_ge_3 = data->has_emac_ge_3; ethqos->rgmii_clk =devm_clk_get_optional (dev,"rgmii" );if (IS_ERR (ethqos->rgmii_clk)) {
@@ -769,12 +803,13 @@ static int qcom_ethqos_probe(struct platform_device *pdev) plat_dat->fix_mac_speed = ethqos_fix_mac_speed; plat_dat->dump_debug_regs = rgmii_dump; plat_dat->has_gmac4 =1 ; -if (ethqos->has_emac3) +if (ethqos->has_emac_ge_3) plat_dat->dwmac4_addrs = &data->dwmac4_addrs; plat_dat->pmt =1 ; plat_dat->tso_en =of_property_read_bool (np,"snps,tso" );if (of_device_is_compatible (np,"qcom,qcs404-ethqos" )) plat_dat->rx_clk_runs_in_lpi =1 ; + plat_dat->has_integrated_pcs = data->has_integrated_pcs;if (ethqos->serdes_phy) { plat_dat->serdes_powerup = qcom_ethqos_serdes_powerup;
@@ -795,6 +830,7 @@ static int qcom_ethqos_probe(struct platform_device *pdev)static const struct of_device_id qcom_ethqos_match[] = { { .compatible ="qcom,qcs404-ethqos" , .data = &emac_v2_3_0_data}, + { .compatible ="qcom,sa8775p-ethqos" , .data = &emac_v4_0_0_data}, { .compatible ="qcom,sc8280xp-ethqos" , .data = &emac_v3_0_0_data}, { .compatible ="qcom,sm8150-ethqos" , .data = &emac_v2_1_0_data}, { }
Signature · 1 line
2.39.2
PATCH 22/26 arm64: dts: qcom: sa8775p-ride: add the SGMII PHY node
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
Add the internal SGMII/SerDes PHY node for sa8775p platforms.
--- arch/arm64/boot/dts/qcom/sa8775p.dtsi | 9 +++++++++ 1 file changed, 9 insertions(+)
arch/arm64/boot/dts/qcom/sa8775p.dtsi +9 -0
@@ -1837,6 +1837,15 @@ adreno_smmu: iommu@3da0000 { <GIC_SPI 687 IRQ_TYPE_LEVEL_HIGH>; }; + serdes_phy: phy@8901000 { + compatible = "qcom,sa8775p-dwmac-sgmii-phy"; + reg = <0 0x08901000 0 0xe10>; + clocks = <&gcc GCC_SGMI_CLKREF_EN>; + clock-names = "sgmi_ref"; + #phy-cells = <0>; + status = "disabled"; + }; + pdc: interrupt-controller@b220000 { compatible = "qcom,sa8775p-pdc", "qcom,pdc"; reg = <0x0 0x0b220000 0x0 0x30000>,
Signature · 1 line
2.39.2
PATCH 24/26 arm64: dts: qcom: sa8775p-ride: enable the SerDes PHY
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
Enable the internal PHY on sa8775p-ride.
--- arch/arm64/boot/dts/qcom/sa8775p-ride.dts | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm64/boot/dts/qcom/sa8775p-ride.dts +4 -0
@@ -355,6 +355,10 @@ &qupv3_id_2 { status = "okay"; }; +&serdes_phy { + status = "okay"; +}; + &sleep_clk { clock-frequency = <32764>; };
Signature · 1 line
2.39.2
PATCH 23/26 arm64: dts: qcom: sa8775p: add the first 1Gb ethernet interface
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
Add the node for the first ethernet interface on sa8775p platforms.
--- arch/arm64/boot/dts/qcom/sa8775p.dtsi | 30 +++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
arch/arm64/boot/dts/qcom/sa8775p.dtsi +30 -0
@@ -2315,6 +2315,36 @@ cpufreq_hw: cpufreq@18591000 { #freq-domain-cells = <1>; }; + + ethernet0: ethernet@23040000 { + compatible = "qcom,sa8775p-ethqos"; + reg = <0x0 0x23040000 0x0 0x10000>, + <0x0 0x23056000 0x0 0x100>; + reg-names = "stmmaceth", "rgmii"; + + clocks = <&gcc GCC_EMAC0_AXI_CLK>, + <&gcc GCC_EMAC0_SLV_AHB_CLK>, + <&gcc GCC_EMAC0_PTP_CLK>, + <&gcc GCC_EMAC0_PHY_AUX_CLK>; + clock-names = "stmmaceth", "pclk", "ptp_ref", "phyaux"; + + power-domains = <&gcc EMAC0_GDSC>; + + interrupts = <GIC_SPI 946 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "macirq"; + + phys = <&serdes_phy>; + phy-names = "serdes"; + + iommus = <&apps_smmu 0x120 0xf>; + + snps,tso; + snps,pbl = <32>; + rx-fifo-depth = <16384>; + tx-fifo-depth = <16384>; + + status = "disabled"; + }; }; arch_timer: timer {
Signature · 1 line
2.39.2
PATCH 25/26 arm64: dts: qcom: sa8775p-ride: add pin functions for ethernet0
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
Add the MDC and MDIO pin functions for ethernet0 on sa8775p-ride.
--- arch/arm64/boot/dts/qcom/sa8775p-ride.dts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
arch/arm64/boot/dts/qcom/sa8775p-ride.dts +16 -0
@@ -370,6 +370,22 @@ &spi16 { }; &tlmm { + ethernet0_default: ethernet0-default-state { + ethernet0_mdc: ethernet0-mdc-pins { + pins = "gpio8"; + function = "emac0_mdc"; + drive-strength = <16>; + bias-pull-up; + }; + + ethernet0_mdio: ethernet0-mdio-pins { + pins = "gpio9"; + function = "emac0_mdio"; + drive-strength = <16>; + bias-pull-up; + }; + }; + qup_uart10_default: qup-uart10-state { pins = "gpio46", "gpio47"; function = "qup1_se3";
Signature · 1 line
2.39.2
PATCH 26/26 arm64: dts: qcom: sa8775p-ride: enable ethernet0
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
Enable the first 1Gb ethernet port on sa8775p-ride development board.
--- arch/arm64/boot/dts/qcom/sa8775p-ride.dts | 89 +++++++++++++++++++++++ 1 file changed, 89 insertions(+)
arch/arm64/boot/dts/qcom/sa8775p-ride.dts +89 -0
@@ -261,6 +261,95 @@ vreg_l8e: ldo8 { }; }; +ðernet0 { + phy-mode = "sgmii"; + phy-handle = <&sgmii_phy>; + phy-supply = <&vreg_l5a>; + + pinctrl-0 = <ðernet0_default>; + pinctrl-names = "default"; + + snps,mtl-rx-config = <&mtl_rx_setup>; + snps,mtl-tx-config = <&mtl_tx_setup>; + snps,ps-speed = <1000>; + + status = "okay"; + + mdio { + compatible = "snps,dwmac-mdio"; + #address-cells = <1>; + #size-cells = <0>; + + reset-gpios = <&pmm8654au_2_gpios 8 GPIO_ACTIVE_LOW>; + reset-delay-us = <11000>; + reset-post-delay-us = <70000>; + + sgmii_phy: phy@8 { + reg = <0x8>; + device_type = "ethernet-phy"; + }; + }; + + mtl_rx_setup: rx-queues-config { + snps,rx-queues-to-use = <4>; + snps,rx-sched-sp; + + queue0 { + snps,dcb-algorithm; + snps,map-to-dma-channel = <0x0>; + snps,route-up; + snps,priority = <0x1>; + }; + + queue1 { + snps,dcb-algorithm; + snps,map-to-dma-channel = <0x1>; + snps,route-ptp; + }; + + queue2 { + snps,avb-algorithm; + snps,map-to-dma-channel = <0x2>; + snps,route-avcp; + }; + + queue3 { + snps,avb-algorithm; + snps,map-to-dma-channel = <0x3>; + snps,priority = <0xc>; + }; + }; + + mtl_tx_setup: tx-queues-config { + snps,tx-queues-to-use = <4>; + snps,tx-sched-sp; + + queue0 { + snps,dcb-algorithm; + }; + + queue1 { + snps,dcb-algorithm; + }; + + queue2 { + snps,avb-algorithm; + snps,send_slope = <0x1000>; + snps,idle_slope = <0x1000>; + snps,high_credit = <0x3e800>; + snps,low_credit = <0xffc18000>; + }; + + queue3 { + snps,avb-algorithm; + snps,send_slope = <0x1000>; + snps,idle_slope = <0x1000>; + snps,high_credit = <0x3e800>; + snps,low_credit = <0xffc18000>; + }; + }; +}; + &i2c11 { clock-frequency = <400000>; pinctrl-0 = <&qup_i2c11_default>;
Signature · 1 line
2.39.2
Re: [PATCH 22/26] arm64: dts: qcom: sa8775p-ride: add the SGMII PHY node
In reply to Bartosz GolaszewskiQuoted 14 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
Add the internal SGMII/SerDes PHY node for sa8775p platforms.
Signed-off-by Bartosz Golaszewski <[email protected]>--- arch/arm64/boot/dts/qcom/sa8775p.dtsi | 9 +++++++++ 1 file changed, 9 insertions(+)arch/arm64/boot/dts/qcom/sa8775p.dtsi +0
-0
arch/arm64/boot/dts/qcom/sa8775p.dtsi adreno_smmu: iommu@3da0000 { · line 1842
Quoted 6 lines
arch/arm64/boot/dts/qcom/sa8775p.dtsi +3
-0@@ -1837,6 +1837,15 @@ adreno_smmu: iommu@3da0000 { <GIC_SPI 687 IRQ_TYPE_LEVEL_HIGH>; }; + serdes_phy: phy@8901000 { + compatible = "qcom,sa8775p-dwmac-sgmii-phy"; + reg = <0 0x08901000 0 0xe10>;
The usage of 0 is inconsistent with 0x0 everywhere else
Konrad
Quoted 9 lines
arch/arm64/boot/dts/qcom/sa8775p.dtsi +6
-0+ clocks = <&gcc GCC_SGMI_CLKREF_EN>; + clock-names = "sgmi_ref"; + #phy-cells = <0>; + status = "disabled"; + }; + pdc: interrupt-controller@b220000 { compatible = "qcom,sa8775p-pdc", "qcom,pdc"; reg = <0x0 0x0b220000 0x0 0x30000>,
Signature · 3 lines
linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
Re: [PATCH 03/26] phy: qcom: add the SGMII SerDes PHY driver
In reply to Bartosz Golaszewskidrivers/phy/qualcomm/phy-qcom-sgmii-eth.c line 386
Quoted 13 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
Implement support for the SGMII/SerDes PHY present on various Qualcomm platforms.
Signed-off-by Bartosz Golaszewski <[email protected]>---
drivers/phy/qualcomm/phy-qcom-sgmii-eth.c new file +6
-0+static const struct regmap_config qcom_dwmac_sgmii_phy_regmap_cfg = { + .reg_bits =32 , + .val_bits =32 , + .reg_stride =4 , + .use_relaxed_mmio = true, + .disable_locking = true,
The last two are rather brave, no?
Konrad
Quoted 60 lines
drivers/phy/qualcomm/phy-qcom-sgmii-eth.c new file +60
-0+}; + +static int qcom_dwmac_sgmii_phy_probe (struct platform_device *pdev) +{ +struct qcom_dwmac_sgmii_phy_data *data; +struct device *dev = &pdev->dev; +struct phy_provider *provider; +struct clk *refclk; +void __iomem *base; +struct phy *phy; + + data =devm_kzalloc (dev,sizeof (*data),GFP_KERNEL ); +if (!data) +return -ENOMEM ; + + base =devm_platform_ioremap_resource (pdev,0 ); +if (IS_ERR (base)) +return PTR_ERR (base); + + data->regmap =devm_regmap_init_mmio (dev, base, + &qcom_dwmac_sgmii_phy_regmap_cfg); +if (IS_ERR (data->regmap)) +return PTR_ERR (data->regmap); + + phy =devm_phy_create (dev,NULL , &qcom_dwmac_sgmii_phy_ops); +if (IS_ERR (phy)) +return PTR_ERR (phy); + + refclk =devm_clk_get_enabled (dev,"sgmi_ref" ); +if (IS_ERR (refclk)) +return PTR_ERR (refclk); + + provider =devm_of_phy_provider_register (dev, of_phy_simple_xlate); +if (IS_ERR (provider)) +return PTR_ERR (provider); + +phy_set_drvdata (phy, data); +platform_set_drvdata (pdev, data); + +return 0 ; +} + +static const struct of_device_id qcom_dwmac_sgmii_phy_of_match[] = { + { .compatible ="qcom,sa8775p-dwmac-sgmii-phy" }, + { }, +}; +MODULE_DEVICE_TABLE (of, qcom_dwmac_sgmii_phy_of_match); + +static struct platform_driver qcom_dwmac_sgmii_phy_driver = { + .probe = qcom_dwmac_sgmii_phy_probe, + .driver = { + .name ="qcom-dwmac-sgmii-phy" , + .of_match_table = qcom_dwmac_sgmii_phy_of_match, + } +}; + +module_platform_driver (qcom_dwmac_sgmii_phy_driver); + +MODULE_DESCRIPTION ("Qualcomm DWMAC SGMII PHY driver" ); +MODULE_LICENSE ("GPL" );
RE: [PATCH 18/26] net: stmmac: add new switch to struct plat_stmmacenet_data
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
Date: Mon, Jun 12, 2023 at 10:23:47
Quoted 38 lines
From: Bartosz Golaszewski <[email protected]>
On some platforms, the PCS can be integrated in the MAC so the driver will not see any PCS link activity. Add a switch that allows the platform drivers to let the core code know.
Signed-off-by Bartosz Golaszewski <[email protected]>--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +- include/linux/stmmac.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1
-1@@ -5793,7 +5793,7 @@ static void stmmac_common_interrupt(struct stmmac_priv *priv) }/* PCS link status */ -if (priv->hw->pcs) { +if (priv->hw->pcs && !priv->plat->has_integrated_pcs) {if (priv->xstats.pcs_link)netif_carrier_on (priv->dev);else include/linux/stmmac.h +1
-0@@ -293,5 +293,6 @@ struct plat_stmmacenet_data {bool sph_disable;bool serdes_up_after_phy_linkup;const struct dwmac4_addrs *dwmac4_addrs; + bool has_integrated_pcs; };#endif Signature · 1 line
2.39.2
We should eventually consider changing some elements of this struct to a bit-field.
Thanks,
Jose
Signature · 3 lines
linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
Re: [PATCH 01/26] phy: qualcomm: fix indentation in Makefile
In reply to Bartosz GolaszewskiQuoted 5 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
Align all entries in
Makefile.Signed-off-by Bartosz Golaszewski <[email protected]>
Quoted 17 lines
--- drivers/phy/qualcomm/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/phy/qualcomm/Makefile +1
-1@@ -20,4 +20,4 @@ obj-$(CONFIG_PHY_QCOM_USB_HSIC) += phy-qcom-usb-hsic.o obj-$(CONFIG_PHY_QCOM_USB_HS_28NM) += phy-qcom-usb-hs-28nm.o obj-$(CONFIG_PHY_QCOM_USB_SS) += phy-qcom-usb-ss.o obj-$(CONFIG_PHY_QCOM_USB_SNPS_FEMTO_V2)+= phy-qcom-snps-femto-v2.o -obj-$(CONFIG_PHY_QCOM_IPQ806X_USB) += phy-qcom-ipq806x-usb.o +obj-$(CONFIG_PHY_QCOM_IPQ806X_USB) += phy-qcom-ipq806x-usb.oSignature · 1 line
2.39.2
Re: [PATCH 05/26] net: stmmac: dwmac-qcom-ethqos: shrink clock code with devres
In reply to Bartosz GolaszewskiQuoted 7 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
We can use a devm action to completely drop the remove callback and use
stmmac_pltfr_remove()directly for remove. We can also drop one of the goto labels.Signed-off-by Bartosz Golaszewski <[email protected]>
I think using the remove callback seems more direct to a reader, but that's pretty opinionated. The change itself looks good so:
Quoted 72 lines
--- .../stmicro/stmmac/dwmac-qcom-ethqos.c | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-)drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +11
-13@@ -586,6 +586,11 @@ static int ethqos_clks_config(void *priv, bool enabled)return ret; } +static void ethqos_clks_disable (void *data) +{ +ethqos_clks_config (data, false); +} +static int qcom_ethqos_probe (struct platform_device *pdev) {struct device_node *np = pdev->dev.of_node;@@ -636,6 +641,10 @@ static int qcom_ethqos_probe(struct platform_device *pdev)if (ret) goto err_mem; + ret =devm_add_action_or_reset (&pdev->dev, ethqos_clks_disable, ethqos); +if (ret) + goto err_mem; + ethqos->speed =SPEED_1000 ;ethqos_update_rgmii_clk (ethqos,SPEED_1000 );ethqos_set_func_clk_en (ethqos);@@ -653,27 +662,16 @@ static int qcom_ethqos_probe(struct platform_device *pdev) ret =stmmac_dvr_probe (&pdev->dev, plat_dat, &stmmac_res);if (ret) - goto err_clk; + goto err_mem;return ret; -err_clk: -ethqos_clks_config (ethqos, false); - err_mem:stmmac_remove_config_dt (pdev, plat_dat);return ret; } -static void qcom_ethqos_remove (struct platform_device *pdev) -{ -struct qcom_ethqos *ethqos =get_stmmac_bsp_priv (&pdev->dev); - -stmmac_pltfr_remove (pdev); -ethqos_clks_config (ethqos, false); -} -static const struct of_device_id qcom_ethqos_match[] = { { .compatible ="qcom,qcs404-ethqos" , .data = &emac_v2_3_0_data}, { .compatible ="qcom,sc8280xp-ethqos" , .data = &emac_v3_0_0_data},@@ -684,7 +682,7 @@ MODULE_DEVICE_TABLE(of, qcom_ethqos_match);static struct platform_driver qcom_ethqos_driver = { .probe = qcom_ethqos_probe, - .remove_new = qcom_ethqos_remove, + .remove_new = stmmac_pltfr_remove, .driver = { .name ="qcom-ethqos" , .pm = &stmmac_pltfr_pm_ops,Signature · 1 line
2.39.2
Signature · 3 lines
linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
Re: [PATCH 06/26] net: stmmac: dwmac-qcom-ethqos: rename a label in probe()
In reply to Bartosz GolaszewskiQuoted 7 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
The
err_memlabel's name is unclear. It actually should be reached on any error afterstmmac_probe_config_dt()succeeds. Name it after the cleanup action that needs to be called before exiting.Signed-off-by Bartosz Golaszewski <[email protected]>
Quoted 62 lines
--- .../ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +7
-7@@ -615,14 +615,14 @@ static int qcom_ethqos_probe(struct platform_device *pdev) ethqos =devm_kzalloc (&pdev->dev,sizeof (*ethqos),GFP_KERNEL );if (!ethqos) { ret = -ENOMEM ; - goto err_mem; + goto out_config_dt; } ethqos->pdev = pdev; ethqos->rgmii_base =devm_platform_ioremap_resource_byname (pdev,"rgmii" );if (IS_ERR (ethqos->rgmii_base)) { ret =PTR_ERR (ethqos->rgmii_base); - goto err_mem; + goto out_config_dt; } data =of_device_get_match_data (&pdev->dev);@@ -634,16 +634,16 @@ static int qcom_ethqos_probe(struct platform_device *pdev) ethqos->rgmii_clk =devm_clk_get (&pdev->dev,"rgmii" );if (IS_ERR (ethqos->rgmii_clk)) { ret =PTR_ERR (ethqos->rgmii_clk); - goto err_mem; + goto out_config_dt; } ret =ethqos_clks_config (ethqos, true);if (ret) - goto err_mem; + goto out_config_dt; ret =devm_add_action_or_reset (&pdev->dev, ethqos_clks_disable, ethqos);if (ret) - goto err_mem; + goto out_config_dt; ethqos->speed =SPEED_1000 ;ethqos_update_rgmii_clk (ethqos,SPEED_1000 );@@ -662,11 +662,11 @@ static int qcom_ethqos_probe(struct platform_device *pdev) ret =stmmac_dvr_probe (&pdev->dev, plat_dat, &stmmac_res);if (ret) - goto err_mem; + goto out_config_dt;return ret; -err_mem: +out_config_dt:stmmac_remove_config_dt (pdev, plat_dat);return ret;Signature · 1 line
2.39.2
Signature · 3 lines
linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
Re: [PATCH 07/26] net: stmmac: dwmac-qcom-ethqos: tweak the order of local variables
In reply to Bartosz GolaszewskiQuoted 5 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
Make sure we follow the reverse-xmas tree convention.
Signed-off-by Bartosz Golaszewski <[email protected]>
Quoted 22 lines
--- drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +1
-1@@ -594,9 +594,9 @@ static void ethqos_clks_disable(void *data)static int qcom_ethqos_probe (struct platform_device *pdev) {struct device_node *np = pdev->dev.of_node; +const struct ethqos_emac_driver_data *data;struct plat_stmmacenet_data *plat_dat;struct stmmac_resources stmmac_res; -const struct ethqos_emac_driver_data *data;struct qcom_ethqos *ethqos;int ret;Signature · 1 line
2.39.2
Signature · 3 lines
linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
Re: [PATCH 08/26] net: stmmac: dwmac-qcom-ethqos: use a helper variable for &pdev->dev
In reply to Bartosz GolaszewskiQuoted 93 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
Shrink code and avoid line breaks by using a helper variable for
&pdev->dev.Signed-off-by Bartosz Golaszewski <[email protected]>--- .../stmicro/stmmac/dwmac-qcom-ethqos.c | 48 ++++++++++--------- 1 file changed, 26 insertions(+), 22 deletions(-)drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +16
-13@@ -123,25 +123,26 @@ static void rgmii_updatel(struct qcom_ethqos *ethqos,static void rgmii_dump (void *priv) {struct qcom_ethqos *ethqos = priv; +struct device *dev = ðqos->pdev->dev; -dev_dbg (ðqos->pdev->dev,"Rgmii register dump\n" ); -dev_dbg (ðqos->pdev->dev,"RGMII_IO_MACRO_CONFIG: %x\n" , +dev_dbg (dev,"Rgmii register dump\n" ); +dev_dbg (dev,"RGMII_IO_MACRO_CONFIG: %x\n" ,rgmii_readl (ethqos,RGMII_IO_MACRO_CONFIG )); -dev_dbg (ðqos->pdev->dev,"SDCC_HC_REG_DLL_CONFIG: %x\n" , +dev_dbg (dev,"SDCC_HC_REG_DLL_CONFIG: %x\n" ,rgmii_readl (ethqos,SDCC_HC_REG_DLL_CONFIG )); -dev_dbg (ðqos->pdev->dev,"SDCC_HC_REG_DDR_CONFIG: %x\n" , +dev_dbg (dev,"SDCC_HC_REG_DDR_CONFIG: %x\n" ,rgmii_readl (ethqos,SDCC_HC_REG_DDR_CONFIG )); -dev_dbg (ðqos->pdev->dev,"SDCC_HC_REG_DLL_CONFIG2: %x\n" , +dev_dbg (dev,"SDCC_HC_REG_DLL_CONFIG2: %x\n" ,rgmii_readl (ethqos,SDCC_HC_REG_DLL_CONFIG2 )); -dev_dbg (ðqos->pdev->dev,"SDC4_STATUS: %x\n" , +dev_dbg (dev,"SDC4_STATUS: %x\n" ,rgmii_readl (ethqos,SDC4_STATUS )); -dev_dbg (ðqos->pdev->dev,"SDCC_USR_CTL: %x\n" , +dev_dbg (dev,"SDCC_USR_CTL: %x\n" ,rgmii_readl (ethqos,SDCC_USR_CTL )); -dev_dbg (ðqos->pdev->dev,"RGMII_IO_MACRO_CONFIG2: %x\n" , +dev_dbg (dev,"RGMII_IO_MACRO_CONFIG2: %x\n" ,rgmii_readl (ethqos,RGMII_IO_MACRO_CONFIG2 )); -dev_dbg (ðqos->pdev->dev,"RGMII_IO_MACRO_DEBUG1: %x\n" , +dev_dbg (dev,"RGMII_IO_MACRO_DEBUG1: %x\n" ,rgmii_readl (ethqos,RGMII_IO_MACRO_DEBUG1 )); -dev_dbg (ðqos->pdev->dev,"EMAC_SYSTEM_LOW_POWER_DEBUG: %x\n" , +dev_dbg (dev,"EMAC_SYSTEM_LOW_POWER_DEBUG: %x\n" ,rgmii_readl (ethqos,EMAC_SYSTEM_LOW_POWER_DEBUG )); }@@ -242,6 +243,7 @@ static const struct ethqos_emac_driver_data emac_v3_0_0_data = {static int ethqos_dll_configure (struct qcom_ethqos *ethqos) { +struct device *dev = ðqos->pdev->dev;unsigned int val;int retry =1000 ;@@ -279,7 +281,7 @@ static int ethqos_dll_configure(struct qcom_ethqos *ethqos) retry--; }while (retry >0 );if (!retry) -dev_err (ðqos->pdev->dev,"Clear CK_OUT_EN timedout\n" ); +dev_err (dev,"Clear CK_OUT_EN timedout\n" );/* Set CK_OUT_EN */ rgmii_updatel(ethqos, SDCC_DLL_CONFIG_CK_OUT_EN,@@ -296,7 +298,7 @@ static int ethqos_dll_configure(struct qcom_ethqos *ethqos) retry--; }while (retry >0 );if (!retry) -dev_err (ðqos->pdev->dev,"Set CK_OUT_EN timedout\n" ); +dev_err (dev,"Set CK_OUT_EN timedout\n" );/* Set DDR_CAL_EN */ rgmii_updatel(ethqos, SDCC_DLL_CONFIG2_DDR_CAL_EN,@@ -322,12 +324,13 @@ static int ethqos_dll_configure(struct qcom_ethqos *ethqos)static int ethqos_rgmii_macro_init (struct qcom_ethqos *ethqos) { +struct device *dev = ðqos->pdev->dev;int phase_shift;int phy_mode;int loopback;/* Determine if the PHY adds a 2 ns TX delay or the MAC handles it */ - phy_mode =device_get_phy_mode (ðqos->pdev->dev); + phy_mode =device_get_phy_mode (dev);if (phy_mode ==PHY_INTERFACE_MODE_RGMII_ID || phy_mode ==PHY_INTERFACE_MODE_RGMII_TXID ) phase_shift =0 ;
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c static int ethqos_rgmii_macro_init(struct qcom_ethqos *ethqos) · line 475
Quoted 6 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +1
-1@@ -468,7 +471,7 @@ static int ethqos_rgmii_macro_init(struct qcom_ethqos *ethqos) loopback, RGMII_IO_MACRO_CONFIG);break ;default : -dev_err (ðqos->pdev->dev, +dev_err (dev,"Invalid speed %d\n" , ethqos->speed);
nit: You could put this on the prior line now
With that in place, feel free to add:
Re: [PATCH 09/26] net: stmmac: dwmac-qcom-ethqos: add missing include
In reply to Bartosz GolaszewskiQuoted 6 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
device_get_phy_mode()is declared inlinux/property.hbut this header is not included.Signed-off-by Bartosz Golaszewski <[email protected]>
Quoted 19 lines
--- drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 1 + 1 file changed, 1 insertion(+)drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +1
-0@@ -6,6 +6,7 @@#include <linux/of_device.h> #include <linux/platform_device.h> #include <linux/phy.h> +#include <linux/property.h> #include "stmmac.h" #include "stmmac_platform.h" Signature · 1 line
2.39.2
Signature · 3 lines
linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
Re: [PATCH 10/26] net: stmmac: dwmac-qcom-ethqos: add a newline between headers
In reply to Bartosz GolaszewskiQuoted 6 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
Typically we use a newline between global and local headers so add it here as well.
Signed-off-by Bartosz Golaszewski <[email protected]>
Quoted 19 lines
--- drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 1 + 1 file changed, 1 insertion(+)drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +1
-0@@ -7,6 +7,7 @@#include <linux/platform_device.h> #include <linux/phy.h> #include <linux/property.h> +#include "stmmac.h" #include "stmmac_platform.h" Signature · 1 line
2.39.2
Re: [PATCH 11/26] net: stmmac: dwmac-qcom-ethqos: remove stray space
In reply to Bartosz GolaszewskiQuoted 5 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
There's an unnecessary space in the
rgmii_updatel()function, remove it.Signed-off-by Bartosz Golaszewski <[email protected]>
Quoted 20 lines
--- drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +1
-1@@ -117,7 +117,7 @@ static void rgmii_updatel(struct qcom_ethqos *ethqos, {unsigned int temp; - temp =rgmii_readl (ethqos, offset); + temp =rgmii_readl (ethqos, offset); temp = (temp & ~(mask)) | val;rgmii_writel (ethqos, temp, offset); }Signature · 1 line
2.39.2
Re: [PATCH 12/26] net: stmmac: dwmac-qcom-ethqos: add support for the optional serdes phy
In reply to Bartosz GolaszewskiQuoted 38 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
On sa8775p platforms, there's a SGMII SerDes PHY between the MAC and external PHY that we need to enable and configure.
Signed-off-by Bartosz Golaszewski <[email protected]>--- .../stmicro/stmmac/dwmac-qcom-ethqos.c | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+)drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +6
-0@@ -6,6 +6,7 @@#include <linux/of_device.h> #include <linux/platform_device.h> #include <linux/phy.h> +#include <linux/phy/phy.h> #include <linux/property.h> #include "stmmac.h" @@ -93,6 +94,7 @@ struct qcom_ethqos {unsigned int rgmii_clk_rate;struct clk *rgmii_clk; +struct phy *serdes_phy;unsigned int speed;const struct ethqos_emac_por *por;@@ -566,6 +568,30 @@ static void ethqos_fix_mac_speed(void *priv, unsigned int speed)ethqos_configure (ethqos); } +static int qcom_ethqos_serdes_powerup (struct net_device *ndev,void *priv) +{ +struct qcom_ethqos *ethqos = priv; +int ret;
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c static void ethqos_fix_mac_speed(void *priv, unsigned int speed) · line 584
Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +10
-0+ + ret =phy_set_speed (ethqos->serdes_phy, ethqos->speed); +if (ret) +return ret; + + ret =phy_init (ethqos->serdes_phy); +if (ret) +return ret; + +return phy_power_on (ethqos->serdes_phy);
The docs say (phy.rst):
The general order of calls should be::
[devm_][of_]phy_get()
phy_init()
phy_power_on()
[phy_set_mode[_ext]()]
...
phy_power_off()
phy_exit()
[[of_]phy_put()]
Some PHY drivers may not implement :c:func:phy_init or :c:func:phy_power_on, but controllers should always call these functions to be compatible with other PHYs. Some PHYs may require :c:func:phy_set_mode <phy_set_mode_ext>, while others may use a default mode (typically configured via devicetree or other firmware). For compatibility, you should always call this function if you know what mode you will be using. Generally, this function should be called after :c:func:phy_power_on, although some PHY drivers may allow it at any time.
Not really dictating you need to do that order, but if possible I think calling phy_set_speed after init + power_on is more generic. Not sure if that plays nice with the phy driver in this series or not.
Otherwise, I think this looks good.
Quoted 41 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +21
-0+} + +static void qcom_ethqos_serdes_powerdown (struct net_device *ndev,void *priv) +{ +struct qcom_ethqos *ethqos = priv; + +phy_power_off (ethqos->serdes_phy); +phy_exit (ethqos->serdes_phy); +} +static int ethqos_clks_config (void *priv,bool enabled) {struct qcom_ethqos *ethqos = priv;@@ -651,6 +677,12 @@ static int qcom_ethqos_probe(struct platform_device *pdev)if (ret) goto out_config_dt; + ethqos->serdes_phy =devm_phy_optional_get (dev,"serdes" ); +if (IS_ERR (ethqos->serdes_phy)) { + ret =PTR_ERR (ethqos->serdes_phy); + goto out_config_dt; + } + ethqos->speed =SPEED_1000 ;ethqos_update_rgmii_clk (ethqos,SPEED_1000 );ethqos_set_func_clk_en (ethqos);@@ -666,6 +698,11 @@ static int qcom_ethqos_probe(struct platform_device *pdev)if (of_device_is_compatible (np,"qcom,qcs404-ethqos" )) plat_dat->rx_clk_runs_in_lpi =1 ; +if (ethqos->serdes_phy) { + plat_dat->serdes_powerup = qcom_ethqos_serdes_powerup; + plat_dat->serdes_powerdown = qcom_ethqos_serdes_powerdown; + } + ret =stmmac_dvr_probe (dev, plat_dat, &stmmac_res);if (ret) goto out_config_dt;Signature · 1 line
2.39.2
Re: [PATCH 13/26] net: stmmac: dwmac-qcom-ethqos: make the rgmii clock optional
In reply to Bartosz GolaszewskiQuoted 14 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
On sa8775p there's no RGMII clock so make it optional in the driver.
Signed-off-by Bartosz Golaszewski <[email protected]>--- drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +0
-0
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c static int qcom_ethqos_probe(struct platform_device *pdev) · line 666
Quoted 5 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +1
-1@@ -663,7 +663,7 @@ static int qcom_ethqos_probe(struct platform_device *pdev) ethqos->rgmii_config_loopback_en = data->rgmii_config_loopback_en; ethqos->has_emac3 = data->has_emac3; - ethqos->rgmii_clk =devm_clk_get (dev,"rgmii" ); + ethqos->rgmii_clk =devm_clk_get_optional (dev,"rgmii" );
This makes it optional for older platforms too, but as far as I know on those platforms it is mandatory.
This can be enforced in dt-binding checks, but should we also enforce that in the driver still? Honestly I feel like yes, but there's probably some precedent maintainers follow on this front that I don't know of.
Quoted 6 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +0
-0if (IS_ERR (ethqos->rgmii_clk)) { ret =PTR_ERR (ethqos->rgmii_clk); goto out_config_dt;Signature · 1 line
2.39.2
Re: [PATCH 14/26] net: stmmac: dwmac-qcom-ethqos: add optional phyaux clock
In reply to Bartosz GolaszewskiQuoted 45 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
On sa8775p we don't use the RGMII clock but have an additional PHYAUX clock so add support for it to the driver.
Signed-off-by Bartosz Golaszewski <[email protected]>--- .../ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +9
-0@@ -94,6 +94,7 @@ struct qcom_ethqos {unsigned int rgmii_clk_rate;struct clk *rgmii_clk; +struct clk *phyaux_clk;struct phy *serdes_phy;unsigned int speed;@@ -604,6 +605,13 @@ static int ethqos_clks_config(void *priv, bool enabled)return ret; } + ret =clk_prepare_enable (ethqos->phyaux_clk); +if (ret) { +clk_disable_unprepare (ethqos->rgmii_clk); +dev_err (ðqos->pdev->dev,"phyaux enable failed\n" ); +return ret; + } +/* Enable functional clock to prevent DMA reset to timeout due * to lacking PHY clock after the hardware block has been power * cycled. The actual configuration will be adjusted once @@ -611,6 +619,7 @@ static int ethqos_clks_config(void *priv, bool enabled)*/ ethqos_set_func_clk_en (ethqos); }else { +clk_disable_unprepare (ethqos->phyaux_clk);clk_disable_unprepare (ethqos->rgmii_clk); }
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c static int qcom_ethqos_probe(struct platform_device *pdev) · line 686
Quoted 9 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +6
-0@@ -669,6 +678,12 @@ static int qcom_ethqos_probe(struct platform_device *pdev) goto out_config_dt; } + ethqos->phyaux_clk =devm_clk_get_optional (dev,"phyaux" ); +if (IS_ERR (ethqos->phyaux_clk)) { + ret =PTR_ERR (ethqos->phyaux_clk); + goto out_config_dt; + } +
Similar comment to the prior patch about whether or not this should be optional (or selected via platform compatible and required), otherwise looks good.
Quoted 6 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +0
-0ret =ethqos_clks_config (ethqos, true);if (ret) goto out_config_dt;Signature · 1 line
2.39.2
Signature · 3 lines
linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
Re: [PATCH 15/26] net: stmmac: dwmac-qcom-ethqos: add support for the optional phy-supply
In reply to Bartosz GolaszewskiQuoted 3 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
On sa8775p-ride we need to enable the power supply for the external PHY.
Is this for the external phy? It doesn't seem like it from the board schematic I have... the regulator never makes it out of the black box that is the SIP/SOM if I'm reading right.
My (poor) understanding was this was for the serdes phy that's doing the conversion to SGMII before hitting the board... good chance I'm wrong though.
Quoted 32 lines
Signed-off-by Bartosz Golaszewski <[email protected]>--- drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +5
-0@@ -8,6 +8,7 @@#include <linux/phy.h> #include <linux/phy/phy.h> #include <linux/property.h> +#include <linux/regulator/consumer.h> #include "stmmac.h" #include "stmmac_platform.h" @@ -692,6 +693,10 @@ static int qcom_ethqos_probe(struct platform_device *pdev)if (ret) goto out_config_dt; + ret =devm_regulator_get_enable_optional (dev,"phy" ); +if (ret <0 && ret != -ENODEV ) + goto out_config_dt; + ethqos->serdes_phy =devm_phy_optional_get (dev,"serdes" );if (IS_ERR (ethqos->serdes_phy)) { ret =PTR_ERR (ethqos->serdes_phy);Signature · 1 line
2.39.2
Re: [PATCH 12/26] net: stmmac: dwmac-qcom-ethqos: add support for the optional serdes phy
In reply to Andrew HalaneyQuoted 72 lines · Andrew Halaney
Quoted 38 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
On sa8775p platforms, there's a SGMII SerDes PHY between the MAC and external PHY that we need to enable and configure.
Signed-off-by Bartosz Golaszewski <[email protected]>--- .../stmicro/stmmac/dwmac-qcom-ethqos.c | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+)drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +6
-0@@ -6,6 +6,7 @@#include <linux/of_device.h> #include <linux/platform_device.h> #include <linux/phy.h> +#include <linux/phy/phy.h> #include <linux/property.h> #include "stmmac.h" @@ -93,6 +94,7 @@ struct qcom_ethqos {unsigned int rgmii_clk_rate;struct clk *rgmii_clk; +struct phy *serdes_phy;unsigned int speed;const struct ethqos_emac_por *por;@@ -566,6 +568,30 @@ static void ethqos_fix_mac_speed(void *priv, unsigned int speed)ethqos_configure (ethqos); } +static int qcom_ethqos_serdes_powerup (struct net_device *ndev,void *priv) +{ +struct qcom_ethqos *ethqos = priv; +int ret;drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c static void ethqos_fix_mac_speed(void *priv, unsigned int speed) · line 584
Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +10
-0+ + ret =phy_set_speed (ethqos->serdes_phy, ethqos->speed); +if (ret) +return ret; + + ret =phy_init (ethqos->serdes_phy); +if (ret) +return ret; + +return phy_power_on (ethqos->serdes_phy);The docs say (
phy.rst):The general order of calls should be::
[devm_][of_]phy_get()
phy_init()
phy_power_on()
[phy_set_mode[_ext]()]
...
phy_power_off()
phy_exit()
[[of_]phy_put()]Some PHY drivers may not implement :c:func:
phy_initor :c:func:phy_power_on, but controllers should always call these functions to be compatible with other PHYs. Some PHYs may require :c:func:phy_set_mode <phy_set_mode_ext>, while others may use a default mode (typically configured via devicetree or other firmware). For compatibility, you should always call this function if you know what mode you will be using. Generally, this function should be called after :c:func:phy_power_on, although some PHY drivers may allow it at any time.
Quoted 6 lines
Not really dictating you need to do that order, but if possible I think calling
phy_set_speedafter init +power_onis more generic. Not sure if that plays nice with the phy driver in this series or not.Otherwise, I think this looks good.
I had to rework the PHY driver code a bit for this order to work but it'll be good now in v2.
Thanks!
Bart
Quoted 42 lines
Quoted 41 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +21
-1+} + +static void qcom_ethqos_serdes_powerdown (struct net_device *ndev,void *priv) +{ +struct qcom_ethqos *ethqos = priv; + +phy_power_off (ethqos->serdes_phy); +phy_exit (ethqos->serdes_phy); +} +static int ethqos_clks_config (void *priv,bool enabled) {struct qcom_ethqos *ethqos = priv;@@ -651,6 +677,12 @@ static int qcom_ethqos_probe(struct platform_device *pdev)if (ret) goto out_config_dt; + ethqos->serdes_phy =devm_phy_optional_get (dev,"serdes" ); +if (IS_ERR (ethqos->serdes_phy)) { + ret =PTR_ERR (ethqos->serdes_phy); + goto out_config_dt; + } + ethqos->speed =SPEED_1000 ;ethqos_update_rgmii_clk (ethqos,SPEED_1000 );ethqos_set_func_clk_en (ethqos);@@ -666,6 +698,11 @@ static int qcom_ethqos_probe(struct platform_device *pdev)if (of_device_is_compatible (np,"qcom,qcs404-ethqos" )) plat_dat->rx_clk_runs_in_lpi =1 ; +if (ethqos->serdes_phy) { + plat_dat->serdes_powerup = qcom_ethqos_serdes_powerup; + plat_dat->serdes_powerdown = qcom_ethqos_serdes_powerdown; + } + ret =stmmac_dvr_probe (dev, plat_dat, &stmmac_res);if (ret) goto out_config_dt; --2.39.2
Re: [PATCH 13/26] net: stmmac: dwmac-qcom-ethqos: make the rgmii clock optional
In reply to Andrew HalaneyQuoted 25 lines · Andrew Halaney
Quoted 14 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
On sa8775p there's no RGMII clock so make it optional in the driver.
Signed-off-by Bartosz Golaszewski <[email protected]>--- drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +0
-0drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c static int qcom_ethqos_probe(struct platform_device *pdev) · line 666
Quoted 5 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +1
-1@@ -663,7 +663,7 @@ static int qcom_ethqos_probe(struct platform_device *pdev) ethqos->rgmii_config_loopback_en = data->rgmii_config_loopback_en; ethqos->has_emac3 = data->has_emac3; - ethqos->rgmii_clk =devm_clk_get (dev,"rgmii" ); + ethqos->rgmii_clk =devm_clk_get_optional (dev,"rgmii" );This makes it optional for older platforms too, but as far as I know on those platforms it is mandatory.
Quoted 4 lines
This can be enforced in dt-binding checks, but should we also enforce that in the driver still? Honestly I feel like yes, but there's probably some precedent maintainers follow on this front that I don't know of.
While my gut feeling is that enforcing the clock list on the DT binding lever is enough, we can also do a different thing: rename the clock from rgmii_clk to link_clk or something similar and just determine the name based on the HW variant ("rgmii" or "phyaux"). Or even get the clock by its index? this way we could fold the next patch in the series into this one and simplify the code.
Bart
Quoted 8 lines
Quoted 7 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +0
-1if (IS_ERR (ethqos->rgmii_clk)) { ret =PTR_ERR (ethqos->rgmii_clk); goto out_config_dt; --2.39.2
Signature · 3 lines
linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
Re: [PATCH 15/26] net: stmmac: dwmac-qcom-ethqos: add support for the optional phy-supply
In reply to Andrew HalaneyQuoted 6 lines · Andrew Halaney
Quoted 3 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
On sa8775p-ride we need to enable the power supply for the external PHY.
Quoted 8 lines
Is this for the external phy? It doesn't seem like it from the board schematic I have... the regulator never makes it out of the black box that is the SIP/SOM if I'm reading right.
My (poor) understanding was this was for the serdes phy that's doing the conversion to SGMII before hitting the board... good chance I'm wrong though.
No, you're right. In which case I think the regulator calls should be moved into the serdes driver instead as phy-supply is defined as the supply of the external PHY in stmmac bindings.
Bart
Quoted 33 lines
Quoted 32 lines
Signed-off-by Bartosz Golaszewski <[email protected]>--- drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +5
-1@@ -8,6 +8,7 @@#include <linux/phy.h> #include <linux/phy/phy.h> #include <linux/property.h> +#include <linux/regulator/consumer.h> #include "stmmac.h" #include "stmmac_platform.h" @@ -692,6 +693,10 @@ static int qcom_ethqos_probe(struct platform_device *pdev)if (ret) goto out_config_dt; + ret =devm_regulator_get_enable_optional (dev,"phy" ); +if (ret <0 && ret != -ENODEV ) + goto out_config_dt; + ethqos->serdes_phy =devm_phy_optional_get (dev,"serdes" );if (IS_ERR (ethqos->serdes_phy)) { ret =PTR_ERR (ethqos->serdes_phy); --2.39.2
Signature · 3 lines
linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
Re: [PATCH 16/26] net: stmmac: dwmac-qcom-ethqos: prepare the driver for more PHY modes
In reply to Bartosz GolaszewskiQuoted 7 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
In preparation for supporting SGMII, let's make the code a bit more generic. Add a new callback for MAC configuration so that we can assign a different variant of it in the future.
Signed-off-by Bartosz Golaszewski <[email protected]>
Quoted 86 lines
--- .../stmicro/stmmac/dwmac-qcom-ethqos.c | 31 ++++++++++++++++--- 1 file changed, 26 insertions(+), 5 deletions(-)drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +26
-5@@ -92,12 +92,14 @@ struct ethqos_emac_driver_data {struct qcom_ethqos {struct platform_device *pdev;void __iomem *rgmii_base; +int (*configure_func)(struct qcom_ethqos *ethqos);unsigned int rgmii_clk_rate;struct clk *rgmii_clk;struct clk *phyaux_clk;struct phy *serdes_phy;unsigned int speed; +int phy_mode;const struct ethqos_emac_por *por;unsigned int num_por;@@ -332,13 +334,11 @@ static int ethqos_rgmii_macro_init(struct qcom_ethqos *ethqos) {struct device *dev = ðqos->pdev->dev;int phase_shift; -int phy_mode;int loopback;/* Determine if the PHY adds a 2 ns TX delay or the MAC handles it */ - phy_mode =device_get_phy_mode (dev); -if (phy_mode ==PHY_INTERFACE_MODE_RGMII_ID || - phy_mode ==PHY_INTERFACE_MODE_RGMII_TXID ) +if (ethqos->phy_mode ==PHY_INTERFACE_MODE_RGMII_ID || + ethqos->phy_mode ==PHY_INTERFACE_MODE_RGMII_TXID ) phase_shift =0 ;else phase_shift =RGMII_CONFIG2_TX_CLK_PHASE_SHIFT_EN ;@@ -485,7 +485,7 @@ static int ethqos_rgmii_macro_init(struct qcom_ethqos *ethqos)return 0 ; } -static int ethqos_configure (struct qcom_ethqos *ethqos) +static int ethqos_configure_rgmii (struct qcom_ethqos *ethqos) {struct device *dev = ðqos->pdev->dev;volatile unsigned int dll_lock;@@ -561,6 +561,11 @@ static int ethqos_configure(struct qcom_ethqos *ethqos)return 0 ; } +static int ethqos_configure (struct qcom_ethqos *ethqos) +{ +return ethqos->configure_func (ethqos); +} +static void ethqos_fix_mac_speed (void *priv,unsigned int speed) {struct qcom_ethqos *ethqos = priv;@@ -660,6 +665,22 @@ static int qcom_ethqos_probe(struct platform_device *pdev) goto out_config_dt; } + ethqos->phy_mode =device_get_phy_mode (dev); +switch (ethqos->phy_mode) { +case PHY_INTERFACE_MODE_RGMII : +case PHY_INTERFACE_MODE_RGMII_ID : +case PHY_INTERFACE_MODE_RGMII_RXID : +case PHY_INTERFACE_MODE_RGMII_TXID : + ethqos->configure_func = ethqos_configure_rgmii; +break ; +case -ENODEV : + ret = -ENODEV ; + goto out_config_dt; +default : + ret = -EINVAL ; + goto out_config_dt; + } + ethqos->pdev = pdev; ethqos->rgmii_base =devm_platform_ioremap_resource_byname (pdev,"rgmii" );if (IS_ERR (ethqos->rgmii_base)) {Signature · 1 line
2.39.2
Bjorn Andersson
maintainerRe: [PATCH 03/26] phy: qcom: add the SGMII SerDes PHY driver
In reply to Bartosz GolaszewskiQuoted 1 line · Bartosz Golaszewski
drivers/phy/qualcomm/phy-qcom-sgmii-eth.c +0
-0
[..]
Quoted 26 lines
drivers/phy/qualcomm/phy-qcom-sgmii-eth.c +26
-0+static int qcom_dwmac_sgmii_phy_probe (struct platform_device *pdev) +{ +struct qcom_dwmac_sgmii_phy_data *data; +struct device *dev = &pdev->dev; +struct phy_provider *provider; +struct clk *refclk; +void __iomem *base; +struct phy *phy; + + data =devm_kzalloc (dev,sizeof (*data),GFP_KERNEL ); +if (!data) +return -ENOMEM ; + + base =devm_platform_ioremap_resource (pdev,0 ); +if (IS_ERR (base)) +return PTR_ERR (base); + + data->regmap =devm_regmap_init_mmio (dev, base, + &qcom_dwmac_sgmii_phy_regmap_cfg); +if (IS_ERR (data->regmap)) +return PTR_ERR (data->regmap); + + phy =devm_phy_create (dev,NULL , &qcom_dwmac_sgmii_phy_ops); +if (IS_ERR (phy)) +return PTR_ERR (phy); +
drivers/phy/qualcomm/phy-qcom-sgmii-eth.c line 424
Quoted 10 lines
drivers/phy/qualcomm/phy-qcom-sgmii-eth.c +10
-0+ refclk =devm_clk_get_enabled (dev,"sgmi_ref" ); +if (IS_ERR (refclk)) +return PTR_ERR (refclk); + + provider =devm_of_phy_provider_register (dev, of_phy_simple_xlate); +if (IS_ERR (provider)) +return PTR_ERR (provider); + +phy_set_drvdata (phy, data); +platform_set_drvdata (pdev, data);
You don't use the pdev's dev's drvdata, so I think you can drop the platform_set_drvdata()
Regards,
Bjorn
Quoted 3 lines
drivers/phy/qualcomm/phy-qcom-sgmii-eth.c +3
-0+ +return 0 ; +}
Re: [PATCH 23/26] arm64: dts: qcom: sa8775p: add the first 1Gb ethernet interface
In reply to Bartosz GolaszewskiQuoted 19 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
Add the node for the first ethernet interface on sa8775p platforms.
Signed-off-by Bartosz Golaszewski <[email protected]>--- arch/arm64/boot/dts/qcom/sa8775p.dtsi | 30 +++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)arch/arm64/boot/dts/qcom/sa8775p.dtsi +2
-0@@ -2315,6 +2315,36 @@ cpufreq_hw: cpufreq@18591000 { #freq-domain-cells = <1>; }; + + ethernet0: ethernet@23040000 {
arch/arm64/boot/dts/qcom/sa8775p.dtsi cpufreq_hw: cpufreq@18591000 { · line 2329
Quoted 10 lines
arch/arm64/boot/dts/qcom/sa8775p.dtsi +10
-0+ compatible = "qcom,sa8775p-ethqos"; + reg = <0x0 0x23040000 0x0 0x10000>, + <0x0 0x23056000 0x0 0x100>; + reg-names = "stmmaceth", "rgmii"; + + clocks = <&gcc GCC_EMAC0_AXI_CLK>, + <&gcc GCC_EMAC0_SLV_AHB_CLK>, + <&gcc GCC_EMAC0_PTP_CLK>, + <&gcc GCC_EMAC0_PHY_AUX_CLK>; + clock-names = "stmmaceth", "pclk", "ptp_ref", "phyaux";
Please make this a vertical list, one per line
arch/arm64/boot/dts/qcom/sa8775p.dtsi cpufreq_hw: cpufreq@18591000 { · line 2334
Quoted 5 lines
arch/arm64/boot/dts/qcom/sa8775p.dtsi +5
-0+ + power-domains = <&gcc EMAC0_GDSC>; + + interrupts = <GIC_SPI 946 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "macirq";
And another nit, interrupts above clocks would match what I ask others to do.. Still working on checks/guidelines for this!
Konrad
Quoted 16 lines
arch/arm64/boot/dts/qcom/sa8775p.dtsi +13
-0+ + phys = <&serdes_phy>; + phy-names = "serdes"; + + iommus = <&apps_smmu 0x120 0xf>; + + snps,tso; + snps,pbl = <32>; + rx-fifo-depth = <16384>; + tx-fifo-depth = <16384>; + + status = "disabled"; + }; }; arch_timer: timer {
Signature · 3 lines
linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
Re: [PATCH 24/26] arm64: dts: qcom: sa8775p-ride: enable the SerDes PHY
In reply to Bartosz GolaszewskiQuoted 6 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
Enable the internal PHY on sa8775p-ride.
Signed-off-by Bartosz Golaszewski <[email protected]>---
---
Bjorn, Krzysztof.. I was thinking whether we should even be disabling such hardware by default..
Things that reside on the SoC and have no external dependencies could be left enabled:
pros:
- less fluff
- we'd probably very quickly fix the missing PM calls
- possibly less fw_devlink woes if we fail to get rid of references to the disabled component?
cons:
- boot times
- slightly more memory usage
Konrad
Quoted 18 lines
arch/arm64/boot/dts/qcom/sa8775p-ride.dts | 4 ++++ 1 file changed, 4 insertions(+)arch/arm64/boot/dts/qcom/sa8775p-ride.dts +4
-0@@ -355,6 +355,10 @@ &qupv3_id_2 { status = "okay"; }; +&serdes_phy { + status = "okay"; +}; + &sleep_clk { clock-frequency = <32764>; };
Re: [PATCH 25/26] arm64: dts: qcom: sa8775p-ride: add pin functions for ethernet0
In reply to Bartosz GolaszewskiQuoted 6 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
Add the MDC and MDIO pin functions for ethernet0 on sa8775p-ride.
Signed-off-by Bartosz Golaszewski <[email protected]>---
Konrad
Quoted 30 lines
arch/arm64/boot/dts/qcom/sa8775p-ride.dts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)arch/arm64/boot/dts/qcom/sa8775p-ride.dts +16
-0@@ -370,6 +370,22 @@ &spi16 { }; &tlmm { + ethernet0_default: ethernet0-default-state { + ethernet0_mdc: ethernet0-mdc-pins { + pins = "gpio8"; + function = "emac0_mdc"; + drive-strength = <16>; + bias-pull-up; + }; + + ethernet0_mdio: ethernet0-mdio-pins { + pins = "gpio9"; + function = "emac0_mdio"; + drive-strength = <16>; + bias-pull-up; + }; + }; + qup_uart10_default: qup-uart10-state { pins = "gpio46", "gpio47"; function = "qup1_se3";
Re: [PATCH 26/26] arm64: dts: qcom: sa8775p-ride: enable ethernet0
In reply to Bartosz GolaszewskiQuoted 6 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
Enable the first 1Gb ethernet port on sa8775p-ride development board.
Signed-off-by Bartosz Golaszewski <[email protected]>---
I don't know a whole lot about this, but it passes bindings checks and looks good overall, so:
Konrad
Quoted 103 lines
arch/arm64/boot/dts/qcom/sa8775p-ride.dts | 89 +++++++++++++++++++++++ 1 file changed, 89 insertions(+)arch/arm64/boot/dts/qcom/sa8775p-ride.dts +89
-0@@ -261,6 +261,95 @@ vreg_l8e: ldo8 { }; }; +ðernet0 { + phy-mode = "sgmii"; + phy-handle = <&sgmii_phy>; + phy-supply = <&vreg_l5a>; + + pinctrl-0 = <ðernet0_default>; + pinctrl-names = "default"; + + snps,mtl-rx-config = <&mtl_rx_setup>; + snps,mtl-tx-config = <&mtl_tx_setup>; + snps,ps-speed = <1000>; + + status = "okay"; + + mdio { + compatible = "snps,dwmac-mdio"; + #address-cells = <1>; + #size-cells = <0>; + + reset-gpios = <&pmm8654au_2_gpios 8 GPIO_ACTIVE_LOW>; + reset-delay-us = <11000>; + reset-post-delay-us = <70000>; + + sgmii_phy: phy@8 { + reg = <0x8>; + device_type = "ethernet-phy"; + }; + }; + + mtl_rx_setup: rx-queues-config { + snps,rx-queues-to-use = <4>; + snps,rx-sched-sp; + + queue0 { + snps,dcb-algorithm; + snps,map-to-dma-channel = <0x0>; + snps,route-up; + snps,priority = <0x1>; + }; + + queue1 { + snps,dcb-algorithm; + snps,map-to-dma-channel = <0x1>; + snps,route-ptp; + }; + + queue2 { + snps,avb-algorithm; + snps,map-to-dma-channel = <0x2>; + snps,route-avcp; + }; + + queue3 { + snps,avb-algorithm; + snps,map-to-dma-channel = <0x3>; + snps,priority = <0xc>; + }; + }; + + mtl_tx_setup: tx-queues-config { + snps,tx-queues-to-use = <4>; + snps,tx-sched-sp; + + queue0 { + snps,dcb-algorithm; + }; + + queue1 { + snps,dcb-algorithm; + }; + + queue2 { + snps,avb-algorithm; + snps,send_slope = <0x1000>; + snps,idle_slope = <0x1000>; + snps,high_credit = <0x3e800>; + snps,low_credit = <0xffc18000>; + }; + + queue3 { + snps,avb-algorithm; + snps,send_slope = <0x1000>; + snps,idle_slope = <0x1000>; + snps,high_credit = <0x3e800>; + snps,low_credit = <0xffc18000>; + }; + }; +}; + &i2c11 { clock-frequency = <400000>; pinctrl-0 = <&qup_i2c11_default>;
Re: [PATCH 02/26] dt-bindings: phy: describe the Qualcomm SGMII PHY
In reply to Bartosz GolaszewskiQuoted 15 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
Describe the SGMII/SerDes PHY present on the sa8775p platforms.
Signed-off-by Bartosz Golaszewski <[email protected]>Documentation/devicetree/bindings/phy/qcom,sa8775p-dwmac-sgmii-phy.yaml new file +8
-0+properties: + compatible: + const: qcom,sa8775p-dwmac-sgmii-phy + + reg: + items: + - description: serdes +
Documentation/devicetree/bindings/phy/qcom,sa8775p-dwmac-sgmii-phy.yaml line 33
Quoted 10 lines
Documentation/devicetree/bindings/phy/qcom,sa8775p-dwmac-sgmii-phy.yaml new file +10
-0+ clocks: + maxItems: 1 + + clock-names: + const: sgmi_ref + + "#phy-cells": + const: 0 + +additionalProperties: false
Please put it after required: block.
Quoted 8 lines
Documentation/devicetree/bindings/phy/qcom,sa8775p-dwmac-sgmii-phy.yaml new file +8
-0+ +required: + - compatible + - reg + - "#phy-cells" + - clocks + - clock-names +
Documentation/devicetree/bindings/phy/qcom,sa8775p-dwmac-sgmii-phy.yaml line 51
Quoted 10 lines
Documentation/devicetree/bindings/phy/qcom,sa8775p-dwmac-sgmii-phy.yaml new file +10
-0+examples: + - | + #include <dt-bindings/clock/qcom,sa8775p-gcc.h> + serdes_phy: phy@8901000 { + compatible = "qcom,sa8775p-dwmac-sgmii-phy"; + reg = <0x08901000 0xe10>; + clocks = <&gcc GCC_SGMI_CLKREF_EN>; + clock-names = "sgmi_ref"; + #phy-cells = <0>; + status = "disabled";
Drop the status.
With above:
Quoted 1 line
+ };
Best regards,
Krzysztof
Re: [PATCH 04/26] arm64: defconfig: enable the SerDes PHY for Qualcomm DWMAC
In reply to Bartosz GolaszewskiQuoted 7 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
Enable the SGMII/SerDes PHY driver. This module is required to enable ethernet on sa8775p platforms.
Signed-off-by Bartosz Golaszewski <[email protected]>---
Best regards,
Krzysztof
Re: [PATCH 03/26] phy: qcom: add the SGMII SerDes PHY driver
In reply to Konrad DybcioQuoted 17 lines · Konrad Dybcio
drivers/phy/qualcomm/phy-qcom-sgmii-eth.c line 386
Quoted 13 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
Implement support for the SGMII/SerDes PHY present on various Qualcomm platforms.
Signed-off-by Bartosz Golaszewski <[email protected]>---
drivers/phy/qualcomm/phy-qcom-sgmii-eth.c new file +6
-0+static const struct regmap_config qcom_dwmac_sgmii_phy_regmap_cfg = { + .reg_bits =32 , + .val_bits =32 , + .reg_stride =4 , + .use_relaxed_mmio = true, + .disable_locking = true,
Quoted 2 lines
The last two are rather brave, no?
We don't need locking because all callbacks are already protected by the phy subsystem with a mutex and I don't really see anything that would make it dangerous to use relaxed semantics in this driver. It's just basic configuration.
Bart
Quoted 61 lines
Konrad
Quoted 60 lines
drivers/phy/qualcomm/phy-qcom-sgmii-eth.c new file +60
-0+}; + +static int qcom_dwmac_sgmii_phy_probe (struct platform_device *pdev) +{ +struct qcom_dwmac_sgmii_phy_data *data; +struct device *dev = &pdev->dev; +struct phy_provider *provider; +struct clk *refclk; +void __iomem *base; +struct phy *phy; + + data =devm_kzalloc (dev,sizeof (*data),GFP_KERNEL ); +if (!data) +return -ENOMEM ; + + base =devm_platform_ioremap_resource (pdev,0 ); +if (IS_ERR (base)) +return PTR_ERR (base); + + data->regmap =devm_regmap_init_mmio (dev, base, + &qcom_dwmac_sgmii_phy_regmap_cfg); +if (IS_ERR (data->regmap)) +return PTR_ERR (data->regmap); + + phy =devm_phy_create (dev,NULL , &qcom_dwmac_sgmii_phy_ops); +if (IS_ERR (phy)) +return PTR_ERR (phy); + + refclk =devm_clk_get_enabled (dev,"sgmi_ref" ); +if (IS_ERR (refclk)) +return PTR_ERR (refclk); + + provider =devm_of_phy_provider_register (dev, of_phy_simple_xlate); +if (IS_ERR (provider)) +return PTR_ERR (provider); + +phy_set_drvdata (phy, data); +platform_set_drvdata (pdev, data); + +return 0 ; +} + +static const struct of_device_id qcom_dwmac_sgmii_phy_of_match[] = { + { .compatible ="qcom,sa8775p-dwmac-sgmii-phy" }, + { }, +}; +MODULE_DEVICE_TABLE (of, qcom_dwmac_sgmii_phy_of_match); + +static struct platform_driver qcom_dwmac_sgmii_phy_driver = { + .probe = qcom_dwmac_sgmii_phy_probe, + .driver = { + .name ="qcom-dwmac-sgmii-phy" , + .of_match_table = qcom_dwmac_sgmii_phy_of_match, + } +}; + +module_platform_driver (qcom_dwmac_sgmii_phy_driver); + +MODULE_DESCRIPTION ("Qualcomm DWMAC SGMII PHY driver" ); +MODULE_LICENSE ("GPL" );
Signature · 3 lines
linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
Re: [PATCH 19/26] dt-bindings: net: snps,dwmac: add compatible for sa8775p ethqos
In reply to Bartosz GolaszewskiQuoted 6 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
Add the compatible string for the MAC controller on sa8775p platforms.
Signed-off-by Bartosz Golaszewski <[email protected]>---
Best regards,
Krzysztof
Re: [PATCH 20/26] dt-bindings: net: qcom,ethqos: add description for sa8775p
In reply to Bartosz GolaszewskiQuoted 7 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
Add the compatible for the MAC controller on sa8775p platforms. This MAC works with a single interrupt so add minItems to the interrupts property. The fourth clock's name is different here so change it. Enable relevant PHY properties.
I think the patch should be squashed with previous. Adding compatible to common snps,dwmac binding does not make sense on its own. It makes sense with adding compatible here.
Quoted 36 lines
Signed-off-by Bartosz Golaszewski <[email protected]>--- .../devicetree/bindings/net/qcom,ethqos.yaml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)Documentation/devicetree/bindings/net/qcom,ethqos.yaml +3
-1@@ -20,6 +20,7 @@ properties: compatible: enum: - qcom,qcs404-ethqos + - qcom,sa8775p-ethqos - qcom,sc8280xp-ethqos - qcom,sm8150-ethqos@@ -32,11 +33,13 @@ properties: - const: rgmii interrupts: + minItems: 1 items: - description: Combined signal for various interrupt events - description: The interrupt that occurs when Rx exits the LPI state interrupt-names: + minItems: 1 items: - const: macirq - const: eth_lpi@@ -49,11 +52,20 @@ properties: - const: stmmaceth - const: pclk - const: ptp_ref - - const: rgmii
Documentation/devicetree/bindings/net/qcom,ethqos.yaml properties: · line 64
Quoted 10 lines
Documentation/devicetree/bindings/net/qcom,ethqos.yaml +6
-0+ - enum: + - rgmii + - phyaux iommus: maxItems: 1 + phys: true + + phy-supply: true
Isn't this property of the phy?
Documentation/devicetree/bindings/net/qcom,ethqos.yaml properties: · line 67
Quoted 3 lines
Documentation/devicetree/bindings/net/qcom,ethqos.yaml +3
-0+ + phy-names: + const: serdes
Keep the phy-names after phys.
Best regards,
Krzysztof
Re: [PATCH 20/26] dt-bindings: net: qcom,ethqos: add description for sa8775p
Quoted 54 lines · Krzysztof Kozlowski
Quoted 7 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
Add the compatible for the MAC controller on sa8775p platforms. This MAC works with a single interrupt so add minItems to the interrupts property. The fourth clock's name is different here so change it. Enable relevant PHY properties.
I think the patch should be squashed with previous. Adding compatible to common snps,dwmac binding does not make sense on its own. It makes sense with adding compatible here.
Quoted 40 lines
Signed-off-by Bartosz Golaszewski <[email protected]>--- .../devicetree/bindings/net/qcom,ethqos.yaml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)Documentation/devicetree/bindings/net/qcom,ethqos.yaml +6
-1@@ -20,6 +20,7 @@ properties: compatible: enum: - qcom,qcs404-ethqos + - qcom,sa8775p-ethqos - qcom,sc8280xp-ethqos - qcom,sm8150-ethqos@@ -32,11 +33,13 @@ properties: - const: rgmii interrupts: + minItems: 1 items: - description: Combined signal for various interrupt events - description: The interrupt that occurs when Rx exits the LPI state interrupt-names: + minItems: 1 items: - const: macirq - const: eth_lpi@@ -49,11 +52,20 @@ properties: - const: stmmaceth - const: pclk - const: ptp_ref - - const: rgmii + - enum: + - rgmii + - phyaux
Quoted 9 lines
Documentation/devicetree/bindings/net/qcom,ethqos.yaml properties: · line 64
Quoted 6 lines
Documentation/devicetree/bindings/net/qcom,ethqos.yaml +3
-0iommus: maxItems: 1 + phys: true + + phy-supply: trueIsn't this property of the phy?
It is, and as discussed elsewhere with Andrew, I will move it to the SerDes PHY driver.
Bart
Quoted 10 lines
Documentation/devicetree/bindings/net/qcom,ethqos.yaml properties: · line 67
Quoted 3 lines
Documentation/devicetree/bindings/net/qcom,ethqos.yaml +3
-0+ + phy-names: + const: serdesKeep the phy-names after phys.
Best regards,
Krzysztof
Bjorn Andersson
maintainerRe: [PATCH 24/26] arm64: dts: qcom: sa8775p-ride: enable the SerDes PHY
In reply to Konrad DybcioQuoted 7 lines · Konrad Dybcio
Quoted 4 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
Enable the internal PHY on sa8775p-ride.
Quoted 9 lines
Quoted 2 lines
Signed-off-by Bartosz Golaszewski <[email protected]>---
Reviewed-by Konrad Dybcio <[email protected]>---
Bjorn, Krzysztof.. I was thinking whether we should even be disabling such hardware by default..
I'm in favor of keeping the configuration as generic/common/simple as possible. So I like your suggestion.
Regards,
Bjorn
Quoted 32 lines
Things that reside on the SoC and have no external dependencies could be left enabled:
pros:
- less fluff
- we'd probably very quickly fix the missing PM calls
- possibly lessfw_devlinkwoes if we fail to get rid of references to the disabled component?cons:
- boot times
- slightly more memory usageKonrad
Quoted 18 lines
arch/arm64/boot/dts/qcom/sa8775p-ride.dts | 4 ++++ 1 file changed, 4 insertions(+)arch/arm64/boot/dts/qcom/sa8775p-ride.dts +4
-0@@ -355,6 +355,10 @@ &qupv3_id_2 { status = "okay"; }; +&serdes_phy { + status = "okay"; +}; + &sleep_clk { clock-frequency = <32764>; };