aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/cxgb3/common.h
diff options
context:
space:
mode:
authorBen Hutchings <bhutchings@solarflare.com>2009-04-29 04:07:20 -0400
committerDavid S. Miller <davem@davemloft.net>2009-04-29 20:32:32 -0400
commit0f07c4ee8c800923ae7918c231532a9256233eed (patch)
tree659322e8607f681af12a43671b17c5b65f94f4d5 /drivers/net/cxgb3/common.h
parent23c3320cb039debfb94b27e8e9bfe26dd47692c3 (diff)
cxgb3: Use generic MDIO definitions and mdio_mii_ioctl()
Compile-tested only. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/cxgb3/common.h')
-rw-r--r--drivers/net/cxgb3/common.h53
1 files changed, 23 insertions, 30 deletions
diff --git a/drivers/net/cxgb3/common.h b/drivers/net/cxgb3/common.h
index e508dc32f3ec..3147789aecec 100644
--- a/drivers/net/cxgb3/common.h
+++ b/drivers/net/cxgb3/common.h
@@ -39,7 +39,7 @@
39#include <linux/init.h> 39#include <linux/init.h>
40#include <linux/netdevice.h> 40#include <linux/netdevice.h>
41#include <linux/ethtool.h> 41#include <linux/ethtool.h>
42#include <linux/mii.h> 42#include <linux/mdio.h>
43#include "version.h" 43#include "version.h"
44 44
45#define CH_ERR(adap, fmt, ...) dev_err(&adap->pdev->dev, fmt, ## __VA_ARGS__) 45#define CH_ERR(adap, fmt, ...) dev_err(&adap->pdev->dev, fmt, ## __VA_ARGS__)
@@ -184,10 +184,11 @@ struct cphy;
184struct adapter; 184struct adapter;
185 185
186struct mdio_ops { 186struct mdio_ops {
187 int (*read)(struct adapter *adapter, int phy_addr, int mmd_addr, 187 int (*read)(struct net_device *dev, int phy_addr, int mmd_addr,
188 int reg_addr, unsigned int *val); 188 u16 reg_addr);
189 int (*write)(struct adapter *adapter, int phy_addr, int mmd_addr, 189 int (*write)(struct net_device *dev, int phy_addr, int mmd_addr,
190 int reg_addr, unsigned int val); 190 u16 reg_addr, u16 val);
191 unsigned mode_support;
191}; 192};
192 193
193struct adapter_info { 194struct adapter_info {
@@ -520,17 +521,6 @@ enum {
520 MAC_RXFIFO_SIZE = 32768 521 MAC_RXFIFO_SIZE = 32768
521}; 522};
522 523
523/* IEEE 802.3 specified MDIO devices */
524enum {
525 MDIO_DEV_PMA_PMD = 1,
526 MDIO_DEV_WIS = 2,
527 MDIO_DEV_PCS = 3,
528 MDIO_DEV_XGXS = 4,
529 MDIO_DEV_ANEG = 7,
530 MDIO_DEV_VEND1 = 30,
531 MDIO_DEV_VEND2 = 31
532};
533
534/* LASI control and status registers */ 524/* LASI control and status registers */
535enum { 525enum {
536 RX_ALARM_CTRL = 0x9000, 526 RX_ALARM_CTRL = 0x9000,
@@ -583,11 +573,12 @@ struct cphy_ops {
583 int (*get_link_status)(struct cphy *phy, int *link_ok, int *speed, 573 int (*get_link_status)(struct cphy *phy, int *link_ok, int *speed,
584 int *duplex, int *fc); 574 int *duplex, int *fc);
585 int (*power_down)(struct cphy *phy, int enable); 575 int (*power_down)(struct cphy *phy, int enable);
576
577 u32 mmds;
586}; 578};
587 579
588/* A PHY instance */ 580/* A PHY instance */
589struct cphy { 581struct cphy {
590 u8 addr; /* PHY address */
591 u8 modtype; /* PHY module type */ 582 u8 modtype; /* PHY module type */
592 short priv; /* scratch pad */ 583 short priv; /* scratch pad */
593 unsigned int caps; /* PHY capabilities */ 584 unsigned int caps; /* PHY capabilities */
@@ -595,23 +586,23 @@ struct cphy {
595 const char *desc; /* PHY description */ 586 const char *desc; /* PHY description */
596 unsigned long fifo_errors; /* FIFO over/under-flows */ 587 unsigned long fifo_errors; /* FIFO over/under-flows */
597 const struct cphy_ops *ops; /* PHY operations */ 588 const struct cphy_ops *ops; /* PHY operations */
598 int (*mdio_read)(struct adapter *adapter, int phy_addr, int mmd_addr, 589 struct mdio_if_info mdio;
599 int reg_addr, unsigned int *val);
600 int (*mdio_write)(struct adapter *adapter, int phy_addr, int mmd_addr,
601 int reg_addr, unsigned int val);
602}; 590};
603 591
604/* Convenience MDIO read/write wrappers */ 592/* Convenience MDIO read/write wrappers */
605static inline int mdio_read(struct cphy *phy, int mmd, int reg, 593static inline int t3_mdio_read(struct cphy *phy, int mmd, int reg,
606 unsigned int *valp) 594 unsigned int *valp)
607{ 595{
608 return phy->mdio_read(phy->adapter, phy->addr, mmd, reg, valp); 596 int rc = phy->mdio.mdio_read(phy->mdio.dev, phy->mdio.prtad, mmd, reg);
597 *valp = (rc >= 0) ? rc : -1;
598 return (rc >= 0) ? 0 : rc;
609} 599}
610 600
611static inline int mdio_write(struct cphy *phy, int mmd, int reg, 601static inline int t3_mdio_write(struct cphy *phy, int mmd, int reg,
612 unsigned int val) 602 unsigned int val)
613{ 603{
614 return phy->mdio_write(phy->adapter, phy->addr, mmd, reg, val); 604 return phy->mdio.mdio_write(phy->mdio.dev, phy->mdio.prtad, mmd,
605 reg, val);
615} 606}
616 607
617/* Convenience initializer */ 608/* Convenience initializer */
@@ -620,14 +611,16 @@ static inline void cphy_init(struct cphy *phy, struct adapter *adapter,
620 const struct mdio_ops *mdio_ops, 611 const struct mdio_ops *mdio_ops,
621 unsigned int caps, const char *desc) 612 unsigned int caps, const char *desc)
622{ 613{
623 phy->addr = phy_addr;
624 phy->caps = caps; 614 phy->caps = caps;
625 phy->adapter = adapter; 615 phy->adapter = adapter;
626 phy->desc = desc; 616 phy->desc = desc;
627 phy->ops = phy_ops; 617 phy->ops = phy_ops;
628 if (mdio_ops) { 618 if (mdio_ops) {
629 phy->mdio_read = mdio_ops->read; 619 phy->mdio.prtad = phy_addr;
630 phy->mdio_write = mdio_ops->write; 620 phy->mdio.mmds = phy_ops->mmds;
621 phy->mdio.mode_support = mdio_ops->mode_support;
622 phy->mdio.mdio_read = mdio_ops->read;
623 phy->mdio.mdio_write = mdio_ops->write;
631 } 624 }
632} 625}
633 626