i2c: rcar: modify I2C driver
Subsystems (4)
RFC 4/10 i2c: rcar: modify I2C driver
From: Nguyen Viet Dung <[email protected]>
This patch modify calculate for clock in I2C driver.
--- drivers/i2c/busses/i2c-rcar.c | 17 +++++++++++++++-- include/linux/i2c/i2c-rcar.h | 4 ++++ 2 files changed, 19 insertions(+), 2 deletions(-)
drivers/i2c/busses/i2c-rcar.c +15 -2
@@ -221,15 +221,28 @@ static int rcar_i2c_clock_calculate(struct rcar_i2c_priv *priv, struct device *dev) {struct clk *clkp =clk_get (NULL ,"peripheral_clk" ); +struct i2c_rcar_platform_data *pdata = dev->platform_data;u32 scgd, cdf;u32 round, ick;u32 scl; +u32 cdf_width; +u32 flags = pdata ? pdata->flags :0 ;if (!clkp) {dev_err (dev,"there is no peripheral_clk\n" );return -EIO ; } +switch (flags &I2C_RCAR_FLAGS_ICCCR_MASK ) { +default : +case I2C_RCAR_FLAGS_ICCCR_IS_2BIT : + cdf_width =2 ; +break ; +case I2C_RCAR_FLAGS_ICCCR_IS_3BIT : + cdf_width =3 ; +break ; + } +/* * calculate SCL clock * see
@@ -245,7 +258,7 @@ static int rcar_i2c_clock_calculate(struct rcar_i2c_priv *priv,* clkp : peripheral_clk * F[] : integer up-valuation */ -for (cdf =0 ; cdf <4 ; cdf++) { +for (cdf =0 ; cdf < (1 << cdf_width); cdf++) { ick =clk_get_rate (clkp) / (1 + cdf);if (ick <20000000 ) goto ick_find;
@@ -287,7 +300,7 @@ scgd_find:/* * keep icccr value */ - priv->icccr = (scgd <<2 | cdf); + priv->icccr = (scgd << (cdf_width) | cdf);return 0 ; }
include/linux/i2c/i2c-rcar.h +4 -0
@@ -5,6 +5,10 @@struct i2c_rcar_platform_data {u32 bus_speed; +u32 flags; +#define I2C_RCAR_FLAGS_ICCCR_MASK (0xF << 0) +#define I2C_RCAR_FLAGS_ICCCR_IS_2BIT (0 << 0)/* default */ +#define I2C_RCAR_FLAGS_ICCCR_IS_3BIT (1 << 0) };#endif /* __I2C_R_CAR_H__ */
Signature · 1 line
1.8.1.4
Hello.
Quoted 3 lines · Ulrich Hecht
From: Nguyen Viet Dung <[email protected]>
This patch modify calculate for clock in I2C driver.
Maybe "modifies clock calculation" instead?
Quoted 10 lines
Signed-off-by Nguyen Viet Dung <[email protected]>--- drivers/i2c/busses/i2c-rcar.c | 17 +++++++++++++++-- include/linux/i2c/i2c-rcar.h | 4 ++++ 2 files changed, 19 insertions(+), 2 deletions(-)drivers/i2c/busses/i2c-rcar.c +0
-0
[...]
drivers/i2c/busses/i2c-rcar.c scgd_find: · line 303
Quoted 6 lines
drivers/i2c/busses/i2c-rcar.c +1
-1@@ -287,7 +300,7 @@ scgd_find:/* * keep icccr value */ - priv->icccr = (scgd <<2 | cdf); + priv->icccr = (scgd << (cdf_width) | cdf);
Parens not needed here at all (if only around <<).
WBR, Sergei
Hello,
Thank you for the patch.
Quoted 66 lines · On Friday 30 August 2013 14:37:38 Ulrich Hecht wrote:
From: Nguyen Viet Dung <[email protected]>
This patch modify calculate for clock in I2C driver.
Signed-off-by Nguyen Viet Dung <[email protected]>--- drivers/i2c/busses/i2c-rcar.c | 17 +++++++++++++++-- include/linux/i2c/i2c-rcar.h | 4 ++++ 2 files changed, 19 insertions(+), 2 deletions(-)drivers/i2c/busses/i2c-rcar.c +15
-2@@ -221,15 +221,28 @@ static int rcar_i2c_clock_calculate(struct rcar_i2c_priv *priv, struct device *dev) { struct clk *clkp = clk_get(NULL, "peripheral_clk"); +struct i2c_rcar_platform_data *pdata = dev->platform_data;u32 scgd, cdf;u32 round, ick;u32 scl; +u32 cdf_width; +u32 flags = pdata ? pdata->flags :0 ;if (!clkp) {dev_err (dev,"there is no peripheral_clk\n" );return -EIO ; } +switch (flags &I2C_RCAR_FLAGS_ICCCR_MASK ) { +default : +case I2C_RCAR_FLAGS_ICCCR_IS_2BIT : + cdf_width =2 ; +break ; +case I2C_RCAR_FLAGS_ICCCR_IS_3BIT : + cdf_width =3 ; +break ; + } +/* * calculate SCL clock * see @@ -245,7 +258,7 @@ static int rcar_i2c_clock_calculate(struct rcar_i2c_priv*priv, * clkp : peripheral_clk * F[] : integer up-valuation */ -for (cdf =0 ; cdf <4 ; cdf++) { +for (cdf =0 ; cdf < (1 << cdf_width); cdf++) { ick =clk_get_rate (clkp) / (1 + cdf);if (ick <20000000 ) goto ick_find;@@ -287,7 +300,7 @@ scgd_find:/* * keep icccr value */ - priv->icccr = (scgd <<2 | cdf); + priv->icccr = (scgd << (cdf_width) | cdf);return 0 ; }include/linux/i2c/i2c-rcar.h +0
-0
include/linux/i2c/i2c-rcar.h line 11
Quoted 7 lines
include/linux/i2c/i2c-rcar.h +4
-0@@ -5,6 +5,10 @@struct i2c_rcar_platform_data {u32 bus_speed; +u32 flags; +#define I2C_RCAR_FLAGS_ICCCR_MASK (0xF << 0) +#define I2C_RCAR_FLAGS_ICCCR_IS_2BIT (0 << 0)/* default */ +#define I2C_RCAR_FLAGS_ICCCR_IS_3BIT (1 << 0)
That looks like an IP core property to me, not a platform property. Shouldn't it be added to a platform_device_id table in the driver instead of being passed through platform data ?
Quoted 3 lines
include/linux/i2c/i2c-rcar.h +0
-0};#endif /* __I2C_R_CAR_H__ */
Signature · 3 lines
Regards, Laurent Pinchart
Quoted 5 lines · Laurent Pinchart
Quoted 4 lines · On Friday 30 August 2013 14:37:38 Ulrich Hecht wrote:
include/linux/i2c/i2c-rcar.h +0
-0@@ -5,6 +5,10 @@
Quoted 10 lines
include/linux/i2c/i2c-rcar.h line 11
Quoted 6 lines
include/linux/i2c/i2c-rcar.h +4
-0struct i2c_rcar_platform_data {u32 bus_speed; +u32 flags; +#define I2C_RCAR_FLAGS_ICCCR_MASK (0xF << 0) +#define I2C_RCAR_FLAGS_ICCCR_IS_2BIT (0 << 0)/* default */ +#define I2C_RCAR_FLAGS_ICCCR_IS_3BIT (1 << 0)That looks like an IP core property to me, not a platform property. Shouldn't it be added to a
platform_device_idtable in the driver instead of being passed through platform data ?
Dung has already posted a new version of this patch that solves this differently, but I haven't had time to integrate it yet:
http://www.spinics.net/lists/kernel/msg1595839.html
CU
Uli
Quoted 3 lines · Ulrich Hecht
From: Nguyen Viet Dung <[email protected]>
This patch modify calculate for clock in I2C driver.
Hi,
could we have a slightly clearer subject for this patch.
Quoted 81 lines
Signed-off-by Nguyen Viet Dung <[email protected]>--- drivers/i2c/busses/i2c-rcar.c | 17 +++++++++++++++-- include/linux/i2c/i2c-rcar.h | 4 ++++ 2 files changed, 19 insertions(+), 2 deletions(-)drivers/i2c/busses/i2c-rcar.c +15
-2@@ -221,15 +221,28 @@ static int rcar_i2c_clock_calculate(struct rcar_i2c_priv *priv, struct device *dev) {struct clk *clkp =clk_get (NULL ,"peripheral_clk" ); +struct i2c_rcar_platform_data *pdata = dev->platform_data;u32 scgd, cdf;u32 round, ick;u32 scl; +u32 cdf_width; +u32 flags = pdata ? pdata->flags :0 ;if (!clkp) {dev_err (dev,"there is no peripheral_clk\n" );return -EIO ; } +switch (flags &I2C_RCAR_FLAGS_ICCCR_MASK ) { +default : +case I2C_RCAR_FLAGS_ICCCR_IS_2BIT : + cdf_width =2 ; +break ; +case I2C_RCAR_FLAGS_ICCCR_IS_3BIT : + cdf_width =3 ; +break ; + } +/* * calculate SCL clock * see @@ -245,7 +258,7 @@ static int rcar_i2c_clock_calculate(struct rcar_i2c_priv *priv,* clkp : peripheral_clk * F[] : integer up-valuation */ -for (cdf =0 ; cdf <4 ; cdf++) { +for (cdf =0 ; cdf < (1 << cdf_width); cdf++) { ick =clk_get_rate (clkp) / (1 + cdf);if (ick <20000000 ) goto ick_find;@@ -287,7 +300,7 @@ scgd_find:/* * keep icccr value */ - priv->icccr = (scgd <<2 | cdf); + priv->icccr = (scgd << (cdf_width) | cdf);return 0 ; }include/linux/i2c/i2c-rcar.h +4
-0@@ -5,6 +5,10 @@struct i2c_rcar_platform_data {u32 bus_speed; +u32 flags; +#define I2C_RCAR_FLAGS_ICCCR_MASK (0xF << 0) +#define I2C_RCAR_FLAGS_ICCCR_IS_2BIT (0 << 0)/* default */ +#define I2C_RCAR_FLAGS_ICCCR_IS_3BIT (1 << 0) };#endif /* __I2C_R_CAR_H__ */ Signature · 6 lines
1.8.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html