All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/7] OMAP clock fixes for v2.6.30-rc1
@ 2009-04-14 18:23 Paul Walmsley
  2009-04-14 18:23 ` [PATCH 1/7] OMAP2xxx clock: init osc_ck, sys_ck internal lists early Paul Walmsley
                   ` (6 more replies)
  0 siblings, 7 replies; 23+ messages in thread
From: Paul Walmsley @ 2009-04-14 18:23 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: linux-omap

Hi Russell,

Here are some OMAP clock-related fixes against v2.6.30-rc1.  If you
are happy with these, Tony will merge them into his omap-fixes branch
for you to pull.

You might consider the last patch to be too big to be a fix; if so,
please let me know and it will be moved to a feature series.


regards

- Paul

---

Arun KS (1):
      OMAP1: clock: Typo fix for clock in omap1

Kevin Hilman (1):
      OMAP: dmtimer: enable all timers to be wakeup events

Paul Walmsley (4):
      OMAP2/3 GPTIMER: allow system tick GPTIMER to be changed in board-*.c files
      OMAP3 GPTIMER: fix GPTIMER12 IRQ
      OMAP2xxx clock: fix broken cpu_mask code
      OMAP2xxx clock: init osc_ck, sys_ck internal lists early

Sergio Aguirre (1):
      OMAP3: clock: Camera module doesn't have IDLEST bit


 arch/arm/mach-omap1/mcbsp.c                |    4 +-
 arch/arm/mach-omap2/board-omap3beagle.c    |    4 ++
 arch/arm/mach-omap2/clock24xx.c            |   15 ++++-----
 arch/arm/mach-omap2/clock24xx.h            |   10 +++++-
 arch/arm/mach-omap2/clock34xx.h            |    7 ++--
 arch/arm/mach-omap2/timer-gp.c             |   48 ++++++++++++++++++++++++++--
 arch/arm/plat-omap/dmtimer.c               |   28 ++++++++++------
 arch/arm/plat-omap/include/mach/dmtimer.h  |    2 +
 arch/arm/plat-omap/include/mach/timer-gp.h |   17 ++++++++++
 9 files changed, 104 insertions(+), 31 deletions(-)
 create mode 100644 arch/arm/plat-omap/include/mach/timer-gp.h


omap-clock-fixes
   text	   data	    bss	    dec	    hex	filename
4601895	 249952	 304788	5156635	 4eaf1b	vmlinux.3430sdp.orig
4602055	 249952	 304788	5156795	 4eafbb	vmlinux.3430sdp



^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH 1/7] OMAP2xxx clock: init osc_ck, sys_ck internal lists early
  2009-04-14 18:23 [PATCH 0/7] OMAP clock fixes for v2.6.30-rc1 Paul Walmsley
@ 2009-04-14 18:23 ` Paul Walmsley
  2009-04-14 18:31   ` [PATCH 1/7] OMAP24xx/25xx " Paul Walmsley
  2009-04-14 18:23 ` [PATCH 2/7] OMAP2xxx clock: fix broken cpu_mask code Paul Walmsley
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 23+ messages in thread
From: Paul Walmsley @ 2009-04-14 18:23 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: Paul Walmsley, Russell King, linux-omap

Commit 3f0a820c4c0b4670fb5f164baa5582e23c2ef118 breaks OMAP2xxx boot
during initial propagate_rate() on osc_ck and sys_ck.  Fix by calling
clk_init_one() for these clocks first.

Resolves

<1>Unable to handle kernel NULL pointer dereference at virtual address 00000000
<1>pgd = c0004000
<1>[00000000] *pgd=00000000
Internal error: Oops: 5 [#1]
Modules linked in:
CPU: 0    Not tainted  (2.6.29-omap1 #37)
PC is at propagate_rate+0x10/0x60
LR is at omap2_clk_init+0x30/0x218
...

Signed-off-by: Paul Walmsley <paul@pwsan.com>
Tested-by: Jarkko Nikula <jarkko.nikula@nokia.com>
Cc: Russell King <linux@arm.linux.org.uk>
---
 arch/arm/mach-omap2/clock24xx.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/clock24xx.c b/arch/arm/mach-omap2/clock24xx.c
index 1e839c5..3b7ecc6 100644
--- a/arch/arm/mach-omap2/clock24xx.c
+++ b/arch/arm/mach-omap2/clock24xx.c
@@ -720,6 +720,8 @@ int __init omap2_clk_init(void)
 
 	clk_init(&omap2_clk_functions);
 
+	clk_init_one(&osc_ck);
+	clk_init_one(&sys_ck);
 	osc_ck.rate = omap2_osc_clk_recalc(&osc_ck);
 	propagate_rate(&osc_ck);
 	sys_ck.rate = omap2_sys_clk_recalc(&sys_ck);



^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 2/7] OMAP2xxx clock: fix broken cpu_mask code
  2009-04-14 18:23 [PATCH 0/7] OMAP clock fixes for v2.6.30-rc1 Paul Walmsley
  2009-04-14 18:23 ` [PATCH 1/7] OMAP2xxx clock: init osc_ck, sys_ck internal lists early Paul Walmsley
@ 2009-04-14 18:23 ` Paul Walmsley
  2009-04-14 18:32   ` [PATCH 2/7] OMAP24xx/OMAP25xx " Paul Walmsley
  2009-04-14 18:23 ` [PATCH 3/7] OMAP3: clock: Camera module doesn't have IDLEST bit Paul Walmsley
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 23+ messages in thread
From: Paul Walmsley @ 2009-04-14 18:23 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: Paul Walmsley, Russell King, linux-omap

Commit 8ad8ff6548f1c0bcbeaa02f274b3927c5015a921 breaks the OMAP2xxx
cpu_mask code, which causes OMAP2xxx to panic on boot.  Fix by
removing the cpu_mask auto variable and by changing CK_242X
and CK_243X to use RATE_IN_242X/RATE_IN_243X.

Resolves

<1>Unable to handle kernel NULL pointer dereference at virtual address 0000000c
<1>pgd = c0004000
<1>[0000000c] *pgd=00000000
Internal error: Oops: 5 [#1]
Modules linked in:
CPU: 0    Not tainted  (2.6.29-omap1 #32)
PC is at omap2_clk_set_parent+0x104/0x120
LR is at omap2_clk_set_parent+0x28/0x120

Signed-off-by: Paul Walmsley <paul@pwsan.com>
Tested-by: Jarkko Nikula <jarkko.nikula@nokia.com>
Cc: Russell King <linux@arm.linux.org.uk>
---
 arch/arm/mach-omap2/clock24xx.c |   12 +++---------
 1 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/arch/arm/mach-omap2/clock24xx.c b/arch/arm/mach-omap2/clock24xx.c
index 3b7ecc6..4306392 100644
--- a/arch/arm/mach-omap2/clock24xx.c
+++ b/arch/arm/mach-omap2/clock24xx.c
@@ -60,8 +60,8 @@ struct omap_clk {
 		},			\
 	}
 
-#define CK_243X	(1 << 0)
-#define CK_242X	(1 << 1)
+#define CK_243X			RATE_IN_243X
+#define CK_242X			RATE_IN_242X
 
 static struct omap_clk omap24xx_clks[] = {
 	/* external root sources */
@@ -711,7 +711,7 @@ int __init omap2_clk_init(void)
 {
 	struct prcm_config *prcm;
 	struct omap_clk *c;
-	u32 clkrate, cpu_mask;
+	u32 clkrate;
 
 	if (cpu_is_omap242x())
 		cpu_mask = RATE_IN_242X;
@@ -730,12 +730,6 @@ int __init omap2_clk_init(void)
 	for (c = omap24xx_clks; c < omap24xx_clks + ARRAY_SIZE(omap24xx_clks); c++)
 		clk_init_one(c->lk.clk);
 
-	cpu_mask = 0;
-	if (cpu_is_omap2420())
-		cpu_mask |= CK_242X;
-	if (cpu_is_omap2430())
-		cpu_mask |= CK_243X;
-
 	for (c = omap24xx_clks; c < omap24xx_clks + ARRAY_SIZE(omap24xx_clks); c++)
 		if (c->cpu & cpu_mask) {
 			clkdev_add(&c->lk);



^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 3/7] OMAP3: clock: Camera module doesn't have IDLEST bit
  2009-04-14 18:23 [PATCH 0/7] OMAP clock fixes for v2.6.30-rc1 Paul Walmsley
  2009-04-14 18:23 ` [PATCH 1/7] OMAP2xxx clock: init osc_ck, sys_ck internal lists early Paul Walmsley
  2009-04-14 18:23 ` [PATCH 2/7] OMAP2xxx clock: fix broken cpu_mask code Paul Walmsley
@ 2009-04-14 18:23 ` Paul Walmsley
  2009-04-14 18:23 ` [PATCH 4/7] OMAP1: clock: Typo fix for clock in omap1 Paul Walmsley
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 23+ messages in thread
From: Paul Walmsley @ 2009-04-14 18:23 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: Sergio Aguirre, Paul Walmsley, linux-omap

From: Sergio Aguirre <saaguirre@ti.com>

This patch avoids waiting for the camera module to become ready,
since it doesn't have IDLEST bit.

Based on a earlier hack done by Paul Walmsley on Sep 9 2008 on
linux-omap tree.

Signed-off-by: Sergio Aguirre <saaguirre@ti.com>
Signed-off-by: Paul Walmsley <paul@pwsan.com>
---
 arch/arm/mach-omap2/clock34xx.h |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-omap2/clock34xx.h b/arch/arm/mach-omap2/clock34xx.h
index 70ec10d..f009017 100644
--- a/arch/arm/mach-omap2/clock34xx.h
+++ b/arch/arm/mach-omap2/clock34xx.h
@@ -2052,7 +2052,7 @@ static struct clk dss_ick = {
 
 static struct clk cam_mclk = {
 	.name		= "cam_mclk",
-	.ops		= &clkops_omap2_dflt_wait,
+	.ops		= &clkops_omap2_dflt,
 	.parent		= &dpll4_m5x2_ck,
 	.enable_reg	= OMAP_CM_REGADDR(OMAP3430_CAM_MOD, CM_FCLKEN),
 	.enable_bit	= OMAP3430_EN_CAM_SHIFT,
@@ -2063,7 +2063,7 @@ static struct clk cam_mclk = {
 static struct clk cam_ick = {
 	/* Handles both L3 and L4 clocks */
 	.name		= "cam_ick",
-	.ops		= &clkops_omap2_dflt_wait,
+	.ops		= &clkops_omap2_dflt,
 	.parent		= &l4_ick,
 	.init		= &omap2_init_clk_clkdm,
 	.enable_reg	= OMAP_CM_REGADDR(OMAP3430_CAM_MOD, CM_ICLKEN),
@@ -2074,7 +2074,7 @@ static struct clk cam_ick = {
 
 static struct clk csi2_96m_fck = {
 	.name		= "csi2_96m_fck",
-	.ops		= &clkops_omap2_dflt_wait,
+	.ops		= &clkops_omap2_dflt,
 	.parent		= &core_96m_fck,
 	.init		= &omap2_init_clk_clkdm,
 	.enable_reg	= OMAP_CM_REGADDR(OMAP3430_CAM_MOD, CM_FCLKEN),



^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 4/7] OMAP1: clock: Typo fix for clock in omap1
  2009-04-14 18:23 [PATCH 0/7] OMAP clock fixes for v2.6.30-rc1 Paul Walmsley
                   ` (2 preceding siblings ...)
  2009-04-14 18:23 ` [PATCH 3/7] OMAP3: clock: Camera module doesn't have IDLEST bit Paul Walmsley
@ 2009-04-14 18:23 ` Paul Walmsley
  2009-04-14 18:23 ` [PATCH 5/7] OMAP3 GPTIMER: fix GPTIMER12 IRQ Paul Walmsley
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 23+ messages in thread
From: Paul Walmsley @ 2009-04-14 18:23 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: Arun KS, Paul Walmsley, linux-omap

From: Arun KS <arunks@mistralsolutions.com>

Typo error when requesting for clock for dsp in omap1

Signed-off-by: Arun KS <arunks@mistralsolutions.com>
Signed-off-by: Paul Walmsley <paul@pwsan.com>
---
 arch/arm/mach-omap1/mcbsp.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-omap1/mcbsp.c b/arch/arm/mach-omap1/mcbsp.c
index d040c3f..a2d7814 100644
--- a/arch/arm/mach-omap1/mcbsp.c
+++ b/arch/arm/mach-omap1/mcbsp.c
@@ -40,8 +40,8 @@ static void omap1_mcbsp_request(unsigned int id)
 	 */
 	if (id == OMAP_MCBSP1 || id == OMAP_MCBSP3) {
 		if (dsp_use++ == 0) {
-			api_clk = clk_get(NULL, "api_clk");
-			dsp_clk = clk_get(NULL, "dsp_clk");
+			api_clk = clk_get(NULL, "api_ck");
+			dsp_clk = clk_get(NULL, "dsp_ck");
 			if (!IS_ERR(api_clk) && !IS_ERR(dsp_clk)) {
 				clk_enable(api_clk);
 				clk_enable(dsp_clk);



^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 5/7] OMAP3 GPTIMER: fix GPTIMER12 IRQ
  2009-04-14 18:23 [PATCH 0/7] OMAP clock fixes for v2.6.30-rc1 Paul Walmsley
                   ` (3 preceding siblings ...)
  2009-04-14 18:23 ` [PATCH 4/7] OMAP1: clock: Typo fix for clock in omap1 Paul Walmsley
@ 2009-04-14 18:23 ` Paul Walmsley
  2009-04-14 18:23 ` [PATCH 6/7] OMAP: dmtimer: enable all timers to be wakeup events Paul Walmsley
  2009-04-14 18:23 ` [PATCH 7/7] OMAP2/3 GPTIMER: allow system tick GPTIMER to be changed in board-*.c files Paul Walmsley
  6 siblings, 0 replies; 23+ messages in thread
