2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2011-04-08 02:56:05 +00:00
|
|
|
/*
|
|
|
|
* Micrel PHY drivers
|
|
|
|
*
|
|
|
|
* Copyright 2010-2011 Freescale Semiconductor, Inc.
|
|
|
|
* author Andy Fleming
|
2013-02-06 21:18:37 +00:00
|
|
|
* (C) 2012 NetModule AG, David Andrey, added KSZ9031
|
net: phy: micrel: Separate KSZ9000 drivers from KSZ8000 drivers
The KS8721BL and KSZ9021 PHYs are software-incompatible, yet they
share the same ID. Drivers for bothe PHYs cannot safely coexist, so
the solution was to use #ifdefs to select between the two drivers.
As a result KSZ9031, which has a unique ID, is now caught in the
crossfire. Unless CONFIG_PHY_MICREL_KSZ9031 is defined, the KSZ9031
will not function properly, as some essential configuration code is
ifdef'd-out.
To prevent such situations, move the KSZ9000 drivers to a separate
file, and place them under a separate Kconfig option. While it is
possible to enable both KSZ8000 and KSZ9000 drivers at the same time,
the assumption is that it is highly unlikely for a system to contain
both a KSZ8000 and a KSZ9000 PHY, and that only one of the drivers
will be enabled at any given time.
Signed-off-by: Alexandru Gagniuc <alex.g@adaptrum.com>
Reviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
2017-07-07 18:36:57 +00:00
|
|
|
* (C) Copyright 2017 Adaptrum, Inc.
|
|
|
|
* Written by Alexandru Gagniuc <alex.g@adaptrum.com> for Adaptrum, Inc.
|
2011-04-08 02:56:05 +00:00
|
|
|
*/
|
2012-02-07 14:08:48 +00:00
|
|
|
#include <common.h>
|
2015-12-05 16:41:58 +00:00
|
|
|
#include <dm.h>
|
2019-08-01 15:46:52 +00:00
|
|
|
#include <env.h>
|
2015-12-05 16:41:58 +00:00
|
|
|
#include <errno.h>
|
2012-02-07 14:08:48 +00:00
|
|
|
#include <micrel.h>
|
2011-04-08 02:56:05 +00:00
|
|
|
#include <phy.h>
|
|
|
|
|
2014-09-09 12:26:51 +00:00
|
|
|
/*
|
2013-02-06 21:18:37 +00:00
|
|
|
* KSZ9021 - KSZ9031 common
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define MII_KSZ90xx_PHY_CTL 0x1f
|
|
|
|
#define MIIM_KSZ90xx_PHYCTL_1000 (1 << 6)
|
|
|
|
#define MIIM_KSZ90xx_PHYCTL_100 (1 << 5)
|
|
|
|
#define MIIM_KSZ90xx_PHYCTL_10 (1 << 4)
|
|
|
|
#define MIIM_KSZ90xx_PHYCTL_DUPLEX (1 << 3)
|
|
|
|
|
net: phy: micrel: Separate KSZ9000 drivers from KSZ8000 drivers
The KS8721BL and KSZ9021 PHYs are software-incompatible, yet they
share the same ID. Drivers for bothe PHYs cannot safely coexist, so
the solution was to use #ifdefs to select between the two drivers.
As a result KSZ9031, which has a unique ID, is now caught in the
crossfire. Unless CONFIG_PHY_MICREL_KSZ9031 is defined, the KSZ9031
will not function properly, as some essential configuration code is
ifdef'd-out.
To prevent such situations, move the KSZ9000 drivers to a separate
file, and place them under a separate Kconfig option. While it is
possible to enable both KSZ8000 and KSZ9000 drivers at the same time,
the assumption is that it is highly unlikely for a system to contain
both a KSZ8000 and a KSZ9000 PHY, and that only one of the drivers
will be enabled at any given time.
Signed-off-by: Alexandru Gagniuc <alex.g@adaptrum.com>
Reviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
2017-07-07 18:36:57 +00:00
|
|
|
/* KSZ9021 PHY Registers */
|
|
|
|
#define MII_KSZ9021_EXTENDED_CTRL 0x0b
|
|
|
|
#define MII_KSZ9021_EXTENDED_DATAW 0x0c
|
|
|
|
#define MII_KSZ9021_EXTENDED_DATAR 0x0d
|
|
|
|
|
|
|
|
#define CTRL1000_PREFER_MASTER (1 << 10)
|
|
|
|
#define CTRL1000_CONFIG_MASTER (1 << 11)
|
|
|
|
#define CTRL1000_MANUAL_CONFIG (1 << 12)
|
|
|
|
|
2019-03-04 17:40:33 +00:00
|
|
|
#define KSZ9021_PS_TO_REG 120
|
|
|
|
|
net: phy: micrel: Separate KSZ9000 drivers from KSZ8000 drivers
The KS8721BL and KSZ9021 PHYs are software-incompatible, yet they
share the same ID. Drivers for bothe PHYs cannot safely coexist, so
the solution was to use #ifdefs to select between the two drivers.
As a result KSZ9031, which has a unique ID, is now caught in the
crossfire. Unless CONFIG_PHY_MICREL_KSZ9031 is defined, the KSZ9031
will not function properly, as some essential configuration code is
ifdef'd-out.
To prevent such situations, move the KSZ9000 drivers to a separate
file, and place them under a separate Kconfig option. While it is
possible to enable both KSZ8000 and KSZ9000 drivers at the same time,
the assumption is that it is highly unlikely for a system to contain
both a KSZ8000 and a KSZ9000 PHY, and that only one of the drivers
will be enabled at any given time.
Signed-off-by: Alexandru Gagniuc <alex.g@adaptrum.com>
Reviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
2017-07-07 18:36:57 +00:00
|
|
|
/* KSZ9031 PHY Registers */
|
|
|
|
#define MII_KSZ9031_MMD_ACCES_CTRL 0x0d
|
|
|
|
#define MII_KSZ9031_MMD_REG_DATA 0x0e
|
|
|
|
|
2019-03-04 17:40:33 +00:00
|
|
|
#define KSZ9031_PS_TO_REG 60
|
|
|
|
|
2013-02-06 21:18:37 +00:00
|
|
|
static int ksz90xx_startup(struct phy_device *phydev)
|
|
|
|
{
|
|
|
|
unsigned phy_ctl;
|
2016-05-18 10:46:12 +00:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = genphy_update_link(phydev);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2013-02-06 21:18:37 +00:00
|
|
|
phy_ctl = phy_read(phydev, MDIO_DEVAD_NONE, MII_KSZ90xx_PHY_CTL);
|
|
|
|
|
|
|
|
if (phy_ctl & MIIM_KSZ90xx_PHYCTL_DUPLEX)
|
|
|
|
phydev->duplex = DUPLEX_FULL;
|
|
|
|
else
|
|
|
|
phydev->duplex = DUPLEX_HALF;
|
|
|
|
|
|
|
|
if (phy_ctl & MIIM_KSZ90xx_PHYCTL_1000)
|
|
|
|
phydev->speed = SPEED_1000;
|
|
|
|
else if (phy_ctl & MIIM_KSZ90xx_PHYCTL_100)
|
|
|
|
phydev->speed = SPEED_100;
|
|
|
|
else if (phy_ctl & MIIM_KSZ90xx_PHYCTL_10)
|
|
|
|
phydev->speed = SPEED_10;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-12-05 16:41:58 +00:00
|
|
|
/* Common OF config bits for KSZ9021 and KSZ9031 */
|
|
|
|
#ifdef CONFIG_DM_ETH
|
|
|
|
struct ksz90x1_reg_field {
|
|
|
|
const char *name;
|
|
|
|
const u8 size; /* Size of the bitfield, in bits */
|
|
|
|
const u8 off; /* Offset from bit 0 */
|
|
|
|
const u8 dflt; /* Default value */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ksz90x1_ofcfg {
|
|
|
|
const u16 reg;
|
|
|
|
const u16 devad;
|
|
|
|
const struct ksz90x1_reg_field *grp;
|
|
|
|
const u16 grpsz;
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct ksz90x1_reg_field ksz90x1_rxd_grp[] = {
|
|
|
|
{ "rxd0-skew-ps", 4, 0, 0x7 }, { "rxd1-skew-ps", 4, 4, 0x7 },
|
|
|
|
{ "rxd2-skew-ps", 4, 8, 0x7 }, { "rxd3-skew-ps", 4, 12, 0x7 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct ksz90x1_reg_field ksz90x1_txd_grp[] = {
|
|
|
|
{ "txd0-skew-ps", 4, 0, 0x7 }, { "txd1-skew-ps", 4, 4, 0x7 },
|
|
|
|
{ "txd2-skew-ps", 4, 8, 0x7 }, { "txd3-skew-ps", 4, 12, 0x7 },
|
|
|
|
};
|
|
|
|
|
net: phy: micrel: Separate KSZ9000 drivers from KSZ8000 drivers
The KS8721BL and KSZ9021 PHYs are software-incompatible, yet they
share the same ID. Drivers for bothe PHYs cannot safely coexist, so
the solution was to use #ifdefs to select between the two drivers.
As a result KSZ9031, which has a unique ID, is now caught in the
crossfire. Unless CONFIG_PHY_MICREL_KSZ9031 is defined, the KSZ9031
will not function properly, as some essential configuration code is
ifdef'd-out.
To prevent such situations, move the KSZ9000 drivers to a separate
file, and place them under a separate Kconfig option. While it is
possible to enable both KSZ8000 and KSZ9000 drivers at the same time,
the assumption is that it is highly unlikely for a system to contain
both a KSZ8000 and a KSZ9000 PHY, and that only one of the drivers
will be enabled at any given time.
Signed-off-by: Alexandru Gagniuc <alex.g@adaptrum.com>
Reviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
2017-07-07 18:36:57 +00:00
|
|
|
static const struct ksz90x1_reg_field ksz9021_clk_grp[] = {
|
|
|
|
{ "txen-skew-ps", 4, 0, 0x7 }, { "txc-skew-ps", 4, 4, 0x7 },
|
|
|
|
{ "rxdv-skew-ps", 4, 8, 0x7 }, { "rxc-skew-ps", 4, 12, 0x7 },
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct ksz90x1_reg_field ksz9031_ctl_grp[] = {
|
|
|
|
{ "txen-skew-ps", 4, 0, 0x7 }, { "rxdv-skew-ps", 4, 4, 0x7 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct ksz90x1_reg_field ksz9031_clk_grp[] = {
|
|
|
|
{ "rxc-skew-ps", 5, 0, 0xf }, { "txc-skew-ps", 5, 5, 0xf }
|
|
|
|
};
|
|
|
|
|
2015-12-05 16:41:58 +00:00
|
|
|
static int ksz90x1_of_config_group(struct phy_device *phydev,
|
2019-03-04 17:40:33 +00:00
|
|
|
struct ksz90x1_ofcfg *ofcfg,
|
|
|
|
int ps_to_regval)
|
2015-12-05 16:41:58 +00:00
|
|
|
{
|
|
|
|
struct udevice *dev = phydev->dev;
|
|
|
|
struct phy_driver *drv = phydev->drv;
|
|
|
|
int val[4];
|
|
|
|
int i, changed = 0, offset, max;
|
|
|
|
u16 regval = 0;
|
net: phy: micrel: Find Micrel PHY node correctly
In some of the device trees that specify skew values for KSZ90x1 PHYs
the values are stored (incorrectly) in the MAC node, whereas in others
it is in an 'ethernet-phy' subnode. Previously the code would fail to
find and program these skew values, so this commit changes it to look
for an "ethernet-phy" subnode first, and revert to looking in the MAC
node if there isn't one.
The device trees affected (where the skew values are in a subnode) are
imx6qdl-icore-rqs.dtsi, r8a77970-eagle.dts, r8a77990-ebisu.dts,
r8a77995-draak.dts, salvator-common.dtsi, sama5d3xcm.dtsi,
sama5d3xcm_cmp.dtsi, socfpga_cyclone5_vining_fpga.dts,
socfpga_stratix10_socdk.dts and ulcb.dtsi. Before this change the skew
values in these device trees would be ignored.
The device trees where the skew values are in the MAC node are
socfpga_arria10_socdk.dtsi, socfpga_arria5_socdk.dts,
socfpga_cyclone5_de0_nano_soc.dts, socfpga_cyclone5_de10_nano.dts,
socfpga_cyclone5_de1_soc.dts, socfpga_cyclone5_is1.dts,
socfpga_cyclone5_socdk.dts, socfpga_cyclone5_sockit.dts. These should be
unaffected by this change.
The changes were tested on a sama5d3xcm.
Signed-off-by: James Byrne <james.byrne@origamienergy.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
2019-03-04 17:40:34 +00:00
|
|
|
ofnode node;
|
2015-12-05 16:41:58 +00:00
|
|
|
|
|
|
|
if (!drv || !drv->writeext)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
net: phy: micrel: Find Micrel PHY node correctly
In some of the device trees that specify skew values for KSZ90x1 PHYs
the values are stored (incorrectly) in the MAC node, whereas in others
it is in an 'ethernet-phy' subnode. Previously the code would fail to
find and program these skew values, so this commit changes it to look
for an "ethernet-phy" subnode first, and revert to looking in the MAC
node if there isn't one.
The device trees affected (where the skew values are in a subnode) are
imx6qdl-icore-rqs.dtsi, r8a77970-eagle.dts, r8a77990-ebisu.dts,
r8a77995-draak.dts, salvator-common.dtsi, sama5d3xcm.dtsi,
sama5d3xcm_cmp.dtsi, socfpga_cyclone5_vining_fpga.dts,
socfpga_stratix10_socdk.dts and ulcb.dtsi. Before this change the skew
values in these device trees would be ignored.
The device trees where the skew values are in the MAC node are
socfpga_arria10_socdk.dtsi, socfpga_arria5_socdk.dts,
socfpga_cyclone5_de0_nano_soc.dts, socfpga_cyclone5_de10_nano.dts,
socfpga_cyclone5_de1_soc.dts, socfpga_cyclone5_is1.dts,
socfpga_cyclone5_socdk.dts, socfpga_cyclone5_sockit.dts. These should be
unaffected by this change.
The changes were tested on a sama5d3xcm.
Signed-off-by: James Byrne <james.byrne@origamienergy.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
2019-03-04 17:40:34 +00:00
|
|
|
/* Look for a PHY node under the Ethernet node */
|
|
|
|
node = dev_read_subnode(dev, "ethernet-phy");
|
|
|
|
if (!ofnode_valid(node)) {
|
|
|
|
/* No node found, look in the Ethernet node */
|
|
|
|
node = dev_ofnode(dev);
|
|
|
|
}
|
|
|
|
|
2015-12-05 16:41:58 +00:00
|
|
|
for (i = 0; i < ofcfg->grpsz; i++) {
|
net: phy: micrel: Find Micrel PHY node correctly
In some of the device trees that specify skew values for KSZ90x1 PHYs
the values are stored (incorrectly) in the MAC node, whereas in others
it is in an 'ethernet-phy' subnode. Previously the code would fail to
find and program these skew values, so this commit changes it to look
for an "ethernet-phy" subnode first, and revert to looking in the MAC
node if there isn't one.
The device trees affected (where the skew values are in a subnode) are
imx6qdl-icore-rqs.dtsi, r8a77970-eagle.dts, r8a77990-ebisu.dts,
r8a77995-draak.dts, salvator-common.dtsi, sama5d3xcm.dtsi,
sama5d3xcm_cmp.dtsi, socfpga_cyclone5_vining_fpga.dts,
socfpga_stratix10_socdk.dts and ulcb.dtsi. Before this change the skew
values in these device trees would be ignored.
The device trees where the skew values are in the MAC node are
socfpga_arria10_socdk.dtsi, socfpga_arria5_socdk.dts,
socfpga_cyclone5_de0_nano_soc.dts, socfpga_cyclone5_de10_nano.dts,
socfpga_cyclone5_de1_soc.dts, socfpga_cyclone5_is1.dts,
socfpga_cyclone5_socdk.dts, socfpga_cyclone5_sockit.dts. These should be
unaffected by this change.
The changes were tested on a sama5d3xcm.
Signed-off-by: James Byrne <james.byrne@origamienergy.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
2019-03-04 17:40:34 +00:00
|
|
|
val[i] = ofnode_read_u32_default(node, ofcfg->grp[i].name, ~0);
|
2015-12-05 16:41:58 +00:00
|
|
|
offset = ofcfg->grp[i].off;
|
|
|
|
if (val[i] == -1) {
|
|
|
|
/* Default register value for KSZ9021 */
|
|
|
|
regval |= ofcfg->grp[i].dflt << offset;
|
|
|
|
} else {
|
|
|
|
changed = 1; /* Value was changed in OF */
|
|
|
|
/* Calculate the register value and fix corner cases */
|
2018-11-29 19:04:53 +00:00
|
|
|
max = (1 << ofcfg->grp[i].size) - 1;
|
|
|
|
if (val[i] > ps_to_regval * max) {
|
2015-12-05 16:41:58 +00:00
|
|
|
regval |= max << offset;
|
|
|
|
} else {
|
|
|
|
regval |= (val[i] / ps_to_regval) << offset;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!changed)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return drv->writeext(phydev, 0, ofcfg->devad, ofcfg->reg, regval);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ksz9021_of_config(struct phy_device *phydev)
|
|
|
|
{
|
|
|
|
struct ksz90x1_ofcfg ofcfg[] = {
|
|
|
|
{ MII_KSZ9021_EXT_RGMII_RX_DATA_SKEW, 0, ksz90x1_rxd_grp, 4 },
|
|
|
|
{ MII_KSZ9021_EXT_RGMII_TX_DATA_SKEW, 0, ksz90x1_txd_grp, 4 },
|
|
|
|
{ MII_KSZ9021_EXT_RGMII_CLOCK_SKEW, 0, ksz9021_clk_grp, 4 },
|
|
|
|
};
|
|
|
|
int i, ret = 0;
|
|
|
|
|
2016-11-14 14:08:42 +00:00
|
|
|
for (i = 0; i < ARRAY_SIZE(ofcfg); i++) {
|
2019-03-04 17:40:33 +00:00
|
|
|
ret = ksz90x1_of_config_group(phydev, &ofcfg[i],
|
|
|
|
KSZ9021_PS_TO_REG);
|
2015-12-05 16:41:58 +00:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
2016-11-14 14:08:42 +00:00
|
|
|
}
|
2015-12-05 16:41:58 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
net: phy: micrel: Separate KSZ9000 drivers from KSZ8000 drivers
The KS8721BL and KSZ9021 PHYs are software-incompatible, yet they
share the same ID. Drivers for bothe PHYs cannot safely coexist, so
the solution was to use #ifdefs to select between the two drivers.
As a result KSZ9031, which has a unique ID, is now caught in the
crossfire. Unless CONFIG_PHY_MICREL_KSZ9031 is defined, the KSZ9031
will not function properly, as some essential configuration code is
ifdef'd-out.
To prevent such situations, move the KSZ9000 drivers to a separate
file, and place them under a separate Kconfig option. While it is
possible to enable both KSZ8000 and KSZ9000 drivers at the same time,
the assumption is that it is highly unlikely for a system to contain
both a KSZ8000 and a KSZ9000 PHY, and that only one of the drivers
will be enabled at any given time.
Signed-off-by: Alexandru Gagniuc <alex.g@adaptrum.com>
Reviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
2017-07-07 18:36:57 +00:00
|
|
|
|
|
|
|
static int ksz9031_of_config(struct phy_device *phydev)
|
|
|
|
{
|
|
|
|
struct ksz90x1_ofcfg ofcfg[] = {
|
|
|
|
{ MII_KSZ9031_EXT_RGMII_CTRL_SIG_SKEW, 2, ksz9031_ctl_grp, 2 },
|
|
|
|
{ MII_KSZ9031_EXT_RGMII_RX_DATA_SKEW, 2, ksz90x1_rxd_grp, 4 },
|
|
|
|
{ MII_KSZ9031_EXT_RGMII_TX_DATA_SKEW, 2, ksz90x1_txd_grp, 4 },
|
|
|
|
{ MII_KSZ9031_EXT_RGMII_CLOCK_SKEW, 2, ksz9031_clk_grp, 2 },
|
|
|
|
};
|
|
|
|
int i, ret = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(ofcfg); i++) {
|
2019-03-04 17:40:33 +00:00
|
|
|
ret = ksz90x1_of_config_group(phydev, &ofcfg[i],
|
|
|
|
KSZ9031_PS_TO_REG);
|
net: phy: micrel: Separate KSZ9000 drivers from KSZ8000 drivers
The KS8721BL and KSZ9021 PHYs are software-incompatible, yet they
share the same ID. Drivers for bothe PHYs cannot safely coexist, so
the solution was to use #ifdefs to select between the two drivers.
As a result KSZ9031, which has a unique ID, is now caught in the
crossfire. Unless CONFIG_PHY_MICREL_KSZ9031 is defined, the KSZ9031
will not function properly, as some essential configuration code is
ifdef'd-out.
To prevent such situations, move the KSZ9000 drivers to a separate
file, and place them under a separate Kconfig option. While it is
possible to enable both KSZ8000 and KSZ9000 drivers at the same time,
the assumption is that it is highly unlikely for a system to contain
both a KSZ8000 and a KSZ9000 PHY, and that only one of the drivers
will be enabled at any given time.
Signed-off-by: Alexandru Gagniuc <alex.g@adaptrum.com>
Reviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
2017-07-07 18:36:57 +00:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ksz9031_center_flp_timing(struct phy_device *phydev)
|
|
|
|
{
|
|
|
|
struct phy_driver *drv = phydev->drv;
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
if (!drv || !drv->writeext)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
ret = drv->writeext(phydev, 0, 0, MII_KSZ9031_FLP_BURST_TX_LO, 0x1A80);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
ret = drv->writeext(phydev, 0, 0, MII_KSZ9031_FLP_BURST_TX_HI, 0x6);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
#else /* !CONFIG_DM_ETH */
|
2015-12-05 16:41:58 +00:00
|
|
|
static int ksz9021_of_config(struct phy_device *phydev)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
net: phy: micrel: Separate KSZ9000 drivers from KSZ8000 drivers
The KS8721BL and KSZ9021 PHYs are software-incompatible, yet they
share the same ID. Drivers for bothe PHYs cannot safely coexist, so
the solution was to use #ifdefs to select between the two drivers.
As a result KSZ9031, which has a unique ID, is now caught in the
crossfire. Unless CONFIG_PHY_MICREL_KSZ9031 is defined, the KSZ9031
will not function properly, as some essential configuration code is
ifdef'd-out.
To prevent such situations, move the KSZ9000 drivers to a separate
file, and place them under a separate Kconfig option. While it is
possible to enable both KSZ8000 and KSZ9000 drivers at the same time,
the assumption is that it is highly unlikely for a system to contain
both a KSZ8000 and a KSZ9000 PHY, and that only one of the drivers
will be enabled at any given time.
Signed-off-by: Alexandru Gagniuc <alex.g@adaptrum.com>
Reviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
2017-07-07 18:36:57 +00:00
|
|
|
|
|
|
|
static int ksz9031_of_config(struct phy_device *phydev)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ksz9031_center_flp_timing(struct phy_device *phydev)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2015-12-05 16:41:58 +00:00
|
|
|
#endif
|
|
|
|
|
net: phy: micrel: Separate KSZ9000 drivers from KSZ8000 drivers
The KS8721BL and KSZ9021 PHYs are software-incompatible, yet they
share the same ID. Drivers for bothe PHYs cannot safely coexist, so
the solution was to use #ifdefs to select between the two drivers.
As a result KSZ9031, which has a unique ID, is now caught in the
crossfire. Unless CONFIG_PHY_MICREL_KSZ9031 is defined, the KSZ9031
will not function properly, as some essential configuration code is
ifdef'd-out.
To prevent such situations, move the KSZ9000 drivers to a separate
file, and place them under a separate Kconfig option. While it is
possible to enable both KSZ8000 and KSZ9000 drivers at the same time,
the assumption is that it is highly unlikely for a system to contain
both a KSZ8000 and a KSZ9000 PHY, and that only one of the drivers
will be enabled at any given time.
Signed-off-by: Alexandru Gagniuc <alex.g@adaptrum.com>
Reviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
2017-07-07 18:36:57 +00:00
|
|
|
/*
|
|
|
|
* KSZ9021
|
|
|
|
*/
|
2012-02-07 14:08:48 +00:00
|
|
|
int ksz9021_phy_extended_write(struct phy_device *phydev, int regnum, u16 val)
|
|
|
|
{
|
|
|
|
/* extended registers */
|
|
|
|
phy_write(phydev, MDIO_DEVAD_NONE,
|
net: phy: micrel: Separate KSZ9000 drivers from KSZ8000 drivers
The KS8721BL and KSZ9021 PHYs are software-incompatible, yet they
share the same ID. Drivers for bothe PHYs cannot safely coexist, so
the solution was to use #ifdefs to select between the two drivers.
As a result KSZ9031, which has a unique ID, is now caught in the
crossfire. Unless CONFIG_PHY_MICREL_KSZ9031 is defined, the KSZ9031
will not function properly, as some essential configuration code is
ifdef'd-out.
To prevent such situations, move the KSZ9000 drivers to a separate
file, and place them under a separate Kconfig option. While it is
possible to enable both KSZ8000 and KSZ9000 drivers at the same time,
the assumption is that it is highly unlikely for a system to contain
both a KSZ8000 and a KSZ9000 PHY, and that only one of the drivers
will be enabled at any given time.
Signed-off-by: Alexandru Gagniuc <alex.g@adaptrum.com>
Reviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
2017-07-07 18:36:57 +00:00
|
|
|
MII_KSZ9021_EXTENDED_CTRL, regnum | 0x8000);
|
2012-02-07 14:08:48 +00:00
|
|
|
return phy_write(phydev, MDIO_DEVAD_NONE,
|
net: phy: micrel: Separate KSZ9000 drivers from KSZ8000 drivers
The KS8721BL and KSZ9021 PHYs are software-incompatible, yet they
share the same ID. Drivers for bothe PHYs cannot safely coexist, so
the solution was to use #ifdefs to select between the two drivers.
As a result KSZ9031, which has a unique ID, is now caught in the
crossfire. Unless CONFIG_PHY_MICREL_KSZ9031 is defined, the KSZ9031
will not function properly, as some essential configuration code is
ifdef'd-out.
To prevent such situations, move the KSZ9000 drivers to a separate
file, and place them under a separate Kconfig option. While it is
possible to enable both KSZ8000 and KSZ9000 drivers at the same time,
the assumption is that it is highly unlikely for a system to contain
both a KSZ8000 and a KSZ9000 PHY, and that only one of the drivers
will be enabled at any given time.
Signed-off-by: Alexandru Gagniuc <alex.g@adaptrum.com>
Reviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
2017-07-07 18:36:57 +00:00
|
|
|
MII_KSZ9021_EXTENDED_DATAW, val);
|
2012-02-07 14:08:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int ksz9021_phy_extended_read(struct phy_device *phydev, int regnum)
|
|
|
|
{
|
|
|
|
/* extended registers */
|
|
|
|
phy_write(phydev, MDIO_DEVAD_NONE, MII_KSZ9021_EXTENDED_CTRL, regnum);
|
|
|
|
return phy_read(phydev, MDIO_DEVAD_NONE, MII_KSZ9021_EXTENDED_DATAR);
|
|
|
|
}
|
|
|
|
|
2013-09-02 13:42:31 +00:00
|
|
|
|
|
|
|
static int ksz9021_phy_extread(struct phy_device *phydev, int addr, int devaddr,
|
net: phy: micrel: Separate KSZ9000 drivers from KSZ8000 drivers
The KS8721BL and KSZ9021 PHYs are software-incompatible, yet they
share the same ID. Drivers for bothe PHYs cannot safely coexist, so
the solution was to use #ifdefs to select between the two drivers.
As a result KSZ9031, which has a unique ID, is now caught in the
crossfire. Unless CONFIG_PHY_MICREL_KSZ9031 is defined, the KSZ9031
will not function properly, as some essential configuration code is
ifdef'd-out.
To prevent such situations, move the KSZ9000 drivers to a separate
file, and place them under a separate Kconfig option. While it is
possible to enable both KSZ8000 and KSZ9000 drivers at the same time,
the assumption is that it is highly unlikely for a system to contain
both a KSZ8000 and a KSZ9000 PHY, and that only one of the drivers
will be enabled at any given time.
Signed-off-by: Alexandru Gagniuc <alex.g@adaptrum.com>
Reviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
2017-07-07 18:36:57 +00:00
|
|
|
int regnum)
|
2013-09-02 13:42:31 +00:00
|
|
|
{
|
|
|
|
return ksz9021_phy_extended_read(phydev, regnum);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ksz9021_phy_extwrite(struct phy_device *phydev, int addr,
|
net: phy: micrel: Separate KSZ9000 drivers from KSZ8000 drivers
The KS8721BL and KSZ9021 PHYs are software-incompatible, yet they
share the same ID. Drivers for bothe PHYs cannot safely coexist, so
the solution was to use #ifdefs to select between the two drivers.
As a result KSZ9031, which has a unique ID, is now caught in the
crossfire. Unless CONFIG_PHY_MICREL_KSZ9031 is defined, the KSZ9031
will not function properly, as some essential configuration code is
ifdef'd-out.
To prevent such situations, move the KSZ9000 drivers to a separate
file, and place them under a separate Kconfig option. While it is
possible to enable both KSZ8000 and KSZ9000 drivers at the same time,
the assumption is that it is highly unlikely for a system to contain
both a KSZ8000 and a KSZ9000 PHY, and that only one of the drivers
will be enabled at any given time.
Signed-off-by: Alexandru Gagniuc <alex.g@adaptrum.com>
Reviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
2017-07-07 18:36:57 +00:00
|
|
|
int devaddr, int regnum, u16 val)
|
2013-09-02 13:42:31 +00:00
|
|
|
{
|
|
|
|
return ksz9021_phy_extended_write(phydev, regnum, val);
|
|
|
|
}
|
|
|
|
|
2012-02-07 14:08:48 +00:00
|
|
|
static int ksz9021_config(struct phy_device *phydev)
|
|
|
|
{
|
|
|
|
unsigned ctrl1000 = 0;
|
|
|
|
const unsigned master = CTRL1000_PREFER_MASTER |
|
net: phy: micrel: Separate KSZ9000 drivers from KSZ8000 drivers
The KS8721BL and KSZ9021 PHYs are software-incompatible, yet they
share the same ID. Drivers for bothe PHYs cannot safely coexist, so
the solution was to use #ifdefs to select between the two drivers.
As a result KSZ9031, which has a unique ID, is now caught in the
crossfire. Unless CONFIG_PHY_MICREL_KSZ9031 is defined, the KSZ9031
will not function properly, as some essential configuration code is
ifdef'd-out.
To prevent such situations, move the KSZ9000 drivers to a separate
file, and place them under a separate Kconfig option. While it is
possible to enable both KSZ8000 and KSZ9000 drivers at the same time,
the assumption is that it is highly unlikely for a system to contain
both a KSZ8000 and a KSZ9000 PHY, and that only one of the drivers
will be enabled at any given time.
Signed-off-by: Alexandru Gagniuc <alex.g@adaptrum.com>
Reviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
2017-07-07 18:36:57 +00:00
|
|
|
CTRL1000_CONFIG_MASTER | CTRL1000_MANUAL_CONFIG;
|
2012-02-07 14:08:48 +00:00
|
|
|
unsigned features = phydev->drv->features;
|
2015-12-05 16:41:58 +00:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = ksz9021_of_config(phydev);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
2012-02-07 14:08:48 +00:00
|
|
|
|
2017-08-03 18:22:12 +00:00
|
|
|
if (env_get("disable_giga"))
|
2012-02-07 14:08:48 +00:00
|
|
|
features &= ~(SUPPORTED_1000baseT_Half |
|
net: phy: micrel: Separate KSZ9000 drivers from KSZ8000 drivers
The KS8721BL and KSZ9021 PHYs are software-incompatible, yet they
share the same ID. Drivers for bothe PHYs cannot safely coexist, so
the solution was to use #ifdefs to select between the two drivers.
As a result KSZ9031, which has a unique ID, is now caught in the
crossfire. Unless CONFIG_PHY_MICREL_KSZ9031 is defined, the KSZ9031
will not function properly, as some essential configuration code is
ifdef'd-out.
To prevent such situations, move the KSZ9000 drivers to a separate
file, and place them under a separate Kconfig option. While it is
possible to enable both KSZ8000 and KSZ9000 drivers at the same time,
the assumption is that it is highly unlikely for a system to contain
both a KSZ8000 and a KSZ9000 PHY, and that only one of the drivers
will be enabled at any given time.
Signed-off-by: Alexandru Gagniuc <alex.g@adaptrum.com>
Reviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
2017-07-07 18:36:57 +00:00
|
|
|
SUPPORTED_1000baseT_Full);
|
2012-02-07 14:08:48 +00:00
|
|
|
/* force master mode for 1000BaseT due to chip errata */
|
|
|
|
if (features & SUPPORTED_1000baseT_Half)
|
|
|
|
ctrl1000 |= ADVERTISE_1000HALF | master;
|
|
|
|
if (features & SUPPORTED_1000baseT_Full)
|
|
|
|
ctrl1000 |= ADVERTISE_1000FULL | master;
|
net: phy: micrel: Separate KSZ9000 drivers from KSZ8000 drivers
The KS8721BL and KSZ9021 PHYs are software-incompatible, yet they
share the same ID. Drivers for bothe PHYs cannot safely coexist, so
the solution was to use #ifdefs to select between the two drivers.
As a result KSZ9031, which has a unique ID, is now caught in the
crossfire. Unless CONFIG_PHY_MICREL_KSZ9031 is defined, the KSZ9031
will not function properly, as some essential configuration code is
ifdef'd-out.
To prevent such situations, move the KSZ9000 drivers to a separate
file, and place them under a separate Kconfig option. While it is
possible to enable both KSZ8000 and KSZ9000 drivers at the same time,
the assumption is that it is highly unlikely for a system to contain
both a KSZ8000 and a KSZ9000 PHY, and that only one of the drivers
will be enabled at any given time.
Signed-off-by: Alexandru Gagniuc <alex.g@adaptrum.com>
Reviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
2017-07-07 18:36:57 +00:00
|
|
|
phydev->advertising = features;
|
|
|
|
phydev->supported = features;
|
2012-02-07 14:08:48 +00:00
|
|
|
phy_write(phydev, MDIO_DEVAD_NONE, MII_CTRL1000, ctrl1000);
|
|
|
|
genphy_config_aneg(phydev);
|
|
|
|
genphy_restart_aneg(phydev);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct phy_driver ksz9021_driver = {
|
|
|
|
.name = "Micrel ksz9021",
|
|
|
|
.uid = 0x221610,
|
2019-03-06 12:48:27 +00:00
|
|
|
.mask = 0xfffffe,
|
2012-02-07 14:08:48 +00:00
|
|
|
.features = PHY_GBIT_FEATURES,
|
|
|
|
.config = &ksz9021_config,
|
2013-02-06 21:18:37 +00:00
|
|
|
.startup = &ksz90xx_startup,
|
2012-02-07 14:08:48 +00:00
|
|
|
.shutdown = &genphy_shutdown,
|
2013-09-02 13:42:31 +00:00
|
|
|
.writeext = &ksz9021_phy_extwrite,
|
|
|
|
.readext = &ksz9021_phy_extread,
|
2012-02-07 14:08:48 +00:00
|
|
|
};
|
|
|
|
|
net: phy: micrel: Separate KSZ9000 drivers from KSZ8000 drivers
The KS8721BL and KSZ9021 PHYs are software-incompatible, yet they
share the same ID. Drivers for bothe PHYs cannot safely coexist, so
the solution was to use #ifdefs to select between the two drivers.
As a result KSZ9031, which has a unique ID, is now caught in the
crossfire. Unless CONFIG_PHY_MICREL_KSZ9031 is defined, the KSZ9031
will not function properly, as some essential configuration code is
ifdef'd-out.
To prevent such situations, move the KSZ9000 drivers to a separate
file, and place them under a separate Kconfig option. While it is
possible to enable both KSZ8000 and KSZ9000 drivers at the same time,
the assumption is that it is highly unlikely for a system to contain
both a KSZ8000 and a KSZ9000 PHY, and that only one of the drivers
will be enabled at any given time.
Signed-off-by: Alexandru Gagniuc <alex.g@adaptrum.com>
Reviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
2017-07-07 18:36:57 +00:00
|
|
|
/*
|
2013-02-06 21:18:37 +00:00
|
|
|
* KSZ9031
|
|
|
|
*/
|
2013-04-30 14:57:25 +00:00
|
|
|
int ksz9031_phy_extended_write(struct phy_device *phydev,
|
|
|
|
int devaddr, int regnum, u16 mode, u16 val)
|
|
|
|
{
|
|
|
|
/*select register addr for mmd*/
|
|
|
|
phy_write(phydev, MDIO_DEVAD_NONE,
|
|
|
|
MII_KSZ9031_MMD_ACCES_CTRL, devaddr);
|
|
|
|
/*select register for mmd*/
|
|
|
|
phy_write(phydev, MDIO_DEVAD_NONE,
|
|
|
|
MII_KSZ9031_MMD_REG_DATA, regnum);
|
|
|
|
/*setup mode*/
|
|
|
|
phy_write(phydev, MDIO_DEVAD_NONE,
|
|
|
|
MII_KSZ9031_MMD_ACCES_CTRL, (mode | devaddr));
|
|
|
|
/*write the value*/
|
|
|
|
return phy_write(phydev, MDIO_DEVAD_NONE,
|
net: phy: micrel: Separate KSZ9000 drivers from KSZ8000 drivers
The KS8721BL and KSZ9021 PHYs are software-incompatible, yet they
share the same ID. Drivers for bothe PHYs cannot safely coexist, so
the solution was to use #ifdefs to select between the two drivers.
As a result KSZ9031, which has a unique ID, is now caught in the
crossfire. Unless CONFIG_PHY_MICREL_KSZ9031 is defined, the KSZ9031
will not function properly, as some essential configuration code is
ifdef'd-out.
To prevent such situations, move the KSZ9000 drivers to a separate
file, and place them under a separate Kconfig option. While it is
possible to enable both KSZ8000 and KSZ9000 drivers at the same time,
the assumption is that it is highly unlikely for a system to contain
both a KSZ8000 and a KSZ9000 PHY, and that only one of the drivers
will be enabled at any given time.
Signed-off-by: Alexandru Gagniuc <alex.g@adaptrum.com>
Reviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
2017-07-07 18:36:57 +00:00
|
|
|
MII_KSZ9031_MMD_REG_DATA, val);
|
2013-04-30 14:57:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int ksz9031_phy_extended_read(struct phy_device *phydev, int devaddr,
|
|
|
|
int regnum, u16 mode)
|
|
|
|
{
|
|
|
|
phy_write(phydev, MDIO_DEVAD_NONE,
|
|
|
|
MII_KSZ9031_MMD_ACCES_CTRL, devaddr);
|
|
|
|
phy_write(phydev, MDIO_DEVAD_NONE,
|
|
|
|
MII_KSZ9031_MMD_REG_DATA, regnum);
|
|
|
|
phy_write(phydev, MDIO_DEVAD_NONE,
|
|
|
|
MII_KSZ9031_MMD_ACCES_CTRL, (devaddr | mode));
|
|
|
|
return phy_read(phydev, MDIO_DEVAD_NONE, MII_KSZ9031_MMD_REG_DATA);
|
|
|
|
}
|
|
|
|
|
2013-09-02 13:42:31 +00:00
|
|
|
static int ksz9031_phy_extread(struct phy_device *phydev, int addr, int devaddr,
|
|
|
|
int regnum)
|
|
|
|
{
|
|
|
|
return ksz9031_phy_extended_read(phydev, devaddr, regnum,
|
|
|
|
MII_KSZ9031_MOD_DATA_NO_POST_INC);
|
net: phy: micrel: Separate KSZ9000 drivers from KSZ8000 drivers
The KS8721BL and KSZ9021 PHYs are software-incompatible, yet they
share the same ID. Drivers for bothe PHYs cannot safely coexist, so
the solution was to use #ifdefs to select between the two drivers.
As a result KSZ9031, which has a unique ID, is now caught in the
crossfire. Unless CONFIG_PHY_MICREL_KSZ9031 is defined, the KSZ9031
will not function properly, as some essential configuration code is
ifdef'd-out.
To prevent such situations, move the KSZ9000 drivers to a separate
file, and place them under a separate Kconfig option. While it is
possible to enable both KSZ8000 and KSZ9000 drivers at the same time,
the assumption is that it is highly unlikely for a system to contain
both a KSZ8000 and a KSZ9000 PHY, and that only one of the drivers
will be enabled at any given time.
Signed-off-by: Alexandru Gagniuc <alex.g@adaptrum.com>
Reviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
2017-07-07 18:36:57 +00:00
|
|
|
}
|
2013-09-02 13:42:31 +00:00
|
|
|
|
|
|
|
static int ksz9031_phy_extwrite(struct phy_device *phydev, int addr,
|
|
|
|
int devaddr, int regnum, u16 val)
|
|
|
|
{
|
|
|
|
return ksz9031_phy_extended_write(phydev, devaddr, regnum,
|
net: phy: micrel: Separate KSZ9000 drivers from KSZ8000 drivers
The KS8721BL and KSZ9021 PHYs are software-incompatible, yet they
share the same ID. Drivers for bothe PHYs cannot safely coexist, so
the solution was to use #ifdefs to select between the two drivers.
As a result KSZ9031, which has a unique ID, is now caught in the
crossfire. Unless CONFIG_PHY_MICREL_KSZ9031 is defined, the KSZ9031
will not function properly, as some essential configuration code is
ifdef'd-out.
To prevent such situations, move the KSZ9000 drivers to a separate
file, and place them under a separate Kconfig option. While it is
possible to enable both KSZ8000 and KSZ9000 drivers at the same time,
the assumption is that it is highly unlikely for a system to contain
both a KSZ8000 and a KSZ9000 PHY, and that only one of the drivers
will be enabled at any given time.
Signed-off-by: Alexandru Gagniuc <alex.g@adaptrum.com>
Reviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
2017-07-07 18:36:57 +00:00
|
|
|
MII_KSZ9031_MOD_DATA_POST_INC_RW, val);
|
|
|
|
}
|
2013-09-02 13:42:31 +00:00
|
|
|
|
2015-12-05 16:41:58 +00:00
|
|
|
static int ksz9031_config(struct phy_device *phydev)
|
|
|
|
{
|
|
|
|
int ret;
|
2017-07-28 19:59:22 +00:00
|
|
|
|
2015-12-05 16:41:58 +00:00
|
|
|
ret = ksz9031_of_config(phydev);
|
2016-10-21 21:31:33 +00:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
ret = ksz9031_center_flp_timing(phydev);
|
2015-12-05 16:41:58 +00:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
2017-07-28 19:59:22 +00:00
|
|
|
|
|
|
|
/* add an option to disable the gigabit feature of this PHY */
|
2017-08-03 18:22:12 +00:00
|
|
|
if (env_get("disable_giga")) {
|
2017-07-28 19:59:22 +00:00
|
|
|
unsigned features;
|
|
|
|
unsigned bmcr;
|
|
|
|
|
|
|
|
/* disable speed 1000 in features supported by the PHY */
|
|
|
|
features = phydev->drv->features;
|
|
|
|
features &= ~(SUPPORTED_1000baseT_Half |
|
|
|
|
SUPPORTED_1000baseT_Full);
|
|
|
|
phydev->advertising = phydev->supported = features;
|
|
|
|
|
|
|
|
/* disable speed 1000 in Basic Control Register */
|
|
|
|
bmcr = phy_read(phydev, MDIO_DEVAD_NONE, MII_BMCR);
|
|
|
|
bmcr &= ~(1 << 6);
|
|
|
|
phy_write(phydev, MDIO_DEVAD_NONE, MII_BMCR, bmcr);
|
|
|
|
|
|
|
|
/* disable speed 1000 in 1000Base-T Control Register */
|
|
|
|
phy_write(phydev, MDIO_DEVAD_NONE, MII_CTRL1000, 0);
|
|
|
|
|
|
|
|
/* start autoneg */
|
|
|
|
genphy_config_aneg(phydev);
|
|
|
|
genphy_restart_aneg(phydev);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-12-05 16:41:58 +00:00
|
|
|
return genphy_config(phydev);
|
|
|
|
}
|
2013-09-02 13:42:31 +00:00
|
|
|
|
2013-02-06 21:18:37 +00:00
|
|
|
static struct phy_driver ksz9031_driver = {
|
|
|
|
.name = "Micrel ksz9031",
|
2020-03-11 10:59:22 +00:00
|
|
|
.uid = PHY_ID_KSZ9031,
|
|
|
|
.mask = MII_KSZ9x31_SILICON_REV_MASK,
|
2013-02-06 21:18:37 +00:00
|
|
|
.features = PHY_GBIT_FEATURES,
|
2015-12-05 16:41:58 +00:00
|
|
|
.config = &ksz9031_config,
|
2013-02-06 21:18:37 +00:00
|
|
|
.startup = &ksz90xx_startup,
|
|
|
|
.shutdown = &genphy_shutdown,
|
2013-09-02 13:42:31 +00:00
|
|
|
.writeext = &ksz9031_phy_extwrite,
|
|
|
|
.readext = &ksz9031_phy_extread,
|
2013-02-06 21:18:37 +00:00
|
|
|
};
|
|
|
|
|
2020-03-11 10:59:23 +00:00
|
|
|
/*
|
|
|
|
* KSZ9131
|
|
|
|
*/
|
2020-12-03 09:18:30 +00:00
|
|
|
|
|
|
|
#define KSZ9131RN_MMD_COMMON_CTRL_REG 2
|
|
|
|
#define KSZ9131RN_RXC_DLL_CTRL 76
|
|
|
|
#define KSZ9131RN_TXC_DLL_CTRL 77
|
|
|
|
#define KSZ9131RN_DLL_CTRL_BYPASS BIT_MASK(12)
|
|
|
|
#define KSZ9131RN_DLL_ENABLE_DELAY 0
|
|
|
|
#define KSZ9131RN_DLL_DISABLE_DELAY BIT(12)
|
|
|
|
|
|
|
|
static int ksz9131_config_rgmii_delay(struct phy_device *phydev)
|
|
|
|
{
|
|
|
|
struct phy_driver *drv = phydev->drv;
|
|
|
|
u16 rxcdll_val, txcdll_val, val;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
switch (phydev->interface) {
|
|
|
|
case PHY_INTERFACE_MODE_RGMII:
|
|
|
|
rxcdll_val = KSZ9131RN_DLL_DISABLE_DELAY;
|
|
|
|
txcdll_val = KSZ9131RN_DLL_DISABLE_DELAY;
|
|
|
|
break;
|
|
|
|
case PHY_INTERFACE_MODE_RGMII_ID:
|
|
|
|
rxcdll_val = KSZ9131RN_DLL_ENABLE_DELAY;
|
|
|
|
txcdll_val = KSZ9131RN_DLL_ENABLE_DELAY;
|
|
|
|
break;
|
|
|
|
case PHY_INTERFACE_MODE_RGMII_RXID:
|
|
|
|
rxcdll_val = KSZ9131RN_DLL_ENABLE_DELAY;
|
|
|
|
txcdll_val = KSZ9131RN_DLL_DISABLE_DELAY;
|
|
|
|
break;
|
|
|
|
case PHY_INTERFACE_MODE_RGMII_TXID:
|
|
|
|
rxcdll_val = KSZ9131RN_DLL_DISABLE_DELAY;
|
|
|
|
txcdll_val = KSZ9131RN_DLL_ENABLE_DELAY;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
val = drv->readext(phydev, 0, KSZ9131RN_MMD_COMMON_CTRL_REG,
|
|
|
|
KSZ9131RN_RXC_DLL_CTRL);
|
|
|
|
val &= ~KSZ9131RN_DLL_CTRL_BYPASS;
|
|
|
|
val |= rxcdll_val;
|
|
|
|
ret = drv->writeext(phydev, 0, KSZ9131RN_MMD_COMMON_CTRL_REG,
|
|
|
|
KSZ9131RN_RXC_DLL_CTRL, val);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
val = drv->readext(phydev, 0, KSZ9131RN_MMD_COMMON_CTRL_REG,
|
|
|
|
KSZ9131RN_TXC_DLL_CTRL);
|
|
|
|
|
|
|
|
val &= ~KSZ9131RN_DLL_CTRL_BYPASS;
|
|
|
|
val |= txcdll_val;
|
|
|
|
ret = drv->writeext(phydev, 0, KSZ9131RN_MMD_COMMON_CTRL_REG,
|
|
|
|
KSZ9131RN_TXC_DLL_CTRL, val);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2020-03-11 10:59:23 +00:00
|
|
|
static int ksz9131_config(struct phy_device *phydev)
|
|
|
|
{
|
2020-12-03 09:18:30 +00:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (phy_interface_is_rgmii(phydev)) {
|
|
|
|
ret = ksz9131_config_rgmii_delay(phydev);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
}
|
2020-03-11 10:59:23 +00:00
|
|
|
|
|
|
|
/* add an option to disable the gigabit feature of this PHY */
|
|
|
|
if (env_get("disable_giga")) {
|
|
|
|
unsigned features;
|
|
|
|
unsigned bmcr;
|
|
|
|
|
|
|
|
/* disable speed 1000 in features supported by the PHY */
|
|
|
|
features = phydev->drv->features;
|
|
|
|
features &= ~(SUPPORTED_1000baseT_Half |
|
|
|
|
SUPPORTED_1000baseT_Full);
|
|
|
|
phydev->advertising = phydev->supported = features;
|
|
|
|
|
|
|
|
/* disable speed 1000 in Basic Control Register */
|
|
|
|
bmcr = phy_read(phydev, MDIO_DEVAD_NONE, MII_BMCR);
|
|
|
|
bmcr &= ~(1 << 6);
|
|
|
|
phy_write(phydev, MDIO_DEVAD_NONE, MII_BMCR, bmcr);
|
|
|
|
|
|
|
|
/* disable speed 1000 in 1000Base-T Control Register */
|
|
|
|
phy_write(phydev, MDIO_DEVAD_NONE, MII_CTRL1000, 0);
|
|
|
|
|
|
|
|
/* start autoneg */
|
|
|
|
genphy_config_aneg(phydev);
|
|
|
|
genphy_restart_aneg(phydev);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return genphy_config(phydev);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct phy_driver ksz9131_driver = {
|
2020-12-03 09:18:31 +00:00
|
|
|
.name = "Micrel ksz9131",
|
2020-03-11 10:59:23 +00:00
|
|
|
.uid = PHY_ID_KSZ9131,
|
|
|
|
.mask = MII_KSZ9x31_SILICON_REV_MASK,
|
|
|
|
.features = PHY_GBIT_FEATURES,
|
|
|
|
.config = &ksz9131_config,
|
|
|
|
.startup = &ksz90xx_startup,
|
|
|
|
.shutdown = &genphy_shutdown,
|
|
|
|
.writeext = &ksz9031_phy_extwrite,
|
|
|
|
.readext = &ksz9031_phy_extread,
|
|
|
|
};
|
|
|
|
|
|
|
|
int ksz9xx1_phy_get_id(struct phy_device *phydev)
|
|
|
|
{
|
|
|
|
unsigned int phyid;
|
|
|
|
|
|
|
|
get_phy_id(phydev->bus, phydev->addr, MDIO_DEVAD_NONE, &phyid);
|
|
|
|
|
|
|
|
return phyid;
|
|
|
|
}
|
|
|
|
|
net: phy: micrel: Separate KSZ9000 drivers from KSZ8000 drivers
The KS8721BL and KSZ9021 PHYs are software-incompatible, yet they
share the same ID. Drivers for bothe PHYs cannot safely coexist, so
the solution was to use #ifdefs to select between the two drivers.
As a result KSZ9031, which has a unique ID, is now caught in the
crossfire. Unless CONFIG_PHY_MICREL_KSZ9031 is defined, the KSZ9031
will not function properly, as some essential configuration code is
ifdef'd-out.
To prevent such situations, move the KSZ9000 drivers to a separate
file, and place them under a separate Kconfig option. While it is
possible to enable both KSZ8000 and KSZ9000 drivers at the same time,
the assumption is that it is highly unlikely for a system to contain
both a KSZ8000 and a KSZ9000 PHY, and that only one of the drivers
will be enabled at any given time.
Signed-off-by: Alexandru Gagniuc <alex.g@adaptrum.com>
Reviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
2017-07-07 18:36:57 +00:00
|
|
|
int phy_micrel_ksz90x1_init(void)
|
2011-04-08 02:56:05 +00:00
|
|
|
{
|
2012-02-07 14:08:48 +00:00
|
|
|
phy_register(&ksz9021_driver);
|
2013-02-06 21:18:37 +00:00
|
|
|
phy_register(&ksz9031_driver);
|
2020-03-11 10:59:23 +00:00
|
|
|
phy_register(&ksz9131_driver);
|
2011-04-08 02:56:05 +00:00
|
|
|
return 0;
|
|
|
|
}
|