aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/cxgb3/common.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/cxgb3/common.h')
-rw-r--r--drivers/net/cxgb3/common.h67
1 files changed, 27 insertions, 40 deletions
diff --git a/drivers/net/cxgb3/common.h b/drivers/net/cxgb3/common.h
index e508dc32f3ec..d21b705501a9 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,27 +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 */
535enum {
536 RX_ALARM_CTRL = 0x9000,
537 TX_ALARM_CTRL = 0x9001,
538 LASI_CTRL = 0x9002,
539 RX_ALARM_STAT = 0x9003,
540 TX_ALARM_STAT = 0x9004,
541 LASI_STAT = 0x9005
542};
543
544/* PHY loopback direction */ 524/* PHY loopback direction */
545enum { 525enum {
546 PHY_LOOPBACK_TX = 1, 526 PHY_LOOPBACK_TX = 1,
@@ -583,11 +563,12 @@ struct cphy_ops {
583 int (*get_link_status)(struct cphy *phy, int *link_ok, int *speed, 563 int (*get_link_status)(struct cphy *phy, int *link_ok, int *speed,
584 int *duplex, int *fc); 564 int *duplex, int *fc);
585 int (*power_down)(struct cphy *phy, int enable); 565 int (*power_down)(struct cphy *phy, int enable);
566
567 u32 mmds;
586}; 568};
587 569
588/* A PHY instance */ 570/* A PHY instance */
589struct cphy { 571struct cphy {
590 u8 addr; /* PHY address */
591 u8 modtype; /* PHY module type */ 572 u8 modtype; /* PHY module type */
592 short priv; /* scratch pad */ 573 short priv; /* scratch pad */
593 unsigned int caps; /* PHY capabilities */ 574 unsigned int caps; /* PHY capabilities */
@@ -595,23 +576,23 @@ struct cphy {
595 const char *desc; /* PHY description */ 576 const char *desc; /* PHY description */
596 unsigned long fifo_errors; /* FIFO over/under-flows */ 577 unsigned long fifo_errors; /* FIFO over/under-flows */
597 const struct cphy_ops *ops; /* PHY operations */ 578 const struct cphy_ops *ops; /* PHY operations */
598 int (*mdio_read)(struct adapter *adapter, int phy_addr, int mmd_addr, 579 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}; 580};
603 581
604/* Convenience MDIO read/write wrappers */ 582/* Convenience MDIO read/write wrappers */
605static inline int mdio_read(struct cphy *phy, int mmd, int reg, 583static inline int t3_mdio_read(struct cphy *phy, int mmd, int reg,
606 unsigned int *valp) 584 unsigned int *valp)
607{ 585{
608 return phy->mdio_read(phy->adapter, phy->addr, mmd, reg, valp); 586 int rc = phy->mdio.mdio_read(phy->mdio.dev, phy->mdio.prtad, mmd, reg);
587 *valp = (rc >= 0) ? rc : -1;
588 return (rc >= 0) ? 0 : rc;
609} 589}
610 590
611static inline int mdio_write(struct cphy *phy, int mmd, int reg, 591static inline int t3_mdio_write(struct cphy *phy, int mmd, int reg,
612 unsigned int val) 592 unsigned int val)
613{ 593{
614 return phy->mdio_write(phy->adapter, phy->addr, mmd, reg, val); 594 return phy->mdio.mdio_write(phy->mdio.dev, phy->mdio.prtad, mmd,
595 reg, val);
615} 596}
616 597
617/* Convenience initializer */ 598/* Convenience initializer */
@@ -620,14 +601,16 @@ static inline void cphy_init(struct cphy *phy, struct adapter *adapter,
620 const struct mdio_ops *mdio_ops, 601 const struct mdio_ops *mdio_ops,
621 unsigned int caps, const char *desc) 602 unsigned int caps, const char *desc)
622{ 603{
623 phy->addr = phy_addr;
624 phy->caps = caps; 604 phy->caps = caps;
625 phy->adapter = adapter; 605 phy->adapter = adapter;
626 phy->desc = desc; 606 phy->desc = desc;
627 phy->ops = phy_ops; 607 phy->ops = phy_ops;
628 if (mdio_ops) { 608 if (mdio_ops) {
629 phy->mdio_read = mdio_ops->read; 609 phy->mdio.prtad = phy_addr;
630 phy->mdio_write = mdio_ops->write; 610 phy->mdio.mmds = phy_ops->mmds;
611 phy->mdio.mode_support = mdio_ops->mode_support;
612 phy->mdio.mdio_read = mdio_ops->read;
613 phy->mdio.mdio_write = mdio_ops->write;
631 } 614 }
632} 615}
633 616
@@ -819,8 +802,12 @@ int t3_ael1006_phy_prep(struct cphy *phy, struct adapter *adapter,
819 int phy_addr, const struct mdio_ops *mdio_ops); 802 int phy_addr, const struct mdio_ops *mdio_ops);
820int t3_ael2005_phy_prep(struct cphy *phy, struct adapter *adapter, 803int t3_ael2005_phy_prep(struct cphy *phy, struct adapter *adapter,
821 int phy_addr, const struct mdio_ops *mdio_ops); 804 int phy_addr, const struct mdio_ops *mdio_ops);
805int t3_ael2020_phy_prep(struct cphy *phy, struct adapter *adapter,
806 int phy_addr, const struct mdio_ops *mdio_ops);
822int t3_qt2045_phy_prep(struct cphy *phy, struct adapter *adapter, int phy_addr, 807int t3_qt2045_phy_prep(struct cphy *phy, struct adapter *adapter, int phy_addr,
823 const struct mdio_ops *mdio_ops); 808 const struct mdio_ops *mdio_ops);
824int t3_xaui_direct_phy_prep(struct cphy *phy, struct adapter *adapter, 809int t3_xaui_direct_phy_prep(struct cphy *phy, struct adapter *adapter,
825 int phy_addr, const struct mdio_ops *mdio_ops); 810 int phy_addr, const struct mdio_ops *mdio_ops);
811int t3_aq100x_phy_prep(struct cphy *phy, struct adapter *adapter,
812 int phy_addr, const struct mdio_ops *mdio_ops);
826#endif /* __CHELSIO_COMMON_H */ 813#endif /* __CHELSIO_COMMON_H */