diff options
author | Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> | 2011-09-27 17:48:58 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-09-28 13:41:50 -0400 |
commit | ae70644df780c0e87f1705fda932e7cb1bdb2074 (patch) | |
tree | 389689f9a84c511d99719d274f9cf8577a21e2ea /drivers/net/ethernet/renesas | |
parent | fd734c6f25aea4b2b44b045e489aec67b388577e (diff) |
net: sh_eth: use ioremap()
This patch also changes writel/readl to iowrite32/ioread32.
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/renesas')
-rw-r--r-- | drivers/net/ethernet/renesas/sh_eth.c | 38 | ||||
-rw-r--r-- | drivers/net/ethernet/renesas/sh_eth.h | 9 |
2 files changed, 29 insertions, 18 deletions
diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c index 4479a45f7329..38ccda55ea7e 100644 --- a/drivers/net/ethernet/renesas/sh_eth.c +++ b/drivers/net/ethernet/renesas/sh_eth.c | |||
@@ -155,18 +155,18 @@ static void sh_eth_chip_reset_giga(struct net_device *ndev) | |||
155 | 155 | ||
156 | /* save MAHR and MALR */ | 156 | /* save MAHR and MALR */ |
157 | for (i = 0; i < 2; i++) { | 157 | for (i = 0; i < 2; i++) { |
158 | malr[i] = readl(GIGA_MALR(i)); | 158 | malr[i] = ioread32((void *)GIGA_MALR(i)); |
159 | mahr[i] = readl(GIGA_MAHR(i)); | 159 | mahr[i] = ioread32((void *)GIGA_MAHR(i)); |
160 | } | 160 | } |
161 | 161 | ||
162 | /* reset device */ | 162 | /* reset device */ |
163 | writel(ARSTR_ARSTR, SH_GIGA_ETH_BASE + 0x1800); | 163 | iowrite32(ARSTR_ARSTR, (void *)(SH_GIGA_ETH_BASE + 0x1800)); |
164 | mdelay(1); | 164 | mdelay(1); |
165 | 165 | ||
166 | /* restore MAHR and MALR */ | 166 | /* restore MAHR and MALR */ |
167 | for (i = 0; i < 2; i++) { | 167 | for (i = 0; i < 2; i++) { |
168 | writel(malr[i], GIGA_MALR(i)); | 168 | iowrite32(malr[i], (void *)GIGA_MALR(i)); |
169 | writel(mahr[i], GIGA_MAHR(i)); | 169 | iowrite32(mahr[i], (void *)GIGA_MAHR(i)); |
170 | } | 170 | } |
171 | } | 171 | } |
172 | 172 | ||
@@ -515,9 +515,9 @@ static unsigned long sh_eth_get_edtrr_trns(struct sh_eth_private *mdp) | |||
515 | } | 515 | } |
516 | 516 | ||
517 | struct bb_info { | 517 | struct bb_info { |
518 | void (*set_gate)(unsigned long addr); | 518 | void (*set_gate)(void *addr); |
519 | struct mdiobb_ctrl ctrl; | 519 | struct mdiobb_ctrl ctrl; |
520 | u32 addr; | 520 | void *addr; |
521 | u32 mmd_msk;/* MMD */ | 521 | u32 mmd_msk;/* MMD */ |
522 | u32 mdo_msk; | 522 | u32 mdo_msk; |
523 | u32 mdi_msk; | 523 | u32 mdi_msk; |
@@ -525,21 +525,21 @@ struct bb_info { | |||
525 | }; | 525 | }; |
526 | 526 | ||
527 | /* PHY bit set */ | 527 | /* PHY bit set */ |
528 | static void bb_set(u32 addr, u32 msk) | 528 | static void bb_set(void *addr, u32 msk) |
529 | { | 529 | { |
530 | writel(readl(addr) | msk, addr); | 530 | iowrite32(ioread32(addr) | msk, addr); |
531 | } | 531 | } |
532 | 532 | ||
533 | /* PHY bit clear */ | 533 | /* PHY bit clear */ |
534 | static void bb_clr(u32 addr, u32 msk) | 534 | static void bb_clr(void *addr, u32 msk) |
535 | { | 535 | { |
536 | writel((readl(addr) & ~msk), addr); | 536 | iowrite32((ioread32(addr) & ~msk), addr); |
537 | } | 537 | } |
538 | 538 | ||
539 | /* PHY bit read */ | 539 | /* PHY bit read */ |
540 | static int bb_read(u32 addr, u32 msk) | 540 | static int bb_read(void *addr, u32 msk) |
541 | { | 541 | { |
542 | return (readl(addr) & msk) != 0; | 542 | return (ioread32(addr) & msk) != 0; |
543 | } | 543 | } |
544 | 544 | ||
545 | /* Data I/O pin control */ | 545 | /* Data I/O pin control */ |
@@ -1680,7 +1680,7 @@ static int sh_mdio_init(struct net_device *ndev, int id, | |||
1680 | } | 1680 | } |
1681 | 1681 | ||
1682 | /* bitbang init */ | 1682 | /* bitbang init */ |
1683 | bitbang->addr = ndev->base_addr + mdp->reg_offset[PIR]; | 1683 | bitbang->addr = mdp->addr + mdp->reg_offset[PIR]; |
1684 | bitbang->set_gate = pd->set_mdio_gate; | 1684 | bitbang->set_gate = pd->set_mdio_gate; |
1685 | bitbang->mdi_msk = 0x08; | 1685 | bitbang->mdi_msk = 0x08; |
1686 | bitbang->mdo_msk = 0x04; | 1686 | bitbang->mdo_msk = 0x04; |
@@ -1812,6 +1812,13 @@ static int sh_eth_drv_probe(struct platform_device *pdev) | |||
1812 | ether_setup(ndev); | 1812 | ether_setup(ndev); |
1813 | 1813 | ||
1814 | mdp = netdev_priv(ndev); | 1814 | mdp = netdev_priv(ndev); |
1815 | mdp->addr = ioremap(res->start, resource_size(res)); | ||
1816 | if (mdp->addr == NULL) { | ||
1817 | ret = -ENOMEM; | ||
1818 | dev_err(&pdev->dev, "ioremap failed.\n"); | ||
1819 | goto out_release; | ||
1820 | } | ||
1821 | |||
1815 | spin_lock_init(&mdp->lock); | 1822 | spin_lock_init(&mdp->lock); |
1816 | mdp->pdev = pdev; | 1823 | mdp->pdev = pdev; |
1817 | pm_runtime_enable(&pdev->dev); | 1824 | pm_runtime_enable(&pdev->dev); |
@@ -1892,6 +1899,8 @@ out_unregister: | |||
1892 | 1899 | ||
1893 | out_release: | 1900 | out_release: |
1894 | /* net_dev free */ | 1901 | /* net_dev free */ |
1902 | if (mdp && mdp->addr) | ||
1903 | iounmap(mdp->addr); | ||
1895 | if (mdp && mdp->tsu_addr) | 1904 | if (mdp && mdp->tsu_addr) |
1896 | iounmap(mdp->tsu_addr); | 1905 | iounmap(mdp->tsu_addr); |
1897 | if (ndev) | 1906 | if (ndev) |
@@ -1910,6 +1919,7 @@ static int sh_eth_drv_remove(struct platform_device *pdev) | |||
1910 | sh_mdio_release(ndev); | 1919 | sh_mdio_release(ndev); |
1911 | unregister_netdev(ndev); | 1920 | unregister_netdev(ndev); |
1912 | pm_runtime_disable(&pdev->dev); | 1921 | pm_runtime_disable(&pdev->dev); |
1922 | iounmap(mdp->addr); | ||
1913 | free_netdev(ndev); | 1923 | free_netdev(ndev); |
1914 | platform_set_drvdata(pdev, NULL); | 1924 | platform_set_drvdata(pdev, NULL); |
1915 | 1925 | ||
diff --git a/drivers/net/ethernet/renesas/sh_eth.h b/drivers/net/ethernet/renesas/sh_eth.h index c3048a6ba676..78e586ecdeaa 100644 --- a/drivers/net/ethernet/renesas/sh_eth.h +++ b/drivers/net/ethernet/renesas/sh_eth.h | |||
@@ -762,6 +762,7 @@ struct sh_eth_private { | |||
762 | struct platform_device *pdev; | 762 | struct platform_device *pdev; |
763 | struct sh_eth_cpu_data *cd; | 763 | struct sh_eth_cpu_data *cd; |
764 | const u16 *reg_offset; | 764 | const u16 *reg_offset; |
765 | void __iomem *addr; | ||
765 | void __iomem *tsu_addr; | 766 | void __iomem *tsu_addr; |
766 | dma_addr_t rx_desc_dma; | 767 | dma_addr_t rx_desc_dma; |
767 | dma_addr_t tx_desc_dma; | 768 | dma_addr_t tx_desc_dma; |
@@ -811,7 +812,7 @@ static inline void sh_eth_write(struct net_device *ndev, unsigned long data, | |||
811 | { | 812 | { |
812 | struct sh_eth_private *mdp = netdev_priv(ndev); | 813 | struct sh_eth_private *mdp = netdev_priv(ndev); |
813 | 814 | ||
814 | writel(data, ndev->base_addr + mdp->reg_offset[enum_index]); | 815 | iowrite32(data, mdp->addr + mdp->reg_offset[enum_index]); |
815 | } | 816 | } |
816 | 817 | ||
817 | static inline unsigned long sh_eth_read(struct net_device *ndev, | 818 | static inline unsigned long sh_eth_read(struct net_device *ndev, |
@@ -819,19 +820,19 @@ static inline unsigned long sh_eth_read(struct net_device *ndev, | |||
819 | { | 820 | { |
820 | struct sh_eth_private *mdp = netdev_priv(ndev); | 821 | struct sh_eth_private *mdp = netdev_priv(ndev); |
821 | 822 | ||
822 | return readl(ndev->base_addr + mdp->reg_offset[enum_index]); | 823 | return ioread32(mdp->addr + mdp->reg_offset[enum_index]); |
823 | } | 824 | } |
824 | 825 | ||
825 | static inline void sh_eth_tsu_write(struct sh_eth_private *mdp, | 826 | static inline void sh_eth_tsu_write(struct sh_eth_private *mdp, |
826 | unsigned long data, int enum_index) | 827 | unsigned long data, int enum_index) |
827 | { | 828 | { |
828 | writel(data, mdp->tsu_addr + mdp->reg_offset[enum_index]); | 829 | iowrite32(data, mdp->tsu_addr + mdp->reg_offset[enum_index]); |
829 | } | 830 | } |
830 | 831 | ||
831 | static inline unsigned long sh_eth_tsu_read(struct sh_eth_private *mdp, | 832 | static inline unsigned long sh_eth_tsu_read(struct sh_eth_private *mdp, |
832 | int enum_index) | 833 | int enum_index) |
833 | { | 834 | { |
834 | return readl(mdp->tsu_addr + mdp->reg_offset[enum_index]); | 835 | return ioread32(mdp->tsu_addr + mdp->reg_offset[enum_index]); |
835 | } | 836 | } |
836 | 837 | ||
837 | #endif /* #ifndef __SH_ETH_H__ */ | 838 | #endif /* #ifndef __SH_ETH_H__ */ |