OMAP2+: PM: omap_device: API for set/get MSTANDBY mode
Subsystems (4)
PATCH v2 1/1 OMAP2+: PM: omap_device: API for set/get MSTANDBY mode
Certain errata's in OMAP2+ processors will require disabling master standby mode before completing on going operation. Without this, the results will be unpredictable.
Since current implementation of PM run time framework does not support changing sysconfig settings during middle of the on going operation, these API's will support the same.
These API's should be used by device drivers only incase of erratum applicable to their modules if there is no other methods to resolve.
This API is required for multiple DMA errata's which require putting DMA controller in no mstandby mode before stopping dma.
The applicable errata's:
1. Errata ID: i557(Applicable for omap36xx all ES versions) The channel hangs when the Pause bit (DMA4_CDPi [7] ) is cleared through config port while in Standby.
2. Errata ID: i541(all omap2plus except omap4)
sDMA FIFO draining does not finish
3. Errata ID: i88(only omap3430 ES1.0)
Special programming model needed to disable DMA before end of block
4. OMAP3430 ES1.0(Errata ID:i88) will require DMA to be put in no mstandby mode before disabling the channel after completing the data transfer operation.
---
Changes from v1 to v2:
- updated patch description with relevant errata id's.
- API name changed to master_standbymode from master_idlemode
arch/arm/mach-omap2/omap_hwmod.c | 83 +++++++++++++++++++++++++ arch/arm/plat-omap/include/plat/omap_device.h | 3 +- arch/arm/plat-omap/include/plat/omap_hwmod.h | 3 + arch/arm/plat-omap/omap_device.c | 36 +++++++++++ 4 files changed, 124 insertions(+), 1 deletions(-)
arch/arm/mach-omap2/omap_hwmod.c +83 -0
@@ -250,6 +250,35 @@ static int _set_master_standbymode(struct omap_hwmod *oh, u8 standbymode, }/** +* _get_master_standbymode: get the OCP_SYSCONFIG MIDLEMODE field in @midlemode +* @oh: struct omap_hwmod * +* @standbymode: pointer to get mstandby mode bits(shifted to bit 0) +* +* Get the master standby mode bits in @midlemode for the @oh hwmod. +* Does not fetch the data from the hardware instead returns value +* from sysc_cache. Returns -EINVAL upon error or 0 upon success. +*/ +static int _get_master_standbymode (struct omap_hwmod *oh,u32 *midlemode) +{ +u32 mstandby_mask; +u8 mstandby_shift; + +if (!oh->class->sysc || + !(oh->class->sysc->sysc_flags &SYSC_HAS_MIDLEMODE )) +return -EINVAL ; + +if (!oh->class->sysc->sysc_fields) { +WARN (1 ,"omap_hwmod: %s: offset struct for sysconfig not" +" provided in class\n" , oh->name); +return -EINVAL ; + } + + *midlemode = ((oh->_sysc_cache) & mstandby_mask) >> mstandby_shift; + +return 0 ; +} + +/** * _set_slave_idlemode: set the OCP_SYSCONFIG SIDLEMODE field in @v * @oh: struct omap_hwmod * * @idlemode: SIDLEMODE field bits
@@ -1427,6 +1456,60 @@ int omap_hwmod_set_slave_idlemode(struct omap_hwmod *oh, u8 idlemode) }/** +* omap_hwmod_set_master_standbymode - set the hwmod's OCP master idlemode +* @oh: struct omap_hwmod * +* @midlemode: MIDLEMODE field bits (shifted to bit 0) +* +* Sets the IP block's OCP master idlemode in hardware, and updates our +* local copy. Intended to be used by drivers that have some erratum +* that requires direct manipulation of the MIDLEMODE bits. Returns +* -EINVAL if @oh is null, or passes along the return value from +* _set_master_standbymode(). +* +* Any users of this function should be scrutinized carefully. +*/ +int omap_hwmod_set_master_standbymode (struct omap_hwmod *oh,u32 midlemode) +{ +u32 v; +int retval =0 ; + +if (!oh) +return -EINVAL ; + + v = oh->_sysc_cache; + + retval =_set_master_standbymode (oh, midlemode, &v); +if (!retval) +_write_sysconfig (v, oh); + +return retval; +} + +/** +* omap_hwmod_get_master_idlemode - set the hwmod's OCP master idlemode +* @oh: struct omap_hwmod * +* @midlemode: pointer to get MIDLEMODE field bits (shifted to bit 0) +* +* Gets the IP block's OCP master idlemode from our local copy. Intended +* to be used by drivers that have some erratum that requires direct +* manipulation of the MIDLEMODE bits. Returns -EINVAL if @oh is null, +* or passes along the return value from _get_master_standbymode(). +* +* Any users of this function should be scrutinized carefully. +*/ +int omap_hwmod_get_master_standbymode (struct omap_hwmod *oh,u32 *midlemode) +{ +int retval =0 ; + +if (!oh) +return -EINVAL ; + + retval =_get_master_standbymode (oh, midlemode); + +return retval; +} + +/** * omap_hwmod_register - register a struct omap_hwmod * @oh: struct omap_hwmod * *
arch/arm/plat-omap/include/plat/omap_device.h +2 -1
@@ -109,13 +109,14 @@ int omap_device_align_pm_lat(struct platform_device *pdev,struct powerdomain *omap_device_get_pwrdm (struct omap_device *od);/* Other */ -int omap_device_idle_hwmods (struct omap_device *od);int omap_device_enable_hwmods (struct omap_device *od);int omap_device_disable_clocks (struct omap_device *od);int omap_device_enable_clocks (struct omap_device *od); +int omap_device_mstandby (struct platform_device *pdev,u32 *midlemode, +bool set_mstandby);/* * Entries should be kept in latency order ascending
arch/arm/plat-omap/include/plat/omap_hwmod.h +3 -0
@@ -526,6 +526,9 @@ int omap_hwmod_disable_clocks(struct omap_hwmod *oh);int omap_hwmod_set_slave_idlemode (struct omap_hwmod *oh,u8 idlemode); +int omap_hwmod_set_master_standbymode (struct omap_hwmod *oh,u32 midlemode); +int omap_hwmod_get_master_standbymode (struct omap_hwmod *oh,u32 *idlemode); +int omap_hwmod_reset (struct omap_hwmod *oh);void omap_hwmod_ocp_barrier (struct omap_hwmod *oh);
arch/arm/plat-omap/omap_device.c +36 -0
@@ -584,6 +584,42 @@ int omap_device_idle(struct platform_device *pdev) }/** +* omap_device_mstandby - set/get mstandby mode an omap_device +* @od: struct omap_device * to idle +* @midlemode: MIDLEMODE field bits (shifted to bit 0) +* @set_mstandby: flag for mstandby get/set +* +* Sets/Gets the IP block's OCP master standby in hardware. Intended +* to be used by drivers that have some erratum that requires direct +* manipulation of the MSTANDBYMODE bits. Returns -EINVAL if the +* omap_device is not currently enabled or passes along the return value +* of omap_hwmod_set_master_standbymode()/omap_hwmod_get_master_standbymode(). +*/ +int omap_device_mstandby (struct platform_device *pdev,u32 *midlemode, +bool set_mstandby) +{ +int ret =0 , i; +struct omap_device *od; +struct omap_hwmod *oh; + + od =_find_by_pdev (pdev); +if (od->_state !=OMAP_DEVICE_STATE_ENABLED ) { +WARN (1 ,"omap_device: %s.%d: %s() called from invalid state %d\n" , + od->pdev.name, od->pdev.id, __func__, od->_state); +return -EINVAL ; + } + + oh = *od->hwmods; +for (i =0 ; i < od->hwmods_cnt; i++) { +if (set_mstandby) + ret =omap_hwmod_set_master_standbymode (oh, *midlemode); +else + ret =omap_hwmod_get_master_standbymode (oh, midlemode); + } +return ret; +} + +/** * omap_device_shutdown - shut down an omap_device * @od: struct omap_device * to shut down *
Signature · 1 line
1.7.1
Paul Walmsley
maintainerHello Manju,
Quoted 23 lines · Manjunath Kondaiah
Certain errata's in OMAP2+ processors will require disabling master standby mode before completing on going operation. Without this, the results will be unpredictable.
Since current implementation of PM run time framework does not support changing sysconfig settings during middle of the on going operation, these API's will support the same.
These API's should be used by device drivers only incase of erratum applicable to their modules if there is no other methods to resolve.
This API is required for multiple DMA errata's which require putting DMA controller in no mstandby mode before stopping dma.
The applicable errata's:
1. Errata ID: i557(Applicable for omap36xx all ES versions) The channel hangs when the Pause bit (DMA4_CDPi[7] ) is cleared through config port while in Standby.2. Errata ID: i541(all omap2plus except omap4)
sDMA FIFO draining does not finish
Quoted 7 lines
3. Errata ID: i88(only omap3430 ES1.0)
Special programming model needed to disable DMA before end of block4. OMAP3430 ES1.0(Errata ID:i88) will require DMA to be put in no mstandby mode before disabling the channel after completing the data transfer operation.
Nice patch description. A few comments:
1. Is it the case that the MSTANDBYMODE only needs to switch between (smart standby/force standby) and no standby? Or will it need to switch between all three?
2. Rather than just using a single omap_device_mstandby() function call, I'd rather see something like omap_device_require_no_standby() and omap_device_release_no_standby(). omap_device_require_no_standby() would force the initiator port into no-standby. omap_device_release_no_standby() would return the initiator port MSTANDBYMODE to whatever the state should be (this depends on whether HWMOD_SWSUP_MSTDBY is set). I'd rather not have the drivers manage the contents of the MSTANDBYMODE bits directly. Then you should be able to drop _get_master_standbymode() and omap_hwmod_get_master_idlemode() also. Can you please make these changes?
3. I have a few other comments below:
Quoted 71 lines
Signed-off-by G, Manjunath Kondaiah <[email protected]>Cc Kevin Hilman <[email protected]>Cc Paul Walmsley <[email protected]>Cc Anand Gadiyar <[email protected]>Cc Benoit Cousson <[email protected]>---
Changes from v1 to v2:
- updated patch description with relevant errata id's.
- API name changed tomaster_standbymodefrommaster_idlemodearch/arm/mach-omap2/omap_hwmod.c | 83 +++++++++++++++++++++++++ arch/arm/plat-omap/include/plat/omap_device.h | 3 +- arch/arm/plat-omap/include/plat/omap_hwmod.h | 3 + arch/arm/plat-omap/omap_device.c | 36 +++++++++++ 4 files changed, 124 insertions(+), 1 deletions(-)arch/arm/mach-omap2/omap_hwmod.c +39
-0@@ -250,6 +250,35 @@ static int _set_master_standbymode(struct omap_hwmod *oh, u8 standbymode, }/** +* _get_master_standbymode: get the OCP_SYSCONFIG MIDLEMODE field in @midlemode +* @oh: struct omap_hwmod * +* @standbymode: pointer to get mstandby mode bits(shifted to bit 0) +* +* Get the master standby mode bits in @midlemode for the @oh hwmod. +* Does not fetch the data from the hardware instead returns value +* from sysc_cache. Returns -EINVAL upon error or 0 upon success. +*/ +static int _get_master_standbymode (struct omap_hwmod *oh,u32 *midlemode) +{ +u32 mstandby_mask; +u8 mstandby_shift; + +if (!oh->class->sysc || + !(oh->class->sysc->sysc_flags &SYSC_HAS_MIDLEMODE )) +return -EINVAL ; + +if (!oh->class->sysc->sysc_fields) { +WARN (1 ,"omap_hwmod: %s: offset struct for sysconfig not" +" provided in class\n" , oh->name); +return -EINVAL ; + } + + *midlemode = ((oh->_sysc_cache) & mstandby_mask) >> mstandby_shift; + +return 0 ; +} + +/** * _set_slave_idlemode: set the OCP_SYSCONFIG SIDLEMODE field in @v * @oh: struct omap_hwmod * * @idlemode: SIDLEMODE field bits @@ -1427,6 +1456,60 @@ int omap_hwmod_set_slave_idlemode(struct omap_hwmod *oh, u8 idlemode) }/** +* omap_hwmod_set_master_standbymode - set the hwmod's OCP master idlemode +* @oh: struct omap_hwmod * +* @midlemode: MIDLEMODE field bits (shifted to bit 0) +* +* Sets the IP block's OCP master idlemode in hardware, and updates our +* local copy. Intended to be used by drivers that have some erratum +* that requires direct manipulation of the MIDLEMODE bits. Returns +* -EINVAL if @oh is null, or passes along the return value from +* _set_master_standbymode(). +*
arch/arm/mach-omap2/omap_hwmod.c int omap_hwmod_set_slave_idlemode(struct omap_hwmod *oh, u8 idlemode) · line 1478
Quoted 10 lines
arch/arm/mach-omap2/omap_hwmod.c +10
-0+* Any users of this function should be scrutinized carefully. +*/ +int omap_hwmod_set_master_standbymode (struct omap_hwmod *oh,u32 midlemode) +{ +u32 v; +int retval =0 ; + +if (!oh) +return -EINVAL ; +
I guess this needs to take the hwmod's mutex.
arch/arm/mach-omap2/omap_hwmod.c int omap_hwmod_set_slave_idlemode(struct omap_hwmod *oh, u8 idlemode) · line 1483
Quoted 5 lines
arch/arm/mach-omap2/omap_hwmod.c +5
-0+ v = oh->_sysc_cache; + + retval =_set_master_standbymode (oh, midlemode, &v); +if (!retval) +_write_sysconfig (v, oh);
And release it here.
Quoted 116 lines
arch/arm/mach-omap2/omap_hwmod.c +29
-0+ +return retval; +} + +/** +* omap_hwmod_get_master_idlemode - set the hwmod's OCP master idlemode +* @oh: struct omap_hwmod * +* @midlemode: pointer to get MIDLEMODE field bits (shifted to bit 0) +* +* Gets the IP block's OCP master idlemode from our local copy. Intended +* to be used by drivers that have some erratum that requires direct +* manipulation of the MIDLEMODE bits. Returns -EINVAL if @oh is null, +* or passes along the return value from _get_master_standbymode(). +* +* Any users of this function should be scrutinized carefully. +*/ +int omap_hwmod_get_master_standbymode (struct omap_hwmod *oh,u32 *midlemode) +{ +int retval =0 ; + +if (!oh) +return -EINVAL ; + + retval =_get_master_standbymode (oh, midlemode); + +return retval; +} + +/** * omap_hwmod_register - register a struct omap_hwmod * @oh: struct omap_hwmod * * arch/arm/plat-omap/include/plat/omap_device.h +2
-1@@ -109,13 +109,14 @@ int omap_device_align_pm_lat(struct platform_device *pdev,struct powerdomain *omap_device_get_pwrdm (struct omap_device *od);/* Other */ -int omap_device_idle_hwmods (struct omap_device *od);int omap_device_enable_hwmods (struct omap_device *od);int omap_device_disable_clocks (struct omap_device *od);int omap_device_enable_clocks (struct omap_device *od); +int omap_device_mstandby (struct platform_device *pdev,u32 *midlemode, +bool set_mstandby);/* * Entries should be kept in latency order ascending arch/arm/plat-omap/include/plat/omap_hwmod.h +3
-0@@ -526,6 +526,9 @@ int omap_hwmod_disable_clocks(struct omap_hwmod *oh);int omap_hwmod_set_slave_idlemode (struct omap_hwmod *oh,u8 idlemode); +int omap_hwmod_set_master_standbymode (struct omap_hwmod *oh,u32 midlemode); +int omap_hwmod_get_master_standbymode (struct omap_hwmod *oh,u32 *idlemode); +int omap_hwmod_reset (struct omap_hwmod *oh);void omap_hwmod_ocp_barrier (struct omap_hwmod *oh);arch/arm/plat-omap/omap_device.c +36
-0@@ -584,6 +584,42 @@ int omap_device_idle(struct platform_device *pdev) }/** +* omap_device_mstandby - set/get mstandby mode an omap_device +* @od: struct omap_device * to idle +* @midlemode: MIDLEMODE field bits (shifted to bit 0) +* @set_mstandby: flag for mstandby get/set +* +* Sets/Gets the IP block's OCP master standby in hardware. Intended +* to be used by drivers that have some erratum that requires direct +* manipulation of the MSTANDBYMODE bits. Returns -EINVAL if the +* omap_device is not currently enabled or passes along the return value +* of omap_hwmod_set_master_standbymode()/omap_hwmod_get_master_standbymode(). +*/ +int omap_device_mstandby (struct platform_device *pdev,u32 *midlemode, +bool set_mstandby) +{ +int ret =0 , i; +struct omap_device *od; +struct omap_hwmod *oh; + + od =_find_by_pdev (pdev); +if (od->_state !=OMAP_DEVICE_STATE_ENABLED ) { +WARN (1 ,"omap_device: %s.%d: %s() called from invalid state %d\n" , + od->pdev.name, od->pdev.id, __func__, od->_state); +return -EINVAL ; + } + + oh = *od->hwmods; +for (i =0 ; i < od->hwmods_cnt; i++) { +if (set_mstandby) + ret =omap_hwmod_set_master_standbymode (oh, *midlemode); +else + ret =omap_hwmod_get_master_standbymode (oh, midlemode); + } +return ret; +} + +/** * omap_device_shutdown - shut down an omap_device * @od: struct omap_device * to shut down * Signature · 1 line
1.7.1
- Paul
Hi Paul,
Quoted 10 lines
-----Original Message-----
From: Paul Walmsley [mailto:[email protected]]
Sent: Thursday, November 11, 2010 4:45 AM
To: G, Manjunath Kondaiah
Cc: [email protected]; Kevin Hilman; Gadiyar, Anand; Cousson, Benoit
Subject: Re: [PATCH v2] OMAP2+: PM:omap_device: API for set/get MSTANDBY modeHello Manju,
[...]
Quoted 6 lines
Nice patch description. A few comments:
1. Is it the case that the MSTANDBYMODE only needs to switch between (smart standby/force standby) and no standby? Or will it need to switch
between all three?
Requirement is - switch to no standby for short time and should be reverted back to original standby mode.
All the combinations are not required.
Quoted 5 lines
2. Rather than just using a single
omap_device_mstandby()function call,
I'd rather see something likeomap_device_require_no_standby()andomap_device_release_no_standby().
s/standby/mstandby ?
Quoted 5 lines
omap_device_require_no_standby()would
force the initiator port into no-standby.omap_device_release_no_standby()would return the initiator port MSTANDBYMODE to whatever the state should be (this depends on whetherHWMOD_SWSUP_MSTDBYis set).
How do we get previous stand by state in this API since standby mode is changed with "omap_device_require_no_standby"
Quoted 12 lines
I'd rather not have the drivers
manage the
contents of the MSTANDBYMODE bits directly. Then you should be able to
drop_get_master_standbymode()andomap_hwmod_get_master_idlemode()also.
Can you please make these changes?3. I have a few other comments below:
Quoted 2 lines
Signed-off-by G, Manjunath Kondaiah <[email protected]>
[...]
Quoted 11 lines
Quoted 1 line
+int omap_hwmod_set_master_standbymode(struct
omap_hwmod*oh, u32 midlemode)
arch/arm/mach-omap2/omap_hwmod.c int omap_hwmod_set_slave_idlemode(struct omap_hwmod *oh, u8 idlemode) · line 1478
Quoted 7 lines
arch/arm/mach-omap2/omap_hwmod.c +7
-0+{ +u32 v; +int retval =0 ; + +if (!oh) +return -EINVAL ; +I guess this needs to take the hwmod's mutex.
ok.
Quoted 8 lines
arch/arm/mach-omap2/omap_hwmod.c int omap_hwmod_set_slave_idlemode(struct omap_hwmod *oh, u8 idlemode) · line 1483
Quoted 6 lines
arch/arm/mach-omap2/omap_hwmod.c +5
-0+ v = oh->_sysc_cache; + + retval =_set_master_standbymode (oh, midlemode, &v); +if (!retval) +_write_sysconfig (v, oh);And release it here.
ok.
-Manjunath
Paul Walmsley
maintainerHello Manju,
Quoted 7 lines · Manjunath Kondaiah
Quoted 3 lines
-----Original Message-----
From: Paul Walmsley [mailto:[email protected]]
Sent: Thursday, November 11, 2010 4:45 AMRequirement is - switch to no standby for short time and should be reverted back to original standby mode.
All the combinations are not required.
OK, good.
Quoted 6 lines
Quoted 4 lines
2. Rather than just using a single
omap_device_mstandby()function call,
I'd rather see something likeomap_device_require_no_standby()andomap_device_release_no_standby().s/standby/mstandby ?
Thanks, that makes more sense.
Quoted 8 lines
Quoted 5 lines
omap_device_require_no_standby()would
force the initiator port into no-standby.omap_device_release_no_standby()would return the initiator port MSTANDBYMODE to whatever the state should be (this depends on whetherHWMOD_SWSUP_MSTDBYis set).How do we get previous stand by state in this API since standby mode is changed with "
omap_device_require_no_standby"
I don't think it is needed. The API is only valid while the hwmod is enabled, I think. So *require_no_mstandby() would force the hwmod into no-MSTANDBY mode, and *release_no_mstandby() would place it into smart standby if HWMOD_SWSUP_MSTDBY is not set, and no standby if it is set.
- Paul
Paul Walmsley
maintainerQuoted 9 lines · Paul Walmsley
Quoted 2 lines · Manjunath Kondaiah
How do we get previous stand by state in this API since standby mode is changed with "
omap_device_require_no_standby"I don't think it is needed. The API is only valid while the hwmod is enabled, I think. So
*require_no_mstandby()would force the hwmod into no-MSTANDBY mode, and*release_no_mstandby()would place it into smart standby ifHWMOD_SWSUP_MSTDBYis not set, and no standby if it is set.
Oops, this last "no standby" should have been "force standby."
- Paul
Paul Walmsley
maintainerQuoted 7 lines · Paul Walmsley
Quoted 5 lines · Paul Walmsley
Quoted 2 lines · Manjunath Kondaiah
How do we get previous stand by state in this API since standby mode is changed with "
omap_device_require_no_standby"
Quoted 6 lines
Quoted 4 lines
I don't think it is needed. The API is only valid while the hwmod is enabled, I think. So
*require_no_mstandby()would force the hwmod into no-MSTANDBY mode, and*release_no_mstandby()would place it into smart standby ifHWMOD_SWSUP_MSTDBYis not set, and no standby if it is set.Oops, this last "no standby" should have been "force standby."
Urk, never mind. Since the hwmod is enabled, it should be "no standby." -ENOCOFFEE
- Paul
Quoted 27 lines
-----Original Message-----
From: Paul Walmsley [mailto:[email protected]]
Sent: Friday, November 12, 2010 7:47 PM
To: G, Manjunath Kondaiah
Cc: [email protected]; Kevin Hilman; Gadiyar, Anand; Cousson, Benoit
Subject: RE: [PATCH v2] OMAP2+: PM:omap_device: API for set/get MSTANDBY modeQuoted 5 lines · Paul Walmsley
Quoted 3 lines · Paul Walmsley
Quoted 1 line · Manjunath Kondaiah
How do we get previous stand by state in this API since
standby mode is
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
changed with "
omap_device_require_no_standby"I don't think it is needed. The API is only valid while
the hwmod is
Quoted 1 line
Quoted 1 line
enabled, I think. So
*require_no_mstandby()would forcethe hwmod into
Quoted 1 line
Quoted 1 line
no-MSTANDBY mode, and
*release_no_mstandby()would place
Quoted 8 lines
it into smart
Quoted 1 line
Quoted 1 line
standby if
HWMOD_SWSUP_MSTDBYis not set, and no standbyif it is set.
Quoted 2 lines
Oops, this last "no standby" should have been "force standby."
Urk, never mind. Since the hwmod is enabled, it should be "no standby."
Thanks. Looks like, it is HWMOD_SWSUP_MSTANDBY, typo in omap_hwmod.h description.
To summarize:
idlemode = (oh->flags & HWMOD_SWSUP_MSTANDBY) ?
HWMOD_IDLEMODE_NO : HWMOD_IDLEMODE_SMART;
_set_master_standbymode(oh, idlemode, &v);
Quoted 1 line
-ENOCOFFEE
Now, return 0.
-Manjunath
Paul Walmsley
maintainerQuoted 2 lines · Manjunath Kondaiah
Thanks. Looks like, it is
HWMOD_SWSUP_MSTANDBY, typo inomap_hwmod.hdescription.
Maybe you can fix that also in your patch...
- Paul