mv88x201x.c revision aa22437e87469fdee94b5344780b4a3dbb87a154
18199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter/*****************************************************************************
28199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter *                                                                           *
38199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter * File: mv88x201x.c                                                         *
4559fb51ba7e66fe298b8355fabde1275b7def35fScott Bardone * $Revision: 1.12 $                                                         *
5559fb51ba7e66fe298b8355fabde1275b7def35fScott Bardone * $Date: 2005/04/15 19:27:14 $                                              *
68199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter * Description:                                                              *
78199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter *  Marvell PHY (mv88x201x) functionality.                                   *
88199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter *  part of the Chelsio 10Gb Ethernet Driver.                                *
98199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter *                                                                           *
108199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter * This program is free software; you can redistribute it and/or modify      *
118199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter * it under the terms of the GNU General Public License, version 2, as       *
128199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter * published by the Free Software Foundation.                                *
138199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter *                                                                           *
148199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter * You should have received a copy of the GNU General Public License along   *
158199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter * with this program; if not, write to the Free Software Foundation, Inc.,   *
168199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.                 *
178199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter *                                                                           *
188199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED    *
198199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF      *
208199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.                     *
218199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter *                                                                           *
228199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter * http://www.chelsio.com                                                    *
238199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter *                                                                           *
248199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter * Copyright (c) 2003 - 2005 Chelsio Communications, Inc.                    *
258199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter * All rights reserved.                                                      *
268199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter *                                                                           *
278199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter * Maintainers: maintainers@chelsio.com                                      *
288199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter *                                                                           *
298199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter * Authors: Dimitrios Michailidis   <dm@chelsio.com>                         *
308199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter *          Tina Yang               <tainay@chelsio.com>                     *
318199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter *          Felix Marti             <felix@chelsio.com>                      *
328199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter *          Scott Bardone           <sbardone@chelsio.com>                   *
338199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter *          Kurt Ottaway            <kottaway@chelsio.com>                   *
348199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter *          Frank DiMambro          <frank@chelsio.com>                      *
358199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter *                                                                           *
368199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter * History:                                                                  *
378199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter *                                                                           *
388199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter ****************************************************************************/
398199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter
408199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter#include "cphy.h"
418199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter#include "elmer0.h"
428199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter
438199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter/*
448199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter * The 88x2010 Rev C. requires some link status registers * to be read
458199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter * twice in order to get the right values. Future * revisions will fix
468199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter * this problem and then this macro * can disappear.
478199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter */
488199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter#define MV88x2010_LINK_STATUS_BUGS    1
498199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter
508199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameterstatic int led_init(struct cphy *cphy)
518199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter{
528199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	/* Setup the LED registers so we can turn on/off.
538199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	 * Writing these bits maps control to another
548199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	 * register. mmd(0x1) addr(0x7)
558199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	 */
5623c3320cb039debfb94b27e8e9bfe26dd47692c3Ben Hutchings	cphy_mdio_write(cphy, MDIO_MMD_PCS, 0x8304, 0xdddd);
578199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	return 0;
588199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter}
598199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter
608199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameterstatic int led_link(struct cphy *cphy, u32 do_enable)
618199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter{
628199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	u32 led = 0;
638199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter#define LINK_ENABLE_BIT 0x1
648199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter
6523c3320cb039debfb94b27e8e9bfe26dd47692c3Ben Hutchings	cphy_mdio_read(cphy, MDIO_MMD_PMAPMD, MDIO_CTRL2, &led);
668199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter
678199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	if (do_enable & LINK_ENABLE_BIT) {
688199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter		led |= LINK_ENABLE_BIT;
6923c3320cb039debfb94b27e8e9bfe26dd47692c3Ben Hutchings		cphy_mdio_write(cphy, MDIO_MMD_PMAPMD, MDIO_CTRL2, led);
708199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	} else {
718199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter		led &= ~LINK_ENABLE_BIT;
7223c3320cb039debfb94b27e8e9bfe26dd47692c3Ben Hutchings		cphy_mdio_write(cphy, MDIO_MMD_PMAPMD, MDIO_CTRL2, led);
738199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	}
748199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	return 0;
758199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter}
768199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter
778199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter/* Port Reset */
788199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameterstatic int mv88x201x_reset(struct cphy *cphy, int wait)
798199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter{
808199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	/* This can be done through registers.  It is not required since
818199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	 * a full chip reset is used.
828199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	 */
838199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	return 0;
848199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter}
858199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter
868199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameterstatic int mv88x201x_interrupt_enable(struct cphy *cphy)
878199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter{
888199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	/* Enable PHY LASI interrupts. */
89aa22437e87469fdee94b5344780b4a3dbb87a154Ben Hutchings	cphy_mdio_write(cphy, MDIO_MMD_PMAPMD, MDIO_PMA_LASI_CTRL,
90aa22437e87469fdee94b5344780b4a3dbb87a154Ben Hutchings			MDIO_PMA_LASI_LSALARM);
918199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter
928199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	/* Enable Marvell interrupts through Elmer0. */
93f1d3d38af75789f1b82969b83b69cab540609789Stephen Hemminger	if (t1_is_asic(cphy->adapter)) {
94f1d3d38af75789f1b82969b83b69cab540609789Stephen Hemminger		u32 elmer;
95f1d3d38af75789f1b82969b83b69cab540609789Stephen Hemminger
96f1d3d38af75789f1b82969b83b69cab540609789Stephen Hemminger		t1_tpi_read(cphy->adapter, A_ELMER0_INT_ENABLE, &elmer);
97f1d3d38af75789f1b82969b83b69cab540609789Stephen Hemminger		elmer |= ELMER0_GP_BIT6;
98f1d3d38af75789f1b82969b83b69cab540609789Stephen Hemminger		t1_tpi_write(cphy->adapter, A_ELMER0_INT_ENABLE, elmer);
99f1d3d38af75789f1b82969b83b69cab540609789Stephen Hemminger	}
1008199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	return 0;
1018199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter}
1028199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter
1038199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameterstatic int mv88x201x_interrupt_disable(struct cphy *cphy)
1048199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter{
1058199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	/* Disable PHY LASI interrupts. */
106aa22437e87469fdee94b5344780b4a3dbb87a154Ben Hutchings	cphy_mdio_write(cphy, MDIO_MMD_PMAPMD, MDIO_PMA_LASI_CTRL, 0x0);
1078199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter
1088199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	/* Disable Marvell interrupts through Elmer0. */
109f1d3d38af75789f1b82969b83b69cab540609789Stephen Hemminger	if (t1_is_asic(cphy->adapter)) {
110f1d3d38af75789f1b82969b83b69cab540609789Stephen Hemminger		u32 elmer;
111f1d3d38af75789f1b82969b83b69cab540609789Stephen Hemminger
112f1d3d38af75789f1b82969b83b69cab540609789Stephen Hemminger		t1_tpi_read(cphy->adapter, A_ELMER0_INT_ENABLE, &elmer);
113f1d3d38af75789f1b82969b83b69cab540609789Stephen Hemminger		elmer &= ~ELMER0_GP_BIT6;
114f1d3d38af75789f1b82969b83b69cab540609789Stephen Hemminger		t1_tpi_write(cphy->adapter, A_ELMER0_INT_ENABLE, elmer);
115f1d3d38af75789f1b82969b83b69cab540609789Stephen Hemminger	}
1168199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	return 0;
1178199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter}
1188199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter
1198199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameterstatic int mv88x201x_interrupt_clear(struct cphy *cphy)
1208199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter{
1218199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	u32 elmer;
1228199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	u32 val;
1238199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter
1248199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter#ifdef MV88x2010_LINK_STATUS_BUGS
1258199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	/* Required to read twice before clear takes affect. */
126aa22437e87469fdee94b5344780b4a3dbb87a154Ben Hutchings	cphy_mdio_read(cphy, MDIO_MMD_PMAPMD, MDIO_PMA_LASI_RXSTAT, &val);
127aa22437e87469fdee94b5344780b4a3dbb87a154Ben Hutchings	cphy_mdio_read(cphy, MDIO_MMD_PMAPMD, MDIO_PMA_LASI_TXSTAT, &val);
128aa22437e87469fdee94b5344780b4a3dbb87a154Ben Hutchings	cphy_mdio_read(cphy, MDIO_MMD_PMAPMD, MDIO_PMA_LASI_STAT, &val);
1298199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter
1308199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	/* Read this register after the others above it else
1318199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	 * the register doesn't clear correctly.
1328199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	 */
13323c3320cb039debfb94b27e8e9bfe26dd47692c3Ben Hutchings	cphy_mdio_read(cphy, MDIO_MMD_PMAPMD, MDIO_STAT1, &val);
1348199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter#endif
1358199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter
1368199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	/* Clear link status. */
13723c3320cb039debfb94b27e8e9bfe26dd47692c3Ben Hutchings	cphy_mdio_read(cphy, MDIO_MMD_PMAPMD, MDIO_STAT1, &val);
1388199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	/* Clear PHY LASI interrupts. */
139aa22437e87469fdee94b5344780b4a3dbb87a154Ben Hutchings	cphy_mdio_read(cphy, MDIO_MMD_PMAPMD, MDIO_PMA_LASI_STAT, &val);
1408199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter
1418199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter#ifdef MV88x2010_LINK_STATUS_BUGS
1428199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	/* Do it again. */
143aa22437e87469fdee94b5344780b4a3dbb87a154Ben Hutchings	cphy_mdio_read(cphy, MDIO_MMD_PMAPMD, MDIO_PMA_LASI_RXSTAT, &val);
144aa22437e87469fdee94b5344780b4a3dbb87a154Ben Hutchings	cphy_mdio_read(cphy, MDIO_MMD_PMAPMD, MDIO_PMA_LASI_TXSTAT, &val);
1458199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter#endif
1468199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter
1478199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	/* Clear Marvell interrupts through Elmer0. */
148f1d3d38af75789f1b82969b83b69cab540609789Stephen Hemminger	if (t1_is_asic(cphy->adapter)) {
149f1d3d38af75789f1b82969b83b69cab540609789Stephen Hemminger		t1_tpi_read(cphy->adapter, A_ELMER0_INT_CAUSE, &elmer);
150f1d3d38af75789f1b82969b83b69cab540609789Stephen Hemminger		elmer |= ELMER0_GP_BIT6;
151f1d3d38af75789f1b82969b83b69cab540609789Stephen Hemminger		t1_tpi_write(cphy->adapter, A_ELMER0_INT_CAUSE, elmer);
152f1d3d38af75789f1b82969b83b69cab540609789Stephen Hemminger	}
1538199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	return 0;
1548199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter}
1558199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter
1568199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameterstatic int mv88x201x_interrupt_handler(struct cphy *cphy)
1578199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter{
1588199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	/* Clear interrupts */
1598199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	mv88x201x_interrupt_clear(cphy);
1608199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter
1618199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	/* We have only enabled link change interrupts and so
1628199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	 * cphy_cause must be a link change interrupt.
1638199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	 */
1648199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	return cphy_cause_link_change;
1658199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter}
1668199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter
1678199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameterstatic int mv88x201x_set_loopback(struct cphy *cphy, int on)
1688199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter{
1698199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	return 0;
1708199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter}
1718199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter
1728199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameterstatic int mv88x201x_get_link_status(struct cphy *cphy, int *link_ok,
1738199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter				     int *speed, int *duplex, int *fc)
1748199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter{
1758199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	u32 val = 0;
1768199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter
1778199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	if (link_ok) {
1788199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter		/* Read link status. */
17923c3320cb039debfb94b27e8e9bfe26dd47692c3Ben Hutchings		cphy_mdio_read(cphy, MDIO_MMD_PMAPMD, MDIO_STAT1, &val);
18023c3320cb039debfb94b27e8e9bfe26dd47692c3Ben Hutchings		val &= MDIO_STAT1_LSTATUS;
18123c3320cb039debfb94b27e8e9bfe26dd47692c3Ben Hutchings		*link_ok = (val == MDIO_STAT1_LSTATUS);
1828199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter		/* Turn on/off Link LED */
1838199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter		led_link(cphy, *link_ok);
1848199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	}
1858199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	if (speed)
1868199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter		*speed = SPEED_10000;
1878199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	if (duplex)
1888199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter		*duplex = DUPLEX_FULL;
1898199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	if (fc)
1908199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter		*fc = PAUSE_RX | PAUSE_TX;
1918199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	return 0;
1928199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter}
1938199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter
1948199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameterstatic void mv88x201x_destroy(struct cphy *cphy)
1958199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter{
1968199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	kfree(cphy);
1978199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter}
1988199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter
1998199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameterstatic struct cphy_ops mv88x201x_ops = {
2008199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	.destroy           = mv88x201x_destroy,
2018199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	.reset             = mv88x201x_reset,
2028199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	.interrupt_enable  = mv88x201x_interrupt_enable,
2038199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	.interrupt_disable = mv88x201x_interrupt_disable,
2048199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	.interrupt_clear   = mv88x201x_interrupt_clear,
2058199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	.interrupt_handler = mv88x201x_interrupt_handler,
2068199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	.get_link_status   = mv88x201x_get_link_status,
2078199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	.set_loopback      = mv88x201x_set_loopback,
20823c3320cb039debfb94b27e8e9bfe26dd47692c3Ben Hutchings	.mmds              = (MDIO_DEVS_PMAPMD | MDIO_DEVS_PCS |
20923c3320cb039debfb94b27e8e9bfe26dd47692c3Ben Hutchings			      MDIO_DEVS_PHYXS | MDIO_DEVS_WIS),
2108199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter};
2118199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter
2128199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameterstatic struct cphy *mv88x201x_phy_create(adapter_t *adapter, int phy_addr,
213459e536b1ddfd217ec8a3437a3214968a98223c7Stephen Hemminger					 const struct mdio_ops *mdio_ops)
2148199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter{
2158199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	u32 val;
2161270266cf94c0de5bd1121f15aff9af8556dee84Stephen Hemminger	struct cphy *cphy = kzalloc(sizeof(*cphy), GFP_KERNEL);
2178199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter
2188199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	if (!cphy)
2198199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter		return NULL;
2201270266cf94c0de5bd1121f15aff9af8556dee84Stephen Hemminger
2218199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	cphy_init(cphy, adapter, phy_addr, &mv88x201x_ops, mdio_ops);
2228199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter
2238199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	/* Commands the PHY to enable XFP's clock. */
22423c3320cb039debfb94b27e8e9bfe26dd47692c3Ben Hutchings	cphy_mdio_read(cphy, MDIO_MMD_PCS, 0x8300, &val);
22523c3320cb039debfb94b27e8e9bfe26dd47692c3Ben Hutchings	cphy_mdio_write(cphy, MDIO_MMD_PCS, 0x8300, val | 1);
2268199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter
2278199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	/* Clear link status. Required because of a bug in the PHY.  */
22823c3320cb039debfb94b27e8e9bfe26dd47692c3Ben Hutchings	cphy_mdio_read(cphy, MDIO_MMD_PMAPMD, MDIO_STAT2, &val);
22923c3320cb039debfb94b27e8e9bfe26dd47692c3Ben Hutchings	cphy_mdio_read(cphy, MDIO_MMD_PCS, MDIO_STAT2, &val);
2308199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter
2318199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	/* Allows for Link,Ack LED turn on/off */
2328199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	led_init(cphy);
2338199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	return cphy;
2348199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter}
2358199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter
2368199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter/* Chip Reset */
2378199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameterstatic int mv88x201x_phy_reset(adapter_t *adapter)
2388199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter{
2398199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	u32 val;
2408199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter
2418199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	t1_tpi_read(adapter, A_ELMER0_GPO, &val);
2428199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	val &= ~4;
2438199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	t1_tpi_write(adapter, A_ELMER0_GPO, val);
2448199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	msleep(100);
2458199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter
2468199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	t1_tpi_write(adapter, A_ELMER0_GPO, val | 4);
2478199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	msleep(1000);
2488199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter
2498199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	/* Now lets enable the Laser. Delay 100us */
2508199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	t1_tpi_read(adapter, A_ELMER0_GPO, &val);
2518199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	val |= 0x8000;
2528199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	t1_tpi_write(adapter, A_ELMER0_GPO, val);
2538199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	udelay(100);
2548199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter	return 0;
2558199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter}
2568199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter
257459e536b1ddfd217ec8a3437a3214968a98223c7Stephen Hemmingerconst struct gphy t1_mv88x201x_ops = {
258459e536b1ddfd217ec8a3437a3214968a98223c7Stephen Hemminger	.create = mv88x201x_phy_create,
259459e536b1ddfd217ec8a3437a3214968a98223c7Stephen Hemminger	.reset = mv88x201x_phy_reset
2608199d3a79c224bbe5943fa08684e1f93a17881b0Christoph Lameter};
261