From: Hong Xu Date: Mon, 28 Jul 2008 19:20:04 +0800 Subject: [U-Boot-Users] [PATCH 1/1] Add support for ATMELAT91SAM9G20EKboard In-Reply-To: <20080728112429.4b0e74e9@hskinnemo-gx745.norway.atmel.com> References: <8130D65399114AF5A2B07FED30A676C2@aeglos> <20080726113654.GC26611@game.jcrosoft.org> <1516faed0807271845r82f3ca8v3f957638ef7f7b8@mail.gmail.com> <20080728102957.5e58c7e5@hskinnemo-gx745.norway.atmel.com> <1516faed0807280159w7166c1adw1c03b61e38400801@mail.gmail.com> <20080728112429.4b0e74e9@hskinnemo-gx745.norway.atmel.com> Message-ID: <1516faed0807280420n4778100ds993acca62a10d1a0@mail.gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Mon, Jul 28, 2008 at 17:24, Haavard Skinnemoen wrote: > "Hong Xu" 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 > 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 > --- > 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 > >