From patchwork Mon Dec 1 11:41:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 41755 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f69.google.com (mail-ee0-f69.google.com [74.125.83.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7D66424001 for ; Mon, 1 Dec 2014 11:42:09 +0000 (UTC) Received: by mail-ee0-f69.google.com with SMTP id d49sf6543063eek.8 for ; Mon, 01 Dec 2014 03:42:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:in-reply-to:references :sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=5qnMbnErmAabpyFiKKYfehgQiWDnXgU4UtKGgV3TI8A=; b=G5pkuG8eXcUAgpa2aT+XWOm65LT/LQcq6MNQBGSUFCtIhswSxjieje0pCkfSs+az27 2QPzHT8f2EDYsIeSCz+7/OqKwqAowWk7Y1ulQRTZJK/CGmZwsJes/CBTRRxZU65nju/F TftDOITKT4u4s+6B0ULL2VSZ27LCpy+FCkcwBMSoLAVo4ti8Wy0MSGJ8A+aii8WxVTeK 1uZBCZtNBloOmM2Amvg2Aa3Cf+LT5CAZuINvpvAe6KVlSw2PT/uRQ7I7XltL5z7DusRY S3dvu1piuWyidJ00F+ehgbWSIEAn0BstdCCdYDRktIYqVTK8d/DmbNoFBpCvGVcawgoo 1qhw== X-Gm-Message-State: ALoCoQk+u1oeReQNQSWmFKgcaCb8VJjtzaaBOk9UcNsuHhWAVxwIgJDuPDWMYMEl6Yi/zpxqJnkD X-Received: by 10.112.55.10 with SMTP id n10mr469526lbp.14.1417434128466; Mon, 01 Dec 2014 03:42:08 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.42.228 with SMTP id r4ls793414lal.41.gmail; Mon, 01 Dec 2014 03:42:08 -0800 (PST) X-Received: by 10.112.201.226 with SMTP id kd2mr45523990lbc.98.1417434128231; Mon, 01 Dec 2014 03:42:08 -0800 (PST) Received: from mail-la0-f44.google.com (mail-la0-f44.google.com. [209.85.215.44]) by mx.google.com with ESMTPS id o10si2344284laf.92.2014.12.01.03.42.08 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 01 Dec 2014 03:42:08 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) client-ip=209.85.215.44; Received: by mail-la0-f44.google.com with SMTP id ge10so8622619lab.17 for ; Mon, 01 Dec 2014 03:42:08 -0800 (PST) X-Received: by 10.112.52.37 with SMTP id q5mr55568781lbo.32.1417434128113; Mon, 01 Dec 2014 03:42:08 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp269014lbc; Mon, 1 Dec 2014 03:42:07 -0800 (PST) X-Received: by 10.70.103.102 with SMTP id fv6mr100680641pdb.92.1417434126378; Mon, 01 Dec 2014 03:42:06 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id xn7si28392466pbc.105.2014.12.01.03.42.05 for ; Mon, 01 Dec 2014 03:42:06 -0800 (PST) Received-SPF: none (google.com: linux-pm-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753391AbaLALl7 (ORCPT + 12 others); Mon, 1 Dec 2014 06:41:59 -0500 Received: from mail-pd0-f172.google.com ([209.85.192.172]:52790 "EHLO mail-pd0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753388AbaLALl5 (ORCPT ); Mon, 1 Dec 2014 06:41:57 -0500 Received: by mail-pd0-f172.google.com with SMTP id y13so10738532pdi.17 for ; Mon, 01 Dec 2014 03:41:56 -0800 (PST) X-Received: by 10.70.130.174 with SMTP id of14mr100250679pdb.90.1417434116670; Mon, 01 Dec 2014 03:41:56 -0800 (PST) Received: from localhost ([122.166.92.172]) by mx.google.com with ESMTPSA id eo4sm14782015pbb.87.2014.12.01.03.41.55 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 01 Dec 2014 03:41:56 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki , Arnd Bergmann , Rob Herring , Grant Likely Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, Nishanth Menon , Sudeep Holla , Stephen Boyd , devicetree@vger.kernel.org, santosh shilimkar , Lorenzo Pieralisi , Mike Turquette , kesavan.abhilash@gmail.com, catalin.marinas@arm.com, k.chander@samsung.com, olof@lixom.net, ta.omasab@gmail.com, linux-arm-kernel@lists.infradead.org, Viresh Kumar Subject: [RFC V1 2/8] cpufreq: Create cpufreq platform-device based on "compatible" from DT Date: Mon, 1 Dec 2014 17:11:23 +0530 Message-Id: <061f06ab89fc2b93796edf0b3548022efaf6e760.1417433163.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.0.3.693.g996b0fd In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , DT based cpufreq drivers doesn't require much support from platform code now a days as most of the stuff is moved behind generic APIs. Like clk APIs for changing clock rates, regulator APIs for changing voltages, etc. One of the bottleneck still left was how to select which cpufreq driver to probe for a given platform as there might be multiple drivers available. Traditionally, we used to create platform devices from machine specific code which binds with a cpufreq driver. And while we moved towards DT based device creation, these devices stayed as is. The problem is getting worse now as we have architectures now with Zero platform specific code. Forcefully these platforms have to create a new file in drivers/cpufreq/ to just add these platform devices in order to use the generic drivers like cpufreq-dt.c. This has been discussed again and again, but with no solution yet. Last it was discussed here: http://lists.infradead.org/pipermail/linux-arm-kernel/2014-May/256154.html This patch creates a separate file which will be responsible for creating cpufreq platform device based on the match with "compatible" property from DT. A Blacklist is also provided for backward compatibility with older DTs. Signed-off-by: Viresh Kumar --- drivers/cpufreq/Makefile | 2 +- drivers/cpufreq/dt_device.c | 52 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 drivers/cpufreq/dt_device.c diff --git a/drivers/cpufreq/Makefile b/drivers/cpufreq/Makefile index b3ca7b0..d6feb0b 100644 --- a/drivers/cpufreq/Makefile +++ b/drivers/cpufreq/Makefile @@ -1,6 +1,6 @@ # CPUfreq core obj-$(CONFIG_CPU_FREQ) += cpufreq.o freq_table.o -obj-$(CONFIG_PM_OPP) += cpufreq_opp.o +obj-$(CONFIG_PM_OPP) += cpufreq_opp.o dt_device.o # CPUfreq stats obj-$(CONFIG_CPU_FREQ_STAT) += cpufreq_stats.o diff --git a/drivers/cpufreq/dt_device.c b/drivers/cpufreq/dt_device.c new file mode 100644 index 0000000..7800968 --- /dev/null +++ b/drivers/cpufreq/dt_device.c @@ -0,0 +1,52 @@ +/* + * Creates platform device for probing cpufreq driver + * + * Copyright (C) 2014 Linaro. + * Viresh Kumar + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed "as is" WITHOUT ANY WARRANTY of any + * kind, whether express or implied; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#include + +static const struct of_device_id compatible_machine_match[] = { + /* All new machines must have the below compatible to use this driver */ + { .compatible = "cpufreq-dt", .data = "cpufreq-dt" }, + { .compatible = "arm-bL-cpufreq-dt", .data = "arm-bL-cpufreq-dt" }, + + /* BLACKLIST of existing users of cpufreq-dt below */ + + /* BLACKLIST of existing users of arm-bL-cpufreq-dt below */ + + /* BLACKLIST of existing users of other drivers below */ + + {}, +}; + +static int cpufreq_dt_create_platform_device(void) +{ + struct device_node *root = of_find_node_by_path("/"); + const struct of_device_id *match; + + match = of_match_node(compatible_machine_match, root); + if (!match) { + pr_debug("%s: Couldn't find a match\n", __func__); + return -ENODEV; + } + + pr_debug("%s: Create device for compatible:%s, driver:%s\n", __func__, + match->compatible, (char *)match->data); + platform_device_register_simple(match->data, -1, NULL, 0); + + return 0; +} +late_initcall(cpufreq_dt_create_platform_device);