diff mbox

Exynos5250: I2C: Fix driver as per new I2C multibus/multiadapter support

Message ID 1378189214-22972-1-git-send-email-rajeshwari.s@samsung.com
State New
Headers show

Commit Message

Rajeshwari Shinde Sept. 3, 2013, 6:20 a.m. UTC
This patch fixes the S3C24xx I2C driver as per new I2C
multibus/multiadapter support for Exynos5250.

Change-Id: I95873fef7d312310670e3bb33ad9532c10f60463
Signed-off-by: Rajeshwari S Shinde <rajeshwari.s@samsung.com>
---
 drivers/i2c/s3c24x0_i2c.c       | 14 +++++++-------
 include/configs/exynos5250-dt.h |  3 ++-
 2 files changed, 9 insertions(+), 8 deletions(-)

Comments

Heiko Schocher Sept. 3, 2013, 7:01 a.m. UTC | #1
Hello Rajeshwari,

Am 03.09.2013 08:20, schrieb Rajeshwari S Shinde:
> This patch fixes the S3C24xx I2C driver as per new I2C
> multibus/multiadapter support for Exynos5250.
>
> Change-Id: I95873fef7d312310670e3bb33ad9532c10f60463
> Signed-off-by: Rajeshwari S Shinde<rajeshwari.s@samsung.com>
> ---
>   drivers/i2c/s3c24x0_i2c.c       | 14 +++++++-------
>   include/configs/exynos5250-dt.h |  3 ++-
>   2 files changed, 9 insertions(+), 8 deletions(-)

Hmm.. could you switch to the new i2c framework instead fixing
the old state of the driver?

Also there is another board which uses this driver:

[hs@pollux u-boot]$ grep -lr CONFIG_DRIVER_S3C24X0_I2C include/configs/
include/configs/exynos5250-dt.h
include/configs/VCMA9.h
[hs@pollux u-boot]$

Please fix this too, if switching to the new framework ... thanks!

> diff --git a/drivers/i2c/s3c24x0_i2c.c b/drivers/i2c/s3c24x0_i2c.c
> index cd09c78..5fdb85f 100644
> --- a/drivers/i2c/s3c24x0_i2c.c
> +++ b/drivers/i2c/s3c24x0_i2c.c
> @@ -53,7 +53,7 @@
>   static unsigned int g_current_bus __attribute__((section(".data")));
>   #ifdef CONFIG_OF_CONTROL
>   static int i2c_busses __attribute__((section(".data")));
> -static struct s3c24x0_i2c_bus i2c_bus[CONFIG_MAX_I2C_NUM]
> +static struct s3c24x0_i2c_bus i2c_bus_data[CONFIG_SYS_NUM_I2C_BUSES]
>   			__attribute__((section(".data")));
>   #endif
>
> @@ -160,7 +160,7 @@ int i2c_set_bus_num(unsigned int bus)
>   {
>   	struct s3c24x0_i2c *i2c;
>
> -	if ((bus<  0) || (bus>= CONFIG_MAX_I2C_NUM)) {
> +	if ((bus<  0) || (bus>= CONFIG_SYS_NUM_I2C_BUSES)) {
>   		debug("Bad bus: %d\n", bus);
>   		return -1;
>   	}
> @@ -503,12 +503,12 @@ int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len)
>   void board_i2c_init(const void *blob)
>   {
>   	int i;
> -	int node_list[CONFIG_MAX_I2C_NUM];
> +	int node_list[CONFIG_SYS_NUM_I2C_BUSES];
>   	int count;
>
>   	count = fdtdec_find_aliases_for_id(blob, "i2c",
>   		COMPAT_SAMSUNG_S3C2440_I2C, node_list,
> -		CONFIG_MAX_I2C_NUM);
> +		CONFIG_SYS_NUM_I2C_BUSES);
>
>   	for (i = 0; i<  count; i++) {
>   		struct s3c24x0_i2c_bus *bus;
> @@ -516,7 +516,7 @@ void board_i2c_init(const void *blob)
>
>   		if (node<= 0)
>   			continue;
> -		bus =&i2c_bus[i];
> +		bus =&i2c_bus_data[i];
>   		bus->regs = (struct s3c24x0_i2c *)
>   			fdtdec_get_addr(blob, node, "reg");
>   		bus->id = pinmux_decode_periph_id(blob, node);
> @@ -529,7 +529,7 @@ void board_i2c_init(const void *blob)
>   static struct s3c24x0_i2c_bus *get_bus(unsigned int bus_idx)
>   {
>   	if (bus_idx<  i2c_busses)
> -		return&i2c_bus[bus_idx];
> +		return&i2c_bus_data[bus_idx];
>
>   	debug("Undefined bus: %d\n", bus_idx);
>   	return NULL;
> @@ -540,7 +540,7 @@ int i2c_get_bus_num_fdt(int node)
>   	int i;
>
>   	for (i = 0; i<  i2c_busses; i++) {
> -		if (node == i2c_bus[i].node)
> +		if (node == i2c_bus_data[i].node)
>   			return i;
>   	}
>
> diff --git a/include/configs/exynos5250-dt.h b/include/configs/exynos5250-dt.h
> index 2b93a45..e6a2cd0 100644
> --- a/include/configs/exynos5250-dt.h
> +++ b/include/configs/exynos5250-dt.h
> @@ -254,8 +254,9 @@
>   #define CONFIG_SYS_I2C_SPEED	100000		/* 100 Kbps */
>   #define CONFIG_DRIVER_S3C24X0_I2C
>   #define CONFIG_I2C_MULTI_BUS

no longer needed, if you use the new framework ...

> -#define CONFIG_MAX_I2C_NUM	8
>   #define CONFIG_SYS_I2C_SLAVE    0x0
> +#define CONFIG_SYS_I2C_MAX_HOPS 1

you do not need the CONFIG_SYS_I2C_MAX_HOPS define, this define is
only needed, if using muxes and using the new framework ...

> +#define CONFIG_SYS_NUM_I2C_BUSES 8

no longer needed if you use the new framework ...

>   #define CONFIG_I2C_EDID
>
>   /* PMIC */

I prefer to switch to the new framework, such it is done for the
tegra driver, see commit:

http://git.denx.de/?p=u-boot.git;a=commitdiff;h=1f2ba722ac06393d6abe6d4734824d3b98ea9108

maybe a fix like this is for you also necessary, as you use fdt:

http://git.denx.de/?p=u-boot.git;a=commitdiff;h=cdce889959c611876690a9f0a3c7ed9aa46189c4

bye,
Heiko
Rajeshwari Birje Sept. 3, 2013, 9:54 a.m. UTC | #2
Hi Heiko,

Ok will work on same and get back to you in-case of any doubts.

Regards,
Rajehswari

On Tue, Sep 3, 2013 at 12:31 PM, Heiko Schocher <hs@denx.de> wrote:
> Hello Rajeshwari,
>
> Am 03.09.2013 08:20, schrieb Rajeshwari S Shinde:
>
>> This patch fixes the S3C24xx I2C driver as per new I2C
>> multibus/multiadapter support for Exynos5250.
>>
>> Change-Id: I95873fef7d312310670e3bb33ad9532c10f60463
>> Signed-off-by: Rajeshwari S Shinde<rajeshwari.s@samsung.com>
>> ---
>>   drivers/i2c/s3c24x0_i2c.c       | 14 +++++++-------
>>   include/configs/exynos5250-dt.h |  3 ++-
>>   2 files changed, 9 insertions(+), 8 deletions(-)
>
>
> Hmm.. could you switch to the new i2c framework instead fixing
> the old state of the driver?
>
> Also there is another board which uses this driver:
>
> [hs@pollux u-boot]$ grep -lr CONFIG_DRIVER_S3C24X0_I2C include/configs/
> include/configs/exynos5250-dt.h
> include/configs/VCMA9.h
> [hs@pollux u-boot]$
>
> Please fix this too, if switching to the new framework ... thanks!
>
>> diff --git a/drivers/i2c/s3c24x0_i2c.c b/drivers/i2c/s3c24x0_i2c.c
>> index cd09c78..5fdb85f 100644
>> --- a/drivers/i2c/s3c24x0_i2c.c
>> +++ b/drivers/i2c/s3c24x0_i2c.c
>> @@ -53,7 +53,7 @@
>>   static unsigned int g_current_bus __attribute__((section(".data")));
>>   #ifdef CONFIG_OF_CONTROL
>>   static int i2c_busses __attribute__((section(".data")));
>> -static struct s3c24x0_i2c_bus i2c_bus[CONFIG_MAX_I2C_NUM]
>> +static struct s3c24x0_i2c_bus i2c_bus_data[CONFIG_SYS_NUM_I2C_BUSES]
>>                         __attribute__((section(".data")));
>>   #endif
>>
>> @@ -160,7 +160,7 @@ int i2c_set_bus_num(unsigned int bus)
>>   {
>>         struct s3c24x0_i2c *i2c;
>>
>> -       if ((bus<  0) || (bus>= CONFIG_MAX_I2C_NUM)) {
>> +       if ((bus<  0) || (bus>= CONFIG_SYS_NUM_I2C_BUSES)) {
>>                 debug("Bad bus: %d\n", bus);
>>                 return -1;
>>         }
>> @@ -503,12 +503,12 @@ int i2c_write(uchar chip, uint addr, int alen, uchar
>> *buffer, int len)
>>   void board_i2c_init(const void *blob)
>>   {
>>         int i;
>> -       int node_list[CONFIG_MAX_I2C_NUM];
>> +       int node_list[CONFIG_SYS_NUM_I2C_BUSES];
>>         int count;
>>
>>         count = fdtdec_find_aliases_for_id(blob, "i2c",
>>                 COMPAT_SAMSUNG_S3C2440_I2C, node_list,
>> -               CONFIG_MAX_I2C_NUM);
>> +               CONFIG_SYS_NUM_I2C_BUSES);
>>
>>         for (i = 0; i<  count; i++) {
>>                 struct s3c24x0_i2c_bus *bus;
>> @@ -516,7 +516,7 @@ void board_i2c_init(const void *blob)
>>
>>                 if (node<= 0)
>>                         continue;
>> -               bus =&i2c_bus[i];
>> +               bus =&i2c_bus_data[i];
>>
>>                 bus->regs = (struct s3c24x0_i2c *)
>>                         fdtdec_get_addr(blob, node, "reg");
>>                 bus->id = pinmux_decode_periph_id(blob, node);
>> @@ -529,7 +529,7 @@ void board_i2c_init(const void *blob)
>>   static struct s3c24x0_i2c_bus *get_bus(unsigned int bus_idx)
>>   {
>>         if (bus_idx<  i2c_busses)
>> -               return&i2c_bus[bus_idx];
>> +               return&i2c_bus_data[bus_idx];
>>
>>
>>         debug("Undefined bus: %d\n", bus_idx);
>>         return NULL;
>> @@ -540,7 +540,7 @@ int i2c_get_bus_num_fdt(int node)
>>         int i;
>>
>>         for (i = 0; i<  i2c_busses; i++) {
>> -               if (node == i2c_bus[i].node)
>> +               if (node == i2c_bus_data[i].node)
>>                         return i;
>>         }
>>
>> diff --git a/include/configs/exynos5250-dt.h
>> b/include/configs/exynos5250-dt.h
>> index 2b93a45..e6a2cd0 100644
>> --- a/include/configs/exynos5250-dt.h
>> +++ b/include/configs/exynos5250-dt.h
>> @@ -254,8 +254,9 @@
>>   #define CONFIG_SYS_I2C_SPEED  100000          /* 100 Kbps */
>>   #define CONFIG_DRIVER_S3C24X0_I2C
>>   #define CONFIG_I2C_MULTI_BUS
>
>
> no longer needed, if you use the new framework ...
>
>
>> -#define CONFIG_MAX_I2C_NUM     8
>>   #define CONFIG_SYS_I2C_SLAVE    0x0
>> +#define CONFIG_SYS_I2C_MAX_HOPS 1
>
>
> you do not need the CONFIG_SYS_I2C_MAX_HOPS define, this define is
> only needed, if using muxes and using the new framework ...
>
>> +#define CONFIG_SYS_NUM_I2C_BUSES 8
>
>
> no longer needed if you use the new framework ...
>
>
>>   #define CONFIG_I2C_EDID
>>
>>   /* PMIC */
>
>
> I prefer to switch to the new framework, such it is done for the
> tegra driver, see commit:
>
> http://git.denx.de/?p=u-boot.git;a=commitdiff;h=1f2ba722ac06393d6abe6d4734824d3b98ea9108
>
> maybe a fix like this is for you also necessary, as you use fdt:
>
> http://git.denx.de/?p=u-boot.git;a=commitdiff;h=cdce889959c611876690a9f0a3c7ed9aa46189c4
>
> bye,
> Heiko
> --
> DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
>
> _______________________________________________
> U-Boot mailing list
> U-Boot@lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
diff mbox

Patch

diff --git a/drivers/i2c/s3c24x0_i2c.c b/drivers/i2c/s3c24x0_i2c.c
index cd09c78..5fdb85f 100644
--- a/drivers/i2c/s3c24x0_i2c.c
+++ b/drivers/i2c/s3c24x0_i2c.c
@@ -53,7 +53,7 @@ 
 static unsigned int g_current_bus __attribute__((section(".data")));
 #ifdef CONFIG_OF_CONTROL
 static int i2c_busses __attribute__((section(".data")));
-static struct s3c24x0_i2c_bus i2c_bus[CONFIG_MAX_I2C_NUM]
+static struct s3c24x0_i2c_bus i2c_bus_data[CONFIG_SYS_NUM_I2C_BUSES]
 			__attribute__((section(".data")));
 #endif
 
@@ -160,7 +160,7 @@  int i2c_set_bus_num(unsigned int bus)
 {
 	struct s3c24x0_i2c *i2c;
 
-	if ((bus < 0) || (bus >= CONFIG_MAX_I2C_NUM)) {
+	if ((bus < 0) || (bus >= CONFIG_SYS_NUM_I2C_BUSES)) {
 		debug("Bad bus: %d\n", bus);
 		return -1;
 	}
@@ -503,12 +503,12 @@  int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len)
 void board_i2c_init(const void *blob)
 {
 	int i;
-	int node_list[CONFIG_MAX_I2C_NUM];
+	int node_list[CONFIG_SYS_NUM_I2C_BUSES];
 	int count;
 
 	count = fdtdec_find_aliases_for_id(blob, "i2c",
 		COMPAT_SAMSUNG_S3C2440_I2C, node_list,
-		CONFIG_MAX_I2C_NUM);
+		CONFIG_SYS_NUM_I2C_BUSES);
 
 	for (i = 0; i < count; i++) {
 		struct s3c24x0_i2c_bus *bus;
@@ -516,7 +516,7 @@  void board_i2c_init(const void *blob)
 
 		if (node <= 0)
 			continue;
-		bus = &i2c_bus[i];
+		bus = &i2c_bus_data[i];
 		bus->regs = (struct s3c24x0_i2c *)
 			fdtdec_get_addr(blob, node, "reg");
 		bus->id = pinmux_decode_periph_id(blob, node);
@@ -529,7 +529,7 @@  void board_i2c_init(const void *blob)
 static struct s3c24x0_i2c_bus *get_bus(unsigned int bus_idx)
 {
 	if (bus_idx < i2c_busses)
-		return &i2c_bus[bus_idx];
+		return &i2c_bus_data[bus_idx];
 
 	debug("Undefined bus: %d\n", bus_idx);
 	return NULL;
@@ -540,7 +540,7 @@  int i2c_get_bus_num_fdt(int node)
 	int i;
 
 	for (i = 0; i < i2c_busses; i++) {
-		if (node == i2c_bus[i].node)
+		if (node == i2c_bus_data[i].node)
 			return i;
 	}
 
diff --git a/include/configs/exynos5250-dt.h b/include/configs/exynos5250-dt.h
index 2b93a45..e6a2cd0 100644
--- a/include/configs/exynos5250-dt.h
+++ b/include/configs/exynos5250-dt.h
@@ -254,8 +254,9 @@ 
 #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 CONFIG_SYS_I2C_SLAVE    0x0
+#define CONFIG_SYS_I2C_MAX_HOPS 1
+#define CONFIG_SYS_NUM_I2C_BUSES 8
 #define CONFIG_I2C_EDID
 
 /* PMIC */