arm:omap1/2/3/4: 32k sync timer cleanup
Subsystems (8)
cover arm:omap1/2/3/4: 32k sync timer cleanup
This patch series is built on top of older version submitted earlier during 2010 timeframe by 'Felipe Balbi' -
http://www.mail-archive.com/linux-omap at vger.kernel.org/msg37403.html
Changes from earlier submitted version:
- hwmod cleanup: Since 2010 there has been some changes happened in hwmod interface, migrated to the latest version.
- wrong hwmod info: the previous version had some issues with newly added 32k-counter hwmod data, like, base_addr, idle_st bit position. So corrected these errors.
- In omap-32k platform driver, replaced clocksource_register => clocksource_register_hz
- Merged patches into more logical grouping
NOTE: Patch series has been tested on AM37xEVM, AM3517EVM, AM335xEVM,
with/without kernel parameter "clocksource=".
The reason why I am submitting this patch-series as a RFC version is,
I am struggling to convince myself and find answers for -
- Do we really required platform_driver approach here?
- Can we simply cleaup the existing plat-omap/counter_32k.c file and add hwmod lookup to make decesion whether the module is present or not on the current device?
- what about existing mmio driver/api? we can avoid some code duplication here.
So I decided to start with RFC with the existing (already submitted) approach and get the expert peoples view on this.
Based on feedback I will submit next version.
Vaibhav Hiremath (5):
arm:omap1/2/3/4:Convert 32k-Sync clocksource driver to
platform_driver
arm:omap2/3: Add idle_st bits for ST_32KSYNC timer arm:omap1/2/3/4: Add 32k counter data to hwmod database arm:omap1/2/3/4: Add platform hookup code for counter-32k driver arm:omap1/2/3: Change dev name for sync_32k_ick clk to
omap-counter-32k
arch/arm/mach-omap1/devices.c | 24 +++ arch/arm/mach-omap2/clock2420_data.c | 2 +- arch/arm/mach-omap2/clock2430_data.c | 2 +- arch/arm/mach-omap2/clock3xxx_data.c | 2 +- arch/arm/mach-omap2/devices.c | 25 ++++ arch/arm/mach-omap2/omap_hwmod_2420_data.c | 53 +++++++ arch/arm/mach-omap2/omap_hwmod_2430_data.c | 52 +++++++ arch/arm/mach-omap2/omap_hwmod_3xxx_data.c | 51 +++++++ arch/arm/mach-omap2/omap_hwmod_44xx_data.c | 2 +- arch/arm/mach-omap2/prcm-common.h | 4 + arch/arm/mach-omap2/timer.c | 17 --- arch/arm/plat-omap/Makefile | 2 +- arch/arm/plat-omap/counter_32k.c | 154 -------------------- drivers/clocksource/Makefile | 1 + drivers/clocksource/omap-32k.c | 210 ++++++++++++++++++++++++++++ include/linux/clocksource.h | 1 + 16 files changed, 426 insertions(+), 176 deletions(-) delete mode 100644 arch/arm/plat-omap/counter_32k.c create mode 100644 drivers/clocksource/omap-32k.c
RFC PATCH 1/5 arm:omap1/2/3/4:Convert 32k-Sync clocksource driver to platform_driver
Convert counter_32k clocksource driver to standard platform_driver and move it drivers/clocksource/ directory.
Also, rename it to more generic name "omap-32k.c".
--- arch/arm/mach-omap2/timer.c | 17 --- arch/arm/plat-omap/Makefile | 2 +- arch/arm/plat-omap/counter_32k.c | 154 ---------------------------- drivers/clocksource/Makefile | 1 + drivers/clocksource/omap-32k.c | 210 ++++++++++++++++++++++++++++++++++++++ include/linux/clocksource.h | 1 + 6 files changed, 213 insertions(+), 172 deletions(-) delete mode 100644 arch/arm/plat-omap/counter_32k.c create mode 100644 drivers/clocksource/omap-32k.c
arch/arm/mach-omap2/timer.c +0 -17
@@ -233,22 +233,6 @@ static void __init omap2_gp_clockevent_init(int gptimer_id, gptimer_id, clkev.rate); } -/* Clocksource code */ - -#ifdef CONFIG_OMAP_32K_TIMER -/* -* When 32k-timer is enabled, don't use GPTimer for clocksource -* instead, just leave default clocksource which uses the 32k -* sync counter. See clocksource setup in plat-omap/counter_32k.c -*/ - -static void __init omap2_gp_clocksource_init (int unused,const char *dummy) -{ -omap_init_clocksource_32k (); -} - -#else -static struct omap_dm_timer clksrc;/*
@@ -307,7 +291,6 @@ static void __init omap2_gp_clocksource_init(int gptimer_id,pr_err ("Could not register clocksource %s\n" , clocksource_gpt.name); } -#endif #define OMAP_SYS_TIMER_INIT (name, clkev_nr, clkev_src, \ clksrc_nr, clksrc_src) \
arch/arm/plat-omap/Makefile +1 -1
@@ -4,7 +4,7 @@ # Common support obj-y := common.o sram.o clock.o devices.o dma.o mux.o \ - usb.o fb.o counter_32k.o + usb.o fb.o obj-m := obj-n := obj- :=
arch/arm/plat-omap/counter_32k.c deleted +0 -154
154 lines not on this page · raw message
drivers/clocksource/Makefile +1 -0
@@ -9,4 +9,5 @@ obj-$(CONFIG_SH_TIMER_TMU) += sh_tmu.o obj-$(CONFIG_CLKBLD_I8253) += i8253.o obj-$(CONFIG_CLKSRC_MMIO) += mmio.o obj-$(CONFIG_DW_APB_TIMER) += dw_apb_timer.o +obj-$(CONFIG_OMAP_32K_TIMER) += omap-32k.o obj-$(CONFIG_CLKSRC_DBX500_PRCMU) += clksrc-dbx500-prcmu.o
drivers/clocksource/omap-32k.c new file +210 -0
210 lines not on this page · raw message
include/linux/clocksource.h +1 -0
@@ -349,5 +349,6 @@ extern int clocksource_mmio_init(void __iomem *, const char *, unsigned long, int, unsigned, cycle_t (*)(struct clocksource *));extern int clocksource_i8253_init (void ); +extern unsigned long long sched_clock_32k (void );#endif /* _LINUX_CLOCKSOURCE_H */
--
1.7.0.4
RFC PATCH 1/5 arm:omap1/2/3/4:Convert 32k-Sync clocksource driver to platform_driver
Quoted 4 lines · Vaibhav Hiremath
Convert
counter_32kclocksource driver to standardplatform_driverand move itdrivers/clocksource/directory.Also, rename it to more generic name "
omap-32k.c".
NAK. sched_clock is supposed to be available early. Platform device driver initialization is FAR too late.
Note that some of the code you're moving has changed in current kernels.
RFC PATCH 1/5 arm:omap1/2/3/4:Convert 32k-Sync clocksource driver to platform_driver
Quoted 9 lines · Russell King - ARM Linux
Quoted 4 lines · Vaibhav Hiremath
Convert
counter_32kclocksource driver to standardplatform_driverand move itdrivers/clocksource/directory.Also, rename it to more generic name "
omap-32k.c".NAK.
sched_clockis supposed to be available early. Platform device driver initialization is FAR too late.
Russell,
Sched_clock is available very early during boot sequence. Initially gp-timer (dmtimer) will get registered as a clocksource. Please refer to the file mach-omap2/timer.c
32k_sync timer (omap-32k.c) will come get registered during arch_init.
Just FYI, the way I tested it is, I used kernel parameter "clocksourse=counter-32k", the switch from gp-timer to 32k timer will happen once it gets registered.
Thanks,
Vaibhav
Quoted 2 lines
Note that some of the code you're moving has changed in current kernels.
RFC PATCH 1/5 arm:omap1/2/3/4:Convert 32k-Sync clocksource driver to platform_driver
Quoted 16 lines · Vaibhav
Quoted 9 lines · Russell King - ARM Linux
Quoted 4 lines · Vaibhav Hiremath
Convert
counter_32kclocksource driver to standardplatform_driverand move itdrivers/clocksource/directory.Also, rename it to more generic name "
omap-32k.c".NAK.
sched_clockis supposed to be available early. Platform device driver initialization is FAR too late.Russell,
Sched_clockis available very early during boot sequence. Initially gp-timer (dmtimer) will get registered as a clocksource. Please refer to the filemach-omap2/timer.c
Quoted 5 lines
32k_sync timer (
omap-32k.c) will come get registered duringarch_init.Just FYI, the way I tested it is, I used kernel parameter "clocksourse=counter-32k", the switch from gp-timer to 32k timer will happen once it gets registered.
So please delete the sched_clock code from the 32k timer stuff you've moved to a platform driver. It will cause sched_clock to reset to zero, and that's bad news.
Only one sched_clock() should ever be registered, and that should only be registered very early at boot time.
RFC PATCH 1/5 arm:omap1/2/3/4:Convert 32k-Sync clocksource driver to platform_driver
Quoted 19 lines · Russell King - ARM Linux
Quoted 18 lines · Vaibhav
Quoted 9 lines · Russell King - ARM Linux
Quoted 4 lines · Vaibhav Hiremath
Convert
counter_32kclocksource driver to standardplatform_driverand move itdrivers/clocksource/directory.Also, rename it to more generic name "
omap-32k.c".NAK.
sched_clockis supposed to be available early. Platform device driver initialization is FAR too late.Russell,
Sched_clockis available very early during boot sequence. Initially gp-timer (dmtimer) will get registered as a clocksource. Please refer to the filemach-omap2/timer.c32k_sync timer (
omap-32k.c) will come get registered duringarch_init.
Quoted 8 lines
Quoted 3 lines
Just FYI, the way I tested it is, I used kernel parameter "clocksourse=counter-32k", the switch from gp-timer to 32k timer will happen once it gets registered.
So please delete the
sched_clockcode from the 32k timer stuff you've moved to a platform driver. It will causesched_clockto reset to zero, and that's bad news.
Oops...you are right, yes it may get reset to zero. Missed this point.
Quoted 3 lines
Only one
sched_clock()should ever be registered, and that should only be registered very early at boot time.
I think this whole platform_driver approach will not work here, I have to cleanup existing plat-omap/counter-32k.c code only and add hwmod (eventually DT) support in it.
I was also not fully convinced with this approach, just followed legacy code
here; and that was the reason I have submitted patch-series as a RFC to initiate discussion and get some community opinion.
Thanks Russell...
Thanks,
Vaibhav
RFC PATCH 1/5 arm:omap1/2/3/4:Convert 32k-Sync clocksource driver to platform_driver
In reply to Russell King - ARM LinuxQuoted 23 lines · Russell King - ARM Linux
Quoted 16 lines · Vaibhav
Quoted 9 lines · Russell King - ARM Linux
Quoted 4 lines · Vaibhav Hiremath
Convert
counter_32kclocksource driver to standardplatform_driverand move itdrivers/clocksource/directory.Also, rename it to more generic name "
omap-32k.c".NAK.
sched_clockis supposed to be available early. Platform device driver initialization is FAR too late.Russell,
Sched_clockis available very early during boot sequence. Initially gp-timer (dmtimer) will get registered as a clocksource. Please refer to the filemach-omap2/timer.cQuoted 5 lines
32k_sync timer (
omap-32k.c) will come get registered duringarch_init.Just FYI, the way I tested it is, I used kernel parameter "clocksourse=counter-32k", the switch from gp-timer to 32k timer will happen once it gets registered.
Quoted 6 lines
So please delete the
sched_clockcode from the 32k timer stuff you've moved to a platform driver. It will causesched_clockto reset to zero, and that's bad news.Only one
sched_clock()should ever be registered, and that should only be registered very early at boot time.
The kernel will WARN if two sched_clock() are registered. I hope this will be enough for people not to persist with such a thing...
M.
Signature · 1 line
Jazz is not dead. It just smells funny...
RFC PATCH 1/5 arm:omap1/2/3/4:Convert 32k-Sync clocksource driver to platform_driver
Quoted 28 lines · Marc Zyngier
Quoted 27 lines · Russell King - ARM Linux
Quoted 16 lines · Vaibhav
Quoted 9 lines · Russell King - ARM Linux
Quoted 4 lines · Vaibhav Hiremath
Convert
counter_32kclocksource driver to standardplatform_driverand move itdrivers/clocksource/directory.Also, rename it to more generic name "
omap-32k.c".NAK.
sched_clockis supposed to be available early. Platform device driver initialization is FAR too late.Russell,
Sched_clockis available very early during boot sequence. Initially gp-timer (dmtimer) will get registered as a clocksource. Please refer to the filemach-omap2/timer.cQuoted 5 lines
32k_sync timer (
omap-32k.c) will come get registered duringarch_init.Just FYI, the way I tested it is, I used kernel parameter "clocksourse=counter-32k", the switch from gp-timer to 32k timer will happen once it gets registered.
So please delete the
sched_clockcode from the 32k timer stuff you've moved to a platform driver. It will causesched_clockto reset to zero, and that's bad news.
Quoted 6 lines
Quoted 2 lines
Only one
sched_clock()should ever be registered, and that should only be registered very early at boot time.The kernel will WARN if two
sched_clock()are registered. I hope this will be enough for people not to persist with such a thing...
Marc,
This code-snippet is not registering multiple sched_clock() functions, Here we have 2 timers
- gp-timer (available on all devices)
- 32k-sync timer (may not available on all devices, like AM33xx)
So we are registering both the timers as a clocksource and kernel Chooses one based on kernel-parameter or rating.
Quoted 1 line
From
sched_clockperspective, we have only one function exported in
mach-omap2/timer.c, which in-turn calls omap-32k.c timer api.
Something like this,
unsigned long long notrace sched_clock(void)
{
U32 cyc;
/* First call 32k-sync timer sched_clock() */
/* return 0 means, the device doesn't have 32k-sync timer available */
cyc = sched_clock_32k();
if (cyc)
return cyc;
/* Fall back to gp-timer approach */
}So there is and will not be any warning from kernel here.
Thanks,
Vaibhav
Quoted 5 lines
M.Signature · 1 line
Jazz is not dead. It just smells funny...
RFC PATCH 1/5 arm:omap1/2/3/4:Convert 32k-Sync clocksource driver to platform_driver
Quoted 63 lines · Vaibhav
Quoted 28 lines · Marc Zyngier
Quoted 27 lines · Russell King - ARM Linux
Quoted 16 lines · Vaibhav
Quoted 9 lines · Russell King - ARM Linux
Quoted 4 lines · Vaibhav Hiremath
Convert
counter_32kclocksource driver to standardplatform_driverand move itdrivers/clocksource/directory.Also, rename it to more generic name "
omap-32k.c".NAK.
sched_clockis supposed to be available early. Platform device driver initialization is FAR too late.Russell,
Sched_clockis available very early during boot sequence. Initially gp-timer (dmtimer) will get registered as a clocksource. Please refer to the filemach-omap2/timer.cQuoted 5 lines
32k_sync timer (
omap-32k.c) will come get registered duringarch_init.Just FYI, the way I tested it is, I used kernel parameter "clocksourse=counter-32k", the switch from gp-timer to 32k timer will happen once it gets registered.
So please delete the
sched_clockcode from the 32k timer stuff you've moved to a platform driver. It will causesched_clockto reset to zero, and that's bad news.Quoted 6 lines
Quoted 2 lines
Only one
sched_clock()should ever be registered, and that should only be registered very early at boot time.The kernel will WARN if two
sched_clock()are registered. I hope this will be enough for people not to persist with such a thing...Marc,
This code-snippet is not registering multiple
sched_clock()functions, Here we have 2 timers
- gp-timer (available on all devices)
- 32k-sync timer (may not available on all devices, like AM33xx)So we are registering both the timers as a clocksource and kernel Chooses one based on kernel-parameter or rating.
Fromsched_clockperspective, we have only one function exported inmach-omap2/timer.c, which in-turn callsomap-32k.ctimer api.Something like this,
unsigned long long notrace
sched_clock(void){ U32 cyc; /* First call 32k-sync timer sched_clock() */ /* return 0 means, the device doesn't have 32k-sync timer available */ cyc = sched_clock_32k(); if (cyc) return cyc; /* Fall back to gp-timer approach */ }
Quoted 1 line
So there is and will not be any warning from kernel here.
Can't you instead use the ARM sched_clock framework? Please have a look at what's currently in mainline (we basically register a read() function with the sched_clock framework).
A per-platform sched_clock() is a step backward for the single zImage work, and I really want to avoid this.
Thanks,
M.
Signature · 1 line
Jazz is not dead. It just smells funny...
RFC PATCH 1/5 arm:omap1/2/3/4:Convert 32k-Sync clocksource driver to platform_driver
Quoted 1 line · Marc Zyngier
Can't you instead use the ARM
sched_clockframework?
OMAP does, and has done for quite some time. The problem is these patches are against an old kernel.
Tony Lindgren
maintainerRFC PATCH 1/5 arm:omap1/2/3/4:Convert 32k-Sync clocksource driver to platform_driver
Quoted 5 lines · Russell King - ARM Linux
Quoted 1 line · Marc Zyngier
Can't you instead use the ARM
sched_clockframework?OMAP does, and has done for quite some time. The problem is these patches are against an old kernel.
Additionally we're already handling the 32k timer or not case already on omap1 as it does not exist on 1510, so there should only minimal patching needed AFAIK.
Tony
RFC PATCH 1/5 arm:omap1/2/3/4:Convert 32k-Sync clocksource driver to platform_driver
Quoted 11 lines · Tony Lindgren
Quoted 5 lines · Russell King - ARM Linux
Quoted 1 line · Marc Zyngier
Can't you instead use the ARM
sched_clockframework?OMAP does, and has done for quite some time. The problem is these patches are against an old kernel.
Additionally we're already handling the 32k timer or not case already on omap1 as it does not exist on 1510, so there should only minimal patching needed AFAIK.
Tony,
All this is handled using cpu_is_omapxxxx() checks, something like,
int __init omap_init_clocksource_32k(void) {
...
if (cpu_is_omap16xx() || cpu_class_is_omap2()) {
...
...
...
}
}This will not help for omap2/3+ devices.
I have cleaned up the code and about to submit it, please review it and provide the comments.
Submitting shortly...
Thanks,
Vaibhav
Quoted 2 lines
Tony
RFC PATCH 1/5 arm:omap1/2/3/4:Convert 32k-Sync clocksource driver to platform_driver
In reply to Vaibhav HiremathQuoted 21 lines · Vaibhav Hiremath
drivers/clocksource/omap-32k.c new file +21
-0+/** +* read_persistent_clock - Return time from a persistent clock. +* +* Reads the time from a source which isn't disabled during PM, the +* 32k sync timer. Convert the cycles elapsed since last read into +* nsecs and adds to a monotonically increasing timespec. +*/ +void read_persistent_clock (struct timespec *ts) +{ +cycles_t delta; +struct timespec *tsp; +unsigned long long nsecs; +struct omap_counter_32k_device *omap = cs; + +if (!omap) { + ts->tv_sec =0 ; + ts->tv_nsec =0 ; +return ; + } + tsp = &omap->persistent_ts; +
drivers/clocksource/omap-32k.c line 111
Quoted 10 lines
drivers/clocksource/omap-32k.c new file +10
-0+ omap->last_cycles = omap->cycles; + omap->cycles = omap->cs.read (&omap->cs); + delta = omap->cycles - omap->last_cycles; + + nsecs =clocksource_cyc2ns (delta, + omap->cs.mult, omap->cs.shift); + +timespec_add_ns (tsp, nsecs); + *ts = *tsp; +}
Hrm. So read_persistent_clock should probably be defined once per arch. So I'm not sure if it makes sense to include this implementation into the generic drivers/clocksource directory, as if some other arch tried to include this clocksource (say if they had the same hardware) they might have collisions w/ their read_persistent_clock implementation.
I'm all for being able to re-use clocksource drivers. But this is the sort of thing that makes me worry we're maybe being too aggressive in pushing clocksources that really are fairly arch/platform specific into drivers/clocksource/
thanks
-john
RFC PATCH 1/5 arm:omap1/2/3/4:Convert 32k-Sync clocksource driver to platform_driver
Quoted 40 lines · john stultz
Quoted 21 lines · Vaibhav Hiremath
drivers/clocksource/omap-32k.c new file +21
-0+/** +* read_persistent_clock - Return time from a persistent clock. +* +* Reads the time from a source which isn't disabled during PM, the +* 32k sync timer. Convert the cycles elapsed since last read into +* nsecs and adds to a monotonically increasing timespec. +*/ +void read_persistent_clock (struct timespec *ts) +{ +cycles_t delta; +struct timespec *tsp; +unsigned long long nsecs; +struct omap_counter_32k_device *omap = cs; + +if (!omap) { + ts->tv_sec =0 ; + ts->tv_nsec =0 ; +return ; + } + tsp = &omap->persistent_ts; +drivers/clocksource/omap-32k.c line 111
Quoted 10 lines
drivers/clocksource/omap-32k.c new file +10
-0+ omap->last_cycles = omap->cycles; + omap->cycles = omap->cs.read (&omap->cs); + delta = omap->cycles - omap->last_cycles; + + nsecs =clocksource_cyc2ns (delta, + omap->cs.mult, omap->cs.shift); + +timespec_add_ns (tsp, nsecs); + *ts = *tsp; +}Hrm. So
read_persistent_clockshould probably be defined once per arch. So I'm not sure if it makes sense to include this implementation into the genericdrivers/clocksourcedirectory, as if some other arch tried to include this clocksource (say if they had the same hardware) they might have collisions w/ theirread_persistent_clockimplementation.
Quoted 5 lines
I'm all for being able to re-use clocksource drivers. But this is the sort of thing that makes me worry we're maybe being too aggressive in pushing clocksources that really are fairly
arch/platformspecific intodrivers/clocksource/
John,
Sorry for delayed response and thanks for your comments.
Just FYI, we had already aligned on the list that, this is not going to work, and after discussion I have already submitted newer version of the omap timer cleanup code -
http://marc.info/?l=linux-omap&m=132730863303625&w=2
Thanks,
Vaibhav
Quoted 5 lines
thanks
-john
RFC PATCH 2/5 arm:omap2/3: Add idle_st bits for ST_32KSYNC timer
In reply to Vaibhav Hiremath32k counter/timer driver has been migrated to use hwmod database now, so add missing idle_st bit for 32K Sync timer.
--- arch/arm/mach-omap2/prcm-common.h | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/prcm-common.h +4 -0
@@ -177,6 +177,8 @@/* PM_WKST_WKUP, CM_IDLEST_WKUP shared bits */ #define OMAP24XX_ST_GPIOS_SHIFT 2#define OMAP24XX_ST_GPIOS_MASK (1 << 2) +#define OMAP24XX_ST_32KSYNC_SHIFT 1 +#define OMAP24XX_ST_32KSYNC_MASK (1 << 1)#define OMAP24XX_ST_GPT1_SHIFT 0#define OMAP24XX_ST_GPT1_MASK (1 << 0)
@@ -307,6 +309,8 @@#define OMAP3430_ST_SR1_MASK (1 << 6)#define OMAP3430_ST_GPIO1_SHIFT 3#define OMAP3430_ST_GPIO1_MASK (1 << 3) +#define OMAP3430_ST_32KSYNC_SHIFT 2 +#define OMAP3430_ST_32KSYNC_MASK (1 << 2)#define OMAP3430_ST_GPT12_SHIFT 1#define OMAP3430_ST_GPT12_MASK (1 << 1)#define OMAP3430_ST_GPT1_SHIFT 0
--
1.7.0.4
RFC PATCH 3/5 arm:omap1/2/3/4: Add 32k counter data to hwmod database
In reply to Vaibhav HiremathIn order to build the platform_device for 32k counter/timer add corresponding hwmod data to omap1/2/3 hwmod database. Also enable it in omap4 hwmod table (was disabled before).
--- arch/arm/mach-omap2/omap_hwmod_2420_data.c | 53 ++++++++++++++++++++++++++++ arch/arm/mach-omap2/omap_hwmod_2430_data.c | 52 +++++++++++++++++++++++++++ arch/arm/mach-omap2/omap_hwmod_3xxx_data.c | 51 ++++++++++++++++++++++++++ arch/arm/mach-omap2/omap_hwmod_44xx_data.c | 2 +- 4 files changed, 157 insertions(+), 1 deletions(-)
arch/arm/mach-omap2/omap_hwmod_2420_data.c +53 -0
@@ -54,6 +54,7 @@ static struct omap_hwmod omap2420_gpio4_hwmod;static struct omap_hwmod omap2420_dma_system_hwmod;static struct omap_hwmod omap2420_mcspi1_hwmod;static struct omap_hwmod omap2420_mcspi2_hwmod; +static struct omap_hwmod omap2420_counter_32k_hwmod;/* L3 -> L4_CORE interface */ static struct omap_hwmod_ocp_if omap2420_l3_main__l4_core = {
@@ -1513,6 +1514,55 @@ static struct omap_hwmod omap2420_mcbsp2_hwmod = { .slaves_cnt = ARRAY_SIZE(omap2420_mcbsp2_slaves), }; +/* +* '32K sync counter' class +* 32-bit ordinary counter, clocked by the falling edge of the 32 khz clock +*/ +static struct omap_hwmod_class omap2420_counter_hwmod_class = { + .name ="counter" , +}; + +/* counter_32k */ +static struct omap_hwmod_addr_space omap2420_counter_32k_addrs[] = { + { + .pa_start =0x48004000 , + .pa_end =0x48004000 +SZ_4K , + .flags =ADDR_TYPE_RT + }, + { } +}; + +/* l4_wkup -> counter_32k */ +static struct omap_hwmod_ocp_if omap2420_l4_wkup__counter_32k = { + .master = &omap2420_l4_wkup_hwmod, + .slave = &omap2420_counter_32k_hwmod, + .clk ="l4_ck" , + .addr = omap2420_counter_32k_addrs, + .user =OCP_USER_MPU |OCP_USER_SDMA , +}; + +/* counter_32k slave ports */ +static struct omap_hwmod_ocp_if *omap2420_counter_32k_slaves[] = { + &omap2420_l4_wkup__counter_32k, +}; + +static struct omap_hwmod omap2420_counter_32k_hwmod = { + .name ="counter_32k" , + .class = &omap2420_counter_hwmod_class, + .main_clk ="sync_32k_ick" , + .prcm = { + .omap2 = { + .module_offs =WKUP_MOD , + .prcm_reg_id =1 , + .module_bit =OMAP24XX_ST_32KSYNC_SHIFT , + .idlest_reg_id =1 , + .idlest_idle_bit =OMAP24XX_ST_32KSYNC_SHIFT , + }, + }, + .slaves = omap2420_counter_32k_slaves, + .slaves_cnt =ARRAY_SIZE (omap2420_counter_32k_slaves), +}; +static __initdata struct omap_hwmod *omap2420_hwmods[] = { &omap2420_l3_main_hwmod, &omap2420_l4_core_hwmod,
@@ -1565,6 +1615,9 @@ static __initdata struct omap_hwmod *omap2420_hwmods[] = {/* mcspi class */ &omap2420_mcspi1_hwmod, &omap2420_mcspi2_hwmod, + +/* 32k sync timer */ + &omap2420_counter_32k_hwmod, NULL, };
arch/arm/mach-omap2/omap_hwmod_2430_data.c +52 -0
70 lines not on this page · raw message
arch/arm/mach-omap2/omap_hwmod_3xxx_data.c +51 -0
69 lines not on this page · raw message
arch/arm/mach-omap2/omap_hwmod_44xx_data.c +1 -1
@@ -5595,7 +5595,7 @@ static __initdata struct omap_hwmod *omap44xx_hwmods[] = { &omap44xx_bandgap_hwmod,/* counter class */ -/* &omap44xx_counter_32k_hwmod, */ + &omap44xx_counter_32k_hwmod,/* dma class */ &omap44xx_dma_system_hwmod,
--
1.7.0.4
RFC PATCH 4/5 arm:omap1/2/3/4: Add platform hookup code for counter-32k driver
In reply to Vaibhav Hiremathomap 32k counter/timer driver has been migrated to the standard platform_driver, so platform hookup is required to bind the driver,
- omap1: Register platform_device for cpu_is_omap16xx()
- omap2/3/4: Use hwmod database lookup mechanism to build the platform_device
--- arch/arm/mach-omap1/devices.c | 24 ++++++++++++++++++++++++ arch/arm/mach-omap2/devices.c | 25 +++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 0 deletions(-)
arch/arm/mach-omap1/devices.c +24 -0
@@ -34,6 +34,29 @@/*-------------------------------------------------------------------------*/ +#define OMAP16XX_TIMER_32K_BASE 0xfffbc400 + +static struct resource omap_32k_resources[] = { + { + .start =OMAP16XX_TIMER_32K_BASE , + .end =SZ_4K , + .flags =IORESOURCE_MEM , + }, +}; + +static struct platform_device omap_32k_device = { + .name ="omap-counter-32k" , + .id =-1 , + .num_resources =ARRAY_SIZE (omap_32k_resources), + .resource = omap_32k_resources, +}; + +static void omap_init_32k (void ) +{ +if (cpu_is_omap16xx ()) + (void )platform_device_register (&omap_32k_device); +}; +#if defined(CONFIG_RTC_DRV_OMAP ) || defined(CONFIG_RTC_DRV_OMAP_MODULE )#define OMAP_RTC_BASE 0xfffb4800
@@ -301,6 +324,7 @@ static int __init omap1_init_devices(void)* in alphabetical order so they're easier to sort through. */ +omap_init_32k ();omap_init_mbox ();omap_init_rtc ();omap_init_spi100k ();
arch/arm/mach-omap2/devices.c +25 -0
@@ -105,6 +105,30 @@ static int __init omap4_l3_init(void) }postcore_initcall (omap4_l3_init); +static int __init omap_init_32k (void ) +{ +int id =-1 ; +struct omap_hwmod *oh; +struct omap_device *od; +const char *oh_name ="counter_32k" ; +const char *dev_name ="omap-counter-32k" ; + +if (!cpu_class_is_omap2 ()) +return -ENODEV ; + + oh =omap_hwmod_lookup (oh_name); +if (!oh) { +pr_err ("Could not lookup %s hwmod\n" , oh_name); +return -ENODEV ; + } + + od =omap_device_build (dev_name, id, oh,NULL ,0 ,NULL ,0 ,0 ); +WARN (IS_ERR (od),"Can't build omap device for %s:%s.\n" , + dev_name, oh->name); + +return 0 ; +}; +#if defined(CONFIG_VIDEO_OMAP2 ) || defined(CONFIG_VIDEO_OMAP2_MODULE ) static struct resource omap2cam_resources[] = {
@@ -700,6 +724,7 @@ static int __init omap2_init_devices(void)* please keep these calls, and their implementations above, * in alphabetical order so they're easier to sort through. */ +omap_init_32k ();omap_init_audio ();omap_init_mcpdm ();omap_init_dmic ();
--
1.7.0.4
RFC PATCH 5/5 arm:omap1/2/3: Change dev name for sync_32k_ick clk to omap-counter-32k
In reply to Vaibhav HiremathDevice name for the sync_32k_ick clock has been set to "omap-counter-32k". This change is required, since 32k counter clocksource driver has been migrated to standard platform_driver.
--- arch/arm/mach-omap2/clock2420_data.c | 2 +- arch/arm/mach-omap2/clock2430_data.c | 2 +- arch/arm/mach-omap2/clock3xxx_data.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
arch/arm/mach-omap2/clock2420_data.c +1 -1
@@ -1861,7 +1861,7 @@ static struct omap_clk omap2420_clks[] = {CLK (NULL ,"gpios_fck" , &gpios_fck,CK_242X ),CLK ("omap_wdt" ,"ick" , &mpu_wdt_ick,CK_242X ),CLK (NULL ,"mpu_wdt_fck" , &mpu_wdt_fck,CK_242X ), -CLK (NULL ,"sync_32k_ick" , &sync_32k_ick,CK_242X ), +CLK ("omap-counter-32k" ,"ick" , &sync_32k_ick,CK_242X ),CLK (NULL ,"wdt1_ick" , &wdt1_ick,CK_242X ),CLK (NULL ,"omapctrl_ick" , &omapctrl_ick,CK_242X ), CLK("omap24xxcam", "fck", &cam_fck, CK_242X),
arch/arm/mach-omap2/clock2430_data.c +1 -1
@@ -1959,7 +1959,7 @@ static struct omap_clk omap2430_clks[] = {CLK (NULL ,"gpios_fck" , &gpios_fck,CK_243X ),CLK ("omap_wdt" ,"ick" , &mpu_wdt_ick,CK_243X ),CLK (NULL ,"mpu_wdt_fck" , &mpu_wdt_fck,CK_243X ), -CLK (NULL ,"sync_32k_ick" , &sync_32k_ick,CK_243X ), +CLK ("omap-counter-32k" ,"ick" , &sync_32k_ick,CK_243X ),CLK (NULL ,"wdt1_ick" , &wdt1_ick,CK_243X ),CLK (NULL ,"omapctrl_ick" , &omapctrl_ick,CK_243X ), CLK(NULL, "icr_ick", &icr_ick, CK_243X),
arch/arm/mach-omap2/clock3xxx_data.c +1 -1
@@ -3402,7 +3402,7 @@ static struct omap_clk omap3xxx_clks[] = {CLK ("omap_wdt" ,"ick" , &wdt2_ick,CK_3XXX ),CLK (NULL ,"wdt1_ick" , &wdt1_ick,CK_3XXX ),CLK (NULL ,"gpio1_ick" , &gpio1_ick,CK_3XXX ), -CLK (NULL ,"omap_32ksync_ick" , &omap_32ksync_ick,CK_3XXX ), +CLK ("omap-counter-32k" ,"ick" , &omap_32ksync_ick,CK_3XXX ),CLK (NULL ,"gpt12_ick" , &gpt12_ick,CK_3XXX ),CLK (NULL ,"gpt1_ick" , &gpt1_ick,CK_3XXX ), CLK("omap-mcbsp.2", "prcm_fck", &per_96m_fck, CK_3XXX),
--
1.7.0.4