diff options
author | Andrew Victor <andrew@sanpeople.com> | 2007-02-07 10:40:44 -0500 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-02-07 18:50:53 -0500 |
commit | 0cc8674f2be3078fb586add1900c7835c977f384 (patch) | |
tree | a27d665a8e859755f2c8974e5e90e83f6fea85c2 /drivers/net/macb.c | |
parent | 683349a3fae4896d91b1fe507ebbadb866587cd8 (diff) |
AT91: MACB support
The Atmel MACB Ethernet peripheral is also integrated in the AT91SAM9260
and AT91SAM9263 processors. The differences from the AVR32 version are:
* Single peripheral clock.
* MII/RMII selection bit is inverted.
* Clock enable bit.
Original patch from Patrice Vilchez.
Signed-off-by: Andrew Victor <andrew@sanpeople.com>
Signed-off-by: Haavard Skinnemoen <hskinnemoen@atmel.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net/macb.c')
-rw-r--r-- | drivers/net/macb.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/drivers/net/macb.c b/drivers/net/macb.c index 25b559b5d5ed..5eb7a3536f29 100644 --- a/drivers/net/macb.c +++ b/drivers/net/macb.c | |||
@@ -1046,6 +1046,14 @@ static int __devinit macb_probe(struct platform_device *pdev) | |||
1046 | 1046 | ||
1047 | spin_lock_init(&bp->lock); | 1047 | spin_lock_init(&bp->lock); |
1048 | 1048 | ||
1049 | #if defined(CONFIG_ARCH_AT91) | ||
1050 | bp->pclk = clk_get(&pdev->dev, "macb_clk"); | ||
1051 | if (IS_ERR(bp->pclk)) { | ||
1052 | dev_err(&pdev->dev, "failed to get macb_clk\n"); | ||
1053 | goto err_out_free_dev; | ||
1054 | } | ||
1055 | clk_enable(bp->pclk); | ||
1056 | #else | ||
1049 | bp->pclk = clk_get(&pdev->dev, "pclk"); | 1057 | bp->pclk = clk_get(&pdev->dev, "pclk"); |
1050 | if (IS_ERR(bp->pclk)) { | 1058 | if (IS_ERR(bp->pclk)) { |
1051 | dev_err(&pdev->dev, "failed to get pclk\n"); | 1059 | dev_err(&pdev->dev, "failed to get pclk\n"); |
@@ -1059,6 +1067,7 @@ static int __devinit macb_probe(struct platform_device *pdev) | |||
1059 | 1067 | ||
1060 | clk_enable(bp->pclk); | 1068 | clk_enable(bp->pclk); |
1061 | clk_enable(bp->hclk); | 1069 | clk_enable(bp->hclk); |
1070 | #endif | ||
1062 | 1071 | ||
1063 | bp->regs = ioremap(regs->start, regs->end - regs->start + 1); | 1072 | bp->regs = ioremap(regs->start, regs->end - regs->start + 1); |
1064 | if (!bp->regs) { | 1073 | if (!bp->regs) { |
@@ -1119,9 +1128,17 @@ static int __devinit macb_probe(struct platform_device *pdev) | |||
1119 | 1128 | ||
1120 | pdata = pdev->dev.platform_data; | 1129 | pdata = pdev->dev.platform_data; |
1121 | if (pdata && pdata->is_rmii) | 1130 | if (pdata && pdata->is_rmii) |
1131 | #if defined(CONFIG_ARCH_AT91) | ||
1132 | macb_writel(bp, USRIO, (MACB_BIT(RMII) | MACB_BIT(CLKEN)) ); | ||
1133 | #else | ||
1122 | macb_writel(bp, USRIO, 0); | 1134 | macb_writel(bp, USRIO, 0); |
1135 | #endif | ||
1123 | else | 1136 | else |
1137 | #if defined(CONFIG_ARCH_AT91) | ||
1138 | macb_writel(bp, USRIO, MACB_BIT(CLKEN)); | ||
1139 | #else | ||
1124 | macb_writel(bp, USRIO, MACB_BIT(MII)); | 1140 | macb_writel(bp, USRIO, MACB_BIT(MII)); |
1141 | #endif | ||
1125 | 1142 | ||
1126 | bp->tx_pending = DEF_TX_RING_PENDING; | 1143 | bp->tx_pending = DEF_TX_RING_PENDING; |
1127 | 1144 | ||
@@ -1148,9 +1165,11 @@ err_out_free_irq: | |||
1148 | err_out_iounmap: | 1165 | err_out_iounmap: |
1149 | iounmap(bp->regs); | 1166 | iounmap(bp->regs); |
1150 | err_out_disable_clocks: | 1167 | err_out_disable_clocks: |
1168 | #ifndef CONFIG_ARCH_AT91 | ||
1151 | clk_disable(bp->hclk); | 1169 | clk_disable(bp->hclk); |
1152 | clk_disable(bp->pclk); | ||
1153 | clk_put(bp->hclk); | 1170 | clk_put(bp->hclk); |
1171 | #endif | ||
1172 | clk_disable(bp->pclk); | ||
1154 | err_out_put_pclk: | 1173 | err_out_put_pclk: |
1155 | clk_put(bp->pclk); | 1174 | clk_put(bp->pclk); |
1156 | err_out_free_dev: | 1175 | err_out_free_dev: |
@@ -1173,9 +1192,11 @@ static int __devexit macb_remove(struct platform_device *pdev) | |||
1173 | unregister_netdev(dev); | 1192 | unregister_netdev(dev); |
1174 | free_irq(dev->irq, dev); | 1193 | free_irq(dev->irq, dev); |
1175 | iounmap(bp->regs); | 1194 | iounmap(bp->regs); |
1195 | #ifndef CONFIG_ARCH_AT91 | ||
1176 | clk_disable(bp->hclk); | 1196 | clk_disable(bp->hclk); |
1177 | clk_disable(bp->pclk); | ||
1178 | clk_put(bp->hclk); | 1197 | clk_put(bp->hclk); |
1198 | #endif | ||
1199 | clk_disable(bp->pclk); | ||
1179 | clk_put(bp->pclk); | 1200 | clk_put(bp->pclk); |
1180 | free_netdev(dev); | 1201 | free_netdev(dev); |
1181 | platform_set_drvdata(pdev, NULL); | 1202 | platform_set_drvdata(pdev, NULL); |