All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] implement software SPI
@ 2012-08-29  8:15 Piotr Wilczek
  2012-08-29  8:15 ` [U-Boot] [PATCH] arm:exynos4:universal_c210: " Piotr Wilczek
  0 siblings, 1 reply; 13+ messages in thread
From: Piotr Wilczek @ 2012-08-29  8:15 UTC (permalink / raw)
  To: u-boot

This patch implements software SPI for the universal C210 board.
SPI is used to configure video driver.

Piotr Wilczek (1):
  arm:exynos4:universal_c210: implement software SPI

 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(-)

-- 
1.7.5.4

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [U-Boot] [PATCH] arm:exynos4:universal_c210: implement software SPI
  2012-08-29  8:15 [U-Boot] [PATCH] implement software SPI Piotr Wilczek
@ 2012-08-29  8:15 ` Piotr Wilczek
  2012-09-15  9:05   ` Minkyu Kang
  2012-09-20 11:50   ` [U-Boot] [PATCH v2] " Piotr Wilczek
  0 siblings, 2 replies; 13+ messages in thread
From: Piotr Wilczek @ 2012-08-29  8:15 UTC (permalink / raw)
  To: u-boot

This patch implements software SPI for the universal C210 board.

Signed-off-by: Piotr Wilczek <p.wilczek@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
CC: Minkyu Kang <mk7.kang@samsung.com>
CC: Wolfgang Denk <wd@denx.de>
CC: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 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 <common.h>
 #include <asm/io.h>
+#include <spi.h>
 #include <asm/arch/adc.h>
 #include <asm/arch/gpio.h>
 #include <asm/arch/mmc.h>
@@ -34,6 +35,10 @@
 #include <max8998_pmic.h>
 #include <asm/arch/watchdog.h>
 
+#if defined(CONFIG_SOFT_SPI)
+# include <asm/gpio.h>
+#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;
+}
+
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 <malloc.h>
 
+#if defined(CONFIG_SOFT_SPI)
+# include <asm/gpio.h>
+#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
 	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

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [U-Boot] [PATCH] arm:exynos4:universal_c210: implement software SPI
  2012-08-29  8:15 ` [U-Boot] [PATCH] arm:exynos4:universal_c210: " Piotr Wilczek
@ 2012-09-15  9:05   ` Minkyu Kang
  2012-09-17 13:52     ` Piotr Wilczek
  2012-09-20 11:50   ` [U-Boot] [PATCH v2] " Piotr Wilczek
  1 sibling, 1 reply; 13+ messages in thread
From: Minkyu Kang @ 2012-09-15  9:05 UTC (permalink / raw)
  To: u-boot

Dear Piotr,

On 29 August 2012 17:15, Piotr Wilczek <p.wilczek@samsung.com> wrote:
> This patch implements software SPI for the universal C210 board.
>
> Signed-off-by: Piotr Wilczek <p.wilczek@samsung.com>
> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
> CC: Minkyu Kang <mk7.kang@samsung.com>
> CC: Wolfgang Denk <wd@denx.de>
> CC: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> ---
>  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 <common.h>
>  #include <asm/io.h>
> +#include <spi.h>
>  #include <asm/arch/adc.h>
>  #include <asm/arch/gpio.h>
>  #include <asm/arch/mmc.h>
> @@ -34,6 +35,10 @@
>  #include <max8998_pmic.h>
>  #include <asm/arch/watchdog.h>
>
> +#if defined(CONFIG_SOFT_SPI)
> +# include <asm/gpio.h>

remove space between # and include.

> +#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?

> +}
> +
> 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 <malloc.h>
>
> +#if defined(CONFIG_SOFT_SPI)
> +# include <asm/gpio.h>
> +#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?

>         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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [U-Boot] [PATCH] arm:exynos4:universal_c210: implement software SPI
  2012-09-15  9:05   ` Minkyu Kang
@ 2012-09-17 13:52     ` Piotr Wilczek
  0 siblings, 0 replies; 13+ messages in thread
