aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/clocksource/sh_cmt.c
AgeCommit message (Collapse)Author
2014-07-04clocksource: sh_cmt: Add DT supportLaurent Pinchart
Document DT bindings and parse them in the CMT driver. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Tested-by: Simon Horman <horms+renesas@verge.net.au>
2014-07-02clocksource: sh_cmt: Replace global spinlock with a per-device spinlockLaurent Pinchart
The global spinlock is used to protect the shared start/stop register. Now that all CMT channels are handled by a single device instance, use a per-device spinlock. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Tested-by: Simon Horman <horms+renesas@verge.net.au>
2014-07-02clocksource: sh_cmt: Drop support for legacy platform dataLaurent Pinchart
Now that all platforms have switched to the new-style platform data, drop support for the legacy version. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Tested-by: Simon Horman <horms+renesas@verge.net.au>
2014-05-23clocksource: sh_cmt: Remove unnecessary OOM messagesJingoo Han
The site-specific OOM messages are unnecessary, because they duplicate the MM subsystem generic OOM message. [dlezcano] : refreshed against latest modifications: kmalloc -> kzalloc Signed-off-by: Jingoo Han <jg1.han@samsung.com> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2014-04-16clocksource: sh_cmt: Request IRQ for clock event device onlyLaurent Pinchart
Clock sources don't need an IRQ, request the IRQ only for channels used as clock event devices. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
2014-04-16clocksource: sh_cmt: Sort headers alphabeticallyLaurent Pinchart
This helps locating duplicates and inserting new headers. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
2014-04-16clocksource: sh_cmt: Remove FSF mail address from GPL noticeLaurent Pinchart
Do not include the paragraph about writing to the Free Software Foundation's mailing address from the sample GPL notice. The FSF has changed addresses in the past, and may do so again. Linux already includes a copy of the GPL. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
2014-04-16clocksource: sh_cmt: Rename clock to "fck" in the non-legacy caseLaurent Pinchart
The sh_cmt driver gets the CMT functional clock using a connection ID of "cmt_fck". While all SH SoCs create clock lookup entries with a NULL device ID and a "cmt_fck" connection ID, the ARM SoCs use the device ID only with a NULL connection ID. This works on legacy platforms but will break on ARM with DT boot. Fix the situation by using a connection ID of "fck" in the non-legacy platform data case. Clock lookup entries will be renamed to use the device ID as well as the connection ID as platforms get moved to new platform data. The legacy code will eventually be dropped, leaving us with device ID based clock lookup, compatible with DT boot. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
2014-04-16clocksource: sh_cmt: Add support for multiple channels per deviceLaurent Pinchart
CMT hardware devices can support multiple channels, with global registers and per-channel registers. The sh_cmt driver currently models the hardware with one Linux device per channel. This model makes it difficult to handle global registers in a clean way. Add support for a new model that uses one Linux device per timer with multiple channels per device. This requires changes to platform data, add new channel configuration fields. Support for the legacy model is kept and will be removed after all platforms switch to the new model. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
2014-04-16clocksource: sh_cmt: Hardcode CMT clock source rating to 125Laurent Pinchart
All boards use or should use a clock source rating of 125 for the CMT, hardcode it in the driver. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
2014-04-16clocksource: sh_cmt: Hardcode CMT clock event rating to 125Laurent Pinchart
All boards use or should use a clock event rating of 125 for the CMT, hardcode it in the driver. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
2014-04-16clocksource: sh_cmt: Set cpumask to cpu_possible_maskLaurent Pinchart
The CMT is a global timer not restricted to a single CPU. It has a lower rating than the TMU or ARM architected timer, but is still useful on systems where the other timers are stopped during CPU sleep. When multiple timers are available the timers core selects which timer to use based on timer ratings. On SMP systems where timer broadcasting is required, one dummy timer is instantiated per CPU with a rating of 100. On those systems the CMT timer has a rating of 80, which makes the dummy timer selected by default on all CPUs. The CMT is then available, and will be used as a broadcast timer. On UP systems no dummy timer is instantiated. The CMT timer has a rating of 125 on those systems and is used directly as a clock event device for CPU0 without broadcasting. The CMT rating shouldn't depend on whether we boot a UP or SMP system. We can't raise the CMT rating to 125 on SMP systems. This would select CMT as the clock event device for CPU0 as its rating is higher than the dummy timer rating, and would leave the system without a broadcast timer. We could instead lower the rating to 80 on all systems, but that wouldn't reflect reality as ratings between 1 and 99 are documented as "unfit for real use". We should raise the rating above 99 and still have the CMT selected as a broadcast timer. This can be done by changing the cpumask from cpumask_of(0) to cpu_possible_mask. In that case the timer selection logic will prefer the previously probed and already selected dummy timer for all CPUs based on the fact that already selected per-cpu timers are preferred over new global timers, regardless of their respective ratings. This also better reflects reality, as the CMT is not tied to the boot CPU. Ideally the timer selection logic should realize that the CMT needs to be used as a broadcast timer on SMP systems as no other broadcast timer is available, regardless of the cpumask and rating. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
2014-04-16clocksource: sh_cmt: Replace hardcoded register values with macrosLaurent Pinchart
Define symbolic macros for all used registers bits. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
2014-04-16clocksource: sh_cmt: Split static information from sh_cmt_deviceLaurent Pinchart
Create a new sh_cmt_info structure to hold static information about the device model and reference that structure from the sh_cmt_device structure. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
2014-04-16clocksource: sh_cmt: Allocate channels dynamicallyLaurent Pinchart
This prepares the driver for multi-channel support. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
2014-04-16clocksource: sh_cmt: Replace kmalloc + memset with kzallocLaurent Pinchart
One kzalloc a day keeps the bugs away. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
2014-04-16clocksource: sh_cmt: Add index to struct sh_cmt_channelLaurent Pinchart
Use the index when printing messages to identify the channel. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
2014-04-16clocksource: sh_cmt: Add memory base to sh_cmt_channel structureLaurent Pinchart
The channel memory base is channel-specific, add it to the channel structure in preparation for support of multiple channels per device. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
2014-04-16clocksource: sh_cmt: Rename mapbase/mapbase_str to mapbase_ch/mapbaseLaurent Pinchart
The mapbase variable points to the mapped base address of the channel, rename it to mapbase_sh. mapbase_str points to the mapped base address of the CMT device, rename it to mapbase. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
2014-04-16clocksource: sh_cmt: Constify name argument to sh_cmt_register()Laurent Pinchart
The name argument is assigned to const structure fields only, constify it. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
2014-04-16clocksource: sh_cmt: Split channel setup to separate functionLaurent Pinchart
Move the channel setup code from sh_cmt_setup to a new sh_cmt_setup_channel function and call it from sh_cmt_setup. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
2014-04-16clocksource: sh_cmt: Rename struct sh_cmt_priv to sh_cmt_deviceLaurent Pinchart
Channel data is private as well, rename priv to device to make the distrinction between the core device and the channels clearer. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
2014-04-16clocksource: sh_cmt: Split channel fields from sh_cmt_privLaurent Pinchart
Create a new sh_cmt_channel structure to hold the channel-specific field in preparation for multiple channels per device support. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
2014-04-16clocksource: sh_cmt: Use request_irq() instead of setup_irq()Laurent Pinchart
The driver claims it needs to register an interrupt handler too early for request_irq(). This might have been true in the past, but the only meaningful difference between request_irq() and setup_irq() today is an additional kzalloc() call in request_irq(). As the driver calls kmalloc() itself we know that the slab allocator is available, we can thus switch to request_irq(). Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
2013-12-18Merge branch 'clockevents/for-Simon-3.13-rc2' into clockevents/3.14Daniel Lezcano
* clocksource: sh_cmt: Add clk_prepare/unprepare support Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2013-12-18clocksource: sh_cmt: Add clk_prepare/unprepare supportLaurent Pinchart
Prepare the clock at probe time, as there is no other appropriate place in the driver where we're allowed to sleep. Cc: Daniel Lezcano <daniel.lezcano@linaro.org> Cc: linux-kernel@vger.kernel.org Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Signed-off-by: Simon Horman <horms+renesas@verge.net.au> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2013-12-11clocksource: misc drivers: Remove deprecated IRQF_DISABLEDMichael Opdenacker
This patch removes the use of the IRQF_DISABLED flag It's a NOOP since 2.6.35 and it will be removed one day. [dlezcano] : slightly changed the changelog Signed-off-by: Michael Opdenacker <michael.opdenacker@free-electrons.com> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2013-08-22clocksource: sh_cmt: 32-bit control register supportMagnus Damm
Add support for CMT hardware with 32-bit control and counter registers, as found on r8a73a4 and r8a7790. To use the CMT with 32-bit hardware a second I/O memory resource needs to point out the CMSTR register and it needs to be 32 bit wide. Signed-off-by: Magnus Damm <damm@opensource.se> Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org> Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
2013-03-13clocksource: sh_cmt: Set initcall level to subsysSimon Horman
The reason for this is to ensure that CMT is probed earlier than with its previous initcall level, module init. This came up as a problem with using kzm9g-reference which does not make use of early timers or devices. In that scenario initialisation of SDHI and MMCIF both stall on msleep() calls due to the absence of a initialised clock source. Boot tested on: armadillo800eva, mackerel and kzm9g Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
2013-03-13clocksource: sh_cmt: Add CMT register layout commentMagnus Damm
Add a comment about different register layouts supported by the CMT driver. Signed-off-by: Magnus Damm <damm@opensource.se> Acked-by: John Stultz <john.stultz@linaro.org> Tested-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
2013-03-13clocksource: sh_cmt: Add control register callbacksMagnus Damm
This patch adds control register callbacks for the CMT driver. At this point only 16-bit access is supported but in the future this will be updated to allow 32-bit access as well. Signed-off-by: Magnus Damm <damm@opensource.se> Acked-by: John Stultz <john.stultz@linaro.org> Tested-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
2013-03-13clocksource: sh_cmt: CMCNT and CMCOR register access updateMagnus Damm
Break out the CMCNT and CMCOR register access code into separate 16-bit and 32-bit functions that are hooked into callbacks at init time. This reduces the amount of software calculations happening at runtime. Signed-off-by: Magnus Damm <damm@opensource.se> Acked-by: John Stultz <john.stultz@linaro.org> Tested-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
2013-03-13clocksource: sh_cmt: CMSTR and CMCSR register access updateMagnus Damm
Update hardware register access code for CMSTR and CMCSR from using sh_cmt_read() and sh_cmt_write() to make use of 16-bit register access functions such as sh_cmt_read16() and sh_cmt_write16(). Also update sh_cmt_read() and sh_cmt_write() now when the special cases are gone. This patch moves us one step closer to the goal of separating counter register access functions from control control register functions. Signed-off-by: Magnus Damm <damm@opensource.se> Acked-by: John Stultz <john.stultz@linaro.org> Tested-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
2013-03-13clocksource: sh_cmt: Consolidate platform_set_drvdata() callMagnus Damm
Cleanup the use of platform_set_drvdata() to reduce code size Signed-off-by: Shinya Kuribayashi <shinya.kuribayashi.px@renesas.com> Signed-off-by: Magnus Damm <damm@opensource.se> Acked-by: John Stultz <john.stultz@linaro.org> Tested-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
2013-03-13clocksource: sh_cmt: Introduce per-register functionsMagnus Damm
Introduce sh_cmt_read_cmstr/cmcsr/cmcnt() and sh_cmt_write_cmstr/cmcsr/cmcnt/cmcor() to in the future allow us to split counter registers from control registers and reduce code complexity by removing sh_cmt_read() and sh_cmt_write(). Signed-off-by: Magnus Damm <damm@opensource.se> Acked-by: John Stultz <john.stultz@linaro.org> Tested-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
2013-03-13clocksource: sh_cmt: Initialize 'max_match_value' and 'lock' in sh_cmt_setup()Magnus Damm
Move the setup of spinlock and max_match_value to sh_cmt_setup(). There's no need to defer those steps until sh_cmt_register(). Signed-off-by: Shinya Kuribayashi <shinya.kuribayashi.px@renesas.com> Signed-off-by: Magnus Damm <damm@opensource.se> Acked-by: John Stultz <john.stultz@linaro.org> Tested-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
2013-03-13clocksource: sh_cmt: Take care of clk_put() when setup_irq() failsMagnus Damm
Make sure clk_put() is called in case of failure in sh_cmt_setup(). Signed-off-by: Shinya Kuribayashi <shinya.kuribayashi.px@renesas.com> Signed-off-by: Magnus Damm <damm@opensource.se> Acked-by: John Stultz <john.stultz@linaro.org> Tested-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
2013-01-03Drivers: clocksource: remove __dev* attributes.Greg Kroah-Hartman
CONFIG_HOTPLUG is going away as an option. As a result, the __dev* markings need to be removed. This change removes the use of __devinit, __devexit_p, __devinitdata, __devinitconst, and __devexit from these drivers. Based on patches originally written by Bill Pemberton, but redone by me in order to handle some of the coding style issues better, by hand. Cc: Bill Pemberton <wfp5p@virginia.edu> Cc: John Stultz <johnstul@us.ibm.com> Cc: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-09-04sh: CMT: Basic runtime PM supportRafael J. Wysocki
Modify the SH CMT clock source/clock event device driver to support runtime PM at a basic level (i.e. device clocks can be disabled and enabled, but domain power must be on, because the devices have to be marked as "irq safe"). Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> Acked-by: Magnus Damm <damm@opensource.se>
2012-09-04PM / Domains: Move syscore flag from subsys data to struct deviceRafael J. Wysocki
The syscore device PM flag is used to mark the devices (belonging to a PM domain) that should never be turned off, except for the system core (syscore) suspend/hibernation and resume stages. That flag is stored in the device's struct pm_subsys_data object whose address is available from struct device. However, in some situations it may be convenient to set that flag before the device is added to a PM domain, so it is better to move it directly to the "power" member of struct device. Then, it can be checked by the routines in drivers/base/power/runtime.c and drivers/base/power/main.c, which is more straightforward. This also reduces the number of dev_gpd_data() invocations in the generic PM domains framework, so the overhead related to the syscore flag is slightly smaller. Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> Acked-by: Magnus Damm <damm@opensource.se>
2012-09-04PM / Domains: Rename the always_on device flag to syscoreRafael J. Wysocki
The always_on device flag is used to mark the devices (belonging to a PM domain) that should never be turned off, except for the system core (syscore) suspend/hibernation and resume stages. Change name of that flag to "syscore" to better reflect its purpose. Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> Acked-by: Magnus Damm <damm@opensource.se>
2012-09-04sh: CMT: Introduce clocksource/clock events suspend/resume routinesRafael J. Wysocki
Introduce suspend/resume routines for SH CMT clock event devices and modify the suspend/resume routines for SH CMT clock sources such that if those devices belong to a PM domain, the generic PM domains framework will be notified that the given domain may be turned off (during system suspend) or that it has to be turned on (during system resume). Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> Acked-by: Magnus Damm <damm@opensource.se>
2012-06-11clocksource: sh_cmt: Convert timer lock to raw spinlock.Paul Mundt
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
2012-03-16PM / shmobile: Make CMT driver use pm_genpd_dev_always_on()Rafael J. Wysocki
Make the CMT clocksource driver mark its device as "always on" using pm_genpd_dev_always_on() to protect it from surprise power removals. Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> Tested-by: Simon Horman <horms@verge.net.au> Acked-by: Paul Mundt <lethal@linux-sh.org> Cc: stable@vger.kernel.org
2011-10-31drivers/clocksource: Add module.h to those who were using it implicitlyPaul Gortmaker
A pending cleanup will mean that module.h won't be implicitly everywhere anymore. Make sure the modular drivers in clocksource are actually calling out for <module.h> explicitly in advance. Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
2011-07-21clocksource: sh_cmt: wait for CMCNT on init V2Magnus Damm
Add code to the CMT driver to wait for CMCNT V2. This to let the register value settle before starting the timer channel. Makes the driver more robust. Needed for CMT2 on sh7372 and certain CMT channels on sh73a0. Signed-off-by: Magnus Damm <damm@opensource.se> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
2011-05-31Revert "clocksource: sh_cmt: Runtime PM support"Paul Mundt
This reverts commit 01fa68b58492a5d6708a91c1f474b6a099a9509e. The same note as per the sh_tmu change applies here, too. Signed-off-by: Paul Mundt <lethal@linux-sh.org>
2011-05-23clocksource: sh_cmt: Runtime PM supportMagnus Damm
Add Runtime PM support to the CMT driver. The hardware device is enabled as long as the clocksource or the clockevent portion of the driver is used. Signed-off-by: Magnus Damm <damm@opensource.se> Acked-by: John Stultz <johnstul@us.ibm.com> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
2011-05-23clocksource: sh_cmt: __clocksource_updatefreq_hz() updateMagnus Damm
This patch updates the clocksource part of the CMT driver to make use of the __clocksource_updatefreq_hz() function. Without this patch the old code uses clocksource_register() together with a hack that assumes a never changing clock rate (see clk_enable(), clk_get_rate() and clk_disable()). The patch uses clocksource_register_hz() with 1 Hz as initial value, then lets the ->enable() callback update the value with __clocksource_updatefreq_hz() once the struct clk has been enabled and the frequency is stable. Signed-off-by: Magnus Damm <damm@opensource.se> Acked-by: John Stultz <johnstul@us.ibm.com> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
2010-12-17clocksource: sh_cmt: Remove nested spinlock fixTakashi YOSHII
There are control flow that sh_cmt_set_next() does double spin-lock. The callers sh_cmt_{start,stop}() already have lock. But another callers sh_cmt_clock_event_{start,next}() does not. Now sh_cmt_set_next() does not lock by itself. All the callers should hold spin-lock before calling it. [damm@opensource.se: use __sh_cmt_set_next() to simplify code] [damm@opensource.se: added stable, suitable for v2.6.35 + v2.6.36] Cc: stable@kernel.org Signed-off-by: Takashi YOSHII <takashi.yoshii.zj@renesas.com> Signed-off-by: Magnus Damm <damm@opensource.se> Signed-off-by: Paul Mundt <lethal@linux-sh.org>