|
| 1 | +diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c |
| 2 | +index 70bd79d..1855f74 100644 |
| 3 | +--- a/drivers/net/ethernet/broadcom/tg3.c |
| 4 | ++++ b/drivers/net/ethernet/broadcom/tg3.c |
| 5 | +@@ -66,6 +66,9 @@ |
| 6 | + #include <uapi/linux/net_tstamp.h> |
| 7 | + #include <linux/ptp_clock_kernel.h> |
| 8 | + |
| 9 | ++static int bid = 0; |
| 10 | ++#include <linux/i2c.h> |
| 11 | ++ |
| 12 | + #define BAR_0 0 |
| 13 | + #define BAR_2 2 |
| 14 | + |
| 15 | +@@ -1497,6 +1500,7 @@ static void tg3_mdio_config_5785(struct tg3 *tp) |
| 16 | + static void tg3_mdio_start(struct tg3 *tp) |
| 17 | + { |
| 18 | + tp->mi_mode &= ~MAC_MI_MODE_AUTO_POLL; |
| 19 | ++ tp->mi_mode |= MAC_MI_MODE_SHORT_PREAMBLE; |
| 20 | + tw32_f(MAC_MI_MODE, tp->mi_mode); |
| 21 | + udelay(80); |
| 22 | + |
| 23 | +@@ -11726,6 +11730,52 @@ static void tg3_stop(struct tg3 *tp) |
| 24 | + tg3_free_consistent(tp); |
| 25 | + } |
| 26 | + |
| 27 | ++static int tg3_get_board_id(struct net_device *dev) |
| 28 | ++{ |
| 29 | ++ struct tg3 *tp = netdev_priv(dev); |
| 30 | ++ struct i2c_client *client; |
| 31 | ++ struct i2c_adapter * i2cadap; |
| 32 | ++ int rc, i2caddr; |
| 33 | ++ |
| 34 | ++ /* bus 0 */ |
| 35 | ++ i2cadap = i2c_get_adapter(0); |
| 36 | ++ |
| 37 | ++ /* 0x77[0] = 1 */ |
| 38 | ++ i2caddr = 0x77; |
| 39 | ++ client = i2c_new_dummy(i2cadap, i2caddr); |
| 40 | ++ if (client == NULL) |
| 41 | ++ goto err; |
| 42 | ++ |
| 43 | ++ i2c_smbus_write_byte_data(client, 0x00, 1); |
| 44 | ++ i2c_unregister_device(client); |
| 45 | ++ |
| 46 | ++ /* 0x76[0] = 4 */ |
| 47 | ++ i2caddr = 0x76; |
| 48 | ++ client = i2c_new_dummy(i2cadap, i2caddr); |
| 49 | ++ if (client == NULL) |
| 50 | ++ goto err; |
| 51 | ++ |
| 52 | ++ i2c_smbus_write_byte_data(client, 0x00, 4); |
| 53 | ++ i2c_unregister_device(client); |
| 54 | ++ |
| 55 | ++ /* read CPLD1 0x60[0] */ |
| 56 | ++ i2caddr = 0x60; |
| 57 | ++ client = i2c_new_dummy(i2cadap, i2caddr); |
| 58 | ++ if (client == NULL) |
| 59 | ++ goto err; |
| 60 | ++ |
| 61 | ++ rc = i2c_smbus_read_byte_data(client, 0x00); |
| 62 | ++ i2c_unregister_device(client); |
| 63 | ++ |
| 64 | ++ netdev_notice(tp->dev, "CPLD1(%#x) offset 0 = %#x\n", i2caddr, rc); |
| 65 | ++ rc = (rc >> 2) & 0x03; |
| 66 | ++ return rc; |
| 67 | ++ |
| 68 | ++err: |
| 69 | ++ netdev_notice(tp->dev, "Failed to create new i2c device %#x\n", i2caddr); |
| 70 | ++ return -1; |
| 71 | ++} |
| 72 | ++ |
| 73 | + static int tg3_open(struct net_device *dev) |
| 74 | + { |
| 75 | + struct tg3 *tp = netdev_priv(dev); |
| 76 | +@@ -11780,6 +11830,28 @@ static int tg3_open(struct net_device *dev) |
| 77 | + pci_set_power_state(tp->pdev, PCI_D3hot); |
| 78 | + } |
| 79 | + |
| 80 | ++ printk(KERN_INFO "finding Accton board...\n"); |
| 81 | ++ bid = tg3_get_board_id(dev); |
| 82 | ++ if( bid < 0){ |
| 83 | ++ bid = 0; |
| 84 | ++ netdev_notice(tp->dev, "Unable to get valid board ID.\nUse default value, board ID = %#x\n", bid); |
| 85 | ++ } |
| 86 | ++ netdev_notice(tp->dev,"Accton board PCB ID = %#x\n", bid); |
| 87 | ++ |
| 88 | ++ if(bid == 3){ |
| 89 | ++ netdev_notice(tp->dev, "enable PHY, SerDes mode.\n"); |
| 90 | ++ __tg3_writephy(tp, 0x8, 0x10, 0x1d0); |
| 91 | ++ __tg3_writephy(tp, 0x1f, 0x00, 0x8140); |
| 92 | ++ udelay(10000); |
| 93 | ++ __tg3_writephy(tp, 0x1f, 0x1c, 0xfc0d); |
| 94 | ++ __tg3_writephy(tp, 0x1f, 0x00, 0x1140); |
| 95 | ++ |
| 96 | ++ }else{ |
| 97 | ++ netdev_notice(tp->dev,"enable PHY, SGMII mode.\n"); |
| 98 | ++ __tg3_writephy(tp, 0x8, 0x10, 0x1d0); |
| 99 | ++ __tg3_writephy(tp, 0x1f, 0x4, 0x5e1); |
| 100 | ++ } |
| 101 | ++ |
| 102 | + return err; |
| 103 | + } |
| 104 | + |
0 commit comments