blob: e741bf614c4eeca4f4c041bff53880a5ca8c7439 [file] [log] [blame]
Maxime Bizon09bb9aa2009-07-01 01:29:36 +00001/*
2 * Driver for Broadcom 63xx SOCs integrated PHYs
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
8 */
Arun Parameswarana1cba562015-10-06 12:25:48 -07009#include "bcm-phy-lib.h"
Maxime Bizon09bb9aa2009-07-01 01:29:36 +000010#include <linux/module.h>
11#include <linux/phy.h>
12
13#define MII_BCM63XX_IR 0x1a /* interrupt register */
14#define MII_BCM63XX_IR_EN 0x4000 /* global interrupt enable */
15#define MII_BCM63XX_IR_DUPLEX 0x0800 /* duplex changed */
16#define MII_BCM63XX_IR_SPEED 0x0400 /* speed changed */
17#define MII_BCM63XX_IR_LINK 0x0200 /* link changed */
18#define MII_BCM63XX_IR_GMASK 0x0100 /* global interrupt mask */
19
20MODULE_DESCRIPTION("Broadcom 63xx internal PHY driver");
21MODULE_AUTHOR("Maxime Bizon <mbizon@freebox.fr>");
22MODULE_LICENSE("GPL");
23
24static int bcm63xx_config_init(struct phy_device *phydev)
25{
26 int reg, err;
27
28 reg = phy_read(phydev, MII_BCM63XX_IR);
29 if (reg < 0)
30 return reg;
31
32 /* Mask interrupts globally. */
33 reg |= MII_BCM63XX_IR_GMASK;
34 err = phy_write(phydev, MII_BCM63XX_IR, reg);
35 if (err < 0)
36 return err;
37
38 /* Unmask events we are interested in */
39 reg = ~(MII_BCM63XX_IR_DUPLEX |
40 MII_BCM63XX_IR_SPEED |
41 MII_BCM63XX_IR_LINK) |
42 MII_BCM63XX_IR_EN;
Srinivas Kandagatlaa25cc432012-04-02 06:24:55 +000043 return phy_write(phydev, MII_BCM63XX_IR, reg);
Maxime Bizon09bb9aa2009-07-01 01:29:36 +000044}
45
Christian Hohnstaedtd5bf9072012-07-04 05:44:34 +000046static struct phy_driver bcm63xx_driver[] = {
47{
Maxime Bizon09bb9aa2009-07-01 01:29:36 +000048 .phy_id = 0x00406000,
49 .phy_id_mask = 0xfffffc00,
50 .name = "Broadcom BCM63XX (1)",
51 /* ASYM_PAUSE bit is marked RO in datasheet, so don't cheat */
52 .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause),
Florian Fainelli50ab7312013-05-23 01:11:13 +000053 .flags = PHY_HAS_INTERRUPT | PHY_IS_INTERNAL,
Maxime Bizon09bb9aa2009-07-01 01:29:36 +000054 .config_init = bcm63xx_config_init,
55 .config_aneg = genphy_config_aneg,
56 .read_status = genphy_read_status,
Arun Parameswarana1cba562015-10-06 12:25:48 -070057 .ack_interrupt = bcm_phy_ack_intr,
58 .config_intr = bcm_phy_config_intr,
Christian Hohnstaedtd5bf9072012-07-04 05:44:34 +000059}, {
60 /* same phy as above, with just a different OUI */
Maxime Bizon09bb9aa2009-07-01 01:29:36 +000061 .phy_id = 0x002bdc00,
62 .phy_id_mask = 0xfffffc00,
63 .name = "Broadcom BCM63XX (2)",
64 .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause),
Florian Fainelli50ab7312013-05-23 01:11:13 +000065 .flags = PHY_HAS_INTERRUPT | PHY_IS_INTERNAL,
Maxime Bizon09bb9aa2009-07-01 01:29:36 +000066 .config_init = bcm63xx_config_init,
67 .config_aneg = genphy_config_aneg,
68 .read_status = genphy_read_status,
Arun Parameswarana1cba562015-10-06 12:25:48 -070069 .ack_interrupt = bcm_phy_ack_intr,
70 .config_intr = bcm_phy_config_intr,
Christian Hohnstaedtd5bf9072012-07-04 05:44:34 +000071} };
Maxime Bizon09bb9aa2009-07-01 01:29:36 +000072
Johan Hovold50fd7152014-11-11 19:45:59 +010073module_phy_driver(bcm63xx_driver);
David Woodhouse4e4f10f2010-04-02 01:05:56 +000074
Uwe Kleine-Königcf93c942010-10-03 23:43:32 +000075static struct mdio_device_id __maybe_unused bcm63xx_tbl[] = {
David Woodhouse4e4f10f2010-04-02 01:05:56 +000076 { 0x00406000, 0xfffffc00 },
77 { 0x002bdc00, 0xfffffc00 },
78 { }
79};
80
Florian Fainelli0de86552010-04-09 01:04:45 +000081MODULE_DEVICE_TABLE(mdio, bcm63xx_tbl);