broadcom.c 18.9 KB
Newer Older
1
// SPDX-License-Identifier: GPL-2.0+
2 3 4 5 6 7 8 9 10 11 12
/*
 *	drivers/net/phy/broadcom.c
 *
 *	Broadcom BCM5411, BCM5421 and BCM5461 Gigabit Ethernet
 *	transceivers.
 *
 *	Copyright (c) 2006  Maciej W. Rozycki
 *
 *	Inspired by code written by Amy Fong.
 */

13
#include "bcm-phy-lib.h"
14 15
#include <linux/module.h>
#include <linux/phy.h>
16
#include <linux/brcmphy.h>
17
#include <linux/of.h>
18 19 20 21

#define BRCM_PHY_MODEL(phydev) \
	((phydev)->drv->phy_id & (phydev)->drv->phy_id_mask)

22 23 24
#define BRCM_PHY_REV(phydev) \
	((phydev)->drv->phy_id & ~((phydev)->drv->phy_id_mask))

25 26 27 28
MODULE_DESCRIPTION("Broadcom PHY driver");
MODULE_AUTHOR("Maciej W. Rozycki");
MODULE_LICENSE("GPL");

29 30
static int bcm54xx_config_clock_delay(struct phy_device *phydev);

31 32 33 34
static int bcm54210e_config_init(struct phy_device *phydev)
{
	int val;

35
	bcm54xx_config_clock_delay(phydev);
36

37 38 39 40 41 42
	if (phydev->dev_flags & PHY_BRCM_EN_MASTER_MODE) {
		val = phy_read(phydev, MII_CTRL1000);
		val |= CTL1000_AS_MASTER | CTL1000_ENABLE_MASTER;
		phy_write(phydev, MII_CTRL1000, val);
	}

43 44 45
	return 0;
}

46 47
static int bcm54612e_config_init(struct phy_device *phydev)
{
48 49
	int reg;

50
	bcm54xx_config_clock_delay(phydev);
51

52 53 54 55 56 57 58 59 60 61 62 63
	/* Enable CLK125 MUX on LED4 if ref clock is enabled. */
	if (!(phydev->dev_flags & PHY_BRCM_RX_REFCLK_UNUSED)) {
		int err;

		reg = bcm_phy_read_exp(phydev, BCM54612E_EXP_SPARE0);
		err = bcm_phy_write_exp(phydev, BCM54612E_EXP_SPARE0,
					BCM54612E_LED4_CLK125OUT_EN | reg);

		if (err < 0)
			return err;
	}

64 65 66
	return 0;
}

67
static int bcm54xx_config_clock_delay(struct phy_device *phydev)
68 69 70
{
	int rc, val;

71
	/* handling PHY's internal RX clock delay */
72 73
	val = bcm54xx_auxctl_read(phydev, MII_BCM54XX_AUXCTL_SHDWSEL_MISC);
	val |= MII_BCM54XX_AUXCTL_MISC_WREN;
74 75 76 77 78 79 80 81 82 83
	if (phydev->interface == PHY_INTERFACE_MODE_RGMII ||
	    phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) {
		/* Disable RGMII RXC-RXD skew */
		val &= ~MII_BCM54XX_AUXCTL_SHDWSEL_MISC_RGMII_SKEW_EN;
	}
	if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID ||
	    phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) {
		/* Enable RGMII RXC-RXD skew */
		val |= MII_BCM54XX_AUXCTL_SHDWSEL_MISC_RGMII_SKEW_EN;
	}
84 85 86 87 88
	rc = bcm54xx_auxctl_write(phydev, MII_BCM54XX_AUXCTL_SHDWSEL_MISC,
				  val);
	if (rc < 0)
		return rc;

89
	/* handling PHY's internal TX clock delay */
90
	val = bcm_phy_read_shadow(phydev, BCM54810_SHD_CLK_CTL);
91 92 93 94 95 96 97 98 99 100
	if (phydev->interface == PHY_INTERFACE_MODE_RGMII ||
	    phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) {
		/* Disable internal TX clock delay */
		val &= ~BCM54810_SHD_CLK_CTL_GTXCLK_EN;
	}
	if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID ||
	    phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) {
		/* Enable internal TX clock delay */
		val |= BCM54810_SHD_CLK_CTL_GTXCLK_EN;
	}
