LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Olof Johansson <olof@lixom.net>, Arnd Bergmann <arnd@arndb.de>
Cc: linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, "Rob Herring" <robh+dt@kernel.org>,
"Eddie Huang" <eddie.huang@mediatek.com>,
"Matthias Brugger" <matthias.bgg@gmail.com>,
"Samuel Ortiz" <sameo@linux.intel.com>,
"Lee Jones" <lee.jones@linaro.org>,
"Yingjoe Chen (陳英洲)" <Yingjoe.Chen@mediatek.com>,
"Henry Chen" <henryc.chen@mediatek.com>,
"YH Chen (陳昱豪)" <yh.chen@mediatek.com>,
kernel@pengutronix.de, "Sascha Hauer" <s.hauer@pengutronix.de>
Subject: [PATCH 2/8] soc: Add MediaTek pericfg controller support
Date: Thu, 5 Feb 2015 16:25:32 +0100 [thread overview]
Message-ID: <1423149938-14471-3-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1423149938-14471-1-git-send-email-s.hauer@pengutronix.de>
This adds support for the MediaTek pericfg controller found
on the MT8135/MT8173 SoCs. The pericfg controller contains
miscellaneous registers for controlling peripheral resets and
clocks.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
.../devicetree/bindings/soc/mediatek/pericfg.txt | 29 +++++
drivers/soc/mediatek/Kconfig | 10 ++
drivers/soc/mediatek/Makefile | 1 +
drivers/soc/mediatek/mtk-pericfg.c | 127 +++++++++++++++++++++
4 files changed, 167 insertions(+)
create mode 100644 Documentation/devicetree/bindings/soc/mediatek/pericfg.txt
create mode 100644 drivers/soc/mediatek/mtk-pericfg.c
diff --git a/Documentation/devicetree/bindings/soc/mediatek/pericfg.txt b/Documentation/devicetree/bindings/soc/mediatek/pericfg.txt
new file mode 100644
index 0000000..3996e171
--- /dev/null
+++ b/Documentation/devicetree/bindings/soc/mediatek/pericfg.txt
@@ -0,0 +1,29 @@
+MediaTek pericfg Controller
+===========================
+
+The pericfg controller contains miscellaneous registers for controlling
+clocks, resets and bus settings.
+
+Required properties:
+- compatible: must be one of:
+ mediatek,mt8135-pericfg
+ mediatek,mt8173-pericfg
+- reg: Address range for the pericfg controller
+- #reset-cells: 1, see below
+
+Specifying reset lines connected to the pericfg controller
+==========================================================
+
+The infracfg controller provides various reset sources to other modules.
+Device nodes using these reset sources should specify the reset lines in
+a property containing a phandle to the infracfg node and a reset index.
+See include/dt-bindings/reset-controller/<soc>-resets.h for a list of valid
+indices.
+
+Example:
+
+ pericfg: pericfg@10003000 {
+ #reset-cells = <1>;
+ compatible = "mediatek,mt8135-pericfg";
+ reg = <0 0x10003000 0 0x1000>;
+ };
diff --git a/drivers/soc/mediatek/Kconfig b/drivers/soc/mediatek/Kconfig
index 3ad39fe..9bdb88f 100644
--- a/drivers/soc/mediatek/Kconfig
+++ b/drivers/soc/mediatek/Kconfig
@@ -10,3 +10,13 @@ config MTK_INFRACFG
contains several miscellaneous registers for clock, reset and bus
settings. Say yes here if you want to run your kernel on one of these
SoCs.
+
+config MTK_PERICFG
+ tristate "MediaTek pericfg controller support"
+ depends on ARCH_MEDIATEK || COMPILE_TEST
+ select REGMAP
+ help
+ The MediaTek pericfg controller found on MT8135 and MT8173 SoCs
+ contains several miscellaneous registers for clock, reset and bus
+ settings. Say yes here if you want to run your kernel on one of these
+ SoCs.
diff --git a/drivers/soc/mediatek/Makefile b/drivers/soc/mediatek/Makefile
index dbeb627..e67be7c 100644
--- a/drivers/soc/mediatek/Makefile
+++ b/drivers/soc/mediatek/Makefile
@@ -1 +1,2 @@
obj-$(CONFIG_MTK_INFRACFG) += mtk-infracfg.o
+obj-$(CONFIG_MTK_PERICFG) += mtk-pericfg.o
diff --git a/drivers/soc/mediatek/mtk-pericfg.c b/drivers/soc/mediatek/mtk-pericfg.c
new file mode 100644
index 0000000..aa9a7eb
--- /dev/null
+++ b/drivers/soc/mediatek/mtk-pericfg.c
@@ -0,0 +1,127 @@
+/*
+ * Copyright (c) 2014 MediaTek Inc.
+ *
+ * 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 <linux/mfd/syscon.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/regmap.h>
+#include <linux/reset-controller.h>
+
+struct mtk_pericfg {
+ struct regmap *regmap;
+ struct reset_controller_dev rcdev;
+};
+
+static int mtk_pericfg_reset_assert(struct reset_controller_dev *rcdev,
+ unsigned long id)
+{
+ struct mtk_pericfg *data = container_of(rcdev, struct mtk_pericfg, rcdev);
+
+ return regmap_update_bits(data->regmap, (id / 32) << 2, BIT(id % 32), ~0);
+}
+
+static int mtk_pericfg_reset_deassert(struct reset_controller_dev *rcdev,
+ unsigned long id)
+{
+ struct mtk_pericfg *data = container_of(rcdev, struct mtk_pericfg, rcdev);
+
+ return regmap_update_bits(data->regmap, (id / 32) << 2, BIT(id % 32), 0);
+}
+
+static int mtk_pericfg_reset(struct reset_controller_dev *rcdev,
+ unsigned long id)
+{
+ int ret;
+
+ ret = mtk_pericfg_reset_assert(rcdev, id);
+ if (ret)
+ return ret;
+
+ return mtk_pericfg_reset_deassert(rcdev, id);
+}
+
+static struct reset_control_ops mtk_pericfg_reset_ops = {
+ .assert = mtk_pericfg_reset_assert,
+ .deassert = mtk_pericfg_reset_deassert,
+ .reset = mtk_pericfg_reset,
+};
+
+static struct regmap_config mtk_pericfg_regmap_config = {
+ .reg_bits = 32,
+ .val_bits = 32,
+ .reg_stride = 4,
+};
+
+static int mtk_pericfg_probe(struct platform_device *pdev)
+{
+ struct mtk_pericfg *data;
+ struct resource *res;
+ void __iomem *base;
+
+ data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
+ if (!data)
+ return -ENOMEM;
+
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ base = devm_ioremap_resource(&pdev->dev, res);
+ if (IS_ERR(base))
+ return PTR_ERR(base);
+
+ data->regmap = devm_regmap_init_mmio(&pdev->dev, base,
+ &mtk_pericfg_regmap_config);
+ if (IS_ERR(data->regmap))
+ return PTR_ERR(data->regmap);
+
+ data->rcdev.owner = THIS_MODULE;
+ data->rcdev.nr_resets = 64;
+ data->rcdev.ops = &mtk_pericfg_reset_ops;
+ data->rcdev.of_node = pdev->dev.of_node;
+
+ return reset_controller_register(&data->rcdev);
+}
+
+static int mtk_pericfg_remove(struct platform_device *pdev)
+{
+ struct mtk_pericfg *data = platform_get_drvdata(pdev);
+
+ reset_controller_unregister(&data->rcdev);
+
+ return 0;
+}
+
+static const struct of_device_id mtk_pericfg_dt_ids[] = {
+ {
+ .compatible = "mediatek,mt8173-pericfg",
+ }, {
+ .compatible = "mediatek,mt8135-pericfg",
+ }, {
+ /* sentinel */
+ },
+};
+MODULE_DEVICE_TABLE(of, mtk_pericfg_dt_ids);
+
+static struct platform_driver mtk_pericfg_driver = {
+ .probe = mtk_pericfg_probe,
+ .remove = mtk_pericfg_remove,
+ .driver = {
+ .name = "mtk-pericfg",
+ .of_match_table = mtk_pericfg_dt_ids,
+ },
+};
+
+module_platform_driver(mtk_pericfg_driver);
+
+MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de>");
+MODULE_DESCRIPTION("MediaTek pericfg controller");
+MODULE_LICENSE("GPL");
--
2.1.4
next prev parent reply other threads:[~2015-02-05 15:26 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-05 15:25 [PATCH v3] MediaTek PMIC support Sascha Hauer
2015-02-05 15:25 ` [PATCH 1/8] soc: Add MediaTek infracfg controller support Sascha Hauer
2015-02-05 15:25 ` Sascha Hauer [this message]
2015-02-05 15:25 ` [PATCH 3/8] dt: bindings: Add MediaTek MT8135/MT8173 reset controller defines Sascha Hauer
2015-02-05 15:25 ` [PATCH 4/8] soc: mediatek: Add PMIC wrapper for MT8135 and MT6397 SoC Sascha Hauer
2015-02-05 15:25 ` [PATCH 5/8] ARM: dts: mt8135: Add pericfg, infracfg and pmic wrapper nodes Sascha Hauer
2015-02-05 15:25 ` [PATCH 6/8] ARM: dts: mt8135-evbp1: Add PMIC support Sascha Hauer
2015-02-05 15:25 ` [PATCH 7/8] mfd: dt-bindings: Add bindings for the MediaTek MT6397 PMIC Sascha Hauer
2015-02-05 15:25 ` [PATCH 8/8] mfd: Add support " Sascha Hauer
2015-02-05 17:05 ` [PATCH v3] MediaTek PMIC support Matthias Brugger
-- strict thread matches above, loose matches on Subject: below --
2015-01-20 9:47 Sascha Hauer
2015-01-20 9:47 ` [PATCH 2/8] soc: Add MediaTek pericfg controller support Sascha Hauer
2015-01-20 13:18 ` Yingjoe Chen
2015-01-20 13:27 ` Sascha Hauer
2015-01-20 16:15 ` Mark Rutland
2015-01-21 8:17 ` Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1423149938-14471-3-git-send-email-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=Yingjoe.Chen@mediatek.com \
--cc=arnd@arndb.de \
--cc=eddie.huang@mediatek.com \
--cc=henryc.chen@mediatek.com \
--cc=kernel@pengutronix.de \
--cc=lee.jones@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matthias.bgg@gmail.com \
--cc=olof@lixom.net \
--cc=robh+dt@kernel.org \
--cc=sameo@linux.intel.com \
--cc=yh.chen@mediatek.com \
--subject='Re: [PATCH 2/8] soc: Add MediaTek pericfg controller support' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).