From patchwork Wed Oct 28 07:59:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sascha Hauer X-Patchwork-Id: 537222 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3696B1409F8 for ; Wed, 28 Oct 2015 19:04:47 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZrLhB-0002ft-3k; Wed, 28 Oct 2015 08:02:57 +0000 Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZrLeH-0007RV-My for linux-arm-kernel@lists.infradead.org; Wed, 28 Oct 2015 07:59:59 +0000 Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7]) by metis.ext.pengutronix.de with esmtps (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1ZrLdg-0002bW-Vr; Wed, 28 Oct 2015 08:59:21 +0100 Received: from sha by dude.hi.pengutronix.de with local (Exim 4.86) (envelope-from ) id 1ZrLdf-00052m-Qk; Wed, 28 Oct 2015 08:59:19 +0100 From: Sascha Hauer To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 4/5] cpufreq: imx6q: Use id_table to distinguish between SoCs Date: Wed, 28 Oct 2015 08:59:13 +0100 Message-Id: <1446019154-16384-5-git-send-email-s.hauer@pengutronix.de> X-Mailer: git-send-email 2.6.1 In-Reply-To: <1446019154-16384-1-git-send-email-s.hauer@pengutronix.de> References: <1446019154-16384-1-git-send-email-s.hauer@pengutronix.de> X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: sha@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151028_005958_283422_D5B3F67A X-CRM114-Status: GOOD ( 18.31 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-pm@vger.kernel.org, Viresh Kumar , Sascha Hauer , "Rafael J . Wysocki" , kernel@pengutronix.de, Shawn Guo , Heiner Kallweit MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org List-Id: linux-imx-kernel.lists.patchwork.ozlabs.org The i.MX6 cpufreq driver is instantiated from a static device in architecture code and not from the device tree. These devices offer the id_table mechanism to distinguish between different types of devices. Use this mechanism rather than of_machine_is_compatible() as it scales better with increasing number of SoCs to check against. Signed-off-by: Sascha Hauer Acked-by: Shawn Guo --- arch/arm/mach-imx/mach-imx6sl.c | 2 +- arch/arm/mach-imx/mach-imx6sx.c | 2 +- arch/arm/mach-imx/mach-imx6ul.c | 2 +- drivers/cpufreq/imx6q-cpufreq.c | 30 +++++++++++++++++++++++++++--- 4 files changed, 30 insertions(+), 6 deletions(-) diff --git a/arch/arm/mach-imx/mach-imx6sl.c b/arch/arm/mach-imx/mach-imx6sl.c index 3003263..c93cf69 100644 --- a/arch/arm/mach-imx/mach-imx6sl.c +++ b/arch/arm/mach-imx/mach-imx6sl.c @@ -39,7 +39,7 @@ static void __init imx6sl_init_late(void) { /* imx6sl reuses imx6q cpufreq driver */ if (IS_ENABLED(CONFIG_ARM_IMX6Q_CPUFREQ)) - platform_device_register_simple("imx6q-cpufreq", -1, NULL, 0); + platform_device_register_simple("imx6sl-cpufreq", -1, NULL, 0); imx6sl_cpuidle_init(); } diff --git a/arch/arm/mach-imx/mach-imx6sx.c b/arch/arm/mach-imx/mach-imx6sx.c index 6a0b061..ca86a25 100644 --- a/arch/arm/mach-imx/mach-imx6sx.c +++ b/arch/arm/mach-imx/mach-imx6sx.c @@ -94,7 +94,7 @@ static void __init imx6sx_init_late(void) imx6sx_cpuidle_init(); if (IS_ENABLED(CONFIG_ARM_IMX6Q_CPUFREQ)) - platform_device_register_simple("imx6q-cpufreq", -1, NULL, 0); + platform_device_register_simple("imx6sx-cpufreq", -1, NULL, 0); } static const char * const imx6sx_dt_compat[] __initconst = { diff --git a/arch/arm/mach-imx/mach-imx6ul.c b/arch/arm/mach-imx/mach-imx6ul.c index acaf705..159ec4e 100644 --- a/arch/arm/mach-imx/mach-imx6ul.c +++ b/arch/arm/mach-imx/mach-imx6ul.c @@ -81,7 +81,7 @@ static void __init imx6ul_init_irq(void) static void __init imx6ul_init_late(void) { if (IS_ENABLED(CONFIG_ARM_IMX6Q_CPUFREQ)) - platform_device_register_simple("imx6q-cpufreq", -1, NULL, 0); + platform_device_register_simple("imx6ul-cpufreq", -1, NULL, 0); } static const char *imx6ul_dt_compat[] __initconst = { diff --git a/drivers/cpufreq/imx6q-cpufreq.c b/drivers/cpufreq/imx6q-cpufreq.c index f81cf8e..f3729f9 100644 --- a/drivers/cpufreq/imx6q-cpufreq.c +++ b/drivers/cpufreq/imx6q-cpufreq.c @@ -42,6 +42,27 @@ static unsigned int transition_latency; static u32 *imx6_soc_volt; static u32 soc_opp_count; +static unsigned long imx6_cpufreq_flags; + +#define IMX6_CPUFREQ_NEED_PU_REG (1 << 0) +#define IMX6_CPUFREQ_NEED_SECONDARY_SEL (1 << 1) + +static const struct platform_device_id imx6_cpufreq_devtype[] = { + { + .name = "imx6q-cpufreq", + .driver_data = IMX6_CPUFREQ_NEED_PU_REG, + }, { + .name = "imx6ul-cpufreq", + .driver_data = IMX6_CPUFREQ_NEED_SECONDARY_SEL, + }, { + .name = "imx6sl-cpufreq", + .driver_data = IMX6_CPUFREQ_NEED_PU_REG, + }, { + .name = "imx6sx-cpufreq", + .driver_data = IMX6_CPUFREQ_NEED_PU_REG, + }, +}; + static int imx6q_set_target(struct cpufreq_policy *policy, unsigned int index) { struct dev_pm_opp *opp; @@ -102,7 +123,7 @@ static int imx6q_set_target(struct cpufreq_policy *policy, unsigned int index) * - Reprogram pll1_sys_clk and reparent pll1_sw_clk back to it * - Disable pll2_pfd2_396m_clk */ - if (of_machine_is_compatible("fsl,imx6ul")) { + if (imx6_cpufreq_flags & IMX6_CPUFREQ_NEED_SECONDARY_SEL) { /* * When changing pll1_sw_clk's parent to pll1_sys_clk, * CPU may run at higher than 528MHz, this will lead to @@ -202,7 +223,7 @@ static int imx6q_cpufreq_get_resources(void) if (IS_ERR(pll2_pfd2_396m_clk)) return PTR_ERR(pll2_pfd2_396m_clk); - if (of_machine_is_compatible("fsl,imx6ul")) { + if (imx6_cpufreq_flags & IMX6_CPUFREQ_NEED_SECONDARY_SEL) { pll2_bus_clk = clk_get(cpu_dev, "pll2_bus"); if (IS_ERR(pll2_bus_clk)) return PTR_ERR(pll2_bus_clk); @@ -283,6 +304,8 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev) const __be32 *val; u32 nr, i, j; + imx6_cpufreq_flags = platform_get_device_id(pdev)->driver_data; + cpu_dev = get_cpu_device(0); if (!cpu_dev) { pr_err("failed to get cpu0 device\n"); @@ -439,8 +462,9 @@ static int imx6q_cpufreq_remove(struct platform_device *pdev) static struct platform_driver imx6q_cpufreq_platdrv = { .driver = { - .name = "imx6q-cpufreq", + .name = "imx6-cpufreq", }, + .id_table = imx6_cpufreq_devtype, .probe = imx6q_cpufreq_probe, .remove = imx6q_cpufreq_remove, };