101 102 103 104 105 106 107
	rc = bcm_phy_write_shadow(phydev, BCM54810_SHD_CLK_CTL, val);
	if (rc < 0)
		return rc;

	return 0;
}

M
Matt Carlson 已提交
108
/* Needs SMDSP clock enabled via bcm54xx_phydsp_config() */
M
Matt Carlson 已提交
109 110 111 112
static int bcm50610_a0_workaround(struct phy_device *phydev)
{
	int err;

113
	err = bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_AADJ1CH0,
M
Matt Carlson 已提交
114 115 116
				MII_BCM54XX_EXP_AADJ1CH0_SWP_ABCD_OEN |
				MII_BCM54XX_EXP_AADJ1CH0_SWSEL_THPF);
	if (err < 0)
M
Matt Carlson 已提交
117
		return err;
M
Matt Carlson 已提交
118

119 120
	err = bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_AADJ1CH3,
				MII_BCM54XX_EXP_AADJ1CH3_ADCCKADJ);
M
Matt Carlson 已提交
121
	if (err < 0)
M
Matt Carlson 已提交
122
		return err;
M
Matt Carlson 已提交
123

124
	err = bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_EXP75,
M
Matt Carlson 已提交
125 126
				MII_BCM54XX_EXP_EXP75_VDACCTRL);
	if (err < 0)
M
Matt Carlson 已提交
127
		return err;
M
Matt Carlson 已提交
128

129
	err = bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_EXP96,
M
Matt Carlson 已提交
130 131
				MII_BCM54XX_EXP_EXP96_MYST);
	if (err < 0)
M
Matt Carlson 已提交
132
		return err;
M
Matt Carlson 已提交
133

134
	err = bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_EXP97,
M
Matt Carlson 已提交
135 136
				MII_BCM54XX_EXP_EXP97_MYST);

M
Matt Carlson 已提交
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
	return err;
}

static int bcm54xx_phydsp_config(struct phy_device *phydev)
{
	int err, err2;

	/* Enable the SMDSP clock */
	err = bcm54xx_auxctl_write(phydev,
				   MII_BCM54XX_AUXCTL_SHDWSEL_AUXCTL,
				   MII_BCM54XX_AUXCTL_ACTL_SMDSP_ENA |
				   MII_BCM54XX_AUXCTL_ACTL_TX_6DB);
	if (err < 0)
		return err;

M
Matt Carlson 已提交
152 153 154
	if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM50610 ||
	    BRCM_PHY_MODEL(phydev) == PHY_ID_BCM50610M) {
		/* Clear bit 9 to fix a phy interop issue. */
155
		err = bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_EXP08,
M
Matt Carlson 已提交
156 157 158 159 160 161 162 163 164 165
					MII_BCM54XX_EXP_EXP08_RJCT_2MHZ);
		if (err < 0)
			goto error;

		if (phydev->drv->phy_id == PHY_ID_BCM50610) {
			err = bcm50610_a0_workaround(phydev);
			if (err < 0)
				goto error;
		}
	}
M
Matt Carlson 已提交
166 167 168 169

	if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM57780) {
		int val;

170
		val = bcm_phy_read_exp(phydev, MII_BCM54XX_EXP_EXP75);
M
Matt Carlson 已提交
171 172 173 174
		if (val < 0)
			goto error;

		val |= MII_BCM54XX_EXP_EXP75_CM_OSC;
175
		err = bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_EXP75, val);
M
Matt Carlson 已提交
176 177
	}

M
Matt Carlson 已提交
178
error:
M
Matt Carlson 已提交
179 180 181 182
	/* Disable the SMDSP clock */
	err2 = bcm54xx_auxctl_write(phydev,
				    MII_BCM54XX_AUXCTL_SHDWSEL_AUXCTL,
				    MII_BCM54XX_AUXCTL_ACTL_TX_6DB);
M
Matt Carlson 已提交
183

M
Matt Carlson 已提交
184 185
	/* Return the first error reported. */
	return err ? err : err2;
