[U-Boot] [PATCH v3 2/2] exynos4: universal_C210: use software SPI
Piotr Wilczek
p.wilczek at samsung.com
Mon Sep 24 13:56:31 CEST 2012
This patch use software spi on Samsung Universal C210 board.
Signed-off-by: Piotr Wilczek <p.wilczek at samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park at samsung.com>
CC: Minkyu Kang <mk7.kang at 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
More information about the U-Boot
mailing list