
On Mon, Jul 28, 2008 at 17:24, Haavard Skinnemoen haavard.skinnemoen@atmel.com wrote:
"Hong Xu" hongxu.cn@gmail.com wrote:
Per J's suggestion, use CONFIG_MACB_INCLK or some other thing to simplify the *big* ifdef in driver/net/macb.c From the existing code, it seems that some boards (AT91CAP9, AT91SAM926[0,3]) need the CLKEN bit of EMAC_USRIO to be set, but others(if exist) do not need to. So in all boards that need this bit to be set, use a new CONFIG_MACB_XXX to denote this.
The problem is that CONFIG_MACB_INCLK is a completely nonsensical name. The difference isn't _only_ the CLKEN bit, it's the MII/RMII bit polarity as well. So if we want a completely "meaningful" define, we have to use something along the lines of CONFIG_MACB_HAS_CLKEN_AND_RMII_IS_ACTIVE_HIGH.
Let's stop the overengineering already. How about the patch below?
Haavard
===============[cut here]=============== From c63fe984e1a8d18c83119bbc3c575ac5175e61af Mon Sep 17 00:00:00 2001 From: Haavard Skinnemoen haavard.skinnemoen@atmel.com Date: Mon, 28 Jul 2008 11:12:33 +0200 Subject: [PATCH] macb: Simplify AT91 vs AVR32 #ifdefs
The AT91 and AVR32 platforms assign different meanings to the bits in USRIO. Until now, this has been handled with two big #ifdefs listing all the various AT91 variants, with the #else branch handling AVR32.
Since there's no catch-all CONFIG_AT91 define, switch the #ifdefs around and use CONFIG_AVR32 instead. The result is identical to what we already have, assuming all AT91 devices behave the same way.
The point is I'm not sure all AT91 series will behave the same way. But since AVR32 has less cases, it's a good idea to use #else to handle AT91 variants. So at least till now, this patch makes sense.
Signed-off-by: Haavard Skinnemoen haavard.skinnemoen@atmel.com
drivers/net/macb.c | 14 ++++++-------- 1 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/drivers/net/macb.c b/drivers/net/macb.c index aa39284..49e81d9 100644 --- a/drivers/net/macb.c +++ b/drivers/net/macb.c @@ -414,18 +414,16 @@ static int macb_init(struct eth_device *netdev, bd_t *bd)
/* choose RMII or MII mode. This depends on the board */
#ifdef CONFIG_RMII -#if defined(CONFIG_AT91CAP9) || defined(CONFIG_AT91SAM9260) || \
- defined(CONFIG_AT91SAM9263)
macb_writel(macb, USRIO, MACB_BIT(RMII) | MACB_BIT(CLKEN));
-#else +#ifdef CONFIG_AVR32 macb_writel(macb, USRIO, 0); -#endif #else -#if defined(CONFIG_AT91CAP9) || defined(CONFIG_AT91SAM9260) || \
- defined(CONFIG_AT91SAM9263)
macb_writel(macb, USRIO, MACB_BIT(CLKEN));
macb_writel(macb, USRIO, MACB_BIT(RMII) | MACB_BIT(CLKEN));
+#endif #else +#ifdef CONFIG_AVR32 macb_writel(macb, USRIO, MACB_BIT(MII)); +#else
macb_writel(macb, USRIO, MACB_BIT(CLKEN));
#endif #endif /* CONFIG_RMII */
-- 1.5.6.2