0e0b246eef195e4f511677b274102a36c586c5d3
[openwrt.git] / target / linux / generic / patches-3.10 / 772-bgmac-add-supprot-for-BCM4707.patch
1 bgmac: add supprot for BCM4707
2
3 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
4
5 --- a/drivers/net/ethernet/broadcom/bgmac.c
6 +++ b/drivers/net/ethernet/broadcom/bgmac.c
7 @@ -825,6 +825,9 @@ static void bgmac_mac_speed(struct bgmac
8         case SPEED_1000:
9                 set |= BGMAC_CMDCFG_ES_1000;
10                 break;
11 +       case SPEED_2500:
12 +               set |= BGMAC_CMDCFG_ES_2500;
13 +               break;
14         default:
15                 bgmac_err(bgmac, "Unsupported speed: %d\n", bgmac->mac_speed);
16         }
17 @@ -837,12 +840,25 @@ static void bgmac_mac_speed(struct bgmac
18  
19  static void bgmac_miiconfig(struct bgmac *bgmac)
20  {
21 -       u8 imode = (bgmac_read(bgmac, BGMAC_DEV_STATUS) & BGMAC_DS_MM_MASK) >>
22 -                       BGMAC_DS_MM_SHIFT;
23 -       if (imode == 0 || imode == 1) {
24 -               bgmac->mac_speed = SPEED_100;
25 +       struct bcma_device *core = bgmac->core;
26 +       struct bcma_chipinfo *ci = &core->bus->chipinfo;
27 +       u8 imode;
28 +
29 +       if (ci->id == BCMA_CHIP_ID_BCM4707 ||
30 +           ci->id == BCMA_CHIP_ID_BCM53018) {
31 +               bcma_awrite32(core, BCMA_IOCTL,
32 +                             bcma_aread32(core, BCMA_IOCTL) | 0x44);
33 +               bgmac->mac_speed = SPEED_2500;
34                 bgmac->mac_duplex = DUPLEX_FULL;
35                 bgmac_mac_speed(bgmac);
36 +       } else {
37 +               imode = (bgmac_read(bgmac, BGMAC_DEV_STATUS) & BGMAC_DS_MM_MASK) >>
38 +                       BGMAC_DS_MM_SHIFT;
39 +               if (imode == 0 || imode == 1) {
40 +                       bgmac->mac_speed = SPEED_100;
41 +                       bgmac->mac_duplex = DUPLEX_FULL;
42 +                       bgmac_mac_speed(bgmac);
43 +               }
44         }
45  }
46  
47 @@ -888,7 +904,8 @@ static void bgmac_chip_reset(struct bgma
48  
49         bcma_core_enable(core, flags);
50  
51 -       if (core->id.rev > 2) {
52 +       if (core->id.rev > 2 && ci->id != BCMA_CHIP_ID_BCM4707 &&
53 +           ci->id != BCMA_CHIP_ID_BCM53018) {
54                 bgmac_set(bgmac, BCMA_CLKCTLST,
55                           BGMAC_BCMA_CLKCTLST_MISC_PLL_REQ);
56                 bgmac_wait_value(bgmac->core, BCMA_CLKCTLST,
57 @@ -1026,12 +1043,15 @@ static void bgmac_enable(struct bgmac *b
58                 break;
59         }
60  
61 -       rxq_ctl = bgmac_read(bgmac, BGMAC_RXQ_CTL);
62 -       rxq_ctl &= ~BGMAC_RXQ_CTL_MDP_MASK;
63 -       bp_clk = bcma_pmu_get_bus_clock(&bgmac->core->bus->drv_cc) / 1000000;
64 -       mdp = (bp_clk * 128 / 1000) - 3;
65 -       rxq_ctl |= (mdp << BGMAC_RXQ_CTL_MDP_SHIFT);
66 -       bgmac_write(bgmac, BGMAC_RXQ_CTL, rxq_ctl);
67 +       if (ci->id != BCMA_CHIP_ID_BCM4707 &&
68 +           ci->id != BCMA_CHIP_ID_BCM53018) {
69 +               rxq_ctl = bgmac_read(bgmac, BGMAC_RXQ_CTL);
70 +               rxq_ctl &= ~BGMAC_RXQ_CTL_MDP_MASK;
71 +               bp_clk = bcma_pmu_get_bus_clock(&bgmac->core->bus->drv_cc) / 1000000;
72 +               mdp = (bp_clk * 128 / 1000) - 3;
73 +               rxq_ctl |= (mdp << BGMAC_RXQ_CTL_MDP_SHIFT);
74 +               bgmac_write(bgmac, BGMAC_RXQ_CTL, rxq_ctl);
75 +       }
76  }
77  
78  /* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipinit */
79 @@ -1421,6 +1441,25 @@ static int bgmac_probe(struct bcma_devic
80                 goto err_netdev_free;
81         }
82  
83 +       /* Northstar, take all GMAC cores out of reset */
84 +       if (core->id.id == BCMA_CHIP_ID_BCM4707 ||
85 +           core->id.id == BCMA_CHIP_ID_BCM53018) {
86 +               struct bcma_device *ns_core;
87 +               int ns_gmac;
88 +
89 +               for (ns_gmac = 0; ns_gmac < 4; ns_gmac++) {
90 +                       /* As northstar requirement, we have to reset all GAMCs before
91 +                        * accessing them. et_probe() call pci_enable_device() for etx
92 +                        * and do si_core_reset for GAMCx only.  Then the other three
93 +                        * GAMCs didn't reset.  We do it here.
94 +                        */
95 +                       ns_core = bcma_find_core_unit(core->bus, BCMA_CORE_MAC_GBIT, ns_gmac);
96 +                       if (!bcma_core_is_enabled(ns_core)) {
97 +                               bcma_core_enable(ns_core, 0);
98 +                       }
99 +               }
100 +       }
101 +
102         bgmac_chip_reset(bgmac);
103  
104         err = bgmac_dma_alloc(bgmac);
105 --- a/drivers/net/ethernet/broadcom/bgmac.h
106 +++ b/drivers/net/ethernet/broadcom/bgmac.h
107 @@ -189,6 +189,7 @@
108  #define   BGMAC_CMDCFG_ES_10                   0x00000000
109  #define   BGMAC_CMDCFG_ES_100                  0x00000004
110  #define   BGMAC_CMDCFG_ES_1000                 0x00000008
111 +#define   BGMAC_CMDCFG_ES_2500                 0x0000000C
112  #define  BGMAC_CMDCFG_PROM                     0x00000010      /* Set to activate promiscuous mode */
113  #define  BGMAC_CMDCFG_PAD_EN                   0x00000020
114  #define  BGMAC_CMDCFG_CF                       0x00000040