From patchwork Tue Nov 12 03:32:08 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 3170551 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C3EF7C045B for ; Tue, 12 Nov 2013 03:32:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A516420320 for ; Tue, 12 Nov 2013 03:32:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C917B20148 for ; Tue, 12 Nov 2013 03:32:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751427Ab3KLDc2 (ORCPT ); Mon, 11 Nov 2013 22:32:28 -0500 Received: from mail-we0-f170.google.com ([74.125.82.170]:61862 "EHLO mail-we0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751336Ab3KLDc1 (ORCPT ); Mon, 11 Nov 2013 22:32:27 -0500 Received: by mail-we0-f170.google.com with SMTP id u57so5487484wes.29 for ; Mon, 11 Nov 2013 19:32:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=zA2TcPoMwNEodATUfX3VuN0zaQBDUs0eg8VCaQ5Sme0=; b=ektdcKv9yPfw2ROWEho+CAOhKU+xQIkYF3zPyImVhNZzAV5tqste7kTyLKpVzeZZx6 aQRMMddQHibv753gzNBRtnYDOK70mPnn6UD5VZIM0HVfnc4RoxHutfZysqgAznOSTV/z aeNVN4sQ//C9TI/HIKWHg8Sz6azEft+d6L2b7l0ob+/7Zojyp/UO4XlTZ4ZVg9IVgkCX Py8O1zHoMl/HGhJOZ/G6FH2ivzFJV0f1Y9Ol5GK1EWEkEgOaRtbzwYWpe41a2l7Uqvj+ eCWsXZJY09VRVdLOsp2UPYbmXjj1CnM5jIUFMxYbZNjB+t0R/7NlwTbkUiN/UqIdYiUr zFFw== X-Received: by 10.180.101.197 with SMTP id fi5mr14556835wib.46.1384227145025; Mon, 11 Nov 2013 19:32:25 -0800 (PST) Received: from fangorn.rup.mentorg.com (nat-min.mentorg.com. [139.181.32.34]) by mx.google.com with ESMTPSA id i8sm40087381wiy.6.2013.11.11.19.32.23 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Nov 2013 19:32:24 -0800 (PST) From: Dmitry Eremin-Solenikov To: linux-arm-kernel@lists.infradead.org Cc: linux-pcmcia@lists.infradead.org, linux-fbdev@vger.kernel.org, Russell King Subject: [PATCH 1/5] arm: sa1100: add cpu clock Date: Tue, 12 Nov 2013 07:32:08 +0400 Message-Id: <1384227132-10501-1-git-send-email-dbaryshkov@gmail.com> X-Mailer: git-send-email 1.8.4.2 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 #include +#include 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)