M
Matt Carlson 已提交
186 187
}

188 189
static void bcm54xx_adjust_rxrefclk(struct phy_device *phydev)
{
190 191
	u32 orig;
	int val;
192
	bool clk125en = true;
193 194

	/* Abort if we are using an untested phy. */
195 196
	if (BRCM_PHY_MODEL(phydev) != PHY_ID_BCM57780 &&
	    BRCM_PHY_MODEL(phydev) != PHY_ID_BCM50610 &&
197 198 199
	    BRCM_PHY_MODEL(phydev) != PHY_ID_BCM50610M)
		return;

200
	val = bcm_phy_read_shadow(phydev, BCM54XX_SHD_SCR3);
201 202 203 204 205
	if (val < 0)
		return;

	orig = val;

206 207 208 209 210 211 212 213 214 215
	if ((BRCM_PHY_MODEL(phydev) == PHY_ID_BCM50610 ||
	     BRCM_PHY_MODEL(phydev) == PHY_ID_BCM50610M) &&
	    BRCM_PHY_REV(phydev) >= 0x3) {
		/*
		 * Here, bit 0 _disables_ CLK125 when set.
		 * This bit is set by default.
		 */
		clk125en = false;
	} else {
		if (phydev->dev_flags & PHY_BRCM_RX_REFCLK_UNUSED) {
216 217
			/* Here, bit 0 _enables_ CLK125 when set */
			val &= ~BCM54XX_SHD_SCR3_DEF_CLK125;
218
			clk125en = false;
219 220 221
		}
	}

222
	if (!clk125en || (phydev->dev_flags & PHY_BRCM_AUTO_PWRDWN_ENABLE))
223 224 225 226
		val &= ~BCM54XX_SHD_SCR3_DLLAPD_DIS;
	else
		val |= BCM54XX_SHD_SCR3_DLLAPD_DIS;

227 228 229
	if (phydev->dev_flags & PHY_BRCM_DIS_TXCRXC_NOENRGY)
		val |= BCM54XX_SHD_SCR3_TRDDAPD;

230
	if (orig != val)
231
		bcm_phy_write_shadow(phydev, BCM54XX_SHD_SCR3, val);
232

233
	val = bcm_phy_read_shadow(phydev, BCM54XX_SHD_APD);
234 235 236 237 238
	if (val < 0)
		return;

	orig = val;

239
	if (!clk125en || (phydev->dev_flags & PHY_BRCM_AUTO_PWRDWN_ENABLE))
240 241 242 243 244
		val |= BCM54XX_SHD_APD_EN;
	else
		val &= ~BCM54XX_SHD_APD_EN;

	if (orig != val)
245
		bcm_phy_write_shadow(phydev, BCM54XX_SHD_APD, val);
246 247
}

248 249
static int bcm54xx_config_init(struct phy_device *phydev)
{
250
	int reg, err, val;
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268

	reg = phy_read(phydev, MII_BCM54XX_ECR);
	if (reg < 0)
		return reg;

	/* Mask interrupts globally.  */
	reg |= MII_BCM54XX_ECR_IM;
	err = phy_write(phydev, MII_BCM54XX_ECR, reg);
	if (err < 0)
		return err;

	/* Unmask events we are interested in.  */
	reg = ~(MII_BCM54XX_INT_DUPLEX |
		MII_BCM54XX_INT_SPEED |
		MII_BCM54XX_INT_LINK);
	err = phy_write(phydev, MII_BCM54XX_IMR, reg);
	if (err < 0)
		return err;
M
Matt Carlson 已提交
269

270 271 272
	if ((BRCM_PHY_MODEL(phydev) == PHY_ID_BCM50610 ||
	     BRCM_PHY_MODEL(phydev) == PHY_ID_BCM50610M) &&
	    (phydev->dev_flags & PHY_BRCM_CLEAR_RGMII_MODE))
273
		bcm_phy_write_shadow(phydev, BCM54XX_SHD_RGMII_MODE, 0);
274

275
	if ((phydev->dev_flags & PHY_BRCM_RX_REFCLK_UNUSED) ||
276
	    (phydev->dev_flags & PHY_BRCM_DIS_TXCRXC_NOENRGY) ||
277
	    (phydev->dev_flags & PHY_BRCM_AUTO_PWRDWN_ENABLE))
278 279
		bcm54xx_adjust_rxrefclk(phydev);

280 281 282 283
	if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54210E) {
		err = bcm54210e_config_init(phydev);
		if (err)
			return err;
284 285 286 287
	} else if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54612E) {
		err = bcm54612e_config_init(phydev);
		if (err)
			return err;
288
	} else if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54810) {
289 290 291 292 293 294 295 296
		/* For BCM54810, we need to disable BroadR-Reach function */
		val = bcm_phy_read_exp(phydev,
				       BCM54810_EXP_BROADREACH_LRE_MISC_CTL);
		val &= ~BCM54810_EXP_BROADREACH_LRE_MISC_CTL_EN;
		err = bcm_phy_write_exp(phydev,
					BCM54810_EXP_BROADREACH_LRE_MISC_CTL,
					val);
		if (err < 0)
297 298 299
			return err;
	}

