Skip to contentSkip to conversation

driver: i2c:s3c24x0: init each channel during probe

PATCH New Naveen Krishna Chatradhi 3 participants 3 messages Nov 22, 2013 – Nov 25, 2013

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

PATCH 1/1 driver: i2c:s3c24x0: init each channel during probe

Each I2C channel must be inited during the probe and then set "active" instead of initing the channel for every time we select the bus using "i2c dev bus"

---
 drivers/i2c/s3c24x0_i2c.c |   29 +++++++++++++----------------
 1 file changed, 13 insertions(+), 16 deletions(-)
drivers/i2c/s3c24x0_i2c.c +13 -16
index f77a9d1..7136771 100644
@@ -408,22 +408,7 @@ static void exynos5_i2c_reset(struct s3c24x0_i2c_bus *i2c_bus)
 #ifdef CONFIG_I2C_MULTI_BUS
 int i2c_set_bus_num(unsigned int bus)
 {
-	struct s3c24x0_i2c_bus *i2c_bus;
-
-	i2c_bus = get_bus(bus);
-	if (!i2c_bus)
-		return -1;
 	g_current_bus = bus;
-
-	if (i2c_bus->is_highspeed) {
-		if (hsi2c_get_clk_details(i2c_bus))
-			return -1;
-		hsi2c_ch_init(i2c_bus);
-	} else {
-		i2c_ch_init(i2c_bus->regs, i2c_bus->clock_frequency,
-						CONFIG_SYS_I2C_SLAVE);
-	}
-
 	return 0;
 }
 
@@ -989,7 +974,6 @@ static void process_nodes(const void *blob, int node_list[], int count,
 			continue;
 
 		bus = &i2c_bus[i];
-		bus->active = true;
 		bus->is_highspeed = is_highspeed;
 
 		if (is_highspeed)
@@ -1009,6 +993,19 @@ static void process_nodes(const void *blob, int node_list[], int count,
 
 		/* Mark position as used */
 		node_list[i] = -1;
+
+		if (bus->is_highspeed) {
+			if (hsi2c_get_clk_details(bus)) {
+				bus->active = false;
+				break;
+			}
+			hsi2c_ch_init(bus);
+			exynos5_i2c_reset(bus);
+		} else {
+			i2c_ch_init(bus->regs, bus->clock_frequency,
+							CONFIG_SYS_I2C_SLAVE);
+		}
+		bus->active = true;
 	}
 }
 
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH 1/1 driver: i2c:s3c24x0: init each channel during probe

Hello All,

Quoted 46 lines · Naveen Krishna Chatradhi

Each I2C channel must be inited during the probe and then set "active" instead of initing the channel for every time we select the bus using "i2c dev bus"

---
 drivers/i2c/s3c24x0_i2c.c |   29 +++++++++++++----------------
 1 file changed, 13 insertions(+), 16 deletions(-)
drivers/i2c/s3c24x0_i2c.c +0 -16
index f77a9d1..7136771 100644
@@ -408,22 +408,7 @@ static void exynos5_i2c_reset(struct s3c24x0_i2c_bus *i2c_bus)
 #ifdef CONFIG_I2C_MULTI_BUS
 int i2c_set_bus_num(unsigned int bus)
 {
-       struct s3c24x0_i2c_bus *i2c_bus;
-
-       i2c_bus = get_bus(bus);
-       if (!i2c_bus)
-               return -1;
        g_current_bus = bus;
-
-       if (i2c_bus->is_highspeed) {
-               if (hsi2c_get_clk_details(i2c_bus))
-                       return -1;
-               hsi2c_ch_init(i2c_bus);
-       } else {
-               i2c_ch_init(i2c_bus->regs, i2c_bus->clock_frequency,
-                                               CONFIG_SYS_I2C_SLAVE);
-       }
-
        return 0;
 }
 
