OMAP: omap_hwmod/omap_device patches for 2.6.33
Subsystems (4)
Paul Walmsley
maintainercover OMAP: omap_hwmod/omap_device patches for 2.6.33
Hello,
This series contains some updates and bugfixes for the omap_hwmod/omap_device code, intended for the 2.6.33 merge window.
- Paul
---
Kevin Hilman (6):
OMAP: omap_device: add to_omap_device() macro
OMAP: omap_device: use UINT_MAX for default wakeup latency limit
OMAP: omap_device: use read_persistent_clock() instead of getnstimeofday()
OMAP: hwmod: warn on missing clockdomain
OMAP: omap_device: fix nsec/usec conversion in latency calculations
OMAP: omap_device: track latency in nanoseconds
Paul Walmsley (4):
OMAP3 hwmod: reprogram OCP_SYSCONFIG register after setting SOFTRESET OMAP3 hwmod: Add automatic OCP_SYSCONFIG AUTOIDLE handling OMAP hwmod: add names to module MPU IRQ lines
OMAP3 hwmod: drop most of the OCP_SYSCONFIG.CLOCKACTIVITY code
arch/arm/mach-omap2/omap_hwmod.c | 151 ++++++++++--------------- arch/arm/plat-omap/include/plat/omap_device.h | 8 + arch/arm/plat-omap/include/plat/omap_hwmod.h | 26 ++++ arch/arm/plat-omap/omap_device.c | 18 +-- 4 files changed, 96 insertions(+), 107 deletions(-)
Paul Walmsley
maintainerPATCH 1/10 OMAP3 hwmod: reprogram OCP_SYSCONFIG register after setting SOFTRESET
Reprogram the module's OCP_SYSCONFIG register after module reset (SOFTRESET = 1). This may not be needed, but the definition of the reset performed by the SOFTRESET bit is unclear.
Kevin Hilman <[email protected]> tested an earlier version of this patch.
--- arch/arm/mach-omap2/omap_hwmod.c | 18 +++++++++++++----- 1 files changed, 13 insertions(+), 5 deletions(-)
arch/arm/mach-omap2/omap_hwmod.c +13 -5
@@ -948,11 +948,19 @@ static int _setup(struct omap_hwmod *oh)_enable (oh); -if (!(oh->flags &HWMOD_INIT_NO_RESET )) -_reset (oh); - -/* XXX OCP AUTOIDLE bit? */ -/* XXX OCP ENAWAKEUP bit? */ +if (!(oh->flags &HWMOD_INIT_NO_RESET )) { +/* +* XXX Do the OCP_SYSCONFIG bits need to be +* reprogrammed after a reset? If not, then this can +* be removed. If they do, then probably the +* _enable() function should be split to avoid the +* rewrite of the OCP_SYSCONFIG register. +*/ +if (oh->sysconfig) { +_update_sysc_cache (oh); +_sysc_enable (oh); + } + }if (!(oh->flags &HWMOD_INIT_NO_IDLE ))_idle (oh);
Paul Walmsley
maintainerPATCH 2/10 OMAP3 hwmod: Add automatic OCP_SYSCONFIG AUTOIDLE handling
In reply to Paul WalmsleyThis patch fills in the OCP_SYSCONFIG.AUTOIDLE handling in the OMAP hwmod code.
After this patch, the hwmod code will set the module AUTOIDLE bit (generally <module>.OCP_SYSCONFIG.AUTOIDLE) to 1 by default upon enable. If the hwmod flag HWMOD_NO_OCP_AUTOIDLE is set, AUTOIDLE will be set to 0 upon enable. Upon module disable, AUTOIDLE will be set to 1.
Enabling module autoidle should save some power. The only reason to not set the OCP_SYSCONFIG.AUTOIDLE bit is if there is a bug in the module RTL, e.g., the MPUINTC block on OMAP3.
Comments from Kevin Hilman <[email protected]> inspired this patch, and Kevin tested an earlier version of this patch.
--- arch/arm/mach-omap2/omap_hwmod.c | 37 +++++++++++++++++++++++++- arch/arm/plat-omap/include/plat/omap_hwmod.h | 8 +++++- 2 files changed, 42 insertions(+), 3 deletions(-)
arch/arm/mach-omap2/omap_hwmod.c +35 -2
@@ -210,6 +210,32 @@ static int _set_softreset(struct omap_hwmod *oh, u32 *v) }/** +* _set_module_autoidle: set the OCP_SYSCONFIG AUTOIDLE field in @v +* @oh: struct omap_hwmod * +* @autoidle: desired AUTOIDLE bitfield value (0 or 1) +* @v: pointer to register contents to modify +* +* Update the module autoidle bit in @v to be @autoidle for the @oh +* hwmod. The autoidle bit controls whether the module can gate +* internal clocks automatically when it isn't doing anything; the +* exact function of this bit varies on a per-module basis. This +* function does not write to the hardware. Returns -EINVAL upon +* error or 0 upon success. +*/ +static int _set_module_autoidle (struct omap_hwmod *oh,u8 autoidle, +u32 *v) +{ +if (!oh->sysconfig || + !(oh->sysconfig->sysc_flags &SYSC_HAS_AUTOIDLE )) +return -EINVAL ; + + *v &= ~SYSC_AUTOIDLE_MASK ; + *v |= autoidle <<SYSC_AUTOIDLE_SHIFT ; + +return 0 ; +} + +/** * _enable_wakeup: set OCP_SYSCONFIG.ENAWAKEUP bit in the hardware * @oh: struct omap_hwmod * *
@@ -557,7 +583,13 @@ static void _sysc_enable(struct omap_hwmod *oh)_set_master_standbymode (oh, idlemode, &v); } -/* XXX OCP AUTOIDLE bit? */ +if (oh->sysconfig->sysc_flags &SYSC_HAS_AUTOIDLE ) { + idlemode = (oh->flags &HWMOD_NO_OCP_AUTOIDLE ) ? +0 :1 ; +_set_module_autoidle (oh, idlemode, &v); + } + +/* XXX OCP ENAWAKEUP bit? */ if (oh->flags &HWMOD_SET_DEFAULT_CLOCKACT && oh->sysconfig->sysc_flags &SYSC_HAS_CLOCKACTIVITY )
@@ -622,7 +654,8 @@ static void _sysc_shutdown(struct omap_hwmod *oh)if (oh->sysconfig->sysc_flags &SYSC_HAS_MIDLEMODE )_set_master_standbymode (oh,HWMOD_IDLEMODE_FORCE , &v); -/* XXX clear OCP AUTOIDLE bit? */ +if (oh->sysconfig->sysc_flags &SYSC_HAS_AUTOIDLE ) +_set_module_autoidle (oh,1 , &v);_write_sysconfig (v, oh); }
arch/arm/plat-omap/include/plat/omap_hwmod.h +7 -1
@@ -50,6 +50,8 @@ struct omap_device;#define SYSC_ENAWAKEUP_MASK (1 << SYSC_ENAWAKEUP_SHIFT)#define SYSC_SOFTRESET_SHIFT 1#define SYSC_SOFTRESET_MASK (1 << SYSC_SOFTRESET_SHIFT) +#define SYSC_AUTOIDLE_SHIFT 0 +#define SYSC_AUTOIDLE_MASK (1 << SYSC_AUTOIDLE_SHIFT)/* OCP SYSSTATUS bit shifts/masks */ #define SYSS_RESETDONE_SHIFT 0
@@ -294,13 +296,17 @@ struct omap_hwmod_omap4_prcm {* SDRAM controller, etc. * HWMOD_INIT_NO_IDLE: don't idle this module at boot - important for SDRAM * controller, etc. +* HWMOD_NO_AUTOIDLE: disable module autoidle (OCP_SYSCONFIG.AUTOIDLE) +* when module is enabled, rather than the default, which is to +* enable autoidle * HWMOD_SET_DEFAULT_CLOCKACT: program CLOCKACTIVITY bits@startup */ #define HWMOD_SWSUP_SIDLE (1 << 0)#define HWMOD_SWSUP_MSTANDBY (1 << 1)#define HWMOD_INIT_NO_RESET (1 << 2)#define HWMOD_INIT_NO_IDLE (1 << 3) -#define HWMOD_SET_DEFAULT_CLOCKACT (1 << 4) +#define HWMOD_NO_OCP_AUTOIDLE (1 << 4) +#define HWMOD_SET_DEFAULT_CLOCKACT (1 << 5)/* * omap_hwmod._int_flags definitions
Paul Walmsley
maintainerPATCH 3/10 OMAP hwmod: add names to module MPU IRQ lines
In reply to Paul WalmsleyReplace the existing u8 array of module MPU IRQ lines with a struct that includes a name - similar to the existing struct omap_hwmod_dma_info. Device drivers can then use platform_get_resource_byname() to retrieve specific IRQs without nasty dependencies on array ordering.
Thanks to Beno?t Cousson <[email protected]> and Kevin Hilman <[email protected]> for feedback on this approach.
--- arch/arm/mach-omap2/omap_hwmod.c | 5 +++-- arch/arm/plat-omap/include/plat/omap_hwmod.h | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-)
arch/arm/mach-omap2/omap_hwmod.c +3 -2
@@ -1389,8 +1389,9 @@ int omap_hwmod_fill_resources(struct omap_hwmod *oh, struct resource *res)/* For each IRQ, DMA, memory area, fill in array.*/ for (i =0 ; i < oh->mpu_irqs_cnt; i++) { - (res + r)->start = *(oh->mpu_irqs + i); - (res + r)->end = *(oh->mpu_irqs + i); + (res + r)->name = (oh->mpu_irqs + i)->name; + (res + r)->start = (oh->mpu_irqs + i)->irq; + (res + r)->end = (oh->mpu_irqs + i)->irq; (res + r)->flags =IORESOURCE_IRQ ; r++; }
arch/arm/plat-omap/include/plat/omap_hwmod.h +16 -2
@@ -64,7 +64,21 @@ struct omap_device;/** -* struct omap_hwmod_dma_info - MPU address space handled by the hwmod +* struct omap_hwmod_irq_info - MPU IRQs used by the hwmod +* @name: name of the IRQ channel (module local name) +* @irq_ch: IRQ channel ID +* +* @name should be something short, e.g., "tx" or "rx". It is for use +* by platform_get_resource_byname(). It is defined locally to the +* hwmod. +*/ +struct omap_hwmod_irq_info { +const char *name; +u16 irq; +}; + +/** +* struct omap_hwmod_dma_info - DMA channels used by the hwmod * @name: name of the DMA channel (module local name) * @dma_ch: DMA channel ID *
@@ -379,7 +393,7 @@ struct omap_hwmod_omap4_prcm {struct omap_hwmod {const char *name;struct omap_device *od; -u8 *mpu_irqs; +struct omap_hwmod_irq_info *mpu_irqs;struct omap_hwmod_dma_info *sdma_chs;union {struct omap_hwmod_omap2_prcm omap2;
Paul Walmsley
maintainerPATCH 4/10 OMAP3 hwmod: drop most of the OCP_SYSCONFIG.CLOCKACTIVITY code
In reply to Paul WalmsleyEarlier, the hwmod code had considered the OCP_SYSCONFIG.CLOCKACTIVITY bits to be incremental power saving bits, controlling internal IP block clock gates. This was a misapprehension. The CLOCKACTIVITY bits are used to indicate, in advance, which clocks will be cut when the module acknowledges an idle request. This enables the IP block to take whatever action is necessary to complete any in-progress work before asserting its IdleAck.
In the current Linux-OMAP code, this implies that the clock framework should be changing module CLOCKACTIVITY bits as module clocks are enabled and disabled. We don't do that yet, but in the future, we should. This must wait until the clock tree is annotated with omap_hwmod pointers (or vice-versa). In the meantime, drop most of the hwmod code that controls CLOCKACTIVITY bits to avoid confusion.
This patch has benefited from many illuminating discussions with (in alphabetical order) Beno?t Cousson <[email protected]>, Rajendra Nayak <[email protected]>, and Sebastien Sabatier <[email protected]>.
--- arch/arm/mach-omap2/omap_hwmod.c | 88 ++------------------------------------ 1 files changed, 5 insertions(+), 83 deletions(-)
arch/arm/mach-omap2/omap_hwmod.c +5 -83
@@ -591,6 +591,11 @@ static void _sysc_enable(struct omap_hwmod *oh)/* XXX OCP ENAWAKEUP bit? */ +/* +* XXX The clock framework should handle this, by +* calling into this code. But this must wait until the +* clock structures are tagged with omap_hwmod entries +*/ if (oh->flags &HWMOD_SET_DEFAULT_CLOCKACT && oh->sysconfig->sysc_flags &SYSC_HAS_CLOCKACTIVITY )_set_clockactivity (oh, oh->sysconfig->clockact, &v);
@@ -917,33 +922,6 @@ static int _shutdown(struct omap_hwmod *oh) }/** -* _write_clockact_lock - set the module's clockactivity bits -* @oh: struct omap_hwmod * -* @clockact: CLOCKACTIVITY field bits -* -* Writes the CLOCKACTIVITY bits @clockact to the hwmod @oh -* OCP_SYSCONFIG register. Returns -EINVAL if the hwmod is in the -* wrong state or returns 0. -*/ -static int _write_clockact_lock (struct omap_hwmod *oh,u8 clockact) -{ -u32 v; - -if (!oh->sysconfig || - !(oh->sysconfig->sysc_flags &SYSC_HAS_CLOCKACTIVITY )) -return -EINVAL ; - -mutex_lock (&omap_hwmod_mutex); - v = oh->_sysc_cache; -_set_clockactivity (oh, clockact, &v); -_write_sysconfig (v, oh); -mutex_unlock (&omap_hwmod_mutex); - -return 0 ; -} - - -/** * _setup - do initial configuration of omap_hwmod * @oh: struct omap_hwmod * *
@@ -1496,62 +1474,6 @@ int omap_hwmod_del_initiator_dep(struct omap_hwmod *oh, }/** -* omap_hwmod_set_clockact_none - set clockactivity test to BOTH -* @oh: struct omap_hwmod * -* -* On some modules, this function can affect the wakeup latency vs. -* power consumption balance. Intended to be called by the -* omap_device layer. Passes along the return value from -* _write_clockact_lock(). -*/ -int omap_hwmod_set_clockact_both (struct omap_hwmod *oh) -{ -return _write_clockact_lock (oh,CLOCKACT_TEST_BOTH ); -} - -/** -* omap_hwmod_set_clockact_none - set clockactivity test to MAIN -* @oh: struct omap_hwmod * -* -* On some modules, this function can affect the wakeup latency vs. -* power consumption balance. Intended to be called by the -* omap_device layer. Passes along the return value from -* _write_clockact_lock(). -*/ -int omap_hwmod_set_clockact_main (struct omap_hwmod *oh) -{ -return _write_clockact_lock (oh,CLOCKACT_TEST_MAIN ); -} - -/** -* omap_hwmod_set_clockact_none - set clockactivity test to ICLK -* @oh: struct omap_hwmod * -* -* On some modules, this function can affect the wakeup latency vs. -* power consumption balance. Intended to be called by the -* omap_device layer. Passes along the return value from -* _write_clockact_lock(). -*/ -int omap_hwmod_set_clockact_iclk (struct omap_hwmod *oh) -{ -return _write_clockact_lock (oh,CLOCKACT_TEST_ICLK ); -} - -/** -* omap_hwmod_set_clockact_none - set clockactivity test to NONE -* @oh: struct omap_hwmod * -* -* On some modules, this function can affect the wakeup latency vs. -* power consumption balance. Intended to be called by the -* omap_device layer. Passes along the return value from -* _write_clockact_lock(). -*/ -int omap_hwmod_set_clockact_none (struct omap_hwmod *oh) -{ -return _write_clockact_lock (oh,CLOCKACT_TEST_NONE ); -} - -/** * omap_hwmod_enable_wakeup - allow device to wake up the system * @oh: struct omap_hwmod * *
Paul Walmsley
maintainerPATCH 5/10 OMAP: omap_device: add to_omap_device() macro
In reply to Paul WalmsleyFrom: Kevin Hilman <[email protected]>
Following the model of to_platform_device(), add to_omap_device() macro so a platform_device pointer can be converted into an omap_device pointer.
--- arch/arm/plat-omap/include/plat/omap_device.h | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
arch/arm/plat-omap/include/plat/omap_device.h +3 -1
@@ -137,5 +137,7 @@ struct omap_device_pm_latency { }; -#endif +/* Get omap_device pointer from platform_device pointer */ +#define to_omap_device (x) container_of((x), struct omap_device, pdev) +#endif
Paul Walmsley
maintainerPATCH 6/10 OMAP: omap_device: use UINT_MAX for default wakeup latency limit
In reply to Paul WalmsleyFrom: Kevin Hilman <[email protected]>
The _dev_wakeup_lat_limit field of struct omap_device is u32, so use UINT_MAX instead of INT_MAX for the default maximum.
--- arch/arm/plat-omap/omap_device.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
arch/arm/plat-omap/omap_device.c +1 -1
@@ -459,7 +459,7 @@ int omap_device_enable(struct platform_device *pdev) ret =_omap_device_activate (od,IGNORE_WAKEUP_LAT ); od->dev_wakeup_lat =0 ; - od->_dev_wakeup_lat_limit =INT_MAX ; + od->_dev_wakeup_lat_limit =UINT_MAX ; od->_state =OMAP_DEVICE_STATE_ENABLED ;return ret;
Paul Walmsley
maintainerPATCH 7/10 OMAP: omap_device: use read_persistent_clock() instead of getnstimeofday()
In reply to Paul WalmsleyFrom: Kevin Hilman <[email protected]>
During suspend and resume, when omap_device deactivation and activation is happening, the timekeeping subsystem has likely already been suspended. Thus getnstimeofday() will fail and trigger a WARN().
Use read_persistent_clock() instead of getnstimeofday() to avoid this.
--- arch/arm/plat-omap/omap_device.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
arch/arm/plat-omap/omap_device.c +4 -4
@@ -134,12 +134,12 @@ static int _omap_device_activate(struct omap_device *od, u8 ignore_lat) (od->dev_wakeup_lat <= od->_dev_wakeup_lat_limit)) break; -getnstimeofday (&a); +read_persistent_clock (&a);/* XXX check return code */ odpl->activate_func (od); -getnstimeofday (&b); +read_persistent_clock (&b); c =timespec_sub (b, a); act_lat =timespec_to_ns (&c) *NSEC_PER_USEC ;
@@ -190,12 +190,12 @@ static int _omap_device_deactivate(struct omap_device *od, u8 ignore_lat) od->_dev_wakeup_lat_limit))break ; -getnstimeofday (&a); +read_persistent_clock (&a);/* XXX check return code */ odpl->deactivate_func (od); -getnstimeofday (&b); +read_persistent_clock (&b); c =timespec_sub (b, a); deact_lat =timespec_to_ns (&c) *NSEC_PER_USEC ;
Paul Walmsley
maintainerPATCH 8/10 OMAP: hwmod: warn on missing clockdomain
In reply to Paul WalmsleyFrom: Kevin Hilman <[email protected]>
WARN if a clock/hwmod is missing a clockdomain association since resulting hwmod will not be able to correctly enable/disable clocks.
--- arch/arm/mach-omap2/omap_hwmod.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/omap_hwmod.c +3 -0
@@ -352,6 +352,9 @@ static int _init_main_clk(struct omap_hwmod *oh) ret = -EINVAL ; oh->_clk = c; +WARN (!c->clkdm,"omap_hwmod: %s: missing clockdomain for %s.\n" , + oh->clkdev_con_id, c->name); +return ret; }
Paul Walmsley
maintainerPATCH 9/10 OMAP: omap_device: fix nsec/usec conversion in latency calculations
In reply to Paul WalmsleyFrom: Kevin Hilman <[email protected]>
Use
usecs = nsecs / NSEC_PER_USEC;
instead of
usecs = nsecs * NSEC_PER_USEC;
--- arch/arm/plat-omap/omap_device.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/plat-omap/omap_device.c +2 -2
@@ -142,7 +142,7 @@ static int _omap_device_activate(struct omap_device *od, u8 ignore_lat)read_persistent_clock (&b); c =timespec_sub (b, a); - act_lat =timespec_to_ns (&c) *NSEC_PER_USEC ; + act_lat =timespec_to_ns (&c) /NSEC_PER_USEC ; pr_debug("omap_device: %s: pm_lat %d: activate: elapsed time " "%llu usec\n", od->pdev.name, od->pm_lat_level,
@@ -198,7 +198,7 @@ static int _omap_device_deactivate(struct omap_device *od, u8 ignore_lat)read_persistent_clock (&b); c =timespec_sub (b, a); - deact_lat =timespec_to_ns (&c) *NSEC_PER_USEC ; + deact_lat =timespec_to_ns (&c) /NSEC_PER_USEC ; pr_debug("omap_device: %s: pm_lat %d: deactivate: elapsed time " "%llu usec\n", od->pdev.name, od->pm_lat_level,
Paul Walmsley
maintainerPATCH 10/10 OMAP: omap_device: track latency in nanoseconds
In reply to Paul WalmsleyFrom: Kevin Hilman <[email protected]>
Rather than having to do a usecs = nsecs / NSECS_PER_USEC to track latency in usecs, just track it in nanoseconds.
--- arch/arm/plat-omap/include/plat/omap_device.h | 4 ++-- arch/arm/plat-omap/omap_device.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-)
arch/arm/plat-omap/include/plat/omap_device.h +2 -2
@@ -50,8 +50,8 @@* @pm_lats: ptr to an omap_device_pm_latency table * @pm_lats_cnt: ARRAY_SIZE() of what is passed to @pm_lats * @pm_lat_level: array index of the last odpl entry executed - -1 if never -* @dev_wakeup_lat: dev wakeup latency in microseconds -* @_dev_wakeup_lat_limit: dev wakeup latency limit in usec - set by OMAP PM +* @dev_wakeup_lat: dev wakeup latency in nanoseconds +* @_dev_wakeup_lat_limit: dev wakeup latency limit in nsec - set by OMAP PM * @_state: one of OMAP_DEVICE_STATE_* (see above) * @flags: device flags *
arch/arm/plat-omap/omap_device.c +4 -4
@@ -142,10 +142,10 @@ static int _omap_device_activate(struct omap_device *od, u8 ignore_lat)read_persistent_clock (&b); c =timespec_sub (b, a); - act_lat =timespec_to_ns (&c) /NSEC_PER_USEC ; + act_lat =timespec_to_ns (&c);pr_debug ("omap_device: %s: pm_lat %d: activate: elapsed time " -"%llu usec\n" , od->pdev.name, od->pm_lat_level, +"%llu nsec\n" , od->pdev.name, od->pm_lat_level, act_lat); WARN(act_lat > odpl->activate_lat, "omap_device: %s.%d: "
@@ -198,10 +198,10 @@ static int _omap_device_deactivate(struct omap_device *od, u8 ignore_lat)read_persistent_clock (&b); c =timespec_sub (b, a); - deact_lat =timespec_to_ns (&c) /NSEC_PER_USEC ; + deact_lat =timespec_to_ns (&c);pr_debug ("omap_device: %s: pm_lat %d: deactivate: elapsed time " -"%llu usec\n" , od->pdev.name, od->pm_lat_level, +"%llu nsec\n" , od->pdev.name, od->pm_lat_level, deact_lat); WARN(deact_lat > odpl->deactivate_lat, "omap_device: %s.%d: "