Merge branch 'net-ethernet-fec-move-GPR-register-offset-and-bit-into-DT'
authorDavid S. Miller <davem@davemloft.net>
Wed, 27 May 2020 03:21:43 +0000 (20:21 -0700)
committerDavid S. Miller <davem@davemloft.net>
Wed, 27 May 2020 03:21:43 +0000 (20:21 -0700)
Fugang Duan says:

====================
net: ethernet: fec: move GPR register offset and bit into DT

The commit da722186f654 (net: fec: set GPR bit on suspend by
DT configuration) set the GPR reigster offset and bit in driver
for wol feature support.

It brings trouble to enable wol feature on imx6sx/imx6ul/imx7d
platforms that have multiple ethernet instances with different
GPR bit for stop mode control. So the patch set is to move GPR
register offset and bit define into DT, and enable imx6q/imx6dl
imx6qp/imx6sx/imx6ul/imx7d stop mode support.

Currently, below NXP i.MX boards support wol:
- imx6q/imx6dl/imx6qp sabresd
- imx6sx sabreauto
- imx7d sdb

imx6q/imx6dl/imx6qp sabresd board dts file miss the property
"fsl,magic-packet;", so patch#4 is to add the property for stop
mode support.

v1 -> v2:
 - driver: switch back to store the quirks bitmask in driver_data
 - dt-bindings: rename 'gpr' property string to 'fsl,stop-mode'
 - imx6/7 dtsi: add imx6sx/imx6ul/imx7d ethernet stop mode property
v2 -> v3:
 - driver: suggested by Sascha Hauer, use a struct fec_devinfo for
   abstracting differences between different hardware variants,
   it can give more freedom to describe the differences.
 - imx6/7 dtsi: correct one typo pointed out by Andrew.

Thanks Martin, Andrew and Sascha Hauer for the review.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
Documentation/devicetree/bindings/net/fsl-fec.txt
arch/arm/boot/dts/imx6qdl-sabresd.dtsi
arch/arm/boot/dts/imx6qdl.dtsi
arch/arm/boot/dts/imx6sx.dtsi
arch/arm/boot/dts/imx6ul.dtsi
arch/arm/boot/dts/imx7d.dtsi
arch/arm/boot/dts/imx7s.dtsi
drivers/net/ethernet/freescale/fec_main.c

index 26c492a..9b54378 100644 (file)
@@ -22,8 +22,11 @@ Optional properties:
 - fsl,err006687-workaround-present: If present indicates that the system has
   the hardware workaround for ERR006687 applied and does not need a software
   workaround.
-- gpr: phandle of SoC general purpose register mode. Required for wake on LAN
-  on some SoCs
+- fsl,stop-mode: register bits of stop mode control, the format is
+                <&gpr req_gpr req_bit>.
+                gpr is the phandle to general purpose register node.
+                req_gpr is the gpr register offset for ENET stop request.
+                req_bit is the gpr bit offset for ENET stop request.
  -interrupt-names:  names of the interrupts listed in interrupts property in
   the same order. The defaults if not specified are
   __Number of interrupts__   __Default__
index fe59dde..28b35cc 100644 (file)
        pinctrl-0 = <&pinctrl_enet>;
        phy-mode = "rgmii-id";
        phy-reset-gpios = <&gpio1 25 GPIO_ACTIVE_LOW>;
+       fsl,magic-packet;
        status = "okay";
 };
 
index 98da446..48f5016 100644 (file)
                                         <&clks IMX6QDL_CLK_ENET>,
                                         <&clks IMX6QDL_CLK_ENET_REF>;
                                clock-names = "ipg", "ahb", "ptp";
-                               gpr = <&gpr>;
+                               fsl,stop-mode = <&gpr 0x34 27>;
                                status = "disabled";
                        };
 
index d6f8317..09f21aa 100644 (file)
                                              "enet_clk_ref", "enet_out";
                                fsl,num-tx-queues = <3>;
                                fsl,num-rx-queues = <3>;
+                               fsl,stop-mode = <&gpr 0x10 3>;
                                status = "disabled";
                        };
 
                                         <&clks IMX6SX_CLK_ENET_PTP>;
                                clock-names = "ipg", "ahb", "ptp",
                                              "enet_clk_ref", "enet_out";
