[7/7,V5] CONFIG: SMDK5250: I2C: Enable I2C

Message ID 1341489592-24243-8-git-send-email-rajeshwari.s@samsung.com
State New
Headers show

Commit Message

Rajeshwari Shinde July 5, 2012, 11:59 a.m.
This enables I2C support on smdk5250.
Pinmux setting moved to board file to avoid repeated setting of
gpio lines.

Signed-off-by: Alim Akhtar <alim.akhtar@samsung.com>
Signed-off-by: Doug Anderson <dianders@chromium.org>
Signed-off-by: Rajeshwari Shinde <rajeshwari.s@samsung.com>
Acked-by: Simon Glass <sjg@chromium.org>
---
Changes in V2:
        - None
Changes in V3:
        - None
Changes in V4:
        - None
Changes in V5:
        - Pinmux setting of gpio lines moved to board_early_init_f.
 board/samsung/smdk5250/smdk5250.c |   23 ++++++++++++++++++++++-
 include/configs/smdk5250.h        |    9 +++++++++
 2 files changed, 31 insertions(+), 1 deletions(-)

Comments

Simon Glass July 18, 2012, 8:09 p.m. | #1
Hi,

On Thu, Jul 5, 2012 at 12:59 PM, Rajeshwari Shinde
<rajeshwari.s@samsung.com> wrote:
> This enables I2C support on smdk5250.
> Pinmux setting moved to board file to avoid repeated setting of
> gpio lines.
>
> Signed-off-by: Alim Akhtar <alim.akhtar@samsung.com>
> Signed-off-by: Doug Anderson <dianders@chromium.org>
> Signed-off-by: Rajeshwari Shinde <rajeshwari.s@samsung.com>
> Acked-by: Simon Glass <sjg@chromium.org>
> ---
> Changes in V2:
>         - None
> Changes in V3:
>         - None
> Changes in V4:
>         - None
> Changes in V5:
>         - Pinmux setting of gpio lines moved to board_early_init_f.
>  board/samsung/smdk5250/smdk5250.c |   23 ++++++++++++++++++++++-
>  include/configs/smdk5250.h        |    9 +++++++++
>  2 files changed, 31 insertions(+), 1 deletions(-)
>
> diff --git a/board/samsung/smdk5250/smdk5250.c b/board/samsung/smdk5250/smdk5250.c
> index b593325..fc08ddc 100644
> --- a/board/samsung/smdk5250/smdk5250.c
> +++ b/board/samsung/smdk5250/smdk5250.c
> @@ -172,9 +172,30 @@ static int board_uart_init(void)
>         return 0;
>  }
>
> +static int board_i2c_init(void)
> +{
> +       int i, err;
> +
> +       for (i = 0; i < CONFIG_MAX_I2C_NUM; i++) {
> +               err = exynos_pinmux_config((PERIPH_ID_I2C0 + i),
> +                                               PINMUX_FLAG_NONE);
> +               if (err) {
> +                       debug("I2C%d not configured\n", (PERIPH_ID_I2C0 + i));
> +                       return err;
> +               }
> +       }
> +       return 0;
> +}
> +
>  #ifdef CONFIG_BOARD_EARLY_INIT_F
>  int board_early_init_f(void)
>  {
> -       return board_uart_init();
> +       int err;
> +       err = board_uart_init();
> +       if (err) {
> +               debug("UART init failed\n");
> +               return err;
> +       }
> +       return board_i2c_init();
>  }
>  #endif
> diff --git a/include/configs/smdk5250.h b/include/configs/smdk5250.h
> index 86dd905..c6df1cf 100644
> --- a/include/configs/smdk5250.h
> +++ b/include/configs/smdk5250.h
> @@ -192,6 +192,15 @@
>
>  #define CONFIG_SYS_INIT_SP_ADDR        (CONFIG_SYS_LOAD_ADDR - 0x1000000)
>
> +/* I2C */
> +#define CONFIG_HARD_I2C
> +#define CONFIG_CMD_I2C
> +#define CONFIG_SYS_I2C_SPEED   100000          /* 100 Kbps */
> +#define CONFIG_DRIVER_S3C24X0_I2C
> +#define CONFIG_I2C_MULTI_BUS
> +#define CONFIG_MAX_I2C_NUM     8
> +#define EXYNOS_I2C_SPACING     0x10000

One more comment - I think this last value should be in cpu.h rather
than a board file.

Regards,
Simon

> +
>  /* Ethernet Controllor Driver */
>  #ifdef CONFIG_CMD_NET
>  #define CONFIG_SMC911X
> --
> 1.7.4.4
>
Rajeshwari Birje July 19, 2012, 6:02 a.m. | #2
Hi Simon Glass,

Thank you for comments.

