From patchwork Wed Feb 7 13:45:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10205197 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5E19E60247 for ; Wed, 7 Feb 2018 13:46:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4BF6720182 for ; Wed, 7 Feb 2018 13:46:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 402DE28518; Wed, 7 Feb 2018 13:46:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B36E920182 for ; Wed, 7 Feb 2018 13:46:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=JxhhQQmT2ww6hVR9oh8hTZSHN6fqNRqFRCEOuRupdZE=; b=Pzb+GSwkh5WRA1Z0YAGs3enQzi 8mqgKKKYEdb4mn1tg1B9G3EbFzLcMd5FYFVxRsu4LJm1s3iE4fohO5niR7VJh06TNnZwRMyWTCyEy SBAaibLyhL+efrBwf21s01xCdj0ywepl/B+BWgw9ejgB91sgqfunMJQ1EDDv3py6NMALSZ70zVs/Y Taz2iGD0b+tuT19ijGYATkWx7I8LgnWKhYr3sMQcG8RL50ozihBVoqA4TYBUPWvhmInFX5TVJXxdN aGsQ9X7qGXZ+G38sEhvu6RUh7mEz/uvllwok+uFrspQMhEoAdVAAtpxuW3lMG02YadnhfBjKSDeyE qHMBZdSQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1ejQ3n-000345-Kt; Wed, 07 Feb 2018 13:46:51 +0000 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1ejQ3H-0002OU-KX for linux-arm-kernel@lists.infradead.org; Wed, 07 Feb 2018 13:46:21 +0000 Received: by mail-wm0-x241.google.com with SMTP id 143so3220387wma.5 for ; Wed, 07 Feb 2018 05:46:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=52AJxxUbyNRb4cZdBiG7youujiomOSLCAYQpMwh8U/Y=; b=MBDQR89trEQuLJQvPktR3klh+uyu86Sf4/ud52R06XZvm7KBBphRvQEcprOVAsP4x7 nO6GWJv+Pywd5bciUuFSpXGK/L3zrlh0XZaNIF+RxLhWdkE3JVK/Tu9Uk4F0h6WuQwQs tRP4PpHEoDT6yyGM0UCoTmQP7gRbKIMo/0RvxPZMVWeCbRIUWLtX7oteJNItPValYV2v 9T1Gn0mLdHSc/ddlncxewhe5B8kx28PyYeQFOPaS0BW3cJHJo8BcuWHk4uRbsnRl7mku +EyQFiUAQ/RpVKHLGQ8Cp0ZiyDeQ7oN3OC8obKtztAqlT4BK7hcKNQEsVknRKU3bGiXe PRLQ== 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=52AJxxUbyNRb4cZdBiG7youujiomOSLCAYQpMwh8U/Y=; b=q4gQJ5aU8UZZnmz7c4PlPdARPAkv4a1DTiUX5uCf60AH1/p2psivCQfH97Bzf+A8hx H/2tDMmpLKeyFJm1C/LNTjRr4kNApJTq83YnptU5GNMiLQ2cjQmybqRS24uJrZcq271n RYYCcOarpjuyCWCBj7R0XKxPAB5HoGy+O+C5GEFNfih088uGL0WwYX8PMLtP85Godwxm rLlfngBnKZf0I/hnxLlm7jUO8+OW4WrkljliknrbyDOC0r/cR0SlpL802NV3kJPD7Hwi Z7ea9BV9HMbcfjxbX06dKuXi65RVk+DfLpgE04NmmeVtFY5lucIvEflq2dlRBKbujToo By+g== X-Gm-Message-State: APf1xPC7iTrRcqjhEiO08bx1UjbSDA67xgUjivQ8LqnK1adg1HXrUHPR kAh1vGZCNp27Pss3HLr7yoganw== X-Google-Smtp-Source: AH8x2277xdRaeQJNAlu7NdlSbV8pxeV2zJfHRmgVPL6EU3p+r19Cq0QDPu22cle25+b8MTy/W3Mo0g== X-Received: by 10.28.92.70 with SMTP id q67mr4882162wmb.43.1518011167772; Wed, 07 Feb 2018 05:46:07 -0800 (PST) Received: from brgl-bgdev.baylibre.local ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id 62sm1336371wrg.81.2018.02.07.05.46.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Feb 2018 05:46:07 -0800 (PST) From: Bartosz Golaszewski To: Rob Herring , Mark Rutland , Sekhar Nori , Kevin Hilman , Russell King , David Lechner Subject: [PATCH 2/7] soc: davinci: new genpd driver Date: Wed, 7 Feb 2018 14:45:48 +0100 Message-Id: <20180207134553.13510-3-brgl@bgdev.pl> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180207134553.13510-1-brgl@bgdev.pl> References: <20180207134553.13510-1-brgl@bgdev.pl> X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Bartosz Golaszewski MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 ");