From e876c143bd5a6ff8afe0abd63176b797207c7582 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sun, 1 Mar 2020 21:05:46 +0100 Subject: [PATCH] fix withgout mdio --- target/linux/ath79/dts/ar9132.dtsi | 4 + ...f-Add-of_get_available_child_by_name.patch | 76 +++++++++++++++++++ ...g71xx-Probe-MDIO-only-when-available.patch | 70 +++++++++++++++++ 3 files changed, 150 insertions(+) create mode 100644 target/linux/ath79/patches-5.4/208-of-Add-of_get_available_child_by_name.patch create mode 100644 target/linux/ath79/patches-5.4/209-ag71xx-Probe-MDIO-only-when-available.patch diff --git a/target/linux/ath79/dts/ar9132.dtsi b/target/linux/ath79/dts/ar9132.dtsi index 2264994279..ec60aff867 100644 --- a/target/linux/ath79/dts/ar9132.dtsi +++ b/target/linux/ath79/dts/ar9132.dtsi @@ -188,10 +188,14 @@ compatible = "qca,ar9130-eth", "syscon"; reg = <0x19000000 0x200 0x18070000 0x4>; + reg-names = "mac", "interface"; + pll-data = <0x1a000000 0x13000a44 0x00441099>; pll-reg = <0x4 0x14 20>; pll-handle = <&pll>; resets = <&rst 9>; reset-names = "mac"; + clocks = <&pll ATH79_CLK_AHB> + clock-names = "eth"; qca,mac-idx = <0>; }; diff --git a/target/linux/ath79/patches-5.4/208-of-Add-of_get_available_child_by_name.patch b/target/linux/ath79/patches-5.4/208-of-Add-of_get_available_child_by_name.patch new file mode 100644 index 0000000000..38b7cc4ccc --- /dev/null +++ b/target/linux/ath79/patches-5.4/208-of-Add-of_get_available_child_by_name.patch @@ -0,0 +1,76 @@ +From 844d79bc784c2ca7c13f095d254f8ca6f3f7551b Mon Sep 17 00:00:00 2001 +From: Hauke Mehrtens +Date: Sun, 1 Mar 2020 20:58:36 +0100 +Subject: of: Add of_get_available_child_by_name() + +This function will return the node with a given name if it is available. +I want to set a node to disable and then the driver should not use it +and handle it similar like it would not be there. + +Signed-off-by: Hauke Mehrtens +--- + drivers/of/base.c | 26 ++++++++++++++++++++++++++ + include/linux/of.h | 10 ++++++++++ + 2 files changed, 36 insertions(+) + +--- a/drivers/of/base.c ++++ b/drivers/of/base.c +@@ -860,6 +860,32 @@ struct device_node *of_get_compatible_ch + EXPORT_SYMBOL(of_get_compatible_child); + + /** ++ * of_get_available_child_by_name - Find the available child node by ++ * name for a given parent ++ * @node: parent node ++ * @name: child name to look for. ++ * ++ * This function looks for child node for given matching name which ++ * status is set to okay. ++ * ++ * Returns a node pointer if found, with refcount incremented, use ++ * of_node_put() on it when done. ++ * Returns NULL if node is not found. ++ */ ++struct device_node *of_get_available_child_by_name( ++ const struct device_node *node, ++ const char *name) ++{ ++ struct device_node *child; ++ ++ for_each_available_child_of_node(node, child) ++ if (of_node_name_eq(child, name)) ++ break; ++ return child; ++} ++EXPORT_SYMBOL(of_get_available_child_by_name); ++ ++/** + * of_get_child_by_name - Find the child node by name for a given parent + * @node: parent node + * @name: child name to look for. +--- a/include/linux/of.h ++++ b/include/linux/of.h +@@ -294,6 +294,9 @@ extern struct device_node *of_get_compat + const char *compatible); + extern struct device_node *of_get_child_by_name(const struct device_node *node, + const char *name); ++extern struct device_node *of_get_available_child_by_name( ++ const struct device_node *node, ++ const char *name); + + /* cache lookup */ + extern struct device_node *of_find_next_cache_node(const struct device_node *); +@@ -663,6 +666,13 @@ static inline struct device_node *of_get + const struct device_node *node, + const char *name) + { ++ return NULL; ++} ++ ++static inline struct device_node *of_get_available_child_by_name( ++ const struct device_node *node, ++ const char *name) ++{ + return NULL; + } + diff --git a/target/linux/ath79/patches-5.4/209-ag71xx-Probe-MDIO-only-when-available.patch b/target/linux/ath79/patches-5.4/209-ag71xx-Probe-MDIO-only-when-available.patch new file mode 100644 index 0000000000..acbcfbec5e --- /dev/null +++ b/target/linux/ath79/patches-5.4/209-ag71xx-Probe-MDIO-only-when-available.patch @@ -0,0 +1,70 @@ +From ad898b7aff3adb66dda908b68b93378541f611b3 Mon Sep 17 00:00:00 2001 +From: Hauke Mehrtens +Date: Sun, 1 Mar 2020 20:59:52 +0100 +Subject: ag71xx: Probe MDIO only when available + +Some devices do not use the MDIO bus when when it is available on the +SoC. These devices should be able to define the MDIO bus as disabled and +then the driver should work without MDIO. + +Signed-off-by: Hauke Mehrtens +--- + drivers/net/ethernet/atheros/ag71xx.c | 18 +++++++++++------- + 1 file changed, 11 insertions(+), 7 deletions(-) + +--- a/drivers/net/ethernet/atheros/ag71xx.c ++++ b/drivers/net/ethernet/atheros/ag71xx.c +@@ -545,7 +545,7 @@ static int ag71xx_mdio_reset(struct mii_ + return 0; + } + +-static int ag71xx_mdio_probe(struct ag71xx *ag) ++static int ag71xx_mdio_probe(struct ag71xx *ag, struct device_node *mnp) + { + struct device *dev = &ag->pdev->dev; + struct net_device *ndev = ag->ndev; +@@ -595,9 +595,7 @@ static int ag71xx_mdio_probe(struct ag71 + msleep(200); + } + +- mnp = of_get_child_by_name(np, "mdio"); + err = of_mdiobus_register(mii_bus, mnp); +- of_node_put(mnp); + if (err) + goto mdio_err_put_clk; + +@@ -1755,6 +1753,7 @@ static const struct net_device_ops ag71x + static int ag71xx_probe(struct platform_device *pdev) + { + struct device_node *np = pdev->dev.of_node; ++ struct device_node *mnp; + const struct ag71xx_dcfg *dcfg; + struct net_device *ndev; + const void *mac_addr; +@@ -1869,9 +1868,13 @@ static int ag71xx_probe(struct platform_ + + ag71xx_hw_init(ag); + +- err = ag71xx_mdio_probe(ag); +- if (err) +- goto err_put_clk; ++ mnp = of_get_available_child_by_name(np, "mdio"); ++ if (mnp) { ++ err = ag71xx_mdio_probe(ag, mnp); ++ of_node_put(mnp); ++ if (err) ++ goto err_put_clk; ++ } + + platform_set_drvdata(pdev, ndev); + +@@ -1895,7 +1898,8 @@ static int ag71xx_probe(struct platform_ + return 0; + + err_mdio_remove: +- ag71xx_mdio_remove(ag); ++ if (mnp) ++ ag71xx_mdio_remove(ag); + err_put_clk: + clk_disable_unprepare(ag->clk_eth); + return err; -- 2.30.2