From patchwork Mon Mar 26 17:38:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 132426 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp4116584ljb; Mon, 26 Mar 2018 10:42:05 -0700 (PDT) X-Google-Smtp-Source: AG47ELtEBRL2jtUV4hAUtMRg7ZneBQCTbKcS0rJadGbiNb8Y21KraRobcPLznwHyKFdzLUc6YgMl X-Received: by 10.98.8.133 with SMTP id 5mr20660584pfi.154.1522086125521; Mon, 26 Mar 2018 10:42:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522086125; cv=none; d=google.com; s=arc-20160816; b=uBTxGFoxiyKXH9AphGmsPON5v2pWQTQ8l8KOSon2jsjq9WRr92qHnEylFWDxEcMnoj Z4varapmb96dUBWjFzUcCNTodhXaXUGgk8tZPQxmTj8KPu0Yu81N/gLBpLjibAmC+3Lm BRbsTm2Vy5z+HNsETt/LDc3PoDEYD4VwCgo9MCIwspdejxvFG3+3sdCrucpDqRPAz2n+ mSRhG2iGuEsq2W/SdXd3ye1n5ZW30hdhXk8qWwTpeFgw6cPusxs8mf9R5gjrStld0Tpz 2ZB6/hsMIT5OuULR8g9xp3NKWGcDloiyG7S1se7o+TilOt5c6Z3O3U+YtXBn2NYUGUeY 48oA== 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=G3kep1LzgtkDH3mUZezm5DqUyADBNUMqfOOuTmS4N9d0+Si1JdWcWlPPlW5VX/OWVy CSBwEDZwBPHiBbRInufnPscVZslFSb52dlbXfYKyvW9djo7nY8L5GDdM2kxtFGS2Z5hK IWnF2x3oUnkHBxd8E1DDiRYIBIdmiX1/EPUdTRJ9mF3buPWoxKVMYW36wgUJ6qIBb4PH Zn+Z9eJ3ABhXejvlhQgdozRKMSE5J/23MWi2w6/gcIkdBaEWpdfq5RmDYfVRi15RAFjM Hhw0J8gU7l7SK50vtr2dkQCJGUyQCD20wQe4N/Kl7AmOHb04r7KVvnzuszEzKWQLAW72 JOJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SfsSO1Lu; 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 s10si10417341pgp.162.2018.03.26.10.42.05; Mon, 26 Mar 2018 10:42:05 -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=SfsSO1Lu; 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 S1752851AbeCZRmC (ORCPT + 28 others); Mon, 26 Mar 2018 13:42:02 -0400 Received: from mail-pl0-f68.google.com ([209.85.160.68]:39430 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752828AbeCZRl7 (ORCPT ); Mon, 26 Mar 2018 13:41:59 -0400 Received: by mail-pl0-f68.google.com with SMTP id s24-v6so2004667plq.6 for ; Mon, 26 Mar 2018 10:41:59 -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=SfsSO1LuR+S85Dr1sJ4UKYIGJqtrbQhbExrmhtsgsD18svLuiXOuXG+fN3an+d8vgp fQmgRMe6pe4U4CMn3mk82vMqyNqsFEKpMwrfrfc50Efr4Uja7YBLrvcQtrVWQWWwA7ju l1eKVFKAGHqp34oWYQGVo34ORbIy236JgEL+Y= 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=Q0uw2CNkUh2GFOP4epnvIOEIDdWIlXK+zn5HXzd/E2LunlA9jSP4Aq9kK5XHwneQRL RunhUt4MjaG/WgoxNKvDGp+KtMT5itTOX0gVWzE80n94pfQyVDsr6ENYwjnJh8JT2+BN RYfFRwTFpxGxKUIZlQzHS/ulT9R37SAMzUrEpOAgttUFKea0Ipt7xg9bIMPpbSnHRJ/+ P7uO2DwOWTRMIIlFsntFCuDSIsigx2ooIUhQAvT1tMJ8bUfrC+Q2Qyf3350XuPGvS/o9 dJLIGR8/cjsju5ZBfXM8LhD4mQqxDsjkwNmgJ2XUHu1nWmSW8jCNIiHGo0NVNy/cXH4Q 2uWA== X-Gm-Message-State: AElRT7Fz/11ZECfhc2Z3GtqR0tNOb/3P9VBqGKqUOLn8+4vuYe9dS998 7KX9C1SSU59KBwOkPa3WaP/R X-Received: by 2002:a17:902:d807:: with SMTP id a7-v6mr41662930plz.218.1522086119075; Mon, 26 Mar 2018 10:41:59 -0700 (PDT) Received: from localhost.localdomain ([2405:204:73cc:afee:304e:6518:873b:59b1]) by smtp.gmail.com with ESMTPSA id x14sm24986115pgo.82.2018.03.26.10.41.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Mar 2018 10:41:58 -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 v7 03/11] clk: actions: Add common clock driver support Date: Mon, 26 Mar 2018 23:08:57 +0530 Message-Id: <20180326173905.22313-4-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180326173905.22313-1-manivannan.sadhasivam@linaro.org> References: <20180326173905.22313-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_ */