[U-Boot] [PATCH v5 5/8] SPI: add Dove support to Kirkwood SPI driver

Sebastian Hesselbarth sebastian.hesselbarth at gmail.com
Wed Jun 26 00:45:50 CEST 2013


On 06/25/2013 11:27 PM, Sascha Silbe wrote:
> The SPI support on Dove is very similar to that on Kirkwood (and
> possibly orion5x as well). Instead of duplicating the code, we tweak
> the Kirkwood driver so it works for Dove, too.
>
> Signed-off-by: Sascha Silbe<t-uboot at infra-silbe.de>
> ---
>   v4->v5: Modify Kirkwood driver rather than duplicating it.
>
>   The patch description might do with slightly more detail, but I'd
>   like some feedback on the approach first. The patch itself should be
>   pretty self-explanatory.
>
>   arch/arm/include/asm/arch-kirkwood/spi.h | 27 ------------------
>   drivers/spi/kirkwood_spi.c               | 47 +++++++++++++++++++++++++++++---
>   2 files changed, 43 insertions(+), 31 deletions(-)
>
> diff --git a/arch/arm/include/asm/arch-kirkwood/spi.h b/arch/arm/include/asm/arch-kirkwood/spi.h
> index 113f258..4145f62 100644
> --- a/arch/arm/include/asm/arch-kirkwood/spi.h
> +++ b/arch/arm/include/asm/arch-kirkwood/spi.h
> @@ -27,16 +27,6 @@
>   #ifndef __KW_SPI_H__
>   #define __KW_SPI_H__
>
> -/* SPI Registers on kirkwood SOC */
> -struct kwspi_registers {
> -	u32 ctrl;	/* 0x10600 */
> -	u32 cfg;	/* 0x10604 */
> -	u32 dout;	/* 0x10608 */
> -	u32 din;	/* 0x1060c */
> -	u32 irq_cause;	/* 0x10610 */
> -	u32 irq_mask;	/* 0x10614 */
> -};
> -
>   /* They are used to define CONFIG_SYS_KW_SPI_MPP
>    * each of the below #defines selects which mpp is
>    * configured for each SPI signal in spi_claim_bus
> @@ -48,21 +38,4 @@ struct kwspi_registers {
>   #define SCK_MPP10	(1<<  1)
>   #define MISO_MPP11	(1<<  2)
>
> -#define KWSPI_CLKPRESCL_MASK	0x1f
> -#define KWSPI_CLKPRESCL_MIN	0x12
> -#define KWSPI_CSN_ACT		1 /* Activates serial memory interface */
> -#define KWSPI_SMEMRDY		(1<<  1) /* SerMem Data xfer ready */
> -#define KWSPI_IRQUNMASK		1 /* unmask SPI interrupt */
> -#define KWSPI_IRQMASK		0 /* mask SPI interrupt */
> -#define KWSPI_SMEMRDIRQ		1 /* SerMem data xfer ready irq */
> -#define KWSPI_XFERLEN_1BYTE	0
> -#define KWSPI_XFERLEN_2BYTE	(1<<  5)
> -#define KWSPI_XFERLEN_MASK	(1<<  5)
> -#define KWSPI_ADRLEN_1BYTE	0
> -#define KWSPI_ADRLEN_2BYTE	1<<  8
> -#define KWSPI_ADRLEN_3BYTE	2<<  8
> -#define KWSPI_ADRLEN_4BYTE	3<<  8
> -#define KWSPI_ADRLEN_MASK	3<<  8
> -#define KWSPI_TIMEOUT		10000
> -
>   #endif /* __KW_SPI_H__ */
> diff --git a/drivers/spi/kirkwood_spi.c b/drivers/spi/kirkwood_spi.c
> index caa91e3..4e4c814 100644
> --- a/drivers/spi/kirkwood_spi.c
> +++ b/drivers/spi/kirkwood_spi.c
> @@ -28,23 +28,58 @@
>   #include<malloc.h>
>   #include<spi.h>
>   #include<asm/io.h>
> -#include<asm/arch/kirkwood.h>
> -#include<asm/arch/spi.h>
> -#include<asm/arch/mpp.h>
> +#include<asm/arch/config.h>
>
> -static struct kwspi_registers *spireg = (struct kwspi_registers *)KW_SPI_BASE;
> +/* SPI Registers on Dove/Kirkwood SOC */
> +struct kwspi_registers {
> +	u32 ctrl;	/* 0x00 */
> +	u32 cfg;	/* 0x04 */
> +	u32 dout;	/* 0x08 */
> +	u32 din;	/* 0x0c */
> +	u32 irq_cause;	/* 0x10 */
> +	u32 irq_mask;	/* 0x14 */
> +};
>
> +#if defined(CONFIG_KIRKWOOD)
> +static struct kwspi_registers *spireg =
> +        (struct kwspi_registers *)KW_SPI_BASE;
> +#elif defined(CONFIG_DOVE)
> +static struct kwspi_registers *spireg =
> +        (struct kwspi_registers *)DOVE_SPI_BASE;
> +#endif
> +
> +#define KWSPI_CLKPRESCL_MASK	0x1f
> +#define KWSPI_CLKPRESCL_MIN	0x12

After I looked deeper in Dove FS SPI registers today, I can now say that
Dove SPI allows some more prescaler settings. Nothing critical, as
kirkwood_spi finds the closest spi clock rate less that requested
frequency. By not using the extended prescaler, you may end up with
spi clock running slower than possible but it will not break anything.

Sebastian


More information about the U-Boot mailing list