From: Piotr Wilczek
Date: Mon, 17 Sep 2012 15:52:53 +0200
Subject: [U-Boot] [PATCH] arm:exynos4:universal_c210: implement software
SPI
In-Reply-To:
References: <1346228122-13444-1-git-send-email-p.wilczek@samsung.com>
<1346228122-13444-2-git-send-email-p.wilczek@samsung.com>
Message-ID: <000001cd94db$bccde050$3669a0f0$%wilczek@samsung.com>
List-Id:
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
To: u-boot@lists.denx.de
Dear Minkyu,
> -----Original Message-----
> From: Minkyu Kang [mailto:promsoft at gmail.com]
> Sent: Saturday, September 15, 2012 11:06 AM
> To: Piotr Wilczek
> Cc: u-boot at lists.denx.de; Kyungmin Park
> Subject: Re: [U-Boot] [PATCH] arm:exynos4:universal_c210: implement
> software SPI
>
> Dear Piotr,
>
> On 29 August 2012 17:15, Piotr Wilczek wrote:
> > This patch implements software SPI for the universal C210 board.
> >
> > Signed-off-by: Piotr Wilczek
> > Signed-off-by: Kyungmin Park
> > CC: Minkyu Kang
> > CC: Wolfgang Denk
> > CC: Jean-Christophe PLAGNIOL-VILLARD
> > ---
> > board/samsung/universal_c210/universal.c | 36
> ++++++++++++++++++++++++++++++
> > drivers/spi/soft_spi.c | 7 +++++-
> > include/configs/s5pc210_universal.h | 19 +++++++++++++++
> > 3 files changed, 61 insertions(+), 1 deletions(-)
> >
> > diff --git a/board/samsung/universal_c210/universal.c
> > b/board/samsung/universal_c210/universal.c
> > index 8a114e6..772ade5 100644
> > --- a/board/samsung/universal_c210/universal.c
> > +++ b/board/samsung/universal_c210/universal.c
> > @@ -24,6 +24,7 @@
> >
> > #include
> > #include
> > +#include
> > #include
> > #include
> > #include
> > @@ -34,6 +35,10 @@
> > #include
> > #include
> >
> > +#if defined(CONFIG_SOFT_SPI)
> > +# include
>
> remove space between # and include.
Ok.
>
> > +#endif
> > +
> > DECLARE_GLOBAL_DATA_PTR;
> >
> > struct exynos4_gpio_part1 *gpio1;
> > @@ -288,3 +293,34 @@ int board_early_init_f(void)
> >
> > return 0;
> > }
> > +
> > +void soft_spi_init()
> > +{
> > + gpio_direction_output(CONFIG_SOFT_SPI_GPIO_SCLK,
> > + CONFIG_SOFT_SPI_MODE & SPI_CPOL);
> > + gpio_direction_output(CONFIG_SOFT_SPI_GPIO_MOSI, 1);
> > + gpio_direction_input(CONFIG_SOFT_SPI_GPIO_MISO);
> > + gpio_direction_output(CONFIG_SOFT_SPI_GPIO_CS,
> > + !(CONFIG_SOFT_SPI_MODE & SPI_CS_HIGH)); }
> > +
> > +void spi_cs_activate(struct spi_slave *slave) {
> > + gpio_set_value(CONFIG_SOFT_SPI_GPIO_CS,
> > + !(CONFIG_SOFT_SPI_MODE & SPI_CS_HIGH));
> > + SPI_SCL(1);
> > + gpio_set_value(CONFIG_SOFT_SPI_GPIO_CS,
> > + CONFIG_SOFT_SPI_MODE & SPI_CS_HIGH); }
> > +
> > +void spi_cs_deactivate(struct spi_slave *slave) {
> > + gpio_set_value(CONFIG_SOFT_SPI_GPIO_CS,
> > + !(CONFIG_SOFT_SPI_MODE & SPI_CS_HIGH)); }
> > +
> > +int spi_cs_is_valid(unsigned int bus, unsigned int cs) {
> > + return 1;
>
> always return 1?
I can change that it would return 1 only if bus==0 and cs==0.
>
> > +}
> > +
> > diff --git a/drivers/spi/soft_spi.c b/drivers/spi/soft_spi.c index
> > 13df8cb..a0a3012 100644
> > --- a/drivers/spi/soft_spi.c
> > +++ b/drivers/spi/soft_spi.c
> > @@ -29,6 +29,10 @@
> >
> > #include
> >
> > +#if defined(CONFIG_SOFT_SPI)
> > +# include
> > +#endif
> > +
> > /*------------------------------------------------------------------
> -----
> > * Definitions
> > */
> > @@ -59,8 +63,9 @@ static inline struct soft_spi_slave
> > *to_soft_spi(struct spi_slave *slave) void spi_init (void) {
> #ifdef
> > SPI_INIT
> > +#ifdef CONFIG_SYS_IMMR
> > volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
> > -
> > +#endif
>
> Is it related change with this patch?
Yes, it is necessary to successfully compile.
>
> > SPI_INIT;
> > #endif
> > }
> > diff --git a/include/configs/s5pc210_universal.h
> > b/include/configs/s5pc210_universal.h
> > index 7978317..a338840 100644
> > --- a/include/configs/s5pc210_universal.h
> > +++ b/include/configs/s5pc210_universal.h
> > @@ -266,4 +266,23 @@
> > #define CONFIG_USB_GADGET_S3C_UDC_OTG #define
> > CONFIG_USB_GADGET_DUALSPEED
> >
> > +/*
> > + * SPI Settings
> > + */
> > +#define CONFIG_SOFT_SPI
> > +#define CONFIG_SOFT_SPI_MODE SPI_MODE_3 #define
> > +CONFIG_SOFT_SPI_GPIO_SCLK exynos4_gpio_part2_get_nr(y3, 1) #define
> > +CONFIG_SOFT_SPI_GPIO_MOSI exynos4_gpio_part2_get_nr(y3, 3) #define
> > +CONFIG_SOFT_SPI_GPIO_MISO exynos4_gpio_part2_get_nr(y3, 0) #define
> > +CONFIG_SOFT_SPI_GPIO_CS exynos4_gpio_part2_get_nr(y4, 3)
> > +
> > +#define SPI_DELAY udelay(1)
> > +#define SPI_INIT soft_spi_init()
> > +#define SPI_SCL(bit) gpio_set_value(CONFIG_SOFT_SPI_GPIO_SCLK, bit)
> > +#define SPI_SDA(bit) gpio_set_value(CONFIG_SOFT_SPI_GPIO_MOSI, bit)
> > +#define SPI_READ gpio_get_value(CONFIG_SOFT_SPI_GPIO_MISO)
> > +#ifndef __ASSEMBLY__
> > +void soft_spi_init(void);
> > +#endif
> > +
> > #endif /* __CONFIG_H */
> > --
> > 1.7.5.4
>
> Thanks.
> Minkyu Kang.
> --
> from. prom.
> www.promsoft.net
Best regards,
Piotr Wilczek