net: ethernet: ti: cpsw: replace cpsw-phy-sel with phy driver
Subsystems (5)
cover net: ethernet: ti: cpsw: replace cpsw-phy-sel with phy driver
TI am335x/am437x/dra7(am5)/dm814x CPSW3G Ethernet Subsystem supports two 10/100/1000 Ethernet ports with selectable G/MII, RMII, and RGMII interfaces. The interface mode is selected by configuring the MII mode selection register(s) (GMII_SEL) in the System Control Module chapter (SCM).
+--------------+
+-------------------------------+ |SCM |
| CPSW | | +---------+ |
| +--------------------------------+gmii_sel | |
| | | | +---------+ |
| +----v---+ +--------+ | +--------------+
| |Port 1..<--+-->GMII/MII<------->
| | | | | | |
| +--------+ | +--------+ |
| | |
| | +--------+ |
| | | RMII <------->
| +--> | |
| | +--------+ |
| | |
| | +--------+ |
| | | RGMII <------->
| +--> | |
| +--------+ |
+-------------------------------+GMII_SEL register(s) and bit fields placement in SCM are different between SoCs while fields meaning is the same. GMII_SEL(s) allows to select - Port GMII/MII/RMII/RGMII Mode; RGMII Internal Delay Mode (SoC dependant) and RMII Reference Clock Output mode (SoC dependant).
Historically CPSW external Port's interface mode selection configuartion was introduced using custom driver and API cpsw-phy-sel.c.
This leads to unnecessary driver, DT binding and custom API support effort. Moreover, even definition of cpsw-phy-sel node in DTs is logically incorrect [1]
mac: ethernet@4a100000 {
compatible = "ti,am4372-cpsw","ti,cpsw";
...
phy_sel: cpsw-phy-sel@44e10650 {
compatible = "ti,am43xx-cpsw-phy-sel";
reg= <0x44e10650 0x4>;
reg-names = "gmii-sel";
};
};This series introduces attempt to drop custom CPSW Port interface selection implementation (cpsw-phy-sel.c) and use well defined Linux PHY framework instead. it introduces CPSW Port's PHY Interface Mode selection Driver (phy-gmii-sel) which implements standard Linux PHY interface. The phy-gmii-sel PHY device should defined as child device of SCM node (scm_conf) and can be attached to each CPSW port node using standard PHY bindings (cell 1 - port number, cell 2 - RMII refclk mode).
scm_conf: scm_conf@0 {
compatible = "syscon", "simple-bus";
gmii_sel_phy: cpsw-sel-netif {
compatible = "ti,am43xx-gmii-sel-phy";
syscon-scm = <&scm_conf>;
#phy-cells = <2>;
};
};mac: ethernet@4a100000 {
compatible = "ti,am4372-cpsw","ti,cpsw";
cpsw_emac0: slave@4a100200 {
phy-mode = "rgmii";
phys = <&gmii_sel_phy 1 0>;
};
};The CPSW driver requests phy-gmii-sel PHY for each external port and uses newly introduced API phy_set_netif_mode() (Patch 1) for port interface mode selection when netdev is opened.
slave->data->gmii_sel_phy = devm_of_phy_get(&pdev->dev, port_node, NULL); slave->data->phy_if = of_get_phy_mode(port_node);
cpsw_ndo_open()
phy_set_netif_mode(slave->data->gmii_sel_phy, slave->data->phy_if);
Note. CPSW Port interface has to be reconfigured every time netdev is opened for proper System Suspend support where CPSW can lose context.
I've considered two options while working on this series:
1) extend enum phy_mode {} and introduce more enum elements to cover missing, required Network PHY's Interface Mode definitions, like MII/GMII/RGMII(-XID), but it'd mean copy-past and data duplication from phy_interface_t -> phy_mode. More over, phy_interface_t can still continue growing.
2) introduce new PHY API for network interface mode selection which will use already defined set of modes from phy_interface_t.
Option 2 was selected for this series.
[1] https://www.mail-archive.com/[email protected]/msg247135.html
Grygorii Strashko (11):
phy: core add phy_set_netif_mode() api
dt-bindings: phy: add cpsw port interface mode selection phy bindings
phy: ti: introduce phy-gmii-sel driver
dt-bindings: net: ti: cpsw: switch to use phy-gmii-sel phy
net: ethernet: ti: cpsw: add support for port interface mode selection
phy
ARM: dts: dra7: switch to use phy-gmii-sel
ARM: dts: dm814x: switch to use phy-gmii-sel
ARM: dts: am4372: switch to use phy-gmii-sel
ARM: dts: am335x: switch to use phy-gmii-sel
dt-bindings: net: ti: deprecate cpsw-phy-sel bindings
net: ethernet: ti: cpsw: deprecate cpsw-phy-sel driver
.../devicetree/bindings/net/cpsw-phy-sel.txt | 2 +- Documentation/devicetree/bindings/net/cpsw.txt | 8 +- .../devicetree/bindings/phy/ti-phy-gmii-sel.txt | 68 ++++ arch/arm/boot/dts/am335x-baltos-ir2110.dts | 4 - arch/arm/boot/dts/am335x-baltos-ir3220.dts | 3 - arch/arm/boot/dts/am335x-baltos-ir5221.dts | 3 - arch/arm/boot/dts/am335x-chiliboard.dts | 3 - arch/arm/boot/dts/am335x-icev2.dts | 4 - arch/arm/boot/dts/am335x-igep0033.dtsi | 3 - arch/arm/boot/dts/am335x-lxm.dts | 3 - arch/arm/boot/dts/am335x-moxa-uc-8100-me-t.dts | 5 - arch/arm/boot/dts/am335x-phycore-som.dtsi | 3 - arch/arm/boot/dts/am33xx.dtsi | 14 +- arch/arm/boot/dts/am4372.dtsi | 16 +- arch/arm/boot/dts/am43x-epos-evm.dts | 5 +- arch/arm/boot/dts/dm814x.dtsi | 15 +- arch/arm/boot/dts/dra7.dtsi | 14 +- drivers/net/ethernet/ti/Kconfig | 6 +- drivers/net/ethernet/ti/cpsw.c | 18 +- drivers/net/ethernet/ti/cpsw.h | 6 + drivers/phy/phy-core.c | 15 + drivers/phy/ti/Kconfig | 10 + drivers/phy/ti/Makefile | 1 + drivers/phy/ti/phy-gmii-sel.c | 345 +++++++++++++++++++++ include/linux/phy/phy.h | 12 + 25 files changed, 520 insertions(+), 66 deletions(-) create mode 100644 Documentation/devicetree/bindings/phy/ti-phy-gmii-sel.txt create mode 100644 drivers/phy/ti/phy-gmii-sel.c
Signature · 1 line
2.10.5
RFC PATCH 1/11 phy: core add phy_set_netif_mode() api
Add new API phy_set_netif_mode(struct phy *phy, phy_interface_t mode) and new PHY operation callback .set_netif_mode() which intended to be implemnte by PHY drivers which supports Network interrfaces mode selection. Both accepts phy_interface_t vlaue as input parameter.
--- drivers/phy/phy-core.c | 15 +++++++++++++++ include/linux/phy/phy.h | 12 ++++++++++++ 2 files changed, 27 insertions(+)
drivers/phy/phy-core.c +15 -0
@@ -377,6 +377,21 @@ int phy_set_mode(struct phy *phy, enum phy_mode mode) }EXPORT_SYMBOL_GPL (phy_set_mode); +int phy_set_netif_mode (struct phy *phy,phy_interface_t mode) +{ +int ret; + +if (!phy || !phy->ops->set_netif_mode) +return 0 ; + +mutex_lock (&phy->mutex); + ret = phy->ops->set_netif_mode (phy, mode); +mutex_unlock (&phy->mutex); + +return ret; +} +EXPORT_SYMBOL_GPL (phy_set_netif_mode); +int phy_reset (struct phy *phy) {int ret;
include/linux/phy/phy.h +12 -0
@@ -17,6 +17,7 @@#include <linux/err.h> #include <linux/of.h> #include <linux/device.h> +#include <linux/phy.h> #include <linux/pm_runtime.h> #include <linux/regulator/consumer.h>
@@ -49,6 +50,7 @@ enum phy_mode {* @power_on: powering on the phy * @power_off: powering off the phy * @set_mode: set the mode of the phy +* @set_netif_mode: set the mode of the net interface phy * @reset: resetting the phy * @calibrate: calibrate the phy * @owner: the module owner containing the ops
@@ -59,6 +61,7 @@ struct phy_ops {int (*power_on)(struct phy *phy);int (*power_off)(struct phy *phy);int (*set_mode)(struct phy *phy,enum phy_mode mode); +int (*set_netif_mode)(struct phy *phy,phy_interface_t mode);int (*reset)(struct phy *phy);int (*calibrate)(struct phy *phy);struct module *owner;
@@ -163,6 +166,7 @@ int phy_exit(struct phy *phy);int phy_power_on (struct phy *phy);int phy_power_off (struct phy *phy);int phy_set_mode (struct phy *phy,enum phy_mode mode); +int phy_set_netif_mode (struct phy *phy,phy_interface_t mode);static inline enum phy_mode phy_get_mode (struct phy *phy) {return phy->attrs.mode;
@@ -283,6 +287,14 @@ static inline int phy_set_mode(struct phy *phy, enum phy_mode mode)return -ENOSYS ; } +static inline int phy_set_netif_mode (struct phy *phy, +phy_interface_t mode) +{ +if (!phy) +return 0 ; +return -ENOTSUPP ; +} +static inline enum phy_mode phy_get_mode (struct phy *phy) {return PHY_MODE_INVALID ;
Signature · 1 line
2.10.5
Re: [RFC PATCH 01/11] phy: core add phy_set_netif_mode() api
Hi Grygorii,
Quoted 25 lines · Grygorii Strashko
Add new API
phy_set_netif_mode(struct phy *phy, phy_interface_t mode)and new PHY operation callback .set_netif_mode() which intended to be implemnte by PHY drivers which supports Network interrfaces mode selection. Both acceptsphy_interface_tvlaue as input parameter.Cc Kishon Vijay Abraham I <[email protected]>Cc Tony Lindgren <[email protected]>Signed-off-by Grygorii Strashko <[email protected]>--- drivers/phy/phy-core.c | 15 +++++++++++++++ include/linux/phy/phy.h | 12 ++++++++++++ 2 files changed, 27 insertions(+)drivers/phy/phy-core.c +4
-0@@ -377,6 +377,21 @@ int phy_set_mode(struct phy *phy, enum phy_mode mode) }EXPORT_SYMBOL_GPL (phy_set_mode); +int phy_set_netif_mode (struct phy *phy,phy_interface_t mode) +{ +int ret; +
drivers/phy/phy-core.c int phy_set_mode(struct phy *phy, enum phy_mode mode) · line 393
Quoted 10 lines
drivers/phy/phy-core.c +10
-0+if (!phy || !phy->ops->set_netif_mode) +return 0 ; + +mutex_lock (&phy->mutex); + ret = phy->ops->set_netif_mode (phy, mode); +mutex_unlock (&phy->mutex); + +return ret; +} +EXPORT_SYMBOL_GPL (phy_set_netif_mode);
We should try to add only generic PHY APIs and not subsystem specific APIs. In this case I think phy_set_mode should suffice.
Thanks
Kishon
Quoted 56 lines
drivers/phy/phy-core.c +1
-0+int phy_reset (struct phy *phy) {int ret;include/linux/phy/phy.h +12
-0@@ -17,6 +17,7 @@#include <linux/err.h> #include <linux/of.h> #include <linux/device.h> +#include <linux/phy.h> #include <linux/pm_runtime.h> #include <linux/regulator/consumer.h> @@ -49,6 +50,7 @@ enum phy_mode {* @power_on: powering on the phy * @power_off: powering off the phy * @set_mode: set the mode of the phy +* @set_netif_mode: set the mode of the net interface phy * @reset: resetting the phy * @calibrate: calibrate the phy * @owner: the module owner containing the ops @@ -59,6 +61,7 @@ struct phy_ops {int (*power_on)(struct phy *phy);int (*power_off)(struct phy *phy);int (*set_mode)(struct phy *phy,enum phy_mode mode); +int (*set_netif_mode)(struct phy *phy,phy_interface_t mode);int (*reset)(struct phy *phy);int (*calibrate)(struct phy *phy);struct module *owner;@@ -163,6 +166,7 @@ int phy_exit(struct phy *phy);int phy_power_on (struct phy *phy);int phy_power_off (struct phy *phy);int phy_set_mode (struct phy *phy,enum phy_mode mode); +int phy_set_netif_mode (struct phy *phy,phy_interface_t mode);static inline enum phy_mode phy_get_mode (struct phy *phy) {return phy->attrs.mode;@@ -283,6 +287,14 @@ static inline int phy_set_mode(struct phy *phy, enum phy_mode mode)return -ENOSYS ; } +static inline int phy_set_netif_mode (struct phy *phy, +phy_interface_t mode) +{ +if (!phy) +return 0 ; +return -ENOTSUPP ; +} +static inline enum phy_mode phy_get_mode (struct phy *phy) {return PHY_MODE_INVALID ;
Re: [RFC PATCH 01/11] phy: core add phy_set_netif_mode() api
Quoted 33 lines · Kishon Vijay Abraham I
Hi Grygorii,
Quoted 30 lines · Grygorii Strashko
Add new API
phy_set_netif_mode(struct phy *phy, phy_interface_t mode)and new PHY operation callback .set_netif_mode() which intended to be implemnte by PHY drivers which supports Network interrfaces mode selection. Both acceptsphy_interface_tvlaue as input parameter.Cc Kishon Vijay Abraham I <[email protected]>Cc Tony Lindgren <[email protected]>Signed-off-by Grygorii Strashko <[email protected]>--- drivers/phy/phy-core.c | 15 +++++++++++++++ include/linux/phy/phy.h | 12 ++++++++++++ 2 files changed, 27 insertions(+)drivers/phy/phy-core.c +9
-0@@ -377,6 +377,21 @@ int phy_set_mode(struct phy *phy, enum phy_mode mode) }EXPORT_SYMBOL_GPL (phy_set_mode); +int phy_set_netif_mode (struct phy *phy,phy_interface_t mode) +{ +int ret; + +if (!phy || !phy->ops->set_netif_mode) +return 0 ; + +mutex_lock (&phy->mutex); + ret = phy->ops->set_netif_mode (phy, mode);
Quoted 8 lines
drivers/phy/phy-core.c int phy_set_mode(struct phy *phy, enum phy_mode mode) · line 393
Quoted 5 lines
drivers/phy/phy-core.c +5
-0+mutex_unlock (&phy->mutex); + +return ret; +} +EXPORT_SYMBOL_GPL (phy_set_netif_mode);We should try to add only generic PHY APIs and not subsystem specific APIs. In this case I think
phy_set_modeshould suffice.
This is what I've had in mind first, but all my guts argued against it after I've tried:
include/linux/phy/phy.h +8 -0
@@ -41,6 +41,14 @@ enum phy_mode {PHY_MODE_10GKR ,PHY_MODE_UFS_HS_A ,PHY_MODE_UFS_HS_B , +PHY_MODE_MODE_MII , +PHY_MODE_MODE_GMII , +PHY_MODE_MODE_SGMII , +PHY_MODE_MODE_RMII , +PHY_MODE_MODE_RGMII , +PHY_MODE_MODE_RGMII_ID , +PHY_MODE_MODE_RGMII_RXID , + PHY_MODE_MODE_RGMII_TXID, };
above introduces ugly constants duplication and required every network phy driver to maintain conversation table phy_interface_t -> enum phy_mode.
More over, if above change happens third time (first time PHY_MODE_SGMII/PHY_MODE_10GKR were added, second - PHY_MODE_2500SGMII) it will never ends (there are ~15 more items only in phy_interface_t). As result, enum phy_mode might became a un-maintainable monster.
So, as per above, and considering that Network subsystem is based on standards (phy_interface_t lists standard intf) I've tried to add separate PHY API.
As an idea:
- seems it could be reasonable to introduce PHY_MODE_NETWORK (or PHY_MODE_ETHERNET) and add generic phy_set_submode(struct phy *phy, long submode).
So, single functional PHY device can just use phy_set_submode() and multi-functional devices (like serdes which can be muxed between PCIe, USB, NET), can use:
phy_set_mode(PHY_MODE_ETHERNET)phy_set_submode(X);
Any way, if you still agree to just add new above phy_modes - i'll redo patches.
Signature · 2 lines
regards, -grygorii
Re: [RFC PATCH 01/11] phy: core add phy_set_netif_mode() api
Hi,
Quoted 79 lines · Grygorii Strashko
Quoted 33 lines · Kishon Vijay Abraham I
Hi Grygorii,
Quoted 30 lines · Grygorii Strashko
Add new API
phy_set_netif_mode(struct phy *phy, phy_interface_t mode)and new PHY operation callback .set_netif_mode() which intended to be implemnte by PHY drivers which supports Network interrfaces mode selection. Both acceptsphy_interface_tvlaue as input parameter.Cc Kishon Vijay Abraham I <[email protected]>Cc Tony Lindgren <[email protected]>Signed-off-by Grygorii Strashko <[email protected]>--- drivers/phy/phy-core.c | 15 +++++++++++++++ include/linux/phy/phy.h | 12 ++++++++++++ 2 files changed, 27 insertions(+)drivers/phy/phy-core.c +9
-0@@ -377,6 +377,21 @@ int phy_set_mode(struct phy *phy, enum phy_mode mode) }EXPORT_SYMBOL_GPL (phy_set_mode); +int phy_set_netif_mode (struct phy *phy,phy_interface_t mode) +{ +int ret; + +if (!phy || !phy->ops->set_netif_mode) +return 0 ; + +mutex_lock (&phy->mutex); + ret = phy->ops->set_netif_mode (phy, mode);Quoted 8 lines
drivers/phy/phy-core.c int phy_set_mode(struct phy *phy, enum phy_mode mode) · line 393
Quoted 5 lines
drivers/phy/phy-core.c +5
-0+mutex_unlock (&phy->mutex); + +return ret; +} +EXPORT_SYMBOL_GPL (phy_set_netif_mode);We should try to add only generic PHY APIs and not subsystem specific APIs. In this case I think
phy_set_modeshould suffice.This is what I've had in mind first, but all my guts argued against it after I've tried:
include/linux/phy/phy.h +8
-0@@ -41,6 +41,14 @@ enum phy_mode {PHY_MODE_10GKR ,PHY_MODE_UFS_HS_A ,PHY_MODE_UFS_HS_B , +PHY_MODE_MODE_MII , +PHY_MODE_MODE_GMII , +PHY_MODE_MODE_SGMII , +PHY_MODE_MODE_RMII , +PHY_MODE_MODE_RGMII , +PHY_MODE_MODE_RGMII_ID , +PHY_MODE_MODE_RGMII_RXID , + PHY_MODE_MODE_RGMII_TXID, };above introduces ugly constants duplication and required every network phy driver to maintain conversation table
phy_interface_t-> enumphy_mode.
More over, if above change happens third time (first time PHY_MODE_SGMII/PHY_MODE_10GKR were added, second -PHY_MODE_2500SGMII) it will never ends (there are ~15 more items only inphy_interface_t). As result, enumphy_modemight became a un-maintainable monster.So, as per above, and considering that Network subsystem is based on standards (
phy_interface_tlists standard intf) I've tried to add separate PHY API.As an idea:
- seems it could be reasonable to introducePHY_MODE_NETWORK(orPHY_MODE_ETHERNET) and add genericphy_set_submode(struct phy *phy, long submode).
Quoted 5 lines
So, single functional PHY device can just use
phy_set_submode()and multi-functional devices (like serdes which can be muxed between PCIe, USB, NET), can use:
phy_set_mode(PHY_MODE_ETHERNET)phy_set_submode(X);
Agreed on the constant duplication comment above. We can modify set_mode to take submode as an additional parameter and fix all the users of phy_set_mode. int phy_set_mode(struct phy *phy, enum phy_mode mode, int submode)
Thanks
Kishon
RFC PATCH 2/11 dt-bindings: phy: add cpsw port interface mode selection phy bindings
In reply to Grygorii StrashkoAdd CPSW Port's Interface Mode Selection PHY (phy-gmii-sel) DT Bindings
--- .../devicetree/bindings/phy/ti-phy-gmii-sel.txt | 68 ++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/ti-phy-gmii-sel.txt
Documentation/devicetree/bindings/phy/ti-phy-gmii-sel.txt new file +68 -0
@@ -0,0 +1,68 @@ +CPSW Port's Interface Mode Selection PHY Tree Bindings +----------------------------------------------- + +TI am335x/am437x/dra7(am5)/dm814x CPSW3G Ethernet Subsystem supports +two 10/100/1000 Ethernet ports with selectable G/MII, RMII, and RGMII interfaces. +The interface mode is selected by configuring the MII mode selection register(s) +(GMII_SEL) in the System Control Module chapter (SCM). GMII_SEL register(s) and +bit fields placement in SCM are different between SoCs while fields meaning +is the same. + +--------------+ + +-------------------------------+ |SCM | + | CPSW | | +---------+ | + | +--------------------------------+gmii_sel | | + | | | | +---------+ | + | +----v---+ +--------+ | +--------------+ + | |Port 1..<--+-->GMII/MII<-------> + | | | | | | | + | +--------+ | +--------+ | + | | | + | | +--------+ | + | | | RMII <-------> + | +--> | | + | | +--------+ | + | | | + | | +--------+ | + | | | RGMII <-------> + | +--> | | + | +--------+ | + +-------------------------------+ + +CPSW Port's Interface Mode Selection PHY describes MII interface mode between +CPSW Port and Ethernet PHY which depends on Eth PHY and board configuration. + +CPSW Port's Interface Mode Selection PHY device should defined as child device +of SCM node (scm_conf) and can be attached to each CPSW port node using standard +PHY bindings (See phy/phy-bindings.txt). + +Required properties: +- compatible : Should be "ti,am3352-phy-gmii-sel" for am335x platform + "ti,dra7xx-phy-gmii-sel" for dra7xx/am57xx platform + "ti,am43xx-phy-gmii-sel" for am43xx platform + "ti,dm814-phy-gmii-sel" for dm814x platform +- #phy-cells : must be 2. + cell 1 - CPSW port number (starting from 1) + cell 2 - RMII refclk mode +- syscon-scm : phandle on SCM node (mfd/syscon.txt) + +Examples: + phy_gmii_sel: phy-gmii-sel { + compatible = "ti,am3352-phy-gmii-sel"; + syscon-scm = <&scm_conf>; + #phy-cells = <2>; + }; + + mac: ethernet@4a100000 { + compatible = "ti,am335x-cpsw","ti,cpsw"; + ... + + cpsw_emac0: slave@4a100200 { + ... + phys = <&phy_gmii_sel 1 1>; + }; + + cpsw_emac1: slave@4a100300 { + ... + phys = <&phy_gmii_sel 2 1>; + }; + };
Signature · 1 line
2.10.5
Re: [RFC PATCH 02/11] dt-bindings: phy: add cpsw port interface mode selection phy bindings
Documentation/devicetree/bindings/phy/ti-phy-gmii-sel.txt line 53
Quoted 6 lines · Grygorii Strashko
Documentation/devicetree/bindings/phy/ti-phy-gmii-sel.txt new file +6
-0+Examples: + phy_gmii_sel: phy-gmii-sel { + compatible = "ti,am3352-phy-gmii-sel"; + syscon-scm = <&scm_conf>; + #phy-cells = <2>; + };
Now that this driver can live in it's proper place in the dts, you may want to consider just using standard reg property for it instead of the syscon-scm. And also get rid of the syscon reads and writes.
Regards,
Tony
Re: [RFC PATCH 02/11] dt-bindings: phy: add cpsw port interface mode selection phy bindings
Quoted 9 lines · Tony Lindgren
Documentation/devicetree/bindings/phy/ti-phy-gmii-sel.txt line 53
Quoted 6 lines · Grygorii Strashko
Documentation/devicetree/bindings/phy/ti-phy-gmii-sel.txt new file +6
-0+Examples: + phy_gmii_sel: phy-gmii-sel { + compatible = "ti,am3352-phy-gmii-sel"; + syscon-scm = <&scm_conf>; + #phy-cells = <2>; + };Now that this driver can live in it's proper place in the
right
Quoted 3 lines
dts, you may want to consider just using standard reg property for it instead of the syscon-scm. And also get rid of the syscon reads and writes.
Could you help clarify how to get syscon in this case? syscon_node_to_regmap(dev->parent->of_node)?
Also, there are could be more then one gmii_sel registers in SCM in the future, so I hidden offsets in of_match data.
As result, "reg" not needed at all now.
Signature · 2 lines
regards, -grygorii
Re: [RFC PATCH 02/11] dt-bindings: phy: add cpsw port interface mode selection phy bindings
Quoted 13 lines · Grygorii Strashko
Quoted 9 lines · Tony Lindgren
Documentation/devicetree/bindings/phy/ti-phy-gmii-sel.txt line 53
Quoted 6 lines · Grygorii Strashko
Documentation/devicetree/bindings/phy/ti-phy-gmii-sel.txt new file +6
-0+Examples: + phy_gmii_sel: phy-gmii-sel { + compatible = "ti,am3352-phy-gmii-sel"; + syscon-scm = <&scm_conf>; + #phy-cells = <2>; + };Now that this driver can live in it's proper place in the
Quoted 8 lines
right
Quoted 3 lines
dts, you may want to consider just using standard reg property for it instead of the syscon-scm. And also get rid of the syscon reads and writes.
Could you help clarify how to get syscon in this case?
syscon_node_to_regmap(dev->parent->of_node)?
Hmm I don't think you need syscon at all now. You can just ioremap the register(s) and use readl/writel and that's it. Or use regmap without syscon if you prefer that.
The ioremap in this case should be hitting cached ranges anyways, so no extra overhead there.
Quoted 3 lines
Also, there are could be more then one
gmii_selregisters in SCM in the future, so I hidden offsets inof_matchdata.
As result, "reg" not needed at all now.
But then you have to patch driver for various SoCs instead of just configuring the standard reg property in the dts file :)
Regards,
Tony
Re: [RFC PATCH 02/11] dt-bindings: phy: add cpsw port interface mode selection phy bindings
Quoted 20 lines · Tony Lindgren
Quoted 19 lines · Grygorii Strashko
Quoted 9 lines · Tony Lindgren
Documentation/devicetree/bindings/phy/ti-phy-gmii-sel.txt line 53
Quoted 6 lines · Grygorii Strashko
Documentation/devicetree/bindings/phy/ti-phy-gmii-sel.txt new file +6
-0+Examples: + phy_gmii_sel: phy-gmii-sel { + compatible = "ti,am3352-phy-gmii-sel"; + syscon-scm = <&scm_conf>; + #phy-cells = <2>; + };Now that this driver can live in it's proper place in the
right
Quoted 3 lines
dts, you may want to consider just using standard reg property for it instead of the syscon-scm. And also get rid of the syscon reads and writes.
Quoted 6 lines
Quoted 2 lines
Could you help clarify how to get syscon in this case?
syscon_node_to_regmap(dev->parent->of_node)?Hmm I don't think you need syscon at all now. You can just ioremap the register(s) and use readl/writel and that's it. Or use regmap without syscon if you prefer that.
It will overlap with already remapped SCM syscon and i'd like to avoid this.
+ it seems common practice to use syscon for devices/drivers which are child to SCM node - makes overall system more consistent.
Quoted 11 lines
The ioremap in this case should be hitting cached ranges anyways, so no extra overhead there.
Quoted 3 lines
Also, there are could be more then one
gmii_selregisters in SCM in the future, so I hidden offsets inof_matchdata.
As result, "reg" not needed at all now.But then you have to patch driver for various SoCs instead of just configuring the standard reg property in the dts file :)
Problem is that they are not guarantee to be standard between SoC's families (number of regs and fields placement), as result it might require to change driver any way for various SoCs to handle properly new fields placement.
I prefer to fix driver then fight with DT ;) as it's static for SoC family and need to be changed only once when new SoC family introduced.
Signature · 2 lines
regards, -grygorii
Re: [RFC PATCH 02/11] dt-bindings: phy: add cpsw port interface mode selection phy bindings
Quoted 26 lines · Grygorii Strashko
Quoted 23 lines · Tony Lindgren
Quoted 21 lines · Grygorii Strashko
Quoted 9 lines · Tony Lindgren
Documentation/devicetree/bindings/phy/ti-phy-gmii-sel.txt line 53
Quoted 6 lines · Grygorii Strashko
Documentation/devicetree/bindings/phy/ti-phy-gmii-sel.txt new file +6
-0+Examples: + phy_gmii_sel: phy-gmii-sel { + compatible = "ti,am3352-phy-gmii-sel"; + syscon-scm = <&scm_conf>; + #phy-cells = <2>; + };Now that this driver can live in it's proper place in the
right
Quoted 3 lines
dts, you may want to consider just using standard reg property for it instead of the syscon-scm. And also get rid of the syscon reads and writes.
Could you help clarify how to get syscon in this case?
syscon_node_to_regmap(dev->parent->of_node)?
Quoted 7 lines
Quoted 3 lines
Hmm I don't think you need syscon at all now. You can just ioremap the register(s) and use readl/writel and that's it. Or use regmap without syscon if you prefer that.
It will overlap with already remapped SCM syscon and i'd like to avoid this.
+ it seems common practice to use syscon for devices/drivers which are child to SCM node - makes overall system more consistent.
Well it was just set up with syscon in deperation earlier with drivers just blindly mapping registers outside of their range..
Quoted 11 lines
Quoted 10 lines
The ioremap in this case should be hitting cached ranges anyways, so no extra overhead there.
Quoted 3 lines
Also, there are could be more then one
gmii_selregisters in SCM in the future, so I hidden offsets inof_matchdata.
As result, "reg" not needed at all now.But then you have to patch driver for various SoCs instead of just configuring the standard reg property in the dts file :)
Quoted 6 lines
Problem is that they are not guarantee to be standard between SoC's families (number of regs and fields placement), as result it might require to change driver any way for various SoCs to handle properly new fields placement.
I prefer to fix driver then fight with DT ;) as it's static for SoC family and need to be changed only once when new SoC family introduced.
Fine with me, that can be changed later too no problem.
Regards,
Tony
Rob Herring
maintainerRe: [RFC PATCH 02/11] dt-bindings: phy: add cpsw port interface mode selection phy bindings
In reply to Grygorii StrashkoQuoted 19 lines · Grygorii Strashko
Quoted 9 lines · Tony Lindgren
Documentation/devicetree/bindings/phy/ti-phy-gmii-sel.txt line 53
Quoted 6 lines · Grygorii Strashko
Documentation/devicetree/bindings/phy/ti-phy-gmii-sel.txt new file +6
-0+Examples: + phy_gmii_sel: phy-gmii-sel { + compatible = "ti,am3352-phy-gmii-sel"; + syscon-scm = <&scm_conf>; + #phy-cells = <2>; + };Now that this driver can live in it's proper place in the
right
Quoted 3 lines
dts, you may want to consider just using standard reg property for it instead of the syscon-scm. And also get rid of the syscon reads and writes.
Quoted 6 lines
Could you help clarify how to get syscon in this case?
syscon_node_to_regmap(dev->parent->of_node)?Also, there are could be more then one
gmii_selregisters in SCM in the future, so I hidden offsets inof_matchdata.
As result, "reg" not needed at all now.
If there's a defined register range which doesn't overlap with other things (other than the parent), then use reg whether you currently need it or not.
Rob
RFC PATCH 3/11 phy: ti: introduce phy-gmii-sel driver
In reply to Grygorii StrashkoTI am335x/am437x/dra7(am5)/dm814x CPSW3G Ethernet Subsystem supports two 10/100/1000 Ethernet ports with selectable G/MII, RMII, and RGMII interfaces. The interface mode is selected by configuring the MII mode selection register(s) (GMII_SEL) in the System Control Module chapter (SCM). GMII_SEL register(s) and bit fields placement in SCM are different between SoCs while fields meaning is the same.
Historically CPSW external Port's interface mode selection configuartion was introduced using custom API and driver cpsw-phy-sel.c. This leads to unnecessary driver, DT binding and custom API support effort.
This patch introduces CPSW Port's PHY Interface Mode selection Driver (phy-gmii-sel) which implements standard Linux PHY interface and proposed as a replacement for TI's specific driver cpsw-phy-sel.c and coresponding custom API.
--- drivers/phy/ti/Kconfig | 10 ++ drivers/phy/ti/Makefile | 1 + drivers/phy/ti/phy-gmii-sel.c | 345 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 356 insertions(+) create mode 100644 drivers/phy/ti/phy-gmii-sel.c
drivers/phy/ti/Kconfig +10 -0
@@ -76,3 +76,13 @@ config TWL4030_USB family chips (including the TWL5030 and TPS659x0 devices). This transceiver supports high and full speed devices plus, in host mode, low speed. + +config PHY_TI_GMII_SEL + tristate + default y if TI_CPSW=y + depends on TI_CPSW || COMPILE_TEST + select GENERIC_PHY + default m + help + This driver supports configuring of the TI CPSW Port mode depending on + the Ethernet PHY connected to the CPSW Port.
drivers/phy/ti/Makefile +1 -0
@@ -6,3 +6,4 @@ obj-$(CONFIG_OMAP_USB2) += phy-omap-usb2.o obj-$(CONFIG_TI_PIPE3) += phy-ti-pipe3.o obj-$(CONFIG_PHY_TUSB1210) += phy-tusb1210.o obj-$(CONFIG_TWL4030_USB) += phy-twl4030-usb.o +obj-$(CONFIG_PHY_TI_GMII_SEL) += phy-gmii-sel.o
drivers/phy/ti/phy-gmii-sel.c new file +345 -0
345 lines not on this page · raw message
Signature · 1 line
2.10.5
Re: [RFC PATCH 03/11] phy: ti: introduce phy-gmii-sel driver
Quoted 16 lines · Grygorii Strashko
drivers/phy/ti/phy-gmii-sel.c new file +16
-0+static int phy_gmii_sel_mode (struct phy *phy,phy_interface_t intf_mode) +{ +struct phy_gmii_sel_phy_priv *if_phy =phy_get_drvdata (phy); +const struct phy_gmii_sel_soc_data *soc_data = if_phy->priv->soc_data; +struct device *dev = if_phy->priv->dev; +struct regmap_field *regfield; +int ret, rgmii_id =0 ; +u32 mode =0 ; + + if_phy->phy_if_mode = intf_mode; + +switch (if_phy->phy_if_mode) { +case PHY_INTERFACE_MODE_RMII : + mode =AM33XX_GMII_SEL_MODE_RMII ; +break ; +
drivers/phy/ti/phy-gmii-sel.c line 80
Quoted 10 lines
drivers/phy/ti/phy-gmii-sel.c new file +10
-0+case PHY_INTERFACE_MODE_RGMII : + mode =AM33XX_GMII_SEL_MODE_RGMII ; +break ; + +case PHY_INTERFACE_MODE_RGMII_ID : +case PHY_INTERFACE_MODE_RGMII_RXID : +case PHY_INTERFACE_MODE_RGMII_TXID : + mode =AM33XX_GMII_SEL_MODE_RGMII ; + rgmii_id =1 ; +break ;
Hi Grygorii
It looks like the MAC can do AM33XX_GMII_SEL_MODE_RGMII and AM33XX_GMII_SEL_MODE_RGMII_ID. I don't think it can do AM33XX_GMII_SEL_MODE_RGMII_RXID or AM33XX_GMII_SEL_MODE_RGMII_TXID? I would prefer it return -EINVAL when asked to do something it cannot do.
drivers/phy/ti/phy-gmii-sel.c line 86
Quoted 6 lines
drivers/phy/ti/phy-gmii-sel.c new file +6
-0+ +default : +dev_warn (dev, +"port%u: unsupported mode: \"%s\". Defaulting to MII.\n" , + if_phy->id,phy_modes (rgmii_id)); +/* fall through */
Returning -EINVAL would be better. Otherwise the DT might never get fixed.
Quoted 19 lines
drivers/phy/ti/phy-gmii-sel.c new file +19
-0+case PHY_INTERFACE_MODE_MII : + mode =AM33XX_GMII_SEL_MODE_MII ; +break ; + }; + +dev_dbg (dev,"%s id:%u mode:%u rgmii_id:%d rmii_clk_ext:%d\n" , + __func__, if_phy->id, mode, rgmii_id, + if_phy->rmii_clock_external); + + regfield = if_phy->fields[PHY_GMII_SEL_PORT_MODE ]; + ret =regmap_field_write (regfield, mode); + +if (soc_data->features &BIT (PHY_GMII_SEL_RGMII_ID_MODE ) && + if_phy->fields[PHY_GMII_SEL_RGMII_ID_MODE ]) { + regfield = if_phy->fields[PHY_GMII_SEL_RGMII_ID_MODE ]; + ret |=regmap_field_write (regfield, rgmii_id); + } + + if (soc_data->features & BIT(PHY_GMII_SEL_RMII_IO_CLK_EN) &&
drivers/phy/ti/phy-gmii-sel.c line 115
Quoted 10 lines
drivers/phy/ti/phy-gmii-sel.c new file +10
-0+ if_phy->fields[PHY_GMII_SEL_RMII_IO_CLK_EN]) { + regfield = if_phy->fields[PHY_GMII_SEL_RMII_IO_CLK_EN ]; + ret |=regmap_field_write (regfield, + if_phy->rmii_clock_external); + } + +if (ret) { +dev_err (dev,"port%u: set mode fail %d" , if_phy->id, ret); +return -EIO ; + }
I would prefer each write had its own error check. The fact you don't return ret means you know ret could be -EINVAL|-EOIO, making -EMORECOFFEE.
Andrew
Re: [RFC PATCH 03/11] phy: ti: introduce phy-gmii-sel driver
Hi Andrew,
Quoted 30 lines · Andrew Lunn
Quoted 16 lines · Grygorii Strashko
drivers/phy/ti/phy-gmii-sel.c new file +16
-0+static int phy_gmii_sel_mode (struct phy *phy,phy_interface_t intf_mode) +{ +struct phy_gmii_sel_phy_priv *if_phy =phy_get_drvdata (phy); +const struct phy_gmii_sel_soc_data *soc_data = if_phy->priv->soc_data; +struct device *dev = if_phy->priv->dev; +struct regmap_field *regfield; +int ret, rgmii_id =0 ; +u32 mode =0 ; + + if_phy->phy_if_mode = intf_mode; + +switch (if_phy->phy_if_mode) { +case PHY_INTERFACE_MODE_RMII : + mode =AM33XX_GMII_SEL_MODE_RMII ; +break ; +drivers/phy/ti/phy-gmii-sel.c line 80
Quoted 10 lines
drivers/phy/ti/phy-gmii-sel.c new file +10
-0+case PHY_INTERFACE_MODE_RGMII : + mode =AM33XX_GMII_SEL_MODE_RGMII ; +break ; + +case PHY_INTERFACE_MODE_RGMII_ID : +case PHY_INTERFACE_MODE_RGMII_RXID : +case PHY_INTERFACE_MODE_RGMII_TXID : + mode =AM33XX_GMII_SEL_MODE_RGMII ; + rgmii_id =1 ; +break ;Hi Grygorii
Quoted 3 lines
It looks like the MAC can do
AM33XX_GMII_SEL_MODE_RGMIIandAM33XX_GMII_SEL_MODE_RGMII_ID. I don't think it can doAM33XX_GMII_SEL_MODE_RGMII_RXIDorAM33XX_GMII_SEL_MODE_RGMII_TXID?
Sry, but would prefer not to thought this logic as part of this series as i moved it here unchanged rom cpsw-phy-sel.c (except adding possibility to update only supported field) and any changes here would require separate review (including all existing TI DT boards) and testing.
I
Quoted 2 lines
would prefer it return
-EINVALwhen asked to do something it cannot do.
Just to clarify rgmii_id = 1 means *disable* CPSW Internal Delay Mode.
Quoted 10 lines
drivers/phy/ti/phy-gmii-sel.c line 86
Quoted 7 lines
drivers/phy/ti/phy-gmii-sel.c new file +6
-0+ +default : +dev_warn (dev, +"port%u: unsupported mode: \"%s\". Defaulting to MII.\n" , + if_phy->id,phy_modes (rgmii_id)); +/* fall through */ Returning
-EINVALwould be better. Otherwise the DT might never get fixed.
ok
Quoted 26 lines
Quoted 26 lines
drivers/phy/ti/phy-gmii-sel.c new file +25
-0+case PHY_INTERFACE_MODE_MII : + mode =AM33XX_GMII_SEL_MODE_MII ; +break ; + }; + +dev_dbg (dev,"%s id:%u mode:%u rgmii_id:%d rmii_clk_ext:%d\n" , + __func__, if_phy->id, mode, rgmii_id, + if_phy->rmii_clock_external); + + regfield = if_phy->fields[PHY_GMII_SEL_PORT_MODE ]; + ret =regmap_field_write (regfield, mode); + +if (soc_data->features &BIT (PHY_GMII_SEL_RGMII_ID_MODE ) && + if_phy->fields[PHY_GMII_SEL_RGMII_ID_MODE ]) { + regfield = if_phy->fields[PHY_GMII_SEL_RGMII_ID_MODE ]; + ret |=regmap_field_write (regfield, rgmii_id); + } + +if (soc_data->features &BIT (PHY_GMII_SEL_RMII_IO_CLK_EN ) && + if_phy->fields[PHY_GMII_SEL_RMII_IO_CLK_EN ]) { + regfield = if_phy->fields[PHY_GMII_SEL_RMII_IO_CLK_EN ]; + ret |=regmap_field_write (regfield, + if_phy->rmii_clock_external); + } +
Quoted 8 lines
drivers/phy/ti/phy-gmii-sel.c line 115
Quoted 4 lines
drivers/phy/ti/phy-gmii-sel.c new file +4
-0+if (ret) { +dev_err (dev,"port%u: set mode fail %d" , if_phy->id, ret); +return -EIO ; + }I would prefer each write had its own error check. The fact you don't return ret means you know ret could be -EINVAL|-EOIO, making
-EMORECOFFEE.
:) right, sry.
Signature · 2 lines
regards, -grygorii
RFC PATCH 4/11 dt-bindings: net: ti: cpsw: switch to use phy-gmii-sel phy
In reply to Grygorii StrashkoThe cpsw-phy-sel driver was replaced with new PHY driver phy-gmii-sel, so deprecate cpsw-phy-sel bindings and update CPSW binding to use phy-gmii-sel PHY bindings.
--- Documentation/devicetree/bindings/net/cpsw.txt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/net/cpsw.txt +7 -1
@@ -22,7 +22,8 @@ Required properties: - cpsw-phy-sel : Specifies the phandle to the CPSW phy mode selection device. See also cpsw-phy-sel.txt for it's binding. Note that in legacy cases cpsw-phy-sel may be - a child device instead of a phandle. + a child device instead of a phandle + (DEPRECATED, use phy-gmii-sel PHY phandle). Optional properties: - ti,hwmods : Must be "cpgmac0"
@@ -44,6 +45,7 @@ Optional properties: Slave Properties: Required properties: - phy-mode : See ethernet.txt file in the same directory +- phys : phandle on phy-gmii-sel PHY (see phy/ti-phy-gmii-sel.txt) Optional properties: - dual_emac_res_vlan : Specifies VID to be used to segregate the ports
@@ -85,12 +87,14 @@ Examples: phy-mode = "rgmii-txid"; /* Filled in by U-Boot */ mac-address = [ 00 00 00 00 00 00 ]; + phys = <&phy_gmii_sel 1 0>; }; cpsw_emac1: slave@1 { phy_id = <&davinci_mdio>, <1>; phy-mode = "rgmii-txid"; /* Filled in by U-Boot */ mac-address = [ 00 00 00 00 00 00 ]; + phys = <&phy_gmii_sel 2 0>; }; };
@@ -114,11 +118,13 @@ Examples: phy-mode = "rgmii-txid"; /* Filled in by U-Boot */ mac-address = [ 00 00 00 00 00 00 ]; + phys = <&phy_gmii_sel 1 0>; }; cpsw_emac1: slave@1 { phy_id = <&davinci_mdio>, <1>; phy-mode = "rgmii-txid"; /* Filled in by U-Boot */ mac-address = [ 00 00 00 00 00 00 ]; + phys = <&phy_gmii_sel 2 0>; }; };
Signature · 1 line
2.10.5
Rob Herring
maintainerRe: [RFC PATCH 04/11] dt-bindings: net: ti: cpsw: switch to use phy-gmii-sel phy
Quoted 16 lines · Grygorii Strashko
The cpsw-phy-sel driver was replaced with new PHY driver phy-gmii-sel, so deprecate cpsw-phy-sel bindings and update CPSW binding to use phy-gmii-sel PHY bindings.
Cc Kishon Vijay Abraham I <[email protected]>Cc Tony Lindgren <[email protected]>Signed-off-by Grygorii Strashko <[email protected]>--- Documentation/devicetree/bindings/net/cpsw.txt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)Documentation/devicetree/bindings/net/cpsw.txt +0
-0
Documentation/devicetree/bindings/net/cpsw.txt Required properties: · line 26
Quoted 6 lines
Documentation/devicetree/bindings/net/cpsw.txt +2
-1@@ -22,7 +22,8 @@ Required properties: - cpsw-phy-sel : Specifies the phandle to the CPSW phy mode selection device. See also cpsw-phy-sel.txt for it's binding. Note that in legacy cases cpsw-phy-sel may be - a child device instead of a phandle. + a child device instead of a phandle + (DEPRECATED, use phy-gmii-sel PHY phandle).
phy-gmii-sel is outside the scope of this binding. Just say use 'phys' property instead.
Quoted 43 lines
Documentation/devicetree/bindings/net/cpsw.txt +5
-0Optional properties: - ti,hwmods : Must be "cpgmac0"@@ -44,6 +45,7 @@ Optional properties: Slave Properties: Required properties: - phy-mode : See ethernet.txt file in the same directory +- phys : phandle on phy-gmii-sel PHY (see phy/ti-phy-gmii-sel.txt) Optional properties: - dual_emac_res_vlan : Specifies VID to be used to segregate the ports@@ -85,12 +87,14 @@ Examples: phy-mode = "rgmii-txid"; /* Filled in by U-Boot */ mac-address = [ 00 00 00 00 00 00 ]; + phys = <&phy_gmii_sel 1 0>; }; cpsw_emac1: slave@1 { phy_id = <&davinci_mdio>, <1>; phy-mode = "rgmii-txid"; /* Filled in by U-Boot */ mac-address = [ 00 00 00 00 00 00 ]; + phys = <&phy_gmii_sel 2 0>; }; };@@ -114,11 +118,13 @@ Examples: phy-mode = "rgmii-txid"; /* Filled in by U-Boot */ mac-address = [ 00 00 00 00 00 00 ]; + phys = <&phy_gmii_sel 1 0>; }; cpsw_emac1: slave@1 { phy_id = <&davinci_mdio>, <1>; phy-mode = "rgmii-txid"; /* Filled in by U-Boot */ mac-address = [ 00 00 00 00 00 00 ]; + phys = <&phy_gmii_sel 2 0>; }; };Signature · 1 line
2.10.5
RFC PATCH 5/11 net: ethernet: ti: cpsw: add support for port interface mode selection phy
In reply to Grygorii StrashkoAdd support for port interface mode selection phy (phy-gmii-sel):
- try to request interface mode selection phy from Port DT node and fail silently if not defined and old CONFIG_TI_CPSW_PHY_SEL driver enabled.
- use new phy if requested successfully.
--- drivers/net/ethernet/ti/cpsw.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)
drivers/net/ethernet/ti/cpsw.c +17 -1
@@ -26,6 +26,7 @@#include <linux/netdevice.h> #include <linux/net_tstamp.h> #include <linux/phy.h> +#include <linux/phy/phy.h> #include <linux/workqueue.h> #include <linux/delay.h> #include <linux/pm_runtime.h>
@@ -387,6 +388,7 @@ struct cpsw_slave_data {int phy_if;u8 mac_addr[ETH_ALEN ];u16 dual_emac_res_vlan;/* Reserved VLAN for DualEMAC */ +struct phy *ifphy; };struct cpsw_platform_data {
@@ -1502,7 +1504,11 @@ static void cpsw_slave_open(struct cpsw_slave *slave, struct cpsw_priv *priv)phy_start (slave->phy);/* Configure GMII_SEL register */ -cpsw_phy_sel (cpsw->dev, slave->phy->interface, slave->slave_num); +if (!IS_ERR (slave->data->ifphy)) +phy_set_netif_mode (slave->data->ifphy, slave->data->phy_if); +else +cpsw_phy_sel (cpsw->dev, slave->phy->interface, + slave->slave_num); }static inline void cpsw_add_default_vlan (struct cpsw_priv *priv)
@@ -3135,6 +3141,16 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,if (strcmp (slave_node->name,"slave" ))continue ; + slave_data->ifphy =devm_of_phy_get (&pdev->dev, slave_node, +NULL ); +if (!IS_ENABLED (CONFIG_TI_CPSW_PHY_SEL ) && +IS_ERR (slave_data->ifphy)) { + ret =PTR_ERR (slave_data->ifphy); +dev_err (&pdev->dev, +"%d: Error retrieving port phy: %d\n" , i, ret); +return ret; + } + slave_data->phy_node =of_parse_phandle (slave_node,"phy-handle" ,0 ); parp =of_get_property (slave_node,"phy_id" , &lenp);
Signature · 1 line
2.10.5
Re: [RFC PATCH 05/11] net: ethernet: ti: cpsw: add support for port interface mode selection phy
drivers/net/ethernet/ti/cpsw.c static void cpsw_slave_open(struct cpsw_slave *slave, struct cpsw_priv *priv) · line 1508
Quoted 4 lines
drivers/net/ethernet/ti/cpsw.c +2
-1/* Configure GMII_SEL register */ -cpsw_phy_sel (cpsw->dev, slave->phy->interface, slave->slave_num); +if (!IS_ERR (slave->data->ifphy)) +phy_set_netif_mode (slave->data->ifphy, slave->data->phy_if);
Is slave->data->phy_if also passed to phy_connect()? So you are going to end up with both the MAC and the PHY inserting RGMII delays, and it not working.
You need to somehow decide if the MAC is going to do the delay, or the PHY. But not both.
Andrew
Re: [RFC PATCH 05/11] net: ethernet: ti: cpsw: add support for port interface mode selection phy
Hi Andrew,
Quoted 8 lines · Andrew Lunn
drivers/net/ethernet/ti/cpsw.c static void cpsw_slave_open(struct cpsw_slave *slave, struct cpsw_priv *priv) · line 1508
Quoted 4 lines
/* Configure
GMII_SELregister */drivers/net/ethernet/ti/cpsw.c +2
-1-cpsw_phy_sel (cpsw->dev, slave->phy->interface, slave->slave_num); +if (!IS_ERR (slave->data->ifphy)) +phy_set_netif_mode (slave->data->ifphy, slave->data->phy_if);Is
slave->data->phy_ifalso passed tophy_connect()? So you are going to end up with both the MAC and the PHY inserting RGMII delays, and it not working.
No. This logic not changed comparing to how it was.
* "rgmii" (RX and TX delays are added by the MAC when required)
rgmii_id = 0 --> CPSW: 0 : Internal Delay, PHY - no delay
* "rgmii-id" (RGMII with internal RX and TX delays provided by the PHY, the MAC should not add the RX or TX delays in this case)
* "rgmii-rxid" (RGMII with internal RX delay provided by the PHY, the MAC should not add an RX delay in this case)
* "rgmii-txid" (RGMII with internal TX delay provided by the PHY, the MAC should not add an TX delay in this case)
rgmii_id = 1 --> CPSW: 1 : No Internal Delay, PHY/board - delay
Quoted 3 lines
You need to somehow decide if the MAC is going to do the delay, or the PHY. But not both.
Again, this series does not change logic - only interfaces and DT.
Thank you for review.
Signature · 2 lines
regards, -grygorii
RFC PATCH 6/11 ARM: dts: dra7: switch to use phy-gmii-sel
In reply to Grygorii StrashkoSwitch to use phy-gmii-sel PHY instead of cpsw-phy-sel.
--- arch/arm/boot/dts/dra7.dtsi | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
arch/arm/boot/dts/dra7.dtsi +8 -6
@@ -187,6 +187,12 @@ }; }; + phy_gmii_sel: phy-gmii-sel { + compatible = "ti,dra7xx-phy-gmii-sel"; + syscon-scm = <&scm_conf>; + #phy-cells = <1>; + }; + scm_conf_clocks: clocks { #address-cells = <1>; #size-cells = <0>;
@@ -1879,17 +1885,13 @@ cpsw_emac0: slave@48480200 { /* Filled in by U-Boot */ mac-address = [ 00 00 00 00 00 00 ]; + phys = <&phy_gmii_sel 1>; }; cpsw_emac1: slave@48480300 { /* Filled in by U-Boot */ mac-address = [ 00 00 00 00 00 00 ]; - }; - - phy_sel: cpsw-phy-sel@4a002554 { - compatible = "ti,dra7xx-cpsw-phy-sel"; - reg= <0x4a002554 0x4>; - reg-names = "gmii-sel"; + phys = <&phy_gmii_sel 2>; }; };
Signature · 1 line
2.10.5
RFC PATCH 7/11 ARM: dts: dm814x: switch to use phy-gmii-sel
In reply to Grygorii StrashkoSwitch to use phy-gmii-sel PHY instead of cpsw-phy-sel.
--- arch/arm/boot/dts/dm814x.dtsi | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
arch/arm/boot/dts/dm814x.dtsi +9 -6
@@ -343,6 +343,12 @@ #size-cells = <1>; ranges = <0 0 0x800>; + phy_gmii_sel: phy-gmii-sel { + compatible = "ti,dm814-phy-gmii-sel"; + syscon-scm = <&scm_conf>; + #phy-cells = <1>; + }; + scm_clocks: clocks { #address-cells = <1>; #size-cells = <0>;
@@ -549,17 +555,14 @@ cpsw_emac0: slave@4a100200 { /* Filled in by U-Boot */ mac-address = [ 00 00 00 00 00 00 ]; + phys = <&phy_gmii_sel 1>; + }; cpsw_emac1: slave@4a100300 { /* Filled in by U-Boot */ mac-address = [ 00 00 00 00 00 00 ]; - }; - - phy_sel: cpsw-phy-sel@48140650 { - compatible = "ti,am3352-cpsw-phy-sel"; - reg= <0x48140650 0x4>; - reg-names = "gmii-sel"; + phys = <&phy_gmii_sel 2>; }; };
Signature · 1 line
2.10.5
RFC PATCH 8/11 ARM: dts: am4372: switch to use phy-gmii-sel
In reply to Grygorii StrashkoSwitch to use phy-gmii-sel PHY instead of cpsw-phy-sel.
--- arch/arm/boot/dts/am4372.dtsi | 16 +++++++++------- arch/arm/boot/dts/am43x-epos-evm.dts | 5 +---- 2 files changed, 10 insertions(+), 11 deletions(-)
arch/arm/boot/dts/am4372.dtsi +9 -7
@@ -212,11 +212,17 @@ }; scm_conf: scm_conf@0 { - compatible = "syscon"; + compatible = "syscon", "simple-bus"; reg = <0x0 0x800>; #address-cells = <1>; #size-cells = <1>; + phy_gmii_sel: phy-gmii-sel { + compatible = "ti,am43xx-phy-gmii-sel"; + syscon-scm = <&scm_conf>; + #phy-cells = <2>; + }; + scm_clocks: clocks { #address-cells = <1>; #size-cells = <0>;
@@ -714,17 +720,13 @@ cpsw_emac0: slave@4a100200 { /* Filled in by U-Boot */ mac-address = [ 00 00 00 00 00 00 ]; + phys = <&phy_gmii_sel 1 0>; }; cpsw_emac1: slave@4a100300 { /* Filled in by U-Boot */ mac-address = [ 00 00 00 00 00 00 ]; - }; - - phy_sel: cpsw-phy-sel@44e10650 { - compatible = "ti,am43xx-cpsw-phy-sel"; - reg= <0x44e10650 0x4>; - reg-names = "gmii-sel"; + phys = <&phy_gmii_sel 2 0>; }; };
arch/arm/boot/dts/am43x-epos-evm.dts +1 -4
@@ -580,10 +580,7 @@ &cpsw_emac0 { phy_id = <&davinci_mdio>, <16>; phy-mode = "rmii"; -}; - -&phy_sel { - rmii-clock-ext; + phys = <&phy_gmii_sel 1 1>; }; &i2c0 {
Signature · 1 line
2.10.5
RFC PATCH 9/11 ARM: dts: am335x: switch to use phy-gmii-sel
In reply to Grygorii StrashkoSwitch to use phy-gmii-sel PHY instead of cpsw-phy-sel.
--- arch/arm/boot/dts/am335x-baltos-ir2110.dts | 4 ---- arch/arm/boot/dts/am335x-baltos-ir3220.dts | 3 --- arch/arm/boot/dts/am335x-baltos-ir5221.dts | 3 --- arch/arm/boot/dts/am335x-chiliboard.dts | 3 --- arch/arm/boot/dts/am335x-icev2.dts | 4 ---- arch/arm/boot/dts/am335x-igep0033.dtsi | 3 --- arch/arm/boot/dts/am335x-lxm.dts | 3 --- arch/arm/boot/dts/am335x-moxa-uc-8100-me-t.dts | 5 ----- arch/arm/boot/dts/am335x-phycore-som.dtsi | 3 --- arch/arm/boot/dts/am33xx.dtsi | 14 ++++++++------ 10 files changed, 8 insertions(+), 37 deletions(-)
arch/arm/boot/dts/am335x-baltos-ir2110.dts +0 -4
@@ -72,7 +72,3 @@ dual_emac_res_vlan = <2>; phy-handle = <&phy1>; }; - -&phy_sel { - rmii-clock-ext = <1>; -};
arch/arm/boot/dts/am335x-baltos-ir3220.dts +0 -3
@@ -115,6 +115,3 @@ phy-handle = <&phy1>; }; -&phy_sel { - rmii-clock-ext = <1>; -};
arch/arm/boot/dts/am335x-baltos-ir5221.dts +0 -3
@@ -133,9 +133,6 @@ phy-handle = <&phy1>; }; -&phy_sel { - rmii-clock-ext = <1>; -}; &dcan1 { pinctrl-names = "default";
arch/arm/boot/dts/am335x-chiliboard.dts +0 -3
@@ -147,9 +147,6 @@ phy-mode = "rmii"; }; -&phy_sel { - rmii-clock-ext; -}; /* USB */ &usb {
arch/arm/boot/dts/am335x-icev2.dts +0 -4
@@ -484,10 +484,6 @@ dual_emac; }; -&phy_sel { - rmii-clock-ext; -}; - &davinci_mdio { pinctrl-names = "default", "sleep"; pinctrl-0 = <&davinci_mdio_default>;
arch/arm/boot/dts/am335x-igep0033.dtsi +0 -3
@@ -114,9 +114,6 @@ phy-mode = "rmii"; }; -&phy_sel { - rmii-clock-ext; -}; &elm { status = "okay";
arch/arm/boot/dts/am335x-lxm.dts +0 -3
@@ -328,9 +328,6 @@ dual_emac_res_vlan = <3>; }; -&phy_sel { - rmii-clock-ext; -}; &mac { pinctrl-names = "default", "sleep";
arch/arm/boot/dts/am335x-moxa-uc-8100-me-t.dts +0 -5
@@ -438,11 +438,6 @@ dual_emac_res_vlan = <2>; }; -&phy_sel { - reg= <0x44e10650 0xf5>; - rmii-clock-ext; -}; - &sham { status = "okay"; };
arch/arm/boot/dts/am335x-phycore-som.dtsi +0 -3
@@ -100,9 +100,6 @@ status = "okay"; }; -&phy_sel { - rmii-clock-ext; -}; /* I2C Busses */ &am33xx_pinmux {
arch/arm/boot/dts/am33xx.dtsi +8 -6
@@ -222,6 +222,12 @@ #size-cells = <1>; ranges = <0 0 0x800>; + phy_gmii_sel: phy-gmii-sel { + compatible = "ti,am3352-phy-gmii-sel"; + syscon-scm = <&scm_conf>; + #phy-cells = <2>; + }; + scm_clocks: clocks { #address-cells = <1>; #size-cells = <0>;
@@ -890,17 +896,13 @@ cpsw_emac0: slave@4a100200 { /* Filled in by U-Boot */ mac-address = [ 00 00 00 00 00 00 ]; + phys = <&phy_gmii_sel 1 1>; }; cpsw_emac1: slave@4a100300 { /* Filled in by U-Boot */ mac-address = [ 00 00 00 00 00 00 ]; - }; - - phy_sel: cpsw-phy-sel@44e10650 { - compatible = "ti,am3352-cpsw-phy-sel"; - reg= <0x44e10650 0x4>; - reg-names = "gmii-sel"; + phys = <&phy_gmii_sel 2 1>; }; };
Signature · 1 line
2.10.5
RFC PATCH 10/11 dt-bindings: net: ti: deprecate cpsw-phy-sel bindings
In reply to Grygorii StrashkoThe cpsw-phy-sel driver was replaced with new PHY driver phy-gmii-sel, so deprecate cpsw-phy-sel bindings.
--- Documentation/devicetree/bindings/net/cpsw-phy-sel.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/devicetree/bindings/net/cpsw-phy-sel.txt +1 -1
@@ -1,4 +1,4 @@ -TI CPSW Phy mode Selection Device Tree Bindings +TI CPSW Phy mode Selection Device Tree Bindings (DEPRECATED) ----------------------------------------------- Required properties:
Signature · 1 line
2.10.5
Re: [RFC PATCH 10/11] dt-bindings: net: ti: deprecate cpsw-phy-sel bindings
Quoted 10 lines · Grygorii Strashko
The cpsw-phy-sel driver was replaced with new PHY driver phy-gmii-sel, so deprecate cpsw-phy-sel bindings.
Cc Kishon Vijay Abraham I <[email protected]>Cc Tony Lindgren <[email protected]>Signed-off-by Grygorii Strashko <[email protected]>--- Documentation/devicetree/bindings/net/cpsw-phy-sel.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
RFC PATCH 11/11 net: ethernet: ti: cpsw: deprecate cpsw-phy-sel driver
In reply to Grygorii StrashkoDeprecate cpsw-phy-sel driver as it's been replaced with new TI phy-gmii-sel PHY driver.
--- drivers/net/ethernet/ti/Kconfig | 6 +++--- drivers/net/ethernet/ti/cpsw.h | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-)
drivers/net/ethernet/ti/Kconfig +3 -3
@@ -49,10 +49,11 @@ config TI_DAVINCI_CPDMA will be called davinci_cpdma. This is recommended. config TI_CPSW_PHY_SEL - bool + bool "TI CPSW Phy mode Selection (DEPRECATED)" + default n ---help--- This driver supports configuring of the phy mode connected to - the CPSW. + the CPSW. DEPRECATED: use PHY_TI_GMII_SEL. config TI_CPSW_ALE tristate "TI CPSW ALE Support"
@@ -64,7 +65,6 @@ config TI_CPSW depends on ARCH_DAVINCI || ARCH_OMAP2PLUS || COMPILE_TEST select TI_DAVINCI_CPDMA select TI_DAVINCI_MDIO - select TI_CPSW_PHY_SEL select TI_CPSW_ALE select MFD_SYSCON select REGMAP
drivers/net/ethernet/ti/cpsw.h +6 -0
@@ -21,7 +21,13 @@ ((mac)[2] << 16) | ((mac)[3] << 24))#define mac_lo (mac) (((mac)[4] << 0) | ((mac)[5] << 8)) +#if IS_ENABLED (CONFIG_TI_CPSW_PHY_SEL )void cpsw_phy_sel (struct device *dev,phy_interface_t phy_mode,int slave); +#else +static inline +void cpsw_phy_sel (struct device *dev,phy_interface_t phy_mode,int slave) +{} +#endif int ti_cm_get_macid (struct device *dev,int slave,u8 *mac_addr);#endif /* __CPSW_H__ */
Signature · 1 line
2.10.5
Quoted 4 lines · Grygorii Strashko
2) introduce new PHY API for network interface mode selection which will use already defined set of modes from
phy_interface_t.Option 2 was selected for this series.
Looks good to me :) The dts files will cause merge conflicts with what I have pending for the ti-sysc changes so please send the dts changes in a separate series when posting without RFC.
Thanks,
Tony
Quoted 9 lines · Tony Lindgren
Quoted 4 lines · Grygorii Strashko
2) introduce new PHY API for network interface mode selection which will use already defined set of modes from
phy_interface_t.Option 2 was selected for this series.
Looks good to me :) The dts files will cause merge conflicts with what I have pending for the ti-sysc changes so please send the dts changes in a separate series when posting without RFC.
expected. I did on top of mauster, but will rebase and resend if approved.
Signature · 2 lines
regards, -grygorii