@@ -989,7 +974,6 @@ static void process_nodes(const void *blob, int node_list[], int count,
                        continue;
 
                bus = &i2c_bus[i];
-               bus->active = true;
                bus->is_highspeed = is_highspeed;
 
                if (is_highspeed)
@@ -1009,6 +993,19 @@ static void process_nodes(const void *blob, int node_list[], int count,
 

drivers/i2c/s3c24x0_i2c.c static void process_nodes(const void *blob, int node_list[], int count, · line 1003

Quoted 10 lines
drivers/i2c/s3c24x0_i2c.c +8 -0
                /* Mark position as used */
                node_list[i] = -1;
+
+               if (bus->is_highspeed) {
+                       if (hsi2c_get_clk_details(bus)) {
+                               bus->active = false;
+                               break;
+                       }
+                       hsi2c_ch_init(bus);
+                       exynos5_i2c_reset(bus);

HSI2C module on Exynos5260 needs a reset of module during reset. Similar patch is being posted for kernel at
http://www.kernelhub.org/?msg=365741&p=2

As this is a one time activity, guess resetting all channels is not a problem. I can implement a "SoC type quirk" to distinguish otherwise.

Quoted 11 lines
drivers/i2c/s3c24x0_i2c.c +5 -1
+               } else {
+                       i2c_ch_init(bus->regs, bus->clock_frequency,
+                                                       CONFIG_SYS_I2C_SLAVE);
+               }
+               bus->active = true;
        }
 }
 
--

1.7.10.4

Signature · 2 lines
Shine bright,
(: Nav :)
#2 lore raw

PATCH 1/1 driver: i2c:s3c24x0: init each channel during probe

Hello Naveen,

Am 22.11.2013 09:50, schrieb Naveen Krishna Ch:

Quoted 12 lines

Hello All,

Quoted 8 lines · Naveen Krishna Chatradhi

Each I2C channel must be inited during the probe and then set "active" instead of initing the channel for every time we select the bus using "i2c dev bus"

---
  drivers/i2c/s3c24x0_i2c.c |   29 +++++++++++++----------------
  1 file changed, 13 insertions(+), 16 deletions(-)

This patch do not apply based on the patches from Piotr Wilczek, see

[U-Boot,V2,1/2] driver:i2c:s3c24x0: adapt driver to new i2c
http://patchwork.ozlabs.org/patch/292705/
[U-Boot,2/2] driver:i2c:s3c24x0: fix clock init for hsi2c
http://patchwork.ozlabs.org/patch/292706/

Could you rebase your patch on base of this two patches?

Thanks!

Quoted 52 lines
Quoted 37 lines
drivers/i2c/s3c24x0_i2c.c +0 -16
index f77a9d1..7136771 100644
@@ -408,22 +408,7 @@ static void exynos5_i2c_reset(struct s3c24x0_i2c_bus *i2c_bus)
  #ifdef CONFIG_I2C_MULTI_BUS
  int i2c_set_bus_num(unsigned int bus)
  {
-       struct s3c24x0_i2c_bus *i2c_bus;
-
-       i2c_bus = get_bus(bus);
-       if (!i2c_bus)
-               return -1;
         g_current_bus = bus;
-
-       if (i2c_bus->is_highspeed) {
-               if (hsi2c_get_clk_details(i2c_bus))
-                       return -1;
-               hsi2c_ch_init(i2c_bus);
-       } else {
-               i2c_ch_init(i2c_bus->regs, i2c_bus->clock_frequency,
-                                               CONFIG_SYS_I2C_SLAVE);
-       }
-
         return 0;
  }
 
@@ -989,7 +974,6 @@ static void process_nodes(const void *blob, int node_list[], int count,
                         continue;
 
                 bus =&i2c_bus[i];
-               bus->active = true;
                 bus->is_highspeed = is_highspeed;
 
                 if (is_highspeed)
@@ -1009,6 +993,19 @@ static void process_nodes(const void *blob, int node_list[], int count,
 

drivers/i2c/s3c24x0_i2c.c static void process_nodes(const void *blob, int node_list[], int count, · line 1003

Quoted 10 lines
drivers/i2c/s3c24x0_i2c.c +8 -0
                 /* Mark position as used */
                 node_list[i] = -1;
+
+               if (bus->is_highspeed) {
+                       if (hsi2c_get_clk_details(bus)) {
+                               bus->active = false;
+                               break;
+                       }
+                       hsi2c_ch_init(bus);
+                       exynos5_i2c_reset(bus);

HSI2C module on Exynos5260 needs a reset of module during reset. Similar patch is being posted for kernel at
http://www.kernelhub.org/?msg=365741&p=2

Quoted 1 line

As this is a one time activity, guess resetting all channels is not a problem.

Ok, from my side.

Quoted 1 line

I can implement a "SoC type quirk" to distinguish otherwise.

bye,
Heiko

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