* [PATCH] AT91: MACB support
@ 2007-02-07 15:40 Haavard Skinnemoen
2007-02-07 22:28 ` Jeff Garzik
0 siblings, 1 reply; 2+ messages in thread
From: Haavard Skinnemoen @ 2007-02-07 15:40 UTC (permalink / raw)
To: Jeff Garzik; +Cc: netdev, Patrice Vilchez, Andrew Victor, Haavard Skinnemoen
From: Andrew Victor <andrew@sanpeople.com>
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>
---
drivers/net/Kconfig | 2 +-
drivers/net/macb.c | 25 +++++++++++++++++++++++--
drivers/net/macb.h | 8 +++++++-
3 files changed, 31 insertions(+), 4 deletions(-)
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 8aa8dd0..3318f30 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -190,7 +190,7 @@ config MII
config MACB
tristate "Atmel MACB support"
- depends on NET_ETHERNET && AVR32
+ depends on NET_ETHERNET && (AVR32 || ARCH_AT91SAM9260 || ARCH_AT91SAM9263)
select MII
help
The Atmel MACB ethernet interface is found on many AT32 and AT91
diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index 25b559b..5eb7a35 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -1046,6 +1046,14 @@ static int __devinit macb_probe(struct platform_device *pdev)
spin_lock_init(&bp->lock);
+#if defined(CONFIG_ARCH_AT91)
+ bp->pclk = clk_get(&pdev->dev, "macb_clk");
+ if (IS_ERR(bp->pclk)) {
+ dev_err(&pdev->dev, "failed to get macb_clk\n");
+ goto err_out_free_dev;
+ }
+ clk_enable(bp->pclk);
+#else
bp->pclk = clk_get(&pdev->dev, "pclk");
if (IS_ERR(bp->pclk)) {
dev_err(&pdev->dev, "failed to get pclk\n");
@@ -1059,6 +1067,7 @@ static int __devinit macb_probe(struct platform_device *pdev)
clk_enable(bp->pclk);
clk_enable(bp->hclk);
+#endif
bp->regs = ioremap(regs->start, regs->end - regs->start + 1);
if (!bp->regs) {
@@ -1119,9 +1128,17 @@ static int __devinit macb_probe(struct platform_device *pdev)
pdata = pdev->dev.platform_data;
if (pdata && pdata->is_rmii)
+#if defined(CONFIG_ARCH_AT91)
+ macb_writel(bp, USRIO, (MACB_BIT(RMII) | MACB_BIT(CLKEN)) );
+#else
macb_writel(bp, USRIO, 0);
+#endif
else
+#if defined(CONFIG_ARCH_AT91)
+ macb_writel(bp, USRIO, MACB_BIT(CLKEN));
+#else
macb_writel(bp, USRIO, MACB_BIT(MII));
+#endif
bp->tx_pending = DEF_TX_RING_PENDING;
@@ -1148,9 +1165,11 @@ err_out_free_irq:
err_out_iounmap:
iounmap(bp->regs);
err_out_disable_clocks:
+#ifndef CONFIG_ARCH_AT91
clk_disable(bp->hclk);
- clk_disable(bp->pclk);
clk_put(bp->hclk);
+#endif
+ clk_disable(bp->pclk);
err_out_put_pclk:
clk_put(bp->pclk);
err_out_free_dev:
@@ -1173,9 +1192,11 @@ static int __devexit macb_remove(struct platform_device *pdev)
unregister_netdev(dev);
free_irq(dev->irq, dev);
iounmap(bp->regs);
+#ifndef CONFIG_ARCH_AT91
clk_disable(bp->hclk);
- clk_disable(bp->pclk);
clk_put(bp->hclk);
+#endif
+ clk_disable(bp->pclk);
clk_put(bp->pclk);
free_netdev(dev);
platform_set_drvdata(pdev, NULL);
diff --git a/drivers/net/macb.h b/drivers/net/macb.h
index 27bf0ae..b3bb218 100644
--- a/drivers/net/macb.h
+++ b/drivers/net/macb.h
@@ -200,7 +200,7 @@
#define MACB_SOF_OFFSET 30
#define MACB_SOF_SIZE 2
-/* Bitfields in USRIO */
+/* Bitfields in USRIO (AVR32) */
#define MACB_MII_OFFSET 0
#define MACB_MII_SIZE 1
#define MACB_EAM_OFFSET 1
@@ -210,6 +210,12 @@
#define MACB_TX_PAUSE_ZERO_OFFSET 3
#define MACB_TX_PAUSE_ZERO_SIZE 1
+/* Bitfields in USRIO (AT91) */
+#define MACB_RMII_OFFSET 0
+#define MACB_RMII_SIZE 1
+#define MACB_CLKEN_OFFSET 1
+#define MACB_CLKEN_SIZE 1
+
/* Bitfields in WOL */
#define MACB_IP_OFFSET 0
#define MACB_IP_SIZE 16
--
1.4.4.3
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] AT91: MACB support
2007-02-07 15:40 [PATCH] AT91: MACB support Haavard Skinnemoen
@ 2007-02-07 22:28 ` Jeff Garzik
0 siblings, 0 replies; 2+ messages in thread
From: Jeff Garzik @ 2007-02-07 22:28 UTC (permalink / raw)
To: Haavard Skinnemoen; +Cc: netdev, Patrice Vilchez, Andrew Victor
Haavard Skinnemoen wrote:
> From: Andrew Victor <andrew@sanpeople.com>
>
> 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>
> ---
> drivers/net/Kconfig | 2 +-
> drivers/net/macb.c | 25 +++++++++++++++++++++++--
> drivers/net/macb.h | 8 +++++++-
> 3 files changed, 31 insertions(+), 4 deletions(-)
applied
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-02-07 22:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-02-07 15:40 [PATCH] AT91: MACB support Haavard Skinnemoen
2007-02-07 22:28 ` Jeff Garzik
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).