diff mbox

[6/6] SMDK5250: Populate I2C data using FDT.

Message ID 1352352603-17114-7-git-send-email-rajeshwari.s@samsung.com
State New
Headers show

Commit Message

Rajeshwari Shinde Nov. 8, 2012, 5:30 a.m. UTC
Signed-off-by: Rajeshwari Shinde <rajeshwari.s@samsung.com>
---
 board/samsung/smdk5250/smdk5250.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

Comments

Simon Glass Nov. 9, 2012, 1:08 a.m. UTC | #1
Hi Rajeshwari,

On Wed, Nov 7, 2012 at 9:30 PM, Rajeshwari Shinde
<rajeshwari.s@samsung.com> wrote:
> Signed-off-by: Rajeshwari Shinde <rajeshwari.s@samsung.com>
> ---
>  board/samsung/smdk5250/smdk5250.c |    7 +++++--
>  1 files changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/board/samsung/smdk5250/smdk5250.c b/board/samsung/smdk5250/smdk5250.c
> index db2457b..dfb7239 100644
> --- a/board/samsung/smdk5250/smdk5250.c
> +++ b/board/samsung/smdk5250/smdk5250.c
> @@ -276,8 +276,11 @@ static int board_uart_init(void)
>  static int board_i2c_init(void)
>  {
>         int i, err;
> -
> -       for (i = 0; i < CONFIG_MAX_I2C_NUM; i++) {
> +       int count = CONFIG_MAX_I2C_NUM;
> +#ifdef CONFIG_OF_CONTROL
> +       count = i2c_fdt_bus_values(gd->fdt_blob);
> +#endif
> +       for (i = 0; i < count; i++) {
>                 err = exynos_pinmux_config((PERIPH_ID_I2C0 + i),
>                                                 PINMUX_FLAG_NONE);
>                 if (err) {

Hmmm well I think you are trying to avoid setting the pinmux for
unused ports. But actually the active ports are determined by the
aliases at present (later we will perhaps use the 'status' property as
we should).

So getting the number of ports doesn't help you - for example, there
might be 4 ports, but only 0 and 3 are used. You may as well just use
CONFIG_MAX_I2C_NUM as it will be no less correct in general.

If you want to setup pinmux only for the ports that are used you will
need to put the exynos_pinmux_config() call inside the driver in the
fdt case. It can set up pinmux in your init function when it finds a
port that is being used in the fdt (the function I suggested you
rename to board_init_i2c()()).

> --
> 1.7.4.4
>

Regards,
Simon
diff mbox

Patch

diff --git a/board/samsung/smdk5250/smdk5250.c b/board/samsung/smdk5250/smdk5250.c
index db2457b..dfb7239 100644
--- a/board/samsung/smdk5250/smdk5250.c
+++ b/board/samsung/smdk5250/smdk5250.c
@@ -276,8 +276,11 @@  static int board_uart_init(void)
 static int board_i2c_init(void)
 {
 	int i, err;
-
-	for (i = 0; i < CONFIG_MAX_I2C_NUM; i++) {
+	int count = CONFIG_MAX_I2C_NUM;
+#ifdef CONFIG_OF_CONTROL
+	count = i2c_fdt_bus_values(gd->fdt_blob);
+#endif
+	for (i = 0; i < count; i++) {
 		err = exynos_pinmux_config((PERIPH_ID_I2C0 + i),
 						PINMUX_FLAG_NONE);
 		if (err) {