109bb9aa0SMaxime Bizon /* 209bb9aa0SMaxime Bizon * Driver for Broadcom 63xx SOCs integrated PHYs 309bb9aa0SMaxime Bizon * 409bb9aa0SMaxime Bizon * This program is free software; you can redistribute it and/or 509bb9aa0SMaxime Bizon * modify it under the terms of the GNU General Public License 609bb9aa0SMaxime Bizon * as published by the Free Software Foundation; either version 709bb9aa0SMaxime Bizon * 2 of the License, or (at your option) any later version. 809bb9aa0SMaxime Bizon */ 9a1cba561SArun Parameswaran #include "bcm-phy-lib.h" 1009bb9aa0SMaxime Bizon #include <linux/module.h> 1109bb9aa0SMaxime Bizon #include <linux/phy.h> 1209bb9aa0SMaxime Bizon 1309bb9aa0SMaxime Bizon #define MII_BCM63XX_IR 0x1a /* interrupt register */ 1409bb9aa0SMaxime Bizon #define MII_BCM63XX_IR_EN 0x4000 /* global interrupt enable */ 1509bb9aa0SMaxime Bizon #define MII_BCM63XX_IR_DUPLEX 0x0800 /* duplex changed */ 1609bb9aa0SMaxime Bizon #define MII_BCM63XX_IR_SPEED 0x0400 /* speed changed */ 1709bb9aa0SMaxime Bizon #define MII_BCM63XX_IR_LINK 0x0200 /* link changed */ 1809bb9aa0SMaxime Bizon #define MII_BCM63XX_IR_GMASK 0x0100 /* global interrupt mask */ 1909bb9aa0SMaxime Bizon 2009bb9aa0SMaxime Bizon MODULE_DESCRIPTION("Broadcom 63xx internal PHY driver"); 2109bb9aa0SMaxime Bizon MODULE_AUTHOR("Maxime Bizon <mbizon@freebox.fr>"); 2209bb9aa0SMaxime Bizon MODULE_LICENSE("GPL"); 2309bb9aa0SMaxime Bizon 2409bb9aa0SMaxime Bizon static int bcm63xx_config_init(struct phy_device *phydev) 2509bb9aa0SMaxime Bizon { 2609bb9aa0SMaxime Bizon int reg, err; 2709bb9aa0SMaxime Bizon 2809bb9aa0SMaxime Bizon reg = phy_read(phydev, MII_BCM63XX_IR); 2909bb9aa0SMaxime Bizon if (reg < 0) 3009bb9aa0SMaxime Bizon return reg; 3109bb9aa0SMaxime Bizon 3209bb9aa0SMaxime Bizon /* Mask interrupts globally. */ 3309bb9aa0SMaxime Bizon reg |= MII_BCM63XX_IR_GMASK; 3409bb9aa0SMaxime Bizon err = phy_write(phydev, MII_BCM63XX_IR, reg); 3509bb9aa0SMaxime Bizon if (err < 0) 3609bb9aa0SMaxime Bizon return err; 3709bb9aa0SMaxime Bizon 3809bb9aa0SMaxime Bizon /* Unmask events we are interested in */ 3909bb9aa0SMaxime Bizon reg = ~(MII_BCM63XX_IR_DUPLEX | 4009bb9aa0SMaxime Bizon MII_BCM63XX_IR_SPEED | 4109bb9aa0SMaxime Bizon MII_BCM63XX_IR_LINK) | 4209bb9aa0SMaxime Bizon MII_BCM63XX_IR_EN; 43a25cc43eSSrinivas Kandagatla return phy_write(phydev, MII_BCM63XX_IR, reg); 4409bb9aa0SMaxime Bizon } 4509bb9aa0SMaxime Bizon 46d5bf9071SChristian Hohnstaedt static struct phy_driver bcm63xx_driver[] = { 47d5bf9071SChristian Hohnstaedt { 4809bb9aa0SMaxime Bizon .phy_id = 0x00406000, 4909bb9aa0SMaxime Bizon .phy_id_mask = 0xfffffc00, 5009bb9aa0SMaxime Bizon .name = "Broadcom BCM63XX (1)", 5109bb9aa0SMaxime Bizon /* ASYM_PAUSE bit is marked RO in datasheet, so don't cheat */ 5209bb9aa0SMaxime Bizon .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause), 5350ab731eSFlorian Fainelli .flags = PHY_HAS_INTERRUPT | PHY_IS_INTERNAL, 5409bb9aa0SMaxime Bizon .config_init = bcm63xx_config_init, 5509bb9aa0SMaxime Bizon .config_aneg = genphy_config_aneg, 5609bb9aa0SMaxime Bizon .read_status = genphy_read_status, 57a1cba561SArun Parameswaran .ack_interrupt = bcm_phy_ack_intr, 58a1cba561SArun Parameswaran .config_intr = bcm_phy_config_intr, 5909bb9aa0SMaxime Bizon .driver = { .owner = THIS_MODULE }, 60d5bf9071SChristian Hohnstaedt }, { 6109bb9aa0SMaxime Bizon /* same phy as above, with just a different OUI */ 6209bb9aa0SMaxime Bizon .phy_id = 0x002bdc00, 6309bb9aa0SMaxime Bizon .phy_id_mask = 0xfffffc00, 6409bb9aa0SMaxime Bizon .name = "Broadcom BCM63XX (2)", 6509bb9aa0SMaxime Bizon .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause), 6650ab731eSFlorian Fainelli .flags = PHY_HAS_INTERRUPT | PHY_IS_INTERNAL, 6709bb9aa0SMaxime Bizon .config_init = bcm63xx_config_init, 6809bb9aa0SMaxime Bizon .config_aneg = genphy_config_aneg, 6909bb9aa0SMaxime Bizon .read_status = genphy_read_status, 70a1cba561SArun Parameswaran .ack_interrupt = bcm_phy_ack_intr, 71a1cba561SArun Parameswaran .config_intr = bcm_phy_config_intr, 7209bb9aa0SMaxime Bizon .driver = { .owner = THIS_MODULE }, 73d5bf9071SChristian Hohnstaedt } }; 7409bb9aa0SMaxime Bizon 7550fd7150SJohan Hovold module_phy_driver(bcm63xx_driver); 764e4f10f6SDavid Woodhouse 77cf93c945SUwe Kleine-König static struct mdio_device_id __maybe_unused bcm63xx_tbl[] = { 784e4f10f6SDavid Woodhouse { 0x00406000, 0xfffffc00 }, 794e4f10f6SDavid Woodhouse { 0x002bdc00, 0xfffffc00 }, 804e4f10f6SDavid Woodhouse { } 814e4f10f6SDavid Woodhouse }; 824e4f10f6SDavid Woodhouse 830de8655aSFlorian Fainelli MODULE_DEVICE_TABLE(mdio, bcm63xx_tbl); 84