forked from Minki/linux
cf93c94581
MODULE_DEVICE_TABLE only expands to something if it's compiled for a module. So when building-in support for the phys, the mdio_device_id tables are unused. Marking them with __maybe_unused fixes the following warnings: drivers/net/phy/bcm63xx.c:134: warning: 'bcm63xx_tbl' defined but not used drivers/net/phy/broadcom.c:933: warning: 'broadcom_tbl' defined but not used drivers/net/phy/cicada.c:162: warning: 'cicada_tbl' defined but not used drivers/net/phy/davicom.c:222: warning: 'davicom_tbl' defined but not used drivers/net/phy/et1011c.c:114: warning: 'et1011c_tbl' defined but not used drivers/net/phy/icplus.c:137: warning: 'icplus_tbl' defined but not used drivers/net/phy/lxt.c:226: warning: 'lxt_tbl' defined but not used drivers/net/phy/marvell.c:724: warning: 'marvell_tbl' defined but not used drivers/net/phy/micrel.c:234: warning: 'micrel_tbl' defined but not used drivers/net/phy/national.c:154: warning: 'ns_tbl' defined but not used drivers/net/phy/qsemi.c:141: warning: 'qs6612_tbl' defined but not used drivers/net/phy/realtek.c:82: warning: 'realtek_tbl' defined but not used drivers/net/phy/smsc.c:257: warning: 'smsc_tbl' defined but not used drivers/net/phy/ste10Xp.c:135: warning: 'ste10Xp_tbl' defined but not used drivers/net/phy/vitesse.c:195: warning: 'vitesse_tbl' defined but not used Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: David S. Miller <davem@davemloft.net>
141 lines
3.5 KiB
C
141 lines
3.5 KiB
C
/*
|
|
* Driver for Broadcom 63xx SOCs integrated PHYs
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation; either version
|
|
* 2 of the License, or (at your option) any later version.
|
|
*/
|
|
#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_init(struct phy_device *phydev)
|
|
{
|
|
int reg, err;
|
|
|
|
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;
|
|
err = phy_write(phydev, MII_BCM63XX_IR, reg);
|
|
if (err < 0)
|
|
return err;
|
|
return 0;
|
|
}
|
|
|
|
static int bcm63xx_ack_interrupt(struct phy_device *phydev)
|
|
{
|
|
int reg;
|
|
|
|
/* Clear pending interrupts. */
|
|
reg = phy_read(phydev, MII_BCM63XX_IR);
|
|
if (reg < 0)
|
|
return reg;
|
|
|
|
return 0;
|
|
}
|
|
|
|
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 struct phy_driver bcm63xx_1_driver = {
|
|
.phy_id = 0x00406000,
|
|
.phy_id_mask = 0xfffffc00,
|
|
.name = "Broadcom BCM63XX (1)",
|
|
/* ASYM_PAUSE bit is marked RO in datasheet, so don't cheat */
|
|
.features = (PHY_BASIC_FEATURES | SUPPORTED_Pause),
|
|
.flags = PHY_HAS_INTERRUPT,
|
|
.config_init = bcm63xx_config_init,
|
|
.config_aneg = genphy_config_aneg,
|
|
.read_status = genphy_read_status,
|
|
.ack_interrupt = bcm63xx_ack_interrupt,
|
|
.config_intr = bcm63xx_config_intr,
|
|
.driver = { .owner = THIS_MODULE },
|
|
};
|
|
|
|
/* same phy as above, with just a different OUI */
|
|
static struct phy_driver bcm63xx_2_driver = {
|
|
.phy_id = 0x002bdc00,
|
|
.phy_id_mask = 0xfffffc00,
|
|
.name = "Broadcom BCM63XX (2)",
|
|
.features = (PHY_BASIC_FEATURES | SUPPORTED_Pause),
|
|
.flags = PHY_HAS_INTERRUPT,
|
|
.config_init = bcm63xx_config_init,
|
|
.config_aneg = genphy_config_aneg,
|
|
.read_status = genphy_read_status,
|
|
.ack_interrupt = bcm63xx_ack_interrupt,
|
|
.config_intr = bcm63xx_config_intr,
|
|
.driver = { .owner = THIS_MODULE },
|
|
};
|
|
|
|
static int __init bcm63xx_phy_init(void)
|
|
{
|
|
int ret;
|
|
|
|
ret = phy_driver_register(&bcm63xx_1_driver);
|
|
if (ret)
|
|
goto out_63xx_1;
|
|
ret = phy_driver_register(&bcm63xx_2_driver);
|
|
if (ret)
|
|
goto out_63xx_2;
|
|
return ret;
|
|
|
|
out_63xx_2:
|
|
phy_driver_unregister(&bcm63xx_1_driver);
|
|
out_63xx_1:
|
|
return ret;
|
|
}
|
|
|
|
static void __exit bcm63xx_phy_exit(void)
|
|
{
|
|
phy_driver_unregister(&bcm63xx_1_driver);
|
|
phy_driver_unregister(&bcm63xx_2_driver);
|
|
}
|
|
|
|
module_init(bcm63xx_phy_init);
|
|
module_exit(bcm63xx_phy_exit);
|
|
|
|
static struct mdio_device_id __maybe_unused bcm63xx_tbl[] = {
|
|
{ 0x00406000, 0xfffffc00 },
|
|
{ 0x002bdc00, 0xfffffc00 },
|
|
{ }
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(mdio, bcm63xx_tbl);
|