[U-Boot] [PATCH 2/2] i2c:gpio:s5p: I2C GPIO Software implementation (via soft_i2c)
Lukasz Majewski
l.majewski at samsung.com
Mon Jul 11 10:18:51 CEST 2011
Signed-off-by: Lukasz Majewski <l.majewski at samsung.com>
Cc: Minkyu Kang <mk7.kang at samsung.com>
---
arch/arm/include/asm/arch-s5pc1xx/gpio.h | 2 +
board/samsung/goni/goni.c | 55 +++++++++++++++++++++++++++++-
include/configs/s5p_goni.h | 13 +++++++
3 files changed, 69 insertions(+), 1 deletions(-)
diff --git a/arch/arm/include/asm/arch-s5pc1xx/gpio.h b/arch/arm/include/asm/arch-s5pc1xx/gpio.h
index 903de9c..108fb64 100644
--- a/arch/arm/include/asm/arch-s5pc1xx/gpio.h
+++ b/arch/arm/include/asm/arch-s5pc1xx/gpio.h
@@ -155,4 +155,6 @@ void s5p_gpio_set_rate(struct s5p_gpio_bank *bank, int gpio, int mode);
#define GPIO_DRV_FAST 0x0
#define GPIO_DRV_SLOW 0x1
+/* GPIO pins per bank */
+#define GPIO_PER_BANK 8
#endif
diff --git a/board/samsung/goni/goni.c b/board/samsung/goni/goni.c
index e24cd29..dbbd7ed 100644
--- a/board/samsung/goni/goni.c
+++ b/board/samsung/goni/goni.c
@@ -1,7 +1,8 @@
/*
- * Copyright (C) 2008-2009 Samsung Electronics
+ * Copyright (C) 2008-2011 Samsung Electronics
* Minkyu Kang <mk7.kang at samsung.com>
* Kyungmin Park <kyungmin.park at samsung.com>
+ * Lukasz Majewski <l.majewski at samsung.com>
*
* See file CREDITS for list of people who contributed to this
* project.
@@ -96,3 +97,55 @@ int board_mmc_init(bd_t *bis)
return s5p_mmc_init(0, 4);
}
#endif
+
+#ifdef CONFIG_SOFT_I2C
+
+enum { I2C_PMIC, I2C_NUM, };
+
+void i2c_init_board(void) {}
+
+int s5p_gpio_get_nr(void *gp_ptr, int gpio)
+{
+ unsigned int offset = gp_ptr - (void *) s5pc110_gpio;
+ offset /= sizeof(struct s5p_gpio_bank);
+
+ return (offset * GPIO_PER_BANK) + gpio;
+}
+
+struct s5p_gpio_bank *s5p_gpio_get_bank(int nr)
+{
+ int bank = nr / GPIO_PER_BANK;
+ bank *= sizeof(struct s5p_gpio_bank);
+
+ return (struct s5p_gpio_bank *) ((void *) s5pc110_gpio + bank);
+}
+
+inline int s5p_gpio_get_pin(int nr)
+{
+ return nr % GPIO_PER_BANK;
+}
+
+inline int gpio_direction_input(int nr)
+{
+ s5p_gpio_direction_input(s5p_gpio_get_bank(nr),
+ s5p_gpio_get_pin(nr));
+}
+
+inline int gpio_direction_output(int nr, int value)
+{
+ s5p_gpio_direction_output(s5p_gpio_get_bank(nr),
+ s5p_gpio_get_pin(nr), value);
+}
+
+inline int gpio_get_value(int nr)
+{
+ return (int) s5p_gpio_get_value(s5p_gpio_get_bank(nr),
+ s5p_gpio_get_pin(nr));
+}
+
+inline void gpio_set_value(int nr, int value)
+{
+ s5p_gpio_set_value(s5p_gpio_get_bank(nr),
+ s5p_gpio_get_pin(nr), value);
+}
+#endif
diff --git a/include/configs/s5p_goni.h b/include/configs/s5p_goni.h
index 010428b..ee87927 100644
--- a/include/configs/s5p_goni.h
+++ b/include/configs/s5p_goni.h
@@ -224,4 +224,17 @@
#define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_LOAD_ADDR - 0x1000000)
+#include <asm/arch/gpio.h>
+/*
+ * I2C Settings
+ */
+#define S5PC110_GPIO_J3 (S5PC110_GPIO_BASE + 0x2C0)
+#define CONFIG_SOFT_I2C_GPIO_SCL s5p_gpio_get_nr(S5PC110_GPIO_J3, 3)
+#define CONFIG_SOFT_I2C_GPIO_SDA s5p_gpio_get_nr(S5PC110_GPIO_J3, 0)
+
+#define CONFIG_SOFT_I2C 1
+#define CONFIG_SYS_I2C_INIT_BOARD
+#define CONFIG_SYS_I2C_SPEED 50000
+#define CONFIG_I2C_MULTI_BUS
+#define CONFIG_SYS_MAX_I2C_BUS 7
#endif /* __CONFIG_H */
--
1.7.2.3
More information about the U-Boot
mailing list