[openwrt/openwrt] apm821xx: convert MR24 to use DT PHY defintion
LEDE Commits
lede-commits at lists.infradead.org
Thu Jan 11 23:04:45 PST 2018
mkresin pushed a commit to openwrt/openwrt.git, branch master:
https://git.lede-project.org/e4371779d2691553e6321e87d86212beaaa8b89d
commit e4371779d2691553e6321e87d86212beaaa8b89d
Author: Christian Lamparter <chunkeey at gmail.com>
AuthorDate: Sun Jan 7 21:27:49 2018 +0100
apm821xx: convert MR24 to use DT PHY defintion
Convert the MR24 to use the DT phy probing and at803x PHY driver.
Signed-off-by: Christian Lamparter <chunkeey at gmail.com>
---
target/linux/apm821xx/dts/meraki-mr24.dts | 12 +
target/linux/apm821xx/nand/config-default | 1 +
...c-replace-custom-rgmii_mode_name-with-phy.patch | 51 +++++
...-ibm-emac-replace-custom-PHY_MODE_-macros.patch | 246 +++++++++++++++++++++
...t-ibm-emac-support-RGMII-RX-TX-ID-phymode.patch | 59 +++++
5 files changed, 369 insertions(+)
diff --git a/target/linux/apm821xx/dts/meraki-mr24.dts b/target/linux/apm821xx/dts/meraki-mr24.dts
index 2c2f8d2..e06d37c 100644
--- a/target/linux/apm821xx/dts/meraki-mr24.dts
+++ b/target/linux/apm821xx/dts/meraki-mr24.dts
@@ -89,6 +89,18 @@
&EMAC0 {
status = "okay";
+
+ phy-mode = "rgmii-id";
+ phy-map = <0x2>;
+ phy-address = <0x1>;
+ phy-handle = <&phy>;
+
+ mdio {
+ phy: phy at 1 {
+ compatible = "ethernet-phy-ieee802.3-c22";
+ reg = <1>;
+ };
+ };
};
&POB0 {
diff --git a/target/linux/apm821xx/nand/config-default b/target/linux/apm821xx/nand/config-default
index 783305a..ca6af46 100644
--- a/target/linux/apm821xx/nand/config-default
+++ b/target/linux/apm821xx/nand/config-default
@@ -1,3 +1,4 @@
+CONFIG_AT803X_PHY=y
CONFIG_AR8216_PHY=y
CONFIG_DMADEVICES=y
CONFIG_DMA_ENGINE=y
diff --git a/target/linux/apm821xx/patches-4.14/030-0001-net-ibm-emac-replace-custom-rgmii_mode_name-with-phy.patch b/target/linux/apm821xx/patches-4.14/030-0001-net-ibm-emac-replace-custom-rgmii_mode_name-with-phy.patch
new file mode 100644
index 0000000..28969a7
--- /dev/null
+++ b/target/linux/apm821xx/patches-4.14/030-0001-net-ibm-emac-replace-custom-rgmii_mode_name-with-phy.patch
@@ -0,0 +1,51 @@
+From 54e1b3004eb85f9317f6c4ceff2e097231c7f52a Mon Sep 17 00:00:00 2001
+From: Christian Lamparter <chunkeey at gmail.com>
+Date: Wed, 20 Dec 2017 22:11:22 +0100
+Subject: [PATCH 1/3] net: ibm: emac: replace custom rgmii_mode_name with
+ phy_modes
+
+The common phylib defines the same names (in lower-case).
+Since rgmii_mode_name() is used only in one place and
+for a "notice-level" printk, I think it can be replaced.
+
+Signed-off-by: Christian Lamparter <chunkeey at gmail.com>
+---
+ drivers/net/ethernet/ibm/emac/rgmii.c | 20 +-------------------
+ 1 file changed, 1 insertion(+), 19 deletions(-)
+
+--- a/drivers/net/ethernet/ibm/emac/rgmii.c
++++ b/drivers/net/ethernet/ibm/emac/rgmii.c
+@@ -59,24 +59,6 @@ static inline int rgmii_valid_mode(int p
+ phy_mode == PHY_MODE_RTBI;
+ }
+
+-static inline const char *rgmii_mode_name(int mode)
+-{
+- switch (mode) {
+- case PHY_MODE_RGMII:
+- return "RGMII";
+- case PHY_MODE_TBI:
+- return "TBI";
+- case PHY_MODE_GMII:
+- return "GMII";
+- case PHY_MODE_MII:
+- return "MII";
+- case PHY_MODE_RTBI:
+- return "RTBI";
+- default:
+- BUG();
+- }
+-}
+-
+ static inline u32 rgmii_mode_mask(int mode, int input)
+ {
+ switch (mode) {
+@@ -115,7 +97,7 @@ int rgmii_attach(struct platform_device
+ out_be32(&p->fer, in_be32(&p->fer) | rgmii_mode_mask(mode, input));
+
+ printk(KERN_NOTICE "%pOF: input %d in %s mode\n",
+- ofdev->dev.of_node, input, rgmii_mode_name(mode));
++ ofdev->dev.of_node, input, phy_modes(mode));
+
+ ++dev->users;
+
diff --git a/target/linux/apm821xx/patches-4.14/030-0002-net-ibm-emac-replace-custom-PHY_MODE_-macros.patch b/target/linux/apm821xx/patches-4.14/030-0002-net-ibm-emac-replace-custom-PHY_MODE_-macros.patch
new file mode 100644
index 0000000..e4a7226
--- /dev/null
+++ b/target/linux/apm821xx/patches-4.14/030-0002-net-ibm-emac-replace-custom-PHY_MODE_-macros.patch
@@ -0,0 +1,246 @@
+From 1477bea9e6931f6be96f45b9d277690a26d0cd97 Mon Sep 17 00:00:00 2001
+From: Christian Lamparter <chunkeey at gmail.com>
+Date: Wed, 20 Dec 2017 22:19:24 +0100
+Subject: [PATCH 2/3] net: ibm: emac: replace custom PHY_MODE_* macros
+
+The ibm_emac driver predates the shared PHY_INTERFACE_MODE_
+enums provided by include/linux/phy.h by a few years.
+
+And while the driver has been retrofitted to use the PHYLIB,
+the old definitions have stuck around to this day.
+
+Signed-off-by: Christian Lamparter <chunkeey at gmail.com>
+---
+ drivers/net/ethernet/ibm/emac/core.c | 20 ++++++++++----------
+ drivers/net/ethernet/ibm/emac/emac.h | 13 -------------
+ drivers/net/ethernet/ibm/emac/phy.c | 10 +++++-----
+ drivers/net/ethernet/ibm/emac/rgmii.c | 20 ++++++++++----------
+ drivers/net/ethernet/ibm/emac/zmii.c | 34 +++++++++++++++++-----------------
+ 5 files changed, 42 insertions(+), 55 deletions(-)
+
+--- a/drivers/net/ethernet/ibm/emac/core.c
++++ b/drivers/net/ethernet/ibm/emac/core.c
+@@ -199,18 +199,18 @@ static void __emac_set_multicast_list(st
+
+ static inline int emac_phy_supports_gige(int phy_mode)
+ {
+- return phy_mode == PHY_MODE_GMII ||
+- phy_mode == PHY_MODE_RGMII ||
+- phy_mode == PHY_MODE_SGMII ||
+- phy_mode == PHY_MODE_TBI ||
+- phy_mode == PHY_MODE_RTBI;
++ return phy_mode == PHY_INTERFACE_MODE_GMII ||
++ phy_mode == PHY_INTERFACE_MODE_RGMII ||
++ phy_mode == PHY_INTERFACE_MODE_SGMII ||
++ phy_mode == PHY_INTERFACE_MODE_TBI ||
++ phy_mode == PHY_INTERFACE_MODE_RTBI;
+ }
+
+ static inline int emac_phy_gpcs(int phy_mode)
+ {
+- return phy_mode == PHY_MODE_SGMII ||
+- phy_mode == PHY_MODE_TBI ||
+- phy_mode == PHY_MODE_RTBI;
++ return phy_mode == PHY_INTERFACE_MODE_SGMII ||
++ phy_mode == PHY_INTERFACE_MODE_TBI ||
++ phy_mode == PHY_INTERFACE_MODE_RTBI;
+ }
+
+ static inline void emac_tx_enable(struct emac_instance *dev)
+@@ -2865,7 +2865,7 @@ static int emac_init_config(struct emac_
+ /* PHY mode needs some decoding */
+ dev->phy_mode = of_get_phy_mode(np);
+ if (dev->phy_mode < 0)
+- dev->phy_mode = PHY_MODE_NA;
++ dev->phy_mode = PHY_INTERFACE_MODE_NA;
+
+ /* Check EMAC version */
+ if (of_device_is_compatible(np, "ibm,emac4sync")) {
+@@ -3168,7 +3168,7 @@ static int emac_probe(struct platform_de
+ printk(KERN_INFO "%s: EMAC-%d %pOF, MAC %pM\n",
+ ndev->name, dev->cell_index, np, ndev->dev_addr);
+
+- if (dev->phy_mode == PHY_MODE_SGMII)
++ if (dev->phy_mode == PHY_INTERFACE_MODE_SGMII)
+ printk(KERN_NOTICE "%s: in SGMII mode\n", ndev->name);
+
+ if (dev->phy.address >= 0)
+--- a/drivers/net/ethernet/ibm/emac/emac.h
++++ b/drivers/net/ethernet/ibm/emac/emac.h
+@@ -104,19 +104,6 @@ struct emac_regs {
+ } u1;
+ };
+
+-/*
+- * PHY mode settings (EMAC <-> ZMII/RGMII bridge <-> PHY)
+- */
+-#define PHY_MODE_NA PHY_INTERFACE_MODE_NA
+-#define PHY_MODE_MII PHY_INTERFACE_MODE_MII
+-#define PHY_MODE_RMII PHY_INTERFACE_MODE_RMII
+-#define PHY_MODE_SMII PHY_INTERFACE_MODE_SMII
+-#define PHY_MODE_RGMII PHY_INTERFACE_MODE_RGMII
+-#define PHY_MODE_TBI PHY_INTERFACE_MODE_TBI
+-#define PHY_MODE_GMII PHY_INTERFACE_MODE_GMII
+-#define PHY_MODE_RTBI PHY_INTERFACE_MODE_RTBI
+-#define PHY_MODE_SGMII PHY_INTERFACE_MODE_SGMII
+-
+ /* EMACx_MR0 */
+ #define EMAC_MR0_RXI 0x80000000
+ #define EMAC_MR0_TXI 0x40000000
+--- a/drivers/net/ethernet/ibm/emac/phy.c
++++ b/drivers/net/ethernet/ibm/emac/phy.c
+@@ -96,7 +96,7 @@ int emac_mii_reset_gpcs(struct mii_phy *
+ if ((val & BMCR_ISOLATE) && limit > 0)
+ gpcs_phy_write(phy, MII_BMCR, val & ~BMCR_ISOLATE);
+
+- if (limit > 0 && phy->mode == PHY_MODE_SGMII) {
++ if (limit > 0 && phy->mode == PHY_INTERFACE_MODE_SGMII) {
+ /* Configure GPCS interface to recommended setting for SGMII */
+ gpcs_phy_write(phy, 0x04, 0x8120); /* AsymPause, FDX */
+ gpcs_phy_write(phy, 0x07, 0x2801); /* msg_pg, toggle */
+@@ -313,16 +313,16 @@ static int cis8201_init(struct mii_phy *
+ epcr &= ~EPCR_MODE_MASK;
+
+ switch (phy->mode) {
+- case PHY_MODE_TBI:
++ case PHY_INTERFACE_MODE_TBI:
+ epcr |= EPCR_TBI_MODE;
+ break;
+- case PHY_MODE_RTBI:
++ case PHY_INTERFACE_MODE_RTBI:
+ epcr |= EPCR_RTBI_MODE;
+ break;
+- case PHY_MODE_GMII:
++ case PHY_INTERFACE_MODE_GMII:
+ epcr |= EPCR_GMII_MODE;
+ break;
+- case PHY_MODE_RGMII:
++ case PHY_INTERFACE_MODE_RGMII:
+ default:
+ epcr |= EPCR_RGMII_MODE;
+ }
+--- a/drivers/net/ethernet/ibm/emac/rgmii.c
++++ b/drivers/net/ethernet/ibm/emac/rgmii.c
+@@ -52,25 +52,25 @@
+ /* RGMII bridge supports only GMII/TBI and RGMII/RTBI PHYs */
+ static inline int rgmii_valid_mode(int phy_mode)
+ {
+- return phy_mode == PHY_MODE_GMII ||
+- phy_mode == PHY_MODE_MII ||
+- phy_mode == PHY_MODE_RGMII ||
+- phy_mode == PHY_MODE_TBI ||
+- phy_mode == PHY_MODE_RTBI;
++ return phy_mode == PHY_INTERFACE_MODE_GMII ||
++ phy_mode == PHY_INTERFACE_MODE_MII ||
++ phy_mode == PHY_INTERFACE_MODE_RGMII ||
++ phy_mode == PHY_INTERFACE_MODE_TBI ||
++ phy_mode == PHY_INTERFACE_MODE_RTBI;
+ }
+
+ static inline u32 rgmii_mode_mask(int mode, int input)
+ {
+ switch (mode) {
+- case PHY_MODE_RGMII:
++ case PHY_INTERFACE_MODE_RGMII:
+ return RGMII_FER_RGMII(input);
+- case PHY_MODE_TBI:
++ case PHY_INTERFACE_MODE_TBI:
+ return RGMII_FER_TBI(input);
+- case PHY_MODE_GMII:
++ case PHY_INTERFACE_MODE_GMII:
+ return RGMII_FER_GMII(input);
+- case PHY_MODE_MII:
++ case PHY_INTERFACE_MODE_MII:
+ return RGMII_FER_MII(input);
+- case PHY_MODE_RTBI:
++ case PHY_INTERFACE_MODE_RTBI:
+ return RGMII_FER_RTBI(input);
+ default:
+ BUG();
+--- a/drivers/net/ethernet/ibm/emac/zmii.c
++++ b/drivers/net/ethernet/ibm/emac/zmii.c
+@@ -49,20 +49,20 @@
+ */
+ static inline int zmii_valid_mode(int mode)
+ {
+- return mode == PHY_MODE_MII ||
+- mode == PHY_MODE_RMII ||
+- mode == PHY_MODE_SMII ||
+- mode == PHY_MODE_NA;
++ return mode == PHY_INTERFACE_MODE_MII ||
++ mode == PHY_INTERFACE_MODE_RMII ||
++ mode == PHY_INTERFACE_MODE_SMII ||
++ mode == PHY_INTERFACE_MODE_NA;
+ }
+
+ static inline const char *zmii_mode_name(int mode)
+ {
+ switch (mode) {
+- case PHY_MODE_MII:
++ case PHY_INTERFACE_MODE_MII:
+ return "MII";
+- case PHY_MODE_RMII:
++ case PHY_INTERFACE_MODE_RMII:
+ return "RMII";
+- case PHY_MODE_SMII:
++ case PHY_INTERFACE_MODE_SMII:
+ return "SMII";
+ default:
+ BUG();
+@@ -72,11 +72,11 @@ static inline const char *zmii_mode_name
+ static inline u32 zmii_mode_mask(int mode, int input)
+ {
+ switch (mode) {
+- case PHY_MODE_MII:
++ case PHY_INTERFACE_MODE_MII:
+ return ZMII_FER_MII(input);
+- case PHY_MODE_RMII:
++ case PHY_INTERFACE_MODE_RMII:
+ return ZMII_FER_RMII(input);
+- case PHY_MODE_SMII:
++ case PHY_INTERFACE_MODE_SMII:
+ return ZMII_FER_SMII(input);
+ default:
+ return 0;
+@@ -106,18 +106,18 @@ int zmii_attach(struct platform_device *
+ * Please, always specify PHY mode in your board port to avoid
+ * any surprises.
+ */
+- if (dev->mode == PHY_MODE_NA) {
+- if (*mode == PHY_MODE_NA) {
++ if (dev->mode == PHY_INTERFACE_MODE_NA) {
++ if (*mode == PHY_INTERFACE_MODE_NA) {
+ u32 r = dev->fer_save;
+
+ ZMII_DBG(dev, "autodetecting mode, FER = 0x%08x" NL, r);
+
+ if (r & (ZMII_FER_MII(0) | ZMII_FER_MII(1)))
+- dev->mode = PHY_MODE_MII;
++ dev->mode = PHY_INTERFACE_MODE_MII;
+ else if (r & (ZMII_FER_RMII(0) | ZMII_FER_RMII(1)))
+- dev->mode = PHY_MODE_RMII;
++ dev->mode = PHY_INTERFACE_MODE_RMII;
+ else
+- dev->mode = PHY_MODE_SMII;
++ dev->mode = PHY_INTERFACE_MODE_SMII;
+ } else
+ dev->mode = *mode;
+
+@@ -126,7 +126,7 @@ int zmii_attach(struct platform_device *
+ zmii_mode_name(dev->mode));
+ } else {
+ /* All inputs must use the same mode */
+- if (*mode != PHY_MODE_NA && *mode != dev->mode) {
++ if (*mode != PHY_INTERFACE_MODE_NA && *mode != dev->mode) {
+ printk(KERN_ERR
+ "%pOF: invalid mode %d specified for input %d\n",
+ ofdev->dev.of_node, *mode, input);
+@@ -246,7 +246,7 @@ static int zmii_probe(struct platform_de
+
+ mutex_init(&dev->lock);
+ dev->ofdev = ofdev;
+- dev->mode = PHY_MODE_NA;
++ dev->mode = PHY_INTERFACE_MODE_NA;
+
+ rc = -ENXIO;
+ if (of_address_to_resource(np, 0, ®s)) {
diff --git a/target/linux/apm821xx/patches-4.14/030-0003-net-ibm-emac-support-RGMII-RX-TX-ID-phymode.patch b/target/linux/apm821xx/patches-4.14/030-0003-net-ibm-emac-support-RGMII-RX-TX-ID-phymode.patch
new file mode 100644
index 0000000..16074c7
--- /dev/null
+++ b/target/linux/apm821xx/patches-4.14/030-0003-net-ibm-emac-support-RGMII-RX-TX-ID-phymode.patch
@@ -0,0 +1,59 @@
+From 0a49f0d1958440f7928047433c983eece05a3723 Mon Sep 17 00:00:00 2001
+From: Christian Lamparter <chunkeey at gmail.com>
+Date: Thu, 14 Dec 2017 19:51:50 +0100
+Subject: [PATCH 3/3] net: ibm: emac: support RGMII-[RX|TX]ID phymode
+
+The RGMII spec allows compliance for devices that implement an internal
+delay on TXC and/or RXC inside the transmitter. This patch adds the
+necessary RGMII_[RX|TX]ID mode code to handle such PHYs with the
+emac driver.
+
+Signed-off-by: Christian Lamparter <chunkeey at gmail.com>
+
+---
+v3: - replace PHY_MODE_* with PHY_INTERFACE_MODE_*
+ - replace rgmii_mode_name() with phy_modes[]
+
+v2: - utilize phy_interface_mode_is_rgmii()
+---
+ drivers/net/ethernet/ibm/emac/core.c | 4 ++--
+ drivers/net/ethernet/ibm/emac/rgmii.c | 7 +++++--
+ 2 files changed, 7 insertions(+), 4 deletions(-)
+
+--- a/drivers/net/ethernet/ibm/emac/core.c
++++ b/drivers/net/ethernet/ibm/emac/core.c
+@@ -199,8 +199,8 @@ static void __emac_set_multicast_list(st
+
+ static inline int emac_phy_supports_gige(int phy_mode)
+ {
+- return phy_mode == PHY_INTERFACE_MODE_GMII ||
+- phy_mode == PHY_INTERFACE_MODE_RGMII ||
++ return phy_interface_mode_is_rgmii(phy_mode) ||
++ phy_mode == PHY_INTERFACE_MODE_GMII ||
+ phy_mode == PHY_INTERFACE_MODE_SGMII ||
+ phy_mode == PHY_INTERFACE_MODE_TBI ||
+ phy_mode == PHY_INTERFACE_MODE_RTBI;
+--- a/drivers/net/ethernet/ibm/emac/rgmii.c
++++ b/drivers/net/ethernet/ibm/emac/rgmii.c
+@@ -52,9 +52,9 @@
+ /* RGMII bridge supports only GMII/TBI and RGMII/RTBI PHYs */
+ static inline int rgmii_valid_mode(int phy_mode)
+ {
+- return phy_mode == PHY_INTERFACE_MODE_GMII ||
++ return phy_interface_mode_is_rgmii(phy_mode) ||
++ phy_mode == PHY_INTERFACE_MODE_GMII ||
+ phy_mode == PHY_INTERFACE_MODE_MII ||
+- phy_mode == PHY_INTERFACE_MODE_RGMII ||
+ phy_mode == PHY_INTERFACE_MODE_TBI ||
+ phy_mode == PHY_INTERFACE_MODE_RTBI;
+ }
+@@ -63,6 +63,9 @@ static inline u32 rgmii_mode_mask(int mo
+ {
+ switch (mode) {
+ case PHY_INTERFACE_MODE_RGMII:
++ case PHY_INTERFACE_MODE_RGMII_ID:
++ case PHY_INTERFACE_MODE_RGMII_RXID:
++ case PHY_INTERFACE_MODE_RGMII_TXID:
+ return RGMII_FER_RGMII(input);
+ case PHY_INTERFACE_MODE_TBI:
+ return RGMII_FER_TBI(input);
More information about the lede-commits
mailing list