From: Crystal Guo <crystal.guo@mediatek.com>
To: <p.zabel@pengutronix.de>, <robh+dt@kernel.org>,
<matthias.bgg@gmail.com>, <crystal.guo@mediatek.com>
Cc: <linux-kernel@vger.kernel.org>, <devicetree@vger.kernel.org>,
<stanley.chu@mediatek.com>, <srv_heupstream@mediatek.com>,
<seiya.wang@mediatek.com>, <fan.chen@mediatek.com>,
<linux-mediatek@lists.infradead.org>, <Yingjoe.Chen@mediatek.com>,
<s-anna@ti.com>, <linux-arm-kernel@lists.infradead.org>,
<Yidi.Lin@mediatek.com>, <ikjn@chromium.org>
Subject: [v7,2/2] reset-controller: ti: introduce an integrated reset handler
Date: Fri, 15 Jan 2021 19:23:31 +0800 [thread overview]
Message-ID: <20210115112331.27434-3-crystal.guo@mediatek.com> (raw)
In-Reply-To: <20210115112331.27434-1-crystal.guo@mediatek.com>
Introduce ti_syscon_reset() to integrate assert and deassert together.
If some modules need do serialized assert and deassert operations
to reset itself, reset_control_reset can be called for convenience.
Such as reset-qcom-aoss.c, it integrates assert and deassert together
by 'reset' method. MTK Socs also need this method to perform reset.
Signed-off-by: Crystal Guo <crystal.guo@mediatek.com>
---
drivers/reset/reset-ti-syscon.c | 39 +++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/drivers/reset/reset-ti-syscon.c b/drivers/reset/reset-ti-syscon.c
index 218370faf37b..a30cb17362a4 100644
--- a/drivers/reset/reset-ti-syscon.c
+++ b/drivers/reset/reset-ti-syscon.c
@@ -15,15 +15,24 @@
* GNU General Public License for more details.
*/
+#include <linux/delay.h>
#include <linux/mfd/syscon.h>
#include <linux/module.h>
#include <linux/of.h>
+#include <linux/of_device.h>
#include <linux/platform_device.h>
#include <linux/regmap.h>
#include <linux/reset-controller.h>
#include <dt-bindings/reset/ti-syscon.h>
+#define MTK_SYSCON_RESET_FLAG BIT(0)
+#define MT_RESET_DURATION 10
+
+struct mediatek_reset_data {
+ unsigned int flag;
+};
+
/**
* struct ti_syscon_reset_control - reset control structure
* @assert_offset: reset assert control register offset from syscon base
@@ -56,6 +65,7 @@ struct ti_syscon_reset_data {
struct regmap *regmap;
struct ti_syscon_reset_control *controls;
unsigned int nr_controls;
+ const struct mediatek_reset_data *reset_data;
};
#define to_ti_syscon_reset_data(rcdev) \
@@ -158,9 +168,32 @@ static int ti_syscon_reset_status(struct reset_controller_dev *rcdev,
!(control->flags & STATUS_SET);
}
+static int mtk_syscon_reset(struct reset_controller_dev *rcdev, unsigned long id)
+{
+ int ret;
+
+ ret = ti_syscon_reset_assert(rcdev, id);
+ if (ret)
+ return ret;
+ usleep_range(MT_RESET_DURATION, MT_RESET_DURATION * 2);
+
+ return ti_syscon_reset_deassert(rcdev, id);
+}
+
+static int ti_syscon_reset(struct reset_controller_dev *rcdev, unsigned long id)
+{
+ struct ti_syscon_reset_data *data = to_ti_syscon_reset_data(rcdev);
+
+ if (data->reset_data && data->reset_data->flag & MTK_SYSCON_RESET_FLAG)
+ return mtk_syscon_reset(rcdev, id);
+ else
+ return -ENOTSUPP;
+}
+
static const struct reset_control_ops ti_syscon_reset_ops = {
.assert = ti_syscon_reset_assert,
.deassert = ti_syscon_reset_deassert,
+ .reset = ti_syscon_reset,
.status = ti_syscon_reset_status,
};
@@ -182,6 +215,7 @@ static int ti_syscon_reset_probe(struct platform_device *pdev)
if (IS_ERR(regmap))
return PTR_ERR(regmap);
+ data->reset_data = of_device_get_match_data(&pdev->dev);
list = of_get_property(np, "ti,reset-bits", &size);
if (!list || (size / sizeof(*list)) % 7 != 0) {
dev_err(dev, "invalid DT reset description\n");
@@ -217,8 +251,13 @@ static int ti_syscon_reset_probe(struct platform_device *pdev)
return devm_reset_controller_register(dev, &data->rcdev);
}
+static const struct mediatek_reset_data mtk_reset_data = {
+ .flag = MTK_SYSCON_RESET_FLAG,
+};
+
static const struct of_device_id ti_syscon_reset_of_match[] = {
{ .compatible = "ti,syscon-reset", },
+ { .compatible = "mediatek,syscon-reset", .data = &mtk_reset_data},
{ /* sentinel */ },
};
MODULE_DEVICE_TABLE(of, ti_syscon_reset_of_match);
--
2.18.0
prev parent reply other threads:[~2021-01-15 11:24 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-15 11:23 [v7,0/2] introduce TI reset controller for MT8192 SoC Crystal Guo
2021-01-15 11:23 ` [v7,1/2] dt-binding: reset-controller: mediatek: add YAML schemas Crystal Guo
2021-01-22 8:13 ` Ikjoon Jang
2021-01-15 11:23 ` Crystal Guo [this message]
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=20210115112331.27434-3-crystal.guo@mediatek.com \
--to=crystal.guo@mediatek.com \
--cc=Yidi.Lin@mediatek.com \
--cc=Yingjoe.Chen@mediatek.com \
--cc=devicetree@vger.kernel.org \
--cc=fan.chen@mediatek.com \
--cc=ikjn@chromium.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=p.zabel@pengutronix.de \
--cc=robh+dt@kernel.org \
--cc=s-anna@ti.com \
--cc=seiya.wang@mediatek.com \
--cc=srv_heupstream@mediatek.com \
--cc=stanley.chu@mediatek.com \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®