M
Matt Carlson 已提交
300
	bcm54xx_phydsp_config(phydev);
301

302 303 304 305 306 307 308 309 310 311 312 313 314
	/* Encode link speed into LED1 and LED3 pair (green/amber).
	 * Also flash these two LEDs on activity. This means configuring
	 * them for MULTICOLOR and encoding link/activity into them.
	 */
	val = BCM5482_SHD_LEDS1_LED1(BCM_LED_SRC_MULTICOLOR1) |
		BCM5482_SHD_LEDS1_LED3(BCM_LED_SRC_MULTICOLOR1);
	bcm_phy_write_shadow(phydev, BCM5482_SHD_LEDS1, val);

	val = BCM_LED_MULTICOLOR_IN_PHASE |
		BCM5482_SHD_LEDS1_LED1(BCM_LED_MULTICOLOR_LINK_ACT) |
		BCM5482_SHD_LEDS1_LED3(BCM_LED_MULTICOLOR_LINK_ACT);
	bcm_phy_write_exp(phydev, BCM_EXP_MULTICOLOR, val);

315 316 317
	return 0;
}

318 319 320 321 322 323 324 325 326 327
static int bcm5482_config_init(struct phy_device *phydev)
{
	int err, reg;

	err = bcm54xx_config_init(phydev);

	if (phydev->dev_flags & PHY_BCM_FLAGS_MODE_1000BX) {
		/*
		 * Enable secondary SerDes and its use as an LED source
		 */
328 329
		reg = bcm_phy_read_shadow(phydev, BCM5482_SHD_SSD);
		bcm_phy_write_shadow(phydev, BCM5482_SHD_SSD,
330 331 332 333 334 335 336
				     reg |
				     BCM5482_SHD_SSD_LEDM |
				     BCM5482_SHD_SSD_EN);

		/*
		 * Enable SGMII slave mode and auto-detection
		 */
337
		reg = BCM5482_SSD_SGMII_SLAVE | MII_BCM54XX_EXP_SEL_SSD;
338
		err = bcm_phy_read_exp(phydev, reg);
339 340
		if (err < 0)
			return err;
341
		err = bcm_phy_write_exp(phydev, reg, err |
342 343 344 345
					BCM5482_SSD_SGMII_SLAVE_EN |
					BCM5482_SSD_SGMII_SLAVE_AD);
		if (err < 0)
			return err;
346 347 348 349

		/*
		 * Disable secondary SerDes powerdown
		 */
350
		reg = BCM5482_SSD_1000BX_CTL | MII_BCM54XX_EXP_SEL_SSD;
351
		err = bcm_phy_read_exp(phydev, reg);
352 353
		if (err < 0)
			return err;
354
		err = bcm_phy_write_exp(phydev, reg,
355 356 357
					err & ~BCM5482_SSD_1000BX_CTL_PWRDOWN);
		if (err < 0)
			return err;
358 359 360 361

		/*
		 * Select 1000BASE-X register set (primary SerDes)
		 */
362 363
		reg = bcm_phy_read_shadow(phydev, BCM5482_SHD_MODE);
		bcm_phy_write_shadow(phydev, BCM5482_SHD_MODE,
364 365 366 367 368 369
				     reg | BCM5482_SHD_MODE_1000BX);

		/*
		 * LED1=ACTIVITYLED, LED3=LINKSPD[2]
		 * (Use LED1 as secondary SerDes ACTIVITY LED)
		 */
370
		bcm_phy_write_shadow(phydev, BCM5482_SHD_LEDS1,
371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407
			BCM5482_SHD_LEDS1_LED1(BCM_LED_SRC_ACTIVITYLED) |
			BCM5482_SHD_LEDS1_LED3(BCM_LED_SRC_LINKSPD2));

		/*
		 * Auto-negotiation doesn't seem to work quite right
		 * in this mode, so we disable it and force it to the
		 * right speed/duplex setting.  Only 'link status'
		 * is important.
		 */
		phydev->autoneg = AUTONEG_DISABLE;
		phydev->speed = SPEED_1000;
		phydev->duplex = DUPLEX_FULL;
	}

	return err;
}

