linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/5] arm: sa1100: add cpu clock
@ 2013-11-12  3:32 Dmitry Eremin-Solenikov
  2013-11-12  3:32 ` [PATCH 2/5] fbdev: sa1100fb: make use of device clock Dmitry Eremin-Solenikov
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Dmitry Eremin-Solenikov @ 2013-11-12  3:32 UTC (permalink / raw)
  To: linux-arm-kernel

Both SA1100 framebuffer and PCMCIA drivers require knowledge of cpu
frequency to correctly program timings.  Currently they receive timing
information by calling cpufreq_get(0).  However if cpu frequency driver
is not enabled (e.g. due to unsupported DRAM chip/board on sa1110)
cpufreq_get(0) returns 0, causing incorrect timings to be programmed.

Add cpu clock returning cpu frequency, to be used by sa11x0 fb and
pcmcia drivers.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 arch/arm/mach-sa1100/clock.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/arch/arm/mach-sa1100/clock.c b/arch/arm/mach-sa1100/clock.c
index 172ebd0..abf1dc1 100644
--- a/arch/arm/mach-sa1100/clock.c
+++ b/arch/arm/mach-sa1100/clock.c
@@ -15,10 +15,12 @@
 #include <linux/clkdev.h>
 
 #include <mach/hardware.h>
+#include <mach/generic.h>
 
 struct clkops {
 	void			(*enable)(struct clk *);
 	void			(*disable)(struct clk *);
+	unsigned long		(*get_rate)(struct clk *);
 };
 
 struct clk {
@@ -51,6 +53,19 @@ static void clk_gpio27_disable(struct clk *clk)
 	GAFR &= ~GPIO_32_768kHz;
 }
 
+static void clk_cpu_enable(struct clk *clk)
+{
+}
+
+static void clk_cpu_disable(struct clk *clk)
+{
+}
+
+static unsigned long clk_cpu_get_rate(struct clk *clk)
+{
+	return sa11x0_getspeed(0) * 1000;
+}
+
 int clk_enable(struct clk *clk)
 {
 	unsigned long flags;
@@ -80,16 +95,35 @@ void clk_disable(struct clk *clk)
 }
 EXPORT_SYMBOL(clk_disable);
 
+unsigned long clk_get_rate(struct clk *clk)
+{
+	if (clk && clk->ops && clk->ops->get_rate)
+		return clk->ops->get_rate(clk);
+	else
+		return 0;
+}
+EXPORT_SYMBOL(clk_get_rate);
+
 const struct clkops clk_gpio27_ops = {
 	.enable		= clk_gpio27_enable,
 	.disable	= clk_gpio27_disable,
 };
 
+const struct clkops clk_cpu_ops = {
+	.enable		= clk_cpu_enable,
+	.disable	= clk_cpu_disable,
+	.get_rate	= clk_cpu_get_rate,
+};
+
 static DEFINE_CLK(gpio27, &clk_gpio27_ops);
 
+static DEFINE_CLK(cpu, &clk_cpu_ops);
+
 static struct clk_lookup sa11xx_clkregs[] = {
 	CLKDEV_INIT("sa1111.0", NULL, &clk_gpio27),
 	CLKDEV_INIT("sa1100-rtc", NULL, NULL),
+	CLKDEV_INIT("sa11x0-fb", NULL, &clk_cpu),
+	CLKDEV_INIT("sa11x0-pcmcia", NULL, &clk_cpu),
 };
 
 static int __init sa11xx_clk_init(void)
-- 
1.8.4.2

^ permalink raw reply related	[flat|nested] 9+ messages in thread
* [PATCH 0/5] arm: sa1100: fix sa1100 fb and pcmcia w/o cpufreq
@ 2014-10-24 10:37 Dmitry Eremin-Solenikov
  2014-10-24 10:37 ` [PATCH 1/5] arm: sa1100: add cpu clock Dmitry Eremin-Solenikov
  0 siblings, 1 reply; 9+ messages in thread
From: Dmitry Eremin-Solenikov @ 2014-10-24 10:37 UTC (permalink / raw)
  To: linux-arm-kernel

Hello,

These patches were sitting in my queue for some time. On SA-1100
framebuffer and PCMCIA drivers make use of cpufreq_get(0) function call
to determine the cpu frequency. Russell's commit
1937f5b91833e2e8e53bcc821fc7a5fbe6ccb9b5 (ARM: fix sa1100 build) fixed
the build issues, but broke two devices (Collie and Jornada720). For
those two boards the cpufreq code gets compiled but is not enabled (as
board files do not provide timing information for the CPUFREQ driver).
Thus cpufreq_get(0) returns incorrect values and incorrect timings get
programmed into the hardware.

PXA2xx (the very similar platform) uses Clock API to determine CPU
frequency both in framebuffer and PCMCIA drivers. These patches make
similar changes to StrongARM drivers.

These patches are required to make use of framebuffer and CF card on
Sharp Collie (and possibly on HP Jornada 720).

-- 
With best wishes
Dmitry

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

end of thread, other threads:[~2014-10-24 10:37 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-12  3:32 [PATCH 1/5] arm: sa1100: add cpu clock Dmitry Eremin-Solenikov
2013-11-12  3:32 ` [PATCH 2/5] fbdev: sa1100fb: make use of device clock Dmitry Eremin-Solenikov
2013-11-12  3:32 ` [PATCH 3/5] pcmcia: sa1100: " Dmitry Eremin-Solenikov
2013-11-12  3:32 ` [PATCH 4/5] arm: sa1100: add a clock alias for sa1111 pcmcia device Dmitry Eremin-Solenikov
2013-11-12 12:00   ` Dmitry Artamonow
2013-11-12  3:32 ` [PATCH 5/5] pcmcia: sa1111: make use of device clock Dmitry Eremin-Solenikov
2013-11-12  9:57 ` [PATCH 1/5] arm: sa1100: add cpu clock Russell King - ARM Linux
2013-11-12 10:37   ` Dmitry Eremin-Solenikov
  -- strict thread matches above, loose matches on Subject: below --
2014-10-24 10:37 [PATCH 0/5] arm: sa1100: fix sa1100 fb and pcmcia w/o cpufreq Dmitry Eremin-Solenikov
2014-10-24 10:37 ` [PATCH 1/5] arm: sa1100: add cpu clock Dmitry Eremin-Solenikov

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).