I2C: driver updates
Subsystems (6)
v2 cover I2C: driver updates
The series attempts to do the following
- The reset should not be done in the driver have support for the same.
- Remove the sysc register access in the driver.
- Restore the context only if the context is lost.
version 2
- Fix the indentation.
- Restore in the error path is not needed as we are doing a init.
Tested on sdp4430 and on omap3430
Shubhrajyoti D (5):
OMAP: I2C: Add a device reset field to platform data
OMAP: I2C: Reset support
OMAP: I2C: Remove the reset in the init path
OMAP: I2C: Remove the SYSC register definition
OMAP: I2C: Restore only if context is lost
arch/arm/plat-omap/i2c.c | 17 +++++++ drivers/i2c/busses/i2c-omap.c | 101 ++++++++++++++++------------------------- include/linux/i2c-omap.h | 1 + 3 files changed, 57 insertions(+), 62 deletions(-)
PATCH v2 1/5 OMAP: I2C: Add a device reset field to platform data
Under some conditions the driver may want to do a reset of the device. Adding a reset field to the platform data.
--- include/linux/i2c-omap.h | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
include/linux/i2c-omap.h +1 -0
@@ -38,6 +38,7 @@ struct omap_i2c_bus_platform_data {int (*device_enable) (struct platform_device *pdev);int (*device_shutdown) (struct platform_device *pdev);int (*device_idle) (struct platform_device *pdev); + int (*device_reset) (struct device *dev); };#endif
Signature · 1 line
1.7.1
PATCH v2 1/5 OMAP: I2C: Add a device reset field to platform data
Shubro,
Quoted 14 lines · Shubhrajyoti D
Under some conditions the driver may want to do a reset of the device. Adding a reset field to the platform data.
Signed-off-by Shubhrajyoti D<[email protected]>--- include/linux/i2c-omap.h | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)include/linux/i2c-omap.h +0
-0
include/linux/i2c-omap.h struct omap_i2c_bus_platform_data { · line 41
Quoted 4 lines
include/linux/i2c-omap.h +1
-0@@ -38,6 +38,7 @@ struct omap_i2c_bus_platform_data {int (*device_enable) (struct platform_device *pdev);int (*device_shutdown) (struct platform_device *pdev);int (*device_idle) (struct platform_device *pdev); +int (*device_reset) (struct device *dev);
Any reason you haven't clubbed this with the omap i2c reset implementation patch ?
Since i2c-omap.h isn't a generic header file and specific to omap i2c drive, you could combine 1/5 and 2/5
PATCH v2 2/5 OMAP: I2C: Reset support
In reply to Shubhrajyoti DUnder some error conditions the i2c driver may do a reset adding support in the platform.
--- arch/arm/plat-omap/i2c.c | 17 +++++++++++++++++ 1 files changed, 17 insertions(+), 0 deletions(-)
arch/arm/plat-omap/i2c.c +17 -0
@@ -146,6 +146,22 @@ static struct omap_device_pm_latency omap_i2c_latency[] = { .flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST, }, }; +/** +* omap2_i2c_reset - reset the omap i2c module. +* @dev: struct device* +*/ + +static int omap2_i2c_reset (struct device *dev) +{ +int r =0 ; +struct platform_device *pdev =to_platform_device (dev); +struct omap_device *odev =to_omap_device (pdev); +struct omap_hwmod *oh; + + oh = odev->hwmods[0 ]; + r =omap_hwmod_reset (oh); +return r; +}static inline int omap2_i2c_add_bus (int bus_id) {
@@ -187,6 +203,7 @@ static inline int omap2_i2c_add_bus(int bus_id)*/ if (cpu_is_omap34xx ()) pdata->set_mpu_wkup_lat = omap_pm_set_max_mpu_wakeup_lat_compat; + pdata->device_reset = omap2_i2c_reset; od =omap_device_build (name, bus_id, oh, pdata,sizeof (struct omap_i2c_bus_platform_data ), omap_i2c_latency,ARRAY_SIZE (omap_i2c_latency),0 );
Signature · 1 line
1.7.1
PATCH v2 2/5 OMAP: I2C: Reset support
Quoted 5 lines · Shubhrajyoti D
Under some error conditions the i2c driver may do a reset adding support in the platform.
Signed-off-by Shubhrajyoti D<[email protected]>---
As commented on 1/5, this one should be folded with 1/5 unless and until you have some valid reason.
Regards
Santosh
PATCH v2 2/5 OMAP: I2C: Reset support
Quoted 8 lines · Santosh Shilimkar
Quoted 5 lines · Shubhrajyoti D
Under some error conditions the i2c driver may do a reset adding support in the platform.
Signed-off-by Shubhrajyoti D<[email protected]>---
As commented on 1/5, this one should be folded with 1/5 unless and until you have some valid reason.
Thanks for your review.
Will combine the patches and send.
Quoted 3 lines
Regards
Santosh
PATCH v2 3/5 OMAP: I2C: Remove the reset in the init path
In reply to Shubhrajyoti DThe reset in the driver at init is not needed
anymore as the hwmod framework takes care of
reseting it.
--- drivers/i2c/busses/i2c-omap.c | 73 ++++++++++++---------------------------- 1 files changed, 22 insertions(+), 51 deletions(-)
drivers/i2c/busses/i2c-omap.c +22 -51
@@ -155,9 +155,6 @@ enum {#define OMAP_I2C_SYSTEST_SDA_O (1 << 0)/* SDA line drive out */ #endif -/* OCP_SYSSTATUS bit definitions */ -#define SYSS_RESETDONE_MASK (1 << 0) -/* OCP_SYSCONFIG bit definitions */ #define SYSC_CLOCKACTIVITY_MASK (0x3 << 8)#define SYSC_SIDLEMODE_MASK (0x3 << 3)
@@ -182,6 +179,7 @@ struct omap_i2c_dev {u32 latency;/* maximum mpu wkup latency */ void (*set_mpu_wkup_lat)(struct device *dev,long latency); +int (*device_reset)(struct device *dev);u32 speed;/* Speed of bus in Khz */ u16 cmd_err;u8 *buf;
@@ -332,7 +330,6 @@ static int omap_i2c_init(struct omap_i2c_dev *dev)u16 psc =0 , scll =0 , sclh =0 , buf =0 ;u16 fsscll =0 , fssclh =0 , hsscll =0 , hssclh =0 ;unsigned long fclk_rate =12000000 ; -unsigned long timeout;unsigned long internal_clk =0 ;struct clk *fclk;struct platform_device *pdev;
@@ -341,53 +338,16 @@ static int omap_i2c_init(struct omap_i2c_dev *dev) pdev =to_platform_device (dev->dev); pdata = pdev->dev.platform_data; -if (dev->rev >=OMAP_I2C_OMAP1_REV_2 ) { -/* Disable I2C controller before soft reset */ -omap_i2c_write_reg (dev,OMAP_I2C_CON_REG , -omap_i2c_read_reg (dev,OMAP_I2C_CON_REG ) & - ~(OMAP_I2C_CON_EN )); - -omap_i2c_write_reg (dev,OMAP_I2C_SYSC_REG ,SYSC_SOFTRESET_MASK ); -/* For some reason we need to set the EN bit before the -* reset done bit gets set. */ - timeout = jiffies +OMAP_I2C_TIMEOUT ; -omap_i2c_write_reg (dev,OMAP_I2C_CON_REG ,OMAP_I2C_CON_EN ); -while (!(omap_i2c_read_reg (dev,OMAP_I2C_SYSS_REG ) & -SYSS_RESETDONE_MASK )) { -if (time_after (jiffies, timeout)) { -dev_warn (dev->dev,"timeout waiting " -"for controller reset\n" ); -return -ETIMEDOUT ; - } -msleep (1 ); - } - -/* SYSC register is cleared by the reset; rewrite it */ -if (dev->rev ==OMAP_I2C_REV_ON_2430 ) { - -omap_i2c_write_reg (dev,OMAP_I2C_SYSC_REG , -SYSC_AUTOIDLE_MASK ); - - }else if (dev->rev >=OMAP_I2C_REV_ON_3430 ) { - dev->syscstate =SYSC_AUTOIDLE_MASK ; - dev->syscstate |=SYSC_ENAWAKEUP_MASK ; - dev->syscstate |= (SYSC_IDLEMODE_SMART << -__ffs (SYSC_SIDLEMODE_MASK )); - dev->syscstate |= (SYSC_CLOCKACTIVITY_FCLK << -__ffs (SYSC_CLOCKACTIVITY_MASK )); - -omap_i2c_write_reg (dev,OMAP_I2C_SYSC_REG , - dev->syscstate); -/* -* Enabling all wakup sources to stop I2C freezing on -* WFI instruction. -* REVISIT: Some wkup sources might not be needed. -*/ - dev->westate =OMAP_I2C_WE_ALL ; -if (dev->rev <OMAP_I2C_REV_ON_3530_4430 ) -omap_i2c_write_reg (dev,OMAP_I2C_WE_REG , - dev->westate); - } +if (dev->rev >=OMAP_I2C_REV_ON_3430 ) { +/* +* Enabling all wakup sources to stop I2C freezing on +* WFI instruction. +* REVISIT: Some wkup sources might not be needed. +*/ + dev->westate =OMAP_I2C_WE_ALL ; +if (dev->rev <OMAP_I2C_REV_ON_3530_4430 ) +omap_i2c_write_reg (dev,OMAP_I2C_WE_REG , + dev->westate); }omap_i2c_write_reg (dev,OMAP_I2C_CON_REG ,0 );
@@ -612,6 +572,11 @@ static int omap_i2c_xfer_msg(struct i2c_adapter *adap,return r;if (r ==0 ) {dev_err (dev->dev,"controller timed out\n" ); +if (dev->device_reset !=NULL ) { + r = dev->device_reset (dev->dev); +if (r <0 ) +dev_err (dev->dev,"reset failed\n" ); + }omap_i2c_init (dev);return -ETIMEDOUT ; }
@@ -622,6 +587,11 @@ static int omap_i2c_xfer_msg(struct i2c_adapter *adap,/* We have an error */ if (dev->cmd_err & (OMAP_I2C_STAT_AL |OMAP_I2C_STAT_ROVR |OMAP_I2C_STAT_XUDF )) { +if (dev->device_reset !=NULL ) { + r = dev->device_reset (dev->dev); +if (r <0 ) +dev_err (dev->dev,"reset failed\n" ); + }omap_i2c_init (dev);return -EIO ; }
@@ -1024,6 +994,7 @@ omap_i2c_probe(struct platform_device *pdev)if (pdata !=NULL ) { speed = pdata->clkrate; dev->set_mpu_wkup_lat = pdata->set_mpu_wkup_lat; + dev->device_reset = pdata->device_reset; }else { speed =100 ;/* Default speed */ dev->set_mpu_wkup_lat =NULL ;
Signature · 1 line
1.7.1
PATCH v2 3/5 OMAP: I2C: Remove the reset in the init path
Quoted 8 lines · Shubhrajyoti D
The reset in the driver at init is not needed
anymore as the hwmod framework takes care of
reseting it.Signed-off-by Shubhrajyoti D<[email protected]>--- drivers/i2c/busses/i2c-omap.c | 73 ++++++++++++---------------------------- 1 files changed, 22 insertions(+), 51 deletions(-)
Excellent cleanup. Some minor coments
Quoted 73 lines
drivers/i2c/busses/i2c-omap.c +1
-42@@ -155,9 +155,6 @@ enum {#define OMAP_I2C_SYSTEST_SDA_O (1<< 0)/* SDA line drive out */ #endif -/* OCP_SYSSTATUS bit definitions */ -#define SYSS_RESETDONE_MASK (1<< 0) -/* OCP_SYSCONFIG bit definitions */ #define SYSC_CLOCKACTIVITY_MASK (0x3<< 8)#define SYSC_SIDLEMODE_MASK (0x3<< 3)@@ -182,6 +179,7 @@ struct omap_i2c_dev {u32 latency;/* maximum mpu wkup latency */ void (*set_mpu_wkup_lat)(struct device *dev,long latency); +int (*device_reset)(struct device *dev);u32 speed;/* Speed of bus in Khz */ u16 cmd_err;u8 *buf;@@ -332,7 +330,6 @@ static int omap_i2c_init(struct omap_i2c_dev *dev)u16 psc =0 , scll =0 , sclh =0 , buf =0 ;u16 fsscll =0 , fssclh =0 , hsscll =0 , hssclh =0 ;unsigned long fclk_rate =12000000 ; -unsigned long timeout;unsigned long internal_clk =0 ;struct clk *fclk;struct platform_device *pdev;@@ -341,53 +338,16 @@ static int omap_i2c_init(struct omap_i2c_dev *dev) pdev =to_platform_device (dev->dev); pdata = pdev->dev.platform_data; -if (dev->rev>=OMAP_I2C_OMAP1_REV_2 ) { -/* Disable I2C controller before soft reset */ -omap_i2c_write_reg (dev,OMAP_I2C_CON_REG , -omap_i2c_read_reg (dev,OMAP_I2C_CON_REG )& - ~(OMAP_I2C_CON_EN )); - -omap_i2c_write_reg (dev,OMAP_I2C_SYSC_REG ,SYSC_SOFTRESET_MASK ); -/* For some reason we need to set the EN bit before the -* reset done bit gets set. */ - timeout = jiffies +OMAP_I2C_TIMEOUT ; -omap_i2c_write_reg (dev,OMAP_I2C_CON_REG ,OMAP_I2C_CON_EN ); -while (!(omap_i2c_read_reg (dev,OMAP_I2C_SYSS_REG )& -SYSS_RESETDONE_MASK )) { -if (time_after (jiffies, timeout)) { -dev_warn (dev->dev,"timeout waiting " -"for controller reset\n" ); -return -ETIMEDOUT ; - } -msleep (1 ); - } - -/* SYSC register is cleared by the reset; rewrite it */ -if (dev->rev ==OMAP_I2C_REV_ON_2430 ) { - -omap_i2c_write_reg (dev,OMAP_I2C_SYSC_REG , -SYSC_AUTOIDLE_MASK ); - - }else if (dev->rev>=OMAP_I2C_REV_ON_3430 ) { - dev->syscstate =SYSC_AUTOIDLE_MASK ; - dev->syscstate |=SYSC_ENAWAKEUP_MASK ; - dev->syscstate |= (SYSC_IDLEMODE_SMART << -__ffs (SYSC_SIDLEMODE_MASK )); - dev->syscstate |= (SYSC_CLOCKACTIVITY_FCLK << -__ffs (SYSC_CLOCKACTIVITY_MASK )); - -omap_i2c_write_reg (dev,OMAP_I2C_SYSC_REG , - dev->syscstate); -/*
drivers/i2c/busses/i2c-omap.c static int omap_i2c_init(struct omap_i2c_dev *dev) · line 341
Quoted 10 lines
drivers/i2c/busses/i2c-omap.c +1
-9-* Enabling all wakup sources to stop I2C freezing on -* WFI instruction. -* REVISIT: Some wkup sources might not be needed. -*/ - dev->westate =OMAP_I2C_WE_ALL ; -if (dev->rev<OMAP_I2C_REV_ON_3530_4430 ) -omap_i2c_write_reg (dev,OMAP_I2C_WE_REG , - dev->westate); - } +if (dev->rev>=OMAP_I2C_REV_ON_3430 ) {
Space please if (dev->rev >= OMAP_I2C_REV_ON_3430) {
drivers/i2c/busses/i2c-omap.c static int omap_i2c_init(struct omap_i2c_dev *dev) · line 346
Quoted 5 lines
drivers/i2c/busses/i2c-omap.c +5
-0+/* +* Enabling all wakup sources to stop I2C freezing on +* WFI instruction. +* REVISIT: Some wkup sources might not be needed. +*/
Surely not related to your patch. But the 'REVISIT:' caught my attention. Is the comment still valid.
drivers/i2c/busses/i2c-omap.c static int omap_i2c_init(struct omap_i2c_dev *dev) · line 348
Quoted 2 lines
drivers/i2c/busses/i2c-omap.c +2
-0+ dev->westate =OMAP_I2C_WE_ALL ; +if (dev->rev<OMAP_I2C_REV_ON_3530_4430 )
Space if (dev->rev < OMAP_I2C_REV_ON_3530_4430)
drivers/i2c/busses/i2c-omap.c static int omap_i2c_xfer_msg(struct i2c_adapter *adap, · line 577
Quoted 12 lines
drivers/i2c/busses/i2c-omap.c +5
-0+omap_i2c_write_reg (dev,OMAP_I2C_WE_REG , + dev->westate); }omap_i2c_write_reg (dev,OMAP_I2C_CON_REG ,0 );@@ -612,6 +572,11 @@ static int omap_i2c_xfer_msg(struct i2c_adapter *adap,return r;if (r ==0 ) {dev_err (dev->dev,"controller timed out\n" ); +if (dev->device_reset !=NULL ) { + r = dev->device_reset (dev->dev); +if (r<0 )
ditto
drivers/i2c/busses/i2c-omap.c static int omap_i2c_xfer_msg(struct i2c_adapter *adap, · line 588
Quoted 8 lines
drivers/i2c/busses/i2c-omap.c +2
-0+dev_err (dev->dev,"reset failed\n" ); + }omap_i2c_init (dev);return -ETIMEDOUT ; }@@ -622,6 +587,11 @@ static int omap_i2c_xfer_msg(struct i2c_adapter *adap,/* We have an error */ if (dev->cmd_err& (OMAP_I2C_STAT_AL | OMAP_I2C_STAT_ROVR |
You can fix this one as well.
drivers/i2c/busses/i2c-omap.c static int omap_i2c_xfer_msg(struct i2c_adapter *adap,
Quoted 4 lines
drivers/i2c/busses/i2c-omap.c +3
-0OMAP_I2C_STAT_XUDF)) { +if (dev->device_reset !=NULL ) { + r = dev->device_reset (dev->dev); +if (r<0 )
here too.
drivers/i2c/busses/i2c-omap.c omap_i2c_probe(struct platform_device *pdev) · line 1000
Quoted 13 lines
drivers/i2c/busses/i2c-omap.c +3
-0+dev_err (dev->dev,"reset failed\n" ); + }omap_i2c_init (dev);return -EIO ; }@@ -1024,6 +994,7 @@ omap_i2c_probe(struct platform_device *pdev)if (pdata !=NULL ) { speed = pdata->clkrate; dev->set_mpu_wkup_lat = pdata->set_mpu_wkup_lat; + dev->device_reset = pdata->device_reset; }else { speed =100 ;/* Default speed */ dev->set_mpu_wkup_lat =NULL ;
Regards
Santosh
PATCH v2 3/5 OMAP: I2C: Remove the reset in the init path
On Thursday 21 July 2011 04:57 PM, Santosh Shilimkar wrote:
Thanks for your review.
Quoted 2 lines · Shubhrajyoti D
<snip>
Quoted 7 lines
drivers/i2c/busses/i2c-omap.c static int omap_i2c_init(struct omap_i2c_dev *dev) · line 346
Quoted 5 lines
drivers/i2c/busses/i2c-omap.c +5
-0+/* +* Enabling all wakup sources to stop I2C freezing on +* WFI instruction. +* REVISIT: Some wkup sources might not be needed. +*/ Surely not related to your patch. But the 'REVISIT:' caught my attention. Is the comment still valid.
Yes I will look and optimise the settings. Obviously all of them may not be needed.
Will get back on this.
Also I see that we are not writing it for " < OMAP_I2C_REV_ON_3530_4430" I will send a patch correcting the same.
Quoted 49 lines
Review
Quoted 3 lines
(quoted diff) +2
-0+ dev->westate = OMAP_I2C_WE_ALL; + if (dev->rev< OMAP_I2C_REV_ON_3530_4430)Space if (
dev->rev<OMAP_I2C_REV_ON_3530_4430)drivers/i2c/busses/i2c-omap.c static int omap_i2c_xfer_msg(struct i2c_adapter · line 578
Quoted 13 lines
drivers/i2c/busses/i2c-omap.c +5
-0+omap_i2c_write_reg (dev,OMAP_I2C_WE_REG , + dev->westate); }omap_i2c_write_reg (dev,OMAP_I2C_CON_REG ,0 );@@ -612,6 +572,11 @@ static int omap_i2c_xfer_msg(struct i2c_adapter *adap, return r;if (r ==0 ) {dev_err (dev->dev,"controller timed out\n" ); +if (dev->device_reset !=NULL ) { + r = dev->device_reset (dev->dev); +if (r<0 )ditto
Review static int omap_i2c_xfer_msg(struct i2c_adapter · line 589
Quoted 9 lines
drivers/i2c/busses/i2c-omap.c +2
-0+dev_err (dev->dev,"reset failed\n" ); + }omap_i2c_init (dev);return -ETIMEDOUT ;}(quoted diff) +0
-0@@ -622,6 +587,11 @@ static int omap_i2c_xfer_msg(struct i2c_adapter *adap, /* We have an error */ if (dev->cmd_err& (OMAP_I2C_STAT_AL | OMAP_I2C_STAT_ROVR |You can fix this one as well.
drivers/i2c/busses/i2c-omap.c static int omap_i2c_xfer_msg(struct i2c_adapter *adap,
Quoted 4 lines
drivers/i2c/busses/i2c-omap.c +3
-0OMAP_I2C_STAT_XUDF)) { +if (dev->device_reset !=NULL ) { + r = dev->device_reset (dev->dev); +if (r<0 )here too.
drivers/i2c/busses/i2c-omap.c omap_i2c_probe(struct platform_device *pdev) · line 1000
Quoted 13 lines
drivers/i2c/busses/i2c-omap.c +2
-0+dev_err (dev->dev,"reset failed\n" ); + }omap_i2c_init (dev);return -EIO ;}drivers/i2c/busses/i2c-omap.c +1
-0@@ -1024,6 +994,7 @@ omap_i2c_probe(struct platform_device *pdev)if (pdata !=NULL ) { speed = pdata->clkrate; dev->set_mpu_wkup_lat = pdata->set_mpu_wkup_lat; + dev->device_reset = pdata->device_reset; }else { speed =100 ;/* Default speed */ dev->set_mpu_wkup_lat =NULL ;Regards
Santosh
PATCH v2 4/5 OMAP: I2C: Remove the SYSC register definition
In reply to Shubhrajyoti DThe SYSC register should not accessed in the driver removing the define from the driver.
--- drivers/i2c/busses/i2c-omap.c | 4 ---- 1 files changed, 0 insertions(+), 4 deletions(-)
drivers/i2c/busses/i2c-omap.c +0 -4
@@ -63,7 +63,6 @@ enum {OMAP_I2C_BUF_REG ,OMAP_I2C_CNT_REG ,OMAP_I2C_DATA_REG , -OMAP_I2C_SYSC_REG ,OMAP_I2C_CON_REG ,OMAP_I2C_OA_REG , OMAP_I2C_SA_REG,
@@ -213,7 +212,6 @@ const static u8 reg_map_ip_v1[] = { [OMAP_I2C_BUF_REG] = 0x05, [OMAP_I2C_CNT_REG] = 0x06, [OMAP_I2C_DATA_REG] = 0x07, - [OMAP_I2C_SYSC_REG] = 0x08, [OMAP_I2C_CON_REG] = 0x09, [OMAP_I2C_OA_REG] = 0x0a, [OMAP_I2C_SA_REG] = 0x0b,
@@ -234,7 +232,6 @@ const static u8 reg_map_ip_v2[] = { [OMAP_I2C_BUF_REG] = 0x94, [OMAP_I2C_CNT_REG] = 0x98, [OMAP_I2C_DATA_REG] = 0x9c, - [OMAP_I2C_SYSC_REG] = 0x20, [OMAP_I2C_CON_REG] = 0xa4, [OMAP_I2C_OA_REG] = 0xa8, [OMAP_I2C_SA_REG] = 0xac,
@@ -281,7 +278,6 @@ static void omap_i2c_unidle(struct omap_i2c_dev *dev)omap_i2c_write_reg (dev,OMAP_I2C_SCLL_REG , dev->scllstate);omap_i2c_write_reg (dev,OMAP_I2C_SCLH_REG , dev->sclhstate);omap_i2c_write_reg (dev,OMAP_I2C_BUF_REG , dev->bufstate); -omap_i2c_write_reg (dev,OMAP_I2C_SYSC_REG , dev->syscstate);omap_i2c_write_reg (dev,OMAP_I2C_WE_REG , dev->westate);omap_i2c_write_reg (dev,OMAP_I2C_CON_REG ,OMAP_I2C_CON_EN ); }
Signature · 1 line
1.7.1
PATCH v2 4/5 OMAP: I2C: Remove the SYSC register definition
Quoted 4 lines · Shubhrajyoti D
The SYSC register should not accessed in the driver removing the define from the driver.
Signed-off-by Shubhrajyoti D<[email protected]>
Looks good.
PATCH v2 5/5 OMAP: I2C: Restore only if context is lost
In reply to Shubhrajyoti DCurrently restore is done always.
Adding conditional restore. The restore is done only if the context is lost.
--- drivers/i2c/busses/i2c-omap.c | 24 +++++++++++++++++------- 1 files changed, 17 insertions(+), 7 deletions(-)
drivers/i2c/busses/i2c-omap.c +17 -7
@@ -40,6 +40,7 @@#include <linux/slab.h> #include <linux/i2c-omap.h> #include <linux/pm_runtime.h> +#include <plat/omap_device.h> /* I2C controller revisions */ #define OMAP_I2C_OMAP1_REV_2 0x20
@@ -200,6 +201,7 @@ struct omap_i2c_dev {u16 syscstate;u16 westate;u16 errata; +u32 dev_lost_count; };const static u8 reg_map_ip_v1[] = {
@@ -260,6 +262,17 @@ static inline u16 omap_i2c_read_reg(struct omap_i2c_dev *i2c_dev, int reg) (i2c_dev->regs[reg] << i2c_dev->reg_shift)); } +static void omap_i2c_restore (struct omap_i2c_dev *dev) +{ +omap_i2c_write_reg (dev,OMAP_I2C_CON_REG ,0 ); +omap_i2c_write_reg (dev,OMAP_I2C_PSC_REG , dev->pscstate); +omap_i2c_write_reg (dev,OMAP_I2C_SCLL_REG , dev->scllstate); +omap_i2c_write_reg (dev,OMAP_I2C_SCLH_REG , dev->sclhstate); +omap_i2c_write_reg (dev,OMAP_I2C_BUF_REG , dev->bufstate); +omap_i2c_write_reg (dev,OMAP_I2C_WE_REG , dev->westate); +omap_i2c_write_reg (dev,OMAP_I2C_CON_REG ,OMAP_I2C_CON_EN ); +} +static void omap_i2c_unidle (struct omap_i2c_dev *dev) {struct platform_device *pdev;
@@ -273,13 +286,9 @@ static void omap_i2c_unidle(struct omap_i2c_dev *dev)pm_runtime_get_sync (&pdev->dev);if (pdata->flags &OMAP_I2C_FLAG_RESET_REGS_POSTIDLE ) { -omap_i2c_write_reg (dev,OMAP_I2C_CON_REG ,0 ); -omap_i2c_write_reg (dev,OMAP_I2C_PSC_REG , dev->pscstate); -omap_i2c_write_reg (dev,OMAP_I2C_SCLL_REG , dev->scllstate); -omap_i2c_write_reg (dev,OMAP_I2C_SCLH_REG , dev->sclhstate); -omap_i2c_write_reg (dev,OMAP_I2C_BUF_REG , dev->bufstate); -omap_i2c_write_reg (dev,OMAP_I2C_WE_REG , dev->westate); -omap_i2c_write_reg (dev,OMAP_I2C_CON_REG ,OMAP_I2C_CON_EN ); +u32 loss_cnt =omap_device_get_context_loss_count (pdev); +if (dev->dev_lost_count != loss_cnt) +omap_i2c_restore (dev); } dev->idle =0 ;
@@ -318,6 +327,7 @@ static void omap_i2c_idle(struct omap_i2c_dev *dev) } dev->idle =1 ; + dev->dev_lost_count =omap_device_get_context_loss_count (pdev);pm_runtime_put_sync (&pdev->dev); }
Signature · 1 line
1.7.1
PATCH v2 5/5 OMAP: I2C: Restore only if context is lost
Quoted 3 lines · Shubhrajyoti D
Currently restore is done always.
Adding conditional restore. The restore is done only if the context is lost.
Minor comment. You may want to say 'i2c register restore' instead of just 'restore'
Quoted 1 line
Signed-off-by Shubhrajyoti D<[email protected]>
o.w