On Thu, Jul 19, 2012 at 1:39 AM, Simon Glass <sjg@chromium.org> wrote:
> Hi,
>
> On Thu, Jul 5, 2012 at 12:59 PM, Rajeshwari Shinde
> <rajeshwari.s@samsung.com> wrote:
>> This enables I2C support on smdk5250.
>> Pinmux setting moved to board file to avoid repeated setting of
>> gpio lines.
>>
>> Signed-off-by: Alim Akhtar <alim.akhtar@samsung.com>
>> Signed-off-by: Doug Anderson <dianders@chromium.org>
>> Signed-off-by: Rajeshwari Shinde <rajeshwari.s@samsung.com>
>> Acked-by: Simon Glass <sjg@chromium.org>
>> ---
>> Changes in V2:
>>         - None
>> Changes in V3:
>>         - None
>> Changes in V4:
>>         - None
>> Changes in V5:
>>         - Pinmux setting of gpio lines moved to board_early_init_f.
>>  board/samsung/smdk5250/smdk5250.c |   23 ++++++++++++++++++++++-
>>  include/configs/smdk5250.h        |    9 +++++++++
>>  2 files changed, 31 insertions(+), 1 deletions(-)
>>
>> diff --git a/board/samsung/smdk5250/smdk5250.c b/board/samsung/smdk5250/smdk5250.c
>> index b593325..fc08ddc 100644
>> --- a/board/samsung/smdk5250/smdk5250.c
>> +++ b/board/samsung/smdk5250/smdk5250.c
>> @@ -172,9 +172,30 @@ static int board_uart_init(void)
>>         return 0;
>>  }
>>
>> +static int board_i2c_init(void)
>> +{
>> +       int i, err;
>> +
>> +       for (i = 0; i < CONFIG_MAX_I2C_NUM; i++) {
>> +               err = exynos_pinmux_config((PERIPH_ID_I2C0 + i),
>> +                                               PINMUX_FLAG_NONE);
>> +               if (err) {
>> +                       debug("I2C%d not configured\n", (PERIPH_ID_I2C0 + i));
>> +                       return err;
>> +               }
>> +       }
>> +       return 0;
>> +}
>> +
>>  #ifdef CONFIG_BOARD_EARLY_INIT_F
>>  int board_early_init_f(void)
>>  {
>> -       return board_uart_init();
>> +       int err;
>> +       err = board_uart_init();
>> +       if (err) {
>> +               debug("UART init failed\n");
>> +               return err;
>> +       }
>> +       return board_i2c_init();
>>  }
>>  #endif
>> diff --git a/include/configs/smdk5250.h b/include/configs/smdk5250.h
>> index 86dd905..c6df1cf 100644
>> --- a/include/configs/smdk5250.h
>> +++ b/include/configs/smdk5250.h
>> @@ -192,6 +192,15 @@
>>
>>  #define CONFIG_SYS_INIT_SP_ADDR        (CONFIG_SYS_LOAD_ADDR - 0x1000000)
>>
>> +/* I2C */
>> +#define CONFIG_HARD_I2C
>> +#define CONFIG_CMD_I2C
>> +#define CONFIG_SYS_I2C_SPEED   100000          /* 100 Kbps */
>> +#define CONFIG_DRIVER_S3C24X0_I2C
>> +#define CONFIG_I2C_MULTI_BUS
>> +#define CONFIG_MAX_I2C_NUM     8
>> +#define EXYNOS_I2C_SPACING     0x10000
>
> One more comment - I think this last value should be in cpu.h rather
> than a board file.
>
-- Ok
> Regards,
> Simon
>
>> +
>>  /* Ethernet Controllor Driver */
>>  #ifdef CONFIG_CMD_NET
>>  #define CONFIG_SMC911X
>> --
>> 1.7.4.4
>>
> _______________________________________________
> U-Boot mailing list
> U-Boot@lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot

Patch

diff --git a/board/samsung/smdk5250/smdk5250.c b/board/samsung/smdk5250/smdk5250.c
index b593325..fc08ddc 100644
--- a/board/samsung/smdk5250/smdk5250.c
+++ b/board/samsung/smdk5250/smdk5250.c
@@ -172,9 +172,30 @@  static int board_uart_init(void)
 	return 0;
 }
 
+static int board_i2c_init(void)
+{
+	int i, err;
+
+	for (i = 0; i < CONFIG_MAX_I2C_NUM; i++) {
+		err = exynos_pinmux_config((PERIPH_ID_I2C0 + i),
+						PINMUX_FLAG_NONE);
+		if (err) {
+			debug("I2C%d not configured\n", (PERIPH_ID_I2C0 + i));
+			return err;
+		}
+	}
+	return 0;
+}
+
 #ifdef CONFIG_BOARD_EARLY_INIT_F
 int board_early_init_f(void)
 {
-	return board_uart_init();
+	int err;
+	err = board_uart_init();
+	if (err) {
+		debug("UART init failed\n");
+		return err;
+	}
+	return board_i2c_init();
 }
 #endif
diff --git a/include/configs/smdk5250.h b/include/configs/smdk5250.h
index 86dd905..c6df1cf 100644
--- a/include/configs/smdk5250.h
+++ b/include/configs/smdk5250.h
@@ -192,6 +192,15 @@ 
 
 #define CONFIG_SYS_INIT_SP_ADDR	(CONFIG_SYS_LOAD_ADDR - 0x1000000)
 
+/* I2C */
+#define CONFIG_HARD_I2C
+#define CONFIG_CMD_I2C
+#define CONFIG_SYS_I2C_SPEED	100000		/* 100 Kbps */
+#define CONFIG_DRIVER_S3C24X0_I2C
+#define CONFIG_I2C_MULTI_BUS
+#define CONFIG_MAX_I2C_NUM	8
+#define EXYNOS_I2C_SPACING	0x10000
+
 /* Ethernet Controllor Driver */
 #ifdef CONFIG_CMD_NET
 #define CONFIG_SMC911X