[PATCH 2/4] xilinx_spi: Switch to iomem functions and support little endian.

Grant Likely grant.likely at secretlab.ca
Thu Nov 12 09:25:17 EST 2009


On Wed, Nov 11, 2009 at 3:19 PM, John Linn <John.Linn at xilinx.com> wrote:
>> -----Original Message-----
>> From: Richard Röjfors [mailto:richard.rojfors at mocean-labs.com]
>> Sent: Wednesday, November 11, 2009 7:39 AM
[...]
>> -static void xspi_init_hw(void __iomem *regs_base)
>> +/* to follow are some functions that does little of big endian read and
>> + * write depending on the config of the device.
>> + */
>> +static inline void xspi_write8(struct xilinx_spi *xspi, u32 offs, u8 val)
>> +{
>> +     iowrite8(val, xspi->regs + offs + ((xspi->big_endian) ? 3 : 0));
>> +}
>> +
>> +static inline void xspi_write16(struct xilinx_spi *xspi, u32 offs, u16 val)
>> +{
>> +     if (xspi->big_endian)
>> +             iowrite16be(val, xspi->regs + offs + 2);
>> +     else
>> +             iowrite16(val, xspi->regs + offs);
>> +}
>> +
>> +static inline void xspi_write32(struct xilinx_spi *xspi, u32 offs, u32 val)
>> +{
>> +     if (xspi->big_endian)
>> +             iowrite32be(val, xspi->regs + offs);
>> +     else
>> +             iowrite32(val, xspi->regs + offs);
>> +}
>> +
>> +static inline u8 xspi_read8(struct xilinx_spi *xspi, u32 offs)
>> +{
>> +     return ioread8(xspi->regs + offs + ((xspi->big_endian) ? 3 : 0));
>> +}
>> +
>> +static inline u16 xspi_read16(struct xilinx_spi *xspi, u32 offs)
>> +{
>> +     if (xspi->big_endian)
>> +             return ioread16be(xspi->regs + offs + 2);
>> +     else
>> +             return ioread16(xspi->regs + offs);
>> +}
>> +
>> +static inline u32 xspi_read32(struct xilinx_spi *xspi, u32 offs)
>> +{
>> +     if (xspi->big_endian)
>> +             return ioread32be(xspi->regs + offs);
>> +     else
>> +             return ioread32(xspi->regs + offs);
>> +}
>> +
>
> Hi Richard,
>
> The registers of the device should all be accessible as 32 bit operations.
>
> It seems like it would be simpler to do that.

If all register accesses can be converted to 32bits, then definitely
you should just do that and make your patch simpler.

g.

-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.


More information about the Linuxppc-dev mailing list