From: Piotr Wilczek @ 2012-09-17 13:52 UTC (permalink / raw)
  To: u-boot

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 <p.wilczek@samsung.com> wrote:
> > This patch implements software SPI for the universal C210 board.
> >
> > Signed-off-by: Piotr Wilczek <p.wilczek@samsung.com>
> > Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
> > CC: Minkyu Kang <mk7.kang@samsung.com>
> > CC: Wolfgang Denk <wd@denx.de>
> > CC: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> > ---
> >  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 <common.h>
> >  #include <asm/io.h>
> > +#include <spi.h>
> >  #include <asm/arch/adc.h>
> >  #include <asm/arch/gpio.h>
> >  #include <asm/arch/mmc.h>
> > @@ -34,6 +35,10 @@
> >  #include <max8998_pmic.h>
> >  #include <asm/arch/watchdog.h>
> >
> > +#if defined(CONFIG_SOFT_SPI)
> > +# include <asm/gpio.h>
> 
> 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 <malloc.h>
> >
> > +#if defined(CONFIG_SOFT_SPI)
> > +# include <asm/gpio.h>
> > +#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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [U-Boot] [PATCH v2] implement software SPI
  2012-08-29  8:15 ` [U-Boot] [PATCH] arm:exynos4:universal_c210: " Piotr Wilczek
  2012-09-15  9:05   ` Minkyu Kang
@ 2012-09-20 11:50   ` Piotr Wilczek
  2012-09-20 11:50     ` [U-Boot] [PATCH v2] arm:exynos4:universal_c210: " Piotr Wilczek
  2012-09-20 15:18     ` [U-Boot] [PATCH v2] implement software SPI Wolfgang Denk
  1 sibling, 2 replies; 13+ messages in thread
From: Piotr Wilczek @ 2012-09-20 11:50 UTC (permalink / raw)
  To: u-boot

This patch implements software SPI for the universal C210 board.
SPI is used to configure video driver.

Changes in v2:
- removed space between # and include;
- changed return in spi_cs_is_valid function;

Piotr Wilczek (1):
  arm:exynos4:universal_c210: implement software SPI

 board/samsung/universal_c210/universal.c |   35 ++++++++++++++++++++++++++++++
 drivers/spi/soft_spi.c                   |    7 +++++-
 include/configs/s5pc210_universal.h      |   19 ++++++++++++++++
 3 files changed, 60 insertions(+), 1 deletions(-)

-- 
1.7.5.4

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [U-Boot] [PATCH v2] arm:exynos4:universal_c210: implement software SPI
  2012-09-20 11:50   ` [U-Boot] [PATCH v2] " Piotr Wilczek
@ 2012-09-20 11:50     ` Piotr Wilczek
  2012-09-24 11:56       ` [U-Boot] [PATCH v3 0/2] Exynos4: add software SPI support on Universal C210 board Piotr Wilczek
  2012-09-20 15:18     ` [U-Boot] [PATCH v2] implement software SPI Wolfgang Denk
  1 sibling, 1 reply; 13+ messages in thread
From: Piotr Wilczek @ 2012-09-20 11:50 UTC (permalink / raw)
  To: u-boot

This patch implements software SPI for the universal C210 board.

Signed-off-by: Piotr Wilczek <p.wilczek@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
CC: Minkyu Kang <mk7.kang@samsung.com>
CC: Wolfgang Denk <wd@denx.de>
CC: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
Changes in v2:
- removed space between # and include;
- changed return in spi_cs_is_valid function;

 board/samsung/universal_c210/universal.c |   35 ++++++++++++++++++++++++++++++
 drivers/spi/soft_spi.c                   |    7 +++++-
 include/configs/s5pc210_universal.h      |   19 ++++++++++++++++
 3 files changed, 60 insertions(+), 1 deletions(-)

diff --git a/board/samsung/universal_c210/universal.c b/board/samsung/universal_c210/universal.c
index ded97ca..6947e83 100644
--- a/board/samsung/universal_c210/universal.c
+++ b/board/samsung/universal_c210/universal.c
@@ -24,6 +24,7 @@
 
 #include <common.h>
 #include <asm/io.h>
+#include <spi.h>
 #include <asm/arch/adc.h>
 #include <asm/arch/gpio.h>
 #include <asm/arch/mmc.h>
@@ -33,6 +34,9 @@
 #include <asm/arch/cpu.h>
 #include <max8998_pmic.h>
 #include <asm/arch/watchdog.h>
+#if defined(CONFIG_SOFT_SPI)
+# include <asm/gpio.h>
+#endif
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -284,3 +288,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 bus == 0 && 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 <malloc.h>
 
+#if defined(CONFIG_SOFT_SPI)
+# include <asm/gpio.h>
+#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
 	SPI_INIT;
 #endif
 }
diff --git a/include/configs/s5pc210_universal.h b/include/configs/s5pc210_universal.h
index 46f2663..f7a7443 100644
--- a/include/configs/s5pc210_universal.h
+++ b/include/configs/s5pc210_universal.h
@@ -264,4 +264,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

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [U-Boot] [PATCH v2] implement software SPI
  2012-09-20 11:50   ` [U-Boot] [PATCH v2] " Piotr Wilczek
  2012-09-20 11:50     ` [U-Boot] [PATCH v2] arm:exynos4:universal_c210: " Piotr Wilczek
@ 2012-09-20 15:18     ` Wolfgang Denk
  2012-09-21  7:34       ` Piotr Wilczek
  1 sibling, 1 reply; 13+ messages in thread
From: Wolfgang Denk @ 2012-09-20 15:18 UTC (permalink / raw)
  To: u-boot

Dear Piotr Wilczek,

In message <1348141834-3603-1-git-send-email-p.wilczek@samsung.com> you wrote:
> This patch implements software SPI for the universal C210 board.
> SPI is used to configure video driver.

Can you please adjust the Subject: to make clear that this is some
C210 board specific code?  Because we do have software SPI support
already ...

Say something like:  "ARM: C210 board: add software SPI support"

Thanks.

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
"No one talks peace unless he's ready to back it up with war."
"He talks of peace if it is the only way to live."
	-- Colonel Green and Surak of Vulcan, "The Savage Curtain",
	   stardate 5906.5.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [U-Boot] [PATCH v2] implement software SPI
  2012-09-20 15:18     ` [U-Boot] [PATCH v2] implement software SPI Wolfgang Denk
