From patchwork Thu Oct 3 16:03:58 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 20811 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f200.google.com (mail-qc0-f200.google.com [209.85.216.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id AB86C25CAB for ; Thu, 3 Oct 2013 16:04:04 +0000 (UTC) Received: by mail-qc0-f200.google.com with SMTP id x20sf4986185qcv.7 for ; Thu, 03 Oct 2013 09:04:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:x-gm-message-state:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=RTYEow0Y5DlxXi78bx4aGOlBN/6Bom9USiwl2Pcntjk=; b=N20p3FbcWYI96keQHtbws4EEz3rxzlqoMr0aSDAM208x3e6kgZjxHS3gHFmunfJVsP U7di07fir6F3vxLkqD63Kp8gEOIpQUiLOMFfx8sPbCYeJgLojPje1SNIWqDGr7coES5t VuVEjF0SjfA75xp83nQ+GPNmd4GCrOcPIE2jtLMmjLLitg/U7aztO0ZPa8FgAC41VcpZ x/EqD8hN4B1uySOMIxLeOru669EfFpqTAiPzgWcuBTeClpWb+aBL3TgK9sf7mYunIcQW Pn18L8cX9LeY1wvo8DH5OlcgNKTS7NebUSLGg2VK0yrWyciO8cDvFoE3hXmzUKOuCJ2L 8gVw== X-Received: by 10.58.147.70 with SMTP id ti6mr1361076veb.8.1380816244479; Thu, 03 Oct 2013 09:04:04 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.62.72 with SMTP id w8ls1054646qer.2.gmail; Thu, 03 Oct 2013 09:04:04 -0700 (PDT) X-Received: by 10.221.64.17 with SMTP id xg17mr8022649vcb.5.1380816244369; Thu, 03 Oct 2013 09:04:04 -0700 (PDT) Received: from mail-vb0-f54.google.com (mail-vb0-f54.google.com [209.85.212.54]) by mx.google.com with ESMTPS id lu1si1899006vcb.13.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 03 Oct 2013 09:04:04 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.54 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.54; Received: by mail-vb0-f54.google.com with SMTP id q14so1691753vbe.13 for ; Thu, 03 Oct 2013 09:04:04 -0700 (PDT) X-Gm-Message-State: ALoCoQnXdIMAZ+1MONnIDFS2bvL3TSilVO8I0LBy2z8Tmxs6jEu2fRBPNblEzjnJWTY5ykzqemXq X-Received: by 10.58.179.104 with SMTP id df8mr1448854vec.26.1380816244252; Thu, 03 Oct 2013 09:04:04 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp189719vcz; Thu, 3 Oct 2013 09:04:03 -0700 (PDT) X-Received: by 10.14.183.130 with SMTP id q2mr13836898eem.5.1380816242855; Thu, 03 Oct 2013 09:04:02 -0700 (PDT) Received: from mail-ee0-f51.google.com (mail-ee0-f51.google.com [74.125.83.51]) by mx.google.com with ESMTPS id f46si6557107eeo.339.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 03 Oct 2013 09:04:02 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.83.51 is neither permitted nor denied by best guess record for domain of linus.walleij@linaro.org) client-ip=74.125.83.51; Received: by mail-ee0-f51.google.com with SMTP id c1so1210654eek.10 for ; Thu, 03 Oct 2013 09:04:02 -0700 (PDT) X-Received: by 10.14.177.199 with SMTP id d47mr13657607eem.14.1380816242308; Thu, 03 Oct 2013 09:04:02 -0700 (PDT) Received: from localhost.localdomain ([85.235.11.236]) by mx.google.com with ESMTPSA id j7sm17293780eeo.15.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 03 Oct 2013 09:04:01 -0700 (PDT) From: Linus Walleij To: linux-arm-kernel@lists.infradead.org Cc: Linus Walleij Subject: [PATCH 6/6] cpufreq: probe the Integrator cpufreq driver from DT Date: Thu, 3 Oct 2013 18:03:58 +0200 Message-Id: <1380816238-3255-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 1.8.3.1 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: linus.walleij@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.54 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , This makes the Integrator cpufreq driver probe from the core module device tree node through it's registered platforms device, getting the memory base from the device tree, remapping it and removing dependencies to and by moving the two affected CM register offsets into the driver. Signed-off-by: Linus Walleij --- drivers/cpufreq/integrator-cpufreq.c | 56 ++++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 18 deletions(-) diff --git a/drivers/cpufreq/integrator-cpufreq.c b/drivers/cpufreq/integrator-cpufreq.c index f7c99df..9faf0ca 100644 --- a/drivers/cpufreq/integrator-cpufreq.c +++ b/drivers/cpufreq/integrator-cpufreq.c @@ -15,18 +15,19 @@ #include #include #include +#include +#include +#include -#include -#include #include #include -static struct cpufreq_driver integrator_driver; +static void __iomem *cm_base; +/* The cpufreq driver only use the OSC register */ +#define INTEGRATOR_HDR_OSC_OFFSET 0x08 +#define INTEGRATOR_HDR_LOCK_OFFSET 0x14 -#define CM_ID __io_address(INTEGRATOR_HDR_ID) -#define CM_OSC __io_address(INTEGRATOR_HDR_OSC) -#define CM_STAT __io_address(INTEGRATOR_HDR_STAT) -#define CM_LOCK __io_address(INTEGRATOR_HDR_LOCK) +static struct cpufreq_driver integrator_driver; static const struct icst_params lclk_params = { .ref = 24000000, @@ -100,7 +101,7 @@ static int integrator_set_target(struct cpufreq_policy *policy, BUG_ON(cpu != smp_processor_id()); /* get current setting */ - cm_osc = __raw_readl(CM_OSC); + cm_osc = __raw_readl(cm_base + INTEGRATOR_HDR_OSC_OFFSET); if (machine_is_integrator()) { vco.s = (cm_osc >> 8) & 7; @@ -128,7 +129,7 @@ static int integrator_set_target(struct cpufreq_policy *policy, cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); - cm_osc = __raw_readl(CM_OSC); + cm_osc = __raw_readl(cm_base + INTEGRATOR_HDR_OSC_OFFSET); if (machine_is_integrator()) { cm_osc &= 0xfffff800; @@ -138,9 +139,9 @@ static int integrator_set_target(struct cpufreq_policy *policy, } cm_osc |= vco.v; - __raw_writel(0xa05f, CM_LOCK); - __raw_writel(cm_osc, CM_OSC); - __raw_writel(0, CM_LOCK); + __raw_writel(0xa05f, cm_base + INTEGRATOR_HDR_LOCK_OFFSET); + __raw_writel(cm_osc, cm_base + INTEGRATOR_HDR_OSC_OFFSET); + __raw_writel(0, cm_base + INTEGRATOR_HDR_LOCK_OFFSET); /* * Restore the CPUs allowed mask. @@ -165,7 +166,7 @@ static unsigned int integrator_get(unsigned int cpu) BUG_ON(cpu != smp_processor_id()); /* detect memory etc. */ - cm_osc = __raw_readl(CM_OSC); + cm_osc = __raw_readl(cm_base + INTEGRATOR_HDR_OSC_OFFSET); if (machine_is_integrator()) { vco.s = (cm_osc >> 8) & 7; @@ -202,19 +203,38 @@ static struct cpufreq_driver integrator_driver = { .name = "integrator", }; -static int __init integrator_cpu_init(void) +static int __init integrator_cpufreq_probe(struct platform_device *pdev) { + struct device_node *np = pdev->dev.of_node; + + cm_base = of_iomap(np, 0); + if (!cm_base) + return -ENODEV; return cpufreq_register_driver(&integrator_driver); } -static void __exit integrator_cpu_exit(void) +static void __exit integrator_cpufreq_remove(struct platform_device *pdev) { cpufreq_unregister_driver(&integrator_driver); } +static const struct of_device_id integrator_cpufreq_match[] = { + { .compatible = "arm,core-module-integrator"}, + { }, +}; + +static struct platform_driver integrator_cpufreq_driver = { + .driver = { + .name = "integrator-cpufreq", + .owner = THIS_MODULE, + .of_match_table = integrator_cpufreq_match, + }, + .remove = __exit_p(integrator_cpufreq_remove), +}; + +module_platform_driver_probe(integrator_cpufreq_driver, + integrator_cpufreq_probe); + MODULE_AUTHOR ("Russell M. King"); MODULE_DESCRIPTION ("cpufreq driver for ARM Integrator CPUs"); MODULE_LICENSE ("GPL"); - -module_init(integrator_cpu_init); -module_exit(integrator_cpu_exit);