brcm47xx: bgmac: make it possible to set the devices into promisc mode when it is...
[openwrt/svn-archive/archive.git] / target / linux / brcm47xx / patches-3.6 / 760-bgmac-fixes.patch
1 --- a/drivers/net/ethernet/broadcom/bgmac.c
2 +++ b/drivers/net/ethernet/broadcom/bgmac.c
3 @@ -761,6 +761,26 @@ static void bgmac_cmdcfg_maskset(struct
4 udelay(2);
5 }
6
7 +static void bgmac_write_mac_address(struct bgmac *bgmac, u8 *addr)
8 +{
9 + u32 tmp;
10 +
11 + tmp = (addr[0] << 24) | (addr[1] << 16) | (addr[2] << 8) | addr[3];
12 + bgmac_write(bgmac, BGMAC_MACADDR_HIGH, tmp);
13 + tmp = (addr[4] << 8) | addr[5];
14 + bgmac_write(bgmac, BGMAC_MACADDR_LOW, tmp);
15 +}
16 +
17 +static void bgmac_set_rx_mode(struct net_device *net_dev)
18 +{
19 + struct bgmac *bgmac = netdev_priv(net_dev);
20 +
21 + if (net_dev->flags & IFF_PROMISC)
22 + bgmac_cmdcfg_maskset(bgmac, ~0, BGMAC_CMDCFG_PROM, false);
23 + else
24 + bgmac_cmdcfg_maskset(bgmac, ~BGMAC_CMDCFG_PROM, 0, false);
25 +}
26 +
27 #if 0 /* We don't use that regs yet */
28 static void bgmac_chip_stats_update(struct bgmac *bgmac)
29 {
30 @@ -889,8 +909,10 @@ static void bgmac_chip_reset(struct bgma
31 sw_type = et_swtype;
32 } else if (ci->id == BCMA_CHIP_ID_BCM5357 && ci->pkg == 9) {
33 sw_type = BGMAC_CHIPCTL_1_SW_TYPE_EPHYRMII;
34 - } else if (0) {
35 - /* TODO */
36 + } else if ((ci->id != BCMA_CHIP_ID_BCM53572 && ci->pkg == 10) ||
37 + (ci->id == BCMA_CHIP_ID_BCM53572 && ci->pkg == 9)) {
38 + sw_type = BGMAC_CHIPCTL_1_IF_TYPE_RGMII |
39 + BGMAC_CHIPCTL_1_SW_TYPE_RGMII;
40 }
41 bcma_chipco_chipctl_maskset(cc, 1,
42 ~(BGMAC_CHIPCTL_1_IF_TYPE_MASK |
43 @@ -1004,8 +1026,6 @@ static void bgmac_enable(struct bgmac *b
44 static void bgmac_chip_init(struct bgmac *bgmac, bool full_init)
45 {
46 struct bgmac_dma_ring *ring;
47 - u8 *mac = bgmac->net_dev->dev_addr;
48 - u32 tmp;
49 int i;
50
51 /* 1 interrupt per received frame */
52 @@ -1014,16 +1034,9 @@ static void bgmac_chip_init(struct bgmac
53 /* Enable 802.3x tx flow control (honor received PAUSE frames) */
54 bgmac_cmdcfg_maskset(bgmac, ~BGMAC_CMDCFG_RPI, 0, true);
55
56 - if (bgmac->net_dev->flags & IFF_PROMISC)
57 - bgmac_cmdcfg_maskset(bgmac, ~0, BGMAC_CMDCFG_PROM, false);
58 - else
59 - bgmac_cmdcfg_maskset(bgmac, ~BGMAC_CMDCFG_PROM, 0, false);
60 + bgmac_set_rx_mode(bgmac->net_dev);
61
62 - /* Set MAC addr */
63 - tmp = (mac[0] << 24) | (mac[1] << 16) | (mac[2] << 8) | mac[3];
64 - bgmac_write(bgmac, BGMAC_MACADDR_HIGH, tmp);
65 - tmp = (mac[4] << 8) | mac[5];
66 - bgmac_write(bgmac, BGMAC_MACADDR_LOW, tmp);
67 + bgmac_write_mac_address(bgmac, bgmac->net_dev->dev_addr);
68
69 if (bgmac->loopback)
70 bgmac_cmdcfg_maskset(bgmac, ~0, BGMAC_CMDCFG_ML, true);
71 @@ -1160,6 +1173,19 @@ static netdev_tx_t bgmac_start_xmit(stru
72 return bgmac_dma_tx_add(bgmac, ring, skb);
73 }
74
75 +static int bgmac_set_mac_address(struct net_device *net_dev, void *addr)
76 +{
77 + struct bgmac *bgmac = netdev_priv(net_dev);
78 + int ret;
79 +
80 + ret = eth_prepare_mac_addr_change(net_dev, addr);
81 + if (ret < 0)
82 + return ret;
83 + bgmac_write_mac_address(bgmac, (u8 *)addr);
84 + eth_commit_mac_addr_change(net_dev, addr);
85 + return 0;
86 +}
87 +
88 static int bgmac_ioctl(struct net_device *net_dev, struct ifreq *ifr, int cmd)
89 {
90 struct bgmac *bgmac = netdev_priv(net_dev);
91 @@ -1190,7 +1216,9 @@ static const struct net_device_ops bgmac
92 .ndo_open = bgmac_open,
93 .ndo_stop = bgmac_stop,
94 .ndo_start_xmit = bgmac_start_xmit,
95 - .ndo_set_mac_address = eth_mac_addr, /* generic, sets dev_addr */
96 + .ndo_set_rx_mode = bgmac_set_rx_mode,
97 + .ndo_set_mac_address = bgmac_set_mac_address,
98 + .ndo_validate_addr = eth_validate_addr,
99 .ndo_do_ioctl = bgmac_ioctl,
100 };
101
102 --- a/drivers/net/ethernet/broadcom/bgmac.h
103 +++ b/drivers/net/ethernet/broadcom/bgmac.h
104 @@ -339,7 +339,7 @@
105 #define BGMAC_CHIPCTL_1_SW_TYPE_EPHY 0x00000000
106 #define BGMAC_CHIPCTL_1_SW_TYPE_EPHYMII 0x00000040
107 #define BGMAC_CHIPCTL_1_SW_TYPE_EPHYRMII 0x00000080
108 -#define BGMAC_CHIPCTL_1_SW_TYPE_RGMI 0x000000C0
109 +#define BGMAC_CHIPCTL_1_SW_TYPE_RGMII 0x000000C0
110 #define BGMAC_CHIPCTL_1_RXC_DLL_BYPASS 0x00010000
111
112 #define BGMAC_SPEED_10 0x0001