1d0507009SDavid J. Choi /* 2d0507009SDavid J. Choi * drivers/net/phy/micrel.c 3d0507009SDavid J. Choi * 4d0507009SDavid J. Choi * Driver for Micrel PHYs 5d0507009SDavid J. Choi * 6d0507009SDavid J. Choi * Author: David J. Choi 7d0507009SDavid J. Choi * 87ab59dc1SDavid J. Choi * Copyright (c) 2010-2013 Micrel, Inc. 9d0507009SDavid J. Choi * 10d0507009SDavid J. Choi * This program is free software; you can redistribute it and/or modify it 11d0507009SDavid J. Choi * under the terms of the GNU General Public License as published by the 12d0507009SDavid J. Choi * Free Software Foundation; either version 2 of the License, or (at your 13d0507009SDavid J. Choi * option) any later version. 14d0507009SDavid J. Choi * 157ab59dc1SDavid J. Choi * Support : Micrel Phys: 167ab59dc1SDavid J. Choi * Giga phys: ksz9021, ksz9031 177ab59dc1SDavid J. Choi * 100/10 Phys : ksz8001, ksz8721, ksz8737, ksz8041 187ab59dc1SDavid J. Choi * ksz8021, ksz8031, ksz8051, 197ab59dc1SDavid J. Choi * ksz8081, ksz8091, 207ab59dc1SDavid J. Choi * ksz8061, 217ab59dc1SDavid J. Choi * Switch : ksz8873, ksz886x 22d0507009SDavid J. Choi */ 23d0507009SDavid J. Choi 24d0507009SDavid J. Choi #include <linux/kernel.h> 25d0507009SDavid J. Choi #include <linux/module.h> 26d0507009SDavid J. Choi #include <linux/phy.h> 27d606ef3fSBaruch Siach #include <linux/micrel_phy.h> 28954c3967SSean Cross #include <linux/of.h> 29d0507009SDavid J. Choi 30212ea99aSMarek Vasut /* Operation Mode Strap Override */ 31212ea99aSMarek Vasut #define MII_KSZPHY_OMSO 0x16 32212ea99aSMarek Vasut #define KSZPHY_OMSO_B_CAST_OFF (1 << 9) 33212ea99aSMarek Vasut #define KSZPHY_OMSO_RMII_OVERRIDE (1 << 1) 34212ea99aSMarek Vasut #define KSZPHY_OMSO_MII_OVERRIDE (1 << 0) 35212ea99aSMarek Vasut 3651f932c4SChoi, David /* general Interrupt control/status reg in vendor specific block. */ 3751f932c4SChoi, David #define MII_KSZPHY_INTCS 0x1B 3851f932c4SChoi, David #define KSZPHY_INTCS_JABBER (1 << 15) 3951f932c4SChoi, David #define KSZPHY_INTCS_RECEIVE_ERR (1 << 14) 4051f932c4SChoi, David #define KSZPHY_INTCS_PAGE_RECEIVE (1 << 13) 4151f932c4SChoi, David #define KSZPHY_INTCS_PARELLEL (1 << 12) 4251f932c4SChoi, David #define KSZPHY_INTCS_LINK_PARTNER_ACK (1 << 11) 4351f932c4SChoi, David #define KSZPHY_INTCS_LINK_DOWN (1 << 10) 4451f932c4SChoi, David #define KSZPHY_INTCS_REMOTE_FAULT (1 << 9) 4551f932c4SChoi, David #define KSZPHY_INTCS_LINK_UP (1 << 8) 4651f932c4SChoi, David #define KSZPHY_INTCS_ALL (KSZPHY_INTCS_LINK_UP |\ 4751f932c4SChoi, David KSZPHY_INTCS_LINK_DOWN) 4851f932c4SChoi, David 4951f932c4SChoi, David /* general PHY control reg in vendor specific block. */ 5051f932c4SChoi, David #define MII_KSZPHY_CTRL 0x1F 5151f932c4SChoi, David /* bitmap of PHY register to set interrupt mode */ 5251f932c4SChoi, David #define KSZPHY_CTRL_INT_ACTIVE_HIGH (1 << 9) 5351f932c4SChoi, David #define KSZ9021_CTRL_INT_ACTIVE_HIGH (1 << 14) 5451f932c4SChoi, David #define KS8737_CTRL_INT_ACTIVE_HIGH (1 << 14) 55d606ef3fSBaruch Siach #define KSZ8051_RMII_50MHZ_CLK (1 << 7) 5651f932c4SChoi, David 57954c3967SSean Cross /* Write/read to/from extended registers */ 58954c3967SSean Cross #define MII_KSZPHY_EXTREG 0x0b 59954c3967SSean Cross #define KSZPHY_EXTREG_WRITE 0x8000 60954c3967SSean Cross 61954c3967SSean Cross #define MII_KSZPHY_EXTREG_WRITE 0x0c 62954c3967SSean Cross #define MII_KSZPHY_EXTREG_READ 0x0d 63954c3967SSean Cross 64954c3967SSean Cross /* Extended registers */ 65954c3967SSean Cross #define MII_KSZPHY_CLK_CONTROL_PAD_SKEW 0x104 66954c3967SSean Cross #define MII_KSZPHY_RX_DATA_PAD_SKEW 0x105 67954c3967SSean Cross #define MII_KSZPHY_TX_DATA_PAD_SKEW 0x106 68954c3967SSean Cross 69954c3967SSean Cross #define PS_TO_REG 200 70954c3967SSean Cross 71b6bb4dfcSHector Palacios static int ksz_config_flags(struct phy_device *phydev) 72b6bb4dfcSHector Palacios { 73b6bb4dfcSHector Palacios int regval; 74b6bb4dfcSHector Palacios 75b6bb4dfcSHector Palacios if (phydev->dev_flags & MICREL_PHY_50MHZ_CLK) { 76b6bb4dfcSHector Palacios regval = phy_read(phydev, MII_KSZPHY_CTRL); 77b6bb4dfcSHector Palacios regval |= KSZ8051_RMII_50MHZ_CLK; 78b6bb4dfcSHector Palacios return phy_write(phydev, MII_KSZPHY_CTRL, regval); 79b6bb4dfcSHector Palacios } 80b6bb4dfcSHector Palacios return 0; 81b6bb4dfcSHector Palacios } 82b6bb4dfcSHector Palacios 83954c3967SSean Cross static int kszphy_extended_write(struct phy_device *phydev, 84954c3967SSean Cross u32 regnum, u16 val) 85954c3967SSean Cross { 86954c3967SSean Cross phy_write(phydev, MII_KSZPHY_EXTREG, KSZPHY_EXTREG_WRITE | regnum); 87954c3967SSean Cross return phy_write(phydev, MII_KSZPHY_EXTREG_WRITE, val); 88954c3967SSean Cross } 89954c3967SSean Cross 90954c3967SSean Cross static int kszphy_extended_read(struct phy_device *phydev, 91954c3967SSean Cross u32 regnum) 92954c3967SSean Cross { 93954c3967SSean Cross phy_write(phydev, MII_KSZPHY_EXTREG, regnum); 94954c3967SSean Cross return phy_read(phydev, MII_KSZPHY_EXTREG_READ); 95954c3967SSean Cross } 96954c3967SSean Cross 9751f932c4SChoi, David static int kszphy_ack_interrupt(struct phy_device *phydev) 9851f932c4SChoi, David { 9951f932c4SChoi, David /* bit[7..0] int status, which is a read and clear register. */ 10051f932c4SChoi, David int rc; 10151f932c4SChoi, David 10251f932c4SChoi, David rc = phy_read(phydev, MII_KSZPHY_INTCS); 10351f932c4SChoi, David 10451f932c4SChoi, David return (rc < 0) ? rc : 0; 10551f932c4SChoi, David } 10651f932c4SChoi, David 10751f932c4SChoi, David static int kszphy_set_interrupt(struct phy_device *phydev) 10851f932c4SChoi, David { 10951f932c4SChoi, David int temp; 11051f932c4SChoi, David temp = (PHY_INTERRUPT_ENABLED == phydev->interrupts) ? 11151f932c4SChoi, David KSZPHY_INTCS_ALL : 0; 11251f932c4SChoi, David return phy_write(phydev, MII_KSZPHY_INTCS, temp); 11351f932c4SChoi, David } 11451f932c4SChoi, David 11551f932c4SChoi, David static int kszphy_config_intr(struct phy_device *phydev) 11651f932c4SChoi, David { 11751f932c4SChoi, David int temp, rc; 11851f932c4SChoi, David 11951f932c4SChoi, David /* set the interrupt pin active low */ 12051f932c4SChoi, David temp = phy_read(phydev, MII_KSZPHY_CTRL); 12151f932c4SChoi, David temp &= ~KSZPHY_CTRL_INT_ACTIVE_HIGH; 12251f932c4SChoi, David phy_write(phydev, MII_KSZPHY_CTRL, temp); 12351f932c4SChoi, David rc = kszphy_set_interrupt(phydev); 12451f932c4SChoi, David return rc < 0 ? rc : 0; 12551f932c4SChoi, David } 12651f932c4SChoi, David 12751f932c4SChoi, David static int ksz9021_config_intr(struct phy_device *phydev) 12851f932c4SChoi, David { 12951f932c4SChoi, David int temp, rc; 13051f932c4SChoi, David 13151f932c4SChoi, David /* set the interrupt pin active low */ 13251f932c4SChoi, David temp = phy_read(phydev, MII_KSZPHY_CTRL); 13351f932c4SChoi, David temp &= ~KSZ9021_CTRL_INT_ACTIVE_HIGH; 13451f932c4SChoi, David phy_write(phydev, MII_KSZPHY_CTRL, temp); 13551f932c4SChoi, David rc = kszphy_set_interrupt(phydev); 13651f932c4SChoi, David return rc < 0 ? rc : 0; 13751f932c4SChoi, David } 13851f932c4SChoi, David 13951f932c4SChoi, David static int ks8737_config_intr(struct phy_device *phydev) 14051f932c4SChoi, David { 14151f932c4SChoi, David int temp, rc; 14251f932c4SChoi, David 14351f932c4SChoi, David /* set the interrupt pin active low */ 14451f932c4SChoi, David temp = phy_read(phydev, MII_KSZPHY_CTRL); 14551f932c4SChoi, David temp &= ~KS8737_CTRL_INT_ACTIVE_HIGH; 14651f932c4SChoi, David phy_write(phydev, MII_KSZPHY_CTRL, temp); 14751f932c4SChoi, David rc = kszphy_set_interrupt(phydev); 14851f932c4SChoi, David return rc < 0 ? rc : 0; 14951f932c4SChoi, David } 150d0507009SDavid J. Choi 151*20d8435aSBen Dooks static int kszphy_setup_led(struct phy_device *phydev, 152*20d8435aSBen Dooks unsigned int reg, unsigned int shift) 153*20d8435aSBen Dooks { 154*20d8435aSBen Dooks 155*20d8435aSBen Dooks struct device *dev = &phydev->dev; 156*20d8435aSBen Dooks struct device_node *of_node = dev->of_node; 157*20d8435aSBen Dooks int rc, temp; 158*20d8435aSBen Dooks u32 val; 159*20d8435aSBen Dooks 160*20d8435aSBen Dooks if (!of_node && dev->parent->of_node) 161*20d8435aSBen Dooks of_node = dev->parent->of_node; 162*20d8435aSBen Dooks 163*20d8435aSBen Dooks if (of_property_read_u32(of_node, "micrel,led-mode", &val)) 164*20d8435aSBen Dooks return 0; 165*20d8435aSBen Dooks 166*20d8435aSBen Dooks temp = phy_read(phydev, reg); 167*20d8435aSBen Dooks if (temp < 0) 168*20d8435aSBen Dooks return temp; 169*20d8435aSBen Dooks 170*20d8435aSBen Dooks temp &= 3 << shift; 171*20d8435aSBen Dooks temp |= val << shift; 172*20d8435aSBen Dooks rc = phy_write(phydev, reg, temp); 173*20d8435aSBen Dooks 174*20d8435aSBen Dooks return rc < 0 ? rc : 0; 175*20d8435aSBen Dooks } 176*20d8435aSBen Dooks 177d0507009SDavid J. Choi static int kszphy_config_init(struct phy_device *phydev) 178d0507009SDavid J. Choi { 179d0507009SDavid J. Choi return 0; 180d0507009SDavid J. Choi } 181d0507009SDavid J. Choi 182*20d8435aSBen Dooks static int kszphy_config_init_led8041(struct phy_device *phydev) 183*20d8435aSBen Dooks { 184*20d8435aSBen Dooks /* single led control, register 0x1e bits 15..14 */ 185*20d8435aSBen Dooks return kszphy_setup_led(phydev, 0x1e, 14); 186*20d8435aSBen Dooks } 187*20d8435aSBen Dooks 188212ea99aSMarek Vasut static int ksz8021_config_init(struct phy_device *phydev) 189212ea99aSMarek Vasut { 190212ea99aSMarek Vasut const u16 val = KSZPHY_OMSO_B_CAST_OFF | KSZPHY_OMSO_RMII_OVERRIDE; 191*20d8435aSBen Dooks int rc; 192*20d8435aSBen Dooks 193*20d8435aSBen Dooks rc = kszphy_setup_led(phydev, 0x1f, 4); 194*20d8435aSBen Dooks if (rc) 195*20d8435aSBen Dooks dev_err(&phydev->dev, "failed to set led mode\n"); 196*20d8435aSBen Dooks 197212ea99aSMarek Vasut phy_write(phydev, MII_KSZPHY_OMSO, val); 198b6bb4dfcSHector Palacios rc = ksz_config_flags(phydev); 199b6bb4dfcSHector Palacios return rc < 0 ? rc : 0; 200212ea99aSMarek Vasut } 201212ea99aSMarek Vasut 202d606ef3fSBaruch Siach static int ks8051_config_init(struct phy_device *phydev) 203d606ef3fSBaruch Siach { 204b6bb4dfcSHector Palacios int rc; 205d606ef3fSBaruch Siach 206*20d8435aSBen Dooks rc = kszphy_setup_led(phydev, 0x1f, 4); 207*20d8435aSBen Dooks if (rc) 208*20d8435aSBen Dooks dev_err(&phydev->dev, "failed to set led mode\n"); 209*20d8435aSBen Dooks 210b6bb4dfcSHector Palacios rc = ksz_config_flags(phydev); 211b6bb4dfcSHector Palacios return rc < 0 ? rc : 0; 212d606ef3fSBaruch Siach } 213d606ef3fSBaruch Siach 214954c3967SSean Cross static int ksz9021_load_values_from_of(struct phy_device *phydev, 215954c3967SSean Cross struct device_node *of_node, u16 reg, 216954c3967SSean Cross char *field1, char *field2, 217954c3967SSean Cross char *field3, char *field4) 218954c3967SSean Cross { 219954c3967SSean Cross int val1 = -1; 220954c3967SSean Cross int val2 = -2; 221954c3967SSean Cross int val3 = -3; 222954c3967SSean Cross int val4 = -4; 223954c3967SSean Cross int newval; 224954c3967SSean Cross int matches = 0; 225954c3967SSean Cross 226954c3967SSean Cross if (!of_property_read_u32(of_node, field1, &val1)) 227954c3967SSean Cross matches++; 228954c3967SSean Cross 229954c3967SSean Cross if (!of_property_read_u32(of_node, field2, &val2)) 230954c3967SSean Cross matches++; 231954c3967SSean Cross 232954c3967SSean Cross if (!of_property_read_u32(of_node, field3, &val3)) 233954c3967SSean Cross matches++; 234954c3967SSean Cross 235954c3967SSean Cross if (!of_property_read_u32(of_node, field4, &val4)) 236954c3967SSean Cross matches++; 237954c3967SSean Cross 238954c3967SSean Cross if (!matches) 239954c3967SSean Cross return 0; 240954c3967SSean Cross 241954c3967SSean Cross if (matches < 4) 242954c3967SSean Cross newval = kszphy_extended_read(phydev, reg); 243954c3967SSean Cross else 244954c3967SSean Cross newval = 0; 245954c3967SSean Cross 246954c3967SSean Cross if (val1 != -1) 247954c3967SSean Cross newval = ((newval & 0xfff0) | ((val1 / PS_TO_REG) & 0xf) << 0); 248954c3967SSean Cross 249954c3967SSean Cross if (val2 != -1) 250954c3967SSean Cross newval = ((newval & 0xff0f) | ((val2 / PS_TO_REG) & 0xf) << 4); 251954c3967SSean Cross 252954c3967SSean Cross if (val3 != -1) 253954c3967SSean Cross newval = ((newval & 0xf0ff) | ((val3 / PS_TO_REG) & 0xf) << 8); 254954c3967SSean Cross 255954c3967SSean Cross if (val4 != -1) 256954c3967SSean Cross newval = ((newval & 0x0fff) | ((val4 / PS_TO_REG) & 0xf) << 12); 257954c3967SSean Cross 258954c3967SSean Cross return kszphy_extended_write(phydev, reg, newval); 259954c3967SSean Cross } 260954c3967SSean Cross 261954c3967SSean Cross static int ksz9021_config_init(struct phy_device *phydev) 262954c3967SSean Cross { 263954c3967SSean Cross struct device *dev = &phydev->dev; 264954c3967SSean Cross struct device_node *of_node = dev->of_node; 265954c3967SSean Cross 266954c3967SSean Cross if (!of_node && dev->parent->of_node) 267954c3967SSean Cross of_node = dev->parent->of_node; 268954c3967SSean Cross 269954c3967SSean Cross if (of_node) { 270954c3967SSean Cross ksz9021_load_values_from_of(phydev, of_node, 271954c3967SSean Cross MII_KSZPHY_CLK_CONTROL_PAD_SKEW, 272954c3967SSean Cross "txen-skew-ps", "txc-skew-ps", 273954c3967SSean Cross "rxdv-skew-ps", "rxc-skew-ps"); 274954c3967SSean Cross ksz9021_load_values_from_of(phydev, of_node, 275954c3967SSean Cross MII_KSZPHY_RX_DATA_PAD_SKEW, 276954c3967SSean Cross "rxd0-skew-ps", "rxd1-skew-ps", 277954c3967SSean Cross "rxd2-skew-ps", "rxd3-skew-ps"); 278954c3967SSean Cross ksz9021_load_values_from_of(phydev, of_node, 279954c3967SSean Cross MII_KSZPHY_TX_DATA_PAD_SKEW, 280954c3967SSean Cross "txd0-skew-ps", "txd1-skew-ps", 281954c3967SSean Cross "txd2-skew-ps", "txd3-skew-ps"); 282954c3967SSean Cross } 283954c3967SSean Cross return 0; 284954c3967SSean Cross } 285954c3967SSean Cross 28693272e07SJean-Christophe PLAGNIOL-VILLARD #define KSZ8873MLL_GLOBAL_CONTROL_4 0x06 28793272e07SJean-Christophe PLAGNIOL-VILLARD #define KSZ8873MLL_GLOBAL_CONTROL_4_DUPLEX (1 << 6) 28893272e07SJean-Christophe PLAGNIOL-VILLARD #define KSZ8873MLL_GLOBAL_CONTROL_4_SPEED (1 << 4) 28932d73b14SJingoo Han static int ksz8873mll_read_status(struct phy_device *phydev) 29093272e07SJean-Christophe PLAGNIOL-VILLARD { 29193272e07SJean-Christophe PLAGNIOL-VILLARD int regval; 29293272e07SJean-Christophe PLAGNIOL-VILLARD 29393272e07SJean-Christophe PLAGNIOL-VILLARD /* dummy read */ 29493272e07SJean-Christophe PLAGNIOL-VILLARD regval = phy_read(phydev, KSZ8873MLL_GLOBAL_CONTROL_4); 29593272e07SJean-Christophe PLAGNIOL-VILLARD 29693272e07SJean-Christophe PLAGNIOL-VILLARD regval = phy_read(phydev, KSZ8873MLL_GLOBAL_CONTROL_4); 29793272e07SJean-Christophe PLAGNIOL-VILLARD 29893272e07SJean-Christophe PLAGNIOL-VILLARD if (regval & KSZ8873MLL_GLOBAL_CONTROL_4_DUPLEX) 29993272e07SJean-Christophe PLAGNIOL-VILLARD phydev->duplex = DUPLEX_HALF; 30093272e07SJean-Christophe PLAGNIOL-VILLARD else 30193272e07SJean-Christophe PLAGNIOL-VILLARD phydev->duplex = DUPLEX_FULL; 30293272e07SJean-Christophe PLAGNIOL-VILLARD 30393272e07SJean-Christophe PLAGNIOL-VILLARD if (regval & KSZ8873MLL_GLOBAL_CONTROL_4_SPEED) 30493272e07SJean-Christophe PLAGNIOL-VILLARD phydev->speed = SPEED_10; 30593272e07SJean-Christophe PLAGNIOL-VILLARD else 30693272e07SJean-Christophe PLAGNIOL-VILLARD phydev->speed = SPEED_100; 30793272e07SJean-Christophe PLAGNIOL-VILLARD 30893272e07SJean-Christophe PLAGNIOL-VILLARD phydev->link = 1; 30993272e07SJean-Christophe PLAGNIOL-VILLARD phydev->pause = phydev->asym_pause = 0; 31093272e07SJean-Christophe PLAGNIOL-VILLARD 31193272e07SJean-Christophe PLAGNIOL-VILLARD return 0; 31293272e07SJean-Christophe PLAGNIOL-VILLARD } 31393272e07SJean-Christophe PLAGNIOL-VILLARD 31493272e07SJean-Christophe PLAGNIOL-VILLARD static int ksz8873mll_config_aneg(struct phy_device *phydev) 31593272e07SJean-Christophe PLAGNIOL-VILLARD { 31693272e07SJean-Christophe PLAGNIOL-VILLARD return 0; 31793272e07SJean-Christophe PLAGNIOL-VILLARD } 31893272e07SJean-Christophe PLAGNIOL-VILLARD 319d5bf9071SChristian Hohnstaedt static struct phy_driver ksphy_driver[] = { 320d5bf9071SChristian Hohnstaedt { 32151f932c4SChoi, David .phy_id = PHY_ID_KS8737, 322d0507009SDavid J. Choi .phy_id_mask = 0x00fffff0, 32351f932c4SChoi, David .name = "Micrel KS8737", 32451f932c4SChoi, David .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause), 32551f932c4SChoi, David .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, 326d0507009SDavid J. Choi .config_init = kszphy_config_init, 327d0507009SDavid J. Choi .config_aneg = genphy_config_aneg, 328d0507009SDavid J. Choi .read_status = genphy_read_status, 32951f932c4SChoi, David .ack_interrupt = kszphy_ack_interrupt, 33051f932c4SChoi, David .config_intr = ks8737_config_intr, 3311a5465f5SPatrice Vilchez .suspend = genphy_suspend, 3321a5465f5SPatrice Vilchez .resume = genphy_resume, 333d0507009SDavid J. Choi .driver = { .owner = THIS_MODULE,}, 334d5bf9071SChristian Hohnstaedt }, { 335212ea99aSMarek Vasut .phy_id = PHY_ID_KSZ8021, 336212ea99aSMarek Vasut .phy_id_mask = 0x00ffffff, 3377ab59dc1SDavid J. Choi .name = "Micrel KSZ8021 or KSZ8031", 338212ea99aSMarek Vasut .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause | 339212ea99aSMarek Vasut SUPPORTED_Asym_Pause), 340212ea99aSMarek Vasut .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, 341212ea99aSMarek Vasut .config_init = ksz8021_config_init, 342212ea99aSMarek Vasut .config_aneg = genphy_config_aneg, 343212ea99aSMarek Vasut .read_status = genphy_read_status, 344212ea99aSMarek Vasut .ack_interrupt = kszphy_ack_interrupt, 345212ea99aSMarek Vasut .config_intr = kszphy_config_intr, 3461a5465f5SPatrice Vilchez .suspend = genphy_suspend, 3471a5465f5SPatrice Vilchez .resume = genphy_resume, 348212ea99aSMarek Vasut .driver = { .owner = THIS_MODULE,}, 349212ea99aSMarek Vasut }, { 350b818d1a7SHector Palacios .phy_id = PHY_ID_KSZ8031, 351b818d1a7SHector Palacios .phy_id_mask = 0x00ffffff, 352b818d1a7SHector Palacios .name = "Micrel KSZ8031", 353b818d1a7SHector Palacios .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause | 354b818d1a7SHector Palacios SUPPORTED_Asym_Pause), 355b818d1a7SHector Palacios .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, 356b818d1a7SHector Palacios .config_init = ksz8021_config_init, 357b818d1a7SHector Palacios .config_aneg = genphy_config_aneg, 358b818d1a7SHector Palacios .read_status = genphy_read_status, 359b818d1a7SHector Palacios .ack_interrupt = kszphy_ack_interrupt, 360b818d1a7SHector Palacios .config_intr = kszphy_config_intr, 3611a5465f5SPatrice Vilchez .suspend = genphy_suspend, 3621a5465f5SPatrice Vilchez .resume = genphy_resume, 363b818d1a7SHector Palacios .driver = { .owner = THIS_MODULE,}, 364b818d1a7SHector Palacios }, { 365510d573fSMarek Vasut .phy_id = PHY_ID_KSZ8041, 366d0507009SDavid J. Choi .phy_id_mask = 0x00fffff0, 367510d573fSMarek Vasut .name = "Micrel KSZ8041", 36851f932c4SChoi, David .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause 36951f932c4SChoi, David | SUPPORTED_Asym_Pause), 37051f932c4SChoi, David .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, 371*20d8435aSBen Dooks .config_init = kszphy_config_init_led8041, 372d0507009SDavid J. Choi .config_aneg = genphy_config_aneg, 373d0507009SDavid J. Choi .read_status = genphy_read_status, 37451f932c4SChoi, David .ack_interrupt = kszphy_ack_interrupt, 37551f932c4SChoi, David .config_intr = kszphy_config_intr, 3761a5465f5SPatrice Vilchez .suspend = genphy_suspend, 3771a5465f5SPatrice Vilchez .resume = genphy_resume, 37851f932c4SChoi, David .driver = { .owner = THIS_MODULE,}, 379d5bf9071SChristian Hohnstaedt }, { 3804bd7b512SSergei Shtylyov .phy_id = PHY_ID_KSZ8041RNLI, 3814bd7b512SSergei Shtylyov .phy_id_mask = 0x00fffff0, 3824bd7b512SSergei Shtylyov .name = "Micrel KSZ8041RNLI", 3834bd7b512SSergei Shtylyov .features = PHY_BASIC_FEATURES | 3844bd7b512SSergei Shtylyov SUPPORTED_Pause | SUPPORTED_Asym_Pause, 3854bd7b512SSergei Shtylyov .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, 386*20d8435aSBen Dooks .config_init = kszphy_config_init_led8041, 3874bd7b512SSergei Shtylyov .config_aneg = genphy_config_aneg, 3884bd7b512SSergei Shtylyov .read_status = genphy_read_status, 3894bd7b512SSergei Shtylyov .ack_interrupt = kszphy_ack_interrupt, 3904bd7b512SSergei Shtylyov .config_intr = kszphy_config_intr, 3914bd7b512SSergei Shtylyov .suspend = genphy_suspend, 3924bd7b512SSergei Shtylyov .resume = genphy_resume, 3934bd7b512SSergei Shtylyov .driver = { .owner = THIS_MODULE,}, 3944bd7b512SSergei Shtylyov }, { 395510d573fSMarek Vasut .phy_id = PHY_ID_KSZ8051, 39651f932c4SChoi, David .phy_id_mask = 0x00fffff0, 397510d573fSMarek Vasut .name = "Micrel KSZ8051", 39851f932c4SChoi, David .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause 39951f932c4SChoi, David | SUPPORTED_Asym_Pause), 40051f932c4SChoi, David .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, 401d606ef3fSBaruch Siach .config_init = ks8051_config_init, 40251f932c4SChoi, David .config_aneg = genphy_config_aneg, 40351f932c4SChoi, David .read_status = genphy_read_status, 40451f932c4SChoi, David .ack_interrupt = kszphy_ack_interrupt, 40551f932c4SChoi, David .config_intr = kszphy_config_intr, 4061a5465f5SPatrice Vilchez .suspend = genphy_suspend, 4071a5465f5SPatrice Vilchez .resume = genphy_resume, 40851f932c4SChoi, David .driver = { .owner = THIS_MODULE,}, 409d5bf9071SChristian Hohnstaedt }, { 410510d573fSMarek Vasut .phy_id = PHY_ID_KSZ8001, 411510d573fSMarek Vasut .name = "Micrel KSZ8001 or KS8721", 41248d7d0adSJason Wang .phy_id_mask = 0x00ffffff, 41351f932c4SChoi, David .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause), 41451f932c4SChoi, David .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, 415*20d8435aSBen Dooks .config_init = kszphy_config_init_led8041, 41651f932c4SChoi, David .config_aneg = genphy_config_aneg, 41751f932c4SChoi, David .read_status = genphy_read_status, 41851f932c4SChoi, David .ack_interrupt = kszphy_ack_interrupt, 41951f932c4SChoi, David .config_intr = kszphy_config_intr, 4201a5465f5SPatrice Vilchez .suspend = genphy_suspend, 4211a5465f5SPatrice Vilchez .resume = genphy_resume, 422d0507009SDavid J. Choi .driver = { .owner = THIS_MODULE,}, 423d5bf9071SChristian Hohnstaedt }, { 4247ab59dc1SDavid J. Choi .phy_id = PHY_ID_KSZ8081, 4257ab59dc1SDavid J. Choi .name = "Micrel KSZ8081 or KSZ8091", 4267ab59dc1SDavid J. Choi .phy_id_mask = 0x00fffff0, 4277ab59dc1SDavid J. Choi .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause), 4287ab59dc1SDavid J. Choi .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, 4297ab59dc1SDavid J. Choi .config_init = kszphy_config_init, 4307ab59dc1SDavid J. Choi .config_aneg = genphy_config_aneg, 4317ab59dc1SDavid J. Choi .read_status = genphy_read_status, 4327ab59dc1SDavid J. Choi .ack_interrupt = kszphy_ack_interrupt, 4337ab59dc1SDavid J. Choi .config_intr = kszphy_config_intr, 4341a5465f5SPatrice Vilchez .suspend = genphy_suspend, 4351a5465f5SPatrice Vilchez .resume = genphy_resume, 4367ab59dc1SDavid J. Choi .driver = { .owner = THIS_MODULE,}, 4377ab59dc1SDavid J. Choi }, { 4387ab59dc1SDavid J. Choi .phy_id = PHY_ID_KSZ8061, 4397ab59dc1SDavid J. Choi .name = "Micrel KSZ8061", 4407ab59dc1SDavid J. Choi .phy_id_mask = 0x00fffff0, 4417ab59dc1SDavid J. Choi .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause), 4427ab59dc1SDavid J. Choi .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, 4437ab59dc1SDavid J. Choi .config_init = kszphy_config_init, 4447ab59dc1SDavid J. Choi .config_aneg = genphy_config_aneg, 4457ab59dc1SDavid J. Choi .read_status = genphy_read_status, 4467ab59dc1SDavid J. Choi .ack_interrupt = kszphy_ack_interrupt, 4477ab59dc1SDavid J. Choi .config_intr = kszphy_config_intr, 4481a5465f5SPatrice Vilchez .suspend = genphy_suspend, 4491a5465f5SPatrice Vilchez .resume = genphy_resume, 4507ab59dc1SDavid J. Choi .driver = { .owner = THIS_MODULE,}, 4517ab59dc1SDavid J. Choi }, { 452d0507009SDavid J. Choi .phy_id = PHY_ID_KSZ9021, 45348d7d0adSJason Wang .phy_id_mask = 0x000ffffe, 454d0507009SDavid J. Choi .name = "Micrel KSZ9021 Gigabit PHY", 45532fcafbcSVlastimil Kosar .features = (PHY_GBIT_FEATURES | SUPPORTED_Pause), 45651f932c4SChoi, David .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, 457954c3967SSean Cross .config_init = ksz9021_config_init, 458d0507009SDavid J. Choi .config_aneg = genphy_config_aneg, 459d0507009SDavid J. Choi .read_status = genphy_read_status, 46051f932c4SChoi, David .ack_interrupt = kszphy_ack_interrupt, 46151f932c4SChoi, David .config_intr = ksz9021_config_intr, 4621a5465f5SPatrice Vilchez .suspend = genphy_suspend, 4631a5465f5SPatrice Vilchez .resume = genphy_resume, 464d0507009SDavid J. Choi .driver = { .owner = THIS_MODULE, }, 46593272e07SJean-Christophe PLAGNIOL-VILLARD }, { 4667ab59dc1SDavid J. Choi .phy_id = PHY_ID_KSZ9031, 4677ab59dc1SDavid J. Choi .phy_id_mask = 0x00fffff0, 4687ab59dc1SDavid J. Choi .name = "Micrel KSZ9031 Gigabit PHY", 4697ab59dc1SDavid J. Choi .features = (PHY_GBIT_FEATURES | SUPPORTED_Pause 4707ab59dc1SDavid J. Choi | SUPPORTED_Asym_Pause), 4717ab59dc1SDavid J. Choi .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, 4727ab59dc1SDavid J. Choi .config_init = kszphy_config_init, 4737ab59dc1SDavid J. Choi .config_aneg = genphy_config_aneg, 4747ab59dc1SDavid J. Choi .read_status = genphy_read_status, 4757ab59dc1SDavid J. Choi .ack_interrupt = kszphy_ack_interrupt, 4767ab59dc1SDavid J. Choi .config_intr = ksz9021_config_intr, 4771a5465f5SPatrice Vilchez .suspend = genphy_suspend, 4781a5465f5SPatrice Vilchez .resume = genphy_resume, 4797ab59dc1SDavid J. Choi .driver = { .owner = THIS_MODULE, }, 4807ab59dc1SDavid J. Choi }, { 48193272e07SJean-Christophe PLAGNIOL-VILLARD .phy_id = PHY_ID_KSZ8873MLL, 48293272e07SJean-Christophe PLAGNIOL-VILLARD .phy_id_mask = 0x00fffff0, 48393272e07SJean-Christophe PLAGNIOL-VILLARD .name = "Micrel KSZ8873MLL Switch", 48493272e07SJean-Christophe PLAGNIOL-VILLARD .features = (SUPPORTED_Pause | SUPPORTED_Asym_Pause), 48593272e07SJean-Christophe PLAGNIOL-VILLARD .flags = PHY_HAS_MAGICANEG, 48693272e07SJean-Christophe PLAGNIOL-VILLARD .config_init = kszphy_config_init, 48793272e07SJean-Christophe PLAGNIOL-VILLARD .config_aneg = ksz8873mll_config_aneg, 48893272e07SJean-Christophe PLAGNIOL-VILLARD .read_status = ksz8873mll_read_status, 4891a5465f5SPatrice Vilchez .suspend = genphy_suspend, 4901a5465f5SPatrice Vilchez .resume = genphy_resume, 49193272e07SJean-Christophe PLAGNIOL-VILLARD .driver = { .owner = THIS_MODULE, }, 4927ab59dc1SDavid J. Choi }, { 4937ab59dc1SDavid J. Choi .phy_id = PHY_ID_KSZ886X, 4947ab59dc1SDavid J. Choi .phy_id_mask = 0x00fffff0, 4957ab59dc1SDavid J. Choi .name = "Micrel KSZ886X Switch", 4967ab59dc1SDavid J. Choi .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause), 4977ab59dc1SDavid J. Choi .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, 4987ab59dc1SDavid J. Choi .config_init = kszphy_config_init, 4997ab59dc1SDavid J. Choi .config_aneg = genphy_config_aneg, 5007ab59dc1SDavid J. Choi .read_status = genphy_read_status, 5011a5465f5SPatrice Vilchez .suspend = genphy_suspend, 5021a5465f5SPatrice Vilchez .resume = genphy_resume, 5037ab59dc1SDavid J. Choi .driver = { .owner = THIS_MODULE, }, 504d5bf9071SChristian Hohnstaedt } }; 505d0507009SDavid J. Choi 506d0507009SDavid J. Choi static int __init ksphy_init(void) 507d0507009SDavid J. Choi { 508d5bf9071SChristian Hohnstaedt return phy_drivers_register(ksphy_driver, 509d5bf9071SChristian Hohnstaedt ARRAY_SIZE(ksphy_driver)); 510d0507009SDavid J. Choi } 511d0507009SDavid J. Choi 512d0507009SDavid J. Choi static void __exit ksphy_exit(void) 513d0507009SDavid J. Choi { 514d5bf9071SChristian Hohnstaedt phy_drivers_unregister(ksphy_driver, 515d5bf9071SChristian Hohnstaedt ARRAY_SIZE(ksphy_driver)); 516d0507009SDavid J. Choi } 517d0507009SDavid J. Choi 518d0507009SDavid J. Choi module_init(ksphy_init); 519d0507009SDavid J. Choi module_exit(ksphy_exit); 520d0507009SDavid J. Choi 521d0507009SDavid J. Choi MODULE_DESCRIPTION("Micrel PHY driver"); 522d0507009SDavid J. Choi MODULE_AUTHOR("David J. Choi"); 523d0507009SDavid J. Choi MODULE_LICENSE("GPL"); 52452a60ed2SDavid S. Miller 525cf93c945SUwe Kleine-König static struct mdio_device_id __maybe_unused micrel_tbl[] = { 52648d7d0adSJason Wang { PHY_ID_KSZ9021, 0x000ffffe }, 5277ab59dc1SDavid J. Choi { PHY_ID_KSZ9031, 0x00fffff0 }, 528510d573fSMarek Vasut { PHY_ID_KSZ8001, 0x00ffffff }, 52951f932c4SChoi, David { PHY_ID_KS8737, 0x00fffff0 }, 530212ea99aSMarek Vasut { PHY_ID_KSZ8021, 0x00ffffff }, 531b818d1a7SHector Palacios { PHY_ID_KSZ8031, 0x00ffffff }, 532510d573fSMarek Vasut { PHY_ID_KSZ8041, 0x00fffff0 }, 533510d573fSMarek Vasut { PHY_ID_KSZ8051, 0x00fffff0 }, 5347ab59dc1SDavid J. Choi { PHY_ID_KSZ8061, 0x00fffff0 }, 5357ab59dc1SDavid J. Choi { PHY_ID_KSZ8081, 0x00fffff0 }, 53693272e07SJean-Christophe PLAGNIOL-VILLARD { PHY_ID_KSZ8873MLL, 0x00fffff0 }, 5377ab59dc1SDavid J. Choi { PHY_ID_KSZ886X, 0x00fffff0 }, 53852a60ed2SDavid S. Miller { } 53952a60ed2SDavid S. Miller }; 54052a60ed2SDavid S. Miller 54152a60ed2SDavid S. Miller MODULE_DEVICE_TABLE(mdio, micrel_tbl); 542