10 #define STATS_TICK_SECS 15
12 #define MAJOR_UPDATE_TICKS (1800 / STATS_TICK_SECS)
21 #define WM_DISABLE 0x01a01fff
22 #define WM_ENABLE 0x014a03F0
34 #define INITBLOCK_SLEEP 0xffffffff
41 spin_lock_bh(&adapter->mac_lock);
47 status = (vhi << 16) | vlo;
49 }
while (((status & 1) == 0) && (i < 50));
51 pr_err(
"Invalid tpi read from MAC, breaking loop.\n");
56 *val = (vhi << 16) | vlo;
61 spin_unlock_bh(&adapter->mac_lock);
66 spin_lock_bh(&adapter->mac_lock);
72 spin_unlock_bh(&adapter->mac_lock);
76 static void vsc7326_full_reset(
adapter_t* adapter)
93 }
while (result != 0x0);
114 static struct init_table vsc7326_portinit[4][22] = {
225 for (i = 0; i < len; i++) {
228 pr_err(
"sleep %d us\n",ib[i].data);
230 vsc_write( adapter, ib[i].addr, ib[i].data );
239 if ((address != 0x0) &&
244 pr_err(
"No bist address: 0x%x\n", address);
246 data = ((0x00 << 24) | ((address & 0xff) << 16) | (0x00 << 8) |
247 ((moduleid & 0xff) << 0));
253 if ((result & (1 << 9)) != 0x0)
254 pr_err(
"Still in bist read: 0x%x\n", result);
255 else if ((result & (1 << 8)) != 0x0)
256 pr_err(
"bist read error: 0x%x\n", result);
258 return result & 0xff;
261 static int bist_wr(
adapter_t *adapter,
int moduleid,
int address,
int value)
266 if ((address != 0x0) &&
271 pr_err(
"No bist address: 0x%x\n", address);
274 pr_err(
"Suspicious write out of range value: 0x%x\n", value);
276 data = ((0x01 << 24) | ((address & 0xff) << 16) | (value << 8) |
277 ((moduleid & 0xff) << 0));
283 if ((result & (1 << 27)) != 0x0)
284 pr_err(
"Still in bist write: 0x%x\n", result);
285 else if ((result & (1 << 26)) != 0x0)
286 pr_err(
"bist write error: 0x%x\n", result);
291 static int run_bist(
adapter_t *adapter,
int moduleid)
294 (
void) bist_wr(adapter,moduleid, 0x00, 0x02);
295 (
void) bist_wr(adapter,moduleid, 0x01, 0x01);
300 static int check_bist(
adapter_t *adapter,
int moduleid)
305 result = bist_rd(adapter,moduleid, 0x02);
306 column = ((bist_rd(adapter,moduleid, 0x0e)<<8) +
307 (bist_rd(adapter,moduleid, 0x0d)));
308 if ((result & 3) != 0x3)
309 pr_err(
"Result: 0x%x BIST error in ram %d, column: 0x%04x\n",
310 result, moduleid, column);
314 static int enable_mem(
adapter_t *adapter,
int moduleid)
317 (
void) bist_wr(adapter,moduleid, 0x00, 0x00);
321 static int run_bist_all(
adapter_t *adapter)
329 for (port = 0; port < 12; port++)
336 (
void) run_bist(adapter,13);
337 (
void) run_bist(adapter,14);
338 (
void) run_bist(adapter,20);
339 (
void) run_bist(adapter,21);
341 (
void) check_bist(adapter,13);
342 (
void) check_bist(adapter,14);
343 (
void) check_bist(adapter,20);
344 (
void) check_bist(adapter,21);
346 (
void) enable_mem(adapter,13);
347 (
void) enable_mem(adapter,14);
348 (
void) enable_mem(adapter,20);
349 (
void) enable_mem(adapter,21);
353 for (port = 0; port < 12; port++)
362 static int mac_intr_handler(
struct cmac *
mac)
367 static int mac_intr_enable(
struct cmac *
mac)
372 static int mac_intr_disable(
struct cmac *
mac)
377 static int mac_intr_clear(
struct cmac *
mac)
383 static int mac_set_address(
struct cmac*
mac,
u8 addr[6])
389 (addr[3] << 16) | (addr[4] << 8) | addr[5]);
391 (addr[0] << 16) | (addr[1] << 8) | addr[2]);
398 0xffff0000 | (addr[4] << 8) | addr[5]);
400 0xffff0000 | (addr[2] << 8) | addr[3]);
402 0xffff0000 | (addr[0] << 8) | addr[1]);
406 static int mac_get_address(
struct cmac *mac,
u8 addr[6])
408 u32 addr_lo, addr_hi;
414 addr[0] = (
u8) (addr_hi >> 16);
415 addr[1] = (
u8) (addr_hi >> 8);
416 addr[2] = (
u8) addr_hi;
417 addr[3] = (
u8) (addr_lo >> 16);
418 addr[4] = (
u8) (addr_lo >> 8);
419 addr[5] = (
u8) addr_lo;
428 run_table(mac->
adapter, vsc7326_portinit[index],
434 static int mac_set_rx_mode(
struct cmac *mac,
struct t1_rx_mode *rm)
443 v &= ~(1 << (port + 16));
445 v |= 1 << (port + 16);
451 static int mac_set_mtu(
struct cmac *mac,
int mtu)
463 static int mac_set_speed_duplex_fc(
struct cmac *mac,
int speed,
int duplex,
526 if (fc == (PAUSE_RX | PAUSE_TX))
532 static int mac_enable(
struct cmac *mac,
int which)
549 static int mac_disable(
struct cmac *mac,
int which)
558 if (which & MAC_DIRECTION_RX)
560 if (which & MAC_DIRECTION_TX)
566 for (i = 0; i <= 0x3a; ++
i)
575 static void rmon_update(
struct cmac *mac,
unsigned int addr,
u64 *
stat)
579 vsc_read(mac->
adapter, addr, &v);
581 *stat = *stat - lo +
v;
587 *stat += (1ULL << 32);
590 static void port_stats_update(
struct cmac *mac)
597 #define HW_STAT(reg, stat_name) \
598 { reg, (&((struct cmac_statistics *)NULL)->stat_name) - (u64 *)NULL }
627 rmon_update(mac,
CRA(0x4, port,
p->reg), stats +
p->offset);
648 port_stats_update(mac);
654 &mac->
stats.RxOctetsOK);
656 &mac->
stats.RxOctetsBad);
658 &mac->
stats.TxOctetsOK);
664 static void mac_destroy(
struct cmac *mac)
669 static struct cmac_ops vsc7326_ops = {
670 .destroy = mac_destroy,
672 .interrupt_handler = mac_intr_handler,
673 .interrupt_enable = mac_intr_enable,
674 .interrupt_disable = mac_intr_disable,
675 .interrupt_clear = mac_intr_clear,
676 .enable = mac_enable,
677 .disable = mac_disable,
678 .set_mtu = mac_set_mtu,
679 .set_rx_mode = mac_set_rx_mode,
680 .set_speed_duplex_fc = mac_set_speed_duplex_fc,
681 .statistics_update = mac_update_statistics,
682 .macaddress_get = mac_get_address,
683 .macaddress_set = mac_set_address,
686 static struct cmac *vsc7326_mac_create(
adapter_t *adapter,
int index)
696 mac->
ops = &vsc7326_ops;
712 val = (vhi << 16) | vlo;
713 }
while ((++i < 10000) && (val == 0xffffffff));
718 static int vsc7326_mac_reset(
adapter_t *adapter)
720 vsc7326_full_reset(adapter);
721 (
void) run_bist_all(adapter);
722 run_table(adapter, vsc7326_reset,
ARRAY_SIZE(vsc7326_reset));
728 .create = vsc7326_mac_create,
729 .reset = vsc7326_mac_reset,