[U-Boot] [PATCH 1/2 v4] i2c:gpio:s5p: I2C GPIO Software implementation (via soft_i2c)

Minkyu Kang promsoft at gmail.com
Thu Aug 18 10:13:09 CEST 2011


Dear Lukasz Majewski,

On 12 August 2011 17:32, Lukasz Majewski <l.majewski at samsung.com> wrote:
> This patch adds support for software I2C for GONI reference target.
> It adds support for access to GPIOs by number, not as it is present,
> by bank and offset.
>
> Signed-off-by: Lukasz Majewski <l.majewski at samsung.com>
> Signed-off-by: Kyungmin Park <kyungmin.park at samsung.com>
> Cc: Minkyu Kang <mk7.kang at samsung.com>
> Cc: Heiko Schocher <hs at denx.de>
>
> ---
> Changes for v2:
>        - Generic GPIO code added to arch/arm/gpio.h
>        - Platform dependent GPIO code added to board/samsung/goni.c
>        - Code cleanup
> Changes for v3:
>        - I2C GPIO common code added to drivers/gpio/s5p_gpio.c
>        - i2c_init_board() function added(required by soft_i2c)
> Changes for v4:
>        - i2x_init_board() removed
>        - s5pc210 support added
>        - GPIO code and I2C enable code split to separate patches
> ---
>  arch/arm/include/asm/arch-s5pc1xx/gpio.h |   38 +++++++++++++++++++++++++++++
>  arch/arm/include/asm/arch-s5pc2xx/gpio.h |   39 ++++++++++++++++++++++++++++++
>  board/samsung/goni/goni.c                |    2 +
>  board/samsung/universal_c210/universal.c |    2 +
>  drivers/gpio/s5p_gpio.c                  |   21 ++++++++++++++++
>  5 files changed, 102 insertions(+), 0 deletions(-)
> diff --git a/board/samsung/goni/goni.c b/board/samsung/goni/goni.c
> index e24cd29..adc1e0e 100644
> --- a/board/samsung/goni/goni.c
> +++ b/board/samsung/goni/goni.c
> @@ -29,11 +29,13 @@
>  DECLARE_GLOBAL_DATA_PTR;
>
>  static struct s5pc110_gpio *s5pc110_gpio;
> +void *s5p_gpio;
>
>  int board_init(void)
>  {
>        /* Set Initial global variables */
>        s5pc110_gpio = (struct s5pc110_gpio *)S5PC110_GPIO_BASE;
> +       s5p_gpio = (void *) s5pc110_gpio;

I can't understand it.
Why is it need?
If you want to get gpio base address, then use the define value directly.
s5p_gpio pointer is unnecessary.

>
>        gd->bd->bi_arch_number = MACH_TYPE_GONI;
>        gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
> diff --git a/board/samsung/universal_c210/universal.c b/board/samsung/universal_c210/universal.c
> index 1b27e8b..b4a7f86 100644
> --- a/board/samsung/universal_c210/universal.c
> +++ b/board/samsung/universal_c210/universal.c
> @@ -32,6 +32,7 @@ DECLARE_GLOBAL_DATA_PTR;
>
>  struct s5pc210_gpio_part1 *gpio1;
>  struct s5pc210_gpio_part2 *gpio2;
> +void *s5p_gpio;
>  unsigned int board_rev;
>
>  u32 get_board_rev(void)
> @@ -50,6 +51,7 @@ int board_init(void)
>  {
>        gpio1 = (struct s5pc210_gpio_part1 *) S5PC210_GPIO_PART1_BASE;
>        gpio2 = (struct s5pc210_gpio_part2 *) S5PC210_GPIO_PART2_BASE;
> +       s5p_gpio = (void *) gpio1; /* ptr used with I2C SW implementation */

How can use gpio part2??

>
>        gd->bd->bi_arch_number = MACH_TYPE_UNIVERSAL_C210;
>        gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
> diff --git a/drivers/gpio/s5p_gpio.c b/drivers/gpio/s5p_gpio.c
> index 2043859..49c43c7 100644
> --- a/drivers/gpio/s5p_gpio.c
> +++ b/drivers/gpio/s5p_gpio.c
> @@ -141,3 +141,24 @@ void s5p_gpio_set_rate(struct s5p_gpio_bank *bank, int gpio, int mode)
>
>        writel(value, &bank->drv);
>  }
> +
> +int s5p_gpio_get_nr(void *gp_ptr, int gpio)
> +{
> +       unsigned int offset = gp_ptr - (void *) s5p_gpio;

As I said..
the purpose of s5p_gpio is to get base address, then please use define value.

> +       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 *) s5p_gpio + bank);
> +}
> +
> +int s5p_gpio_get_pin(int nr)
> +{
> +       return nr % GPIO_PER_BANK;
> +}
> --

And you should solve how can use gpio part2.

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


More information about the U-Boot mailing list