@ 2012-09-21  7:34       ` Piotr Wilczek
  0 siblings, 0 replies; 13+ messages in thread
From: Piotr Wilczek @ 2012-09-21  7:34 UTC (permalink / raw)
  To: u-boot

Dear Wolfgang Denk,

Thank you for your comment. The title is indeed misleading and I change it. Also the patch should be split in two patches. Actually I'm using your software SPI in our board and I need to add two modifications in the soft_spi.c file.

Best regards,
Piotr Wilczek

> -----Original Message-----
> From: Wolfgang Denk [mailto:wd at denx.de]
> Sent: Thursday, September 20, 2012 5:18 PM
> To: Piotr Wilczek
> Cc: u-boot at lists.denx.de; Minkyu Kang; Kyungmin Park; Jean-Christophe
> PLAGNIOL-VILLARD; Lukasz Majewski
> Subject: Re: [PATCH v2] implement software SPI
> 
> Dear Piotr Wilczek,
> 
> In message <1348141834-3603-1-git-send-email-p.wilczek@samsung.com> you
> wrote:
> > This patch implements software SPI for the universal C210 board.
> > SPI is used to configure video driver.
> 
> Can you please adjust the Subject: to make clear that this is some
> C210 board specific code?  Because we do have software SPI support
> already ...
> 
> Say something like:  "ARM: C210 board: add software SPI support"
> 
> Thanks.
> 
> 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
> "No one talks peace unless he's ready to back it up with war."
> "He talks of peace if it is the only way to live."
> 	-- Colonel Green and Surak of Vulcan, "The Savage Curtain",
> 	   stardate 5906.5.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [U-Boot] [PATCH v3 0/2] Exynos4: add software SPI support on Universal C210 board
  2012-09-20 11:50     ` [U-Boot] [PATCH v2] arm:exynos4:universal_c210: " Piotr Wilczek
@ 2012-09-24 11:56       ` Piotr Wilczek
  2012-09-24 11:56         ` [U-Boot] [PATCH v3 1/2] drivers: spi: modify soft spi driver Piotr Wilczek
                           ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Piotr Wilczek @ 2012-09-24 11:56 UTC (permalink / raw)
  To: u-boot

This patchset add software SPI support on Samsung Universal C210 board.
In SPI software driver #ifdef CONFIG_SYS_IMMR in spi_init function is added.

Changes in v2:
- removed space between # and include;
- changed return in spi_cs_is_valid function;
Changes in v3:
- Patch is split in two patches:
  - the first modifies software SPI driver;
  - the second patch add support for SPI on Universal C210 board

Piotr Wilczek (2):
  drivers: spi: modify soft spi driver
  exynos4: universal_C210: use software SPI

 board/samsung/universal_c210/universal.c |   34 ++++++++++++++++++++++++++++++
 drivers/spi/soft_spi.c                   |    3 ++
 include/configs/s5pc210_universal.h      |   19 ++++++++++++++++
 3 files changed, 56 insertions(+), 0 deletions(-)

-- 
1.7.5.4

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [U-Boot] [PATCH v3 1/2] drivers: spi: modify soft spi driver
  2012-09-24 11:56       ` [U-Boot] [PATCH v3 0/2] Exynos4: add software SPI support on Universal C210 board Piotr Wilczek
@ 2012-09-24 11:56         ` Piotr Wilczek
  2012-09-24 11:56         ` [U-Boot] [PATCH v3 2/2] exynos4: universal_C210: use software SPI Piotr Wilczek
  2012-10-10 11:55         ` [U-Boot] [PATCH v3 0/2] Exynos4: add software SPI support on Universal C210 board Minkyu Kang
  2 siblings, 0 replies; 13+ messages in thread
From: Piotr Wilczek @ 2012-09-24 11:56 UTC (permalink / raw)
  To: u-boot

This patch add #ifdef CONFIG_SYS_IMMR in spi_init function

Signed-off-by: Piotr Wilczek <p.wilczek@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
CC: Minkyu Kang <mk7.kang@samsung.com>
CC: Wolfgang Denk <wd@denx.de>
CC: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
Changes in v2:
- removed space between # and include;
- changed return in spi_cs_is_valid function;
Changes in v3:
- New patch from splited v2:

 drivers/spi/soft_spi.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/drivers/spi/soft_spi.c b/drivers/spi/soft_spi.c
index 13df8cb..1e7e9f7 100644
--- a/drivers/spi/soft_spi.c
+++ b/drivers/spi/soft_spi.c
@@ -26,6 +26,7 @@
 
 #include <common.h>
 #include <spi.h>
+#include <asm/gpio.h>
 
 #include <malloc.h>
 
@@ -59,7 +60,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
 
 	SPI_INIT;
 #endif
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [U-Boot] [PATCH v3 2/2] exynos4: universal_C210: use software SPI
  2012-09-24 11:56       ` [U-Boot] [PATCH v3 0/2] Exynos4: add software SPI support on Universal C210 board Piotr Wilczek
  2012-09-24 11:56         ` [U-Boot] [PATCH v3 1/2] drivers: spi: modify soft spi driver Piotr Wilczek
@ 2012-09-24 11:56         ` Piotr Wilczek
  2012-10-10 11:55         ` [U-Boot] [PATCH v3 0/2] Exynos4: add software SPI support on Universal C210 board Minkyu Kang
  2 siblings, 0 replies; 13+ messages in thread
From: Piotr Wilczek @ 2012-09-24 11:56 UTC (permalink / raw)
  To: u-boot

This patch use software spi on Samsung Universal C210 board.

Signed-off-by: Piotr Wilczek <p.wilczek@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
CC: Minkyu Kang <mk7.kang@samsung.com>
---
Changes in v2:
- removed space between # and include;
- changed return in spi_cs_is_valid function;
Changes in v3:
- New patch from splited v2:

 board/samsung/universal_c210/universal.c |   34 ++++++++++++++++++++++++++++++
 include/configs/s5pc210_universal.h      |   19 ++++++++++++++++
 2 files changed, 53 insertions(+), 0 deletions(-)

diff --git a/board/samsung/universal_c210/universal.c b/board/samsung/universal_c210/universal.c
index ded97ca..72999d9 100644
--- a/board/samsung/universal_c210/universal.c
+++ b/board/samsung/universal_c210/universal.c
@@ -23,7 +23,9 @@
  */
 
 #include <common.h>
+#include <spi.h>
 #include <asm/io.h>
+#include <asm/gpio.h>
 #include <asm/arch/adc.h>
 #include <asm/arch/gpio.h>
 #include <asm/arch/mmc.h>
@@ -284,3 +286,35 @@ int board_early_init_f(void)
 
 	return 0;
 }
+
+#ifdef CONFIG_SOFT_SPI
+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 bus == 0 && cs == 0;
+}
+#endif
diff --git a/include/configs/s5pc210_universal.h b/include/configs/s5pc210_universal.h
index 46f2663..f7a7443 100644
--- a/include/configs/s5pc210_universal.h
+++ b/include/configs/s5pc210_universal.h
@@ -264,4 +264,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

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [U-Boot] [PATCH v3 0/2] Exynos4: add software SPI support on Universal C210 board
  2012-09-24 11:56       ` [U-Boot] [PATCH v3 0/2] Exynos4: add software SPI support on Universal C210 board Piotr Wilczek
  2012-09-24 11:56         ` [U-Boot] [PATCH v3 1/2] drivers: spi: modify soft spi driver Piotr Wilczek
  2012-09-24 11:56         ` [U-Boot] [PATCH v3 2/2] exynos4: universal_C210: use software SPI Piotr Wilczek
@ 2012-10-10 11:55         ` Minkyu Kang
  2012-10-15  1:11           ` Minkyu Kang
  2 siblings, 1 reply; 13+ messages in thread
From: Minkyu Kang @ 2012-10-10 11:55 UTC (permalink / raw)
  To: u-boot

Dear Piotr Wilczek,

On 24 September 2012 20:56, Piotr Wilczek <p.wilczek@samsung.com> wrote:
> This patchset add software SPI support on Samsung Universal C210 board.
> In SPI software driver #ifdef CONFIG_SYS_IMMR in spi_init function is added.
>
> Changes in v2:
> - removed space between # and include;
> - changed return in spi_cs_is_valid function;
> Changes in v3:
> - Patch is split in two patches:
>   - the first modifies software SPI driver;
>   - the second patch add support for SPI on Universal C210 board
>
> Piotr Wilczek (2):
>   drivers: spi: modify soft spi driver
>   exynos4: universal_C210: use software SPI
>
>  board/samsung/universal_c210/universal.c |   34 ++++++++++++++++++++++++++++++
>  drivers/spi/soft_spi.c                   |    3 ++
>  include/configs/s5pc210_universal.h      |   19 ++++++++++++++++
>  3 files changed, 56 insertions(+), 0 deletions(-)
>

applied to u-boot-samsung.

Thanks.
Minkyu Kang.
-- 
from. prom.
www.promsoft.net

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [U-Boot] [PATCH v3 0/2] Exynos4: add software SPI support on Universal C210 board
  2012-10-10 11:55         ` [U-Boot] [PATCH v3 0/2] Exynos4: add software SPI support on Universal C210 board Minkyu Kang
@ 2012-10-15  1:11           ` Minkyu Kang
  0 siblings, 0 replies; 13+ messages in thread
From: Minkyu Kang @ 2012-10-15  1:11 UTC (permalink / raw)
  To: u-boot

On 10 October 2012 20:55, Minkyu Kang <promsoft@gmail.com> wrote:
> Dear Piotr Wilczek,
>
> On 24 September 2012 20:56, Piotr Wilczek <p.wilczek@samsung.com> wrote:
>> This patchset add software SPI support on Samsung Universal C210 board.
>> In SPI software driver #ifdef CONFIG_SYS_IMMR in spi_init function is added.
>>
>> Changes in v2:
>> - removed space between # and include;
>> - changed return in spi_cs_is_valid function;
>> Changes in v3:
>> - Patch is split in two patches:
>>   - the first modifies software SPI driver;
>>   - the second patch add support for SPI on Universal C210 board
>>
>> Piotr Wilczek (2):
>>   drivers: spi: modify soft spi driver
>>   exynos4: universal_C210: use software SPI
>>
>>  board/samsung/universal_c210/universal.c |   34 ++++++++++++++++++++++++++++++
>>  drivers/spi/soft_spi.c                   |    3 ++
>>  include/configs/s5pc210_universal.h      |   19 ++++++++++++++++
>>  3 files changed, 56 insertions(+), 0 deletions(-)
>>
>
> applied to u-boot-samsung.
>

This patchset was reverted.

Thanks.
Minkyu Kang.
-- 
from. prom.
www.promsoft.net

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2012-10-15  1:11 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-29  8:15 [U-Boot] [PATCH] implement software SPI Piotr Wilczek
2012-08-29  8:15 ` [U-Boot] [PATCH] arm:exynos4:universal_c210: " Piotr Wilczek
2012-09-15  9:05   ` Minkyu Kang
2012-09-17 13:52     ` Piotr Wilczek
2012-09-20 11:50   ` [U-Boot] [PATCH v2] " Piotr Wilczek
2012-09-20 11:50     ` [U-Boot] [PATCH v2] arm:exynos4:universal_c210: " Piotr Wilczek
2012-09-24 11:56       ` [U-Boot] [PATCH v3 0/2] Exynos4: add software SPI support on Universal C210 board Piotr Wilczek
2012-09-24 11:56         ` [U-Boot] [PATCH v3 1/2] drivers: spi: modify soft spi driver Piotr Wilczek
2012-09-24 11:56         ` [U-Boot] [PATCH v3 2/2] exynos4: universal_C210: use software SPI Piotr Wilczek
2012-10-10 11:55         ` [U-Boot] [PATCH v3 0/2] Exynos4: add software SPI support on Universal C210 board Minkyu Kang
2012-10-15  1:11           ` Minkyu Kang
2012-09-20 15:18     ` [U-Boot] [PATCH v2] implement software SPI Wolfgang Denk
2012-09-21  7:34       ` Piotr Wilczek

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.