Received: by 10.223.176.5 with SMTP id f5csp1159045wra; Wed, 7 Feb 2018 13:50:28 -0800 (PST) X-Google-Smtp-Source: AH8x225XzT0ydH/2fA8BGXc+kfZ53V+AVtlpxN5eMOkzdfx3/B1P+sRtN/TZVGhth3SOXo/HcheD X-Received: by 10.98.64.9 with SMTP id n9mr7403774pfa.194.1518040227972; Wed, 07 Feb 2018 13:50:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518040227; cv=none; d=google.com; s=arc-20160816; b=aPy3jXoN98kTGP5cNEPto5JC2KfCJcOzFrRtLDj0B6okCEptmQAq+Ger61M+mqVqrF U9iC1lfsVc1JPdxo/KHv3IzC+UqXPu8EJoJE+MBEs9AepTm5qyHsSiHfejOy/Lnaw3nN 6/DGYF2fuVcAA300y+sHSpZSJMXbDQj0XADXpjyG/FjfbGxewZenqcP7O2+fQG1uZqiS O6kAIOJ8paMFIdOJdt8Lh8WeiCcBI9T7vO/b6QRkls/lZ8FsuXYmKfkPFiMrTr28Gzb4 Fg5Bpg1nYS2A0QRt2sXeI1jCplSXIEkecVVYMJbZv/LtLV9KWUNrR6wohMB6iZ72RENU uhyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=LRh+p5WAVK4hFwBL04+chsgkIJsH98ZBNfSkSp9bFXU=; b=aHq8QThhT23R/mJlee3UDyPLBv1XWAkuSSe2ANFxbMeWSzDwLrB6t9iIsoyZLkhMmo OThBAqnE6TlGHFXEbCz7Vjr8lpZRqSDThRXBXReOoV0yUChV3Lgpipkf178kh3BJQ8eu sdUjXbyni9x/q0feCH3AZL/BfteJLA/7OsuWotX0E8r7BISZpTncNsWbNGW2gAzHMVyV Q9HmabVBiRDKxi8V49gCRv8RkQN1jqZlXgnBXYE9b4c1nepG1cceeyYVFV5Jr597agzO j/NF6TeRh60WU1r78+OkhTxhS6DL09Vacp2r45ha4aaHMYx63PCSaBlWhJbd0f8j7XAI SZ8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@lechnology.com header.s=default header.b=wMDbxaXK; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x2-v6si1670228plv.672.2018.02.07.13.50.14; Wed, 07 Feb 2018 13:50:27 -0800 (PST) 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=fail header.i=@lechnology.com header.s=default header.b=wMDbxaXK; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750987AbeBGVti (ORCPT + 99 others); Wed, 7 Feb 2018 16:49:38 -0500 Received: from vern.gendns.com ([206.190.152.46]:38992 "EHLO vern.gendns.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750722AbeBGVth (ORCPT ); Wed, 7 Feb 2018 16:49:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lechnology.com; s=default; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=LRh+p5WAVK4hFwBL04+chsgkIJsH98ZBNfSkSp9bFXU=; b=wMDbxaXKmMFO4bmlk8WrmTyUCg f2SJSbcFt4/9h4IoLSOaHojVRj8eF4FA1I9TNARLRQ3qXdL/qZoLcKf/hAqG4Hekw8B4RVhkEqwuS p3d5Uscwq/9kITnDhRO06vY6aR3jUvJxeC1BSUiYFU75praS3HMIZYVW6Mfq+h3G222TjL5/+A5Ew +wwOnVocn6JtBIhigDYcEN1LGsM137GpjcDUNZmLO33E/9OoX4pnEP2NdtvzZ3E13SHlLMYDCbFUX r1cETj0f2GoW7ViIyEKR1NKb4wcmJqb0/nJneptpelWg57Z5MuhzhqKe1Gd7qDleFKXijE0t1Xe5I DbhMKuhg==; Received: from 108-198-5-147.lightspeed.okcbok.sbcglobal.net ([108.198.5.147]:57568 helo=[192.168.0.134]) by vern.gendns.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.89_1) (envelope-from ) id 1ejXZz-000Cgs-77; Wed, 07 Feb 2018 16:48:35 -0500 Subject: Re: [PATCH 2/7] soc: davinci: new genpd driver To: Bartosz Golaszewski , Rob Herring , Mark Rutland , Sekhar Nori , Kevin Hilman , Russell King Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Bartosz Golaszewski References: <20180207134553.13510-1-brgl@bgdev.pl> <20180207134553.13510-3-brgl@bgdev.pl> From: David Lechner Message-ID: <42938acb-7ad3-f19a-29d5-79151a7b7f4b@lechnology.com> Date: Wed, 7 Feb 2018 15:49:40 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <20180207134553.13510-3-brgl@bgdev.pl> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - vern.gendns.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lechnology.com X-Get-Message-Sender-Via: vern.gendns.com: authenticated_id: davidmain+lechnology.com/only user confirmed/virtual account not confirmed X-Authenticated-Sender: vern.gendns.com: davidmain@lechnology.com X-Source: X-Source-Args: X-Source-Dir: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/07/2018 07:45 AM, Bartosz Golaszewski wrote: > From: Bartosz Golaszewski > > Add a simple clock_pm-based driver for DaVinci SoCs. This is required > to complete the transision to using the common clock framework for this > architecture. > > Signed-off-by: Bartosz Golaszewski > --- > drivers/soc/Kconfig | 1 + > drivers/soc/Makefile | 1 + > drivers/soc/davinci/Kconfig | 16 ++++ > drivers/soc/davinci/Makefile | 1 + > drivers/soc/davinci/davinci_pm_domains.c | 125 +++++++++++++++++++++++++++++++ > 5 files changed, 144 insertions(+) > create mode 100644 drivers/soc/davinci/Kconfig > create mode 100644 drivers/soc/davinci/Makefile > create mode 100644 drivers/soc/davinci/davinci_pm_domains.c > > diff --git a/drivers/soc/Kconfig b/drivers/soc/Kconfig > index fc9e98047421..f318899a6cf6 100644 > --- a/drivers/soc/Kconfig > +++ b/drivers/soc/Kconfig > @@ -4,6 +4,7 @@ source "drivers/soc/actions/Kconfig" > source "drivers/soc/amlogic/Kconfig" > source "drivers/soc/atmel/Kconfig" > source "drivers/soc/bcm/Kconfig" > +source "drivers/soc/davinci/Kconfig" > source "drivers/soc/fsl/Kconfig" > source "drivers/soc/imx/Kconfig" > source "drivers/soc/mediatek/Kconfig" > diff --git a/drivers/soc/Makefile b/drivers/soc/Makefile > index deecb16e7256..8e5fe23d6678 100644 > --- a/drivers/soc/Makefile > +++ b/drivers/soc/Makefile > @@ -8,6 +8,7 @@ obj-$(CONFIG_ARCH_AT91) += atmel/ > obj-y += bcm/ > obj-$(CONFIG_ARCH_DOVE) += dove/ > obj-$(CONFIG_MACH_DOVE) += dove/ > +obj-$(CONFIG_ARCH_DAVINCI) += davinci/ > obj-y += fsl/ > obj-$(CONFIG_ARCH_MXC) += imx/ > obj-$(CONFIG_SOC_XWAY) += lantiq/ > diff --git a/drivers/soc/davinci/Kconfig b/drivers/soc/davinci/Kconfig > new file mode 100644 > index 000000000000..7ee44f4ff41e > --- /dev/null > +++ b/drivers/soc/davinci/Kconfig > @@ -0,0 +1,16 @@ > +# > +# TI DaVinci SOC drivers > +# > +menuconfig SOC_DAVINCI > + bool "TI DaVinci SOC drivers support" > + > +if SOC_DAVINCI > + > +config DAVINCI_PM_DOMAINS > + tristate "TI DaVinci PM Domains Driver" > + depends on ARCH_DAVINCI > + depends on PM_GENERIC_DOMAINS > + help > + Generic power domains driver for TI DaVinci family of SoCs. > + > +endif # SOC_DAVINCI > diff --git a/drivers/soc/davinci/Makefile b/drivers/soc/davinci/Makefile > new file mode 100644 > index 000000000000..822b03c18260 > --- /dev/null > +++ b/drivers/soc/davinci/Makefile > @@ -0,0 +1 @@ > +obj-$(CONFIG_DAVINCI_PM_DOMAINS) += davinci_pm_domains.o > diff --git a/drivers/soc/davinci/davinci_pm_domains.c b/drivers/soc/davinci/davinci_pm_domains.c > new file mode 100644 > index 000000000000..c27d4c404d52 > --- /dev/null > +++ b/drivers/soc/davinci/davinci_pm_domains.c > @@ -0,0 +1,125 @@ > +/* > + * TI DaVinci Generic Power Domain Driver > + * > + * Copyright (C) 2018 BayLibre SAS > + * Bartosz Golaszewski > + * > + * 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 in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > + > +struct davinci_genpd_ctx { > + struct device *dev; > + struct generic_pm_domain pd; > + struct clk *pm_clk; > +}; > + > +static int davinci_genpd_attach_dev(struct generic_pm_domain *domain, > + struct device *dev) > +{ > + struct davinci_genpd_ctx *ctx; > + struct clk *clk; > + int rv; > + > + ctx = container_of(domain, struct davinci_genpd_ctx, pd); > + > + if (dev->pm_domain) > + return -EEXIST; > + > + /* > + * DaVinci always uses a single clock for power-management. We assume > + * it's the first one in the clocks property. > + */ > + clk = of_clk_get(dev->of_node, 0); > + if (IS_ERR(clk)) > + return PTR_ERR(clk); > + > + rv = pm_clk_create(dev); > + if (rv) { > + clk_put(clk); > + return rv; > + } > + > + rv = pm_clk_add_clk(dev, clk); > + if (rv) { > + pm_clk_destroy(dev); > + return rv; > + } > + > + dev_pm_domain_set(dev, &domain->domain); > + ctx->pm_clk = clk; > + > + return 0; > +} > + > +static void davinci_genpd_detach_dev(struct generic_pm_domain *domain, > + struct device *dev) > +{ > + struct davinci_genpd_ctx *ctx; > + > + ctx = container_of(domain, struct davinci_genpd_ctx, pd); > + > + pm_clk_remove_clk(dev, ctx->pm_clk); > + pm_clk_destroy(dev); > +} > + > +static const struct of_device_id davinci_genpd_matches[] = { > + { .compatible = "ti,davinci-pm-domains", }, > + { }, > +}; > +MODULE_DEVICE_TABLE(of, davinci_genpd_matches); > + > +static int davinci_genpd_probe(struct platform_device *pdev) > +{ > + struct davinci_genpd_ctx *pd; > + struct device_node *np; > + struct device *dev; > + > + dev = &pdev->dev; > + np = dev->of_node; > + > + pd = devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL); > + if (!pd) > + return -ENOMEM; > + > + pd->pd.name = devm_kasprintf(dev, GFP_KERNEL, > + "davinci_pwc_pd%d", > + of_alias_get_id(np, "pwc")); > + if (!pd->pd.name) > + return -ENOMEM; > + > + pd->dev = dev; > + pd->pd.attach_dev = davinci_genpd_attach_dev; > + pd->pd.detach_dev = davinci_genpd_detach_dev; > + pd->pd.flags |= GENPD_FLAG_PM_CLK; > + > + pm_genpd_init(&pd->pd, NULL, true); > + > + return of_genpd_add_provider_simple(np, &pd->pd); > +} > + > +static struct platform_driver davinci_genpd_driver = { > + .probe = davinci_genpd_probe, > + .driver = { > + .name = "davinci_genpd", > + .of_match_table = davinci_genpd_matches, > + }, > +}; > +module_platform_driver(davinci_genpd_driver); > + > +MODULE_LICENSE("GPL v2"); > +MODULE_DESCRIPTION("TI DaVinci Generic Power Domains driver"); > +MODULE_AUTHOR("Bartosz Golaszewski "); > Likewise, I don't think we need a separate driver for this. Just register a genpd provider from the PSC clock driver.