static int bcm5482_read_status(struct phy_device *phydev)
{
	int err;

	err = genphy_read_status(phydev);

	if (phydev->dev_flags & PHY_BCM_FLAGS_MODE_1000BX) {
		/*
		 * Only link status matters for 1000Base-X mode, so force
		 * 1000 Mbit/s full-duplex status
		 */
		if (phydev->link) {
			phydev->speed = SPEED_1000;
			phydev->duplex = DUPLEX_FULL;
		}
	}

	return err;
}

408 409
static int bcm5481_config_aneg(struct phy_device *phydev)
{
410
	struct device_node *np = phydev->mdio.dev.of_node;
411 412 413 414 415 416
	int ret;

	/* Aneg firsly. */
	ret = genphy_config_aneg(phydev);

	/* Then we can set up the delay. */
417
	bcm54xx_config_clock_delay(phydev);
418

419 420 421 422 423 424 425 426
	if (of_property_read_bool(np, "enet-phy-lane-swap")) {
		/* Lane Swap - Undocumented register...magic! */
		ret = bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_SEL_ER + 0x9,
					0x11B);
		if (ret < 0)
			return ret;
	}

427 428 429
	return ret;
}

430 431 432 433 434 435 436 437 438 439 440 441 442
static int bcm54616s_config_aneg(struct phy_device *phydev)
{
	int ret;

	/* Aneg firsly. */
	ret = genphy_config_aneg(phydev);

	/* Then we can set up the delay. */
	bcm54xx_config_clock_delay(phydev);

	return ret;
}

M
Matt Carlson 已提交
443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508
static int brcm_phy_setbits(struct phy_device *phydev, int reg, int set)
{
	int val;

	val = phy_read(phydev, reg);
	if (val < 0)
		return val;

	return phy_write(phydev, reg, val | set);
}

static int brcm_fet_config_init(struct phy_device *phydev)
{
	int reg, err, err2, brcmtest;

	/* Reset the PHY to bring it to a known state. */
	err = phy_write(phydev, MII_BMCR, BMCR_RESET);
	if (err < 0)
		return err;

	reg = phy_read(phydev, MII_BRCM_FET_INTREG);
	if (reg < 0)
		return reg;

	/* Unmask events we are interested in and mask interrupts globally. */
	reg = MII_BRCM_FET_IR_DUPLEX_EN |
	      MII_BRCM_FET_IR_SPEED_EN |
	      MII_BRCM_FET_IR_LINK_EN |
	      MII_BRCM_FET_IR_ENABLE |
	      MII_BRCM_FET_IR_MASK;

	err = phy_write(phydev, MII_BRCM_FET_INTREG, reg);
	if (err < 0)
		return err;

	/* Enable shadow register access */
	brcmtest = phy_read(phydev, MII_BRCM_FET_BRCMTEST);
	if (brcmtest < 0)
		return brcmtest;

	reg = brcmtest | MII_BRCM_FET_BT_SRE;

	err = phy_write(phydev, MII_BRCM_FET_BRCMTEST, reg);
	if (err < 0)
		return err;

	/* Set the LED mode */
	reg = phy_read(phydev, MII_BRCM_FET_SHDW_AUXMODE4);
	if (reg < 0) {
		err = reg;
		goto done;
	}

	reg &= ~MII_BRCM_FET_SHDW_AM4_LED_MASK;
	reg |= MII_BRCM_FET_SHDW_AM4_LED_MODE1;

	err = phy_write(phydev, MII_BRCM_FET_SHDW_AUXMODE4, reg);
	if (err < 0)
		goto done;

	/* Enable auto MDIX */
	err = brcm_phy_setbits(phydev, MII_BRCM_FET_SHDW_MISCCTRL,
				       MII_BRCM_FET_SHDW_MC_FAME);
	if (err < 0)
		goto done;

509 510 511 512 513
	if (phydev->dev_flags & PHY_BRCM_AUTO_PWRDWN_ENABLE) {
		/* Enable auto power down */
		err = brcm_phy_setbits(phydev, MII_BRCM_FET_SHDW_AUXSTAT2,
					       MII_BRCM_FET_SHDW_AS2_APDE);
	}
M
Matt Carlson 已提交
514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552

done:
	/* Disable shadow register access */
	err2 = phy_write(phydev, MII_BRCM_FET_BRCMTEST, brcmtest);
	if (!err)
		err = err2;

	return err;
}