+                               fsl,stop-mode = <&gpr 0x10 4>;
                                status = "disabled";
                        };
 
index 2ccf67c..345ae9b 100644 (file)
                                              "enet_clk_ref", "enet_out";
                                fsl,num-tx-queues = <1>;
                                fsl,num-rx-queues = <1>;
+                               fsl,stop-mode = <&gpr 0x10 4>;
                                status = "disabled";
                        };
 
                                              "enet_clk_ref", "enet_out";
                                fsl,num-tx-queues = <1>;
                                fsl,num-rx-queues = <1>;
+                               fsl,stop-mode = <&gpr 0x10 3>;
                                status = "disabled";
                        };
 
index 4c22828..cff875b 100644 (file)
                        "enet_clk_ref", "enet_out";
                fsl,num-tx-queues = <3>;
                fsl,num-rx-queues = <3>;
+               fsl,stop-mode = <&gpr 0x10 4>;
                status = "disabled";
        };
 
index 76e3ffb..5bf0b39 100644 (file)
                                        "enet_clk_ref", "enet_out";
                                fsl,num-tx-queues = <3>;
                                fsl,num-rx-queues = <3>;
+                               fsl,stop-mode = <&gpr 0x10 3>;
                                status = "disabled";
                        };
                };
index 2e20914..4acb91d 100644 (file)
@@ -88,8 +88,6 @@ static void fec_enet_itr_coal_init(struct net_device *ndev);
 
 struct fec_devinfo {
        u32 quirks;
-       u8 stop_gpr_reg;
-       u8 stop_gpr_bit;
 };
 
 static const struct fec_devinfo fec_imx25_info = {
@@ -112,8 +110,6 @@ static const struct fec_devinfo fec_imx6q_info = {
                  FEC_QUIRK_HAS_BUFDESC_EX | FEC_QUIRK_HAS_CSUM |
                  FEC_QUIRK_HAS_VLAN | FEC_QUIRK_ERR006358 |
                  FEC_QUIRK_HAS_RACC,
-       .stop_gpr_reg = 0x34,
-       .stop_gpr_bit = 27,
 };
 
 static const struct fec_devinfo fec_mvf600_info = {
@@ -3476,19 +3472,23 @@ static int fec_enet_get_irq_cnt(struct platform_device *pdev)
 }
 
 static int fec_enet_init_stop_mode(struct fec_enet_private *fep,
-                                  struct fec_devinfo *dev_info,
                                   struct device_node *np)
 {
        struct device_node *gpr_np;
+       u32 out_val[3];
        int ret = 0;
 
-       if (!dev_info)
-               return 0;
-
-       gpr_np = of_parse_phandle(np, "gpr", 0);
+       gpr_np = of_parse_phandle(np, "fsl,stop-mode", 0);
        if (!gpr_np)
                return 0;
 
+       ret = of_property_read_u32_array(np, "fsl,stop-mode", out_val,
+                                        ARRAY_SIZE(out_val));
+       if (ret) {
+               dev_dbg(&fep->pdev->dev, "no stop mode property\n");
+               return ret;
+       }
+
        fep->stop_gpr.gpr = syscon_node_to_regmap(gpr_np);
        if (IS_ERR(fep->stop_gpr.gpr)) {
                dev_err(&fep->pdev->dev, "could not find gpr regmap\n");
@@ -3497,8 +3497,8 @@ static int fec_enet_init_stop_mode(struct fec_enet_private *fep,
                goto out;
        }
 
-       fep->stop_gpr.reg = dev_info->stop_gpr_reg;
-       fep->stop_gpr.bit = dev_info->stop_gpr_bit;
+       fep->stop_gpr.reg = out_val[1];
+       fep->stop_gpr.bit = out_val[2];
 
 out:
        of_node_put(gpr_np);
@@ -3575,7 +3575,7 @@ fec_probe(struct platform_device *pdev)
        if (of_get_property(np, "fsl,magic-packet", NULL))
                fep->wol_flag |= FEC_WOL_HAS_MAGIC_PACKET;
 
-       ret = fec_enet_init_stop_mode(fep, dev_info, np);
+       ret = fec_enet_init_stop_mode(fep, np);
        if (ret)
                goto failed_stop_mode;