* [RFC PATCH 0/5] arm:omap1/2/3/4: 32k sync timer cleanup
@ 2012-01-18 11:28 Vaibhav Hiremath
2012-01-18 11:28 ` [RFC PATCH 1/5] arm:omap1/2/3/4:Convert 32k-Sync clocksource driver to platform_driver Vaibhav Hiremath
` (4 more replies)
0 siblings, 5 replies; 18+ messages in thread
From: Vaibhav Hiremath @ 2012-01-18 11:28 UTC (permalink / raw)
To: linux-arm-kernel
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.
Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Cc: Benoit Cousson <b-cousson@ti.com>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Paul Walmsley <paul@pwsan.com>
Cc: Kevin Hilman <khilman@ti.com>
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
^ permalink raw reply [flat|nested] 18+ messages in thread
* [RFC PATCH 1/5] arm:omap1/2/3/4:Convert 32k-Sync clocksource driver to platform_driver
2012-01-18 11:28 [RFC PATCH 0/5] arm:omap1/2/3/4: 32k sync timer cleanup Vaibhav Hiremath
@ 2012-01-18 11:28 ` Vaibhav Hiremath
2012-01-18 11:59 ` Russell King - ARM Linux
2012-01-25 23:53 ` john stultz
2012-01-18 11:28 ` [RFC PATCH 2/5] arm:omap2/3: Add idle_st bits for ST_32KSYNC timer Vaibhav Hiremath
` (3 subsequent siblings)
4 siblings, 2 replies; 18+ messages in thread
From: Vaibhav Hiremath @ 2012-01-18 11:28 UTC (permalink / raw)
To: linux-arm-kernel
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".
Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Cc: Benoit Cousson <b-cousson@ti.com>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Paul Walmsley <paul@pwsan.com>
Cc: Tarun Kanti DebBarma <tarun.kanti@ti.com>
Cc: Kevin Hilman <khilman@ti.com>
---
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
diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c
index bfae81b..46b81df 100644
--- a/arch/arm/mach-omap2/timer.c
+++ b/arch/arm/mach-omap2/timer.c
@@ -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) \
diff --git a/arch/arm/plat-omap/Makefile b/arch/arm/plat-omap/Makefile
index 9a58461..b35bb93 100644
--- a/arch/arm/plat-omap/Makefile
+++ b/arch/arm/plat-omap/Makefile
@@ -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- :=
diff --git a/arch/arm/plat-omap/counter_32k.c b/arch/arm/plat-omap/counter_32k.c
deleted file mode 100644
index a6cbb71..0000000
--- a/arch/arm/plat-omap/counter_32k.c
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * OMAP 32ksynctimer/counter_32k-related code
- *
- * Copyright (C) 2009 Texas Instruments
- * Copyright (C) 2010 Nokia Corporation
- * Tony Lindgren <tony@atomide.com>
- * Added OMAP4 support - Santosh Shilimkar <santosh.shilimkar@ti.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * NOTE: This timer is not the same timer as the old OMAP1 MPU timer.
- */
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/clk.h>
-#include <linux/err.h>
-#include <linux/io.h>
-#include <linux/sched.h>
-#include <linux/clocksource.h>
-
-#include <asm/sched_clock.h>
-
-#include <plat/common.h>
-#include <plat/board.h>
-
-#include <plat/clock.h>
-
-/*
- * 32KHz clocksource ... always available, on pretty most chips except
- * OMAP 730 and 1510. Other timers could be used as clocksources, with
- * higher resolution in free-running counter modes (e.g. 12 MHz xtal),
- * but systems won't necessarily want to spend resources that way.
- */
-static void __iomem *timer_32k_base;
-
-#define OMAP16XX_TIMER_32K_SYNCHRONIZED 0xfffbc410
-
-/*
- * Returns current time from boot in nsecs. It's OK for this to wrap
- * around for now, as it's just a relative time stamp.
- */
-static DEFINE_CLOCK_DATA(cd);
-
-/*
- * Constants generated by clocks_calc_mult_shift(m, s, 32768, NSEC_PER_SEC, 60).
- * This gives a resolution of about 30us and a wrap period of about 36hrs.
- */
-#define SC_MULT 4000000000u
-#define SC_SHIFT 17
-
-static inline unsigned long long notrace _omap_32k_sched_clock(void)
-{
- u32 cyc = timer_32k_base ? __raw_readl(timer_32k_base) : 0;
- return cyc_to_fixed_sched_clock(&cd, cyc, (u32)~0, SC_MULT, SC_SHIFT);
-}
-
-#if defined(CONFIG_OMAP_32K_TIMER) && !defined(CONFIG_OMAP_MPU_TIMER)
-unsigned long long notrace sched_clock(void)
-{
- return _omap_32k_sched_clock();
-}
-#else
-unsigned long long notrace omap_32k_sched_clock(void)
-{
- return _omap_32k_sched_clock();
-}
-#endif
-
-static void notrace omap_update_sched_clock(void)
-{
- u32 cyc = timer_32k_base ? __raw_readl(timer_32k_base) : 0;
- update_sched_clock(&cd, cyc, (u32)~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.
- */
-static struct timespec persistent_ts;
-static cycles_t cycles, last_cycles;
-static unsigned int persistent_mult, persistent_shift;
-void read_persistent_clock(struct timespec *ts)
-{
- unsigned long long nsecs;
- cycles_t delta;
- struct timespec *tsp = &persistent_ts;
-
- last_cycles = cycles;
- cycles = timer_32k_base ? __raw_readl(timer_32k_base) : 0;
- delta = cycles - last_cycles;
-
- nsecs = clocksource_cyc2ns(delta, persistent_mult, persistent_shift);
-
- timespec_add_ns(tsp, nsecs);
- *ts = *tsp;
-}
-
-int __init omap_init_clocksource_32k(void)
-{
- static char err[] __initdata = KERN_ERR
- "%s: can't register clocksource!\n";
-
- if (cpu_is_omap16xx() || cpu_class_is_omap2()) {
- u32 pbase;
- unsigned long size = SZ_4K;
- void __iomem *base;
- struct clk *sync_32k_ick;
-
- if (cpu_is_omap16xx()) {
- pbase = OMAP16XX_TIMER_32K_SYNCHRONIZED;
- size = SZ_1K;
- } else if (cpu_is_omap2420())
- pbase = OMAP2420_32KSYNCT_BASE + 0x10;
- else if (cpu_is_omap2430())
- pbase = OMAP2430_32KSYNCT_BASE + 0x10;
- else if (cpu_is_omap34xx())
- pbase = OMAP3430_32KSYNCT_BASE + 0x10;
- else if (cpu_is_omap44xx())
- pbase = OMAP4430_32KSYNCT_BASE + 0x10;
- else
- return -ENODEV;
-
- /* For this to work we must have a static mapping in io.c for this area */
- base = ioremap(pbase, size);
- if (!base)
- return -ENODEV;
-
- sync_32k_ick = clk_get(NULL, "omap_32ksync_ick");
- if (!IS_ERR(sync_32k_ick))
- clk_enable(sync_32k_ick);
-
- timer_32k_base = base;
-
- /*
- * 120000 rough estimate from the calculations in
- * __clocksource_updatefreq_scale.
- */
- clocks_calc_mult_shift(&persistent_mult, &persistent_shift,
- 32768, NSEC_PER_SEC, 120000);
-
- if (clocksource_mmio_init(base, "32k_counter", 32768, 250, 32,
- clocksource_mmio_readl_up))
- printk(err, "32k_counter");
-
- init_fixed_sched_clock(&cd, omap_update_sched_clock, 32,
- 32768, SC_MULT, SC_SHIFT);
- }
- return 0;
-}
diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
index 8d81a1d..0f5d5d2 100644
--- a/drivers/clocksource/Makefile
+++ b/drivers/clocksource/Makefile
@@ -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
\ No newline at end of file
diff --git a/drivers/clocksource/omap-32k.c b/drivers/clocksource/omap-32k.c
new file mode 100644
index 0000000..f6d579e
--- /dev/null
+++ b/drivers/clocksource/omap-32k.c
@@ -0,0 +1,210 @@
+/*
+ * omap-32k.c -- OMAP 32k Sync Timer Clocksource Driver
+ *
+ * Copyright (C) 2005-2010 Tony Lindgren <t...@atomide.com>
+ * Copyright (C) 2010 Nokia Corporation
+ * Copyright (C) 2010 Felipe Balbi <m...@felipebalbi.com>
+ * Copyright (C) 2009-2010 Texas Instruments
+ * Added OMAP4 support - Santosh Shilimkar <santosh.shilim...@ti.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/time.h>
+#include <linux/clocksource.h>
+#include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
+#include <linux/err.h>
+#include <linux/module.h>
+
+struct omap_counter_32k_device {
+ struct timespec persistent_ts;
+ struct clocksource cs;
+ cycles_t cycles;
+ cycles_t last_cycles;
+
+ struct device *dev;
+ void __iomem *base;
+};
+
+#define to_omap_32k(cs) (container_of(cs, struct omap_counter_32k_device, cs))
+
+static struct omap_counter_32k_device *cs;
+
+static inline u32 omap_counter_32k_readl(const void __iomem *base,
+ unsigned offset)
+{
+ return __raw_readl(base + offset);
+}
+
+static cycle_t omap_counter_32k_read(struct clocksource *cs)
+{
+ struct omap_counter_32k_device *omap = to_omap_32k(cs);
+
+ return omap_counter_32k_readl(omap->base, 0x10);
+}
+
+/*
+ * Returns current time from boot in nsecs. It's OK for this to wrap
+ * around for now, as it's just a relative time stamp.
+ *
+ * NOTE: There is common sched_clock() function in mach-omap2/timer.c
+ * file from where this function will be called.
+ * Return 0, means the device doesn't have 32k-sync timer and
+ * execution will fallback to gp-timer.
+ */
+unsigned long long sched_clock_32k(void)
+{
+ struct omap_counter_32k_device *omap = cs;
+
+ if (!omap)
+ return 0;
+
+ return clocksource_cyc2ns(omap->cs.read(&omap->cs),
+ omap->cs.mult, omap->cs.shift);
+}
+
+/**
+ * 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;
+
+ 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;
+}
+
+static int __init omap_counter_32k_probe(struct platform_device *pdev)
+{
+ int ret;
+ void __iomem *base;
+ struct resource *res;
+ struct omap_counter_32k_device *omap;
+
+ omap = kzalloc(sizeof(*omap), GFP_KERNEL);
+ if (!omap) {
+ dev_dbg(&pdev->dev, "unable to allocate memory\n");
+ return -ENOMEM;
+ }
+
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (!res) {
+ dev_dbg(&pdev->dev, "couldn't get resource\n");
+ ret = -ENODEV;
+ goto err0;
+ }
+
+ base = ioremap(res->start, resource_size(res));
+ if (!base) {
+ dev_dbg(&pdev->dev, "ioremap failed\n");
+ ret = -ENOMEM;
+ goto err0;
+ }
+
+ pm_runtime_enable(&pdev->dev);
+ ret = pm_runtime_get(&pdev->dev);
+ if (ret) {
+ dev_dbg(&pdev->dev, "unable to enable runtime pm\n");
+ goto err1;
+ }
+
+ omap->base = base;
+ omap->dev = &pdev->dev;
+
+ omap->cs.name = "counter-32k";
+ omap->cs.rating = 250;
+ omap->cs.read = omap_counter_32k_read;
+ omap->cs.mask = CLOCKSOURCE_MASK(32);
+ omap->cs.flags = CLOCK_SOURCE_IS_CONTINUOUS;
+
+ platform_set_drvdata(pdev, omap);
+
+ ret = clocksource_register_hz(&omap->cs, 32768);
+ if (ret) {
+ dev_dbg(&pdev->dev, "failed to register clocksource\n");
+ goto err2;
+ }
+
+ cs = omap;
+ return 0;
+
+err2:
+ pm_runtime_put(&pdev->dev);
+err1:
+ iounmap(base);
+err0:
+ kfree(omap);
+ return ret;
+}
+
+static int __exit omap_counter_32k_remove(struct platform_device *pdev)
+{
+ struct omap_counter_32k_device *omap = platform_get_drvdata(pdev);
+
+ clocksource_unregister(&omap->cs);
+ pm_runtime_put(&pdev->dev);
+ iounmap(omap->base);
+ kfree(omap);
+ platform_set_drvdata(pdev, NULL);
+
+ return 0;
+}
+
+static struct platform_driver omap_counter_32k_driver = {
+ .remove = __exit_p(omap_counter_32k_remove),
+ .driver = {
+ .name = "omap-counter-32k",
+ },
+};
+
+static int __init omap_counter_32k_init(void)
+{
+ return platform_driver_probe(&omap_counter_32k_driver,
+ omap_counter_32k_probe);
+}
+arch_initcall(omap_counter_32k_init);
+
+static void __exit omap_counter_32k_exit(void)
+{
+ platform_driver_unregister(&omap_counter_32k_driver);
+}
+module_exit(omap_counter_32k_exit);
+
+MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>");
+MODULE_LICENSE("GPL v2");
diff --git a/include/linux/clocksource.h b/include/linux/clocksource.h
index c86c940..67f6067 100644
--- a/include/linux/clocksource.h
+++ b/include/linux/clocksource.h
@@ -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
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [RFC PATCH 2/5] arm:omap2/3: Add idle_st bits for ST_32KSYNC timer
2012-01-18 11:28 [RFC PATCH 0/5] arm:omap1/2/3/4: 32k sync timer cleanup Vaibhav Hiremath
2012-01-18 11:28 ` [RFC PATCH 1/5] arm:omap1/2/3/4:Convert 32k-Sync clocksource driver to platform_driver Vaibhav Hiremath
@ 2012-01-18 11:28 ` Vaibhav Hiremath
2012-01-18 11:28 ` [RFC PATCH 3/5] arm:omap1/2/3/4: Add 32k counter data to hwmod database Vaibhav Hiremath
` (2 subsequent siblings)
4 siblings, 0 replies; 18+ messages in thread
From: Vaibhav Hiremath @ 2012-01-18 11:28 UTC (permalink / raw)
To: linux-arm-kernel
32k counter/timer driver has been migrated to use hwmod database
now, so add missing idle_st bit for 32K Sync timer.
Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
Cc: Felipe Balbi <balbi@ti.com>
Cc: Benoit Cousson <b-cousson@ti.com>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Paul Walmsley <paul@pwsan.com>
Cc: Kevin Hilman <khilman@ti.com>
---
arch/arm/mach-omap2/prcm-common.h | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/arch/arm/mach-omap2/prcm-common.h b/arch/arm/mach-omap2/prcm-common.h
index 5aa5435..29955d5 100644
--- a/arch/arm/mach-omap2/prcm-common.h
+++ b/arch/arm/mach-omap2/prcm-common.h
@@ -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
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [RFC PATCH 3/5] arm:omap1/2/3/4: Add 32k counter data to hwmod database
2012-01-18 11:28 [RFC PATCH 0/5] arm:omap1/2/3/4: 32k sync timer cleanup Vaibhav Hiremath
2012-01-18 11:28 ` [RFC PATCH 1/5] arm:omap1/2/3/4:Convert 32k-Sync clocksource driver to platform_driver Vaibhav Hiremath
2012-01-18 11:28 ` [RFC PATCH 2/5] arm:omap2/3: Add idle_st bits for ST_32KSYNC timer Vaibhav Hiremath
@ 2012-01-18 11:28 ` Vaibhav Hiremath
2012-01-18 11:28 ` [RFC PATCH 4/5] arm:omap1/2/3/4: Add platform hookup code for counter-32k driver Vaibhav Hiremath
2012-01-18 11:28 ` [RFC PATCH 5/5] arm:omap1/2/3: Change dev name for sync_32k_ick clk to omap-counter-32k Vaibhav Hiremath
4 siblings, 0 replies; 18+ messages in thread
From: Vaibhav Hiremath @ 2012-01-18 11:28 UTC (permalink / raw)
To: linux-arm-kernel
In 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).
Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Cc: Benoit Cousson <b-cousson@ti.com>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Paul Walmsley <paul@pwsan.com>
Cc: Kevin Hilman <khilman@ti.com>
---
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(-)
diff --git a/arch/arm/mach-omap2/omap_hwmod_2420_data.c b/arch/arm/mach-omap2/omap_hwmod_2420_data.c
index a5409ce..2091a5c 100644
--- a/arch/arm/mach-omap2/omap_hwmod_2420_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_2420_data.c
@@ -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,
};
diff --git a/arch/arm/mach-omap2/omap_hwmod_2430_data.c b/arch/arm/mach-omap2/omap_hwmod_2430_data.c
index c4f56cb..f7cc4bb 100644
--- a/arch/arm/mach-omap2/omap_hwmod_2430_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_2430_data.c
@@ -64,6 +64,7 @@ static struct omap_hwmod omap2430_mcspi2_hwmod;
static struct omap_hwmod omap2430_mcspi3_hwmod;
static struct omap_hwmod omap2430_mmc1_hwmod;
static struct omap_hwmod omap2430_mmc2_hwmod;
+static struct omap_hwmod omap2430_counter_32k_hwmod;
/* L3 -> L4_CORE interface */
static struct omap_hwmod_ocp_if omap2430_l3_main__l4_core = {
@@ -2001,6 +2002,55 @@ static struct omap_hwmod omap2430_mmc2_hwmod = {
.class = &omap2430_mmc_class,
};
+/*
+ * '32K sync counter' class
+ * 32-bit ordinary counter, clocked by the falling edge of the 32 khz clock
+ */
+static struct omap_hwmod_class omap2430_counter_hwmod_class = {
+ .name = "counter",
+};
+
+/* counter_32k */
+static struct omap_hwmod_addr_space omap2430_counter_32k_addrs[] = {
+ {
+ .pa_start = 0x49020000,
+ .pa_end = 0x49020000 + SZ_4K,
+ .flags = ADDR_TYPE_RT
+ },
+ { }
+};
+
+/* l4_wkup -> counter_32k */
+static struct omap_hwmod_ocp_if omap2430_l4_wkup__counter_32k = {
+ .master = &omap2430_l4_wkup_hwmod,
+ .slave = &omap2430_counter_32k_hwmod,
+ .clk = "l4_ck",
+ .addr = omap2430_counter_32k_addrs,
+ .user = OCP_USER_MPU | OCP_USER_SDMA,
+};
+
+/* counter_32k slave ports */
+static struct omap_hwmod_ocp_if *omap2430_counter_32k_slaves[] = {
+ &omap2430_l4_wkup__counter_32k,
+};
+
+static struct omap_hwmod omap2430_counter_32k_hwmod = {
+ .name = "counter_32k",
+ .class = &omap2430_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 = omap2430_counter_32k_slaves,
+ .slaves_cnt = ARRAY_SIZE(omap2430_counter_32k_slaves),
+};
+
static __initdata struct omap_hwmod *omap2430_hwmods[] = {
&omap2430_l3_main_hwmod,
&omap2430_l4_core_hwmod,
@@ -2064,6 +2114,8 @@ static __initdata struct omap_hwmod *omap2430_hwmods[] = {
/* usbotg class*/
&omap2430_usbhsotg_hwmod,
+ /* 32k sync timer */
+ &omap2430_counter_32k_hwmod,
NULL,
};
diff --git a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
index 5324e8d..cb2df36 100644
--- a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
@@ -86,6 +86,7 @@ static struct omap_hwmod omap3xxx_mcbsp2_sidetone_hwmod;
static struct omap_hwmod omap3xxx_mcbsp3_sidetone_hwmod;
static struct omap_hwmod omap3xxx_usb_host_hs_hwmod;
static struct omap_hwmod omap3xxx_usb_tll_hs_hwmod;
+static struct omap_hwmod omap3xxx_counter_32k_hwmod;
/* L3 -> L4_CORE interface */
static struct omap_hwmod_ocp_if omap3xxx_l3_main__l4_core = {
@@ -3498,6 +3499,55 @@ static struct omap_hwmod omap3xxx_usb_tll_hs_hwmod = {
.slaves_cnt = ARRAY_SIZE(omap3xxx_usb_tll_hs_slaves),
};
+/*
+ * '32K sync counter' class
+ * 32-bit ordinary counter, clocked by the falling edge of the 32 khz clock
+ */
+static struct omap_hwmod_class omap3xxx_counter_hwmod_class = {
+ .name = "counter",
+};
+
+/* counter_32k */
+static struct omap_hwmod_addr_space omap3xxx_counter_32k_addrs[] = {
+ {
+ .pa_start = 0x48320000,
+ .pa_end = 0x48320000 + SZ_4K,
+ .flags = ADDR_TYPE_RT
+ },
+ { }
+};
+
+/* l4_wkup -> counter_32k */
+static struct omap_hwmod_ocp_if omap3xxx_l4_wkup__counter_32k = {
+ .master = &omap3xxx_l4_wkup_hwmod,
+ .slave = &omap3xxx_counter_32k_hwmod,
+ .clk = "wkup_l4_ick",
+ .addr = omap3xxx_counter_32k_addrs,
+ .user = OCP_USER_MPU | OCP_USER_SDMA,
+};
+
+/* counter_32k slave ports */
+static struct omap_hwmod_ocp_if *omap3xxx_counter_32k_slaves[] = {
+ &omap3xxx_l4_wkup__counter_32k,
+};
+
+static struct omap_hwmod omap3xxx_counter_32k_hwmod = {
+ .name = "counter_32k",
+ .class = &omap3xxx_counter_hwmod_class,
+ .main_clk = "omap_32ksync_ick",
+ .prcm = {
+ .omap2 = {
+ .module_offs = WKUP_MOD,
+ .prcm_reg_id = 1,
+ .module_bit = OMAP3430_ST_32KSYNC_SHIFT,
+ .idlest_reg_id = 1,
+ .idlest_idle_bit = OMAP3430_ST_32KSYNC_MASK,
+ },
+ },
+ .slaves = omap3xxx_counter_32k_slaves,
+ .slaves_cnt = ARRAY_SIZE(omap3xxx_counter_32k_slaves),
+};
+
static __initdata struct omap_hwmod *omap3xxx_hwmods[] = {
&omap3xxx_l3_main_hwmod,
&omap3xxx_l4_core_hwmod,
@@ -3561,6 +3611,7 @@ static __initdata struct omap_hwmod *omap3xxx_hwmods[] = {
&omap34xx_mcspi3,
&omap34xx_mcspi4,
+ &omap3xxx_counter_32k_hwmod,
NULL,
};
diff --git a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
index 31a3084..f9a8db0 100644
--- a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
@@ -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
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [RFC PATCH 4/5] arm:omap1/2/3/4: Add platform hookup code for counter-32k driver
2012-01-18 11:28 [RFC PATCH 0/5] arm:omap1/2/3/4: 32k sync timer cleanup Vaibhav Hiremath
` (2 preceding siblings ...)
2012-01-18 11:28 ` [RFC PATCH 3/5] arm:omap1/2/3/4: Add 32k counter data to hwmod database Vaibhav Hiremath
@ 2012-01-18 11:28 ` Vaibhav Hiremath
2012-01-18 11:28 ` [RFC PATCH 5/5] arm:omap1/2/3: Change dev name for sync_32k_ick clk to omap-counter-32k Vaibhav Hiremath
4 siblings, 0 replies; 18+ messages in thread
From: Vaibhav Hiremath @ 2012-01-18 11:28 UTC (permalink / raw)
To: linux-arm-kernel
omap 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
Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Cc: Benoit Cousson <b-cousson@ti.com>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Paul Walmsley <paul@pwsan.com>
Cc: Kevin Hilman <khilman@ti.com>
---
arch/arm/mach-omap1/devices.c | 24 ++++++++++++++++++++++++
arch/arm/mach-omap2/devices.c | 25 +++++++++++++++++++++++++
2 files changed, 49 insertions(+), 0 deletions(-)
diff --git a/arch/arm/mach-omap1/devices.c b/arch/arm/mach-omap1/devices.c
index 1d76a63..c7e99b3 100644
--- a/arch/arm/mach-omap1/devices.c
+++ b/arch/arm/mach-omap1/devices.c
@@ -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();
diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
index 35d5dff..fee14d6 100644
--- a/arch/arm/mach-omap2/devices.c
+++ b/arch/arm/mach-omap2/devices.c
@@ -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
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [RFC PATCH 5/5] arm:omap1/2/3: Change dev name for sync_32k_ick clk to omap-counter-32k
2012-01-18 11:28 [RFC PATCH 0/5] arm:omap1/2/3/4: 32k sync timer cleanup Vaibhav Hiremath
` (3 preceding siblings ...)
2012-01-18 11:28 ` [RFC PATCH 4/5] arm:omap1/2/3/4: Add platform hookup code for counter-32k driver Vaibhav Hiremath
@ 2012-01-18 11:28 ` Vaibhav Hiremath
4 siblings, 0 replies; 18+ messages in thread
From: Vaibhav Hiremath @ 2012-01-18 11:28 UTC (permalink / raw)
To: linux-arm-kernel
Device 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.
Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Cc: Benoit Cousson <b-cousson@ti.com>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Paul Walmsley <paul@pwsan.com>
Cc: Kevin Hilman <khilman@ti.com>
---
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(-)
diff --git a/arch/arm/mach-omap2/clock2420_data.c b/arch/arm/mach-omap2/clock2420_data.c
index 61ad385..1cb8803 100644
--- a/arch/arm/mach-omap2/clock2420_data.c
+++ b/arch/arm/mach-omap2/clock2420_data.c
@@ -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),
diff --git a/arch/arm/mach-omap2/clock2430_data.c b/arch/arm/mach-omap2/clock2430_data.c
index 0cc1287..353a97c 100644
--- a/arch/arm/mach-omap2/clock2430_data.c
+++ b/arch/arm/mach-omap2/clock2430_data.c
@@ -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),
diff --git a/arch/arm/mach-omap2/clock3xxx_data.c b/arch/arm/mach-omap2/clock3xxx_data.c
index 7dbb218..8e255e8 100644
--- a/arch/arm/mach-omap2/clock3xxx_data.c
+++ b/arch/arm/mach-omap2/clock3xxx_data.c
@@ -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
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [RFC PATCH 1/5] arm:omap1/2/3/4:Convert 32k-Sync clocksource driver to platform_driver
2012-01-18 11:28 ` [RFC PATCH 1/5] arm:omap1/2/3/4:Convert 32k-Sync clocksource driver to platform_driver Vaibhav Hiremath
@ 2012-01-18 11:59 ` Russell King - ARM Linux
2012-01-18 13:34 ` Hiremath, Vaibhav
2012-01-25 23:53 ` john stultz
1 sibling, 1 reply; 18+ messages in thread
From: Russell King - ARM Linux @ 2012-01-18 11:59 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, Jan 18, 2012 at 04:58:02PM +0530, Vaibhav Hiremath wrote:
> 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".
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.
^ permalink raw reply [flat|nested] 18+ messages in thread
* [RFC PATCH 1/5] arm:omap1/2/3/4:Convert 32k-Sync clocksource driver to platform_driver
2012-01-18 11:59 ` Russell King - ARM Linux
@ 2012-01-18 13:34 ` Hiremath, Vaibhav
2012-01-18 14:11 ` Russell King - ARM Linux
0 siblings, 1 reply; 18+ messages in thread
From: Hiremath, Vaibhav @ 2012-01-18 13:34 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, Jan 18, 2012 at 17:29:52, Russell King - ARM Linux wrote:
> On Wed, Jan 18, 2012 at 04:58:02PM +0530, Vaibhav Hiremath wrote:
> > 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".
>
> NAK. sched_clock is 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
> Note that some of the code you're moving has changed in current kernels.
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* [RFC PATCH 1/5] arm:omap1/2/3/4:Convert 32k-Sync clocksource driver to platform_driver
2012-01-18 13:34 ` Hiremath, Vaibhav
@ 2012-01-18 14:11 ` Russell King - ARM Linux
2012-01-18 14:19 ` Hiremath, Vaibhav
2012-01-18 14:25 ` Marc Zyngier
0 siblings, 2 replies; 18+ messages in thread
From: Russell King - ARM Linux @ 2012-01-18 14:11 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, Jan 18, 2012 at 01:34:55PM +0000, Hiremath, Vaibhav wrote:
> On Wed, Jan 18, 2012 at 17:29:52, Russell King - ARM Linux wrote:
> > On Wed, Jan 18, 2012 at 04:58:02PM +0530, Vaibhav Hiremath wrote:
> > > 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".
> >
> > NAK. sched_clock is 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.
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.
^ permalink raw reply [flat|nested] 18+ messages in thread
* [RFC PATCH 1/5] arm:omap1/2/3/4:Convert 32k-Sync clocksource driver to platform_driver
2012-01-18 14:11 ` Russell King - ARM Linux
@ 2012-01-18 14:19 ` Hiremath, Vaibhav
2012-01-18 14:25 ` Marc Zyngier
1 sibling, 0 replies; 18+ messages in thread
From: Hiremath, Vaibhav @ 2012-01-18 14:19 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, Jan 18, 2012 at 19:41:47, Russell King - ARM Linux wrote:
> On Wed, Jan 18, 2012 at 01:34:55PM +0000, Hiremath, Vaibhav wrote:
> > On Wed, Jan 18, 2012 at 17:29:52, Russell King - ARM Linux wrote:
> > > On Wed, Jan 18, 2012 at 04:58:02PM +0530, Vaibhav Hiremath wrote:
> > > > 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".
> > >
> > > NAK. sched_clock is 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.
>
> 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.
>
Oops...you are right, yes it may get reset to zero. Missed this point.
> 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
^ permalink raw reply [flat|nested] 18+ messages in thread
* [RFC PATCH 1/5] arm:omap1/2/3/4:Convert 32k-Sync clocksource driver to platform_driver
2012-01-18 14:11 ` Russell King - ARM Linux
2012-01-18 14:19 ` Hiremath, Vaibhav
@ 2012-01-18 14:25 ` Marc Zyngier
2012-01-18 14:38 ` Hiremath, Vaibhav
1 sibling, 1 reply; 18+ messages in thread
From: Marc Zyngier @ 2012-01-18 14:25 UTC (permalink / raw)
To: linux-arm-kernel
On 18/01/12 14:11, Russell King - ARM Linux wrote:
> On Wed, Jan 18, 2012 at 01:34:55PM +0000, Hiremath, Vaibhav wrote:
>> On Wed, Jan 18, 2012 at 17:29:52, Russell King - ARM Linux wrote:
>>> On Wed, Jan 18, 2012 at 04:58:02PM +0530, Vaibhav Hiremath wrote:
>>>> 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".
>>>
>>> NAK. sched_clock is 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.
>
> 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.
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.
--
Jazz is not dead. It just smells funny...
^ permalink raw reply [flat|nested] 18+ messages in thread
* [RFC PATCH 1/5] arm:omap1/2/3/4:Convert 32k-Sync clocksource driver to platform_driver
2012-01-18 14:25 ` Marc Zyngier
@ 2012-01-18 14:38 ` Hiremath, Vaibhav
2012-01-18 14:45 ` Marc Zyngier
0 siblings, 1 reply; 18+ messages in thread
From: Hiremath, Vaibhav @ 2012-01-18 14:38 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, Jan 18, 2012 at 19:55:51, Marc Zyngier wrote:
> On 18/01/12 14:11, Russell King - ARM Linux wrote:
> > On Wed, Jan 18, 2012 at 01:34:55PM +0000, Hiremath, Vaibhav wrote:
> >> On Wed, Jan 18, 2012 at 17:29:52, Russell King - ARM Linux wrote:
> >>> On Wed, Jan 18, 2012 at 04:58:02PM +0530, Vaibhav Hiremath wrote:
> >>>> 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".
> >>>
> >>> NAK. sched_clock is 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.
> >
> > 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.
>
> 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.
>From sched_clock perspective, 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
> M.
> --
> Jazz is not dead. It just smells funny...
>
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* [RFC PATCH 1/5] arm:omap1/2/3/4:Convert 32k-Sync clocksource driver to platform_driver
2012-01-18 14:38 ` Hiremath, Vaibhav
@ 2012-01-18 14:45 ` Marc Zyngier
2012-01-18 14:50 ` Russell King - ARM Linux
0 siblings, 1 reply; 18+ messages in thread
From: Marc Zyngier @ 2012-01-18 14:45 UTC (permalink / raw)
To: linux-arm-kernel
On 18/01/12 14:38, Hiremath, Vaibhav wrote:
> On Wed, Jan 18, 2012 at 19:55:51, Marc Zyngier wrote:
>> On 18/01/12 14:11, Russell King - ARM Linux wrote:
>>> On Wed, Jan 18, 2012 at 01:34:55PM +0000, Hiremath, Vaibhav wrote:
>>>> On Wed, Jan 18, 2012 at 17:29:52, Russell King - ARM Linux wrote:
>>>>> On Wed, Jan 18, 2012 at 04:58:02PM +0530, Vaibhav Hiremath wrote:
>>>>>> 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".
>>>>>
>>>>> NAK. sched_clock is 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.
>>>
>>> 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.
>>
>> 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.
> From sched_clock perspective, 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.
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.
--
Jazz is not dead. It just smells funny...
^ permalink raw reply [flat|nested] 18+ messages in thread
* [RFC PATCH 1/5] arm:omap1/2/3/4:Convert 32k-Sync clocksource driver to platform_driver
2012-01-18 14:45 ` Marc Zyngier
@ 2012-01-18 14:50 ` Russell King - ARM Linux
2012-01-19 13:09 ` Tony Lindgren
0 siblings, 1 reply; 18+ messages in thread
From: Russell King - ARM Linux @ 2012-01-18 14:50 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, Jan 18, 2012 at 02:45:36PM +0000, Marc Zyngier wrote:
> Can't you instead use the ARM sched_clock framework?
OMAP does, and has done for quite some time. The problem is these
patches are against an old kernel.
^ permalink raw reply [flat|nested] 18+ messages in thread
* [RFC PATCH 1/5] arm:omap1/2/3/4:Convert 32k-Sync clocksource driver to platform_driver
2012-01-18 14:50 ` Russell King - ARM Linux
@ 2012-01-19 13:09 ` Tony Lindgren
2012-01-19 13:30 ` Hiremath, Vaibhav
0 siblings, 1 reply; 18+ messages in thread
From: Tony Lindgren @ 2012-01-19 13:09 UTC (permalink / raw)
To: linux-arm-kernel
* Russell King - ARM Linux <linux@arm.linux.org.uk> [120118 06:18]:
> On Wed, Jan 18, 2012 at 02:45:36PM +0000, Marc Zyngier wrote:
> > Can't you instead use the ARM sched_clock framework?
>
> 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
^ permalink raw reply [flat|nested] 18+ messages in thread
* [RFC PATCH 1/5] arm:omap1/2/3/4:Convert 32k-Sync clocksource driver to platform_driver
2012-01-19 13:09 ` Tony Lindgren
@ 2012-01-19 13:30 ` Hiremath, Vaibhav
0 siblings, 0 replies; 18+ messages in thread
From: Hiremath, Vaibhav @ 2012-01-19 13:30 UTC (permalink / raw)
To: linux-arm-kernel
On Thu, Jan 19, 2012 at 18:39:26, Tony Lindgren wrote:
> * Russell King - ARM Linux <linux@arm.linux.org.uk> [120118 06:18]:
> > On Wed, Jan 18, 2012 at 02:45:36PM +0000, Marc Zyngier wrote:
> > > Can't you instead use the ARM sched_clock framework?
> >
> > 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
> Tony
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* [RFC PATCH 1/5] arm:omap1/2/3/4:Convert 32k-Sync clocksource driver to platform_driver
2012-01-18 11:28 ` [RFC PATCH 1/5] arm:omap1/2/3/4:Convert 32k-Sync clocksource driver to platform_driver Vaibhav Hiremath
2012-01-18 11:59 ` Russell King - ARM Linux
@ 2012-01-25 23:53 ` john stultz
2012-01-30 8:49 ` Hiremath, Vaibhav
1 sibling, 1 reply; 18+ messages in thread
From: john stultz @ 2012-01-25 23:53 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, 2012-01-18 at 16:58 +0530, Vaibhav Hiremath wrote:
> +/**
> + * 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;
> +
> + 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
^ permalink raw reply [flat|nested] 18+ messages in thread
* [RFC PATCH 1/5] arm:omap1/2/3/4:Convert 32k-Sync clocksource driver to platform_driver
2012-01-25 23:53 ` john stultz
@ 2012-01-30 8:49 ` Hiremath, Vaibhav
0 siblings, 0 replies; 18+ messages in thread
From: Hiremath, Vaibhav @ 2012-01-30 8:49 UTC (permalink / raw)
To: linux-arm-kernel
On Thu, Jan 26, 2012 at 05:23:30, john stultz wrote:
> On Wed, 2012-01-18 at 16:58 +0530, Vaibhav Hiremath wrote:
> > +/**
> > + * 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;
> > +
> > + 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/
>
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
> thanks
> -john
>
>
>
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2012-01-30 8:49 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-18 11:28 [RFC PATCH 0/5] arm:omap1/2/3/4: 32k sync timer cleanup Vaibhav Hiremath
2012-01-18 11:28 ` [RFC PATCH 1/5] arm:omap1/2/3/4:Convert 32k-Sync clocksource driver to platform_driver Vaibhav Hiremath
2012-01-18 11:59 ` Russell King - ARM Linux
2012-01-18 13:34 ` Hiremath, Vaibhav
2012-01-18 14:11 ` Russell King - ARM Linux
2012-01-18 14:19 ` Hiremath, Vaibhav
2012-01-18 14:25 ` Marc Zyngier
2012-01-18 14:38 ` Hiremath, Vaibhav
2012-01-18 14:45 ` Marc Zyngier
2012-01-18 14:50 ` Russell King - ARM Linux
2012-01-19 13:09 ` Tony Lindgren
2012-01-19 13:30 ` Hiremath, Vaibhav
2012-01-25 23:53 ` john stultz
2012-01-30 8:49 ` Hiremath, Vaibhav
2012-01-18 11:28 ` [RFC PATCH 2/5] arm:omap2/3: Add idle_st bits for ST_32KSYNC timer Vaibhav Hiremath
2012-01-18 11:28 ` [RFC PATCH 3/5] arm:omap1/2/3/4: Add 32k counter data to hwmod database Vaibhav Hiremath
2012-01-18 11:28 ` [RFC PATCH 4/5] arm:omap1/2/3/4: Add platform hookup code for counter-32k driver Vaibhav Hiremath
2012-01-18 11:28 ` [RFC PATCH 5/5] arm:omap1/2/3: Change dev name for sync_32k_ick clk to omap-counter-32k Vaibhav Hiremath
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).