static int brcm_fet_ack_interrupt(struct phy_device *phydev)
{
	int reg;

	/* Clear pending interrupts.  */
	reg = phy_read(phydev, MII_BRCM_FET_INTREG);
	if (reg < 0)
		return reg;

	return 0;
}

static int brcm_fet_config_intr(struct phy_device *phydev)
{
	int reg, err;

	reg = phy_read(phydev, MII_BRCM_FET_INTREG);
	if (reg < 0)
		return reg;

	if (phydev->interrupts == PHY_INTERRUPT_ENABLED)
		reg &= ~MII_BRCM_FET_IR_MASK;
	else
		reg |= MII_BRCM_FET_IR_MASK;

	err = phy_write(phydev, MII_BRCM_FET_INTREG, reg);
	return err;
}

553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583
struct bcm53xx_phy_priv {
	u64	*stats;
};

static int bcm53xx_phy_probe(struct phy_device *phydev)
{
	struct bcm53xx_phy_priv *priv;

	priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL);
	if (!priv)
		return -ENOMEM;

	phydev->priv = priv;

	priv->stats = devm_kcalloc(&phydev->mdio.dev,
				   bcm_phy_get_sset_count(phydev), sizeof(u64),
				   GFP_KERNEL);
	if (!priv->stats)
		return -ENOMEM;

	return 0;
}

static void bcm53xx_phy_get_stats(struct phy_device *phydev,
				  struct ethtool_stats *stats, u64 *data)
{
	struct bcm53xx_phy_priv *priv = phydev->priv;

	bcm_phy_get_stats(phydev, priv->stats, stats, data);
}

