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
|
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>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <fdtdec.h>
|
2012-02-07 14:08:48 +00:00
|
|
|
#include <micrel.h>
|
2011-04-08 02:56:05 +00:00
|
|
|
#include <phy.h>
|
|
|
|
|
|
|
|
static struct phy_driver KSZ804_driver = {
|
|
|
|
.name = "Micrel KSZ804",
|
|
|
|
.uid = 0x221510,
|
|
|
|
.mask = 0xfffff0,
|
|
|
|
.features = PHY_BASIC_FEATURES,
|
|
|
|
.config = &genphy_config,
|
|
|
|
.startup = &genphy_startup,
|
|
|
|
.shutdown = &genphy_shutdown,
|
|
|
|
};
|
|
|
|
|
2016-01-22 19:06:33 +00:00
|
|
|
#define MII_KSZPHY_OMSO 0x16
|
|
|
|
#define KSZPHY_OMSO_B_CAST_OFF (1 << 9)
|
|
|
|
|
|
|
|
static int ksz_genconfig_bcastoff(struct phy_device *phydev)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = phy_read(phydev, MDIO_DEVAD_NONE, MII_KSZPHY_OMSO);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
ret = phy_write(phydev, MDIO_DEVAD_NONE, MII_KSZPHY_OMSO,
|
|
|
|
ret | KSZPHY_OMSO_B_CAST_OFF);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
return genphy_config(phydev);
|
|
|
|
}
|
|
|
|
|
2015-09-09 20:29:51 +00:00
|
|
|
static struct phy_driver KSZ8031_driver = {
|
|
|
|
.name = "Micrel KSZ8021/KSZ8031",
|
|
|
|
.uid = 0x221550,
|
|
|
|
.mask = 0xfffff0,
|
|
|
|
.features = PHY_BASIC_FEATURES,
|
2016-01-22 19:06:33 +00:00
|
|
|
.config = &ksz_genconfig_bcastoff,
|
2015-09-09 20:29:51 +00:00
|
|
|
.startup = &genphy_startup,
|
|
|
|
.shutdown = &genphy_shutdown,
|
|
|
|
};
|
|
|
|
|
2015-10-07 20:54:22 +00:00
|
|
|
/**
|
|
|
|
* KSZ8051
|
|
|
|
*/
|
|
|
|
#define MII_KSZ8051_PHY_OMSO 0x16
|
|
|
|
#define MII_KSZ8051_PHY_OMSO_NAND_TREE_ON (1 << 5)
|
|
|
|
|
|
|
|
static int ksz8051_config(struct phy_device *phydev)
|
|
|
|
{
|
|
|
|
unsigned val;
|
|
|
|
|
|
|
|
/* Disable NAND-tree */
|
|
|
|
val = phy_read(phydev, MDIO_DEVAD_NONE, MII_KSZ8051_PHY_OMSO);
|
|
|
|
val &= ~MII_KSZ8051_PHY_OMSO_NAND_TREE_ON;
|
|
|
|
phy_write(phydev, MDIO_DEVAD_NONE, MII_KSZ8051_PHY_OMSO, val);
|
|
|
|
|
|
|
|
return genphy_config(phydev);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct phy_driver KSZ8051_driver = {
|
|
|
|
.name = "Micrel KSZ8051",
|
|
|
|
.uid = 0x221550,
|
|
|
|
.mask = 0xfffff0,
|
|
|
|
.features = PHY_BASIC_FEATURES,
|
|
|
|
.config = &ksz8051_config,
|
|
|
|
.startup = &genphy_startup,
|
|
|
|
.shutdown = &genphy_shutdown,
|
|
|
|
};
|
|
|
|
|
2015-03-24 10:32:24 +00:00
|
|
|
static struct phy_driver KSZ8081_driver = {
|
|
|
|
.name = "Micrel KSZ8081",
|
|
|
|
.uid = 0x221560,
|
|
|
|
.mask = 0xfffff0,
|
|
|
|
.features = PHY_BASIC_FEATURES,
|
2016-01-22 19:06:33 +00:00
|
|
|
.config = &ksz_genconfig_bcastoff,
|
2015-03-24 10:32:24 +00:00
|
|
|
.startup = &genphy_startup,
|
|
|
|
.shutdown = &genphy_shutdown,
|
|
|
|
};
|
|
|
|
|
2014-02-19 16:21:59 +00:00
|
|
|
/**
|
|
|
|
* KSZ8895
|
|
|
|
*/
|
|
|
|
|
|
|
|
static unsigned short smireg_to_phy(unsigned short reg)
|
|
|
|
{
|
|
|
|
return ((reg & 0xc0) >> 3) + 0x06 + ((reg & 0x20) >> 5);
|
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned short smireg_to_reg(unsigned short reg)
|
|
|
|
{
|
|
|
|
return reg & 0x1F;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ksz8895_write_smireg(struct phy_device *phydev, int smireg, int val)
|
|
|
|
{
|
|
|
|
phydev->bus->write(phydev->bus, smireg_to_phy(smireg), MDIO_DEVAD_NONE,
|
|
|
|
smireg_to_reg(smireg), val);
|
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
static int ksz8895_read_smireg(struct phy_device *phydev, int smireg)
|
|
|
|
{
|
|
|
|
return phydev->bus->read(phydev->bus, smireg_to_phy(smireg),
|
|
|
|
MDIO_DEVAD_NONE, smireg_to_reg(smireg));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int ksz8895_config(struct phy_device *phydev)
|
|
|
|
{
|
|
|
|
/* we are connected directly to the switch without
|
|
|
|
* dedicated PHY. SCONF1 == 001 */
|
|
|
|
phydev->link = 1;
|
|
|
|
phydev->duplex = DUPLEX_FULL;
|
|
|
|
phydev->speed = SPEED_100;
|
|
|
|
|
|
|
|
/* Force the switch to start */
|
|
|
|
ksz8895_write_smireg(phydev, 1, 1);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ksz8895_startup(struct phy_device *phydev)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct phy_driver ksz8895_driver = {
|
|
|
|
.name = "Micrel KSZ8895/KSZ8864",
|
|
|
|
.uid = 0x221450,
|
|
|
|
.mask = 0xffffe1,
|
|
|
|
.features = PHY_BASIC_FEATURES,
|
|
|
|
.config = &ksz8895_config,
|
|
|
|
.startup = &ksz8895_startup,
|
|
|
|
.shutdown = &genphy_shutdown,
|
|
|
|
};
|
|
|
|
|
2017-07-07 18:36:59 +00:00
|
|
|
/* Micrel used the exact same part number for the KSZ9021. */
|
2011-12-06 02:47:57 +00:00
|
|
|
static struct phy_driver KS8721_driver = {
|
|
|
|
.name = "Micrel KS8721BL",
|
|
|
|
.uid = 0x221610,
|
|
|
|
.mask = 0xfffff0,
|
|
|
|
.features = PHY_BASIC_FEATURES,
|
|
|
|
.config = &genphy_config,
|
|
|
|
.startup = &genphy_startup,
|
|
|
|
.shutdown = &genphy_shutdown,
|
|
|
|
};
|
2013-02-06 21:18:37 +00:00
|
|
|
|
2016-05-26 13:28:44 +00:00
|
|
|
int ksz886x_config(struct phy_device *phydev)
|
|
|
|
{
|
|
|
|
/* we are connected directly to the switch without
|
|
|
|
* dedicated PHY. */
|
|
|
|
phydev->link = 1;
|
|
|
|
phydev->duplex = DUPLEX_FULL;
|
|
|
|
phydev->speed = SPEED_100;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ksz886x_startup(struct phy_device *phydev)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct phy_driver ksz886x_driver = {
|
|
|
|
.name = "Micrel KSZ886x Switch",
|
|
|
|
.uid = 0x00221430,
|
|
|
|
.mask = 0xfffff0,
|
|
|
|
.features = PHY_BASIC_FEATURES,
|
|
|
|
.config = &ksz886x_config,
|
|
|
|
.startup = &ksz886x_startup,
|
|
|
|
.shutdown = &genphy_shutdown,
|
|
|
|
};
|
|
|
|
|
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_ksz8xxx_init(void)
|
2011-04-08 02:56:05 +00:00
|
|
|
{
|
|
|
|
phy_register(&KSZ804_driver);
|
2015-09-09 20:29:51 +00:00
|
|
|
phy_register(&KSZ8031_driver);
|
2015-10-07 20:54:22 +00:00
|
|
|
phy_register(&KSZ8051_driver);
|
2015-03-24 10:32:24 +00:00
|
|
|
phy_register(&KSZ8081_driver);
|
2012-06-28 08:00:28 +00:00
|
|
|
phy_register(&KS8721_driver);
|
2014-02-19 16:21:59 +00:00
|
|
|
phy_register(&ksz8895_driver);
|
2016-05-26 13:28:44 +00:00
|
|
|
phy_register(&ksz886x_driver);
|
2011-04-08 02:56:05 +00:00
|
|
|
return 0;
|
|
|
|
}
|