From patchwork Sat Mar 24 13:31:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 132376 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1790022ljb; Sat, 24 Mar 2018 06:33:28 -0700 (PDT) X-Google-Smtp-Source: AG47ELvF/yv5HXUtAyCdJwkKMiF/tq2Zk4ASBOd4lhUxVH30ynB7yHcpbhz4OtPuYecOjl1z9lK7 X-Received: by 10.99.103.69 with SMTP id b66mr23670568pgc.233.1521898408458; Sat, 24 Mar 2018 06:33:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521898408; cv=none; d=google.com; s=arc-20160816; b=h14359/IzgE9xAKaLyDTbOBbTyI/lFmRJiYM4zpfN2GUKByeRFh9o5RrUp0oebcmVx MbxDEgIYSmY/6qeDlNG3SzMNk5VsuZINBD5sprc6BNRSRSGM/72RJBehUH/amhPRWOKM r9M727l1RwijVwkvQqfLku7iAKXUw+YRKgPUENBUqGaxZkxmmiKAAiAqiXxx9DD9454i /8b9ljAUacqQIC/XwSWcngSW9eQPwGDlR+PoVtCiZDXAf9D4DAUdkg/hFhFTJQPDkTWD 5p3jTMQ2TqUW32xVTlzOIvVvOPVF601+L/B4LfrrCrkqSDWaZLT1xbrYwNpR228mUNKY rgsQ== 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=WeN2pV4uc7Y6QdOvOL2uEl5SSRCRCPGzkg+OU3ORWdI=; b=Z5L1HaWr4Xf/lCzxONsOe+DPtEUO69HvsOxZ3fUS/1h8T+kHZk8YEpy3utIUzTBwge 6jOBHVWxDu+fv9mLTHD/7e3eYEW08V0t6puTWxOJc5x5l7CkiWMODqtbKai91e93k69m EqcXKOftLRtDWBHwLtO3aM2z4Qg0L62P1XJ7ciYj39rq9QkChq4/fayqyrq5WCVhibB9 bpoKEKLqtjd0NwGkL5BzjY+7mKQ3TUap78lInqQnGKHFmO5V5RynxItsenCuce5cc6+t dl+TOA6T5iD3l7cDmx1LnwMGLledxKJz4e1NJZcmIV6BwlxJM1u35YoG4Tm+1mAP4pDc 5BlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UsKcA1j3; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p29si948221pgd.392.2018.03.24.06.33.28; Sat, 24 Mar 2018 06:33:28 -0700 (PDT) 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=@linaro.org header.s=google header.b=UsKcA1j3; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752352AbeCXNd0 (ORCPT + 28 others); Sat, 24 Mar 2018 09:33:26 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:45908 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752314AbeCXNdY (ORCPT ); Sat, 24 Mar 2018 09:33:24 -0400 Received: by mail-pl0-f66.google.com with SMTP id n15-v6so9118349plp.12 for ; Sat, 24 Mar 2018 06:33:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=WeN2pV4uc7Y6QdOvOL2uEl5SSRCRCPGzkg+OU3ORWdI=; b=UsKcA1j3QC4cR4L+gkyEE7c9bQwSN35UzFLprU3rqSnKaRt4v1AZL7d28syUEvnp7n 7gPdIHhTFd3IvultlJgCAUOacFl1RUB7nyURws3Wz336fROGtvjw3TYE0Hwr1Z3kas9u YC2v1Hv1LPNrIhdVJsaeXdC3NnDFMKLtZ/a1A= 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=WeN2pV4uc7Y6QdOvOL2uEl5SSRCRCPGzkg+OU3ORWdI=; b=ikYP9aS1qL28jJLrDbLcSoIuygsmmR8tPMSV9jfEFIWvuvqKdD9C2HYIK2hQJvQIml aLITpIqD8KgQ8gTrTfIzNdEhdFTO3mxzW6o5rKFLpBzWgY8aF8QLe5PjSmWPoX4kKZq7 eifBvXPCVMbxoaiZaOpqhS1dopSz6iSUUirfQ0FEXtygxbd3nyuFStK7ZDYX5iWkSgtd C+LtG1AxNVeeJI37O8Xcsty4zUfXpuwJ3wyFKEzZj71cGGFzxnJbtn0ITk2ayGo1y7T1 UklXS5Atbz0vajQlHp3TwUbEXMNij34U4VLyAL5ze8F5FGtgjIpxjonrqGUdAYmvoiEw rOgA== X-Gm-Message-State: AElRT7HOnfr+lMtGvFGt2L90MgjapC2qMdA/uTvBdSKXQWD6IVxn9xZy azVCM8fE0iHuFNyFqG/1a4WP X-Received: by 2002:a17:902:a713:: with SMTP id w19-v6mr32601640plq.246.1521898403389; Sat, 24 Mar 2018 06:33:23 -0700 (PDT) Received: from localhost.localdomain ([2405:204:7401:11e6:b12d:f551:4edc:7f21]) by smtp.gmail.com with ESMTPSA id a76sm4133980pfc.97.2018.03.24.06.33.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 24 Mar 2018 06:33:22 -0700 (PDT) From: Manivannan Sadhasivam To: mturquette@baylibre.com, sboyd@kernel.org, afaerber@suse.de, robh+dt@kernel.org, mark.rutland@arm.com Cc: liuwei@actions-semi.com, mp-cs@actions-semi.com, 96boards@ucrobotics.com, devicetree@vger.kernel.org, davem@davemloft.net, mchehab@kernel.org, daniel.thompson@linaro.org, amit.kucheria@linaro.org, viresh.kumar@linaro.org, hzhang@ucrobotics.com, bdong@ucrobotics.com, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, manivannanece23@gmail.com, Manivannan Sadhasivam Subject: [PATCH v6 03/11] clk: actions: Add common clock driver support Date: Sat, 24 Mar 2018 19:01:51 +0530 Message-Id: <20180324133159.4824-4-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180324133159.4824-1-manivannan.sadhasivam@linaro.org> References: <20180324133159.4824-1-manivannan.sadhasivam@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add support for Actions Semi common clock driver with generic structures and interface functions. Signed-off-by: Manivannan Sadhasivam --- drivers/clk/Kconfig | 1 + drivers/clk/Makefile | 1 + drivers/clk/actions/Kconfig | 4 ++ drivers/clk/actions/Makefile | 3 ++ drivers/clk/actions/owl-common.c | 89 ++++++++++++++++++++++++++++++++++++++++ drivers/clk/actions/owl-common.h | 41 ++++++++++++++++++ 6 files changed, 139 insertions(+) create mode 100644 drivers/clk/actions/Kconfig create mode 100644 drivers/clk/actions/Makefile create mode 100644 drivers/clk/actions/owl-common.c create mode 100644 drivers/clk/actions/owl-common.h -- 2.14.1 diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig index 98ce9fc6e6c0..6313a4f4327a 100644 --- a/drivers/clk/Kconfig +++ b/drivers/clk/Kconfig @@ -238,6 +238,7 @@ config COMMON_CLK_VC5 This driver supports the IDT VersaClock 5 and VersaClock 6 programmable clock generators. +source "drivers/clk/actions/Kconfig" source "drivers/clk/bcm/Kconfig" source "drivers/clk/hisilicon/Kconfig" source "drivers/clk/imgtec/Kconfig" diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile index 71ec41e6364f..b7909df532ed 100644 --- a/drivers/clk/Makefile +++ b/drivers/clk/Makefile @@ -56,6 +56,7 @@ obj-$(CONFIG_COMMON_CLK_WM831X) += clk-wm831x.o obj-$(CONFIG_COMMON_CLK_XGENE) += clk-xgene.o # please keep this section sorted lexicographically by directory path name +obj-y += actions/ obj-$(CONFIG_COMMON_CLK_AT91) += at91/ obj-$(CONFIG_ARCH_ARTPEC) += axis/ obj-$(CONFIG_ARC_PLAT_AXS10X) += axs10x/ diff --git a/drivers/clk/actions/Kconfig b/drivers/clk/actions/Kconfig new file mode 100644 index 000000000000..13a3e5083d43 --- /dev/null +++ b/drivers/clk/actions/Kconfig @@ -0,0 +1,4 @@ +config CLK_ACTIONS + bool "Clock driver for Actions Semi SoCs" + depends on ARCH_ACTIONS || COMPILE_TEST + default ARCH_ACTIONS diff --git a/drivers/clk/actions/Makefile b/drivers/clk/actions/Makefile new file mode 100644 index 000000000000..64a50fc2d335 --- /dev/null +++ b/drivers/clk/actions/Makefile @@ -0,0 +1,3 @@ +obj-$(CONFIG_CLK_ACTIONS) += clk-owl.o + +clk-owl-y += owl-common.o diff --git a/drivers/clk/actions/owl-common.c b/drivers/clk/actions/owl-common.c new file mode 100644 index 000000000000..61c1071b5180 --- /dev/null +++ b/drivers/clk/actions/owl-common.c @@ -0,0 +1,89 @@ +// SPDX-License-Identifier: GPL-2.0+ +// +// OWL common clock driver +// +// Copyright (c) 2014 Actions Semi Inc. +// Author: David Liu +// +// Copyright (c) 2018 Linaro Ltd. +// Author: Manivannan Sadhasivam + +#include +#include +#include +#include + +#include "owl-common.h" + +static const struct regmap_config owl_regmap_config = { + .reg_bits = 32, + .reg_stride = 4, + .val_bits = 32, + .max_register = 0x00cc, + .fast_io = true, +}; + +static void owl_clk_set_regmap(const struct owl_clk_desc *desc, + struct regmap *regmap) +{ + int i; + struct owl_clk_common *clks; + + for (i = 0; i < desc->num_clks; i++) { + clks = desc->clks[i]; + if (!clks) + continue; + + clks->regmap = regmap; + } +} + +int owl_clk_regmap_init(struct platform_device *pdev, + const struct owl_clk_desc *desc) +{ + void __iomem *base; + struct regmap *regmap; + struct resource *res; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + base = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(base)) + return PTR_ERR(base); + + regmap = devm_regmap_init_mmio(&pdev->dev, base, &owl_regmap_config); + if (IS_ERR(regmap)) { + pr_err("failed to init regmap\n"); + return PTR_ERR(regmap); + } + + owl_clk_set_regmap(desc, regmap); + + return 0; +} + +int owl_clk_probe(struct device *dev, struct clk_hw_onecell_data *hw_clks) +{ + int i, ret; + struct clk_hw *hw; + + for (i = 0; i < hw_clks->num; i++) { + + hw = hw_clks->hws[i]; + + if (IS_ERR_OR_NULL(hw)) + continue; + + ret = devm_clk_hw_register(dev, hw); + if (ret) { + dev_err(dev, "Couldn't register clock %d - %s\n", + i, hw->init->name); + return ret; + } + } + + ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, hw_clks); + if (ret) + dev_err(dev, "Failed to add clock provider\n"); + + return ret; +} diff --git a/drivers/clk/actions/owl-common.h b/drivers/clk/actions/owl-common.h new file mode 100644 index 000000000000..4fd726ec54a6 --- /dev/null +++ b/drivers/clk/actions/owl-common.h @@ -0,0 +1,41 @@ +// SPDX-License-Identifier: GPL-2.0+ +// +// OWL common clock driver +// +// Copyright (c) 2014 Actions Semi Inc. +// Author: David Liu +// +// Copyright (c) 2018 Linaro Ltd. +// Author: Manivannan Sadhasivam + +#ifndef _OWL_COMMON_H_ +#define _OWL_COMMON_H_ + +#include +#include +#include + +struct device_node; + +struct owl_clk_common { + struct regmap *regmap; + struct clk_hw hw; +}; + +struct owl_clk_desc { + struct owl_clk_common **clks; + unsigned long num_clks; + struct clk_hw_onecell_data *hw_clks; +}; + +static inline struct owl_clk_common * + hw_to_owl_clk_common(const struct clk_hw *hw) +{ + return container_of(hw, struct owl_clk_common, hw); +} + +int owl_clk_regmap_init(struct platform_device *pdev, + const struct owl_clk_desc *desc); +int owl_clk_probe(struct device *dev, struct clk_hw_onecell_data *hw_clks); + +#endif /* _OWL_COMMON_H_ */