584 585
static struct phy_driver broadcom_drivers[] = {
{
586
	.phy_id		= PHY_ID_BCM5411,
587 588
	.phy_id_mask	= 0xfffffff0,
	.name		= "Broadcom BCM5411",
589
	/* PHY_GBIT_FEATURES */
590
	.config_init	= bcm54xx_config_init,
591 592
	.ack_interrupt	= bcm_phy_ack_intr,
	.config_intr	= bcm_phy_config_intr,
593
}, {
594
	.phy_id		= PHY_ID_BCM5421,
595 596
	.phy_id_mask	= 0xfffffff0,
	.name		= "Broadcom BCM5421",
597
	/* PHY_GBIT_FEATURES */
598
	.config_init	= bcm54xx_config_init,
599 600
	.ack_interrupt	= bcm_phy_ack_intr,
	.config_intr	= bcm_phy_config_intr,
601 602 603 604
}, {
	.phy_id		= PHY_ID_BCM54210E,
	.phy_id_mask	= 0xfffffff0,
	.name		= "Broadcom BCM54210E",
605
	/* PHY_GBIT_FEATURES */
606 607 608
	.config_init	= bcm54xx_config_init,
	.ack_interrupt	= bcm_phy_ack_intr,
	.config_intr	= bcm_phy_config_intr,
609
}, {
610
	.phy_id		= PHY_ID_BCM5461,
611 612
	.phy_id_mask	= 0xfffffff0,
	.name		= "Broadcom BCM5461",
613
	/* PHY_GBIT_FEATURES */
614
	.config_init	= bcm54xx_config_init,
615 616
	.ack_interrupt	= bcm_phy_ack_intr,
	.config_intr	= bcm_phy_config_intr,
617 618 619 620
}, {
	.phy_id		= PHY_ID_BCM54612E,
	.phy_id_mask	= 0xfffffff0,
	.name		= "Broadcom BCM54612E",
621
	/* PHY_GBIT_FEATURES */
622 623 624
	.config_init	= bcm54xx_config_init,
	.ack_interrupt	= bcm_phy_ack_intr,
	.config_intr	= bcm_phy_config_intr,
625 626 627 628
}, {
	.phy_id		= PHY_ID_BCM54616S,
	.phy_id_mask	= 0xfffffff0,
	.name		= "Broadcom BCM54616S",
629
	/* PHY_GBIT_FEATURES */
630
	.config_init	= bcm54xx_config_init,
631
	.config_aneg	= bcm54616s_config_aneg,
632 633
	.ack_interrupt	= bcm_phy_ack_intr,
	.config_intr	= bcm_phy_config_intr,
634
}, {
635
	.phy_id		= PHY_ID_BCM5464,
636 637
	.phy_id_mask	= 0xfffffff0,
	.name		= "Broadcom BCM5464",
638
	/* PHY_GBIT_FEATURES */
639
	.config_init	= bcm54xx_config_init,
640 641
	.ack_interrupt	= bcm_phy_ack_intr,
	.config_intr	= bcm_phy_config_intr,
642 643
	.suspend	= genphy_suspend,
	.resume		= genphy_resume,
644
}, {
645
	.phy_id		= PHY_ID_BCM5481,
646 647
	.phy_id_mask	= 0xfffffff0,
	.name		= "Broadcom BCM5481",
648
	/* PHY_GBIT_FEATURES */
649
	.config_init	= bcm54xx_config_init,
650
	.config_aneg	= bcm5481_config_aneg,
651 652
	.ack_interrupt	= bcm_phy_ack_intr,
	.config_intr	= bcm_phy_config_intr,
653 654 655 656
}, {
	.phy_id         = PHY_ID_BCM54810,
	.phy_id_mask    = 0xfffffff0,
	.name           = "Broadcom BCM54810",
657
	/* PHY_GBIT_FEATURES */
658
	.config_init    = bcm54xx_config_init,
659
	.config_aneg    = bcm5481_config_aneg,
660 661
	.ack_interrupt  = bcm_phy_ack_intr,
	.config_intr    = bcm_phy_config_intr,
662
}, {
663
	.phy_id		= PHY_ID_BCM5482,
N
Nate Case 已提交
664 665
	.phy_id_mask	= 0xfffffff0,
	.name		= "Broadcom BCM5482",
666
	/* PHY_GBIT_FEATURES */
667
	.config_init	= bcm5482_config_init,
668
	.read_status	= bcm5482_read_status,
669 670
	.ack_interrupt	= bcm_phy_ack_intr,
	.config_intr	= bcm_phy_config_intr,
671
}, {
M
Matt Carlson 已提交
672 673 674
	.phy_id		= PHY_ID_BCM50610,
	.phy_id_mask	= 0xfffffff0,
	.name		= "Broadcom BCM50610",
675
	/* PHY_GBIT_FEATURES */
M
Matt Carlson 已提交
676
	.config_init	= bcm54xx_config_init,
677 678
	.ack_interrupt	= bcm_phy_ack_intr,
	.config_intr	= bcm_phy_config_intr,
679
}, {
M
Matt Carlson 已提交
680 681 682
	.phy_id		= PHY_ID_BCM50610M,
	.phy_id_mask	= 0xfffffff0,
	.name		= "Broadcom BCM50610M",
683
	/* PHY_GBIT_FEATURES */
M
Matt Carlson 已提交
684
	.config_init	= bcm54xx_config_init,
685 686
	.ack_interrupt	= bcm_phy_ack_intr,
	.config_intr	= bcm_phy_config_intr,
687
}, {
688
	.phy_id		= PHY_ID_BCM57780,
M
Matt Carlson 已提交
689 690
	.phy_id_mask	= 0xfffffff0,
	.name		= "Broadcom BCM57780",
691
	/* PHY_GBIT_FEATURES */
M
Matt Carlson 已提交
692
	.config_init	= bcm54xx_config_init,
693 694
	.ack_interrupt	= bcm_phy_ack_intr,
	.config_intr	= bcm_phy_config_intr,
695
}, {
696
	.phy_id		= PHY_ID_BCMAC131,
M
Matt Carlson 已提交
697 698
	.phy_id_mask	= 0xfffffff0,
	.name		= "Broadcom BCMAC131",
699
	/* PHY_BASIC_FEATURES */
M
Matt Carlson 已提交
700 701 702
	.config_init	= brcm_fet_config_init,
	.ack_interrupt	= brcm_fet_ack_interrupt,
	.config_intr	= brcm_fet_config_intr,
703
}, {
D
Dmitry Baryshkov 已提交
704 705 706
	.phy_id		= PHY_ID_BCM5241,
	.phy_id_mask	= 0xfffffff0,
	.name		= "Broadcom BCM5241",
707
	/* PHY_BASIC_FEATURES */
D
Dmitry Baryshkov 已提交
708 709 710
	.config_init	= brcm_fet_config_init,
	.ack_interrupt	= brcm_fet_ack_interrupt,
	.config_intr	= brcm_fet_config_intr,
711 712 713 714 715
}, {
	.phy_id		= PHY_ID_BCM5395,
	.phy_id_mask	= 0xfffffff0,
	.name		= "Broadcom BCM5395",
	.flags		= PHY_IS_INTERNAL,
716
	/* PHY_GBIT_FEATURES */
717 718 719 720
	.get_sset_count	= bcm_phy_get_sset_count,
	.get_strings	= bcm_phy_get_strings,
	.get_stats	= bcm53xx_phy_get_stats,
	.probe		= bcm53xx_phy_probe,
721 722 723 724
}, {
	.phy_id         = PHY_ID_BCM89610,
	.phy_id_mask    = 0xfffffff0,
	.name           = "Broadcom BCM89610",
725
	/* PHY_GBIT_FEATURES */
726 727 728
	.config_init    = bcm54xx_config_init,
	.ack_interrupt  = bcm_phy_ack_intr,
	.config_intr    = bcm_phy_config_intr,
729
} };
D
Dmitry Baryshkov 已提交
730

