diff options
author | Manuel Lauss <manuel.lauss@googlemail.com> | 2011-08-02 13:50:57 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2011-10-24 18:34:22 -0400 |
commit | 553737aa95016542780e7a4b4b810fef85c4eb72 (patch) | |
tree | 0cf2429c1ace23d7e5f9b35fcb8e4a287283c1d1 /drivers/net | |
parent | 08fa624f504e5edab6f69014fc92ecc7b2bbd81e (diff) |
NET: au1000_eth: Pass MACDMA address through platform resource info.
This patch removes the last hardcoded base address from the au1000_eth
driver. The base address of the MACDMA unit was derived from the
platform device id; if someone registered the MACs in inverse order
both would not work.
So instead pass the base address of the DMA unit to the driver with
the other platform resource information.
Signed-off-by: Manuel Lauss <manuel.lauss@googlemail.com>
Acked-by: David S. Miller <davem@davemloft.net>
To: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/2674/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/au1000_eth.c | 48 | ||||
-rw-r--r-- | drivers/net/au1000_eth.h | 2 |
2 files changed, 37 insertions, 13 deletions
diff --git a/drivers/net/au1000_eth.c b/drivers/net/au1000_eth.c index b9debcfb61a0..7013afcc13e6 100644 --- a/drivers/net/au1000_eth.c +++ b/drivers/net/au1000_eth.c | |||
@@ -541,19 +541,17 @@ static void au1000_reset_mac(struct net_device *dev) | |||
541 | * these are not descriptors sitting in memory. | 541 | * these are not descriptors sitting in memory. |
542 | */ | 542 | */ |
543 | static void | 543 | static void |
544 | au1000_setup_hw_rings(struct au1000_private *aup, u32 rx_base, u32 tx_base) | 544 | au1000_setup_hw_rings(struct au1000_private *aup, void __iomem *tx_base) |
545 | { | 545 | { |
546 | int i; | 546 | int i; |
547 | 547 | ||
548 | for (i = 0; i < NUM_RX_DMA; i++) { | 548 | for (i = 0; i < NUM_RX_DMA; i++) { |
549 | aup->rx_dma_ring[i] = | 549 | aup->rx_dma_ring[i] = (struct rx_dma *) |
550 | (struct rx_dma *) | 550 | (tx_base + 0x100 + sizeof(struct rx_dma) * i); |
551 | (rx_base + sizeof(struct rx_dma)*i); | ||
552 | } | 551 | } |
553 | for (i = 0; i < NUM_TX_DMA; i++) { | 552 | for (i = 0; i < NUM_TX_DMA; i++) { |
554 | aup->tx_dma_ring[i] = | 553 | aup->tx_dma_ring[i] = (struct tx_dma *) |
555 | (struct tx_dma *) | 554 | (tx_base + sizeof(struct tx_dma) * i); |
556 | (tx_base + sizeof(struct tx_dma)*i); | ||
557 | } | 555 | } |
558 | } | 556 | } |
559 | 557 | ||
@@ -1026,7 +1024,7 @@ static int __devinit au1000_probe(struct platform_device *pdev) | |||
1026 | struct net_device *dev = NULL; | 1024 | struct net_device *dev = NULL; |
1027 | struct db_dest *pDB, *pDBfree; | 1025 | struct db_dest *pDB, *pDBfree; |
1028 | int irq, i, err = 0; | 1026 | int irq, i, err = 0; |
1029 | struct resource *base, *macen; | 1027 | struct resource *base, *macen, *macdma; |
1030 | 1028 | ||
1031 | base = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 1029 | base = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
1032 | if (!base) { | 1030 | if (!base) { |
@@ -1049,6 +1047,13 @@ static int __devinit au1000_probe(struct platform_device *pdev) | |||
1049 | goto out; | 1047 | goto out; |
1050 | } | 1048 | } |
1051 | 1049 | ||
1050 | macdma = platform_get_resource(pdev, IORESOURCE_MEM, 2); | ||
1051 | if (!macdma) { | ||
1052 | dev_err(&pdev->dev, "failed to retrieve MACDMA registers\n"); | ||
1053 | err = -ENODEV; | ||
1054 | goto out; | ||
1055 | } | ||
1056 | |||
1052 | if (!request_mem_region(base->start, resource_size(base), | 1057 | if (!request_mem_region(base->start, resource_size(base), |
1053 | pdev->name)) { | 1058 | pdev->name)) { |
1054 | dev_err(&pdev->dev, "failed to request memory region for base registers\n"); | 1059 | dev_err(&pdev->dev, "failed to request memory region for base registers\n"); |
@@ -1063,6 +1068,13 @@ static int __devinit au1000_probe(struct platform_device *pdev) | |||
1063 | goto err_request; | 1068 | goto err_request; |
1064 | } | 1069 | } |
1065 | 1070 | ||
1071 | if (!request_mem_region(macdma->start, resource_size(macdma), | ||
1072 | pdev->name)) { | ||
1073 | dev_err(&pdev->dev, "failed to request MACDMA memory region\n"); | ||
1074 | err = -ENXIO; | ||
1075 | goto err_macdma; | ||
1076 | } | ||
1077 | |||
1066 | dev = alloc_etherdev(sizeof(struct au1000_private)); | 1078 | dev = alloc_etherdev(sizeof(struct au1000_private)); |
1067 | if (!dev) { | 1079 | if (!dev) { |
1068 | dev_err(&pdev->dev, "alloc_etherdev failed\n"); | 1080 | dev_err(&pdev->dev, "alloc_etherdev failed\n"); |
@@ -1109,10 +1121,14 @@ static int __devinit au1000_probe(struct platform_device *pdev) | |||
1109 | } | 1121 | } |
1110 | aup->mac_id = pdev->id; | 1122 | aup->mac_id = pdev->id; |
1111 | 1123 | ||
1112 | if (pdev->id == 0) | 1124 | aup->macdma = ioremap_nocache(macdma->start, resource_size(macdma)); |
1113 | au1000_setup_hw_rings(aup, MAC0_RX_DMA_ADDR, MAC0_TX_DMA_ADDR); | 1125 | if (!aup->macdma) { |
1114 | else if (pdev->id == 1) | 1126 | dev_err(&pdev->dev, "failed to ioremap MACDMA registers\n"); |
1115 | au1000_setup_hw_rings(aup, MAC1_RX_DMA_ADDR, MAC1_TX_DMA_ADDR); | 1127 | err = -ENXIO; |
1128 | goto err_remap3; | ||
1129 | } | ||
1130 | |||
1131 | au1000_setup_hw_rings(aup, aup->macdma); | ||
1116 | 1132 | ||
1117 | /* set a random MAC now in case platform_data doesn't provide one */ | 1133 | /* set a random MAC now in case platform_data doesn't provide one */ |
1118 | random_ether_addr(dev->dev_addr); | 1134 | random_ether_addr(dev->dev_addr); |
@@ -1252,6 +1268,8 @@ err_out: | |||
1252 | err_mdiobus_reg: | 1268 | err_mdiobus_reg: |
1253 | mdiobus_free(aup->mii_bus); | 1269 | mdiobus_free(aup->mii_bus); |
1254 | err_mdiobus_alloc: | 1270 | err_mdiobus_alloc: |
1271 | iounmap(aup->macdma); | ||
1272 | err_remap3: | ||
1255 | iounmap(aup->enable); | 1273 | iounmap(aup->enable); |
1256 | err_remap2: | 1274 | err_remap2: |
1257 | iounmap(aup->mac); | 1275 | iounmap(aup->mac); |
@@ -1261,6 +1279,8 @@ err_remap1: | |||
1261 | err_vaddr: | 1279 | err_vaddr: |
1262 | free_netdev(dev); | 1280 | free_netdev(dev); |
1263 | err_alloc: | 1281 | err_alloc: |
1282 | release_mem_region(macdma->start, resource_size(macdma)); | ||
1283 | err_macdma: | ||
1264 | release_mem_region(macen->start, resource_size(macen)); | 1284 | release_mem_region(macen->start, resource_size(macen)); |
1265 | err_request: | 1285 | err_request: |
1266 | release_mem_region(base->start, resource_size(base)); | 1286 | release_mem_region(base->start, resource_size(base)); |
@@ -1293,9 +1313,13 @@ static int __devexit au1000_remove(struct platform_device *pdev) | |||
1293 | (NUM_TX_BUFFS + NUM_RX_BUFFS), | 1313 | (NUM_TX_BUFFS + NUM_RX_BUFFS), |
1294 | (void *)aup->vaddr, aup->dma_addr); | 1314 | (void *)aup->vaddr, aup->dma_addr); |
1295 | 1315 | ||
1316 | iounmap(aup->macdma); | ||
1296 | iounmap(aup->mac); | 1317 | iounmap(aup->mac); |
1297 | iounmap(aup->enable); | 1318 | iounmap(aup->enable); |
1298 | 1319 | ||
1320 | base = platform_get_resource(pdev, IORESOURCE_MEM, 2); | ||
1321 | release_mem_region(base->start, resource_size(base)); | ||
1322 | |||
1299 | base = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 1323 | base = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
1300 | release_mem_region(base->start, resource_size(base)); | 1324 | release_mem_region(base->start, resource_size(base)); |
1301 | 1325 | ||
diff --git a/drivers/net/au1000_eth.h b/drivers/net/au1000_eth.h index 6229c774552c..4b7f7ad62bb8 100644 --- a/drivers/net/au1000_eth.h +++ b/drivers/net/au1000_eth.h | |||
@@ -124,7 +124,7 @@ struct au1000_private { | |||
124 | */ | 124 | */ |
125 | struct mac_reg *mac; /* mac registers */ | 125 | struct mac_reg *mac; /* mac registers */ |
126 | u32 *enable; /* address of MAC Enable Register */ | 126 | u32 *enable; /* address of MAC Enable Register */ |
127 | 127 | void __iomem *macdma; /* base of MAC DMA port */ | |
128 | u32 vaddr; /* virtual address of rx/tx buffers */ | 128 | u32 vaddr; /* virtual address of rx/tx buffers */ |
129 | dma_addr_t dma_addr; /* dma address of rx/tx buffers */ | 129 | dma_addr_t dma_addr; /* dma address of rx/tx buffers */ |
130 | 130 | ||