Commit cf3db45d authored by David S. Miller's avatar David S. Miller

Merge branch 'phy-internal'

Florian Fainelli says:

====================
net: phy: Support "internal" PHY interface

This makes the "internal" phy-mode property generally available and
documented and this allows us to remove some custom parsing code
we had for bcmgenet and bcm_sf2 which both used that specific value.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents d4d0249a bedd00c8
...@@ -11,6 +11,7 @@ The following properties are common to the Ethernet controllers: ...@@ -11,6 +11,7 @@ The following properties are common to the Ethernet controllers:
the maximum frame size (there's contradiction in ePAPR). the maximum frame size (there's contradiction in ePAPR).
- phy-mode: string, operation mode of the PHY interface. This is now a de-facto - phy-mode: string, operation mode of the PHY interface. This is now a de-facto
standard property; supported values are: standard property; supported values are:
* "internal"
* "mii" * "mii"
* "gmii" * "gmii"
* "sgmii" * "sgmii"
......
...@@ -498,10 +498,8 @@ static void bcm_sf2_identify_ports(struct bcm_sf2_priv *priv, ...@@ -498,10 +498,8 @@ static void bcm_sf2_identify_ports(struct bcm_sf2_priv *priv,
struct device_node *dn) struct device_node *dn)
{ {
struct device_node *port; struct device_node *port;
const char *phy_mode_str;
int mode; int mode;
unsigned int port_num; unsigned int port_num;
int ret;
priv->moca_port = -1; priv->moca_port = -1;
...@@ -515,15 +513,11 @@ static void bcm_sf2_identify_ports(struct bcm_sf2_priv *priv, ...@@ -515,15 +513,11 @@ static void bcm_sf2_identify_ports(struct bcm_sf2_priv *priv,
* time * time
*/ */
mode = of_get_phy_mode(port); mode = of_get_phy_mode(port);
if (mode < 0) { if (mode < 0)
ret = of_property_read_string(port, "phy-mode", continue;
&phy_mode_str);
if (ret < 0) if (mode == PHY_INTERFACE_MODE_INTERNAL)
continue; priv->int_phy_mask |= 1 << port_num;
if (!strcasecmp(phy_mode_str, "internal"))
priv->int_phy_mask |= 1 << port_num;
}
if (mode == PHY_INTERFACE_MODE_MOCA) if (mode == PHY_INTERFACE_MODE_MOCA)
priv->moca_port = port_num; priv->moca_port = port_num;
......
...@@ -251,11 +251,8 @@ int bcmgenet_mii_config(struct net_device *dev) ...@@ -251,11 +251,8 @@ int bcmgenet_mii_config(struct net_device *dev)
priv->ext_phy = !priv->internal_phy && priv->ext_phy = !priv->internal_phy &&
(priv->phy_interface != PHY_INTERFACE_MODE_MOCA); (priv->phy_interface != PHY_INTERFACE_MODE_MOCA);
if (priv->internal_phy)
priv->phy_interface = PHY_INTERFACE_MODE_NA;
switch (priv->phy_interface) { switch (priv->phy_interface) {
case PHY_INTERFACE_MODE_NA: case PHY_INTERFACE_MODE_INTERNAL:
case PHY_INTERFACE_MODE_MOCA: case PHY_INTERFACE_MODE_MOCA:
/* Irrespective of the actually configured PHY speed (100 or /* Irrespective of the actually configured PHY speed (100 or
* 1000) GENETv4 only has an internal GPHY so we will just end * 1000) GENETv4 only has an internal GPHY so we will just end
...@@ -471,7 +468,6 @@ static int bcmgenet_mii_of_init(struct bcmgenet_priv *priv) ...@@ -471,7 +468,6 @@ static int bcmgenet_mii_of_init(struct bcmgenet_priv *priv)
{ {
struct device_node *dn = priv->pdev->dev.of_node; struct device_node *dn = priv->pdev->dev.of_node;
struct device *kdev = &priv->pdev->dev; struct device *kdev = &priv->pdev->dev;
const char *phy_mode_str = NULL;
struct phy_device *phydev = NULL; struct phy_device *phydev = NULL;
char *compat; char *compat;
int phy_mode; int phy_mode;
...@@ -510,23 +506,19 @@ static int bcmgenet_mii_of_init(struct bcmgenet_priv *priv) ...@@ -510,23 +506,19 @@ static int bcmgenet_mii_of_init(struct bcmgenet_priv *priv)
/* Get the link mode */ /* Get the link mode */
phy_mode = of_get_phy_mode(dn); phy_mode = of_get_phy_mode(dn);
if (phy_mode < 0) {
dev_err(kdev, "invalid PHY mode property\n");
return phy_mode;
}
priv->phy_interface = phy_mode; priv->phy_interface = phy_mode;
/* We need to specifically look up whether this PHY interface is internal /* We need to specifically look up whether this PHY interface is internal
* or not *before* we even try to probe the PHY driver over MDIO as we * or not *before* we even try to probe the PHY driver over MDIO as we
* may have shut down the internal PHY for power saving purposes. * may have shut down the internal PHY for power saving purposes.
*/ */
if (phy_mode < 0) { if (priv->phy_interface == PHY_INTERFACE_MODE_INTERNAL)
ret = of_property_read_string(dn, "phy-mode", &phy_mode_str); priv->internal_phy = true;
if (ret < 0) {
dev_err(kdev, "invalid PHY mode property\n");
return ret;
}
priv->phy_interface = PHY_INTERFACE_MODE_NA;
if (!strcasecmp(phy_mode_str, "internal"))
priv->internal_phy = true;
}
/* Make sure we initialize MoCA PHYs with a link down */ /* Make sure we initialize MoCA PHYs with a link down */
if (phy_mode == PHY_INTERFACE_MODE_MOCA) { if (phy_mode == PHY_INTERFACE_MODE_MOCA) {
......
...@@ -64,6 +64,7 @@ ...@@ -64,6 +64,7 @@
/* Interface Mode definitions */ /* Interface Mode definitions */
typedef enum { typedef enum {
PHY_INTERFACE_MODE_NA, PHY_INTERFACE_MODE_NA,
PHY_INTERFACE_MODE_INTERNAL,
PHY_INTERFACE_MODE_MII, PHY_INTERFACE_MODE_MII,
PHY_INTERFACE_MODE_GMII, PHY_INTERFACE_MODE_GMII,
PHY_INTERFACE_MODE_SGMII, PHY_INTERFACE_MODE_SGMII,
...@@ -114,6 +115,8 @@ static inline const char *phy_modes(phy_interface_t interface) ...@@ -114,6 +115,8 @@ static inline const char *phy_modes(phy_interface_t interface)
switch (interface) { switch (interface) {
case PHY_INTERFACE_MODE_NA: case PHY_INTERFACE_MODE_NA:
return ""; return "";
case PHY_INTERFACE_MODE_INTERNAL:
return "internal";
case PHY_INTERFACE_MODE_MII: case PHY_INTERFACE_MODE_MII:
return "mii"; return "mii";
case PHY_INTERFACE_MODE_GMII: case PHY_INTERFACE_MODE_GMII:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment