Skip to contentSkip to conversation

I2C: MV64XYZ: Add Device Tree support

PATCH New Andrew Lunn 2 participants 3 messages Jul 22, 2012 – Jul 24, 2012

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

PATCH 1/1 I2C: MV64XYZ: Add Device Tree support

Extends the driver to get properties from device tree. Rather than pass the N & M factors in DT, use the more standard clock-frequency property. Calculate N & M at run time. In order to do this, we need to know tclk. So the driver uses clk_get() etc in order to get the clock and clk_get_rate() to determine the tclk rate. Not all platforms however have CLK, so some #ifdefery is needed to ensure the driver still compiles when CLK is not available.

---

- Replaced the timeout property in DT, with a hard coded 1 second.
- Put all the OF code together.
- Split the ARM parts from the driver itself.
- Dropped Sebastian Hesselbarth Acked-by, since the changes are not trivial.
- Change MV64XXX to MV64XYZ in the Subject to try to get it past the list spam filter.
- return -ENODEV and else if comments from Wolfram.
- Rebased on i2c-embedded/for-next

 Documentation/devicetree/bindings/i2c/mrvl-i2c.txt |   19 ++-
 drivers/i2c/busses/i2c-mv64xxx.c                   |  134 +++++++++++++++++++-
 2 files changed, 147 insertions(+), 6 deletions(-)
Documentation/devicetree/bindings/i2c/mrvl-i2c.txt +18 -1
index b891ee2..0f79450 100644
@@ -1,4 +1,4 @@
-* I2C
+* Marvell MMP I2C controller
 
 Required properties :
 
@@ -32,3 +32,20 @@ Examples:
 		interrupts = <58>;
 	};
 
+* Marvell MV64XXX I2C controller
+
+Required properties :
+
+ - reg             : Offset and length of the register set for the device
+ - compatible      : Should be "marvell,mv64xxx-i2c"
+ - interrupts      : The interrupt number
+ - clock-frequency : Desired I2C bus clock frequency in Hz.
+
+Examples:
+
+	i2c at 11000 {
+		compatible = "marvell,mv64xxx-i2c";
+		reg = <0x11000 0x20>;
+		interrupts = <29>;
+		clock-frequency = <100000>;
+	};
drivers/i2c/busses/i2c-mv64xxx.c +129 -5

201 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#1 lore raw

PATCH 1/1 I2C: MV64XYZ: Add Device Tree support

Quoted 9 lines · Andrew Lunn

Extends the driver to get properties from device tree. Rather than pass the N & M factors in DT, use the more standard clock-frequency property. Calculate N & M at run time. In order to do this, we need to know tclk. So the driver uses clk_get() etc in order to get the clock and clk_get_rate() to determine the tclk rate. Not all platforms however have CLK, so some #ifdefery is needed to ensure the driver still compiles when CLK is not available.

Sparse complained about this:

drivers/i2c/busses/i2c-mv64xxx.c:584:54: warning: incorrect type in argument 3 (different signedness)
drivers/i2c/busses/i2c-mv64xxx.c:584:54: expected unsigned int [usertype] *out_value
drivers/i2c/busses/i2c-mv64xxx.c:584:54: got int *<noident>
drivers/i2c/busses/i2c-mv64xxx.c:586:41: warning: incorrect type in argument 3 (different signedness)
drivers/i2c/busses/i2c-mv64xxx.c:586:41: expected int *best_n
drivers/i2c/busses/i2c-mv64xxx.c:586:41: got unsigned int *<noident>
drivers/i2c/busses/i2c-mv64xxx.c:586:60: warning: incorrect type in argument 4 (different signedness)
drivers/i2c/busses/i2c-mv64xxx.c:586:60: expected int *best_m
drivers/i2c/busses/i2c-mv64xxx.c:586:60: got unsigned int *<noident>

I applied your patch with the following fix to -next. Let me know if you agree with that.

Regards,

Wolfram

drivers/i2c/busses/i2c-mv64xxx.c +3 -4
@@ -537,8 +537,8 @@ mv64xxx_calc_freq(const int tclk, const int n, const int m)
 }
 
 static bool __devinit
-mv64xxx_find_baud_factors(const int req_freq, const int tclk, int *best_n,
-                         int *best_m)
+mv64xxx_find_baud_factors(const u32 req_freq, const u32 tclk, u32 *best_n,
+                         u32 *best_m)
 {
        int freq, delta, best_delta = INT_MAX;
        int m, n;
@@ -564,8 +564,7 @@ static int __devinit
 mv64xxx_of_config(struct mv64xxx_i2c_data *drv_data,
                  struct device_node *np)
 {
-       int bus_freq;
-       int tclk;
+       u32 bus_freq, tclk;
        int rc = 0;
 
        /* CLK is mandatory when using DT to describe the i2c bus. We
Signature · 9 lines
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120723/eb671a3b/attachment.sig>
#2 lore raw

PATCH 1/1 I2C: MV64XYZ: Add Device Tree support

Quoted 23 lines · Wolfram Sang
Quoted 9 lines · Andrew Lunn

Extends the driver to get properties from device tree. Rather than pass the N & M factors in DT, use the more standard clock-frequency property. Calculate N & M at run time. In order to do this, we need to know tclk. So the driver uses clk_get() etc in order to get the clock and clk_get_rate() to determine the tclk rate. Not all platforms however have CLK, so some #ifdefery is needed to ensure the driver still compiles when CLK is not available.

Sparse complained about this:

drivers/i2c/busses/i2c-mv64xxx.c:584:54: warning: incorrect type in argument 3 (different signedness)
drivers/i2c/busses/i2c-mv64xxx.c:584:54: expected unsigned int [usertype] *out_value
drivers/i2c/busses/i2c-mv64xxx.c:584:54: got int *<noident>
drivers/i2c/busses/i2c-mv64xxx.c:586:41: warning: incorrect type in argument 3 (different signedness)
drivers/i2c/busses/i2c-mv64xxx.c:586:41: expected int *best_n
drivers/i2c/busses/i2c-mv64xxx.c:586:41: got unsigned int *<noident>
drivers/i2c/busses/i2c-mv64xxx.c:586:60: warning: incorrect type in argument 4 (different signedness)
drivers/i2c/busses/i2c-mv64xxx.c:586:60: expected int *best_m
drivers/i2c/busses/i2c-mv64xxx.c:586:60: got unsigned int *<noident>

Quoted 2 lines

I applied your patch with the following fix to -next. Let me know if you agree with that.

Hi Wolfram

Looks good, thanks for the fix.

Andrew