Skip to contentSkip to conversation

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

PATCH New Rajeshwari S Shinde 3 participants 3 messages Sep 3, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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

This patch fixes the S3C24xx I2C driver as per new I2C multibus/multiadapter support for Exynos5250.

Change-Id I95873fef7d312310670e3bb33ad9532c10f60463
---
 drivers/i2c/s3c24x0_i2c.c       | 14 +++++++-------
 include/configs/exynos5250-dt.h |  3 ++-
 2 files changed, 9 insertions(+), 8 deletions(-)
drivers/i2c/s3c24x0_i2c.c +7 -7
index cd09c78..5fdb85f 100644
@@ -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;
 	}
 
include/configs/exynos5250-dt.h +2 -1
index 2b93a45..e6a2cd0 100644
@@ -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 */
Signature · 1 line
1.7.12.4
#1 lore raw

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

Hello Rajeshwari,

Am 03.09.2013 08:20, schrieb Rajeshwari S Shinde:

Quoted 9 lines

This patch fixes the S3C24xx I2C driver as per new I2C multibus/multiadapter support for Exynos5250.

Change-Id I95873fef7d312310670e3bb33ad9532c10f60463
---
  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 at pollux u-boot]$ grep -lr CONFIG_DRIVER_S3C24X0_I2C include/configs/ include/configs/exynos5250-dt.h
include/configs/VCMA9.h
[hs at pollux u-boot]$

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

Quoted 69 lines
drivers/i2c/s3c24x0_i2c.c +7 -7
index cd09c78..5fdb85f 100644
@@ -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;
  	}
 
include/configs/exynos5250-dt.h +0 -0
index 2b93a45..e6a2cd0 100644

include/configs/exynos5250-dt.h line 256

Quoted 3 lines
include/configs/exynos5250-dt.h +0 -0
@@ -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 ...

include/configs/exynos5250-dt.h line 258

Quoted 3 lines
include/configs/exynos5250-dt.h +1 -1
-#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 ...

include/configs/exynos5250-dt.h line 259

Quoted 1 line
include/configs/exynos5250-dt.h +1 -0
+#define CONFIG_SYS_NUM_I2C_BUSES 8

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

include/configs/exynos5250-dt.h line 262

Quoted 3 lines
include/configs/exynos5250-dt.h +0 -0
  #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

Signature · 2 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
#2 lore raw

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

Hi Heiko,

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

Regards,
Rajehswari

Quoted 146 lines · Heiko Schocher

Hello Rajeshwari,

Am 03.09.2013 08:20, schrieb Rajeshwari S Shinde:

Quoted 9 lines

This patch fixes the S3C24xx I2C driver as per new I2C multibus/multiadapter support for Exynos5250.

Change-Id I95873fef7d312310670e3bb33ad9532c10f60463
---
  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 at pollux u-boot]$ grep -lr CONFIG_DRIVER_S3C24X0_I2C include/configs/ include/configs/exynos5250-dt.h
include/configs/VCMA9.h
[hs at pollux u-boot]$

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

Quoted 73 lines
drivers/i2c/s3c24x0_i2c.c +4 -4
index cd09c78..5fdb85f 100644
@@ -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;
drivers/i2c/s3c24x0_i2c.c +1 -1
@@ -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);
drivers/i2c/s3c24x0_i2c.c +1 -1
@@ -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;
drivers/i2c/s3c24x0_i2c.c +1 -1
@@ -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;
        }
 
include/configs/exynos5250-dt.h +0 -0
index 2b93a45..e6a2cd0 100644

include/configs/exynos5250-dt.h line 256

Quoted 3 lines
include/configs/exynos5250-dt.h +0 -0
@@ -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 ...

include/configs/exynos5250-dt.h line 258

Quoted 3 lines
include/configs/exynos5250-dt.h +1 -1
-#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 ...

include/configs/exynos5250-dt.h line 259

Quoted 1 line
include/configs/exynos5250-dt.h +1 -0
+#define CONFIG_SYS_NUM_I2C_BUSES 8

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

include/configs/exynos5250-dt.h line 262

Quoted 3 lines
include/configs/exynos5250-dt.h +0 -0
  #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 at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Signature · 2 lines
Regards,
Rajeshwari Shinde