Skip to contentSkip to conversation

i2c: omap: fix dts property "clock-frequency" usage

PATCH Applied Teresa Gámez 2 participants 2 messages Oct 1, 2014 – Oct 2, 2014

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

PATCH 1/1 i2c: omap: fix dts property "clock-frequency" usage

Looking at the linux kernel the clock-frequency property of the device tree is used to set the bus speed and not the fclk_rate. Adapted this to be compliant with linux kernel.

---
 drivers/i2c/busses/i2c-omap.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/i2c/busses/i2c-omap.c +10 -10
index adc952b..48bdfbe 100644
@@ -151,7 +151,6 @@ struct omap_i2c_struct {
 	u8			reg_shift;
 	struct omap_i2c_driver_data	*data;
 	struct resource		*ioarea;
-	u32			fclk_rate;
 	u32			speed;		/* Speed of bus in Khz */
 	u16			scheme;
 	u16			cmd_err;
@@ -421,7 +420,7 @@ static int omap_i2c_init(struct omap_i2c_struct *i2c_omap)
 		internal_clk = 4000;
 
 	/* Compute prescaler divisor */
-	psc = i2c_omap->fclk_rate / internal_clk;
+	psc = i2c_data->fclk_rate / internal_clk;
 	psc = psc - 1;
 
 	/* If configured for High Speed */
@@ -1016,9 +1015,16 @@ i2c_omap_probe(struct device_d *pdev)
 	i2c_omap->reg_shift = (i2c_data->flags >>
 					OMAP_I2C_FLAG_BUS_SHIFT__SHIFT) & 3;
 
-	if (pdev->platform_data != NULL)
+	if (pdev->platform_data != NULL) {
 		speed = *(u32 *)pdev->platform_data;
-	else
+	} else {
+		of_property_read_u32(pdev->device_node, "clock-frequency",
+			&speed);
+		/* convert DT freq value in Hz into kHz for speed */
+		speed /= 1000;
+	}
+
+	if (!speed)
 		speed = 100;	/* Default speed */
 
 	i2c_omap->speed = speed;
@@ -1080,12 +1086,6 @@ i2c_omap_probe(struct device_d *pdev)
 			i2c_omap->b_hw = 1; /* Enable hardware fixes */
 	}
 
-	i2c_omap->fclk_rate = i2c_data->fclk_rate;
-
-	if (!i2c_omap->fclk_rate)
-		of_property_read_u32(pdev->device_node, "clock-frequency",
-				&i2c_omap->fclk_rate);
-
 	/* reset ASAP, clearing any IRQs */
 	omap_i2c_init(i2c_omap);
 
Signature · 7 lines
1.9.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Applied
#1 lore raw
Quoted 5 lines · Teresa Gámez

Looking at the linux kernel the clock-frequency property of the device tree is used to set the bus speed and not the fclk_rate. Adapted this to be compliant with linux kernel.

Applied, thanks

Sascha

Quoted 65 lines
---
 drivers/i2c/busses/i2c-omap.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/i2c/busses/i2c-omap.c +10 -10
index adc952b..48bdfbe 100644
@@ -151,7 +151,6 @@ struct omap_i2c_struct {
 	u8			reg_shift;
 	struct omap_i2c_driver_data	*data;
 	struct resource		*ioarea;
-	u32			fclk_rate;
 	u32			speed;		/* Speed of bus in Khz */
 	u16			scheme;
 	u16			cmd_err;
@@ -421,7 +420,7 @@ static int omap_i2c_init(struct omap_i2c_struct *i2c_omap)
 		internal_clk = 4000;
 
 	/* Compute prescaler divisor */
-	psc = i2c_omap->fclk_rate / internal_clk;
+	psc = i2c_data->fclk_rate / internal_clk;
 	psc = psc - 1;
 
 	/* If configured for High Speed */
@@ -1016,9 +1015,16 @@ i2c_omap_probe(struct device_d *pdev)
 	i2c_omap->reg_shift = (i2c_data->flags >>
 					OMAP_I2C_FLAG_BUS_SHIFT__SHIFT) & 3;
 
-	if (pdev->platform_data != NULL)
+	if (pdev->platform_data != NULL) {
 		speed = *(u32 *)pdev->platform_data;
-	else
+	} else {
+		of_property_read_u32(pdev->device_node, "clock-frequency",
+			&speed);
+		/* convert DT freq value in Hz into kHz for speed */
+		speed /= 1000;
+	}
+
+	if (!speed)
 		speed = 100;	/* Default speed */
 
 	i2c_omap->speed = speed;
@@ -1080,12 +1086,6 @@ i2c_omap_probe(struct device_d *pdev)
 			i2c_omap->b_hw = 1; /* Enable hardware fixes */
 	}
 
-	i2c_omap->fclk_rate = i2c_data->fclk_rate;
-
-	if (!i2c_omap->fclk_rate)
-		of_property_read_u32(pdev->device_node, "clock-frequency",
-				&i2c_omap->fclk_rate);
-
 	/* reset ASAP, clearing any IRQs */
 	omap_i2c_init(i2c_omap);
 
Signature · 7 lines
1.9.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
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