[U-Boot] [PATCH 2/2] i2c:gpio:s5p: I2C GPIO Software implementation (via soft_i2c)
Signed-off-by: Lukasz Majewski Cc: Minkyu Kang --- 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 * Kyungmin Park + * Lukasz Majewski * * 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 - 0x100) +#include +/* + * 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_I2C1 +#define CONFIG_SYS_I2C_INIT_BOARD +#define CONFIG_SYS_I2C_SPEED 5 +#define CONFIG_I2C_MULTI_BUS +#define CONFIG_SYS_MAX_I2C_BUS 7 #endif /* __CONFIG_H */ -- 1.7.2.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 2/2] i2c:gpio:s5p: I2C GPIO Software implementation (via soft_i2c)
Dear Lukasz Majewski, On 11 July 2011 17:18, Lukasz Majewski wrote: > Signed-off-by: Lukasz Majewski > Cc: Minkyu Kang > --- > 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(-) You missing commit message. > > 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 > * Kyungmin Park > + * Lukasz Majewski > * > * 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, }; What purpose of these enum? Where these used? > + > +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 I think It's not a board specific. Please make common file for I2C gpio for s5p. > 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 - 0x100) > > +#include > +/* > + * 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) I have one question. How we can handle multiple bus? I mean.. how we can change SCL and SDA? > + > +#define CONFIG_SOFT_I2C 1 > +#define CONFIG_SYS_I2C_INIT_BOARD > +#define CONFIG_SYS_I2C_SPEED 5 > +#define CONFIG_I2C_MULTI_BUS > +#define CONFIG_SYS_MAX_I2C_BUS 7 > #endif /* __CONFIG_H */ > -- > 1.7.2.3 Thanks Minkyu Kang -- from. prom. www.promsoft.net ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 2/2] i2c:gpio:s5p: I2C GPIO Software implementation (via soft_i2c)
Hi Minkyu, > > + > > +#ifdef CONFIG_SOFT_I2C > > + > > +enum { I2C_PMIC, I2C_NUM, }; > > What purpose of these enum? > Where these used? For now goni reference target is going to use only one I2C bus (implemented as soft_i2c GPIO). Therefore this enum will be erased for v2. In the future, however this might be needed. > > +#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) > > I have one question. > How we can handle multiple bus? > I mean.. how we can change SCL and SDA? I've asked this question to Heiko Schocher already. Please refer to this reply: http://lists.denx.de/pipermail/u-boot/2011-July/095610.html -- Best regards, Lukasz Majewski Samsung Poland R&D Center Platform Group ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot