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> 291fadee0cSSascha Hauer #include <linux/clk.h> 30d0507009SDavid J. Choi 31212ea99aSMarek Vasut /* Operation Mode Strap Override */ 32212ea99aSMarek Vasut #define MII_KSZPHY_OMSO 0x16 3300aee095SJohan Hovold #define KSZPHY_OMSO_B_CAST_OFF BIT(9) 3400aee095SJohan Hovold #define KSZPHY_OMSO_RMII_OVERRIDE BIT(1) 3500aee095SJohan Hovold #define KSZPHY_OMSO_MII_OVERRIDE BIT(0) 36212ea99aSMarek Vasut 3751f932c4SChoi, David /* general Interrupt control/status reg in vendor specific block. */ 3851f932c4SChoi, David #define MII_KSZPHY_INTCS 0x1B 3900aee095SJohan Hovold #define KSZPHY_INTCS_JABBER BIT(15) 4000aee095SJohan Hovold #define KSZPHY_INTCS_RECEIVE_ERR BIT(14) 4100aee095SJohan Hovold #define KSZPHY_INTCS_PAGE_RECEIVE BIT(13) 4200aee095SJohan Hovold #define KSZPHY_INTCS_PARELLEL BIT(12) 4300aee095SJohan Hovold #define KSZPHY_INTCS_LINK_PARTNER_ACK BIT(11) 4400aee095SJohan Hovold #define KSZPHY_INTCS_LINK_DOWN BIT(10) 4500aee095SJohan Hovold #define KSZPHY_INTCS_REMOTE_FAULT BIT(9) 4600aee095SJohan Hovold #define KSZPHY_INTCS_LINK_UP BIT(8) 4751f932c4SChoi, David #define KSZPHY_INTCS_ALL (KSZPHY_INTCS_LINK_UP |\ 4851f932c4SChoi, David KSZPHY_INTCS_LINK_DOWN) 4951f932c4SChoi, David 505a16778eSJohan Hovold /* PHY Control 1 */ 515a16778eSJohan Hovold #define MII_KSZPHY_CTRL_1 0x1e 525a16778eSJohan Hovold 535a16778eSJohan Hovold /* PHY Control 2 / PHY Control (if no PHY Control 1) */ 545a16778eSJohan Hovold #define MII_KSZPHY_CTRL_2 0x1f 555a16778eSJohan Hovold #define MII_KSZPHY_CTRL MII_KSZPHY_CTRL_2 5651f932c4SChoi, David /* bitmap of PHY register to set interrupt mode */ 5700aee095SJohan Hovold #define KSZPHY_CTRL_INT_ACTIVE_HIGH BIT(9) 5800aee095SJohan Hovold #define KSZ9021_CTRL_INT_ACTIVE_HIGH BIT(14) 5900aee095SJohan Hovold #define KS8737_CTRL_INT_ACTIVE_HIGH BIT(14) 6000aee095SJohan Hovold #define KSZ8051_RMII_50MHZ_CLK BIT(7) 6151f932c4SChoi, David 62954c3967SSean Cross /* Write/read to/from extended registers */ 63954c3967SSean Cross #define MII_KSZPHY_EXTREG 0x0b 64954c3967SSean Cross #define KSZPHY_EXTREG_WRITE 0x8000 65954c3967SSean Cross 66954c3967SSean Cross #define MII_KSZPHY_EXTREG_WRITE 0x0c 67954c3967SSean Cross #define MII_KSZPHY_EXTREG_READ 0x0d 68954c3967SSean Cross 69954c3967SSean Cross /* Extended registers */ 70954c3967SSean Cross #define MII_KSZPHY_CLK_CONTROL_PAD_SKEW 0x104 71954c3967SSean Cross #define MII_KSZPHY_RX_DATA_PAD_SKEW 0x105 72954c3967SSean Cross #define MII_KSZPHY_TX_DATA_PAD_SKEW 0x106 73954c3967SSean Cross 74954c3967SSean Cross #define PS_TO_REG 200 75954c3967SSean Cross 76e6a423a8SJohan Hovold struct kszphy_type { 77e6a423a8SJohan Hovold u32 led_mode_reg; 78e6a423a8SJohan Hovold }; 79e6a423a8SJohan Hovold 80e6a423a8SJohan Hovold struct kszphy_priv { 81e6a423a8SJohan Hovold const struct kszphy_type *type; 82*e7a792e9SJohan Hovold int led_mode; 83e6a423a8SJohan Hovold }; 84e6a423a8SJohan Hovold 85e6a423a8SJohan Hovold static const struct kszphy_type ksz8021_type = { 86e6a423a8SJohan Hovold .led_mode_reg = MII_KSZPHY_CTRL_2, 87e6a423a8SJohan Hovold }; 88e6a423a8SJohan Hovold 89e6a423a8SJohan Hovold static const struct kszphy_type ksz8041_type = { 90e6a423a8SJohan Hovold .led_mode_reg = MII_KSZPHY_CTRL_1, 91e6a423a8SJohan Hovold }; 92e6a423a8SJohan Hovold 93e6a423a8SJohan Hovold static const struct kszphy_type ksz8051_type = { 94e6a423a8SJohan Hovold .led_mode_reg = MII_KSZPHY_CTRL_2, 95e6a423a8SJohan Hovold }; 96e6a423a8SJohan Hovold 97e6a423a8SJohan Hovold static const struct kszphy_type ksz8081_type = { 98e6a423a8SJohan Hovold .led_mode_reg = MII_KSZPHY_CTRL_2, 99e6a423a8SJohan Hovold }; 100e6a423a8SJohan Hovold 101b6bb4dfcSHector Palacios static int ksz_config_flags(struct phy_device *phydev) 102b6bb4dfcSHector Palacios { 103b6bb4dfcSHector Palacios int regval; 104b6bb4dfcSHector Palacios 1051fadee0cSSascha Hauer if (phydev->dev_flags & (MICREL_PHY_50MHZ_CLK | MICREL_PHY_25MHZ_CLK)) { 106b6bb4dfcSHector Palacios regval = phy_read(phydev, MII_KSZPHY_CTRL); 1071fadee0cSSascha Hauer if (phydev->dev_flags & MICREL_PHY_50MHZ_CLK) 108b6bb4dfcSHector Palacios regval |= KSZ8051_RMII_50MHZ_CLK; 1091fadee0cSSascha Hauer else 1101fadee0cSSascha Hauer regval &= ~KSZ8051_RMII_50MHZ_CLK; 111b6bb4dfcSHector Palacios return phy_write(phydev, MII_KSZPHY_CTRL, regval); 112b6bb4dfcSHector Palacios } 113b6bb4dfcSHector Palacios return 0; 114b6bb4dfcSHector Palacios } 115b6bb4dfcSHector Palacios 116954c3967SSean Cross static int kszphy_extended_write(struct phy_device *phydev, 117954c3967SSean Cross u32 regnum, u16 val) 118954c3967SSean Cross { 119954c3967SSean Cross phy_write(phydev, MII_KSZPHY_EXTREG, KSZPHY_EXTREG_WRITE | regnum); 120954c3967SSean Cross return phy_write(phydev, MII_KSZPHY_EXTREG_WRITE, val); 121954c3967SSean Cross } 122954c3967SSean Cross 123954c3967SSean Cross static int kszphy_extended_read(struct phy_device *phydev, 124954c3967SSean Cross u32 regnum) 125954c3967SSean Cross { 126954c3967SSean Cross phy_write(phydev, MII_KSZPHY_EXTREG, regnum); 127954c3967SSean Cross return phy_read(phydev, MII_KSZPHY_EXTREG_READ); 128954c3967SSean Cross } 129954c3967SSean Cross 13051f932c4SChoi, David static int kszphy_ack_interrupt(struct phy_device *phydev) 13151f932c4SChoi, David { 13251f932c4SChoi, David /* bit[7..0] int status, which is a read and clear register. */ 13351f932c4SChoi, David int rc; 13451f932c4SChoi, David 13551f932c4SChoi, David rc = phy_read(phydev, MII_KSZPHY_INTCS); 13651f932c4SChoi, David 13751f932c4SChoi, David return (rc < 0) ? rc : 0; 13851f932c4SChoi, David } 13951f932c4SChoi, David 14051f932c4SChoi, David static int kszphy_set_interrupt(struct phy_device *phydev) 14151f932c4SChoi, David { 14251f932c4SChoi, David int temp; 14351f932c4SChoi, David temp = (PHY_INTERRUPT_ENABLED == phydev->interrupts) ? 14451f932c4SChoi, David KSZPHY_INTCS_ALL : 0; 14551f932c4SChoi, David return phy_write(phydev, MII_KSZPHY_INTCS, temp); 14651f932c4SChoi, David } 14751f932c4SChoi, David 14851f932c4SChoi, David static int kszphy_config_intr(struct phy_device *phydev) 14951f932c4SChoi, David { 15051f932c4SChoi, David int temp, rc; 15151f932c4SChoi, David 15251f932c4SChoi, David /* set the interrupt pin active low */ 15351f932c4SChoi, David temp = phy_read(phydev, MII_KSZPHY_CTRL); 1545bb8fc0dSJohan Hovold if (temp < 0) 1555bb8fc0dSJohan Hovold return temp; 15651f932c4SChoi, David temp &= ~KSZPHY_CTRL_INT_ACTIVE_HIGH; 15751f932c4SChoi, David phy_write(phydev, MII_KSZPHY_CTRL, temp); 15851f932c4SChoi, David rc = kszphy_set_interrupt(phydev); 15951f932c4SChoi, David return rc < 0 ? rc : 0; 16051f932c4SChoi, David } 16151f932c4SChoi, David 16251f932c4SChoi, David static int ksz9021_config_intr(struct phy_device *phydev) 16351f932c4SChoi, David { 16451f932c4SChoi, David int temp, rc; 16551f932c4SChoi, David 16651f932c4SChoi, David /* set the interrupt pin active low */ 16751f932c4SChoi, David temp = phy_read(phydev, MII_KSZPHY_CTRL); 1685bb8fc0dSJohan Hovold if (temp < 0) 1695bb8fc0dSJohan Hovold return temp; 17051f932c4SChoi, David temp &= ~KSZ9021_CTRL_INT_ACTIVE_HIGH; 17151f932c4SChoi, David phy_write(phydev, MII_KSZPHY_CTRL, temp); 17251f932c4SChoi, David rc = kszphy_set_interrupt(phydev); 17351f932c4SChoi, David return rc < 0 ? rc : 0; 17451f932c4SChoi, David } 17551f932c4SChoi, David 17651f932c4SChoi, David static int ks8737_config_intr(struct phy_device *phydev) 17751f932c4SChoi, David { 17851f932c4SChoi, David int temp, rc; 17951f932c4SChoi, David 18051f932c4SChoi, David /* set the interrupt pin active low */ 18151f932c4SChoi, David temp = phy_read(phydev, MII_KSZPHY_CTRL); 1825bb8fc0dSJohan Hovold if (temp < 0) 1835bb8fc0dSJohan Hovold return temp; 18451f932c4SChoi, David temp &= ~KS8737_CTRL_INT_ACTIVE_HIGH; 18551f932c4SChoi, David phy_write(phydev, MII_KSZPHY_CTRL, temp); 18651f932c4SChoi, David rc = kszphy_set_interrupt(phydev); 18751f932c4SChoi, David return rc < 0 ? rc : 0; 18851f932c4SChoi, David } 189d0507009SDavid J. Choi 190*e7a792e9SJohan Hovold static int kszphy_setup_led(struct phy_device *phydev, u32 reg, int val) 19120d8435aSBen Dooks { 1925a16778eSJohan Hovold int rc, temp, shift; 1938620546cSJohan Hovold 1945a16778eSJohan Hovold switch (reg) { 1955a16778eSJohan Hovold case MII_KSZPHY_CTRL_1: 1965a16778eSJohan Hovold shift = 14; 1975a16778eSJohan Hovold break; 1985a16778eSJohan Hovold case MII_KSZPHY_CTRL_2: 1995a16778eSJohan Hovold shift = 4; 2005a16778eSJohan Hovold break; 2015a16778eSJohan Hovold default: 2025a16778eSJohan Hovold return -EINVAL; 2035a16778eSJohan Hovold } 2045a16778eSJohan Hovold 20520d8435aSBen Dooks temp = phy_read(phydev, reg); 206b7035860SJohan Hovold if (temp < 0) { 207b7035860SJohan Hovold rc = temp; 208b7035860SJohan Hovold goto out; 209b7035860SJohan Hovold } 21020d8435aSBen Dooks 21128bdc499SSergei Shtylyov temp &= ~(3 << shift); 21220d8435aSBen Dooks temp |= val << shift; 21320d8435aSBen Dooks rc = phy_write(phydev, reg, temp); 214b7035860SJohan Hovold out: 215b7035860SJohan Hovold if (rc < 0) 216b7035860SJohan Hovold dev_err(&phydev->dev, "failed to set led mode\n"); 21720d8435aSBen Dooks 218b7035860SJohan Hovold return rc; 21920d8435aSBen Dooks } 22020d8435aSBen Dooks 221bde15129SJohan Hovold /* Disable PHY address 0 as the broadcast address, so that it can be used as a 222bde15129SJohan Hovold * unique (non-broadcast) address on a shared bus. 223bde15129SJohan Hovold */ 224bde15129SJohan Hovold static int kszphy_broadcast_disable(struct phy_device *phydev) 225bde15129SJohan Hovold { 226bde15129SJohan Hovold int ret; 227bde15129SJohan Hovold 228bde15129SJohan Hovold ret = phy_read(phydev, MII_KSZPHY_OMSO); 229bde15129SJohan Hovold if (ret < 0) 230bde15129SJohan Hovold goto out; 231bde15129SJohan Hovold 232bde15129SJohan Hovold ret = phy_write(phydev, MII_KSZPHY_OMSO, ret | KSZPHY_OMSO_B_CAST_OFF); 233bde15129SJohan Hovold out: 234bde15129SJohan Hovold if (ret) 235bde15129SJohan Hovold dev_err(&phydev->dev, "failed to disable broadcast address\n"); 236bde15129SJohan Hovold 237bde15129SJohan Hovold return ret; 238bde15129SJohan Hovold } 239bde15129SJohan Hovold 240d0507009SDavid J. Choi static int kszphy_config_init(struct phy_device *phydev) 241d0507009SDavid J. Choi { 242e6a423a8SJohan Hovold struct kszphy_priv *priv = phydev->priv; 243e6a423a8SJohan Hovold const struct kszphy_type *type; 244d0507009SDavid J. Choi 245e6a423a8SJohan Hovold if (!priv) 246e6a423a8SJohan Hovold return 0; 247e6a423a8SJohan Hovold 248e6a423a8SJohan Hovold type = priv->type; 249e6a423a8SJohan Hovold 250*e7a792e9SJohan Hovold if (priv->led_mode >= 0) 251*e7a792e9SJohan Hovold kszphy_setup_led(phydev, type->led_mode_reg, priv->led_mode); 252e6a423a8SJohan Hovold 253e6a423a8SJohan Hovold return 0; 25420d8435aSBen Dooks } 25520d8435aSBen Dooks 256212ea99aSMarek Vasut static int ksz8021_config_init(struct phy_device *phydev) 257212ea99aSMarek Vasut { 25820d8435aSBen Dooks int rc; 25920d8435aSBen Dooks 260e6a423a8SJohan Hovold kszphy_config_init(phydev); 26120d8435aSBen Dooks 262b6bb4dfcSHector Palacios rc = ksz_config_flags(phydev); 263b838b4acSBruno Thomsen if (rc < 0) 264b838b4acSBruno Thomsen return rc; 265bde15129SJohan Hovold 266bde15129SJohan Hovold rc = kszphy_broadcast_disable(phydev); 267bde15129SJohan Hovold 268b6bb4dfcSHector Palacios return rc < 0 ? rc : 0; 269212ea99aSMarek Vasut } 270212ea99aSMarek Vasut 271d606ef3fSBaruch Siach static int ks8051_config_init(struct phy_device *phydev) 272d606ef3fSBaruch Siach { 273b6bb4dfcSHector Palacios int rc; 274d606ef3fSBaruch Siach 275e6a423a8SJohan Hovold kszphy_config_init(phydev); 27620d8435aSBen Dooks 277b6bb4dfcSHector Palacios rc = ksz_config_flags(phydev); 278b6bb4dfcSHector Palacios return rc < 0 ? rc : 0; 279d606ef3fSBaruch Siach } 280d606ef3fSBaruch Siach 28157a38effSJohan Hovold static int ksz8081_config_init(struct phy_device *phydev) 28257a38effSJohan Hovold { 28357a38effSJohan Hovold kszphy_broadcast_disable(phydev); 28457a38effSJohan Hovold 285e6a423a8SJohan Hovold return kszphy_config_init(phydev); 28657a38effSJohan Hovold } 28757a38effSJohan Hovold 288954c3967SSean Cross static int ksz9021_load_values_from_of(struct phy_device *phydev, 289954c3967SSean Cross struct device_node *of_node, u16 reg, 290954c3967SSean Cross char *field1, char *field2, 291954c3967SSean Cross char *field3, char *field4) 292954c3967SSean Cross { 293954c3967SSean Cross int val1 = -1; 294954c3967SSean Cross int val2 = -2; 295954c3967SSean Cross int val3 = -3; 296954c3967SSean Cross int val4 = -4; 297954c3967SSean Cross int newval; 298954c3967SSean Cross int matches = 0; 299954c3967SSean Cross 300954c3967SSean Cross if (!of_property_read_u32(of_node, field1, &val1)) 301954c3967SSean Cross matches++; 302954c3967SSean Cross 303954c3967SSean Cross if (!of_property_read_u32(of_node, field2, &val2)) 304954c3967SSean Cross matches++; 305954c3967SSean Cross 306954c3967SSean Cross if (!of_property_read_u32(of_node, field3, &val3)) 307954c3967SSean Cross matches++; 308954c3967SSean Cross 309954c3967SSean Cross if (!of_property_read_u32(of_node, field4, &val4)) 310954c3967SSean Cross matches++; 311954c3967SSean Cross 312954c3967SSean Cross if (!matches) 313954c3967SSean Cross return 0; 314954c3967SSean Cross 315954c3967SSean Cross if (matches < 4) 316954c3967SSean Cross newval = kszphy_extended_read(phydev, reg); 317954c3967SSean Cross else 318954c3967SSean Cross newval = 0; 319954c3967SSean Cross 320954c3967SSean Cross if (val1 != -1) 321954c3967SSean Cross newval = ((newval & 0xfff0) | ((val1 / PS_TO_REG) & 0xf) << 0); 322954c3967SSean Cross 3236a119745SHubert Chaumette if (val2 != -2) 324954c3967SSean Cross newval = ((newval & 0xff0f) | ((val2 / PS_TO_REG) & 0xf) << 4); 325954c3967SSean Cross 3266a119745SHubert Chaumette if (val3 != -3) 327954c3967SSean Cross newval = ((newval & 0xf0ff) | ((val3 / PS_TO_REG) & 0xf) << 8); 328954c3967SSean Cross 3296a119745SHubert Chaumette if (val4 != -4) 330954c3967SSean Cross newval = ((newval & 0x0fff) | ((val4 / PS_TO_REG) & 0xf) << 12); 331954c3967SSean Cross 332954c3967SSean Cross return kszphy_extended_write(phydev, reg, newval); 333954c3967SSean Cross } 334954c3967SSean Cross 335954c3967SSean Cross static int ksz9021_config_init(struct phy_device *phydev) 336954c3967SSean Cross { 337954c3967SSean Cross struct device *dev = &phydev->dev; 338954c3967SSean Cross struct device_node *of_node = dev->of_node; 339954c3967SSean Cross 340954c3967SSean Cross if (!of_node && dev->parent->of_node) 341954c3967SSean Cross of_node = dev->parent->of_node; 342954c3967SSean Cross 343954c3967SSean Cross if (of_node) { 344954c3967SSean Cross ksz9021_load_values_from_of(phydev, of_node, 345954c3967SSean Cross MII_KSZPHY_CLK_CONTROL_PAD_SKEW, 346954c3967SSean Cross "txen-skew-ps", "txc-skew-ps", 347954c3967SSean Cross "rxdv-skew-ps", "rxc-skew-ps"); 348954c3967SSean Cross ksz9021_load_values_from_of(phydev, of_node, 349954c3967SSean Cross MII_KSZPHY_RX_DATA_PAD_SKEW, 350954c3967SSean Cross "rxd0-skew-ps", "rxd1-skew-ps", 351954c3967SSean Cross "rxd2-skew-ps", "rxd3-skew-ps"); 352954c3967SSean Cross ksz9021_load_values_from_of(phydev, of_node, 353954c3967SSean Cross MII_KSZPHY_TX_DATA_PAD_SKEW, 354954c3967SSean Cross "txd0-skew-ps", "txd1-skew-ps", 355954c3967SSean Cross "txd2-skew-ps", "txd3-skew-ps"); 356954c3967SSean Cross } 357954c3967SSean Cross return 0; 358954c3967SSean Cross } 359954c3967SSean Cross 3606e4b8273SHubert Chaumette #define MII_KSZ9031RN_MMD_CTRL_REG 0x0d 3616e4b8273SHubert Chaumette #define MII_KSZ9031RN_MMD_REGDATA_REG 0x0e 3626e4b8273SHubert Chaumette #define OP_DATA 1 3636e4b8273SHubert Chaumette #define KSZ9031_PS_TO_REG 60 3646e4b8273SHubert Chaumette 3656e4b8273SHubert Chaumette /* Extended registers */ 3666e4b8273SHubert Chaumette #define MII_KSZ9031RN_CONTROL_PAD_SKEW 4 3676e4b8273SHubert Chaumette #define MII_KSZ9031RN_RX_DATA_PAD_SKEW 5 3686e4b8273SHubert Chaumette #define MII_KSZ9031RN_TX_DATA_PAD_SKEW 6 3696e4b8273SHubert Chaumette #define MII_KSZ9031RN_CLK_PAD_SKEW 8 3706e4b8273SHubert Chaumette 3716e4b8273SHubert Chaumette static int ksz9031_extended_write(struct phy_device *phydev, 3726e4b8273SHubert Chaumette u8 mode, u32 dev_addr, u32 regnum, u16 val) 3736e4b8273SHubert Chaumette { 3746e4b8273SHubert Chaumette phy_write(phydev, MII_KSZ9031RN_MMD_CTRL_REG, dev_addr); 3756e4b8273SHubert Chaumette phy_write(phydev, MII_KSZ9031RN_MMD_REGDATA_REG, regnum); 3766e4b8273SHubert Chaumette phy_write(phydev, MII_KSZ9031RN_MMD_CTRL_REG, (mode << 14) | dev_addr); 3776e4b8273SHubert Chaumette return phy_write(phydev, MII_KSZ9031RN_MMD_REGDATA_REG, val); 3786e4b8273SHubert Chaumette } 3796e4b8273SHubert Chaumette 3806e4b8273SHubert Chaumette static int ksz9031_extended_read(struct phy_device *phydev, 3816e4b8273SHubert Chaumette u8 mode, u32 dev_addr, u32 regnum) 3826e4b8273SHubert Chaumette { 3836e4b8273SHubert Chaumette phy_write(phydev, MII_KSZ9031RN_MMD_CTRL_REG, dev_addr); 3846e4b8273SHubert Chaumette phy_write(phydev, MII_KSZ9031RN_MMD_REGDATA_REG, regnum); 3856e4b8273SHubert Chaumette phy_write(phydev, MII_KSZ9031RN_MMD_CTRL_REG, (mode << 14) | dev_addr); 3866e4b8273SHubert Chaumette return phy_read(phydev, MII_KSZ9031RN_MMD_REGDATA_REG); 3876e4b8273SHubert Chaumette } 3886e4b8273SHubert Chaumette 3896e4b8273SHubert Chaumette static int ksz9031_of_load_skew_values(struct phy_device *phydev, 3906e4b8273SHubert Chaumette struct device_node *of_node, 3916e4b8273SHubert Chaumette u16 reg, size_t field_sz, 3926e4b8273SHubert Chaumette char *field[], u8 numfields) 3936e4b8273SHubert Chaumette { 3946e4b8273SHubert Chaumette int val[4] = {-1, -2, -3, -4}; 3956e4b8273SHubert Chaumette int matches = 0; 3966e4b8273SHubert Chaumette u16 mask; 3976e4b8273SHubert Chaumette u16 maxval; 3986e4b8273SHubert Chaumette u16 newval; 3996e4b8273SHubert Chaumette int i; 4006e4b8273SHubert Chaumette 4016e4b8273SHubert Chaumette for (i = 0; i < numfields; i++) 4026e4b8273SHubert Chaumette if (!of_property_read_u32(of_node, field[i], val + i)) 4036e4b8273SHubert Chaumette matches++; 4046e4b8273SHubert Chaumette 4056e4b8273SHubert Chaumette if (!matches) 4066e4b8273SHubert Chaumette return 0; 4076e4b8273SHubert Chaumette 4086e4b8273SHubert Chaumette if (matches < numfields) 4096e4b8273SHubert Chaumette newval = ksz9031_extended_read(phydev, OP_DATA, 2, reg); 4106e4b8273SHubert Chaumette else 4116e4b8273SHubert Chaumette newval = 0; 4126e4b8273SHubert Chaumette 4136e4b8273SHubert Chaumette maxval = (field_sz == 4) ? 0xf : 0x1f; 4146e4b8273SHubert Chaumette for (i = 0; i < numfields; i++) 4156e4b8273SHubert Chaumette if (val[i] != -(i + 1)) { 4166e4b8273SHubert Chaumette mask = 0xffff; 4176e4b8273SHubert Chaumette mask ^= maxval << (field_sz * i); 4186e4b8273SHubert Chaumette newval = (newval & mask) | 4196e4b8273SHubert Chaumette (((val[i] / KSZ9031_PS_TO_REG) & maxval) 4206e4b8273SHubert Chaumette << (field_sz * i)); 4216e4b8273SHubert Chaumette } 4226e4b8273SHubert Chaumette 4236e4b8273SHubert Chaumette return ksz9031_extended_write(phydev, OP_DATA, 2, reg, newval); 4246e4b8273SHubert Chaumette } 4256e4b8273SHubert Chaumette 4266e4b8273SHubert Chaumette static int ksz9031_config_init(struct phy_device *phydev) 4276e4b8273SHubert Chaumette { 4286e4b8273SHubert Chaumette struct device *dev = &phydev->dev; 4296e4b8273SHubert Chaumette struct device_node *of_node = dev->of_node; 4306e4b8273SHubert Chaumette char *clk_skews[2] = {"rxc-skew-ps", "txc-skew-ps"}; 4316e4b8273SHubert Chaumette char *rx_data_skews[4] = { 4326e4b8273SHubert Chaumette "rxd0-skew-ps", "rxd1-skew-ps", 4336e4b8273SHubert Chaumette "rxd2-skew-ps", "rxd3-skew-ps" 4346e4b8273SHubert Chaumette }; 4356e4b8273SHubert Chaumette char *tx_data_skews[4] = { 4366e4b8273SHubert Chaumette "txd0-skew-ps", "txd1-skew-ps", 4376e4b8273SHubert Chaumette "txd2-skew-ps", "txd3-skew-ps" 4386e4b8273SHubert Chaumette }; 4396e4b8273SHubert Chaumette char *control_skews[2] = {"txen-skew-ps", "rxdv-skew-ps"}; 4406e4b8273SHubert Chaumette 4416e4b8273SHubert Chaumette if (!of_node && dev->parent->of_node) 4426e4b8273SHubert Chaumette of_node = dev->parent->of_node; 4436e4b8273SHubert Chaumette 4446e4b8273SHubert Chaumette if (of_node) { 4456e4b8273SHubert Chaumette ksz9031_of_load_skew_values(phydev, of_node, 4466e4b8273SHubert Chaumette MII_KSZ9031RN_CLK_PAD_SKEW, 5, 4476e4b8273SHubert Chaumette clk_skews, 2); 4486e4b8273SHubert Chaumette 4496e4b8273SHubert Chaumette ksz9031_of_load_skew_values(phydev, of_node, 4506e4b8273SHubert Chaumette MII_KSZ9031RN_CONTROL_PAD_SKEW, 4, 4516e4b8273SHubert Chaumette control_skews, 2); 4526e4b8273SHubert Chaumette 4536e4b8273SHubert Chaumette ksz9031_of_load_skew_values(phydev, of_node, 4546e4b8273SHubert Chaumette MII_KSZ9031RN_RX_DATA_PAD_SKEW, 4, 4556e4b8273SHubert Chaumette rx_data_skews, 4); 4566e4b8273SHubert Chaumette 4576e4b8273SHubert Chaumette ksz9031_of_load_skew_values(phydev, of_node, 4586e4b8273SHubert Chaumette MII_KSZ9031RN_TX_DATA_PAD_SKEW, 4, 4596e4b8273SHubert Chaumette tx_data_skews, 4); 4606e4b8273SHubert Chaumette } 4616e4b8273SHubert Chaumette return 0; 4626e4b8273SHubert Chaumette } 4636e4b8273SHubert Chaumette 46493272e07SJean-Christophe PLAGNIOL-VILLARD #define KSZ8873MLL_GLOBAL_CONTROL_4 0x06 46500aee095SJohan Hovold #define KSZ8873MLL_GLOBAL_CONTROL_4_DUPLEX BIT(6) 46600aee095SJohan Hovold #define KSZ8873MLL_GLOBAL_CONTROL_4_SPEED BIT(4) 46732d73b14SJingoo Han static int ksz8873mll_read_status(struct phy_device *phydev) 46893272e07SJean-Christophe PLAGNIOL-VILLARD { 46993272e07SJean-Christophe PLAGNIOL-VILLARD int regval; 47093272e07SJean-Christophe PLAGNIOL-VILLARD 47193272e07SJean-Christophe PLAGNIOL-VILLARD /* dummy read */ 47293272e07SJean-Christophe PLAGNIOL-VILLARD regval = phy_read(phydev, KSZ8873MLL_GLOBAL_CONTROL_4); 47393272e07SJean-Christophe PLAGNIOL-VILLARD 47493272e07SJean-Christophe PLAGNIOL-VILLARD regval = phy_read(phydev, KSZ8873MLL_GLOBAL_CONTROL_4); 47593272e07SJean-Christophe PLAGNIOL-VILLARD 47693272e07SJean-Christophe PLAGNIOL-VILLARD if (regval & KSZ8873MLL_GLOBAL_CONTROL_4_DUPLEX) 47793272e07SJean-Christophe PLAGNIOL-VILLARD phydev->duplex = DUPLEX_HALF; 47893272e07SJean-Christophe PLAGNIOL-VILLARD else 47993272e07SJean-Christophe PLAGNIOL-VILLARD phydev->duplex = DUPLEX_FULL; 48093272e07SJean-Christophe PLAGNIOL-VILLARD 48193272e07SJean-Christophe PLAGNIOL-VILLARD if (regval & KSZ8873MLL_GLOBAL_CONTROL_4_SPEED) 48293272e07SJean-Christophe PLAGNIOL-VILLARD phydev->speed = SPEED_10; 48393272e07SJean-Christophe PLAGNIOL-VILLARD else 48493272e07SJean-Christophe PLAGNIOL-VILLARD phydev->speed = SPEED_100; 48593272e07SJean-Christophe PLAGNIOL-VILLARD 48693272e07SJean-Christophe PLAGNIOL-VILLARD phydev->link = 1; 48793272e07SJean-Christophe PLAGNIOL-VILLARD phydev->pause = phydev->asym_pause = 0; 48893272e07SJean-Christophe PLAGNIOL-VILLARD 48993272e07SJean-Christophe PLAGNIOL-VILLARD return 0; 49093272e07SJean-Christophe PLAGNIOL-VILLARD } 49193272e07SJean-Christophe PLAGNIOL-VILLARD 49293272e07SJean-Christophe PLAGNIOL-VILLARD static int ksz8873mll_config_aneg(struct phy_device *phydev) 49393272e07SJean-Christophe PLAGNIOL-VILLARD { 49493272e07SJean-Christophe PLAGNIOL-VILLARD return 0; 49593272e07SJean-Christophe PLAGNIOL-VILLARD } 49693272e07SJean-Christophe PLAGNIOL-VILLARD 49719936942SVince Bridgers /* This routine returns -1 as an indication to the caller that the 49819936942SVince Bridgers * Micrel ksz9021 10/100/1000 PHY does not support standard IEEE 49919936942SVince Bridgers * MMD extended PHY registers. 50019936942SVince Bridgers */ 50119936942SVince Bridgers static int 50219936942SVince Bridgers ksz9021_rd_mmd_phyreg(struct phy_device *phydev, int ptrad, int devnum, 50319936942SVince Bridgers int regnum) 50419936942SVince Bridgers { 50519936942SVince Bridgers return -1; 50619936942SVince Bridgers } 50719936942SVince Bridgers 50819936942SVince Bridgers /* This routine does nothing since the Micrel ksz9021 does not support 50919936942SVince Bridgers * standard IEEE MMD extended PHY registers. 51019936942SVince Bridgers */ 51119936942SVince Bridgers static void 51219936942SVince Bridgers ksz9021_wr_mmd_phyreg(struct phy_device *phydev, int ptrad, int devnum, 51319936942SVince Bridgers int regnum, u32 val) 51419936942SVince Bridgers { 51519936942SVince Bridgers } 51619936942SVince Bridgers 517e6a423a8SJohan Hovold static int kszphy_probe(struct phy_device *phydev) 518e6a423a8SJohan Hovold { 519e6a423a8SJohan Hovold const struct kszphy_type *type = phydev->drv->driver_data; 520*e7a792e9SJohan Hovold struct device_node *np = phydev->dev.of_node; 521e6a423a8SJohan Hovold struct kszphy_priv *priv; 522*e7a792e9SJohan Hovold int ret; 523e6a423a8SJohan Hovold 524e6a423a8SJohan Hovold priv = devm_kzalloc(&phydev->dev, sizeof(*priv), GFP_KERNEL); 525e6a423a8SJohan Hovold if (!priv) 526e6a423a8SJohan Hovold return -ENOMEM; 527e6a423a8SJohan Hovold 528e6a423a8SJohan Hovold phydev->priv = priv; 529e6a423a8SJohan Hovold 530e6a423a8SJohan Hovold priv->type = type; 531e6a423a8SJohan Hovold 532*e7a792e9SJohan Hovold if (type->led_mode_reg) { 533*e7a792e9SJohan Hovold ret = of_property_read_u32(np, "micrel,led-mode", 534*e7a792e9SJohan Hovold &priv->led_mode); 535*e7a792e9SJohan Hovold if (ret) 536*e7a792e9SJohan Hovold priv->led_mode = -1; 537*e7a792e9SJohan Hovold 538*e7a792e9SJohan Hovold if (priv->led_mode > 3) { 539*e7a792e9SJohan Hovold dev_err(&phydev->dev, "invalid led mode: 0x%02x\n", 540*e7a792e9SJohan Hovold priv->led_mode); 541*e7a792e9SJohan Hovold priv->led_mode = -1; 542*e7a792e9SJohan Hovold } 543*e7a792e9SJohan Hovold } else { 544*e7a792e9SJohan Hovold priv->led_mode = -1; 545*e7a792e9SJohan Hovold } 546*e7a792e9SJohan Hovold 547e6a423a8SJohan Hovold return 0; 548e6a423a8SJohan Hovold } 549e6a423a8SJohan Hovold 5501fadee0cSSascha Hauer static int ksz8021_probe(struct phy_device *phydev) 5511fadee0cSSascha Hauer { 5521fadee0cSSascha Hauer struct clk *clk; 5531fadee0cSSascha Hauer 5541fadee0cSSascha Hauer clk = devm_clk_get(&phydev->dev, "rmii-ref"); 5551fadee0cSSascha Hauer if (!IS_ERR(clk)) { 5561fadee0cSSascha Hauer unsigned long rate = clk_get_rate(clk); 5571fadee0cSSascha Hauer 5581fadee0cSSascha Hauer if (rate > 24500000 && rate < 25500000) { 5591fadee0cSSascha Hauer phydev->dev_flags |= MICREL_PHY_25MHZ_CLK; 5601fadee0cSSascha Hauer } else if (rate > 49500000 && rate < 50500000) { 5611fadee0cSSascha Hauer phydev->dev_flags |= MICREL_PHY_50MHZ_CLK; 5621fadee0cSSascha Hauer } else { 5631fadee0cSSascha Hauer dev_err(&phydev->dev, "Clock rate out of range: %ld\n", rate); 5641fadee0cSSascha Hauer return -EINVAL; 5651fadee0cSSascha Hauer } 5661fadee0cSSascha Hauer } 5671fadee0cSSascha Hauer 568e6a423a8SJohan Hovold return kszphy_probe(phydev); 5691fadee0cSSascha Hauer } 5701fadee0cSSascha Hauer 571d5bf9071SChristian Hohnstaedt static struct phy_driver ksphy_driver[] = { 572d5bf9071SChristian Hohnstaedt { 57351f932c4SChoi, David .phy_id = PHY_ID_KS8737, 574d0507009SDavid J. Choi .phy_id_mask = 0x00fffff0, 57551f932c4SChoi, David .name = "Micrel KS8737", 57651f932c4SChoi, David .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause), 57751f932c4SChoi, David .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, 578d0507009SDavid J. Choi .config_init = kszphy_config_init, 579d0507009SDavid J. Choi .config_aneg = genphy_config_aneg, 580d0507009SDavid J. Choi .read_status = genphy_read_status, 58151f932c4SChoi, David .ack_interrupt = kszphy_ack_interrupt, 58251f932c4SChoi, David .config_intr = ks8737_config_intr, 5831a5465f5SPatrice Vilchez .suspend = genphy_suspend, 5841a5465f5SPatrice Vilchez .resume = genphy_resume, 585d0507009SDavid J. Choi .driver = { .owner = THIS_MODULE,}, 586d5bf9071SChristian Hohnstaedt }, { 587212ea99aSMarek Vasut .phy_id = PHY_ID_KSZ8021, 588212ea99aSMarek Vasut .phy_id_mask = 0x00ffffff, 5897ab59dc1SDavid J. Choi .name = "Micrel KSZ8021 or KSZ8031", 590212ea99aSMarek Vasut .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause | 591212ea99aSMarek Vasut SUPPORTED_Asym_Pause), 592212ea99aSMarek Vasut .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, 593e6a423a8SJohan Hovold .driver_data = &ksz8021_type, 5941fadee0cSSascha Hauer .probe = ksz8021_probe, 595212ea99aSMarek Vasut .config_init = ksz8021_config_init, 596212ea99aSMarek Vasut .config_aneg = genphy_config_aneg, 597212ea99aSMarek Vasut .read_status = genphy_read_status, 598212ea99aSMarek Vasut .ack_interrupt = kszphy_ack_interrupt, 599212ea99aSMarek Vasut .config_intr = kszphy_config_intr, 6001a5465f5SPatrice Vilchez .suspend = genphy_suspend, 6011a5465f5SPatrice Vilchez .resume = genphy_resume, 602212ea99aSMarek Vasut .driver = { .owner = THIS_MODULE,}, 603212ea99aSMarek Vasut }, { 604b818d1a7SHector Palacios .phy_id = PHY_ID_KSZ8031, 605b818d1a7SHector Palacios .phy_id_mask = 0x00ffffff, 606b818d1a7SHector Palacios .name = "Micrel KSZ8031", 607b818d1a7SHector Palacios .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause | 608b818d1a7SHector Palacios SUPPORTED_Asym_Pause), 609b818d1a7SHector Palacios .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, 610e6a423a8SJohan Hovold .driver_data = &ksz8021_type, 6111fadee0cSSascha Hauer .probe = ksz8021_probe, 612b818d1a7SHector Palacios .config_init = ksz8021_config_init, 613b818d1a7SHector Palacios .config_aneg = genphy_config_aneg, 614b818d1a7SHector Palacios .read_status = genphy_read_status, 615b818d1a7SHector Palacios .ack_interrupt = kszphy_ack_interrupt, 616b818d1a7SHector Palacios .config_intr = kszphy_config_intr, 6171a5465f5SPatrice Vilchez .suspend = genphy_suspend, 6181a5465f5SPatrice Vilchez .resume = genphy_resume, 619b818d1a7SHector Palacios .driver = { .owner = THIS_MODULE,}, 620b818d1a7SHector Palacios }, { 621510d573fSMarek Vasut .phy_id = PHY_ID_KSZ8041, 622d0507009SDavid J. Choi .phy_id_mask = 0x00fffff0, 623510d573fSMarek Vasut .name = "Micrel KSZ8041", 62451f932c4SChoi, David .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause 62551f932c4SChoi, David | SUPPORTED_Asym_Pause), 62651f932c4SChoi, David .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, 627e6a423a8SJohan Hovold .driver_data = &ksz8041_type, 628e6a423a8SJohan Hovold .probe = kszphy_probe, 629e6a423a8SJohan Hovold .config_init = kszphy_config_init, 630d0507009SDavid J. Choi .config_aneg = genphy_config_aneg, 631d0507009SDavid J. Choi .read_status = genphy_read_status, 63251f932c4SChoi, David .ack_interrupt = kszphy_ack_interrupt, 63351f932c4SChoi, David .config_intr = kszphy_config_intr, 6341a5465f5SPatrice Vilchez .suspend = genphy_suspend, 6351a5465f5SPatrice Vilchez .resume = genphy_resume, 63651f932c4SChoi, David .driver = { .owner = THIS_MODULE,}, 637d5bf9071SChristian Hohnstaedt }, { 6384bd7b512SSergei Shtylyov .phy_id = PHY_ID_KSZ8041RNLI, 6394bd7b512SSergei Shtylyov .phy_id_mask = 0x00fffff0, 6404bd7b512SSergei Shtylyov .name = "Micrel KSZ8041RNLI", 6414bd7b512SSergei Shtylyov .features = PHY_BASIC_FEATURES | 6424bd7b512SSergei Shtylyov SUPPORTED_Pause | SUPPORTED_Asym_Pause, 6434bd7b512SSergei Shtylyov .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, 644e6a423a8SJohan Hovold .driver_data = &ksz8041_type, 645e6a423a8SJohan Hovold .probe = kszphy_probe, 646e6a423a8SJohan Hovold .config_init = kszphy_config_init, 6474bd7b512SSergei Shtylyov .config_aneg = genphy_config_aneg, 6484bd7b512SSergei Shtylyov .read_status = genphy_read_status, 6494bd7b512SSergei Shtylyov .ack_interrupt = kszphy_ack_interrupt, 6504bd7b512SSergei Shtylyov .config_intr = kszphy_config_intr, 6514bd7b512SSergei Shtylyov .suspend = genphy_suspend, 6524bd7b512SSergei Shtylyov .resume = genphy_resume, 6534bd7b512SSergei Shtylyov .driver = { .owner = THIS_MODULE,}, 6544bd7b512SSergei Shtylyov }, { 655510d573fSMarek Vasut .phy_id = PHY_ID_KSZ8051, 65651f932c4SChoi, David .phy_id_mask = 0x00fffff0, 657510d573fSMarek Vasut .name = "Micrel KSZ8051", 65851f932c4SChoi, David .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause 65951f932c4SChoi, David | SUPPORTED_Asym_Pause), 66051f932c4SChoi, David .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, 661e6a423a8SJohan Hovold .driver_data = &ksz8051_type, 662e6a423a8SJohan Hovold .probe = kszphy_probe, 663d606ef3fSBaruch Siach .config_init = ks8051_config_init, 66451f932c4SChoi, David .config_aneg = genphy_config_aneg, 66551f932c4SChoi, David .read_status = genphy_read_status, 66651f932c4SChoi, David .ack_interrupt = kszphy_ack_interrupt, 66751f932c4SChoi, David .config_intr = kszphy_config_intr, 6681a5465f5SPatrice Vilchez .suspend = genphy_suspend, 6691a5465f5SPatrice Vilchez .resume = genphy_resume, 67051f932c4SChoi, David .driver = { .owner = THIS_MODULE,}, 671d5bf9071SChristian Hohnstaedt }, { 672510d573fSMarek Vasut .phy_id = PHY_ID_KSZ8001, 673510d573fSMarek Vasut .name = "Micrel KSZ8001 or KS8721", 67448d7d0adSJason Wang .phy_id_mask = 0x00ffffff, 67551f932c4SChoi, David .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause), 67651f932c4SChoi, David .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, 677e6a423a8SJohan Hovold .driver_data = &ksz8041_type, 678e6a423a8SJohan Hovold .probe = kszphy_probe, 679e6a423a8SJohan Hovold .config_init = kszphy_config_init, 68051f932c4SChoi, David .config_aneg = genphy_config_aneg, 68151f932c4SChoi, David .read_status = genphy_read_status, 68251f932c4SChoi, David .ack_interrupt = kszphy_ack_interrupt, 68351f932c4SChoi, David .config_intr = kszphy_config_intr, 6841a5465f5SPatrice Vilchez .suspend = genphy_suspend, 6851a5465f5SPatrice Vilchez .resume = genphy_resume, 686d0507009SDavid J. Choi .driver = { .owner = THIS_MODULE,}, 687d5bf9071SChristian Hohnstaedt }, { 6887ab59dc1SDavid J. Choi .phy_id = PHY_ID_KSZ8081, 6897ab59dc1SDavid J. Choi .name = "Micrel KSZ8081 or KSZ8091", 6907ab59dc1SDavid J. Choi .phy_id_mask = 0x00fffff0, 6917ab59dc1SDavid J. Choi .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause), 6927ab59dc1SDavid J. Choi .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, 693e6a423a8SJohan Hovold .driver_data = &ksz8081_type, 694e6a423a8SJohan Hovold .probe = kszphy_probe, 69557a38effSJohan Hovold .config_init = ksz8081_config_init, 6967ab59dc1SDavid J. Choi .config_aneg = genphy_config_aneg, 6977ab59dc1SDavid J. Choi .read_status = genphy_read_status, 6987ab59dc1SDavid J. Choi .ack_interrupt = kszphy_ack_interrupt, 6997ab59dc1SDavid J. Choi .config_intr = kszphy_config_intr, 7001a5465f5SPatrice Vilchez .suspend = genphy_suspend, 7011a5465f5SPatrice Vilchez .resume = genphy_resume, 7027ab59dc1SDavid J. Choi .driver = { .owner = THIS_MODULE,}, 7037ab59dc1SDavid J. Choi }, { 7047ab59dc1SDavid J. Choi .phy_id = PHY_ID_KSZ8061, 7057ab59dc1SDavid J. Choi .name = "Micrel KSZ8061", 7067ab59dc1SDavid J. Choi .phy_id_mask = 0x00fffff0, 7077ab59dc1SDavid J. Choi .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause), 7087ab59dc1SDavid J. Choi .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, 7097ab59dc1SDavid J. Choi .config_init = kszphy_config_init, 7107ab59dc1SDavid J. Choi .config_aneg = genphy_config_aneg, 7117ab59dc1SDavid J. Choi .read_status = genphy_read_status, 7127ab59dc1SDavid J. Choi .ack_interrupt = kszphy_ack_interrupt, 7137ab59dc1SDavid J. Choi .config_intr = kszphy_config_intr, 7141a5465f5SPatrice Vilchez .suspend = genphy_suspend, 7151a5465f5SPatrice Vilchez .resume = genphy_resume, 7167ab59dc1SDavid J. Choi .driver = { .owner = THIS_MODULE,}, 7177ab59dc1SDavid J. Choi }, { 718d0507009SDavid J. Choi .phy_id = PHY_ID_KSZ9021, 71948d7d0adSJason Wang .phy_id_mask = 0x000ffffe, 720d0507009SDavid J. Choi .name = "Micrel KSZ9021 Gigabit PHY", 72132fcafbcSVlastimil Kosar .features = (PHY_GBIT_FEATURES | SUPPORTED_Pause), 72251f932c4SChoi, David .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, 723954c3967SSean Cross .config_init = ksz9021_config_init, 724d0507009SDavid J. Choi .config_aneg = genphy_config_aneg, 725d0507009SDavid J. Choi .read_status = genphy_read_status, 72651f932c4SChoi, David .ack_interrupt = kszphy_ack_interrupt, 72751f932c4SChoi, David .config_intr = ksz9021_config_intr, 7281a5465f5SPatrice Vilchez .suspend = genphy_suspend, 7291a5465f5SPatrice Vilchez .resume = genphy_resume, 73019936942SVince Bridgers .read_mmd_indirect = ksz9021_rd_mmd_phyreg, 73119936942SVince Bridgers .write_mmd_indirect = ksz9021_wr_mmd_phyreg, 732d0507009SDavid J. Choi .driver = { .owner = THIS_MODULE, }, 73393272e07SJean-Christophe PLAGNIOL-VILLARD }, { 7347ab59dc1SDavid J. Choi .phy_id = PHY_ID_KSZ9031, 7357ab59dc1SDavid J. Choi .phy_id_mask = 0x00fffff0, 7367ab59dc1SDavid J. Choi .name = "Micrel KSZ9031 Gigabit PHY", 73795e8b103SMike Looijmans .features = (PHY_GBIT_FEATURES | SUPPORTED_Pause), 7387ab59dc1SDavid J. Choi .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, 7396e4b8273SHubert Chaumette .config_init = ksz9031_config_init, 7407ab59dc1SDavid J. Choi .config_aneg = genphy_config_aneg, 7417ab59dc1SDavid J. Choi .read_status = genphy_read_status, 7427ab59dc1SDavid J. Choi .ack_interrupt = kszphy_ack_interrupt, 7437ab59dc1SDavid J. Choi .config_intr = ksz9021_config_intr, 7441a5465f5SPatrice Vilchez .suspend = genphy_suspend, 7451a5465f5SPatrice Vilchez .resume = genphy_resume, 7467ab59dc1SDavid J. Choi .driver = { .owner = THIS_MODULE, }, 7477ab59dc1SDavid J. Choi }, { 74893272e07SJean-Christophe PLAGNIOL-VILLARD .phy_id = PHY_ID_KSZ8873MLL, 74993272e07SJean-Christophe PLAGNIOL-VILLARD .phy_id_mask = 0x00fffff0, 75093272e07SJean-Christophe PLAGNIOL-VILLARD .name = "Micrel KSZ8873MLL Switch", 75193272e07SJean-Christophe PLAGNIOL-VILLARD .features = (SUPPORTED_Pause | SUPPORTED_Asym_Pause), 75293272e07SJean-Christophe PLAGNIOL-VILLARD .flags = PHY_HAS_MAGICANEG, 75393272e07SJean-Christophe PLAGNIOL-VILLARD .config_init = kszphy_config_init, 75493272e07SJean-Christophe PLAGNIOL-VILLARD .config_aneg = ksz8873mll_config_aneg, 75593272e07SJean-Christophe PLAGNIOL-VILLARD .read_status = ksz8873mll_read_status, 7561a5465f5SPatrice Vilchez .suspend = genphy_suspend, 7571a5465f5SPatrice Vilchez .resume = genphy_resume, 75893272e07SJean-Christophe PLAGNIOL-VILLARD .driver = { .owner = THIS_MODULE, }, 7597ab59dc1SDavid J. Choi }, { 7607ab59dc1SDavid J. Choi .phy_id = PHY_ID_KSZ886X, 7617ab59dc1SDavid J. Choi .phy_id_mask = 0x00fffff0, 7627ab59dc1SDavid J. Choi .name = "Micrel KSZ886X Switch", 7637ab59dc1SDavid J. Choi .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause), 7647ab59dc1SDavid J. Choi .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, 7657ab59dc1SDavid J. Choi .config_init = kszphy_config_init, 7667ab59dc1SDavid J. Choi .config_aneg = genphy_config_aneg, 7677ab59dc1SDavid J. Choi .read_status = genphy_read_status, 7681a5465f5SPatrice Vilchez .suspend = genphy_suspend, 7691a5465f5SPatrice Vilchez .resume = genphy_resume, 7707ab59dc1SDavid J. Choi .driver = { .owner = THIS_MODULE, }, 771d5bf9071SChristian Hohnstaedt } }; 772d0507009SDavid J. Choi 77350fd7150SJohan Hovold module_phy_driver(ksphy_driver); 774d0507009SDavid J. Choi 775d0507009SDavid J. Choi MODULE_DESCRIPTION("Micrel PHY driver"); 776d0507009SDavid J. Choi MODULE_AUTHOR("David J. Choi"); 777d0507009SDavid J. Choi MODULE_LICENSE("GPL"); 77852a60ed2SDavid S. Miller 779cf93c945SUwe Kleine-König static struct mdio_device_id __maybe_unused micrel_tbl[] = { 78048d7d0adSJason Wang { PHY_ID_KSZ9021, 0x000ffffe }, 7817ab59dc1SDavid J. Choi { PHY_ID_KSZ9031, 0x00fffff0 }, 782510d573fSMarek Vasut { PHY_ID_KSZ8001, 0x00ffffff }, 78351f932c4SChoi, David { PHY_ID_KS8737, 0x00fffff0 }, 784212ea99aSMarek Vasut { PHY_ID_KSZ8021, 0x00ffffff }, 785b818d1a7SHector Palacios { PHY_ID_KSZ8031, 0x00ffffff }, 786510d573fSMarek Vasut { PHY_ID_KSZ8041, 0x00fffff0 }, 787510d573fSMarek Vasut { PHY_ID_KSZ8051, 0x00fffff0 }, 7887ab59dc1SDavid J. Choi { PHY_ID_KSZ8061, 0x00fffff0 }, 7897ab59dc1SDavid J. Choi { PHY_ID_KSZ8081, 0x00fffff0 }, 79093272e07SJean-Christophe PLAGNIOL-VILLARD { PHY_ID_KSZ8873MLL, 0x00fffff0 }, 7917ab59dc1SDavid J. Choi { PHY_ID_KSZ886X, 0x00fffff0 }, 79252a60ed2SDavid S. Miller { } 79352a60ed2SDavid S. Miller }; 79452a60ed2SDavid S. Miller 79552a60ed2SDavid S. Miller MODULE_DEVICE_TABLE(mdio, micrel_tbl); 796