2019-01-22 02:05:50 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2009-07-01 09:29:36 +08:00
|
|
|
/*
|
|
|
|
* Driver for Broadcom 63xx SOCs integrated PHYs
|
|
|
|
*/
|
2015-10-07 03:25:48 +08:00
|
|
|
#include "bcm-phy-lib.h"
|
2009-07-01 09:29:36 +08:00
|
|
|
#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");
|
|
|
|
|
2017-01-18 08:26:55 +08:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2009-07-01 09:29:36 +08:00
|
|
|
static int bcm63xx_config_init(struct phy_device *phydev)
|
|
|
|
{
|
|
|
|
int reg, err;
|
|
|
|
|
2018-09-30 05:04:16 +08:00
|
|
|
/* ASYM_PAUSE bit is marked RO in datasheet, so don't cheat */
|
2018-11-11 06:43:33 +08:00
|
|
|
linkmode_set_bit(ETHTOOL_LINK_MODE_Pause_BIT, phydev->supported);
|
2018-09-30 05:04:16 +08:00
|
|
|
|
2009-07-01 09:29:36 +08:00
|
|
|
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;
|
2012-04-02 14:24:55 +08:00
|
|
|
return phy_write(phydev, MII_BCM63XX_IR, reg);
|
2009-07-01 09:29:36 +08:00
|
|
|
}
|
|
|
|
|
2012-07-04 13:44:34 +08:00
|
|
|
static struct phy_driver bcm63xx_driver[] = {
|
|
|
|
{
|
2009-07-01 09:29:36 +08:00
|
|
|
.phy_id = 0x00406000,
|
|
|
|
.phy_id_mask = 0xfffffc00,
|
|
|
|
.name = "Broadcom BCM63XX (1)",
|
2019-04-13 02:47:03 +08:00
|
|
|
/* PHY_BASIC_FEATURES */
|
2018-11-10 01:17:22 +08:00
|
|
|
.flags = PHY_IS_INTERNAL,
|
2009-07-01 09:29:36 +08:00
|
|
|
.config_init = bcm63xx_config_init,
|
2015-10-07 03:25:48 +08:00
|
|
|
.ack_interrupt = bcm_phy_ack_intr,
|
2017-01-18 08:26:55 +08:00
|
|
|
.config_intr = bcm63xx_config_intr,
|
2012-07-04 13:44:34 +08:00
|
|
|
}, {
|
|
|
|
/* same phy as above, with just a different OUI */
|
2009-07-01 09:29:36 +08:00
|
|
|
.phy_id = 0x002bdc00,
|
|
|
|
.phy_id_mask = 0xfffffc00,
|
2019-04-13 02:47:03 +08:00
|
|
|
/* PHY_BASIC_FEATURES */
|
2018-11-10 01:17:22 +08:00
|
|
|
.flags = PHY_IS_INTERNAL,
|
2009-07-01 09:29:36 +08:00
|
|
|
.config_init = bcm63xx_config_init,
|
2015-10-07 03:25:48 +08:00
|
|
|
.ack_interrupt = bcm_phy_ack_intr,
|
2017-01-18 08:26:55 +08:00
|
|
|
.config_intr = bcm63xx_config_intr,
|
2012-07-04 13:44:34 +08:00
|
|
|
} };
|
2009-07-01 09:29:36 +08:00
|
|
|
|
2014-11-12 02:45:59 +08:00
|
|
|
module_phy_driver(bcm63xx_driver);
|
2010-04-02 09:05:56 +08:00
|
|
|
|
2010-10-04 07:43:32 +08:00
|
|
|
static struct mdio_device_id __maybe_unused bcm63xx_tbl[] = {
|
2010-04-02 09:05:56 +08:00
|
|
|
{ 0x00406000, 0xfffffc00 },
|
|
|
|
{ 0x002bdc00, 0xfffffc00 },
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2010-04-09 09:04:45 +08:00
|
|
|
MODULE_DEVICE_TABLE(mdio, bcm63xx_tbl);
|