From patchwork Thu May 18 20:17:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 100123 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp6155qge; Thu, 18 May 2017 13:17:52 -0700 (PDT) X-Received: by 10.98.102.208 with SMTP id s77mr6396246pfj.22.1495138672033; Thu, 18 May 2017 13:17:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495138672; cv=none; d=google.com; s=arc-20160816; b=toQZr+i/K/gHySBXDgbAB+I5XdE+a00X+So9/F2zhhCpsl2otempoVYwQmwrBN30zp axsqux9clYUfJMcT+avIEroxZ9+SHOXNbz+hROZdLYc1YPLHGf2Qk2sN6PJxY8QhXBAT IFikqnugG6Tv5yn4lgsCnDmQc/9DbDqqSUEIBrMGlAMTYOEPsN5wDT5olsE+IPCImRP6 +KnbQlw0uJ4ikZ8rx6Ngu41B739ef8aY7MKMLsWner0kazJ2qCO333yYN5IpQzW9/cuD TQr2Y3By7NlRXBMag5bbnnn9NfXiWZBWctOFPyyEbTLvssWsLlbrdfBCp+tsprTz+z5B 2SRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=FKAj8m1E5dzyahIa2rRBGI725A6CG+k150yA7L8WO0I=; b=ZMRgtAWruZwlMF+BZiJh7f88V8VhdLOB5sAnnUwNUkH0pVAtow7HaZz0T/m3jWALNA wmS75DIsbqDxlI4nwHcdOZN+ag+Ne7Snh7d1aRISzr1sABdrtHABjorISaUrJUXjpqrj ZgKcmWpMPx8uUCK04leZtYJ4ZorboME7bR1L47TPm6pJF3yWmoFFslUwml5GeKBfTyHn qVZ9CzyRcSx0Rxqe9A+6WMEUBHMFGnxxPIbAOnjbIrC6H4XZRENiZ7nkKf+PWq42LfAG LoWEFjyLVY80ofQE4RqIAN7HP09g0gFAQZlIBYPhXuXqPpEPiNqhCVVvaUdd6kS2+QV5 JC/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q7si6059160pfd.332.2017.05.18.13.17.51; Thu, 18 May 2017 13:17:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755797AbdERURa (ORCPT + 25 others); Thu, 18 May 2017 16:17:30 -0400 Received: from mail-wm0-f50.google.com ([74.125.82.50]:38253 "EHLO mail-wm0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755695AbdERUR0 (ORCPT ); Thu, 18 May 2017 16:17:26 -0400 Received: by mail-wm0-f50.google.com with SMTP id v15so65047073wmv.1 for ; Thu, 18 May 2017 13:17:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=FKAj8m1E5dzyahIa2rRBGI725A6CG+k150yA7L8WO0I=; b=J3IgQq2LZgVFrHOoEpn01kdu6e0WG9cgrmVlLetSO88frWIaCgRVPOOimU0yFi7VVd EjbEf46JzFY7n8as+z/2T1wDV4CifycnOOvvytifPoxt/j5veh3tkTK7kwHlBCGG0UjU A1HQughaSaTux9dbd3Ntpv1Upv0RnwVVlPmgE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=FKAj8m1E5dzyahIa2rRBGI725A6CG+k150yA7L8WO0I=; b=MNw65tmbeQNjVTPqs7OWUigPuNVfzIdRpL6flBwIv8d/Wnqpym7B0adtlLqG99LsKs m63d76pIMeG32Ek4gQ4+gSW7N444ycfGLj+Eup9u9qOdlQ437lzNPNQAwrSEj/1burn9 rJzn+4uykEYvUdWTvjoCa9OSaCRkVLeaJ7Gq66SyT0ArPDZjGynbrhal9AF6HesCDzEI yIdq6/H2tY/hjyn5D+KENCqmtw7szACWlf+aXi3fM+umYn8jIjj36yWTNRKJXM7TH89/ G/s4ufFC76y8ZZKySHRPAh1wEWIpWcJICmg8a6Uxng4RZtXqyzrFYrMsU/xIkCO86MER iQaA== X-Gm-Message-State: AODbwcD8EVdliTLIZLh6CJH7u5ILgIU7iPNzq2sRWjomM1Pb5cLt4cyC 5M1FcAIdJJHtW+8r X-Received: by 10.25.221.198 with SMTP id w67mr1490783lfi.114.1495138644994; Thu, 18 May 2017 13:17:24 -0700 (PDT) Received: from fabina.bredbandsbolaget.se (c-787571d5.014-348-6c756e10.cust.bredbandsbolaget.se. [213.113.117.120]) by smtp.gmail.com with ESMTPSA id y1sm1103615lja.24.2017.05.18.13.17.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 May 2017 13:17:23 -0700 (PDT) From: Linus Walleij To: Daniel Lezcano , Thomas Gleixner , Joel Stanley , Jonas Jensen Cc: Janos Laube , Paulius Zaleckas , linux-arm-kernel@lists.infradead.org, Hans Ulli Kroll , Florian Fainelli , linux-kernel@vger.kernel.org, Linus Walleij Subject: [PATCH 3/8 v2] clocksource/drivers/fttmr010: Drop Gemini specifics Date: Thu, 18 May 2017 22:17:00 +0200 Message-Id: <20170518201705.28790-3-linus.walleij@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170518201705.28790-1-linus.walleij@linaro.org> References: <20170518201705.28790-1-linus.walleij@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The Gemini now has a proper clock driver and a proper PCLK assigned in its device tree. Drop the Gemini-specific hacks to look up the system speed and rely on the clock framework like everyone else. Cc: Joel Stanley Tested-by: Jonas Jensen Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Added Jonas' Tested-by, no functional changes. --- drivers/clocksource/timer-fttmr010.c | 103 ++++++++--------------------------- 1 file changed, 22 insertions(+), 81 deletions(-) -- 2.9.3 diff --git a/drivers/clocksource/timer-fttmr010.c b/drivers/clocksource/timer-fttmr010.c index 58ce017e4a65..db097db346e3 100644 --- a/drivers/clocksource/timer-fttmr010.c +++ b/drivers/clocksource/timer-fttmr010.c @@ -11,8 +11,6 @@ #include #include #include -#include -#include #include #include #include @@ -179,9 +177,28 @@ static struct irqaction fttmr010_timer_irq = { .handler = fttmr010_timer_interrupt, }; -static int __init fttmr010_timer_common_init(struct device_node *np) +static int __init fttmr010_timer_init(struct device_node *np) { int irq; + struct clk *clk; + int ret; + + /* + * These implementations require a clock reference. + * FIXME: we currently only support clocking using PCLK + * and using EXTCLK is not supported in the driver. + */ + clk = of_clk_get_by_name(np, "PCLK"); + if (IS_ERR(clk)) { + pr_err("could not get PCLK\n"); + return PTR_ERR(clk); + } + ret = clk_prepare_enable(clk); + if (ret) { + pr_err("failed to enable PCLK\n"); + return ret; + } + tick_rate = clk_get_rate(clk); base = of_iomap(np, 0); if (!base) { @@ -229,81 +246,5 @@ static int __init fttmr010_timer_common_init(struct device_node *np) return 0; } - -static int __init fttmr010_timer_of_init(struct device_node *np) -{ - /* - * These implementations require a clock reference. - * FIXME: we currently only support clocking using PCLK - * and using EXTCLK is not supported in the driver. - */ - struct clk *clk; - int ret; - - clk = of_clk_get_by_name(np, "PCLK"); - if (IS_ERR(clk)) { - pr_err("could not get PCLK\n"); - return PTR_ERR(clk); - } - ret = clk_prepare_enable(clk); - if (ret) { - pr_err("failed to enable PCLK\n"); - return ret; - } - tick_rate = clk_get_rate(clk); - - return fttmr010_timer_common_init(np); -} -CLOCKSOURCE_OF_DECLARE(fttmr010, "faraday,fttmr010", fttmr010_timer_of_init); - -/* - * Gemini-specific: relevant registers in the global syscon - */ -#define GLOBAL_STATUS 0x04 -#define CPU_AHB_RATIO_MASK (0x3 << 18) -#define CPU_AHB_1_1 (0x0 << 18) -#define CPU_AHB_3_2 (0x1 << 18) -#define CPU_AHB_24_13 (0x2 << 18) -#define CPU_AHB_2_1 (0x3 << 18) -#define REG_TO_AHB_SPEED(reg) ((((reg) >> 15) & 0x7) * 10 + 130) - -static int __init gemini_timer_of_init(struct device_node *np) -{ - static struct regmap *map; - int ret; - u32 val; - - map = syscon_regmap_lookup_by_phandle(np, "syscon"); - if (IS_ERR(map)) { - pr_err("Can't get regmap for syscon handle\n"); - return -ENODEV; - } - ret = regmap_read(map, GLOBAL_STATUS, &val); - if (ret) { - pr_err("Can't read syscon status register\n"); - return -ENXIO; - } - - tick_rate = REG_TO_AHB_SPEED(val) * 1000000; - pr_info("Bus: %dMHz ", tick_rate / 1000000); - - tick_rate /= 6; /* APB bus run AHB*(1/6) */ - - switch (val & CPU_AHB_RATIO_MASK) { - case CPU_AHB_1_1: - pr_cont("(1/1)\n"); - break; - case CPU_AHB_3_2: - pr_cont("(3/2)\n"); - break; - case CPU_AHB_24_13: - pr_cont("(24/13)\n"); - break; - case CPU_AHB_2_1: - pr_cont("(2/1)\n"); - break; - } - - return fttmr010_timer_common_init(np); -} -CLOCKSOURCE_OF_DECLARE(gemini, "cortina,gemini-timer", gemini_timer_of_init); +CLOCKSOURCE_OF_DECLARE(fttmr010, "faraday,fttmr010", fttmr010_timer_init); +CLOCKSOURCE_OF_DECLARE(gemini, "cortina,gemini-timer", fttmr010_timer_init);