From patchwork Fri Mar 2 05:48:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 130469 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp906519lja; Thu, 1 Mar 2018 21:51:17 -0800 (PST) X-Google-Smtp-Source: AG47ELtHVlwFOVYDcTZyR+GwDmHkBn1WsTj/ocO5t6yLryezmlM7QAfm8HWDX/EaJaxa2PEEc0/E X-Received: by 10.98.12.149 with SMTP id 21mr4573680pfm.118.1519969877125; Thu, 01 Mar 2018 21:51:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519969877; cv=none; d=google.com; s=arc-20160816; b=PsgouX2sfY0SFq5YrgecFN7Nona3ZBbi0qDh7C93mdJcE0u8X9aUodr5XajcXPa1Cb zTLFDDGtvx2wmKPQRs9FoZW5dxfjEQgPTA6FqnV1fdqYNQXH6qKxI/orSEVIZOHhyM4U tSBIZU6m1SJDucXBbzZpZYTlhe6uZKm04gKz1ggBTnLlEoVaFRaQYcDzhWgJN2+X4qUx G3JVPRAYM5npODhQ0nIvdrA0fhcpb5iAxHtGrgFW4CQf3trAKDXHi2a6Q+K7FF+3B25F RegjdRTbY9ooRN4jApnU+GWLzSShcXWR3A0JP6ZnL4gw5lFZjubzfIn3j9p0qlHHAds6 rsOw== 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=SQGyxKuKh7kk1DTIAS5AB/WGlPSeIM69CRcjILG6EAg=; b=HpUs5zeI+gHTeD5UMxDK4txDCnGMIWDHBBaERy1I5GNSMR7qEP3uqESurFTqzviNRk LEgCj0XvxunwPF5mGITEe1S4UPx0oro+Dp+TcJJL6dMgkdNHSHv3/AIpiRo+JSrOoQCu 1tIBF2Wd5ST3/gtyvohsBN5bruxB68e5rzsYsGTVo85aRD3KTVYeNiJJdHIoSqZZ83FK EBvIzdy3ksy0cdzkja/Ecv03l8wbyxAtJfLBSI8h8TO+qLlzOLir/z2MFNMFGmbCLeeJ xiDZinj2W88DmWdZfhDPNmxN5jW/3GLqP0Dx9jO0JYpBoqiY1nkFvvad0l3bAT79D9My 8VXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SkmugrbZ; 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 e9-v6si4204910plt.685.2018.03.01.21.51.16; Thu, 01 Mar 2018 21:51:17 -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=@linaro.org header.s=google header.b=SkmugrbZ; 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 S935984AbeCBFvN (ORCPT + 28 others); Fri, 2 Mar 2018 00:51:13 -0500 Received: from mail-pg0-f66.google.com ([74.125.83.66]:46619 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935969AbeCBFvJ (ORCPT ); Fri, 2 Mar 2018 00:51:09 -0500 Received: by mail-pg0-f66.google.com with SMTP id r26so3337302pgv.13 for ; Thu, 01 Mar 2018 21:51:09 -0800 (PST) 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=SQGyxKuKh7kk1DTIAS5AB/WGlPSeIM69CRcjILG6EAg=; b=SkmugrbZxTVR+9l2AcNURZcWpcE+9Fv0lZMVwkVSZYXcdVl/DuVuVcJsNa2Ln7bIqE stT5acLkn634g4+i3crMwmG1hUvikGcyGFuPkmFZSviQdZbRbOnszWqyUBfy3skG5mRK Qvu2zuF43q5DLqOf/fJQA6LQXA9/5SRtCxFFg= 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=SQGyxKuKh7kk1DTIAS5AB/WGlPSeIM69CRcjILG6EAg=; b=KTL3+ZLGXjRoYmbb79tMjRbmEMcgIFd20U3vn+UuBLTd6vKhYZXpfVlnVnQOCI8ZCx cqRG4FKAXL/j8dZ2zWWsfpNXJfEk/foNlMl/m3DZ8xkdGuoGcvVUaOOelNRm/ve8toMt 2IQZfxyPYIYmiHS7yRR5TQ73NW/cuGOtpbp/mKjwSFiMKywQmJX9WPBKBzDt+51kflyd PgVE8b3FbC0Z92xVnjp1m6classIijCqzxtFTkubGl8Pk8sNo05kL3UCIWlfnfdnqM8j W+pA4DLV/MUxcrVlVgjy14tl9wtrZiIoToAtda+hj+45x7cgaQC1jmimVKNmdBCTz9OI O+Yg== X-Gm-Message-State: APf1xPAGpsP6yGNIwu4hT9HWkH/zyNVdlsqPF/F1aRNyiNbSAvKggBq/ lrBFa3feGBmQQ4qZ/yPO2T0x X-Received: by 10.99.1.12 with SMTP id 12mr3635145pgb.179.1519969868397; Thu, 01 Mar 2018 21:51:08 -0800 (PST) Received: from localhost.localdomain ([2405:204:71c0:7f9a:bd87:b648:dccb:cbc9]) by smtp.gmail.com with ESMTPSA id t63sm12569748pfj.44.2018.03.01.21.50.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Mar 2018 21:51:07 -0800 (PST) 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, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, manivannanece23@gmail.com, Manivannan Sadhasivam Subject: [PATCH v4 04/11] clk: actions: Add common clock driver support Date: Fri, 2 Mar 2018 11:18:53 +0530 Message-Id: <20180302054900.11275-5-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180302054900.11275-1-manivannan.sadhasivam@linaro.org> References: <20180302054900.11275-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 | 84 ++++++++++++++++++++++++++++++++++++++++ drivers/clk/actions/owl-common.h | 41 ++++++++++++++++++++ 6 files changed, 134 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..a7cb698fdc86 --- /dev/null +++ b/drivers/clk/actions/owl-common.c @@ -0,0 +1,84 @@ +// 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 "owl-common.h" + +static const struct regmap_config owl_regmap_config = { + .reg_bits = 32, + .reg_stride = 4, + .val_bits = 32, + .max_register = 0xffff, + .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 device_node *node = pdev->dev.of_node; + struct regmap *regmap; + + base = of_iomap(node, 0); + regmap = devm_regmap_init_mmio(&pdev->dev, base, &owl_regmap_config); + if (IS_ERR_OR_NULL(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 (!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_ */