aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Carlson <mcarlson@broadcom.com>2008-05-26 02:49:44 -0400
committerDavid S. Miller <davem@davemloft.net>2008-05-29 04:38:46 -0400
commita9daf36746b1fb5c2db8d164ca70c30c63a0d7b2 (patch)
tree766a1f2ce9925b1d409a8d55fa26a953c2f3da31
parent57e6983cbde91b4569b4014b933f3a16e12b99fd (diff)
tg3: Add shmem options.
This patch adds some options obtained through shared memory. Signed-off-by: Matt Carlson <mcarlson@broadcom.com> Signed-off-by: Michael Chan <mchan@broadcom.com> Signed-off-by: Benjamin Li <benli@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/tg3.c95
-rw-r--r--drivers/net/tg3.h30
-rw-r--r--include/linux/brcmphy.h6
3 files changed, 123 insertions, 8 deletions
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 69ded90cd96e..365fcffc3144 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -33,6 +33,7 @@
33#include <linux/ethtool.h> 33#include <linux/ethtool.h>
34#include <linux/mii.h> 34#include <linux/mii.h>
35#include <linux/phy.h> 35#include <linux/phy.h>
36#include <linux/brcmphy.h>
36#include <linux/if_vlan.h> 37#include <linux/if_vlan.h>
37#include <linux/ip.h> 38#include <linux/ip.h>
38#include <linux/tcp.h> 39#include <linux/tcp.h>
@@ -869,6 +870,51 @@ static int tg3_mdio_reset(struct mii_bus *bp)
869 return 0; 870 return 0;
870} 871}
871 872
873static void tg3_mdio_config(struct tg3 *tp)
874{
875 u32 val;
876
877 if (tp->mdio_bus.phy_map[PHY_ADDR]->interface !=
878 PHY_INTERFACE_MODE_RGMII)
879 return;
880
881 val = tr32(MAC_PHYCFG1) & ~(MAC_PHYCFG1_RGMII_EXT_RX_DEC |
882 MAC_PHYCFG1_RGMII_SND_STAT_EN);
883 if (tp->tg3_flags3 & TG3_FLG3_RGMII_STD_IBND_DISABLE) {
884 if (tp->tg3_flags3 & TG3_FLG3_RGMII_EXT_IBND_RX_EN)
885 val |= MAC_PHYCFG1_RGMII_EXT_RX_DEC;
886 if (tp->tg3_flags3 & TG3_FLG3_RGMII_EXT_IBND_TX_EN)
887 val |= MAC_PHYCFG1_RGMII_SND_STAT_EN;
888 }
889 tw32(MAC_PHYCFG1, val | MAC_PHYCFG1_RGMII_INT | MAC_PHYCFG1_TXC_DRV);
890
891 val = tr32(MAC_PHYCFG2) & ~(MAC_PHYCFG2_INBAND_ENABLE);
892 if (!(tp->tg3_flags3 & TG3_FLG3_RGMII_STD_IBND_DISABLE))
893 val |= MAC_PHYCFG2_INBAND_ENABLE;
894 tw32(MAC_PHYCFG2, val);
895
896 val = tr32(MAC_EXT_RGMII_MODE);
897 val &= ~(MAC_RGMII_MODE_RX_INT_B |
898 MAC_RGMII_MODE_RX_QUALITY |
899 MAC_RGMII_MODE_RX_ACTIVITY |
900 MAC_RGMII_MODE_RX_ENG_DET |
901 MAC_RGMII_MODE_TX_ENABLE |
902 MAC_RGMII_MODE_TX_LOWPWR |
903 MAC_RGMII_MODE_TX_RESET);
904 if (tp->tg3_flags3 & TG3_FLG3_RGMII_STD_IBND_DISABLE) {
905 if (tp->tg3_flags3 & TG3_FLG3_RGMII_EXT_IBND_RX_EN)
906 val |= MAC_RGMII_MODE_RX_INT_B |
907 MAC_RGMII_MODE_RX_QUALITY |
908 MAC_RGMII_MODE_RX_ACTIVITY |
909 MAC_RGMII_MODE_RX_ENG_DET;
910 if (tp->tg3_flags3 & TG3_FLG3_RGMII_EXT_IBND_TX_EN)
911 val |= MAC_RGMII_MODE_TX_ENABLE |
912 MAC_RGMII_MODE_TX_LOWPWR |
913 MAC_RGMII_MODE_TX_RESET;
914 }
915 tw32(MAC_EXT_RGMII_MODE, val);
916}
917
872static void tg3_mdio_start(struct tg3 *tp) 918static void tg3_mdio_start(struct tg3 *tp)
873{ 919{
874 if (tp->tg3_flags3 & TG3_FLG3_MDIOBUS_INITED) { 920 if (tp->tg3_flags3 & TG3_FLG3_MDIOBUS_INITED) {
@@ -880,6 +926,9 @@ static void tg3_mdio_start(struct tg3 *tp)
880 tp->mi_mode &= ~MAC_MI_MODE_AUTO_POLL; 926 tp->mi_mode &= ~MAC_MI_MODE_AUTO_POLL;
881 tw32_f(MAC_MI_MODE, tp->mi_mode); 927 tw32_f(MAC_MI_MODE, tp->mi_mode);
882 udelay(80); 928 udelay(80);
929
930 if (tp->tg3_flags3 & TG3_FLG3_MDIOBUS_INITED)
931 tg3_mdio_config(tp);
883} 932}
884 933
885static void tg3_mdio_stop(struct tg3 *tp) 934static void tg3_mdio_stop(struct tg3 *tp)
@@ -895,6 +944,7 @@ static int tg3_mdio_init(struct tg3 *tp)
895{ 944{
896 int i; 945 int i;
897 u32 reg; 946 u32 reg;
947 struct phy_device *phydev;
898 struct mii_bus *mdio_bus = &tp->mdio_bus; 948 struct mii_bus *mdio_bus = &tp->mdio_bus;
899 949
900 tg3_mdio_start(tp); 950 tg3_mdio_start(tp);
@@ -928,13 +978,34 @@ static int tg3_mdio_init(struct tg3 *tp)
928 tg3_bmcr_reset(tp); 978 tg3_bmcr_reset(tp);
929 979
930 i = mdiobus_register(mdio_bus); 980 i = mdiobus_register(mdio_bus);
931 if (!i) 981 if (i) {
932 tp->tg3_flags3 |= TG3_FLG3_MDIOBUS_INITED;
933 else
934 printk(KERN_WARNING "%s: mdiobus_reg failed (0x%x)\n", 982 printk(KERN_WARNING "%s: mdiobus_reg failed (0x%x)\n",
935 tp->dev->name, i); 983 tp->dev->name, i);
984 return i;
985 }
936 986
937 return i; 987 tp->tg3_flags3 |= TG3_FLG3_MDIOBUS_INITED;
988
989 phydev = tp->mdio_bus.phy_map[PHY_ADDR];
990
991 switch (phydev->phy_id) {
992 case TG3_PHY_ID_BCM50610:
993 phydev->interface = PHY_INTERFACE_MODE_RGMII;
994 if (tp->tg3_flags3 & TG3_FLG3_RGMII_STD_IBND_DISABLE)
995 phydev->dev_flags |= PHY_BRCM_STD_IBND_DISABLE;
996 if (tp->tg3_flags3 & TG3_FLG3_RGMII_EXT_IBND_RX_EN)
997 phydev->dev_flags |= PHY_BRCM_EXT_IBND_RX_ENABLE;
998 if (tp->tg3_flags3 & TG3_FLG3_RGMII_EXT_IBND_TX_EN)
999 phydev->dev_flags |= PHY_BRCM_EXT_IBND_TX_ENABLE;
1000 break;
1001 case TG3_PHY_ID_BCMAC131:
1002 phydev->interface = PHY_INTERFACE_MODE_MII;
1003 break;
1004 }
1005
1006 tg3_mdio_config(tp);
1007
1008 return 0;
938} 1009}
939 1010
940static void tg3_mdio_fini(struct tg3 *tp) 1011static void tg3_mdio_fini(struct tg3 *tp)
@@ -1238,8 +1309,8 @@ static int tg3_phy_init(struct tg3 *tp)
1238 phydev = tp->mdio_bus.phy_map[PHY_ADDR]; 1309 phydev = tp->mdio_bus.phy_map[PHY_ADDR];
1239 1310
1240 /* Attach the MAC to the PHY. */ 1311 /* Attach the MAC to the PHY. */
1241 phydev = phy_connect(tp->dev, phydev->dev.bus_id, 1312 phydev = phy_connect(tp->dev, phydev->dev.bus_id, tg3_adjust_link,
1242 tg3_adjust_link, 0, phydev->interface); 1313 phydev->dev_flags, phydev->interface);
1243 if (IS_ERR(phydev)) { 1314 if (IS_ERR(phydev)) {
1244 printk(KERN_ERR "%s: Could not attach to PHY\n", tp->dev->name); 1315 printk(KERN_ERR "%s: Could not attach to PHY\n", tp->dev->name);
1245 return PTR_ERR(phydev); 1316 return PTR_ERR(phydev);
@@ -11219,7 +11290,7 @@ static void __devinit tg3_get_eeprom_hw_cfg(struct tg3 *tp)
11219 tg3_read_mem(tp, NIC_SRAM_DATA_SIG, &val); 11290 tg3_read_mem(tp, NIC_SRAM_DATA_SIG, &val);
11220 if (val == NIC_SRAM_DATA_SIG_MAGIC) { 11291 if (val == NIC_SRAM_DATA_SIG_MAGIC) {
11221 u32 nic_cfg, led_cfg; 11292 u32 nic_cfg, led_cfg;
11222 u32 nic_phy_id, ver, cfg2 = 0, eeprom_phy_id; 11293 u32 nic_phy_id, ver, cfg2 = 0, cfg4 = 0, eeprom_phy_id;
11223 int eeprom_phy_serdes = 0; 11294 int eeprom_phy_serdes = 0;
11224 11295
11225 tg3_read_mem(tp, NIC_SRAM_DATA_CFG, &nic_cfg); 11296 tg3_read_mem(tp, NIC_SRAM_DATA_CFG, &nic_cfg);
@@ -11233,6 +11304,9 @@ static void __devinit tg3_get_eeprom_hw_cfg(struct tg3 *tp)
11233 (ver > 0) && (ver < 0x100)) 11304 (ver > 0) && (ver < 0x100))
11234 tg3_read_mem(tp, NIC_SRAM_DATA_CFG_2, &cfg2); 11305 tg3_read_mem(tp, NIC_SRAM_DATA_CFG_2, &cfg2);
11235 11306
11307 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5785)
11308 tg3_read_mem(tp, NIC_SRAM_DATA_CFG_4, &cfg4);
11309
11236 if ((nic_cfg & NIC_SRAM_DATA_CFG_PHY_TYPE_MASK) == 11310 if ((nic_cfg & NIC_SRAM_DATA_CFG_PHY_TYPE_MASK) ==
11237 NIC_SRAM_DATA_CFG_PHY_TYPE_FIBER) 11311 NIC_SRAM_DATA_CFG_PHY_TYPE_FIBER)
11238 eeprom_phy_serdes = 1; 11312 eeprom_phy_serdes = 1;
@@ -11357,6 +11431,13 @@ static void __devinit tg3_get_eeprom_hw_cfg(struct tg3 *tp)
11357 if (cfg3 & NIC_SRAM_ASPM_DEBOUNCE) 11431 if (cfg3 & NIC_SRAM_ASPM_DEBOUNCE)
11358 tp->tg3_flags |= TG3_FLAG_ASPM_WORKAROUND; 11432 tp->tg3_flags |= TG3_FLAG_ASPM_WORKAROUND;
11359 } 11433 }
11434
11435 if (cfg4 & NIC_SRAM_RGMII_STD_IBND_DISABLE)
11436 tp->tg3_flags3 |= TG3_FLG3_RGMII_STD_IBND_DISABLE;
11437 if (cfg4 & NIC_SRAM_RGMII_EXT_IBND_RX_EN)
11438 tp->tg3_flags3 |= TG3_FLG3_RGMII_EXT_IBND_RX_EN;
11439 if (cfg4 & NIC_SRAM_RGMII_EXT_IBND_TX_EN)
11440 tp->tg3_flags3 |= TG3_FLG3_RGMII_EXT_IBND_TX_EN;
11360 } 11441 }
11361} 11442}
11362 11443
diff --git a/drivers/net/tg3.h b/drivers/net/tg3.h
index 95ac4c9590a1..df07842172b7 100644
--- a/drivers/net/tg3.h
+++ b/drivers/net/tg3.h
@@ -529,7 +529,23 @@
529#define MAC_SERDES_CFG 0x00000590 529#define MAC_SERDES_CFG 0x00000590
530#define MAC_SERDES_CFG_EDGE_SELECT 0x00001000 530#define MAC_SERDES_CFG_EDGE_SELECT 0x00001000
531#define MAC_SERDES_STAT 0x00000594 531#define MAC_SERDES_STAT 0x00000594
532/* 0x598 --> 0x5b0 unused */ 532/* 0x598 --> 0x5a0 unused */
533#define MAC_PHYCFG1 0x000005a0
534#define MAC_PHYCFG1_RGMII_INT 0x00000001
535#define MAC_PHYCFG1_RGMII_EXT_RX_DEC 0x02000000
536#define MAC_PHYCFG1_RGMII_SND_STAT_EN 0x04000000
537#define MAC_PHYCFG1_TXC_DRV 0x20000000
538#define MAC_PHYCFG2 0x000005a4
539#define MAC_PHYCFG2_INBAND_ENABLE 0x00000001
540#define MAC_EXT_RGMII_MODE 0x000005a8
541#define MAC_RGMII_MODE_TX_ENABLE 0x00000001
542#define MAC_RGMII_MODE_TX_LOWPWR 0x00000002
543#define MAC_RGMII_MODE_TX_RESET 0x00000004
544#define MAC_RGMII_MODE_RX_INT_B 0x00000100
545#define MAC_RGMII_MODE_RX_QUALITY 0x00000200
546#define MAC_RGMII_MODE_RX_ACTIVITY 0x00000400
547#define MAC_RGMII_MODE_RX_ENG_DET 0x00000800
548/* 0x5ac --> 0x5b0 unused */
533#define SERDES_RX_CTRL 0x000005b0 /* 5780/5714 only */ 549#define SERDES_RX_CTRL 0x000005b0 /* 5780/5714 only */
534#define SERDES_RX_SIG_DETECT 0x00000400 550#define SERDES_RX_SIG_DETECT 0x00000400
535#define SG_DIG_CTRL 0x000005b0 551#define SG_DIG_CTRL 0x000005b0
@@ -1715,6 +1731,12 @@
1715#define NIC_SRAM_DATA_CFG_3 0x00000d3c 1731#define NIC_SRAM_DATA_CFG_3 0x00000d3c
1716#define NIC_SRAM_ASPM_DEBOUNCE 0x00000002 1732#define NIC_SRAM_ASPM_DEBOUNCE 0x00000002
1717 1733
1734#define NIC_SRAM_DATA_CFG_4 0x00000d60
1735#define NIC_SRAM_GMII_MODE 0x00000002
1736#define NIC_SRAM_RGMII_STD_IBND_DISABLE 0x00000004
1737#define NIC_SRAM_RGMII_EXT_IBND_RX_EN 0x00000008
1738#define NIC_SRAM_RGMII_EXT_IBND_TX_EN 0x00000010
1739
1718#define NIC_SRAM_RX_MINI_BUFFER_DESC 0x00001000 1740#define NIC_SRAM_RX_MINI_BUFFER_DESC 0x00001000
1719 1741
1720#define NIC_SRAM_DMA_DESC_POOL_BASE 0x00002000 1742#define NIC_SRAM_DMA_DESC_POOL_BASE 0x00002000
@@ -2486,6 +2508,9 @@ struct tg3 {
2486#define TG3_FLG3_MDIOBUS_INITED 0x00000020 2508#define TG3_FLG3_MDIOBUS_INITED 0x00000020
2487#define TG3_FLG3_MDIOBUS_PAUSED 0x00000040 2509#define TG3_FLG3_MDIOBUS_PAUSED 0x00000040
2488#define TG3_FLG3_PHY_CONNECTED 0x00000080 2510#define TG3_FLG3_PHY_CONNECTED 0x00000080
2511#define TG3_FLG3_RGMII_STD_IBND_DISABLE 0x00000100
2512#define TG3_FLG3_RGMII_EXT_IBND_RX_EN 0x00000200
2513#define TG3_FLG3_RGMII_EXT_IBND_TX_EN 0x00000400
2489 2514
2490 struct timer_list timer; 2515 struct timer_list timer;
2491 u16 timer_counter; 2516 u16 timer_counter;
@@ -2556,6 +2581,9 @@ struct tg3 {
2556#define PHY_REV_BCM5401_B2 0x3 2581#define PHY_REV_BCM5401_B2 0x3
2557#define PHY_REV_BCM5401_C0 0x6 2582#define PHY_REV_BCM5401_C0 0x6
2558#define PHY_REV_BCM5411_X0 0x1 /* Found on Netgear GA302T */ 2583#define PHY_REV_BCM5411_X0 0x1 /* Found on Netgear GA302T */
2584#define TG3_PHY_ID_BCM50610 0x143bd60
2585#define TG3_PHY_ID_BCMAC131 0x143bc70
2586
2559 2587
2560 u32 led_ctrl; 2588 u32 led_ctrl;
2561 u32 phy_otp; 2589 u32 phy_otp;
diff --git a/include/linux/brcmphy.h b/include/linux/brcmphy.h
new file mode 100644
index 000000000000..9b64b6d67873
--- /dev/null
+++ b/include/linux/brcmphy.h
@@ -0,0 +1,6 @@
1#define PHY_BRCM_WIRESPEED_ENABLE 0x00000001
2#define PHY_BRCM_AUTO_PWRDWN_ENABLE 0x00000002
3#define PHY_BRCM_APD_CLK125_ENABLE 0x00000004
4#define PHY_BRCM_STD_IBND_DISABLE 0x00000008
5#define PHY_BRCM_EXT_IBND_RX_ENABLE 0x00000010
6#define PHY_BRCM_EXT_IBND_TX_ENABLE 0x00000020