731
module_phy_driver(broadcom_drivers);
732

733
static struct mdio_device_id __maybe_unused broadcom_tbl[] = {
734 735
	{ PHY_ID_BCM5411, 0xfffffff0 },
	{ PHY_ID_BCM5421, 0xfffffff0 },
736
	{ PHY_ID_BCM54210E, 0xfffffff0 },
737
	{ PHY_ID_BCM5461, 0xfffffff0 },
738
	{ PHY_ID_BCM54612E, 0xfffffff0 },
739
	{ PHY_ID_BCM54616S, 0xfffffff0 },
740
	{ PHY_ID_BCM5464, 0xfffffff0 },
741
	{ PHY_ID_BCM5481, 0xfffffff0 },
742
	{ PHY_ID_BCM54810, 0xfffffff0 },
743
	{ PHY_ID_BCM5482, 0xfffffff0 },
744 745 746 747
	{ PHY_ID_BCM50610, 0xfffffff0 },
	{ PHY_ID_BCM50610M, 0xfffffff0 },
	{ PHY_ID_BCM57780, 0xfffffff0 },
	{ PHY_ID_BCMAC131, 0xfffffff0 },
D
Dmitry Baryshkov 已提交
748
	{ PHY_ID_BCM5241, 0xfffffff0 },
749
	{ PHY_ID_BCM5395, 0xfffffff0 },
750
	{ PHY_ID_BCM89610, 0xfffffff0 },
751 752 753 754
	{ }
};

MODULE_DEVICE_TABLE(mdio, broadcom_tbl);