Received: by 10.223.176.5 with SMTP id f5csp676488wra; Wed, 7 Feb 2018 05:50:02 -0800 (PST) X-Google-Smtp-Source: AH8x226rrftzKRlNM4SkmEejkUsmElsoHntQYXU1JoBcYfmEtpPR6WArkIH0LE2VDuFv5o9MF9Z3 X-Received: by 2002:a17:902:9a97:: with SMTP id w23-v6mr6237493plp.100.1518011402257; Wed, 07 Feb 2018 05:50:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518011402; cv=none; d=google.com; s=arc-20160816; b=deJm+NZSA8VGZmEw1MR+2bubddwy8W41IDG+QjU2iGxvTh6dXJoY9arnvDtNG9VMB2 iv84XQNC2E+Fhj3LavoclYsYy3WIshuJKJhXbi9U7/HSWeCn+tBqbwVAHdYxaXDrQgSi PUhkbAkfhq+1l6/H760RMDRuNPAy4F+skLIgGNjgmLGqKGszlm6cbjJ1joPSWtunj2JU F6HYQGEtPq7aVDiQmTfPvt7HPwi5G42CNsxAApKvxmVa4o1uE5IgCbT0i3TQy3st49QM 0x/sewVIlW91HFbbehzu8/E0ef66WKdbw89IqvShYseAOmbz85R+gOQgHYwi7uodJBEP fsmw== 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=52AJxxUbyNRb4cZdBiG7youujiomOSLCAYQpMwh8U/Y=; b=JREVUv6BONi2mVCwFXeXMq5xftdUUD5F9YtGNflAhaNo+UzHXcGU5iR2CeN+VLgBNo ZwdUzHENKz7igQGSbax8g2hn0s/NES7FNhc2ZJnu/kudgUOg/fwCIlreySwiM5Onlro1 boY742LtmAWWv/D9cTkzbQ95Gc51e+tZu5ICOZDevADyIi/aoJRbZ6yCzqVKaE4OsXAW t53K186vXbJd6JHDNKB/r/HpGjqnwHVAr//xlifNiCAX3J5CRSs6pu7Cpu65mclSeHmK gMOhDiL0kDjiz1P0JPk724DSqFjD/G8CC7cAj0qTvDOF75iqYr0k9TIjgHUnI/N7eKW3 iwYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=MBDQR89t; 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 67-v6si1115766ple.609.2018.02.07.05.49.48; Wed, 07 Feb 2018 05:50:02 -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=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=MBDQR89t; 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 S1754383AbeBGNr2 (ORCPT + 99 others); Wed, 7 Feb 2018 08:47:28 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:38727 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754151AbeBGNqJ (ORCPT ); Wed, 7 Feb 2018 08:46:09 -0500 Received: by mail-wm0-f67.google.com with SMTP id 141so3411135wme.3 for ; Wed, 07 Feb 2018 05:46:08 -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=S7uFtPpUiRueaCX/brXetG3tSB6YW2c3HLr1WaidhlamAWPxZrEdm5MOtMT6dBNQU/ gGgpVkluHr5qCG3boaYdX0rgnk3k5D8oDRaJP6RD5mWWNGagGJmXdXanMMHXBRGMj4Ks 7jKG4ilnWa6zYJweAY+7/027lHM6mHax/+nmWZX1oxFFUsAN/Gr0a0SX7ZUBdO+7Pbp4 bBvS/Ep0teZSF6AVPWWCcu0TitcQ3Oksyc2k/HU0W5CVi9Wtle+tFTrGF6blF9GZIj4w csWgWyOBSpijJCENfmsCc+JsnzwP2kAcc3DrhlGdHcmjLs9yprAkgQ+3jt4sPRPqQSf2 UXOQ== X-Gm-Message-State: APf1xPDJayWc/9hTGDMbMVbwUQfmLOytmWsnbX9I6iwvpoO2aml3xSx9 jNw762V0bEexeZUmaQLLH+sH7eFRGM4= 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 Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Bartosz Golaszewski 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 "); -- 2.16.1