diff options
author | Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> | 2011-03-07 16:59:34 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-03-14 17:10:14 -0400 |
commit | 4986b996882d82c68ab54b822d7cfdd7dd35f19a (patch) | |
tree | 9bfe429b440788817946b3de9f616ef9a80495a5 /drivers | |
parent | 4a55530f38e4eeee3afb06093e81309138fe8360 (diff) |
net: sh_eth: remove the SH_TSU_ADDR
The defination is hardcoded in this driver for some CPUs. This patch
modifies to get resource of TSU address from platform_device.
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/sh_eth.c | 31 | ||||
-rw-r--r-- | drivers/net/sh_eth.h | 18 |
2 files changed, 27 insertions, 22 deletions
diff --git a/drivers/net/sh_eth.c b/drivers/net/sh_eth.c index 51268f591405..c7abcc586dbd 100644 --- a/drivers/net/sh_eth.c +++ b/drivers/net/sh_eth.c | |||
@@ -145,8 +145,10 @@ static struct sh_eth_cpu_data sh_eth_my_cpu_data = { | |||
145 | #define SH_ETH_HAS_TSU 1 | 145 | #define SH_ETH_HAS_TSU 1 |
146 | static void sh_eth_chip_reset(struct net_device *ndev) | 146 | static void sh_eth_chip_reset(struct net_device *ndev) |
147 | { | 147 | { |
148 | struct sh_eth_private *mdp = netdev_priv(ndev); | ||
149 | |||
148 | /* reset device */ | 150 | /* reset device */ |
149 | writel(ARSTR_ARSTR, ARSTR); | 151 | sh_eth_tsu_write(mdp, ARSTR_ARSTR, ARSTR); |
150 | mdelay(1); | 152 | mdelay(1); |
151 | } | 153 | } |
152 | 154 | ||
@@ -229,6 +231,7 @@ static struct sh_eth_cpu_data sh_eth_my_cpu_data = { | |||
229 | .hw_swap = 1, | 231 | .hw_swap = 1, |
230 | .no_trimd = 1, | 232 | .no_trimd = 1, |
231 | .no_ade = 1, | 233 | .no_ade = 1, |
234 | .tsu = 1, | ||
232 | }; | 235 | }; |
233 | 236 | ||
234 | #elif defined(CONFIG_CPU_SUBTYPE_SH7619) | 237 | #elif defined(CONFIG_CPU_SUBTYPE_SH7619) |
@@ -246,6 +249,7 @@ static struct sh_eth_cpu_data sh_eth_my_cpu_data = { | |||
246 | #define SH_ETH_HAS_TSU 1 | 249 | #define SH_ETH_HAS_TSU 1 |
247 | static struct sh_eth_cpu_data sh_eth_my_cpu_data = { | 250 | static struct sh_eth_cpu_data sh_eth_my_cpu_data = { |
248 | .eesipr_value = DMAC_M_RFRMER | DMAC_M_ECI | 0x003fffff, | 251 | .eesipr_value = DMAC_M_RFRMER | DMAC_M_ECI | 0x003fffff, |
252 | .tsu = 1, | ||
249 | }; | 253 | }; |
250 | #endif | 254 | #endif |
251 | 255 | ||
@@ -1446,6 +1450,7 @@ static void sh_eth_set_multicast_list(struct net_device *ndev) | |||
1446 | ECMR_MCT, ECMR); | 1450 | ECMR_MCT, ECMR); |
1447 | } | 1451 | } |
1448 | } | 1452 | } |
1453 | #endif /* SH_ETH_HAS_TSU */ | ||
1449 | 1454 | ||
1450 | /* SuperH's TSU register init function */ | 1455 | /* SuperH's TSU register init function */ |
1451 | static void sh_eth_tsu_init(struct sh_eth_private *mdp) | 1456 | static void sh_eth_tsu_init(struct sh_eth_private *mdp) |
@@ -1475,7 +1480,6 @@ static void sh_eth_tsu_init(struct sh_eth_private *mdp) | |||
1475 | sh_eth_tsu_write(mdp, 0, TSU_POST3); /* Disable CAM entry [16-23] */ | 1480 | sh_eth_tsu_write(mdp, 0, TSU_POST3); /* Disable CAM entry [16-23] */ |
1476 | sh_eth_tsu_write(mdp, 0, TSU_POST4); /* Disable CAM entry [24-31] */ | 1481 | sh_eth_tsu_write(mdp, 0, TSU_POST4); /* Disable CAM entry [24-31] */ |
1477 | } | 1482 | } |
1478 | #endif /* SH_ETH_HAS_TSU */ | ||
1479 | 1483 | ||
1480 | /* MDIO bus release function */ | 1484 | /* MDIO bus release function */ |
1481 | static int sh_mdio_release(struct net_device *ndev) | 1485 | static int sh_mdio_release(struct net_device *ndev) |
@@ -1676,14 +1680,23 @@ static int sh_eth_drv_probe(struct platform_device *pdev) | |||
1676 | 1680 | ||
1677 | /* First device only init */ | 1681 | /* First device only init */ |
1678 | if (!devno) { | 1682 | if (!devno) { |
1683 | if (mdp->cd->tsu) { | ||
1684 | struct resource *rtsu; | ||
1685 | rtsu = platform_get_resource(pdev, IORESOURCE_MEM, 1); | ||
1686 | if (!rtsu) { | ||
1687 | dev_err(&pdev->dev, "Not found TSU resource\n"); | ||
1688 | goto out_release; | ||
1689 | } | ||
1690 | mdp->tsu_addr = ioremap(rtsu->start, | ||
1691 | resource_size(rtsu)); | ||
1692 | } | ||
1679 | if (mdp->cd->chip_reset) | 1693 | if (mdp->cd->chip_reset) |
1680 | mdp->cd->chip_reset(ndev); | 1694 | mdp->cd->chip_reset(ndev); |
1681 | 1695 | ||
1682 | #if defined(SH_ETH_HAS_TSU) | 1696 | if (mdp->cd->tsu) { |
1683 | /* TSU init (Init only)*/ | 1697 | /* TSU init (Init only)*/ |
1684 | mdp->tsu_addr = SH_TSU_ADDR; | 1698 | sh_eth_tsu_init(mdp); |
1685 | sh_eth_tsu_init(mdp); | 1699 | } |
1686 | #endif | ||
1687 | } | 1700 | } |
1688 | 1701 | ||
1689 | /* network device register */ | 1702 | /* network device register */ |
@@ -1709,6 +1722,8 @@ out_unregister: | |||
1709 | 1722 | ||
1710 | out_release: | 1723 | out_release: |
1711 | /* net_dev free */ | 1724 | /* net_dev free */ |
1725 | if (mdp->tsu_addr) | ||
1726 | iounmap(mdp->tsu_addr); | ||
1712 | if (ndev) | 1727 | if (ndev) |
1713 | free_netdev(ndev); | 1728 | free_netdev(ndev); |
1714 | 1729 | ||
@@ -1719,7 +1734,9 @@ out: | |||
1719 | static int sh_eth_drv_remove(struct platform_device *pdev) | 1734 | static int sh_eth_drv_remove(struct platform_device *pdev) |
1720 | { | 1735 | { |
1721 | struct net_device *ndev = platform_get_drvdata(pdev); | 1736 | struct net_device *ndev = platform_get_drvdata(pdev); |
1737 | struct sh_eth_private *mdp = netdev_priv(ndev); | ||
1722 | 1738 | ||
1739 | iounmap(mdp->tsu_addr); | ||
1723 | sh_mdio_release(ndev); | 1740 | sh_mdio_release(ndev); |
1724 | unregister_netdev(ndev); | 1741 | unregister_netdev(ndev); |
1725 | pm_runtime_disable(&pdev->dev); | 1742 | pm_runtime_disable(&pdev->dev); |
diff --git a/drivers/net/sh_eth.h b/drivers/net/sh_eth.h index 1510a7ca956a..35a3adbb2e7a 100644 --- a/drivers/net/sh_eth.h +++ b/drivers/net/sh_eth.h | |||
@@ -207,6 +207,7 @@ static const u16 sh_eth_offset_gigabit[SH_ETH_MAX_REGISTER_OFFSET] = { | |||
207 | [CEECR] = 0x0770, | 207 | [CEECR] = 0x0770, |
208 | [MAFCR] = 0x0778, | 208 | [MAFCR] = 0x0778, |
209 | 209 | ||
210 | [ARSTR] = 0x0000, | ||
210 | [TSU_CTRST] = 0x0004, | 211 | [TSU_CTRST] = 0x0004, |
211 | [TSU_FWEN0] = 0x0010, | 212 | [TSU_FWEN0] = 0x0010, |
212 | [TSU_FWEN1] = 0x0014, | 213 | [TSU_FWEN1] = 0x0014, |
@@ -328,6 +329,7 @@ static const u16 sh_eth_offset_fast_sh3_sh2[SH_ETH_MAX_REGISTER_OFFSET] = { | |||
328 | [TPAUSER] = 0x01c4, | 329 | [TPAUSER] = 0x01c4, |
329 | [BCFR] = 0x01cc, | 330 | [BCFR] = 0x01cc, |
330 | 331 | ||
332 | [ARSTR] = 0x0000, | ||
331 | [TSU_CTRST] = 0x0004, | 333 | [TSU_CTRST] = 0x0004, |
332 | [TSU_FWEN0] = 0x0010, | 334 | [TSU_FWEN0] = 0x0010, |
333 | [TSU_FWEN1] = 0x0014, | 335 | [TSU_FWEN1] = 0x0014, |
@@ -371,21 +373,6 @@ static const u16 sh_eth_offset_fast_sh3_sh2[SH_ETH_MAX_REGISTER_OFFSET] = { | |||
371 | 373 | ||
372 | }; | 374 | }; |
373 | 375 | ||
374 | #if defined(CONFIG_CPU_SUBTYPE_SH7763) | ||
375 | /* This CPU register maps is very difference by other SH4 CPU */ | ||
376 | /* Chip Base Address */ | ||
377 | # define SH_TSU_ADDR 0xFEE01800 | ||
378 | # define ARSTR SH_TSU_ADDR | ||
379 | #elif defined(CONFIG_CPU_SH4) /* #if defined(CONFIG_CPU_SUBTYPE_SH7763) */ | ||
380 | #else /* #elif defined(CONFIG_CPU_SH4) */ | ||
381 | /* This section is SH3 or SH2 */ | ||
382 | #ifndef CONFIG_CPU_SUBTYPE_SH7619 | ||
383 | /* Chip base address */ | ||
384 | # define SH_TSU_ADDR 0xA7000804 | ||
385 | # define ARSTR 0xA7000800 | ||
386 | #endif | ||
387 | #endif /* CONFIG_CPU_SUBTYPE_SH7763 */ | ||
388 | |||
389 | /* Driver's parameters */ | 376 | /* Driver's parameters */ |
390 | #if defined(CONFIG_CPU_SH4) | 377 | #if defined(CONFIG_CPU_SH4) |
391 | #define SH4_SKB_RX_ALIGN 32 | 378 | #define SH4_SKB_RX_ALIGN 32 |
@@ -770,6 +757,7 @@ struct sh_eth_cpu_data { | |||
770 | unsigned mpr:1; /* EtherC have MPR */ | 757 | unsigned mpr:1; /* EtherC have MPR */ |
771 | unsigned tpauser:1; /* EtherC have TPAUSER */ | 758 | unsigned tpauser:1; /* EtherC have TPAUSER */ |
772 | unsigned bculr:1; /* EtherC have BCULR */ | 759 | unsigned bculr:1; /* EtherC have BCULR */ |
760 | unsigned tsu:1; /* EtherC have TSU */ | ||
773 | unsigned hw_swap:1; /* E-DMAC have DE bit in EDMR */ | 761 | unsigned hw_swap:1; /* E-DMAC have DE bit in EDMR */ |
774 | unsigned rpadir:1; /* E-DMAC have RPADIR */ | 762 | unsigned rpadir:1; /* E-DMAC have RPADIR */ |
775 | unsigned no_trimd:1; /* E-DMAC DO NOT have TRIMD */ | 763 | unsigned no_trimd:1; /* E-DMAC DO NOT have TRIMD */ |