From: Paul Walmsley @ 2009-04-14 18:23 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: Paul Walmsley, Tony Lindgren, linux-omap

GPTIMER12 IRQ is at IRQ 95 on OMAP3, unlike OMAP2.  (ref: OMAP34xx
Multimedia High Security (HS) Device Silicon Revision 3.0 Security
Addendum Rev. B, SWPU119B)

Signed-off-by: Paul Walmsley <paul@pwsan.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 arch/arm/plat-omap/dmtimer.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/arm/plat-omap/dmtimer.c b/arch/arm/plat-omap/dmtimer.c
index bfd4757..c99d611 100644
--- a/arch/arm/plat-omap/dmtimer.c
+++ b/arch/arm/plat-omap/dmtimer.c
@@ -238,7 +238,7 @@ static struct omap_dm_timer omap3_dm_timers[] = {
 	{ .phys_base = 0x49040000, .irq = INT_24XX_GPTIMER9 },
 	{ .phys_base = 0x48086000, .irq = INT_24XX_GPTIMER10 },
 	{ .phys_base = 0x48088000, .irq = INT_24XX_GPTIMER11 },
-	{ .phys_base = 0x48304000, .irq = INT_24XX_GPTIMER12 },
+	{ .phys_base = 0x48304000, .irq = INT_34XX_GPT12_IRQ },
 };
 
 static const char *omap3_dm_source_names[] __initdata = {



^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 6/7] OMAP: dmtimer: enable all timers to be wakeup events
  2009-04-14 18:23 [PATCH 0/7] OMAP clock fixes for v2.6.30-rc1 Paul Walmsley
                   ` (4 preceding siblings ...)
  2009-04-14 18:23 ` [PATCH 5/7] OMAP3 GPTIMER: fix GPTIMER12 IRQ Paul Walmsley
@ 2009-04-14 18:23 ` Paul Walmsley
  2009-04-14 18:23 ` [PATCH 7/7] OMAP2/3 GPTIMER: allow system tick GPTIMER to be changed in board-*.c files Paul Walmsley
  6 siblings, 0 replies; 23+ messages in thread
From: Paul Walmsley @ 2009-04-14 18:23 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: Kevin Hilman, Paul Walmsley, linux-omap

From: Kevin Hilman <khilman@deeprootsystems.com>

All GP timers on OMAP2/3 can generate wakeup events.  The wakeup status is
cleared in the PRCM interrupt handler.

Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
Signed-off-by: Paul Walmsley <paul@pwsan.com>
---
 arch/arm/plat-omap/dmtimer.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/arm/plat-omap/dmtimer.c b/arch/arm/plat-omap/dmtimer.c
index c99d611..a05205c 100644
--- a/arch/arm/plat-omap/dmtimer.c
+++ b/arch/arm/plat-omap/dmtimer.c
@@ -321,11 +321,9 @@ static void omap_dm_timer_reset(struct omap_dm_timer *timer)
 	l |= 0x2 << 8;   /* Set clock activity to perserve f-clock on idle */
 
 	/*
-	 * Enable wake-up only for GPT1 on OMAP2 CPUs.
-	 * FIXME: All timers should have wake-up enabled and clear
-	 * PRCM status.
+	 * Enable wake-up on OMAP2 CPUs.
 	 */
-	if (cpu_class_is_omap2() && (timer == &dm_timers[0]))
+	if (cpu_class_is_omap2())
 		l |= 1 << 2;
 	omap_dm_timer_write_reg(timer, OMAP_TIMER_OCP_CFG_REG, l);
 



^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 7/7] OMAP2/3 GPTIMER: allow system tick GPTIMER to be changed in board-*.c files
  2009-04-14 18:23 [PATCH 0/7] OMAP clock fixes for v2.6.30-rc1 Paul Walmsley
                   ` (5 preceding siblings ...)
  2009-04-14 18:23 ` [PATCH 6/7] OMAP: dmtimer: enable all timers to be wakeup events Paul Walmsley
@ 2009-04-14 18:23 ` Paul Walmsley
  2009-04-14 21:45   ` Tony Lindgren
  6 siblings, 1 reply; 23+ messages in thread
From: Paul Walmsley @ 2009-04-14 18:23 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: Paul Walmsley, Tony Lindgren, linux-omap

Add a function omap2_gp_clockevent_set_gptimer() for board-*.c files
to use in .init_irq functions to configure the system tick GPTIMER.
Practical choices at this point are GPTIMER1 or GPTIMER12.  Both of
these timers are in the WKUP powerdomain, and so are unaffected by
chip power management.  GPTIMER1 can use sys_clk as a source, for
applications where a high-resolution timer is more important than
power management.  GPTIMER12 has the special property that it has the
secure 32kHz oscillator as its source clock, which may be less prone
to glitches than the off-chip 32kHz oscillator.  But on HS devices, it
may not be available for Linux use.

It appears that most boards are fine with GPTIMER1, but BeagleBoard
should use GPTIMER12 when using a 32KiHz timer source, due to hardware bugs
in revisions B4 and below.  Modify board-omap3beagle.c to use GPTIMER12.

This patch originally used a Kbuild config option to select the GPTIMER,
but was changed to allow this to be specified in board-*.c files, per
Tony's request.

Tested on Beagle rev B4 ES2.1, with and without CONFIG_OMAP_32K_TIMER, and
3430SDP.

Signed-off-by: Paul Walmsley <paul@pwsan.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 arch/arm/mach-omap2/board-omap3beagle.c    |    4 ++
 arch/arm/mach-omap2/clock24xx.c            |    1 +
 arch/arm/mach-omap2/clock24xx.h            |   10 +++++-
 arch/arm/mach-omap2/clock34xx.h            |    1 -
 arch/arm/mach-omap2/timer-gp.c             |   48 ++++++++++++++++++++++++++--
 arch/arm/plat-omap/dmtimer.c               |   20 ++++++++----
 arch/arm/plat-omap/include/mach/dmtimer.h  |    2 +
 arch/arm/plat-omap/include/mach/timer-gp.h |   17 ++++++++++
 8 files changed, 91 insertions(+), 12 deletions(-)
 create mode 100644 arch/arm/plat-omap/include/mach/timer-gp.h

diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
index 744740a..3a7a29d 100644
--- a/arch/arm/mach-omap2/board-omap3beagle.c
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -42,6 +42,7 @@
 #include <mach/nand.h>
 #include <mach/mux.h>
 #include <mach/usb.h>
+#include <mach/timer-gp.h>
 
 #include "mmc-twl4030.h"
 
@@ -186,6 +187,9 @@ static void __init omap3_beagle_init_irq(void)
 {
 	omap2_init_common_hw(NULL);
 	omap_init_irq();
+#ifdef CONFIG_OMAP_32K_TIMER
+	omap2_gp_clockevent_set_gptimer(12);
+#endif
 	omap_gpio_init();
 }
 
