Skip to contentSkip to conversation

reset: hi6220: Add support for AO reset controller

PATCH Superseded John Stultz 3 participants 3 messages Mar 2, 2020 – Mar 4, 2020 Reset controller framework

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 reset: hi6220: Add support for AO reset controller

From: Peter Griffin <[email protected]>

This is required to bring Mali450 gpu out of reset.

Cc Philipp Zabel <[email protected]>
Cc Peter Griffin <[email protected]>
Cc Enrico Weigelt <[email protected]>

---
v2:
* Updated to v2 of Peter's patch from here:

    https://lkml.org/lkml/2019/4/19/253
* Added a comment to explain ordering question brought
  up on the list.
---
 drivers/reset/hisilicon/hi6220_reset.c | 71 +++++++++++++++++++++++++-
 1 file changed, 70 insertions(+), 1 deletion(-)
drivers/reset/hisilicon/hi6220_reset.c +70 -1
index 24e6d420b26b..a85ed276ab83 100644
@@ -33,6 +33,7 @@
 enum hi6220_reset_ctrl_type {
 	PERIPHERAL,
 	MEDIA,
+	AO,
 };
 
 struct hi6220_reset_data {
@@ -92,6 +93,67 @@ static const struct reset_control_ops hi6220_media_reset_ops = {
 	.deassert = hi6220_media_deassert,
 };
 
+#define AO_SCTRL_SC_PW_CLKEN0     0x800
+#define AO_SCTRL_SC_PW_CLKDIS0    0x804
+
+#define AO_SCTRL_SC_PW_RSTEN0     0x810
+#define AO_SCTRL_SC_PW_RSTDIS0    0x814
+
+#define AO_SCTRL_SC_PW_ISOEN0     0x820
+#define AO_SCTRL_SC_PW_ISODIS0    0x824
+#define AO_MAX_INDEX              12
+
+static int hi6220_ao_assert(struct reset_controller_dev *rc_dev,
+			       unsigned long idx)
+{
+	struct hi6220_reset_data *data = to_reset_data(rc_dev);
+	struct regmap *regmap = data->regmap;
+	int ret;
+
+	ret = regmap_write(regmap, AO_SCTRL_SC_PW_RSTEN0, BIT(idx));
+	if (ret)
+		return ret;
+
+	ret = regmap_write(regmap, AO_SCTRL_SC_PW_ISOEN0, BIT(idx));
+	if (ret)
+		return ret;
+
+	ret = regmap_write(regmap, AO_SCTRL_SC_PW_CLKDIS0, BIT(idx));
+	if (ret)
+		return ret;
+}
+
+static int hi6220_ao_deassert(struct reset_controller_dev *rc_dev,
+				 unsigned long idx)
+{
+	struct hi6220_reset_data *data = to_reset_data(rc_dev);
+	struct regmap *regmap = data->regmap;
+	int ret;
+
+	/*
+	 * It was suggested to disable isolation before enabling
+	 * the clocks and deasserting reset, to avoid glitches.
+	 * But this order is preserved to keep it matching the
+	 * vendor code.
+	 */
+	ret = regmap_write(regmap, AO_SCTRL_SC_PW_RSTDIS0, BIT(idx));
+	if (ret)
+		return ret;
+
+	ret = regmap_write(regmap, AO_SCTRL_SC_PW_ISODIS0, BIT(idx));
+	if (ret)
+		return ret;
+
+	ret = regmap_write(regmap, AO_SCTRL_SC_PW_CLKEN0, BIT(idx));
+	if (ret)
+		return ret;
+}
+
+static const struct reset_control_ops hi6220_ao_reset_ops = {
+	.assert = hi6220_ao_assert,
+	.deassert = hi6220_ao_deassert,
+};
+
 static int hi6220_reset_probe(struct platform_device *pdev)
 {
 	struct device_node *np = pdev->dev.of_node;
@@ -117,9 +179,12 @@ static int hi6220_reset_probe(struct platform_device *pdev)
 	if (type == MEDIA) {
 		data->rc_dev.ops = &hi6220_media_reset_ops;
 		data->rc_dev.nr_resets = MEDIA_MAX_INDEX;
-	} else {
+	} else if (type == PERIPHERAL) {
 		data->rc_dev.ops = &hi6220_peripheral_reset_ops;
 		data->rc_dev.nr_resets = PERIPH_MAX_INDEX;
+	} else {
+		data->rc_dev.ops = &hi6220_ao_reset_ops;
+		data->rc_dev.nr_resets = AO_MAX_INDEX;
 	}
 
 	return reset_controller_register(&data->rc_dev);
@@ -134,6 +199,10 @@ static const struct of_device_id hi6220_reset_match[] = {
 		.compatible = "hisilicon,hi6220-mediactrl",
 		.data = (void *)MEDIA,
 	},
+	{
+		.compatible = "hisilicon,hi6220-aoctrl",
+		.data = (void *)AO,
+	},
 	{ /* sentinel */ },
 };
 MODULE_DEVICE_TABLE(of, hi6220_reset_match);
Signature · 1 line
2.17.1
#1 lore raw
Thank you for the patch! Perhaps something to improve:

Hi John,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on pza/reset/next]
[also build test WARNING on linux/master linus/master v5.6-rc4 next-20200302] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/John-Stultz/reset-hi6220-Add-support-for-AO-reset-controller/20200303-041136
base:   https://git.pengutronix.de/git/pza/linux reset/next
config: sh-allmodconfig (attached as .config)
compiler: sh4-linux-gcc (GCC) 7.5.0

reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.5.0 make.cross ARCH=sh

If you fix the issue, kindly add following tag

All warnings (new ones prefixed by >>):

drivers/reset/hisilicon/hi6220_reset.c: In function 'hi6220_ao_deassert':

>> drivers/reset/hisilicon/hi6220_reset.c:150:1: warning: control reaches end of non-void function [-Wreturn-type]
    }
    ^
   drivers/reset/hisilicon/hi6220_reset.c: In function 'hi6220_ao_assert':
   drivers/reset/hisilicon/hi6220_reset.c:124:1: warning: control reaches end of non-void function [-Wreturn-type]
    }
    ^

vim +150 drivers/reset/hisilicon/hi6220_reset.c

125
126 static int hi6220_ao_deassert(struct reset_controller_dev *rc_dev,
127 unsigned long idx)
128 {
129 struct hi6220_reset_data *data = to_reset_data(rc_dev);
130 struct regmap *regmap = data->regmap;
131 int ret;
132
133 /*
134 * It was suggested to disable isolation before enabling
135 * the clocks and deasserting reset, to avoid glitches.
136 * But this order is preserved to keep it matching the
137 * vendor code.
138 */
139 ret = regmap_write(regmap, AO_SCTRL_SC_PW_RSTDIS0, BIT(idx));
140 if (ret)
141 return ret;
142
143 ret = regmap_write(regmap, AO_SCTRL_SC_PW_ISODIS0, BIT(idx));
144 if (ret)
145 return ret;
146
147 ret = regmap_write(regmap, AO_SCTRL_SC_PW_CLKEN0, BIT(idx));
148 if (ret)
149 return ret;

 > 150	}

151

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

maintainer
#2 lore raw
In reply to John Stultz

Hi John, Peter,

thank you for the patch. Just one issue remaining, see below:

Quoted 53 lines · John Stultz

From: Peter Griffin <[email protected]>

This is required to bring Mali450 gpu out of reset.

Cc Philipp Zabel <[email protected]>
Cc Peter Griffin <[email protected]>
Cc Enrico Weigelt <[email protected]>

---
v2:
* Updated to v2 of Peter's patch from here:

    https://lkml.org/lkml/2019/4/19/253
* Added a comment to explain ordering question brought
  up on the list.
---
 drivers/reset/hisilicon/hi6220_reset.c | 71 +++++++++++++++++++++++++-
 1 file changed, 70 insertions(+), 1 deletion(-)
drivers/reset/hisilicon/hi6220_reset.c +19 -0
index 24e6d420b26b..a85ed276ab83 100644
@@ -33,6 +33,7 @@
 enum hi6220_reset_ctrl_type {
 	PERIPHERAL,
 	MEDIA,
+	AO,
 };
 
 struct hi6220_reset_data {
@@ -92,6 +93,67 @@ static const struct reset_control_ops hi6220_media_reset_ops = {
 	.deassert = hi6220_media_deassert,
 };
 
+#define AO_SCTRL_SC_PW_CLKEN0     0x800
+#define AO_SCTRL_SC_PW_CLKDIS0    0x804
+
+#define AO_SCTRL_SC_PW_RSTEN0     0x810
+#define AO_SCTRL_SC_PW_RSTDIS0    0x814
+
+#define AO_SCTRL_SC_PW_ISOEN0     0x820
+#define AO_SCTRL_SC_PW_ISODIS0    0x824
+#define AO_MAX_INDEX              12
+
+static int hi6220_ao_assert(struct reset_controller_dev *rc_dev,
+			       unsigned long idx)
+{
+	struct hi6220_reset_data *data = to_reset_data(rc_dev);
+	struct regmap *regmap = data->regmap;
+	int ret;
+
+	ret = regmap_write(regmap, AO_SCTRL_SC_PW_RSTEN0, BIT(idx));

drivers/reset/hisilicon/hi6220_reset.c static const struct reset_control_ops hi6220_media_reset_ops = { · line 123

Quoted 10 lines
drivers/reset/hisilicon/hi6220_reset.c +10 -0
+	if (ret)
+		return ret;
+
+	ret = regmap_write(regmap, AO_SCTRL_SC_PW_ISOEN0, BIT(idx));
+	if (ret)
+		return ret;
+
+	ret = regmap_write(regmap, AO_SCTRL_SC_PW_CLKDIS0, BIT(idx));
+	if (ret)
+		return ret;

drivers/reset/hisilicon/hi6220_reset.c: In function ‘hi6220_ao_assert’:
drivers/reset/hisilicon/hi6220_reset.c:124:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^

Just "return regmap_write(...)" for the last one, same in hi6220_ao_deassert().

regards
Philipp