2005-03-31 01:34:31 +04:00
|
|
|
/*****************************************************************************
|
|
|
|
* *
|
|
|
|
* File: mv88x201x.c *
|
Update Chelsio gige net driver.
- Use extern prefix for functions required.
- Removed a lot of wrappers, including t1_read/write_reg_4.
- Removed various macros, using native kernel calls now.
- Enumerated various #defines.
- Removed a lot of shared code which is not currently used in "NIC only" mode.
- Removed dead code.
Documentation/networking/cxgb.txt:
- Updated release notes for version 2.1.1
drivers/net/chelsio/ch_ethtool.h
- removed file, no longer using ETHTOOL namespace.
drivers/net/chelsio/common.h
- moved code from osdep.h to common.h
- added comment to #endif indicating which symbol it closes.
drivers/net/chelsio/cphy.h
- removed dead code.
- added comment to #endif indicating which symbol it closes.
drivers/net/chelsio/cxgb2.c
- use DMA_{32,64}BIT_MASK in include/linux/dma-mapping.h.
- removed unused code.
- use printk message for link info resembling drivers/net/mii.c.
- no longer using the MODULE_xxx namespace.
- no longer using "pci_" namespace.
- no longer using ETHTOOL namespace.
drivers/net/chelsio/cxgb2.h
- removed file, merged into common.h
drivers/net/chelsio/elmer0.h
- removed dead code.
- added various enums.
- added comment to #endif indicating which symbol it closes.
drivers/net/chelsio/espi.c
- removed various macros, using native kernel calls now.
- removed a lot of wrappers, including t1_read/write_reg_4.
drivers/net/chelsio/espi.h
- added comment to #endif indicating which symbol it closes.
drivers/net/chelsio/gmac.h
- added comment to #endif indicating which symbol it closes.
drivers/net/chelsio/mv88x201x.c
- changes to sync with Chelsio TOT.
drivers/net/chelsio/osdep.h
- removed file, consolidation. osdep was used to translate wrapper functions
since our code supports multiple OSs. removed wrappers.
drivers/net/chelsio/pm3393.c
- removed various macros, using native kernel calls now.
- removed a lot of wrappers, including t1_read/write_reg_4.
- removed unused code.
drivers/net/chelsio/regs.h
- added a few register entries for future and current feature support.
- added comment to #endif indicating which symbol it closes.
drivers/net/chelsio/sge.c
- rewrote large portion of scatter-gather engine to stabilize
performance.
- using u8/u16/u32 kernel types instead of __u8/__u16/__u32 compiler
types.
drivers/net/chelsio/sge.h
- rewrote large portion of scatter-gather engine to stabilize
performance.
- added comment to #endif indicating which symbol it closes.
drivers/net/chelsio/subr.c
- merged tp.c into subr.c
- removed various macros, using native kernel calls now.
- removed a lot of wrappers, including t1_read/write_reg_4.
- removed unused code.
drivers/net/chelsio/suni1x10gexp_regs.h
- modified copyright and authorship of file.
- added comment to #endif indicating which symbol it closes.
drivers/net/chelsio/tp.c
- removed file, merged into subr.c.
drivers/net/chelsio/tp.h
- removed file.
include/linux/pci_ids.h
- patched to include PCI_VENDOR_ID_CHELSIO 0x1425, removed define from
our code.
2005-06-23 09:40:19 +04:00
|
|
|
* $Revision: 1.12 $ *
|
|
|
|
* $Date: 2005/04/15 19:27:14 $ *
|
2005-03-31 01:34:31 +04:00
|
|
|
* Description: *
|
|
|
|
* Marvell PHY (mv88x201x) functionality. *
|
|
|
|
* part of the Chelsio 10Gb Ethernet Driver. *
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License, version 2, as *
|
|
|
|
* published by the Free Software Foundation. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License along *
|
2013-12-06 18:28:43 +04:00
|
|
|
* with this program; if not, see <http://www.gnu.org/licenses/>. *
|
2005-03-31 01:34:31 +04:00
|
|
|
* *
|
|
|
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED *
|
|
|
|
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF *
|
|
|
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. *
|
|
|
|
* *
|
|
|
|
* http://www.chelsio.com *
|
|
|
|
* *
|
|
|
|
* Copyright (c) 2003 - 2005 Chelsio Communications, Inc. *
|
|
|
|
* All rights reserved. *
|
|
|
|
* *
|
|
|
|
* Maintainers: maintainers@chelsio.com *
|
|
|
|
* *
|
|
|
|
* Authors: Dimitrios Michailidis <dm@chelsio.com> *
|
|
|
|
* Tina Yang <tainay@chelsio.com> *
|
|
|
|
* Felix Marti <felix@chelsio.com> *
|
|
|
|
* Scott Bardone <sbardone@chelsio.com> *
|
|
|
|
* Kurt Ottaway <kottaway@chelsio.com> *
|
|
|
|
* Frank DiMambro <frank@chelsio.com> *
|
|
|
|
* *
|
|
|
|
* History: *
|
|
|
|
* *
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include "cphy.h"
|
|
|
|
#include "elmer0.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The 88x2010 Rev C. requires some link status registers * to be read
|
|
|
|
* twice in order to get the right values. Future * revisions will fix
|
|
|
|
* this problem and then this macro * can disappear.
|
|
|
|
*/
|
|
|
|
#define MV88x2010_LINK_STATUS_BUGS 1
|
|
|
|
|
|
|
|
static int led_init(struct cphy *cphy)
|
|
|
|
{
|
|
|
|
/* Setup the LED registers so we can turn on/off.
|
|
|
|
* Writing these bits maps control to another
|
|
|
|
* register. mmd(0x1) addr(0x7)
|
|
|
|
*/
|
2009-04-29 12:06:34 +04:00
|
|
|
cphy_mdio_write(cphy, MDIO_MMD_PCS, 0x8304, 0xdddd);
|
2005-03-31 01:34:31 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int led_link(struct cphy *cphy, u32 do_enable)
|
|
|
|
{
|
|
|
|
u32 led = 0;
|
|
|
|
#define LINK_ENABLE_BIT 0x1
|
|
|
|
|
2009-04-29 12:06:34 +04:00
|
|
|
cphy_mdio_read(cphy, MDIO_MMD_PMAPMD, MDIO_CTRL2, &led);
|
2005-03-31 01:34:31 +04:00
|
|
|
|
|
|
|
if (do_enable & LINK_ENABLE_BIT) {
|
|
|
|
led |= LINK_ENABLE_BIT;
|
2009-04-29 12:06:34 +04:00
|
|
|
cphy_mdio_write(cphy, MDIO_MMD_PMAPMD, MDIO_CTRL2, led);
|
2005-03-31 01:34:31 +04:00
|
|
|
} else {
|
|
|
|
led &= ~LINK_ENABLE_BIT;
|
2009-04-29 12:06:34 +04:00
|
|
|
cphy_mdio_write(cphy, MDIO_MMD_PMAPMD, MDIO_CTRL2, led);
|
2005-03-31 01:34:31 +04:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Port Reset */
|
|
|
|
static int mv88x201x_reset(struct cphy *cphy, int wait)
|
|
|
|
{
|
|
|
|
/* This can be done through registers. It is not required since
|
|
|
|
* a full chip reset is used.
|
|
|
|
*/
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mv88x201x_interrupt_enable(struct cphy *cphy)
|
|
|
|
{
|
|
|
|
/* Enable PHY LASI interrupts. */
|
2009-05-19 17:21:07 +04:00
|
|
|
cphy_mdio_write(cphy, MDIO_MMD_PMAPMD, MDIO_PMA_LASI_CTRL,
|
|
|
|
MDIO_PMA_LASI_LSALARM);
|
2005-03-31 01:34:31 +04:00
|
|
|
|
|
|
|
/* Enable Marvell interrupts through Elmer0. */
|
2006-12-02 03:36:16 +03:00
|
|
|
if (t1_is_asic(cphy->adapter)) {
|
|
|
|
u32 elmer;
|
|
|
|
|
|
|
|
t1_tpi_read(cphy->adapter, A_ELMER0_INT_ENABLE, &elmer);
|
|
|
|
elmer |= ELMER0_GP_BIT6;
|
|
|
|
t1_tpi_write(cphy->adapter, A_ELMER0_INT_ENABLE, elmer);
|
|
|
|
}
|
2005-03-31 01:34:31 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mv88x201x_interrupt_disable(struct cphy *cphy)
|
|
|
|
{
|
|
|
|
/* Disable PHY LASI interrupts. */
|
2009-05-19 17:21:07 +04:00
|
|
|
cphy_mdio_write(cphy, MDIO_MMD_PMAPMD, MDIO_PMA_LASI_CTRL, 0x0);
|
2005-03-31 01:34:31 +04:00
|
|
|
|
|
|
|
/* Disable Marvell interrupts through Elmer0. */
|
2006-12-02 03:36:16 +03:00
|
|
|
if (t1_is_asic(cphy->adapter)) {
|
|
|
|
u32 elmer;
|
|
|
|
|
|
|
|
t1_tpi_read(cphy->adapter, A_ELMER0_INT_ENABLE, &elmer);
|
|
|
|
elmer &= ~ELMER0_GP_BIT6;
|
|
|
|
t1_tpi_write(cphy->adapter, A_ELMER0_INT_ENABLE, elmer);
|
|
|
|
}
|
2005-03-31 01:34:31 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mv88x201x_interrupt_clear(struct cphy *cphy)
|
|
|
|
{
|
|
|
|
u32 elmer;
|
|
|
|
u32 val;
|
|
|
|
|
|
|
|
#ifdef MV88x2010_LINK_STATUS_BUGS
|
|
|
|
/* Required to read twice before clear takes affect. */
|
2009-05-19 17:21:07 +04:00
|
|
|
cphy_mdio_read(cphy, MDIO_MMD_PMAPMD, MDIO_PMA_LASI_RXSTAT, &val);
|
|
|
|
cphy_mdio_read(cphy, MDIO_MMD_PMAPMD, MDIO_PMA_LASI_TXSTAT, &val);
|
|
|
|
cphy_mdio_read(cphy, MDIO_MMD_PMAPMD, MDIO_PMA_LASI_STAT, &val);
|
2005-03-31 01:34:31 +04:00
|
|
|
|
|
|
|
/* Read this register after the others above it else
|
|
|
|
* the register doesn't clear correctly.
|
|
|
|
*/
|
2009-04-29 12:06:34 +04:00
|
|
|
cphy_mdio_read(cphy, MDIO_MMD_PMAPMD, MDIO_STAT1, &val);
|
2005-03-31 01:34:31 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Clear link status. */
|
2009-04-29 12:06:34 +04:00
|
|
|
cphy_mdio_read(cphy, MDIO_MMD_PMAPMD, MDIO_STAT1, &val);
|
2005-03-31 01:34:31 +04:00
|
|
|
/* Clear PHY LASI interrupts. */
|
2009-05-19 17:21:07 +04:00
|
|
|
cphy_mdio_read(cphy, MDIO_MMD_PMAPMD, MDIO_PMA_LASI_STAT, &val);
|
2005-03-31 01:34:31 +04:00
|
|
|
|
|
|
|
#ifdef MV88x2010_LINK_STATUS_BUGS
|
|
|
|
/* Do it again. */
|
2009-05-19 17:21:07 +04:00
|
|
|
cphy_mdio_read(cphy, MDIO_MMD_PMAPMD, MDIO_PMA_LASI_RXSTAT, &val);
|
|
|
|
cphy_mdio_read(cphy, MDIO_MMD_PMAPMD, MDIO_PMA_LASI_TXSTAT, &val);
|
2005-03-31 01:34:31 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Clear Marvell interrupts through Elmer0. */
|
2006-12-02 03:36:16 +03:00
|
|
|
if (t1_is_asic(cphy->adapter)) {
|
|
|
|
t1_tpi_read(cphy->adapter, A_ELMER0_INT_CAUSE, &elmer);
|
|
|
|
elmer |= ELMER0_GP_BIT6;
|
|
|
|
t1_tpi_write(cphy->adapter, A_ELMER0_INT_CAUSE, elmer);
|
|
|
|
}
|
2005-03-31 01:34:31 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mv88x201x_interrupt_handler(struct cphy *cphy)
|
|
|
|
{
|
|
|
|
/* Clear interrupts */
|
|
|
|
mv88x201x_interrupt_clear(cphy);
|
|
|
|
|
|
|
|
/* We have only enabled link change interrupts and so
|
|
|
|
* cphy_cause must be a link change interrupt.
|
|
|
|
*/
|
|
|
|
return cphy_cause_link_change;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mv88x201x_set_loopback(struct cphy *cphy, int on)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mv88x201x_get_link_status(struct cphy *cphy, int *link_ok,
|
|
|
|
int *speed, int *duplex, int *fc)
|
|
|
|
{
|
|
|
|
u32 val = 0;
|
|
|
|
|
|
|
|
if (link_ok) {
|
|
|
|
/* Read link status. */
|
2009-04-29 12:06:34 +04:00
|
|
|
cphy_mdio_read(cphy, MDIO_MMD_PMAPMD, MDIO_STAT1, &val);
|
|
|
|
val &= MDIO_STAT1_LSTATUS;
|
|
|
|
*link_ok = (val == MDIO_STAT1_LSTATUS);
|
2005-03-31 01:34:31 +04:00
|
|
|
/* Turn on/off Link LED */
|
|
|
|
led_link(cphy, *link_ok);
|
|
|
|
}
|
|
|
|
if (speed)
|
|
|
|
*speed = SPEED_10000;
|
|
|
|
if (duplex)
|
|
|
|
*duplex = DUPLEX_FULL;
|
|
|
|
if (fc)
|
|
|
|
*fc = PAUSE_RX | PAUSE_TX;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mv88x201x_destroy(struct cphy *cphy)
|
|
|
|
{
|
|
|
|
kfree(cphy);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct cphy_ops mv88x201x_ops = {
|
|
|
|
.destroy = mv88x201x_destroy,
|
|
|
|
.reset = mv88x201x_reset,
|
|
|
|
.interrupt_enable = mv88x201x_interrupt_enable,
|
|
|
|
.interrupt_disable = mv88x201x_interrupt_disable,
|
|
|
|
.interrupt_clear = mv88x201x_interrupt_clear,
|
|
|
|
.interrupt_handler = mv88x201x_interrupt_handler,
|
|
|
|
.get_link_status = mv88x201x_get_link_status,
|
|
|
|
.set_loopback = mv88x201x_set_loopback,
|
2009-04-29 12:06:34 +04:00
|
|
|
.mmds = (MDIO_DEVS_PMAPMD | MDIO_DEVS_PCS |
|
|
|
|
MDIO_DEVS_PHYXS | MDIO_DEVS_WIS),
|
2005-03-31 01:34:31 +04:00
|
|
|
};
|
|
|
|
|
2009-05-20 19:56:12 +04:00
|
|
|
static struct cphy *mv88x201x_phy_create(struct net_device *dev, int phy_addr,
|
2007-02-21 02:58:02 +03:00
|
|
|
const struct mdio_ops *mdio_ops)
|
2005-03-31 01:34:31 +04:00
|
|
|
{
|
|
|
|
u32 val;
|
2006-12-02 03:36:14 +03:00
|
|
|
struct cphy *cphy = kzalloc(sizeof(*cphy), GFP_KERNEL);
|
2005-03-31 01:34:31 +04:00
|
|
|
|
|
|
|
if (!cphy)
|
|
|
|
return NULL;
|
2006-12-02 03:36:14 +03:00
|
|
|
|
2009-05-20 19:56:12 +04:00
|
|
|
cphy_init(cphy, dev, phy_addr, &mv88x201x_ops, mdio_ops);
|
2005-03-31 01:34:31 +04:00
|
|
|
|
|
|
|
/* Commands the PHY to enable XFP's clock. */
|
2009-04-29 12:06:34 +04:00
|
|
|
cphy_mdio_read(cphy, MDIO_MMD_PCS, 0x8300, &val);
|
|
|
|
cphy_mdio_write(cphy, MDIO_MMD_PCS, 0x8300, val | 1);
|
2005-03-31 01:34:31 +04:00
|
|
|
|
|
|
|
/* Clear link status. Required because of a bug in the PHY. */
|
2009-04-29 12:06:34 +04:00
|
|
|
cphy_mdio_read(cphy, MDIO_MMD_PMAPMD, MDIO_STAT2, &val);
|
|
|
|
cphy_mdio_read(cphy, MDIO_MMD_PCS, MDIO_STAT2, &val);
|
2005-03-31 01:34:31 +04:00
|
|
|
|
|
|
|
/* Allows for Link,Ack LED turn on/off */
|
|
|
|
led_init(cphy);
|
|
|
|
return cphy;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Chip Reset */
|
|
|
|
static int mv88x201x_phy_reset(adapter_t *adapter)
|
|
|
|
{
|
|
|
|
u32 val;
|
|
|
|
|
|
|
|
t1_tpi_read(adapter, A_ELMER0_GPO, &val);
|
|
|
|
val &= ~4;
|
|
|
|
t1_tpi_write(adapter, A_ELMER0_GPO, val);
|
|
|
|
msleep(100);
|
|
|
|
|
|
|
|
t1_tpi_write(adapter, A_ELMER0_GPO, val | 4);
|
|
|
|
msleep(1000);
|
|
|
|
|
|
|
|
/* Now lets enable the Laser. Delay 100us */
|
|
|
|
t1_tpi_read(adapter, A_ELMER0_GPO, &val);
|
|
|
|
val |= 0x8000;
|
|
|
|
t1_tpi_write(adapter, A_ELMER0_GPO, val);
|
|
|
|
udelay(100);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-02-21 02:58:02 +03:00
|
|
|
const struct gphy t1_mv88x201x_ops = {
|
|
|
|
.create = mv88x201x_phy_create,
|
|
|
|
.reset = mv88x201x_phy_reset
|
2005-03-31 01:34:31 +04:00
|
|
|
};
|