[xburst] Enable fireware loading support
[openwrt.git] / target / linux / brcm47xx / patches-2.6.31 / 700-ssb-gigabit-ethernet-driver.patch
1 --- a/drivers/net/tg3.c
2 +++ b/drivers/net/tg3.c
3 @@ -41,6 +41,7 @@
4 #include <linux/prefetch.h>
5 #include <linux/dma-mapping.h>
6 #include <linux/firmware.h>
7 +#include <linux/ssb/ssb_driver_gige.h>
8
9 #include <net/checksum.h>
10 #include <net/ip.h>
11 @@ -446,8 +447,9 @@ static void _tw32_flush(struct tg3 *tp,
12 static inline void tw32_mailbox_flush(struct tg3 *tp, u32 off, u32 val)
13 {
14 tp->write32_mbox(tp, off, val);
15 - if (!(tp->tg3_flags & TG3_FLAG_MBOX_WRITE_REORDER) &&
16 - !(tp->tg3_flags2 & TG3_FLG2_ICH_WORKAROUND))
17 + if ((tp->tg3_flags3 & TG3_FLG3_FLUSH_POSTED_WRITES) ||
18 + (!(tp->tg3_flags & TG3_FLAG_MBOX_WRITE_REORDER) &&
19 + !(tp->tg3_flags2 & TG3_FLG2_ICH_WORKAROUND)))
20 tp->read32_mbox(tp, off);
21 }
22
23 @@ -457,7 +459,7 @@ static void tg3_write32_tx_mbox(struct t
24 writel(val, mbox);
25 if (tp->tg3_flags & TG3_FLAG_TXD_MBOX_HWBUG)
26 writel(val, mbox);
27 - if (tp->tg3_flags & TG3_FLAG_MBOX_WRITE_REORDER)
28 + if ((tp->tg3_flags & TG3_FLAG_MBOX_WRITE_REORDER) || (tp->tg3_flags3 & TG3_FLG3_FLUSH_POSTED_WRITES))
29 readl(mbox);
30 }
31
32 @@ -729,7 +731,7 @@ static void tg3_switch_clocks(struct tg3
33
34 #define PHY_BUSY_LOOPS 5000
35
36 -static int tg3_readphy(struct tg3 *tp, int reg, u32 *val)
37 +static int __tg3_readphy(struct tg3 *tp, unsigned int phy_addr, int reg, u32 *val)
38 {
39 u32 frame_val;
40 unsigned int loops;
41 @@ -743,7 +745,7 @@ static int tg3_readphy(struct tg3 *tp, i
42
43 *val = 0x0;
44
45 - frame_val = ((PHY_ADDR << MI_COM_PHY_ADDR_SHIFT) &
46 + frame_val = ((phy_addr << MI_COM_PHY_ADDR_SHIFT) &
47 MI_COM_PHY_ADDR_MASK);
48 frame_val |= ((reg << MI_COM_REG_ADDR_SHIFT) &
49 MI_COM_REG_ADDR_MASK);
50 @@ -778,7 +780,12 @@ static int tg3_readphy(struct tg3 *tp, i
51 return ret;
52 }
53
54 -static int tg3_writephy(struct tg3 *tp, int reg, u32 val)
55 +static int tg3_readphy(struct tg3 *tp, int reg, u32 *val)
56 +{
57 + return __tg3_readphy(tp, PHY_ADDR, reg, val);
58 +}
59 +
60 +static int __tg3_writephy(struct tg3 *tp, unsigned int phy_addr, int reg, u32 val)
61 {
62 u32 frame_val;
63 unsigned int loops;
64 @@ -794,7 +801,7 @@ static int tg3_writephy(struct tg3 *tp,
65 udelay(80);
66 }
67
68 - frame_val = ((PHY_ADDR << MI_COM_PHY_ADDR_SHIFT) &
69 + frame_val = ((phy_addr << MI_COM_PHY_ADDR_SHIFT) &
70 MI_COM_PHY_ADDR_MASK);
71 frame_val |= ((reg << MI_COM_REG_ADDR_SHIFT) &
72 MI_COM_REG_ADDR_MASK);
73 @@ -827,6 +834,11 @@ static int tg3_writephy(struct tg3 *tp,
74 return ret;
75 }
76
77 +static int tg3_writephy(struct tg3 *tp, int reg, u32 val)
78 +{
79 + return __tg3_writephy(tp, PHY_ADDR, reg, val);
80 +}
81 +
82 static int tg3_bmcr_reset(struct tg3 *tp)
83 {
84 u32 phy_control;
85 @@ -2263,6 +2275,9 @@ static int tg3_nvram_read(struct tg3 *tp
86 {
87 int ret;
88
89 + if (tp->tg3_flags3 & TG3_FLG3_IS_SSB_CORE)
90 + return -ENODEV;
91 +
92 if (!(tp->tg3_flags & TG3_FLAG_NVRAM))
93 return tg3_nvram_read_using_eeprom(tp, offset, val);
94
95 @@ -2594,8 +2609,10 @@ static int tg3_set_power_state(struct tg
96 tg3_frob_aux_power(tp);
97
98 /* Workaround for unstable PLL clock */
99 - if ((GET_CHIP_REV(tp->pci_chip_rev_id) == CHIPREV_5750_AX) ||
100 - (GET_CHIP_REV(tp->pci_chip_rev_id) == CHIPREV_5750_BX)) {
101 + if ((tp->phy_id & PHY_ID_MASK != PHY_ID_BCM5750_2) &&
102 + /* !!! FIXME !!! */
103 + ((GET_CHIP_REV(tp->pci_chip_rev_id) == CHIPREV_5750_AX) ||
104 + (GET_CHIP_REV(tp->pci_chip_rev_id) == CHIPREV_5750_BX))) {
105 u32 val = tr32(0x7d00);
106
107 val &= ~((1 << 16) | (1 << 4) | (1 << 2) | (1 << 1) | 1);
108 @@ -3087,6 +3104,14 @@ relink:
109
110 tg3_phy_copper_begin(tp);
111
112 + if (tp->tg3_flags3 & TG3_FLG3_ROBOSWITCH) {
113 + current_link_up = 1;
114 + current_speed = SPEED_1000; //FIXME
115 + current_duplex = DUPLEX_FULL;
116 + tp->link_config.active_speed = current_speed;
117 + tp->link_config.active_duplex = current_duplex;
118 + }
119 +
120 tg3_readphy(tp, MII_BMSR, &tmp);
121 if (!tg3_readphy(tp, MII_BMSR, &tmp) &&
122 (tmp & BMSR_LSTATUS))
123 @@ -6000,6 +6025,11 @@ static int tg3_poll_fw(struct tg3 *tp)
124 int i;
125 u32 val;
126
127 + if (tp->tg3_flags3 & TG3_FLG3_IS_SSB_CORE) {
128 + /* We don't use firmware. */
129 + return 0;
130 + }
131 +
132 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) {
133 /* Wait up to 20ms for init done. */
134 for (i = 0; i < 200; i++) {
135 @@ -6257,6 +6287,14 @@ static int tg3_chip_reset(struct tg3 *tp
136 tw32(0x5000, 0x400);
137 }
138
139 + if (tp->tg3_flags3 & TG3_FLG3_IS_SSB_CORE) {
140 + /* BCM4785: In order to avoid repercussions from using potentially
141 + * defective internal ROM, stop the Rx RISC CPU, which is not
142 + * required. */
143 + tg3_stop_fw(tp);
144 + tg3_halt_cpu(tp, RX_CPU_BASE);
145 + }
146 +
147 tw32(GRC_MODE, tp->grc_mode);
148
149 if (tp->pci_chip_rev_id == CHIPREV_ID_5705_A0) {
150 @@ -6409,9 +6447,12 @@ static int tg3_halt_cpu(struct tg3 *tp,
151 return -ENODEV;
152 }
153
154 - /* Clear firmware's nvram arbitration. */
155 - if (tp->tg3_flags & TG3_FLAG_NVRAM)
156 - tw32(NVRAM_SWARB, SWARB_REQ_CLR0);
157 + if (!(tp->tg3_flags3 & TG3_FLG3_IS_SSB_CORE)) {
158 + /* Clear firmware's nvram arbitration. */
159 + if (tp->tg3_flags & TG3_FLAG_NVRAM)
160 + tw32(NVRAM_SWARB, SWARB_REQ_CLR0);
161 + }
162 +
163 return 0;
164 }
165
166 @@ -6474,6 +6515,11 @@ static int tg3_load_5701_a0_firmware_fix
167 const __be32 *fw_data;
168 int err, i;
169
170 + if (tp->tg3_flags3 & TG3_FLG3_IS_SSB_CORE) {
171 + /* We don't use firmware. */
172 + return 0;
173 + }
174 +
175 fw_data = (void *)tp->fw->data;
176
177 /* Firmware blob starts with version numbers, followed by
178 @@ -6533,6 +6579,11 @@ static int tg3_load_tso_firmware(struct
179 unsigned long cpu_base, cpu_scratch_base, cpu_scratch_size;
180 int err, i;
181
182 + if (tp->tg3_flags3 & TG3_FLG3_IS_SSB_CORE) {
183 + /* We don't use firmware. */
184 + return 0;
185 + }
186 +
187 if (tp->tg3_flags2 & TG3_FLG2_HW_TSO)
188 return 0;
189
190 @@ -7444,6 +7495,11 @@ static void tg3_timer(unsigned long __op
191
192 spin_lock(&tp->lock);
193
194 + if (tp->tg3_flags3 & TG3_FLG3_FLUSH_POSTED_WRITES) {
195 + /* BCM4785: Flush posted writes from GbE to host memory. */
196 + tr32(HOSTCC_MODE);
197 + }
198 +
199 if (!(tp->tg3_flags & TG3_FLAG_TAGGED_STATUS)) {
200 /* All of this garbage is because when using non-tagged
201 * IRQ status the mailbox/status_block protocol the chip
202 @@ -9217,6 +9273,11 @@ static int tg3_test_nvram(struct tg3 *tp
203 if (tp->tg3_flags3 & TG3_FLG3_NO_NVRAM)
204 return 0;
205
206 + if (tp->tg3_flags3 & TG3_FLG3_IS_SSB_CORE) {
207 + /* We don't have NVRAM. */
208 + return 0;
209 + }
210 +
211 if (tg3_nvram_read(tp, 0, &magic) != 0)
212 return -EIO;
213
214 @@ -10010,7 +10071,7 @@ static int tg3_ioctl(struct net_device *
215 return -EAGAIN;
216
217 spin_lock_bh(&tp->lock);
218 - err = tg3_readphy(tp, data->reg_num & 0x1f, &mii_regval);
219 + err = __tg3_readphy(tp, data->phy_id & 0x1f, data->reg_num & 0x1f, &mii_regval);
220 spin_unlock_bh(&tp->lock);
221
222 data->val_out = mii_regval;
223 @@ -10029,7 +10090,7 @@ static int tg3_ioctl(struct net_device *
224 return -EAGAIN;
225
226 spin_lock_bh(&tp->lock);
227 - err = tg3_writephy(tp, data->reg_num & 0x1f, data->val_in);
228 + err = __tg3_writephy(tp, data->phy_id & 0x1f, data->reg_num & 0x1f, data->val_in);
229 spin_unlock_bh(&tp->lock);
230
231 return err;
232 @@ -10619,6 +10680,12 @@ static void __devinit tg3_get_57780_nvra
233 /* Chips other than 5700/5701 use the NVRAM for fetching info. */
234 static void __devinit tg3_nvram_init(struct tg3 *tp)
235 {
236 + if (tp->tg3_flags3 & TG3_FLG3_IS_SSB_CORE) {
237 + /* No NVRAM and EEPROM on the SSB Broadcom GigE core. */
238 + tp->tg3_flags &= ~(TG3_FLAG_NVRAM | TG3_FLAG_NVRAM_BUFFERED);
239 + return;
240 + }
241 +
242 tw32_f(GRC_EEPROM_ADDR,
243 (EEPROM_ADDR_FSM_RESET |
244 (EEPROM_DEFAULT_CLOCK_PERIOD <<
245 @@ -10877,6 +10944,9 @@ static int tg3_nvram_write_block(struct
246 {
247 int ret;
248
249 + if (tp->tg3_flags3 & TG3_FLG3_IS_SSB_CORE)
250 + return -ENODEV;
251 +
252 if (tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT) {
253 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl &
254 ~GRC_LCLCTRL_GPIO_OUTPUT1);
255 @@ -12100,7 +12170,6 @@ static int __devinit tg3_get_invariants(
256 tp->write32 = tg3_write_flush_reg32;
257 }
258
259 -
260 if ((tp->tg3_flags & TG3_FLAG_TXD_MBOX_HWBUG) ||
261 (tp->tg3_flags & TG3_FLAG_MBOX_WRITE_REORDER)) {
262 tp->write32_tx_mbox = tg3_write32_tx_mbox;
263 @@ -12136,6 +12205,11 @@ static int __devinit tg3_get_invariants(
264 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701)))
265 tp->tg3_flags |= TG3_FLAG_SRAM_USE_CONFIG;
266
267 + if (tp->tg3_flags3 & TG3_FLG3_FLUSH_POSTED_WRITES) {
268 + tp->write32_tx_mbox = tg3_write_flush_reg32;
269 + tp->write32_rx_mbox = tg3_write_flush_reg32;
270 + }
271 +
272 /* Get eeprom hw config before calling tg3_set_power_state().
273 * In particular, the TG3_FLG2_IS_NIC flag must be
274 * determined before calling tg3_set_power_state() so that
275 @@ -12513,6 +12587,10 @@ static int __devinit tg3_get_device_addr
276 }
277
278 if (!is_valid_ether_addr(&dev->dev_addr[0])) {
279 + if (tp->tg3_flags3 & TG3_FLG3_IS_SSB_CORE)
280 + ssb_gige_get_macaddr(tp->pdev, &dev->dev_addr[0]);
281 + }
282 + if (!is_valid_ether_addr(&dev->dev_addr[0])) {
283 #ifdef CONFIG_SPARC
284 if (!tg3_get_default_macaddr_sparc(tp))
285 return 0;
286 @@ -13004,6 +13082,7 @@ static char * __devinit tg3_phy_string(s
287 case PHY_ID_BCM5704: return "5704";
288 case PHY_ID_BCM5705: return "5705";
289 case PHY_ID_BCM5750: return "5750";
290 + case PHY_ID_BCM5750_2: return "5750-2";
291 case PHY_ID_BCM5752: return "5752";
292 case PHY_ID_BCM5714: return "5714";
293 case PHY_ID_BCM5780: return "5780";
294 @@ -13214,6 +13293,13 @@ static int __devinit tg3_init_one(struct
295 tp->msg_enable = tg3_debug;
296 else
297 tp->msg_enable = TG3_DEF_MSG_ENABLE;
298 + if (pdev_is_ssb_gige_core(pdev)) {
299 + tp->tg3_flags3 |= TG3_FLG3_IS_SSB_CORE;
300 + if (ssb_gige_must_flush_posted_writes(pdev))
301 + tp->tg3_flags3 |= TG3_FLG3_FLUSH_POSTED_WRITES;
302 + if (ssb_gige_have_roboswitch(pdev))
303 + tp->tg3_flags3 |= TG3_FLG3_ROBOSWITCH;
304 + }
305
306 /* The word/byte swap controls here control register access byte
307 * swapping. DMA data byte swapping is controlled in the GRC_MODE
308 --- a/drivers/net/tg3.h
309 +++ b/drivers/net/tg3.h
310 @@ -1853,6 +1853,9 @@
311 #define NIC_SRAM_RGMII_STD_IBND_DISABLE 0x00000004
312 #define NIC_SRAM_RGMII_EXT_IBND_RX_EN 0x00000008
313 #define NIC_SRAM_RGMII_EXT_IBND_TX_EN 0x00000010
314 +#define TG3_FLG3_IS_SSB_CORE 0x00000800
315 +#define TG3_FLG3_FLUSH_POSTED_WRITES 0x00001000
316 +#define TG3_FLG3_ROBOSWITCH 0x00002000
317
318 #define NIC_SRAM_RX_MINI_BUFFER_DESC 0x00001000
319
320 @@ -2701,6 +2704,7 @@ struct tg3 {
321 #define PHY_ID_BCM5714 0x60008340
322 #define PHY_ID_BCM5780 0x60008350
323 #define PHY_ID_BCM5755 0xbc050cc0
324 +#define PHY_ID_BCM5750_2 0xbc050cd0
325 #define PHY_ID_BCM5787 0xbc050ce0
326 #define PHY_ID_BCM5756 0xbc050ed0
327 #define PHY_ID_BCM5784 0xbc050fa0
328 @@ -2745,7 +2749,7 @@ struct tg3 {
329 (X) == PHY_ID_BCM5780 || (X) == PHY_ID_BCM5787 || \
330 (X) == PHY_ID_BCM5755 || (X) == PHY_ID_BCM5756 || \
331 (X) == PHY_ID_BCM5906 || (X) == PHY_ID_BCM5761 || \
332 - (X) == PHY_ID_BCM8002)
333 + (X) == PHY_ID_BCM8002 || (X) == PHY_ID_BCM5750_2)
334
335 struct tg3_hw_stats *hw_stats;
336 dma_addr_t stats_mapping;
This page took 0.052829 seconds and 5 git commands to generate.