diff --git a/arch/arm/mach-omap2/clock24xx.c b/arch/arm/mach-omap2/clock24xx.c
index 4306392..fa2bd09 100644
--- a/arch/arm/mach-omap2/clock24xx.c
+++ b/arch/arm/mach-omap2/clock24xx.c
@@ -66,6 +66,7 @@ struct omap_clk {
 static struct omap_clk omap24xx_clks[] = {
 	/* external root sources */
 	CLK(NULL,	"func_32k_ck",	&func_32k_ck,	CK_243X | CK_242X),
+	CLK(NULL,	"secure_32k_ck", &secure_32k_ck, CK_243X | CK_242X),
 	CLK(NULL,	"osc_ck",	&osc_ck,	CK_243X | CK_242X),
 	CLK(NULL,	"sys_ck",	&sys_ck,	CK_243X | CK_242X),
 	CLK(NULL,	"alt_ck",	&alt_ck,	CK_243X | CK_242X),
diff --git a/arch/arm/mach-omap2/clock24xx.h b/arch/arm/mach-omap2/clock24xx.h
index 33c3e5b..72003f7 100644
--- a/arch/arm/mach-omap2/clock24xx.h
+++ b/arch/arm/mach-omap2/clock24xx.h
@@ -625,6 +625,14 @@ static struct clk func_32k_ck = {
 	.clkdm_name	= "wkup_clkdm",
 };
 
+static struct clk secure_32k_fck = {
+	.name		= "secure_32k_fck",
+	.ops		= &clkops_null,
+	.rate		= 32768,
+	.flags		= RATE_FIXED,
+	.clkdm_name	= "wkup_clkdm",
+};
+
 /* Typical 12/13MHz in standalone mode, will be 26Mhz in chassis mode */
 static struct clk osc_ck = {		/* (*12, *13, 19.2, *26, 38.4)MHz */
 	.name		= "osc_ck",
@@ -1790,7 +1798,7 @@ static struct clk gpt12_ick = {
 static struct clk gpt12_fck = {
 	.name		= "gpt12_fck",
 	.ops		= &clkops_omap2_dflt_wait,
-	.parent		= &func_32k_ck,
+	.parent		= &secure_32k_ck,
 	.clkdm_name	= "core_l4_clkdm",
 	.enable_reg	= OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1),
 	.enable_bit	= OMAP24XX_EN_GPT12_SHIFT,
diff --git a/arch/arm/mach-omap2/clock34xx.h b/arch/arm/mach-omap2/clock34xx.h
index f009017..6763b8f 100644
--- a/arch/arm/mach-omap2/clock34xx.h
+++ b/arch/arm/mach-omap2/clock34xx.h
@@ -2901,7 +2901,6 @@ static struct clk sr_l4_ick = {
 
 /* SECURE_32K_FCK clocks */
 
-/* XXX This clock no longer exists in 3430 TRM rev F */
 static struct clk gpt12_fck = {
 	.name		= "gpt12_fck",
 	.ops		= &clkops_null,
diff --git a/arch/arm/mach-omap2/timer-gp.c b/arch/arm/mach-omap2/timer-gp.c
index 9fc13a2..7835048 100644
--- a/arch/arm/mach-omap2/timer-gp.c
+++ b/arch/arm/mach-omap2/timer-gp.c
@@ -3,6 +3,8 @@
  *
  * OMAP2 GP timer support.
  *
+ * Copyright (C) 2009 Nokia Corporation
+ *
  * Update to use new clocksource/clockevent layers
  * Author: Kevin Hilman, MontaVista Software, Inc. <source@mvista.com>
  * Copyright (C) 2007 MontaVista Software, Inc.
@@ -36,8 +38,13 @@
 #include <asm/mach/time.h>
 #include <mach/dmtimer.h>
 
+/* MAX_GPTIMER_ID: number of GPTIMERs on the chip */
+#define MAX_GPTIMER_ID		12
+
 static struct omap_dm_timer *gptimer;
 static struct clock_event_device clockevent_gpt;
+static u8 __initdata gptimer_id = 1;
+static u8 __initdata inited;
 
 static irqreturn_t omap2_gp_timer_interrupt(int irq, void *dev_id)
 {
@@ -95,20 +102,53 @@ static struct clock_event_device clockevent_gpt = {
 	.set_mode	= omap2_gp_timer_set_mode,
 };
 
+/**
+ * omap2_gp_clockevent_set_gptimer - set which GPTIMER is used for clockevents
+ * @id: GPTIMER to use (1..MAX_GPTIMER_ID)
+ *
+ * Define the GPTIMER that the system should use for the tick timer.
+ * Meant to be called from board-*.c files in the event that GPTIMER1, the
+ * default, is unsuitable.  Returns -EINVAL on error or 0 on success.
+ */
+int __init omap2_gp_clockevent_set_gptimer(u8 id)
+{
+	if (id < 1 || id > MAX_GPTIMER_ID)
+		return -EINVAL;
+
+	BUG_ON(inited);
+
+	gptimer_id = id;
+
+	return 0;
+}
+
 static void __init omap2_gp_clockevent_init(void)
 {
 	u32 tick_rate;
+	int src;
+
+	inited = 1;
 
-	gptimer = omap_dm_timer_request_specific(1);
+	gptimer = omap_dm_timer_request_specific(gptimer_id);
 	BUG_ON(gptimer == NULL);
 
 #if defined(CONFIG_OMAP_32K_TIMER)
-	omap_dm_timer_set_source(gptimer, OMAP_TIMER_SRC_32_KHZ);
+	src = OMAP_TIMER_SRC_32_KHZ;
 #else
-	omap_dm_timer_set_source(gptimer, OMAP_TIMER_SRC_SYS_CLK);
+	src = OMAP_TIMER_SRC_SYS_CLK;
+	WARN(gptimer_id == 12, "WARNING: GPTIMER12 can only use the "
+	     "secure 32KiHz clock source\n");
 #endif
+
+	if (gptimer_id != 12)
+		WARN(IS_ERR_VALUE(omap_dm_timer_set_source(gptimer, src)),
+		     "timer-gp: omap_dm_timer_set_source() failed\n");
+
 	tick_rate = clk_get_rate(omap_dm_timer_get_fclk(gptimer));
 
+	pr_info("OMAP clockevent source: GPTIMER%d at %u Hz\n",
+		gptimer_id, tick_rate);
+
 	omap2_gp_timer_irq.dev_id = (void *)gptimer;
 	setup_irq(omap_dm_timer_get_irq(gptimer), &omap2_gp_timer_irq);
 	omap_dm_timer_set_int_enable(gptimer, OMAP_TIMER_INT_OVERFLOW);
@@ -125,6 +165,8 @@ static void __init omap2_gp_clockevent_init(void)
 	clockevents_register_device(&clockevent_gpt);
 }
 
+/* Clocksource code */
+
 #ifdef CONFIG_OMAP_32K_TIMER
 /* 
  * When 32k-timer is enabled, don't use GPTimer for clocksource
diff --git a/arch/arm/plat-omap/dmtimer.c b/arch/arm/plat-omap/dmtimer.c
index a05205c..55bb996 100644
--- a/arch/arm/plat-omap/dmtimer.c
+++ b/arch/arm/plat-omap/dmtimer.c
@@ -509,7 +509,7 @@ EXPORT_SYMBOL_GPL(omap_dm_timer_stop);
 
 #ifdef CONFIG_ARCH_OMAP1
 
-void omap_dm_timer_set_source(struct omap_dm_timer *timer, int source)
+int omap_dm_timer_set_source(struct omap_dm_timer *timer, int source)
 {
 	int n = (timer - dm_timers) << 1;
 	u32 l;
@@ -517,23 +517,31 @@ void omap_dm_timer_set_source(struct omap_dm_timer *timer, int source)
 	l = omap_readl(MOD_CONF_CTRL_1) & ~(0x03 << n);
 	l |= source << n;
 	omap_writel(l, MOD_CONF_CTRL_1);
+
+	return 0;
 }
 EXPORT_SYMBOL_GPL(omap_dm_timer_set_source);
 
 #else
 
-void omap_dm_timer_set_source(struct omap_dm_timer *timer, int source)
+int omap_dm_timer_set_source(struct omap_dm_timer *timer, int source)
 {
+	int ret = -EINVAL;
+
 	if (source < 0 || source >= 3)
-		return;
+		return -EINVAL;
 
 	clk_disable(timer->fclk);
-	clk_set_parent(timer->fclk, dm_source_clocks[source]);
+	ret = clk_set_parent(timer->fclk, dm_source_clocks[source]);
 	clk_enable(timer->fclk);
 
-	/* When the functional clock disappears, too quick writes seem to
-	 * cause an abort. */
+	/*
+	 * When the functional clock disappears, too quick writes seem
+	 * to cause an abort. XXX Is this still necessary?
+	 */
 	__delay(150000);
+
+	return ret;
 }
 EXPORT_SYMBOL_GPL(omap_dm_timer_set_source);
 
diff --git a/arch/arm/plat-omap/include/mach/dmtimer.h b/arch/arm/plat-omap/include/mach/dmtimer.h
index 6dc7031..20f1054 100644
--- a/arch/arm/plat-omap/include/mach/dmtimer.h
+++ b/arch/arm/plat-omap/include/mach/dmtimer.h
@@ -64,7 +64,7 @@ void omap_dm_timer_trigger(struct omap_dm_timer *timer);
 void omap_dm_timer_start(struct omap_dm_timer *timer);
 void omap_dm_timer_stop(struct omap_dm_timer *timer);
 
-void omap_dm_timer_set_source(struct omap_dm_timer *timer, int source);
+int omap_dm_timer_set_source(struct omap_dm_timer *timer, int source);
 void omap_dm_timer_set_load(struct omap_dm_timer *timer, int autoreload, unsigned int value);
 void omap_dm_timer_set_load_start(struct omap_dm_timer *timer, int autoreload, unsigned int value);
 void omap_dm_timer_set_match(struct omap_dm_timer *timer, int enable, unsigned int match);
diff --git a/arch/arm/plat-omap/include/mach/timer-gp.h b/arch/arm/plat-omap/include/mach/timer-gp.h
new file mode 100644
index 0000000..c88d346
--- /dev/null
+++ b/arch/arm/plat-omap/include/mach/timer-gp.h
@@ -0,0 +1,17 @@
+/*
+ * OMAP2/3 GPTIMER support.headers
+ *
+ * Copyright (C) 2009 Nokia Corporation
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+
+#ifndef __ARCH_ARM_PLAT_OMAP_INCLUDE_MACH_TIMER_GP_H
+#define __ARCH_ARM_PLAT_OMAP_INCLUDE_MACH_TIMER_GP_H
+
+int __init omap2_gp_clockevent_set_gptimer(u8 id);
+
+#endif
+



^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Re: [PATCH 1/7] OMAP24xx/25xx clock: init osc_ck, sys_ck internal lists early
  2009-04-14 18:23 ` [PATCH 1/7] OMAP2xxx clock: init osc_ck, sys_ck internal lists early Paul Walmsley
@ 2009-04-14 18:31   ` Paul Walmsley
  2009-04-14 18:37     ` Russell King - ARM Linux
  2009-04-21 19:54     ` Russell King - ARM Linux
  0 siblings, 2 replies; 23+ messages in thread
From: Paul Walmsley @ 2009-04-14 18:31 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: Russell King, linux-omap


Modifying subject line since lists.arm.linux.org.uk mail server bounces 
subjects containing "xxx".

- Paul

On Tue, 14 Apr 2009, Paul Walmsley wrote:

> Commit 3f0a820c4c0b4670fb5f164baa5582e23c2ef118 breaks OMAP2xxx boot
> during initial propagate_rate() on osc_ck and sys_ck.  Fix by calling
> clk_init_one() for these clocks first.
> 
> Resolves
> 
> <1>Unable to handle kernel NULL pointer dereference at virtual address 00000000
> <1>pgd = c0004000
> <1>[00000000] *pgd=00000000
> Internal error: Oops: 5 [#1]
> Modules linked in:
> CPU: 0    Not tainted  (2.6.29-omap1 #37)
> PC is at propagate_rate+0x10/0x60
> LR is at omap2_clk_init+0x30/0x218
> ...
> 
> Signed-off-by: Paul Walmsley <paul@pwsan.com>
> Tested-by: Jarkko Nikula <jarkko.nikula@nokia.com>
> Cc: Russell King <linux@arm.linux.org.uk>
> ---
>  arch/arm/mach-omap2/clock24xx.c |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/arm/mach-omap2/clock24xx.c b/arch/arm/mach-omap2/clock24xx.c
> index 1e839c5..3b7ecc6 100644
> --- a/arch/arm/mach-omap2/clock24xx.c
> +++ b/arch/arm/mach-omap2/clock24xx.c
> @@ -720,6 +720,8 @@ int __init omap2_clk_init(void)
>  
>  	clk_init(&omap2_clk_functions);
>  
> +	clk_init_one(&osc_ck);
> +	clk_init_one(&sys_ck);
>  	osc_ck.rate = omap2_osc_clk_recalc(&osc_ck);
>  	propagate_rate(&osc_ck);
>  	sys_ck.rate = omap2_sys_clk_recalc(&sys_ck);
> 
> 

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 2/7] OMAP24xx/OMAP25xx clock: fix broken cpu_mask code
  2009-04-14 18:23 ` [PATCH 2/7] OMAP2xxx clock: fix broken cpu_mask code Paul Walmsley
@ 2009-04-14 18:32   ` Paul Walmsley
  0 siblings, 0 replies; 23+ messages in thread
From: Paul Walmsley @ 2009-04-14 18:32 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: Russell King, linux-omap


Modifying subject line since lists.arm.linux.org.uk mail server bounces
subjects containing "xxx".

- Paul

On Tue, 14 Apr 2009, Paul Walmsley wrote:

> Commit 8ad8ff6548f1c0bcbeaa02f274b3927c5015a921 breaks the OMAP2xxx
> cpu_mask code, which causes OMAP2xxx to panic on boot.  Fix by
> removing the cpu_mask auto variable and by changing CK_242X
> and CK_243X to use RATE_IN_242X/RATE_IN_243X.
> 
> Resolves
> 
> <1>Unable to handle kernel NULL pointer dereference at virtual address 0000000c
> <1>pgd = c0004000
> <1>[0000000c] *pgd=00000000
> Internal error: Oops: 5 [#1]
> Modules linked in:
> CPU: 0    Not tainted  (2.6.29-omap1 #32)
> PC is at omap2_clk_set_parent+0x104/0x120
> LR is at omap2_clk_set_parent+0x28/0x120
> 
> Signed-off-by: Paul Walmsley <paul@pwsan.com>
> Tested-by: Jarkko Nikula <jarkko.nikula@nokia.com>
> Cc: Russell King <linux@arm.linux.org.uk>
> ---
>  arch/arm/mach-omap2/clock24xx.c |   12 +++---------
>  1 files changed, 3 insertions(+), 9 deletions(-)
> 
> diff --git a/arch/arm/mach-omap2/clock24xx.c b/arch/arm/mach-omap2/clock24xx.c
> index 3b7ecc6..4306392 100644
> --- a/arch/arm/mach-omap2/clock24xx.c
> +++ b/arch/arm/mach-omap2/clock24xx.c
> @@ -60,8 +60,8 @@ struct omap_clk {
>  		},			\
>  	}
>  
> -#define CK_243X	(1 << 0)
> -#define CK_242X	(1 << 1)
> +#define CK_243X			RATE_IN_243X
> +#define CK_242X			RATE_IN_242X
>  
>  static struct omap_clk omap24xx_clks[] = {
>  	/* external root sources */
> @@ -711,7 +711,7 @@ int __init omap2_clk_init(void)
>  {
>  	struct prcm_config *prcm;
>  	struct omap_clk *c;
> -	u32 clkrate, cpu_mask;
> +	u32 clkrate;
>  
>  	if (cpu_is_omap242x())
>  		cpu_mask = RATE_IN_242X;
> @@ -730,12 +730,6 @@ int __init omap2_clk_init(void)
>  	for (c = omap24xx_clks; c < omap24xx_clks + ARRAY_SIZE(omap24xx_clks); c++)
>  		clk_init_one(c->lk.clk);
>  
> -	cpu_mask = 0;
> -	if (cpu_is_omap2420())
> -		cpu_mask |= CK_242X;
> -	if (cpu_is_omap2430())
> -		cpu_mask |= CK_243X;
> -
>  	for (c = omap24xx_clks; c < omap24xx_clks + ARRAY_SIZE(omap24xx_clks); c++)
>  		if (c->cpu & cpu_mask) {
>  			clkdev_add(&c->lk);
> 
> 


- Paul

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 1/7] OMAP24xx/25xx clock: init osc_ck, sys_ck internal lists early
  2009-04-14 18:31   ` [PATCH 1/7] OMAP24xx/25xx " Paul Walmsley
@ 2009-04-14 18:37     ` Russell King - ARM Linux
  2009-04-21 19:54     ` Russell King - ARM Linux
  1 sibling, 0 replies; 23+ messages in thread
From: Russell King - ARM Linux @ 2009-04-14 18:37 UTC (permalink / raw)
  To: Paul Walmsley; +Cc: linux-arm-kernel, linux-omap

On Tue, Apr 14, 2009 at 12:31:47PM -0600, Paul Walmsley wrote:
> Modifying subject line since lists.arm.linux.org.uk mail server bounces 
> subjects containing "xxx".

And quite rightly too.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 7/7] OMAP2/3 GPTIMER: allow system tick GPTIMER to be changed in board-*.c files
  2009-04-14 18:23 ` [PATCH 7/7] OMAP2/3 GPTIMER: allow system tick GPTIMER to be changed in board-*.c files Paul Walmsley
@ 2009-04-14 21:45   ` Tony Lindgren
  0 siblings, 0 replies; 23+ messages in thread
From: Tony Lindgren @ 2009-04-14 21:45 UTC (permalink / raw)
  To: Paul Walmsley; +Cc: linux-arm-kernel, linux-omap

* Paul Walmsley <paul@pwsan.com> [090414 11:27]:
> Add a function omap2_gp_clockevent_set_gptimer() for board-*.c files
> to use in .init_irq functions to configure the system tick GPTIMER.
> Practical choices at this point are GPTIMER1 or GPTIMER12.  Both of
> these timers are in the WKUP powerdomain, and so are unaffected by
> chip power management.  GPTIMER1 can use sys_clk as a source, for
> applications where a high-resolution timer is more important than
> power management.  GPTIMER12 has the special property that it has the
> secure 32kHz oscillator as its source clock, which may be less prone
> to glitches than the off-chip 32kHz oscillator.  But on HS devices, it
> may not be available for Linux use.
> 
> It appears that most boards are fine with GPTIMER1, but BeagleBoard
> should use GPTIMER12 when using a 32KiHz timer source, due to hardware bugs
> in revisions B4 and below.  Modify board-omap3beagle.c to use GPTIMER12.
> 
> This patch originally used a Kbuild config option to select the GPTIMER,
> but was changed to allow this to be specified in board-*.c files, per
> Tony's request.
> 
> Tested on Beagle rev B4 ES2.1, with and without CONFIG_OMAP_32K_TIMER, and
> 3430SDP.

Although this adds new code, it would be nice to merge this during the
-rc cycle as it fixes an issue on quite a few boards out there.

Without this fix a large number of Beagle boards will eventually hang with
no timer interrupts happening.

Tony

 
> Signed-off-by: Paul Walmsley <paul@pwsan.com>
> Signed-off-by: Tony Lindgren <tony@atomide.com>
> ---
>  arch/arm/mach-omap2/board-omap3beagle.c    |    4 ++
>  arch/arm/mach-omap2/clock24xx.c            |    1 +
>  arch/arm/mach-omap2/clock24xx.h            |   10 +++++-
>  arch/arm/mach-omap2/clock34xx.h            |    1 -
>  arch/arm/mach-omap2/timer-gp.c             |   48 ++++++++++++++++++++++++++--
>  arch/arm/plat-omap/dmtimer.c               |   20 ++++++++----
>  arch/arm/plat-omap/include/mach/dmtimer.h  |    2 +
>  arch/arm/plat-omap/include/mach/timer-gp.h |   17 ++++++++++
>  8 files changed, 91 insertions(+), 12 deletions(-)
>  create mode 100644 arch/arm/plat-omap/include/mach/timer-gp.h
> 
> diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
> index 744740a..3a7a29d 100644
> --- a/arch/arm/mach-omap2/board-omap3beagle.c
> +++ b/arch/arm/mach-omap2/board-omap3beagle.c
> @@ -42,6 +42,7 @@
>  #include <mach/nand.h>
>  #include <mach/mux.h>
>  #include <mach/usb.h>
> +#include <mach/timer-gp.h>
>  
>  #include "mmc-twl4030.h"
>  
> @@ -186,6 +187,9 @@ static void __init omap3_beagle_init_irq(void)
>  {
>  	omap2_init_common_hw(NULL);
>  	omap_init_irq();
> +#ifdef CONFIG_OMAP_32K_TIMER
> +	omap2_gp_clockevent_set_gptimer(12);
> +#endif
>  	omap_gpio_init();
>  }
>  
> diff --git a/arch/arm/mach-omap2/clock24xx.c b/arch/arm/mach-omap2/clock24xx.c
> index 4306392..fa2bd09 100644
> --- a/arch/arm/mach-omap2/clock24xx.c
> +++ b/arch/arm/mach-omap2/clock24xx.c
> @@ -66,6 +66,7 @@ struct omap_clk {
>  static struct omap_clk omap24xx_clks[] = {
>  	/* external root sources */
>  	CLK(NULL,	"func_32k_ck",	&func_32k_ck,	CK_243X | CK_242X),
> +	CLK(NULL,	"secure_32k_ck", &secure_32k_ck, CK_243X | CK_242X),
>  	CLK(NULL,	"osc_ck",	&osc_ck,	CK_243X | CK_242X),
>  	CLK(NULL,	"sys_ck",	&sys_ck,	CK_243X | CK_242X),
>  	CLK(NULL,	"alt_ck",	&alt_ck,	CK_243X | CK_242X),
> diff --git a/arch/arm/mach-omap2/clock24xx.h b/arch/arm/mach-omap2/clock24xx.h
> index 33c3e5b..72003f7 100644
> --- a/arch/arm/mach-omap2/clock24xx.h
> +++ b/arch/arm/mach-omap2/clock24xx.h
> @@ -625,6 +625,14 @@ static struct clk func_32k_ck = {
>  	.clkdm_name	= "wkup_clkdm",
>  };
>  
> +static struct clk secure_32k_fck = {
> +	.name		= "secure_32k_fck",
> +	.ops		= &clkops_null,
> +	.rate		= 32768,
> +	.flags		= RATE_FIXED,
> +	.clkdm_name	= "wkup_clkdm",
> +};
> +
>  /* Typical 12/13MHz in standalone mode, will be 26Mhz in chassis mode */
>  static struct clk osc_ck = {		/* (*12, *13, 19.2, *26, 38.4)MHz */
>  	.name		= "osc_ck",
> @@ -1790,7 +1798,7 @@ static struct clk gpt12_ick = {
>  static struct clk gpt12_fck = {
>  	.name		= "gpt12_fck",
>  	.ops		= &clkops_omap2_dflt_wait,
> -	.parent		= &func_32k_ck,
> +	.parent		= &secure_32k_ck,
>  	.clkdm_name	= "core_l4_clkdm",
>  	.enable_reg	= OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1),
>  	.enable_bit	= OMAP24XX_EN_GPT12_SHIFT,
> diff --git a/arch/arm/mach-omap2/clock34xx.h b/arch/arm/mach-omap2/clock34xx.h
> index f009017..6763b8f 100644
> --- a/arch/arm/mach-omap2/clock34xx.h
> +++ b/arch/arm/mach-omap2/clock34xx.h
> @@ -2901,7 +2901,6 @@ static struct clk sr_l4_ick = {
>  
>  /* SECURE_32K_FCK clocks */
>  
> -/* XXX This clock no longer exists in 3430 TRM rev F */
>  static struct clk gpt12_fck = {
>  	.name		= "gpt12_fck",
>  	.ops		= &clkops_null,
> diff --git a/arch/arm/mach-omap2/timer-gp.c b/arch/arm/mach-omap2/timer-gp.c
> index 9fc13a2..7835048 100644
> --- a/arch/arm/mach-omap2/timer-gp.c
> +++ b/arch/arm/mach-omap2/timer-gp.c
> @@ -3,6 +3,8 @@
>   *
>   * OMAP2 GP timer support.
>   *
> + * Copyright (C) 2009 Nokia Corporation
> + *
>   * Update to use new clocksource/clockevent layers
>   * Author: Kevin Hilman, MontaVista Software, Inc. <source@mvista.com>
>   * Copyright (C) 2007 MontaVista Software, Inc.
> @@ -36,8 +38,13 @@
>  #include <asm/mach/time.h>
>  #include <mach/dmtimer.h>
>  
> +/* MAX_GPTIMER_ID: number of GPTIMERs on the chip */
> +#define MAX_GPTIMER_ID		12
> +
>  static struct omap_dm_timer *gptimer;
>  static struct clock_event_device clockevent_gpt;
> +static u8 __initdata gptimer_id = 1;
> +static u8 __initdata inited;
>  
>  static irqreturn_t omap2_gp_timer_interrupt(int irq, void *dev_id)
>  {
> @@ -95,20 +102,53 @@ static struct clock_event_device clockevent_gpt = {
>  	.set_mode	= omap2_gp_timer_set_mode,
>  };
>  
> +/**
> + * omap2_gp_clockevent_set_gptimer - set which GPTIMER is used for clockevents
> + * @id: GPTIMER to use (1..MAX_GPTIMER_ID)
> + *
> + * Define the GPTIMER that the system should use for the tick timer.
> + * Meant to be called from board-*.c files in the event that GPTIMER1, the
> + * default, is unsuitable.  Returns -EINVAL on error or 0 on success.
> + */
> +int __init omap2_gp_clockevent_set_gptimer(u8 id)
> +{
> +	if (id < 1 || id > MAX_GPTIMER_ID)
> +		return -EINVAL;
> +
> +	BUG_ON(inited);
> +
> +	gptimer_id = id;
> +
> +	return 0;
> +}
> +
>  static void __init omap2_gp_clockevent_init(void)
>  {
>  	u32 tick_rate;
> +	int src;
> +
> +	inited = 1;
>  
> -	gptimer = omap_dm_timer_request_specific(1);
> +	gptimer = omap_dm_timer_request_specific(gptimer_id);
>  	BUG_ON(gptimer == NULL);
>  
>  #if defined(CONFIG_OMAP_32K_TIMER)
> -	omap_dm_timer_set_source(gptimer, OMAP_TIMER_SRC_32_KHZ);
> +	src = OMAP_TIMER_SRC_32_KHZ;
>  #else
> -	omap_dm_timer_set_source(gptimer, OMAP_TIMER_SRC_SYS_CLK);
> +	src = OMAP_TIMER_SRC_SYS_CLK;
> +	WARN(gptimer_id == 12, "WARNING: GPTIMER12 can only use the "
> +	     "secure 32KiHz clock source\n");
>  #endif
> +
> +	if (gptimer_id != 12)
> +		WARN(IS_ERR_VALUE(omap_dm_timer_set_source(gptimer, src)),
> +		     "timer-gp: omap_dm_timer_set_source() failed\n");
> +
>  	tick_rate = clk_get_rate(omap_dm_timer_get_fclk(gptimer));
>  
> +	pr_info("OMAP clockevent source: GPTIMER%d at %u Hz\n",
> +		gptimer_id, tick_rate);
> +
>  	omap2_gp_timer_irq.dev_id = (void *)gptimer;
>  	setup_irq(omap_dm_timer_get_irq(gptimer), &omap2_gp_timer_irq);
>  	omap_dm_timer_set_int_enable(gptimer, OMAP_TIMER_INT_OVERFLOW);
> @@ -125,6 +165,8 @@ static void __init omap2_gp_clockevent_init(void)
>  	clockevents_register_device(&clockevent_gpt);
>  }
>  
> +/* Clocksource code */
> +
>  #ifdef CONFIG_OMAP_32K_TIMER
>  /* 
>   * When 32k-timer is enabled, don't use GPTimer for clocksource
> diff --git a/arch/arm/plat-omap/dmtimer.c b/arch/arm/plat-omap/dmtimer.c
> index a05205c..55bb996 100644
> --- a/arch/arm/plat-omap/dmtimer.c
> +++ b/arch/arm/plat-omap/dmtimer.c
> @@ -509,7 +509,7 @@ EXPORT_SYMBOL_GPL(omap_dm_timer_stop);
>  
>  #ifdef CONFIG_ARCH_OMAP1
>  
> -void omap_dm_timer_set_source(struct omap_dm_timer *timer, int source)
> +int omap_dm_timer_set_source(struct omap_dm_timer *timer, int source)
>  {
>  	int n = (timer - dm_timers) << 1;
>  	u32 l;
> @@ -517,23 +517,31 @@ void omap_dm_timer_set_source(struct omap_dm_timer *timer, int source)
>  	l = omap_readl(MOD_CONF_CTRL_1) & ~(0x03 << n);
>  	l |= source << n;
>  	omap_writel(l, MOD_CONF_CTRL_1);
> +
> +	return 0;
>  }
>  EXPORT_SYMBOL_GPL(omap_dm_timer_set_source);
>  
>  #else
>  
> -void omap_dm_timer_set_source(struct omap_dm_timer *timer, int source)
> +int omap_dm_timer_set_source(struct omap_dm_timer *timer, int source)
>  {
> +	int ret = -EINVAL;
> +
>  	if (source < 0 || source >= 3)
> -		return;
> +		return -EINVAL;
>  
>  	clk_disable(timer->fclk);
> -	clk_set_parent(timer->fclk, dm_source_clocks[source]);
> +	ret = clk_set_parent(timer->fclk, dm_source_clocks[source]);
>  	clk_enable(timer->fclk);
>  
> -	/* When the functional clock disappears, too quick writes seem to
> -	 * cause an abort. */
> +	/*
> +	 * When the functional clock disappears, too quick writes seem
> +	 * to cause an abort. XXX Is this still necessary?
> +	 */
>  	__delay(150000);
> +
> +	return ret;
>  }
>  EXPORT_SYMBOL_GPL(omap_dm_timer_set_source);
>  
> diff --git a/arch/arm/plat-omap/include/mach/dmtimer.h b/arch/arm/plat-omap/include/mach/dmtimer.h
> index 6dc7031..20f1054 100644
> --- a/arch/arm/plat-omap/include/mach/dmtimer.h
> +++ b/arch/arm/plat-omap/include/mach/dmtimer.h
> @@ -64,7 +64,7 @@ void omap_dm_timer_trigger(struct omap_dm_timer *timer);
>  void omap_dm_timer_start(struct omap_dm_timer *timer);
>  void omap_dm_timer_stop(struct omap_dm_timer *timer);
>  
> -void omap_dm_timer_set_source(struct omap_dm_timer *timer, int source);
> +int omap_dm_timer_set_source(struct omap_dm_timer *timer, int source);
>  void omap_dm_timer_set_load(struct omap_dm_timer *timer, int autoreload, unsigned int value);
>  void omap_dm_timer_set_load_start(struct omap_dm_timer *timer, int autoreload, unsigned int value);
>  void omap_dm_timer_set_match(struct omap_dm_timer *timer, int enable, unsigned int match);
> diff --git a/arch/arm/plat-omap/include/mach/timer-gp.h b/arch/arm/plat-omap/include/mach/timer-gp.h
> new file mode 100644
> index 0000000..c88d346
> --- /dev/null
> +++ b/arch/arm/plat-omap/include/mach/timer-gp.h
> @@ -0,0 +1,17 @@
> +/*
> + * OMAP2/3 GPTIMER support.headers
> + *
> + * Copyright (C) 2009 Nokia Corporation
> + *
> + * This file is subject to the terms and conditions of the GNU General Public
> + * License. See the file "COPYING" in the main directory of this archive
> + * for more details.
> + */
> +
> +#ifndef __ARCH_ARM_PLAT_OMAP_INCLUDE_MACH_TIMER_GP_H
> +#define __ARCH_ARM_PLAT_OMAP_INCLUDE_MACH_TIMER_GP_H
> +
> +int __init omap2_gp_clockevent_set_gptimer(u8 id);
> +
> +#endif
> +
> 
> 

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 1/7] OMAP24xx/25xx clock: init osc_ck, sys_ck internal lists early
  2009-04-14 18:31   ` [PATCH 1/7] OMAP24xx/25xx " Paul Walmsley
  2009-04-14 18:37     ` Russell King - ARM Linux
@ 2009-04-21 19:54     ` Russell King - ARM Linux
  2009-04-23  2:01       ` Paul Walmsley
  1 sibling, 1 reply; 23+ messages in thread
From: Russell King - ARM Linux @ 2009-04-21 19:54 UTC (permalink / raw)
  To: Paul Walmsley; +Cc: linux-arm-kernel, linux-omap

On Tue, Apr 14, 2009 at 12:31:47PM -0600, Paul Walmsley wrote:
> On Tue, 14 Apr 2009, Paul Walmsley wrote:
> > Commit 3f0a820c4c0b4670fb5f164baa5582e23c2ef118 breaks OMAP2xxx boot
> > during initial propagate_rate() on osc_ck and sys_ck.  Fix by calling
> > clk_init_one() for these clocks first.

A better fix would be to move the loop initializing all clocks to be
immediately after the call to clk_init().

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 1/7] OMAP24xx/25xx clock: init osc_ck, sys_ck internal lists early
  2009-04-21 19:54     ` Russell King - ARM Linux
@ 2009-04-23  2:01       ` Paul Walmsley
  2009-04-23  7:53         ` Russell King - ARM Linux
  0 siblings, 1 reply; 23+ messages in thread
From: Paul Walmsley @ 2009-04-23  2:01 UTC (permalink / raw)
  To: Russell King - ARM Linux; +Cc: linux-arm-kernel, linux-omap

Hello Russell,

On Tue, 21 Apr 2009, Russell King - ARM Linux wrote:

> On Tue, Apr 14, 2009 at 12:31:47PM -0600, Paul Walmsley wrote:
> > On Tue, 14 Apr 2009, Paul Walmsley wrote:
> > > Commit 3f0a820c4c0b4670fb5f164baa5582e23c2ef118 breaks OMAP2xxx boot
> > > during initial propagate_rate() on osc_ck and sys_ck.  Fix by calling
> > > clk_init_one() for these clocks first.
> 
> A better fix would be to move the loop initializing all clocks to be
> immediately after the call to clk_init().

thanks for the comment.  Here's a revised patch:


- Paul

From: Paul Walmsley <paul@pwsan.com>
Date: Wed, 22 Apr 2009 19:48:53 -0600
Subject: [PATCH] OMAP2xxx clock: pre-initialize struct clks early

Commit 3f0a820c4c0b4670fb5f164baa5582e23c2ef118 breaks OMAP2xxx boot
during initial propagate_rate() on osc_ck and sys_ck.  Fix by
pre-initializing all struct clks before running any other clock init
code.  The patch also renames clk_init_one() to clk_preinit() to
distinguish its function from clk_init() and the individual struct clk
init functions.  Incorporates review comments from Russell King
<linux@arm.linux.org.uk>.

Resolves

<1>Unable to handle kernel NULL pointer dereference at virtual address 00000000
<1>pgd = c0004000
<1>[00000000] *pgd=00000000
Internal error: Oops: 5 [#1]
Modules linked in:
CPU: 0    Not tainted  (2.6.29-omap1 #37)
PC is at propagate_rate+0x10/0x60
LR is at omap2_clk_init+0x30/0x218
...

Signed-off-by: Paul Walmsley <paul@pwsan.com>
Tested-by: Jarkko Nikula <jarkko.nikula@nokia.com>
Cc: Russell King <linux@arm.linux.org.uk>
---
 arch/arm/mach-omap1/clock.c             |    2 +-
 arch/arm/mach-omap2/clock24xx.c         |    6 +++---
 arch/arm/mach-omap2/clock34xx.c         |    2 +-
 arch/arm/plat-omap/clock.c              |    9 ++++++++-
 arch/arm/plat-omap/include/mach/clock.h |    2 +-
 5 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/arch/arm/mach-omap1/clock.c b/arch/arm/mach-omap1/clock.c
index dafe4f7..571d33d 100644
--- a/arch/arm/mach-omap1/clock.c
+++ b/arch/arm/mach-omap1/clock.c
@@ -775,7 +775,7 @@ int __init omap1_clk_init(void)
 	arm_idlect1_mask = ~0;
 
 	for (c = omap_clks; c < omap_clks + ARRAY_SIZE(omap_clks); c++)
-		clk_init_one(c->lk.clk);
+		clk_preinit(c->lk.clk);
 
 	cpu_mask = 0;
 	if (cpu_is_omap16xx())
diff --git a/arch/arm/mach-omap2/clock24xx.c b/arch/arm/mach-omap2/clock24xx.c
index 1e839c5..61dcc22 100644
--- a/arch/arm/mach-omap2/clock24xx.c
+++ b/arch/arm/mach-omap2/clock24xx.c
@@ -720,14 +720,14 @@ int __init omap2_clk_init(void)
 
 	clk_init(&omap2_clk_functions);
 
+	for (c = omap24xx_clks; c < omap24xx_clks + ARRAY_SIZE(omap24xx_clks); c++)
+		clk_preinit(c->lk.clk);
+
 	osc_ck.rate = omap2_osc_clk_recalc(&osc_ck);
 	propagate_rate(&osc_ck);
 	sys_ck.rate = omap2_sys_clk_recalc(&sys_ck);
 	propagate_rate(&sys_ck);
 
-	for (c = omap24xx_clks; c < omap24xx_clks + ARRAY_SIZE(omap24xx_clks); c++)
-		clk_init_one(c->lk.clk);
-
 	cpu_mask = 0;
 	if (cpu_is_omap2420())
 		cpu_mask |= CK_242X;
diff --git a/arch/arm/mach-omap2/clock34xx.c b/arch/arm/mach-omap2/clock34xx.c
index 0a14dca..430c6a0 100644
--- a/arch/arm/mach-omap2/clock34xx.c
+++ b/arch/arm/mach-omap2/clock34xx.c
@@ -956,7 +956,7 @@ int __init omap2_clk_init(void)
 	clk_init(&omap2_clk_functions);
 
 	for (c = omap34xx_clks; c < omap34xx_clks + ARRAY_SIZE(omap34xx_clks); c++)
-		clk_init_one(c->lk.clk);
+		clk_preinit(c->lk.clk);
 
 	for (c = omap34xx_clks; c < omap34xx_clks + ARRAY_SIZE(omap34xx_clks); c++)
 		if (c->cpu & cpu_clkflg) {
diff --git a/arch/arm/plat-omap/clock.c b/arch/arm/plat-omap/clock.c
index 2e06145..508c96a 100644
--- a/arch/arm/plat-omap/clock.c
+++ b/arch/arm/plat-omap/clock.c
@@ -239,7 +239,14 @@ void recalculate_root_clocks(void)
 	}
 }
 
-void clk_init_one(struct clk *clk)
+/**
+ * clk_preinit - initialize any fields in the struct clk before clk init
+ * @clk: struct clk * to initialize
+ *
+ * Initialize any struct clk fields needed before normal clk initialization
+ * can run.  No return value.
+ */
+void clk_preinit(struct clk *clk)
 {
 	INIT_LIST_HEAD(&clk->children);
 }
diff --git a/arch/arm/plat-omap/include/mach/clock.h b/arch/arm/plat-omap/include/mach/clock.h
index 073a2c5..793fbc0 100644
--- a/arch/arm/plat-omap/include/mach/clock.h
+++ b/arch/arm/plat-omap/include/mach/clock.h
@@ -118,8 +118,8 @@ struct clk_functions {
 
 extern unsigned int mpurate;
 
+extern void clk_preinit(struct clk *clk);
 extern int clk_init(struct clk_functions *custom_clocks);
-extern void clk_init_one(struct clk *clk);
 extern int clk_register(struct clk *clk);
 extern void clk_reparent(struct clk *child, struct clk *parent);
 extern void clk_unregister(struct clk *clk);
-- 
1.6.2.1.307.g91408


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Re: [PATCH 1/7] OMAP24xx/25xx clock: init osc_ck, sys_ck internal lists early
  2009-04-23  2:01       ` Paul Walmsley
@ 2009-04-23  7:53         ` Russell King - ARM Linux
  2009-04-23  8:32           ` Paul Walmsley
  0 siblings, 1 reply; 23+ messages in thread
From: Russell King - ARM Linux @ 2009-04-23  7:53 UTC (permalink / raw)
  To: Paul Walmsley; +Cc: linux-arm-kernel, linux-omap

On Wed, Apr 22, 2009 at 08:01:29PM -0600, Paul Walmsley wrote:
> The patch also renames clk_init_one() to clk_preinit() to
> distinguish its function from clk_init() and the individual struct clk
> init functions.

That's rather unnecessary.  'clk_init_one' is already unique.  In the
long run, it's clk_init that needs to go.

>  Incorporates review comments from Russell King
> <linux@arm.linux.org.uk>.

Please don't add this email address to git commit comments.  Thanks.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 1/7] OMAP24xx/25xx clock: init osc_ck, sys_ck internal lists early
  2009-04-23  7:53         ` Russell King - ARM Linux
@ 2009-04-23  8:32           ` Paul Walmsley
  2009-04-23 18:00             ` Tony Lindgren
  0 siblings, 1 reply; 23+ messages in thread
From: Paul Walmsley @ 2009-04-23  8:32 UTC (permalink / raw)
  To: Russell King - ARM Linux; +Cc: linux-arm-kernel, linux-omap

Hello Russell,

On Thu, 23 Apr 2009, Russell King - ARM Linux wrote:

> On Wed, Apr 22, 2009 at 08:01:29PM -0600, Paul Walmsley wrote:
> > The patch also renames clk_init_one() to clk_preinit() to
> > distinguish its function from clk_init() and the individual struct clk
> > init functions.
> 
> That's rather unnecessary.  'clk_init_one' is already unique.  In the
> long run, it's clk_init that needs to go.

Even if clk_init() were to disappear, the struct clk .init function 
pointer would still be present.  clk->init() performs a very different 
kind of initialization than clk_init_one().

> >  Incorporates review comments from Russell King
> > <linux@arm.linux.org.uk>.
> 
> Please don't add this email address to git commit comments.  Thanks.

Updated in the git branch to rmk+kernel.


- Paul

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 1/7] OMAP24xx/25xx clock: init osc_ck, sys_ck internal lists early
  2009-04-23  8:32           ` Paul Walmsley
@ 2009-04-23 18:00             ` Tony Lindgren
  2009-04-23 22:26               ` Russell King - ARM Linux
  0 siblings, 1 reply; 23+ messages in thread
From: Tony Lindgren @ 2009-04-23 18:00 UTC (permalink / raw)
  To: Paul Walmsley; +Cc: Russell King - ARM Linux, linux-arm-kernel, linux-omap

* Paul Walmsley <paul@pwsan.com> [090423 01:35]:
> Hello Russell,
> 
> On Thu, 23 Apr 2009, Russell King - ARM Linux wrote:
> 
> > On Wed, Apr 22, 2009 at 08:01:29PM -0600, Paul Walmsley wrote:
> > > The patch also renames clk_init_one() to clk_preinit() to
> > > distinguish its function from clk_init() and the individual struct clk
> > > init functions.
> > 
> > That's rather unnecessary.  'clk_init_one' is already unique.  In the
> > long run, it's clk_init that needs to go.
> 
> Even if clk_init() were to disappear, the struct clk .init function 
> pointer would still be present.  clk->init() performs a very different 
> kind of initialization than clk_init_one().

I'm OK doing the rename in this fix. The original naming can cause
confusion while reading the code.

Tony
 
> > >  Incorporates review comments from Russell King
> > > <linux@arm.linux.org.uk>.
> > 
> > Please don't add this email address to git commit comments.  Thanks.
> 
> Updated in the git branch to rmk+kernel.
> 
> 
> - Paul

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 1/7] OMAP24xx/25xx clock: init osc_ck, sys_ck internal lists early
  2009-04-23 18:00             ` Tony Lindgren
@ 2009-04-23 22:26               ` Russell King - ARM Linux
  2009-04-23 23:55                 ` Tony Lindgren
  0 siblings, 1 reply; 23+ messages in thread
From: Russell King - ARM Linux @ 2009-04-23 22:26 UTC (permalink / raw)
  To: Tony Lindgren; +Cc: Paul Walmsley, linux-arm-kernel, linux-omap

On Thu, Apr 23, 2009 at 11:00:31AM -0700, Tony Lindgren wrote:
> * Paul Walmsley <paul@pwsan.com> [090423 01:35]:
> > Hello Russell,
> > 
> > On Thu, 23 Apr 2009, Russell King - ARM Linux wrote:
> > 
> > > On Wed, Apr 22, 2009 at 08:01:29PM -0600, Paul Walmsley wrote:
> > > > The patch also renames clk_init_one() to clk_preinit() to
> > > > distinguish its function from clk_init() and the individual struct clk
> > > > init functions.
> > > 
> > > That's rather unnecessary.  'clk_init_one' is already unique.  In the
> > > long run, it's clk_init that needs to go.
> > 
> > Even if clk_init() were to disappear, the struct clk .init function 
> > pointer would still be present.  clk->init() performs a very different 
> > kind of initialization than clk_init_one().
> 
> I'm OK doing the rename in this fix. The original naming can cause
> confusion while reading the code.

Well I'm not, and I want to discuss it some more.  And I'm sending Linus
a pull request tonight, so I'm dropping the OMAP stuff from that.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 1/7] OMAP24xx/25xx clock: init osc_ck, sys_ck internal lists early
  2009-04-23 22:26               ` Russell King - ARM Linux
@ 2009-04-23 23:55                 ` Tony Lindgren
  2009-04-24  3:13                   ` Paul Walmsley
  0 siblings, 1 reply; 23+ messages in thread
From: Tony Lindgren @ 2009-04-23 23:55 UTC (permalink / raw)
  To: Russell King - ARM Linux; +Cc: Paul Walmsley, linux-arm-kernel, linux-omap

* Russell King - ARM Linux <linux@arm.linux.org.uk> [090423 15:26]:
> On Thu, Apr 23, 2009 at 11:00:31AM -0700, Tony Lindgren wrote:
> > * Paul Walmsley <paul@pwsan.com> [090423 01:35]:
> > > Hello Russell,
> > > 
> > > On Thu, 23 Apr 2009, Russell King - ARM Linux wrote:
> > > 
> > > > On Wed, Apr 22, 2009 at 08:01:29PM -0600, Paul Walmsley wrote:
> > > > > The patch also renames clk_init_one() to clk_preinit() to
> > > > > distinguish its function from clk_init() and the individual struct clk
> > > > > init functions.
> > > > 
> > > > That's rather unnecessary.  'clk_init_one' is already unique.  In the
> > > > long run, it's clk_init that needs to go.
> > > 
> > > Even if clk_init() were to disappear, the struct clk .init function 
> > > pointer would still be present.  clk->init() performs a very different 
> > > kind of initialization than clk_init_one().
> > 
> > I'm OK doing the rename in this fix. The original naming can cause
> > confusion while reading the code.
> 
> Well I'm not, and I want to discuss it some more.  And I'm sending Linus
> a pull request tonight, so I'm dropping the OMAP stuff from that.

OK. Paul, can you please separate out the rename part into a separate
patch so we only have a minimal fix & then repost it here?

That way we'll get the necessary fixes in and you guys can schedule
other changes for next merge window.

Thanks,

Tony

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 1/7] OMAP24xx/25xx clock: init osc_ck, sys_ck internal lists early
  2009-04-23 23:55                 ` Tony Lindgren
@ 2009-04-24  3:13                   ` Paul Walmsley
  2009-04-24  5:23                     ` Tony Lindgren
  0 siblings, 1 reply; 23+ messages in thread
From: Paul Walmsley @ 2009-04-24  3:13 UTC (permalink / raw)
  To: Tony Lindgren; +Cc: Russell King - ARM Linux, linux-arm-kernel, linux-omap

On Thu, 23 Apr 2009, Tony Lindgren wrote:

> * Russell King - ARM Linux <linux@arm.linux.org.uk> [090423 15:26]:
> > On Thu, Apr 23, 2009 at 11:00:31AM -0700, Tony Lindgren wrote:
> > > * Paul Walmsley <paul@pwsan.com> [090423 01:35]:
> > > > Hello Russell,
> > > > 
> > > > On Thu, 23 Apr 2009, Russell King - ARM Linux wrote:
> > > > 
> > > > > On Wed, Apr 22, 2009 at 08:01:29PM -0600, Paul Walmsley wrote:
> > > > > > The patch also renames clk_init_one() to clk_preinit() to
> > > > > > distinguish its function from clk_init() and the individual struct clk
> > > > > > init functions.
> > > > > 
> > > > > That's rather unnecessary.  'clk_init_one' is already unique.  In the
> > > > > long run, it's clk_init that needs to go.
> > > > 
> > > > Even if clk_init() were to disappear, the struct clk .init function 
> > > > pointer would still be present.  clk->init() performs a very different 
> > > > kind of initialization than clk_init_one().
> > > 
> > > I'm OK doing the rename in this fix. The original naming can cause
> > > confusion while reading the code.
> > 
> > Well I'm not, and I want to discuss it some more.  And I'm sending Linus
> > a pull request tonight, so I'm dropping the OMAP stuff from that.
> 
> OK. Paul, can you please separate out the rename part into a separate
> patch so we only have a minimal fix & then repost it here?
> 
> That way we'll get the necessary fixes in and you guys can schedule
> other changes for next merge window.

The omap-clock-fixes branch has been updated to remove the rename.

Not that this should stop the discussion, but at least this should no 
longer prevent these needed fixes from going upstream.


- Paul

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 1/7] OMAP24xx/25xx clock: init osc_ck, sys_ck internal lists early
  2009-04-24  3:13                   ` Paul Walmsley
@ 2009-04-24  5:23                     ` Tony Lindgren
  2009-04-24  6:29                       ` Paul Walmsley
  0 siblings, 1 reply; 23+ messages in thread
From: Tony Lindgren @ 2009-04-24  5:23 UTC (permalink / raw)
  To: Paul Walmsley; +Cc: Russell King - ARM Linux, linux-arm-kernel, linux-omap

* Paul Walmsley <paul@pwsan.com> [090423 20:13]:
> On Thu, 23 Apr 2009, Tony Lindgren wrote:
> 
> > * Russell King - ARM Linux <linux@arm.linux.org.uk> [090423 15:26]:
> > > On Thu, Apr 23, 2009 at 11:00:31AM -0700, Tony Lindgren wrote:
> > > > * Paul Walmsley <paul@pwsan.com> [090423 01:35]:
> > > > > Hello Russell,
> > > > > 
> > > > > On Thu, 23 Apr 2009, Russell King - ARM Linux wrote:
> > > > > 
> > > > > > On Wed, Apr 22, 2009 at 08:01:29PM -0600, Paul Walmsley wrote:
> > > > > > > The patch also renames clk_init_one() to clk_preinit() to
> > > > > > > distinguish its function from clk_init() and the individual struct clk
> > > > > > > init functions.
> > > > > > 
> > > > > > That's rather unnecessary.  'clk_init_one' is already unique.  In the
> > > > > > long run, it's clk_init that needs to go.
> > > > > 
> > > > > Even if clk_init() were to disappear, the struct clk .init function 
> > > > > pointer would still be present.  clk->init() performs a very different 
> > > > > kind of initialization than clk_init_one().
> > > > 
> > > > I'm OK doing the rename in this fix. The original naming can cause
> > > > confusion while reading the code.
> > > 
> > > Well I'm not, and I want to discuss it some more.  And I'm sending Linus
> > > a pull request tonight, so I'm dropping the OMAP stuff from that.
> > 
> > OK. Paul, can you please separate out the rename part into a separate
> > patch so we only have a minimal fix & then repost it here?
> > 
> > That way we'll get the necessary fixes in and you guys can schedule
> > other changes for next merge window.
> 
> The omap-clock-fixes branch has been updated to remove the rename.
> 
> Not that this should stop the discussion, but at least this should no 
> longer prevent these needed fixes from going upstream.

Care to post the updated patch here too? Temporay git branches are 
not too readable by most people..

Tony

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 1/7] OMAP24xx/25xx clock: init osc_ck, sys_ck internal lists early
  2009-04-24  5:23                     ` Tony Lindgren
@ 2009-04-24  6:29                       ` Paul Walmsley
  2009-04-24 17:51                         ` Tony Lindgren
  0 siblings, 1 reply; 23+ messages in thread
From: Paul Walmsley @ 2009-04-24  6:29 UTC (permalink / raw)
  To: Tony Lindgren; +Cc: Russell King - ARM Linux, linux-arm-kernel, linux-omap

On Thu, 23 Apr 2009, Tony Lindgren wrote:

> * Paul Walmsley <paul@pwsan.com> [090423 20:13]:
> > On Thu, 23 Apr 2009, Tony Lindgren wrote:
> > 
> > > * Russell King - ARM Linux <linux@arm.linux.org.uk> [090423 15:26]:
> > > > On Thu, Apr 23, 2009 at 11:00:31AM -0700, Tony Lindgren wrote:
> > > > > * Paul Walmsley <paul@pwsan.com> [090423 01:35]:
> > > > > > Hello Russell,
> > > > > > 
> > > > > > On Thu, 23 Apr 2009, Russell King - ARM Linux wrote:
> > > > > > 
> > > > > > > On Wed, Apr 22, 2009 at 08:01:29PM -0600, Paul Walmsley wrote:
> > > > > > > > The patch also renames clk_init_one() to clk_preinit() to
> > > > > > > > distinguish its function from clk_init() and the individual struct clk
> > > > > > > > init functions.
> > > > > > > 
> > > > > > > That's rather unnecessary.  'clk_init_one' is already unique.  In the
> > > > > > > long run, it's clk_init that needs to go.
> > > > > > 
> > > > > > Even if clk_init() were to disappear, the struct clk .init function 
> > > > > > pointer would still be present.  clk->init() performs a very different 
> > > > > > kind of initialization than clk_init_one().
> > > > > 
> > > > > I'm OK doing the rename in this fix. The original naming can cause
> > > > > confusion while reading the code.
> > > > 
> > > > Well I'm not, and I want to discuss it some more.  And I'm sending Linus
> > > > a pull request tonight, so I'm dropping the OMAP stuff from that.
> > > 
> > > OK. Paul, can you please separate out the rename part into a separate
> > > patch so we only have a minimal fix & then repost it here?
> > > 
> > > That way we'll get the necessary fixes in and you guys can schedule
> > > other changes for next merge window.
> > 
> > The omap-clock-fixes branch has been updated to remove the rename.
> > 
> > Not that this should stop the discussion, but at least this should no 
> > longer prevent these needed fixes from going upstream.
> 
> Care to post the updated patch here too? Temporay git branches are 
> not too readable by most people..

Here you go:

- Paul


From: Paul Walmsley <paul@pwsan.com>
Date: Wed, 22 Apr 2009 19:48:53 -0600
Subject: [PATCH] OMAP2xxx clock: pre-initialize struct clks early

Commit 3f0a820c4c0b4670fb5f164baa5582e23c2ef118 breaks OMAP2xxx boot
during initial propagate_rate() on osc_ck and sys_ck.  Fix by
pre-initializing all struct clks before running any other clock init
code.  Incorporates review comments from Russell King
<rmk+kernel@arm.linux.org.uk>.

Resolves

<1>Unable to handle kernel NULL pointer dereference at virtual address 00000000
<1>pgd = c0004000
<1>[00000000] *pgd=00000000
Internal error: Oops: 5 [#1]
Modules linked in:
CPU: 0    Not tainted  (2.6.29-omap1 #37)
PC is at propagate_rate+0x10/0x60
LR is at omap2_clk_init+0x30/0x218
...

Signed-off-by: Paul Walmsley <paul@pwsan.com>
Tested-by: Jarkko Nikula <jarkko.nikula@nokia.com>
Cc: Russell King <rmk+kernel@arm.linux.org.uk>
---
 arch/arm/mach-omap2/clock24xx.c |    6 +++---
 arch/arm/plat-omap/clock.c      |    7 +++++++
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-omap2/clock24xx.c b/arch/arm/mach-omap2/clock24xx.c
index 1e839c5..984fb86 100644
--- a/arch/arm/mach-omap2/clock24xx.c
+++ b/arch/arm/mach-omap2/clock24xx.c
@@ -720,14 +720,14 @@ int __init omap2_clk_init(void)
 
 	clk_init(&omap2_clk_functions);
 
+	for (c = omap24xx_clks; c < omap24xx_clks + ARRAY_SIZE(omap24xx_clks); c++)
+		clk_init_one(c->lk.clk);
+
 	osc_ck.rate = omap2_osc_clk_recalc(&osc_ck);
 	propagate_rate(&osc_ck);
 	sys_ck.rate = omap2_sys_clk_recalc(&sys_ck);
 	propagate_rate(&sys_ck);
 
-	for (c = omap24xx_clks; c < omap24xx_clks + ARRAY_SIZE(omap24xx_clks); c++)
-		clk_init_one(c->lk.clk);
-
 	cpu_mask = 0;
 	if (cpu_is_omap2420())
 		cpu_mask |= CK_242X;
diff --git a/arch/arm/plat-omap/clock.c b/arch/arm/plat-omap/clock.c
index 2e06145..29efc27 100644
--- a/arch/arm/plat-omap/clock.c
+++ b/arch/arm/plat-omap/clock.c
@@ -239,6 +239,13 @@ void recalculate_root_clocks(void)
 	}
 }
 
+/**
+ * clk_init_one - initialize any fields in the struct clk before clk init
+ * @clk: struct clk * to initialize
+ *
+ * Initialize any struct clk fields needed before normal clk initialization
+ * can run.  No return value.
+ */
 void clk_init_one(struct clk *clk)
 {
 	INIT_LIST_HEAD(&clk->children);
-- 
1.6.3.rc1.51.gea0b7


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Re: [PATCH 1/7] OMAP24xx/25xx clock: init osc_ck, sys_ck internal lists early
  2009-04-24  6:29                       ` Paul Walmsley
@ 2009-04-24 17:51                         ` Tony Lindgren
  0 siblings, 0 replies; 23+ messages in thread
From: Tony Lindgren @ 2009-04-24 17:51 UTC (permalink / raw)
  To: Paul Walmsley; +Cc: Russell King - ARM Linux, linux-arm-kernel, linux-omap

* Paul Walmsley <paul@pwsan.com> [090423 23:29]:
> On Thu, 23 Apr 2009, Tony Lindgren wrote:
> 
> > * Paul Walmsley <paul@pwsan.com> [090423 20:13]:
> > > On Thu, 23 Apr 2009, Tony Lindgren wrote:
> > > 
> > > > * Russell King - ARM Linux <linux@arm.linux.org.uk> [090423 15:26]:
> > > > > On Thu, Apr 23, 2009 at 11:00:31AM -0700, Tony Lindgren wrote:
> > > > > > * Paul Walmsley <paul@pwsan.com> [090423 01:35]:
> > > > > > > Hello Russell,
> > > > > > > 
> > > > > > > On Thu, 23 Apr 2009, Russell King - ARM Linux wrote:
> > > > > > > 
> > > > > > > > On Wed, Apr 22, 2009 at 08:01:29PM -0600, Paul Walmsley wrote:
> > > > > > > > > The patch also renames clk_init_one() to clk_preinit() to
> > > > > > > > > distinguish its function from clk_init() and the individual struct clk
> > > > > > > > > init functions.
> > > > > > > > 
> > > > > > > > That's rather unnecessary.  'clk_init_one' is already unique.  In the
> > > > > > > > long run, it's clk_init that needs to go.
> > > > > > > 
> > > > > > > Even if clk_init() were to disappear, the struct clk .init function 
> > > > > > > pointer would still be present.  clk->init() performs a very different 
> > > > > > > kind of initialization than clk_init_one().
> > > > > > 
> > > > > > I'm OK doing the rename in this fix. The original naming can cause
> > > > > > confusion while reading the code.
> > > > > 
> > > > > Well I'm not, and I want to discuss it some more.  And I'm sending Linus
> > > > > a pull request tonight, so I'm dropping the OMAP stuff from that.
> > > > 
> > > > OK. Paul, can you please separate out the rename part into a separate
> > > > patch so we only have a minimal fix & then repost it here?
> > > > 
> > > > That way we'll get the necessary fixes in and you guys can schedule
> > > > other changes for next merge window.
> > > 
> > > The omap-clock-fixes branch has been updated to remove the rename.
> > > 
> > > Not that this should stop the discussion, but at least this should no 
> > > longer prevent these needed fixes from going upstream.
> > 
> > Care to post the updated patch here too? Temporay git branches are 
> > not too readable by most people..
> 
> Here you go:

Thanks, I've updated omap-fixes again and will post a new pull request.

Tony

> 
> - Paul
> 
> 
> From: Paul Walmsley <paul@pwsan.com>
> Date: Wed, 22 Apr 2009 19:48:53 -0600
> Subject: [PATCH] OMAP2xxx clock: pre-initialize struct clks early
> 
> Commit 3f0a820c4c0b4670fb5f164baa5582e23c2ef118 breaks OMAP2xxx boot
> during initial propagate_rate() on osc_ck and sys_ck.  Fix by
> pre-initializing all struct clks before running any other clock init
> code.  Incorporates review comments from Russell King
> <rmk+kernel@arm.linux.org.uk>.
> 
> Resolves
> 
> <1>Unable to handle kernel NULL pointer dereference at virtual address 00000000
> <1>pgd = c0004000
> <1>[00000000] *pgd=00000000
> Internal error: Oops: 5 [#1]
> Modules linked in:
> CPU: 0    Not tainted  (2.6.29-omap1 #37)
> PC is at propagate_rate+0x10/0x60
> LR is at omap2_clk_init+0x30/0x218
> ...
> 
> Signed-off-by: Paul Walmsley <paul@pwsan.com>
> Tested-by: Jarkko Nikula <jarkko.nikula@nokia.com>
> Cc: Russell King <rmk+kernel@arm.linux.org.uk>
> ---
>  arch/arm/mach-omap2/clock24xx.c |    6 +++---
>  arch/arm/plat-omap/clock.c      |    7 +++++++
>  2 files changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/arm/mach-omap2/clock24xx.c b/arch/arm/mach-omap2/clock24xx.c
> index 1e839c5..984fb86 100644
> --- a/arch/arm/mach-omap2/clock24xx.c
> +++ b/arch/arm/mach-omap2/clock24xx.c
> @@ -720,14 +720,14 @@ int __init omap2_clk_init(void)
>  
>  	clk_init(&omap2_clk_functions);
>  
> +	for (c = omap24xx_clks; c < omap24xx_clks + ARRAY_SIZE(omap24xx_clks); c++)
> +		clk_init_one(c->lk.clk);
> +
>  	osc_ck.rate = omap2_osc_clk_recalc(&osc_ck);
>  	propagate_rate(&osc_ck);
>  	sys_ck.rate = omap2_sys_clk_recalc(&sys_ck);
>  	propagate_rate(&sys_ck);
>  
> -	for (c = omap24xx_clks; c < omap24xx_clks + ARRAY_SIZE(omap24xx_clks); c++)
> -		clk_init_one(c->lk.clk);
> -
>  	cpu_mask = 0;
>  	if (cpu_is_omap2420())
>  		cpu_mask |= CK_242X;
> diff --git a/arch/arm/plat-omap/clock.c b/arch/arm/plat-omap/clock.c
> index 2e06145..29efc27 100644
> --- a/arch/arm/plat-omap/clock.c
> +++ b/arch/arm/plat-omap/clock.c
> @@ -239,6 +239,13 @@ void recalculate_root_clocks(void)
>  	}
>  }
>  
> +/**
> + * clk_init_one - initialize any fields in the struct clk before clk init
> + * @clk: struct clk * to initialize
> + *
> + * Initialize any struct clk fields needed before normal clk initialization
> + * can run.  No return value.
> + */
>  void clk_init_one(struct clk *clk)
>  {
>  	INIT_LIST_HEAD(&clk->children);
> -- 
> 1.6.3.rc1.51.gea0b7
> 

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2009-04-24 17:51 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-14 18:23 [PATCH 0/7] OMAP clock fixes for v2.6.30-rc1 Paul Walmsley
2009-04-14 18:23 ` [PATCH 1/7] OMAP2xxx clock: init osc_ck, sys_ck internal lists early Paul Walmsley
2009-04-14 18:31   ` [PATCH 1/7] OMAP24xx/25xx " Paul Walmsley
2009-04-14 18:37     ` Russell King - ARM Linux
2009-04-21 19:54     ` Russell King - ARM Linux
2009-04-23  2:01       ` Paul Walmsley
2009-04-23  7:53         ` Russell King - ARM Linux
2009-04-23  8:32           ` Paul Walmsley
2009-04-23 18:00             ` Tony Lindgren
2009-04-23 22:26               ` Russell King - ARM Linux
2009-04-23 23:55                 ` Tony Lindgren
2009-04-24  3:13                   ` Paul Walmsley
2009-04-24  5:23                     ` Tony Lindgren
2009-04-24  6:29                       ` Paul Walmsley
2009-04-24 17:51                         ` Tony Lindgren
2009-04-14 18:23 ` [PATCH 2/7] OMAP2xxx clock: fix broken cpu_mask code Paul Walmsley
2009-04-14 18:32   ` [PATCH 2/7] OMAP24xx/OMAP25xx " Paul Walmsley
2009-04-14 18:23 ` [PATCH 3/7] OMAP3: clock: Camera module doesn't have IDLEST bit Paul Walmsley
2009-04-14 18:23 ` [PATCH 4/7] OMAP1: clock: Typo fix for clock in omap1 Paul Walmsley
2009-04-14 18:23 ` [PATCH 5/7] OMAP3 GPTIMER: fix GPTIMER12 IRQ Paul Walmsley
2009-04-14 18:23 ` [PATCH 6/7] OMAP: dmtimer: enable all timers to be wakeup events Paul Walmsley
2009-04-14 18:23 ` [PATCH 7/7] OMAP2/3 GPTIMER: allow system tick GPTIMER to be changed in board-*.c files Paul Walmsley
2009-04-14 21:45   ` Tony Lindgren

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.