[U-Boot] [PATCH v2 1/2] gpio: Add GPIO driver framework for Marvell SoCs

Prafulla Wadaskar prafulla at marvell.com
Sun Aug 7 04:16:13 CEST 2011



> -----Original Message-----
> From: Ajay Bhargav [mailto:ajay.bhargav at einfochips.com]
> Sent: Saturday, August 06, 2011 10:40 AM
> To: Prafulla Wadaskar
> Cc: u-boot at lists.denx.de; Lei Wen; Simon Guinot
> Subject: Re: [U-Boot] [PATCH v2 1/2] gpio: Add GPIO driver framework for
> Marvell SoCs
> 
...snip...

> > >
> > > @lei
> > > How bout if we check for architecture and use specific code or
> > defines?
> > > i.e.
> > > #ifdef CONFIG_KIRKWOOD
> > > //KW code
> > > #elif CONFIG_ARMADA100
> > > //Armada code
> > > #else
> > > //orion or other?
> > > #endif
> >
> > Let's avoid this, because there will be several SoC architectures that
> > uses similar GPIO register definitions, like kirkwood/orion have
> > similar definition and armada/mmp/pantheon/etc.. have different one.
> >
> > So we will end up having several #ifdefs. Ideally #ifdefs are
> > discouraged for better coding practices.
> >
> > Instead,
> > I would suggest to use macros for this code segments or alternatively
> > inlined functions and those should be defined in mvgpio.h, #ifdefed
> > with  CPU core subversion (i.e. CONFIG_FEROCEION,
> > CONFIG_SHEEVA_88SV331xV5)
> >
> > Regards..
> > Prafulla . .
> 
> Hi Prafulla,
> 
> I think it will be better to keep two driver files. Let this patch be
> for
> Armada/mmp/pantheon and other compatible SoCs. Should the common GPIO
> struct for armada/mmp etc.. be moved out of GPIO.h to mvgpio.h?

Hi Ajay
This is straight forward solution, but the idea here to share the code, better design.
To simplify further, you can go ahead with below arch for this design.

1. Generic driver skeleton in mvgpio.c
2. Generic driver header mvgpio.h (optional you can avoid this)
3. Arch specific header asm/arch/gpio.h, to hold MAX GPIOs, register definition and gpio set/clr,config inlined functions or macros only.
4. Base address in asm/arch/<soc_name>.h and this file to be included in asm/arch/gpio.h

In future if we need to add support for other SoC we will add gpio.h.

Regards..
Prafulla . .


More information about the U-Boot mailing list