forked from luck/tmp_suning_uos_patched
dcdecdcfe1
Recently genphy_read_abilities() has been added that dynamically detects clause 22 PHY abilities. I *think* this detection should work with all supported PHY's, at least for the ones with basic features sets, i.e. PHY_BASIC_FEATURES and PHY_GBIT_FEATURES. So let's remove setting these features explicitly and rely on phylib feature detection. I don't have access to most of these PHY's, therefore I'd appreciate regression testing. v2: - make the feature constant a comment so that readers know which features are supported by the respective PHY Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Tested-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
92 lines
2.3 KiB
C
92 lines
2.3 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* Driver for Broadcom 63xx SOCs integrated PHYs
|
|
*/
|
|
#include "bcm-phy-lib.h"
|
|
#include <linux/module.h>
|
|
#include <linux/phy.h>
|
|
|
|
#define MII_BCM63XX_IR 0x1a /* interrupt register */
|
|
#define MII_BCM63XX_IR_EN 0x4000 /* global interrupt enable */
|
|
#define MII_BCM63XX_IR_DUPLEX 0x0800 /* duplex changed */
|
|
#define MII_BCM63XX_IR_SPEED 0x0400 /* speed changed */
|
|
#define MII_BCM63XX_IR_LINK 0x0200 /* link changed */
|
|
#define MII_BCM63XX_IR_GMASK 0x0100 /* global interrupt mask */
|
|
|
|
MODULE_DESCRIPTION("Broadcom 63xx internal PHY driver");
|
|
MODULE_AUTHOR("Maxime Bizon <mbizon@freebox.fr>");
|
|
MODULE_LICENSE("GPL");
|
|
|
|
static int bcm63xx_config_intr(struct phy_device *phydev)
|
|
{
|
|
int reg, err;
|
|
|
|
reg = phy_read(phydev, MII_BCM63XX_IR);
|
|
if (reg < 0)
|
|
return reg;
|
|
|
|
if (phydev->interrupts == PHY_INTERRUPT_ENABLED)
|
|
reg &= ~MII_BCM63XX_IR_GMASK;
|
|
else
|
|
reg |= MII_BCM63XX_IR_GMASK;
|
|
|
|
err = phy_write(phydev, MII_BCM63XX_IR, reg);
|
|
return err;
|
|
}
|
|
|
|
static int bcm63xx_config_init(struct phy_device *phydev)
|
|
{
|
|
int reg, err;
|
|
|
|
/* ASYM_PAUSE bit is marked RO in datasheet, so don't cheat */
|
|
linkmode_set_bit(ETHTOOL_LINK_MODE_Pause_BIT, phydev->supported);
|
|
|
|
reg = phy_read(phydev, MII_BCM63XX_IR);
|
|
if (reg < 0)
|
|
return reg;
|
|
|
|
/* Mask interrupts globally. */
|
|
reg |= MII_BCM63XX_IR_GMASK;
|
|
err = phy_write(phydev, MII_BCM63XX_IR, reg);
|
|
if (err < 0)
|
|
return err;
|
|
|
|
/* Unmask events we are interested in */
|
|
reg = ~(MII_BCM63XX_IR_DUPLEX |
|
|
MII_BCM63XX_IR_SPEED |
|
|
MII_BCM63XX_IR_LINK) |
|
|
MII_BCM63XX_IR_EN;
|
|
return phy_write(phydev, MII_BCM63XX_IR, reg);
|
|
}
|
|
|
|
static struct phy_driver bcm63xx_driver[] = {
|
|
{
|
|
.phy_id = 0x00406000,
|
|
.phy_id_mask = 0xfffffc00,
|
|
.name = "Broadcom BCM63XX (1)",
|
|
/* PHY_BASIC_FEATURES */
|
|
.flags = PHY_IS_INTERNAL,
|
|
.config_init = bcm63xx_config_init,
|
|
.ack_interrupt = bcm_phy_ack_intr,
|
|
.config_intr = bcm63xx_config_intr,
|
|
}, {
|
|
/* same phy as above, with just a different OUI */
|
|
.phy_id = 0x002bdc00,
|
|
.phy_id_mask = 0xfffffc00,
|
|
/* PHY_BASIC_FEATURES */
|
|
.flags = PHY_IS_INTERNAL,
|
|
.config_init = bcm63xx_config_init,
|
|
.ack_interrupt = bcm_phy_ack_intr,
|
|
.config_intr = bcm63xx_config_intr,
|
|
} };
|
|
|
|
module_phy_driver(bcm63xx_driver);
|
|
|
|
static struct mdio_device_id __maybe_unused bcm63xx_tbl[] = {
|
|
{ 0x00406000, 0xfffffc00 },
|
|
{ 0x002bdc00, 0xfffffc00 },
|
|
{ }
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(mdio, bcm63xx_tbl);
|