net, phy, smsc: add posibility to disable energy detect mode
Subsystems (5)
v2 cover net, phy, smsc: add posibility to disable energy detect mode
On some boards the energy enable detect mode leads in trouble with some switches, so make the enabling of this mode configurable through DT.
Therefore the property "smsc,disable-energy-detect" is introduced.
Patch 1 introduces phy-handle support for the ti,cpsw driver. This is needed now for the smsc phy.
Patch 2 adds the disable energy mode functionality to the smsc phy
Changes in v2:
- add comments from Florian Fainelli
- I did not change disable property name into enable because I fear to break existing behaviour
- add smsc vendor prefix
- remove CONFIG_OF and use __maybe_unused
- introduce "phy-handle" ability into ti,cpsw driver, so I can remove bogus:
if (!of_node && dev->parent->of_node)
of_node = dev->parent->of_node;
construct. Therefore new patch for the ti,cpsw driver is necessary.
Heiko Schocher (2):
drivers: net: cpsw: add phy-handle parsing
net: phy: smsc: disable energy detect mode
Documentation/devicetree/bindings/net/cpsw.txt | 1 + .../devicetree/bindings/net/smsc-lan87xx.txt | 24 ++++++++++++++++++++++ drivers/net/ethernet/ti/cpsw.c | 15 ++++++++++---- drivers/net/phy/smsc.c | 19 ++++++++++++----- 4 files changed, 50 insertions(+), 9 deletions(-) create mode 100644 Documentation/devicetree/bindings/net/smsc-lan87xx.txt
Signature · 1 line
2.1.0
PATCH v2 1/2 drivers: net: cpsw: add phy-handle parsing
add the ability to parse "phy-handle". This
is needed for phys, which have a DT node, and
need to parse DT properties.
---
Changes in v2: None
Documentation/devicetree/bindings/net/cpsw.txt | 1 + drivers/net/ethernet/ti/cpsw.c | 15 +++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-)
Documentation/devicetree/bindings/net/cpsw.txt +1 -0
@@ -39,6 +39,7 @@ Required properties: Optional properties: - dual_emac_res_vlan : Specifies VID to be used to segregate the ports - mac-address : See ethernet.txt file in the same directory +- phy-handle : See ethernet.txt file in the same directory Note: "ti,hwmods" field is used to fetch the base address and irq resources from TI, omap hwmod data base during device registration.
drivers/net/ethernet/ti/cpsw.c +11 -4
@@ -30,6 +30,7 @@#include <linux/delay.h> #include <linux/pm_runtime.h> #include <linux/of.h> +#include <linux/of_mdio.h> #include <linux/of_net.h> #include <linux/of_device.h> #include <linux/if_vlan.h>
@@ -365,6 +366,7 @@ struct cpsw_priv {spinlock_t lock;struct platform_device *pdev;struct net_device *ndev; +struct device_node *phy_node;struct napi_struct napi_rx;struct napi_struct napi_tx;struct device *dev;
@@ -1145,7 +1147,11 @@ static void cpsw_slave_open(struct cpsw_slave *slave, struct cpsw_priv *priv)cpsw_ale_add_mcast (priv->ale, priv->ndev->broadcast,1 << slave_port,0 ,0 ,ALE_MCAST_FWD_2 ); - slave->phy =phy_connect (priv->ndev, slave->data->phy_id, +if (priv->phy_node) + slave->phy =of_phy_connect (priv->ndev, priv->phy_node, + &cpsw_adjust_link,0 , slave->data->phy_if); +else + slave->phy =phy_connect (priv->ndev, slave->data->phy_id, &cpsw_adjust_link, slave->data->phy_if);if (IS_ERR (slave->phy)) { dev_err(priv->dev, "phy %s not found on slave %d\n",
@@ -1934,11 +1940,12 @@ static void cpsw_slave_init(struct cpsw_slave *slave, struct cpsw_priv *priv, slave->port_vlan = data->dual_emac_res_vlan; } -static int cpsw_probe_dt (struct cpsw_platform_data *data, +static int cpsw_probe_dt (struct cpsw_priv *priv,struct platform_device *pdev) {struct device_node *node = pdev->dev.of_node;struct device_node *slave_node; +struct cpsw_platform_data *data = &priv->data;int i =0 , ret;u32 prop;
@@ -2029,6 +2036,7 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,if (strcmp (slave_node->name,"slave" ))continue ; + priv->phy_node =of_parse_phandle (slave_node,"phy-handle" ,0 ); parp =of_get_property (slave_node,"phy_id" , &lenp);if ((parp ==NULL ) || (lenp != (sizeof (void *) *2 ))) {dev_err (&pdev->dev,"Missing slave[%d] phy_id property\n" , i);
@@ -2044,7 +2052,6 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data, }snprintf (slave_data->phy_id,sizeof (slave_data->phy_id),PHY_ID_FMT , mdio->name, phyid); - slave_data->phy_if =of_get_phy_mode (slave_node);if (slave_data->phy_if <0 ) { dev_err(&pdev->dev, "Missing or malformed slave[%d] phy-mode property\n",
@@ -2240,7 +2247,7 @@ static int cpsw_probe(struct platform_device *pdev)/* Select default pin state */ pinctrl_pm_select_default_state (&pdev->dev); -if (cpsw_probe_dt (&priv->data, pdev)) { +if (cpsw_probe_dt (priv, pdev)) {dev_err (&pdev->dev,"cpsw: platform data missing\n" ); ret = -ENODEV ; goto clean_runtime_disable_ret;
Signature · 1 line
2.1.0
PATCH v2 1/2 drivers: net: cpsw: add phy-handle parsing
In reply to Heiko Schocheradd the ability to parse "phy-handle". This
is needed for phys, which have a DT node, and
need to parse DT properties.
---
Changes in v2: None
Documentation/devicetree/bindings/net/cpsw.txt | 1 + drivers/net/ethernet/ti/cpsw.c | 15 +++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-)
Documentation/devicetree/bindings/net/cpsw.txt +1 -0
@@ -39,6 +39,7 @@ Required properties: Optional properties: - dual_emac_res_vlan : Specifies VID to be used to segregate the ports - mac-address : See ethernet.txt file in the same directory +- phy-handle : See ethernet.txt file in the same directory Note: "ti,hwmods" field is used to fetch the base address and irq resources from TI, omap hwmod data base during device registration.
drivers/net/ethernet/ti/cpsw.c +11 -4
@@ -30,6 +30,7 @@#include <linux/delay.h> #include <linux/pm_runtime.h> #include <linux/of.h> +#include <linux/of_mdio.h> #include <linux/of_net.h> #include <linux/of_device.h> #include <linux/if_vlan.h>
@@ -365,6 +366,7 @@ struct cpsw_priv {spinlock_t lock;struct platform_device *pdev;struct net_device *ndev; +struct device_node *phy_node;struct napi_struct napi_rx;struct napi_struct napi_tx;struct device *dev;
@@ -1145,7 +1147,11 @@ static void cpsw_slave_open(struct cpsw_slave *slave, struct cpsw_priv *priv)cpsw_ale_add_mcast (priv->ale, priv->ndev->broadcast,1 << slave_port,0 ,0 ,ALE_MCAST_FWD_2 ); - slave->phy =phy_connect (priv->ndev, slave->data->phy_id, +if (priv->phy_node) + slave->phy =of_phy_connect (priv->ndev, priv->phy_node, + &cpsw_adjust_link,0 , slave->data->phy_if); +else + slave->phy =phy_connect (priv->ndev, slave->data->phy_id, &cpsw_adjust_link, slave->data->phy_if);if (IS_ERR (slave->phy)) { dev_err(priv->dev, "phy %s not found on slave %d\n",
@@ -1934,11 +1940,12 @@ static void cpsw_slave_init(struct cpsw_slave *slave, struct cpsw_priv *priv, slave->port_vlan = data->dual_emac_res_vlan; } -static int cpsw_probe_dt (struct cpsw_platform_data *data, +static int cpsw_probe_dt (struct cpsw_priv *priv,struct platform_device *pdev) {struct device_node *node = pdev->dev.of_node;struct device_node *slave_node; +struct cpsw_platform_data *data = &priv->data;int i =0 , ret;u32 prop;
@@ -2029,6 +2036,7 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,if (strcmp (slave_node->name,"slave" ))continue ; + priv->phy_node =of_parse_phandle (slave_node,"phy-handle" ,0 ); parp =of_get_property (slave_node,"phy_id" , &lenp);if ((parp ==NULL ) || (lenp != (sizeof (void *) *2 ))) {dev_err (&pdev->dev,"Missing slave[%d] phy_id property\n" , i);
@@ -2044,7 +2052,6 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data, }snprintf (slave_data->phy_id,sizeof (slave_data->phy_id),PHY_ID_FMT , mdio->name, phyid); - slave_data->phy_if =of_get_phy_mode (slave_node);if (slave_data->phy_if <0 ) { dev_err(&pdev->dev, "Missing or malformed slave[%d] phy-mode property\n",
@@ -2240,7 +2247,7 @@ static int cpsw_probe(struct platform_device *pdev)/* Select default pin state */ pinctrl_pm_select_default_state (&pdev->dev); -if (cpsw_probe_dt (&priv->data, pdev)) { +if (cpsw_probe_dt (priv, pdev)) {dev_err (&pdev->dev,"cpsw: platform data missing\n" ); ret = -ENODEV ; goto clean_runtime_disable_ret;
Signature · 1 line
2.1.0
PATCH v2 2/2 net: phy: smsc: disable energy detect mode
In reply to Heiko SchocherOn some boards the energy enable detect mode leads in trouble with some switches, so make the enabling of this mode configurable through DT.
---
Changes in v2:
- add comments from Florian Fainelli
- I did not change disable property name into enable because I fear to break existing behaviour
- add smsc vendor prefix
- remove CONFIG_OF and use __maybe_unused
- introduce "phy-handle" ability into ti,cpsw driver, so I can remove bogus:
if (!of_node && dev->parent->of_node)
of_node = dev->parent->of_node;
construct. Therefore new patch for the ti,cpsw driver is necessary.
.../devicetree/bindings/net/smsc-lan87xx.txt | 24 ++++++++++++++++++++++ drivers/net/phy/smsc.c | 19 ++++++++++++----- 2 files changed, 38 insertions(+), 5 deletions(-) create mode 100644 Documentation/devicetree/bindings/net/smsc-lan87xx.txt
Documentation/devicetree/bindings/net/smsc-lan87xx.txt new file +24 -0
@@ -0,0 +1,24 @@ +SMSC LAN87xx Ethernet PHY + +Some boards require special tuning values. Configure them +through an Ethernet OF device node. + +Optional properties: + +- smsc,disable-energy-detect: + If set, do not enable energy detect mode for the SMSC phy. + default: enable energy detect mode + +Examples: +smsc phy with disabled energy detect mode on an am335x based board. +&davinci_mdio { + pinctrl-names = "default", "sleep"; + pinctrl-0 = <&davinci_mdio_default>; + pinctrl-1 = <&davinci_mdio_sleep>; + status = "okay"; + + ethernetphy0: ethernet-phy@0 { + reg = <0>; + smsc,disable-energy-detect; + }; +};
drivers/net/phy/smsc.c +14 -5
@@ -43,16 +43,25 @@ static int smsc_phy_ack_interrupt(struct phy_device *phydev)static int smsc_phy_config_init (struct phy_device *phydev) { +int __maybe_unused len; +struct device *dev__maybe_unused = &phydev->dev; +struct device_node *of_node__maybe_unused = dev->of_node;int rc =phy_read (phydev,MII_LAN83C185_CTRL_STATUS ); +int enable_energy =1 ;if (rc <0 )return rc; -/* Enable energy detect mode for this SMSC Transceivers */ - rc =phy_write (phydev,MII_LAN83C185_CTRL_STATUS , - rc |MII_LAN83C185_EDPWRDOWN ); -if (rc <0 ) -return rc; +if (of_find_property (of_node,"smsc,disable-energy-detect" , &len)) + enable_energy =0 ; + +if (enable_energy) { +/* Enable energy detect mode for this SMSC Transceivers */ + rc =phy_write (phydev,MII_LAN83C185_CTRL_STATUS , + rc |MII_LAN83C185_EDPWRDOWN ); +if (rc <0 ) +return rc; + }return smsc_phy_ack_interrupt (phydev); }
Signature · 6 lines
2.1.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
David Miller
maintainerFrom: Heiko Schocher <[email protected]>
Date: Sat, 17 Oct 2015 06:04:34 +0200
Quoted 11 lines
On some boards the energy enable detect mode leads in trouble with some switches, so make the enabling of this mode configurable through DT.
Therefore the property "smsc,disable-energy-detect" is introduced.Patch 1 introduces phy-handle support for the ti,cpsw driver. This is needed now for the smsc phy.
Patch 2 adds the disable energy mode functionality to the smsc phy
Series applied, thanks.