[PATCH 1/3] imx: make IMX_IO_ADDRESS assembly compatible

Baruch Siach baruch at tkos.co.il
Tue Mar 16 05:41:55 EDT 2010


Hi Uwe,

On Tue, Mar 16, 2010 at 09:52:12AM +0100, Uwe Kleine-König wrote:
> On Tue, Mar 16, 2010 at 08:35:37AM +0200, Baruch Siach wrote:
> > The IMX_IO_ADDRESS macro may be used directly on indirectly in assembly code.
> > Make it assembly compatible by using the IOMEM helper macro.
> > 
> > Signed-off-by: Baruch Siach <baruch at tkos.co.il>
> > ---
> >  arch/arm/plat-mxc/include/mach/hardware.h |   16 ++++++++++++----
> >  1 files changed, 12 insertions(+), 4 deletions(-)
> > 
> > diff --git a/arch/arm/plat-mxc/include/mach/hardware.h b/arch/arm/plat-mxc/include/mach/hardware.h
> > index ebadf4a..f75a5cc 100644
> > --- a/arch/arm/plat-mxc/include/mach/hardware.h
> > +++ b/arch/arm/plat-mxc/include/mach/hardware.h
> > @@ -22,10 +22,18 @@
> >  
> >  #include <asm/sizes.h>
> >  
> > -#define IMX_IO_ADDRESS(addr, module)					\
> > -	((void __force __iomem *)					\
> > -	 (((unsigned long)((addr) - (module ## _BASE_ADDR)) < module ## _SIZE) ?\
> > -	 (addr) - (module ## _BASE_ADDR) + (module ## _BASE_ADDR_VIRT) : 0))
> > +#ifdef __ASSEMBLER__
> > +#define IOMEM(addr,base,size,virt)	((addr) - (base) + (virt))
> > +#else
> > +#define IOMEM(addr,base,size,virt)			\
> > +	((void __force __iomem *)			\
> > +	((unsigned long) ((addr) - (base)) < size) ?	\
> > +	(addr) - (base) + (virt) : 0)
> > +#endif
> > +
> > +#define IMX_IO_ADDRESS(addr, module)				\
> > +	IOMEM(addr, module ## _BASE_ADDR, module ## _SIZE,	\
> > +	module ## _BASE_ADDR_VIRT)
> hmmm, the construct used to define MX27_IO_ADDRESS et al. does only work
> without __ASSEMBLER__ anyhow, still I think it might be at least
> surprising that e.g.
> 
> 	IOMEM(MX27_WDOG_BASE_ADDR, MX27_SAHB1_BASE_ADDR, MX27_SAHB1_SIZE, MX27_SAHB1_BASE_ADDR_VIRT)
> 
> evaluates to 0x84102000 if __ASSEMBLER__ is defined but 0 if not.
> 
> I tend to think we should use a different solution.
> 
> IMHO it would be great to have a macro that maps physical to virtual
> addresses for both assembler and C.  E.g. ns9xxx has something like
> that[1], other probably, too, but for imx it would be harder as the used
> addresses differ and are spread over the whole address space.  Some time
> ago I found a function that would do the task, but Sascha didn't agree
> to use it because it involved too much magic.

So, what you actually suggest is to use the simple arithmetic IOMEM version 
which is assembly compatible, and remove the C only ?: error checking, as is 
being done in ns9xxx, right? Or are you suggesting to change the P2V mapping 
of the entire i.MX platform so that this error checking is not needed?

baruch

-- 
                                                     ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -



More information about the linux-arm-kernel mailing list