diff options
author | Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com> | 2012-06-25 13:34:14 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-06-26 02:54:32 -0400 |
commit | 5e7a76be0e48217aff6b6f34bdcce4725db999e2 (patch) | |
tree | df608a434dd29946445d9ad9965606654ed990ea | |
parent | 4dc27d1cf3b3027b9ce654221c559e88b2f41b33 (diff) |
net/sh-eth: Add support selecting MII function for SH7734 and R8A7740
Ethernet IP of SH7734 and R8A7740 has selecting MII register.
The user needs to change a value according to MII to be used.
This adds the function to change the value of this register.
Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/renesas/sh_eth.c | 108 | ||||
-rw-r--r-- | drivers/net/ethernet/renesas/sh_eth.h | 1 |
2 files changed, 66 insertions, 43 deletions
diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c index 79bf09b41971..8d696e0c082b 100644 --- a/drivers/net/ethernet/renesas/sh_eth.c +++ b/drivers/net/ethernet/renesas/sh_eth.c | |||
@@ -49,6 +49,34 @@ | |||
49 | NETIF_MSG_RX_ERR| \ | 49 | NETIF_MSG_RX_ERR| \ |
50 | NETIF_MSG_TX_ERR) | 50 | NETIF_MSG_TX_ERR) |
51 | 51 | ||
52 | #if defined(CONFIG_CPU_SUBTYPE_SH7734) || \ | ||
53 | defined(CONFIG_CPU_SUBTYPE_SH7763) || \ | ||
54 | defined(CONFIG_ARCH_R8A7740) | ||
55 | static void sh_eth_select_mii(struct net_device *ndev) | ||
56 | { | ||
57 | u32 value = 0x0; | ||
58 | struct sh_eth_private *mdp = netdev_priv(ndev); | ||
59 | |||
60 | switch (mdp->phy_interface) { | ||
61 | case PHY_INTERFACE_MODE_GMII: | ||
62 | value = 0x2; | ||
63 | break; | ||
64 | case PHY_INTERFACE_MODE_MII: | ||
65 | value = 0x1; | ||
66 | break; | ||
67 | case PHY_INTERFACE_MODE_RMII: | ||
68 | value = 0x0; | ||
69 | break; | ||
70 | default: | ||
71 | pr_warn("PHY interface mode was not setup. Set to MII.\n"); | ||
72 | value = 0x1; | ||
73 | break; | ||
74 | } | ||
75 | |||
76 | sh_eth_write(ndev, value, RMII_MII); | ||
77 | } | ||
78 | #endif | ||
79 | |||
52 | /* There is CPU dependent code */ | 80 | /* There is CPU dependent code */ |
53 | #if defined(CONFIG_CPU_SUBTYPE_SH7724) | 81 | #if defined(CONFIG_CPU_SUBTYPE_SH7724) |
54 | #define SH_ETH_RESET_DEFAULT 1 | 82 | #define SH_ETH_RESET_DEFAULT 1 |
@@ -283,6 +311,7 @@ static struct sh_eth_cpu_data *sh_eth_get_cpu_data(struct sh_eth_private *mdp) | |||
283 | #elif defined(CONFIG_CPU_SUBTYPE_SH7734) || defined(CONFIG_CPU_SUBTYPE_SH7763) | 311 | #elif defined(CONFIG_CPU_SUBTYPE_SH7734) || defined(CONFIG_CPU_SUBTYPE_SH7763) |
284 | #define SH_ETH_HAS_TSU 1 | 312 | #define SH_ETH_HAS_TSU 1 |
285 | static void sh_eth_reset_hw_crc(struct net_device *ndev); | 313 | static void sh_eth_reset_hw_crc(struct net_device *ndev); |
314 | |||
286 | static void sh_eth_chip_reset(struct net_device *ndev) | 315 | static void sh_eth_chip_reset(struct net_device *ndev) |
287 | { | 316 | { |
288 | struct sh_eth_private *mdp = netdev_priv(ndev); | 317 | struct sh_eth_private *mdp = netdev_priv(ndev); |
@@ -292,35 +321,6 @@ static void sh_eth_chip_reset(struct net_device *ndev) | |||
292 | mdelay(1); | 321 | mdelay(1); |
293 | } | 322 | } |
294 | 323 | ||
295 | static void sh_eth_reset(struct net_device *ndev) | ||
296 | { | ||
297 | int cnt = 100; | ||
298 | |||
299 | sh_eth_write(ndev, EDSR_ENALL, EDSR); | ||
300 | sh_eth_write(ndev, sh_eth_read(ndev, EDMR) | EDMR_SRST_GETHER, EDMR); | ||
301 | while (cnt > 0) { | ||
302 | if (!(sh_eth_read(ndev, EDMR) & 0x3)) | ||
303 | break; | ||
304 | mdelay(1); | ||
305 | cnt--; | ||
306 | } | ||
307 | if (cnt == 0) | ||
308 | printk(KERN_ERR "Device reset fail\n"); | ||
309 | |||
310 | /* Table Init */ | ||
311 | sh_eth_write(ndev, 0x0, TDLAR); | ||
312 | sh_eth_write(ndev, 0x0, TDFAR); | ||
313 | sh_eth_write(ndev, 0x0, TDFXR); | ||
314 | sh_eth_write(ndev, 0x0, TDFFR); | ||
315 | sh_eth_write(ndev, 0x0, RDLAR); | ||
316 | sh_eth_write(ndev, 0x0, RDFAR); | ||
317 | sh_eth_write(ndev, 0x0, RDFXR); | ||
318 | sh_eth_write(ndev, 0x0, RDFFR); | ||
319 | |||
320 | /* Reset HW CRC register */ | ||
321 | sh_eth_reset_hw_crc(ndev); | ||
322 | } | ||
323 | |||
324 | static void sh_eth_set_duplex(struct net_device *ndev) | 324 | static void sh_eth_set_duplex(struct net_device *ndev) |
325 | { | 325 | { |
326 | struct sh_eth_private *mdp = netdev_priv(ndev); | 326 | struct sh_eth_private *mdp = netdev_priv(ndev); |
@@ -377,9 +377,43 @@ static struct sh_eth_cpu_data sh_eth_my_cpu_data = { | |||
377 | .tsu = 1, | 377 | .tsu = 1, |
378 | #if defined(CONFIG_CPU_SUBTYPE_SH7734) | 378 | #if defined(CONFIG_CPU_SUBTYPE_SH7734) |
379 | .hw_crc = 1, | 379 | .hw_crc = 1, |
380 | .select_mii = 1, | ||
380 | #endif | 381 | #endif |
381 | }; | 382 | }; |
382 | 383 | ||
384 | static void sh_eth_reset(struct net_device *ndev) | ||
385 | { | ||
386 | int cnt = 100; | ||
387 | |||
388 | sh_eth_write(ndev, EDSR_ENALL, EDSR); | ||
389 | sh_eth_write(ndev, sh_eth_read(ndev, EDMR) | EDMR_SRST_GETHER, EDMR); | ||
390 | while (cnt > 0) { | ||
391 | if (!(sh_eth_read(ndev, EDMR) & 0x3)) | ||
392 | break; | ||
393 | mdelay(1); | ||
394 | cnt--; | ||
395 | } | ||
396 | if (cnt == 0) | ||
397 | printk(KERN_ERR "Device reset fail\n"); | ||
398 | |||
399 | /* Table Init */ | ||
400 | sh_eth_write(ndev, 0x0, TDLAR); | ||
401 | sh_eth_write(ndev, 0x0, TDFAR); | ||
402 | sh_eth_write(ndev, 0x0, TDFXR); | ||
403 | sh_eth_write(ndev, 0x0, TDFFR); | ||
404 | sh_eth_write(ndev, 0x0, RDLAR); | ||
405 | sh_eth_write(ndev, 0x0, RDFAR); | ||
406 | sh_eth_write(ndev, 0x0, RDFXR); | ||
407 | sh_eth_write(ndev, 0x0, RDFFR); | ||
408 | |||
409 | /* Reset HW CRC register */ | ||
410 | sh_eth_reset_hw_crc(ndev); | ||
411 | |||
412 | /* Select MII mode */ | ||
413 | if (sh_eth_my_cpu_data.select_mii) | ||
414 | sh_eth_select_mii(ndev); | ||
415 | } | ||
416 | |||
383 | static void sh_eth_reset_hw_crc(struct net_device *ndev) | 417 | static void sh_eth_reset_hw_crc(struct net_device *ndev) |
384 | { | 418 | { |
385 | if (sh_eth_my_cpu_data.hw_crc) | 419 | if (sh_eth_my_cpu_data.hw_crc) |
@@ -391,25 +425,12 @@ static void sh_eth_reset_hw_crc(struct net_device *ndev) | |||
391 | static void sh_eth_chip_reset(struct net_device *ndev) | 425 | static void sh_eth_chip_reset(struct net_device *ndev) |
392 | { | 426 | { |
393 | struct sh_eth_private *mdp = netdev_priv(ndev); | 427 | struct sh_eth_private *mdp = netdev_priv(ndev); |
394 | unsigned long mii; | ||
395 | 428 | ||
396 | /* reset device */ | 429 | /* reset device */ |
397 | sh_eth_tsu_write(mdp, ARSTR_ARSTR, ARSTR); | 430 | sh_eth_tsu_write(mdp, ARSTR_ARSTR, ARSTR); |
398 | mdelay(1); | 431 | mdelay(1); |
399 | 432 | ||
400 | switch (mdp->phy_interface) { | 433 | sh_eth_select_mii(ndev); |
401 | case PHY_INTERFACE_MODE_GMII: | ||
402 | mii = 2; | ||
403 | break; | ||
404 | case PHY_INTERFACE_MODE_MII: | ||
405 | mii = 1; | ||
406 | break; | ||
407 | case PHY_INTERFACE_MODE_RMII: | ||
408 | default: | ||
409 | mii = 0; | ||
410 | break; | ||
411 | } | ||
412 | sh_eth_write(ndev, mii, RMII_MII); | ||
413 | } | 434 | } |
414 | 435 | ||
415 | static void sh_eth_reset(struct net_device *ndev) | 436 | static void sh_eth_reset(struct net_device *ndev) |
@@ -492,6 +513,7 @@ static struct sh_eth_cpu_data sh_eth_my_cpu_data = { | |||
492 | .no_trimd = 1, | 513 | .no_trimd = 1, |
493 | .no_ade = 1, | 514 | .no_ade = 1, |
494 | .tsu = 1, | 515 | .tsu = 1, |
516 | .select_mii = 1, | ||
495 | }; | 517 | }; |
496 | 518 | ||
497 | #elif defined(CONFIG_CPU_SUBTYPE_SH7619) | 519 | #elif defined(CONFIG_CPU_SUBTYPE_SH7619) |
diff --git a/drivers/net/ethernet/renesas/sh_eth.h b/drivers/net/ethernet/renesas/sh_eth.h index 57b8e1fc5d15..d6763b1392d7 100644 --- a/drivers/net/ethernet/renesas/sh_eth.h +++ b/drivers/net/ethernet/renesas/sh_eth.h | |||
@@ -757,6 +757,7 @@ struct sh_eth_cpu_data { | |||
757 | unsigned no_trimd:1; /* E-DMAC DO NOT have TRIMD */ | 757 | unsigned no_trimd:1; /* E-DMAC DO NOT have TRIMD */ |
758 | unsigned no_ade:1; /* E-DMAC DO NOT have ADE bit in EESR */ | 758 | unsigned no_ade:1; /* E-DMAC DO NOT have ADE bit in EESR */ |
759 | unsigned hw_crc:1; /* E-DMAC have CSMR */ | 759 | unsigned hw_crc:1; /* E-DMAC have CSMR */ |
760 | unsigned select_mii:1; /* EtherC have RMII_MII (MII select register) */ | ||
760 | }; | 761 | }; |
761 | 762 | ||
762 | struct sh_eth_private { | 763 | struct sh_eth_private { |