[U-Boot] [PATCH] spi: add support SuperH SPI module

Wolfgang Denk wd at denx.de
Tue Jan 18 10:28:38 CET 2011


Dear Yoshihiro Shimoda,

In message <4D33C089.8040007 at renesas.com> you wrote:
> SH7757 has SPI module. This patch supports it.
> 
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh at renesas.com>
> ---
>  drivers/spi/Makefile |    1 +
>  drivers/spi/sh_spi.c |  295 ++++++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 296 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/spi/sh_spi.c
> 
> diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile
> index e34a124..d582fbb 100644
> --- a/drivers/spi/Makefile
> +++ b/drivers/spi/Makefile
> @@ -37,6 +37,7 @@ COBJS-$(CONFIG_MPC8XXX_SPI) += mpc8xxx_spi.o
>  COBJS-$(CONFIG_MXC_SPI) += mxc_spi.o
>  COBJS-$(CONFIG_OMAP3_SPI) += omap3_spi.o
>  COBJS-$(CONFIG_SOFT_SPI) += soft_spi.o
> +COBJS-$(CONFIG_SH_SPI) += sh_spi.o

Please keep list sorted.

> diff --git a/drivers/spi/sh_spi.c b/drivers/spi/sh_spi.c
> new file mode 100644
> index 0000000..89ea5e2
> --- /dev/null
> +++ b/drivers/spi/sh_spi.c
...
> +#define SPI_TBR		0x00
> +#define SPI_RBR		0x00
> +#define SPI_CR1		0x08
> +#define SPI_CR2		0x10
> +#define SPI_CR3		0x18
> +#define SPI_CR4		0x20

Please declare a poper C struct instead.

> +/* CR1 */
> +#define SPI_TBE		0x80
> +#define SPI_TBF		0x40
> +#define SPI_RBE		0x20
> +#define SPI_RBF		0x10
> +#define SPI_PFONRD	0x08
> +#define SPI_SSDB	0x04
> +#define SPI_SSD		0x02
> +#define SPI_SSA		0x01
> +
> +/* CR2 */
> +#define SPI_RSTF	0x80
> +#define SPI_LOOPBK	0x40
> +#define SH_SPI_CPOL	0x20
> +#define SH_SPI_CPHA	0x10
> +#define SPI_L1M0	0x08
> +
> +/* CR3 */
> +#define SPI_MAX_BYTE	0xFF
> +
> +/* CR4 */
> +#define SPI_TBEI	0x80
> +#define SPI_TBFI	0x40
> +#define SPI_RBEI	0x20
> +#define SPI_RBFI	0x10
> +#define SPI_WPABRT	0x04
> +#define SPI_SSS		0x01
> +
> +#define SPI_FIFO_SIZE	32

All this stuff should better go into a separate header file.

> +static void sh_spi_write(unsigned long data, unsigned long offset)
> +{
> +	writel(data, CONFIG_SH_SPI_BASE + offset);

NAK.  We do not allow the base + offset notation.  Pleaseuse a proper
C struct instead.

Please fix globally.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"When the only  tool  you  have  is  a  hammer,  you  tend  to  treat
everything as if it were a nail."                    - Abraham Maslow


More information about the U-Boot mailing list