Skip to contentSkip to conversation

i2c: omap: fix fclk_rate for ti,omap4-i2c

PATCH Superseded Jan Weitzel 2 participants 7 messages Dec 10, 2014 – Jan 7, 2015

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

PATCH 1/1 i2c: omap: fix fclk_rate for ti,omap4-i2c

"ti,am33xx" and "ti,omap4" use "ti,omap4-i2c" with different fclk_rate. By now set it according to the used cpu compatible.

---
 drivers/i2c/busses/i2c-omap.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/i2c/busses/i2c-omap.c +7 -0
index 094f591..d2254d4 100644
@@ -1015,6 +1015,13 @@ i2c_omap_probe(struct device_d *pdev)
 	i2c_omap->reg_shift = (i2c_data->flags >>
 					OMAP_I2C_FLAG_BUS_SHIFT__SHIFT) & 3;
 
+	if (!i2c_data->fclk_rate) {
+		if (of_machine_is_compatible("ti,am33xx"))
+			i2c_data->fclk_rate = am33xx_data.fclk_rate;
+		if (of_machine_is_compatible("ti,omap4"))
+			i2c_data->fclk_rate = omap4_data.fclk_rate;
+	}
+
 	if (pdev->platform_data != NULL) {
 		speed = *(u32 *)pdev->platform_data;
 	} else {
Signature · 7 lines
1.9.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw
Quoted 13 lines · Jan Weitzel

"ti,am33xx" and "ti,omap4" use "ti,omap4-i2c" with different fclk_rate. By now set it according to the used cpu compatible.

---
 drivers/i2c/busses/i2c-omap.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/i2c/busses/i2c-omap.c +0 -0
index 094f591..d2254d4 100644

drivers/i2c/busses/i2c-omap.c i2c_omap_probe(struct device_d *pdev) · line 1023

Quoted 9 lines
drivers/i2c/busses/i2c-omap.c +6 -0
@@ -1015,6 +1015,13 @@ i2c_omap_probe(struct device_d *pdev)
 	i2c_omap->reg_shift = (i2c_data->flags >>
 					OMAP_I2C_FLAG_BUS_SHIFT__SHIFT) & 3;
 
+	if (!i2c_data->fclk_rate) {
+		if (of_machine_is_compatible("ti,am33xx"))
+			i2c_data->fclk_rate = am33xx_data.fclk_rate;
+		if (of_machine_is_compatible("ti,omap4"))
+			i2c_data->fclk_rate = omap4_data.fclk_rate;
+	}

Can't we just do a:

	if (of_machine_is_compatible("ti,am33xx"))
		i2c_omap->data = &am33xx_data;
	if (of_machine_is_compatible("ti,omap4"))
		i2c_omap->data = &omap4_data;

Instead?

With that we could also remove the nonworking omap4_of_data.

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

PATCH v2 1/1 i2c: omap: fix fclk_rate for ti,omap4-i2c

The compatible "ti,omap4-i2c" don't help to get fclk_rate. So set it acording to cpu compatible: "ti,am33xx" and "ti,omap4"

---
v2: set i2c_data directly

 drivers/i2c/busses/i2c-omap.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/i2c/busses/i2c-omap.c +5 -6
index 094f591..96c3c2b 100644
@@ -271,11 +271,6 @@ static struct omap_i2c_driver_data am33xx_data = {
 	.fclk_rate =	48000,
 };
 
-static struct omap_i2c_driver_data omap4_of_data = {
-	.flags =	OMAP_I2C_FLAG_BUS_SHIFT_NONE,
-	.fclk_rate =	0,
-};
-
 static inline void omap_i2c_write_reg(struct omap_i2c_struct *i2c_omap,
 				      int reg, u16 val)
 {
@@ -1011,6 +1006,11 @@ i2c_omap_probe(struct device_d *pdev)
 	if (r)
 		return r;
 
+	if (of_machine_is_compatible("ti,am33xx"))
+		i2c_data = &am33xx_data;
+	if (of_machine_is_compatible("ti,omap4"))
+		i2c_data = &omap4_data;
+
 	i2c_omap->data = i2c_data;
 	i2c_omap->reg_shift = (i2c_data->flags >>
 					OMAP_I2C_FLAG_BUS_SHIFT__SHIFT) & 3;
@@ -1140,7 +1140,6 @@ static __maybe_unused struct of_device_id omap_i2c_dt_ids[] = {
 		.data = (unsigned long)&omap3_data,
 	}, {
 		.compatible = "ti,omap4-i2c",
-		.data = (unsigned long)&omap4_of_data,
 	}, {
 		/* sentinel */
 	}
Signature · 7 lines
1.9.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#3 lore raw
Quoted 7 lines · Jan Weitzel

The compatible "ti,omap4-i2c" don't help to get fclk_rate. So set it acording to cpu compatible: "ti,am33xx" and "ti,omap4"

---
v2: set i2c_data directly
-9.0.1.i586.deb

ping

Jan

Quoted 47 lines
 drivers/i2c/busses/i2c-omap.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/i2c/busses/i2c-omap.c +5 -6
index 094f591..96c3c2b 100644
@@ -271,11 +271,6 @@ static struct omap_i2c_driver_data am33xx_data = {
 	.fclk_rate =	48000,
 };
 
-static struct omap_i2c_driver_data omap4_of_data = {
-	.flags =	OMAP_I2C_FLAG_BUS_SHIFT_NONE,
-	.fclk_rate =	0,
-};
-
 static inline void omap_i2c_write_reg(struct omap_i2c_struct *i2c_omap,
 				      int reg, u16 val)
 {
@@ -1011,6 +1006,11 @@ i2c_omap_probe(struct device_d *pdev)
 	if (r)
 		return r;
 
+	if (of_machine_is_compatible("ti,am33xx"))
+		i2c_data = &am33xx_data;
+	if (of_machine_is_compatible("ti,omap4"))
+		i2c_data = &omap4_data;
+
 	i2c_omap->data = i2c_data;
 	i2c_omap->reg_shift = (i2c_data->flags >>
 					OMAP_I2C_FLAG_BUS_SHIFT__SHIFT) & 3;
@@ -1140,7 +1140,6 @@ static __maybe_unused struct of_device_id omap_i2c_dt_ids[] = {
 		.data = (unsigned long)&omap3_data,
 	}, {
 		.compatible = "ti,omap4-i2c",
-		.data = (unsigned long)&omap4_of_data,
 	}, {
 		/* sentinel */
 	}
Signature · 7 lines
1.9.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#4 lore raw
Quoted 10 lines · Jan Weitzel
Quoted 7 lines · Jan Weitzel

The compatible "ti,omap4-i2c" don't help to get fclk_rate. So set it acording to cpu compatible: "ti,am33xx" and "ti,omap4"

---
v2: set i2c_data directly
-9.0.1.i586.deb

ping

Applied now.

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#5 lore raw
Quoted 5 lines · Sascha Hauer
Quoted 4 lines · Jan Weitzel
Quoted 3 lines · Jan Weitzel

The compatible "ti,omap4-i2c" don't help to get fclk_rate. So set it acording to cpu compatible: "ti,am33xx" and "ti,omap4"

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

---
v2: set i2c_data directly
-9.0.1.i586.deb

ping

Applied now.

Thanks :)

Jan

Quoted 9 lines

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#6 lore raw
In reply to Sascha Hauer
Quoted 26 lines · Sascha Hauer
Quoted 13 lines · Jan Weitzel

"ti,am33xx" and "ti,omap4" use "ti,omap4-i2c" with different fclk_rate. By now set it according to the used cpu compatible.

---
 drivers/i2c/busses/i2c-omap.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/i2c/busses/i2c-omap.c +0 -0
index 094f591..d2254d4 100644

drivers/i2c/busses/i2c-omap.c i2c_omap_probe(struct device_d *pdev) · line 1023

Quoted 9 lines
drivers/i2c/busses/i2c-omap.c +6 -0
@@ -1015,6 +1015,13 @@ i2c_omap_probe(struct device_d *pdev)
 	i2c_omap->reg_shift = (i2c_data->flags >>
 					OMAP_I2C_FLAG_BUS_SHIFT__SHIFT) & 3;
 
+	if (!i2c_data->fclk_rate) {
+		if (of_machine_is_compatible("ti,am33xx"))
+			i2c_data->fclk_rate = am33xx_data.fclk_rate;
+		if (of_machine_is_compatible("ti,omap4"))
+			i2c_data->fclk_rate = omap4_data.fclk_rate;
+	}

Can't we just do a:

Quoted 6 lines
	if (of_machine_is_compatible("ti,am33xx"))
		i2c_omap->data = &am33xx_data;
	if (of_machine_is_compatible("ti,omap4"))
		i2c_omap->data = &omap4_data;

Instead?

Sounds good, I reworked the patch.

Jan

Quoted 11 lines

With that we could also remove the nonworking omap4_of_data.

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox