[U-Boot] [PATCH] spi: kirkwood_spi: implement mvebu_spi_set_mode()

Jagan Teki jagan at openedev.com
Wed Oct 26 09:15:54 CEST 2016


On Fri, Oct 14, 2016 at 8:49 AM, Chris Packham <judge.packham at gmail.com> wrote:
> Set the appropriate bits in the interface config register based
> on the SPI_ mode flags.
>
> Signed-off-by: Chris Packham <judge.packham at gmail.com>
> ---
>
>  arch/arm/include/asm/arch-mvebu/spi.h |  4 ++++
>  drivers/spi/kirkwood_spi.c            | 13 +++++++++++++
>  2 files changed, 17 insertions(+)
>
> diff --git a/arch/arm/include/asm/arch-mvebu/spi.h b/arch/arm/include/asm/arch-mvebu/spi.h
> index 78869a253d1f..3545aed17347 100644
> --- a/arch/arm/include/asm/arch-mvebu/spi.h
> +++ b/arch/arm/include/asm/arch-mvebu/spi.h
> @@ -52,6 +52,10 @@ struct kwspi_registers {
>  #define KWSPI_ADRLEN_3BYTE     (2 << 8)
>  #define KWSPI_ADRLEN_4BYTE     (3 << 8)
>  #define KWSPI_ADRLEN_MASK      (3 << 8)
> +#define KWSPI_CPOL             (1 << 11)
> +#define KWSPI_CPHA             (1 << 12)
> +#define KWSPI_TXLSBF           (1 << 13)
> +#define KWSPI_RXLSBF           (1 << 14)
>
>  #define KWSPI_IRQUNMASK                1 /* unmask SPI interrupt */
>  #define KWSPI_IRQMASK          0 /* mask SPI interrupt */
> diff --git a/drivers/spi/kirkwood_spi.c b/drivers/spi/kirkwood_spi.c
> index 6851ba942f51..69a0be9ea5b2 100644
> --- a/drivers/spi/kirkwood_spi.c
> +++ b/drivers/spi/kirkwood_spi.c
> @@ -271,6 +271,19 @@ static int mvebu_spi_set_speed(struct udevice *bus, uint hz)
>
>  static int mvebu_spi_set_mode(struct udevice *bus, uint mode)
>  {
> +       struct mvebu_spi_platdata *plat = dev_get_platdata(bus);
> +       struct kwspi_registers *reg = plat->spireg;
> +       u32 data = readl(&reg->cfg);

Better to clear the bits(mask) on data before updating,

thanks!
-- 
Jagan Teki
Free Software Engineer | www.openedev.com
U-Boot, Linux | Upstream Maintainer
Hyderabad, India.


More information about the U-Boot mailing list