Skip to contentSkip to conversation

add hisilicon reset

PATCH New Zhangfei Gao 4 participants 24 messages Nov 22, 2016 – Nov 24, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover add hisilicon reset

Add reset-hi3660.c
Update reset-hi6220 as well
reset.c is shared by reset-hi3660.c and reset-hi6220.c Change hi6220.dtsi accordingly

Zhangfei Gao (6):
reset: hisilicon: add reset core
dt-bindings: Document the hi3660 reset bindings
reset: hisilicon: add reset-hi3660
dt-bindings: change hi6220-reset.txt according to reset-hi6220.c
reset: hisilicon: Use new driver reset-hi6222
arm64: dts: hi6220: update reset node according to reset-hi6220.c

 .../bindings/reset/hisilicon,hi3660-reset.txt      |  42 ++++++
 .../bindings/reset/hisilicon,hi6220-reset.txt      |  14 +-
 arch/arm64/boot/dts/hisilicon/hi6220.dtsi          |  20 ++-
 drivers/reset/Makefile                             |   2 +-
 drivers/reset/hisilicon/Kconfig                    |   7 +
 drivers/reset/hisilicon/Makefile                   |   4 +-
 drivers/reset/hisilicon/hi6220_reset.c             | 157 ---------------------
 drivers/reset/hisilicon/reset-hi3660.c             |  78 ++++++++++
 drivers/reset/hisilicon/reset-hi6220.c             | 123 ++++++++++++++++
 drivers/reset/hisilicon/reset.c                    | 108 ++++++++++++++
 drivers/reset/hisilicon/reset.h                    |  37 +++++
 include/dt-bindings/reset/hisi,hi3660-resets.h     |  38 +++++
 include/dt-bindings/reset/hisi,hi6220-resets.h     | 130 ++++++++---------
 13 files changed, 527 insertions(+), 233 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/reset/hisilicon,hi3660-reset.txt
 delete mode 100644 drivers/reset/hisilicon/hi6220_reset.c
 create mode 100644 drivers/reset/hisilicon/reset-hi3660.c
 create mode 100644 drivers/reset/hisilicon/reset-hi6220.c
 create mode 100644 drivers/reset/hisilicon/reset.c
 create mode 100644 drivers/reset/hisilicon/reset.h
 create mode 100644 include/dt-bindings/reset/hisi,hi3660-resets.h
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/6 reset: hisilicon: add reset core

reset.c will be shared by hisilicon chips like hi3660 and hi6220

---
 drivers/reset/Makefile           |   2 +-
 drivers/reset/hisilicon/Makefile |   1 +
 drivers/reset/hisilicon/reset.c  | 108 +++++++++++++++++++++++++++++++++++++++
 drivers/reset/hisilicon/reset.h  |  37 ++++++++++++++
 4 files changed, 147 insertions(+), 1 deletion(-)
 create mode 100644 drivers/reset/hisilicon/reset.c
 create mode 100644 drivers/reset/hisilicon/reset.h
drivers/reset/Makefile +1 -1
index bbe7026..7e3dc4e 100644
@@ -1,8 +1,8 @@
 obj-y += core.o
-obj-y += hisilicon/
 obj-$(CONFIG_ARCH_STI) += sti/
 obj-$(CONFIG_RESET_ATH79) += reset-ath79.o
 obj-$(CONFIG_RESET_BERLIN) += reset-berlin.o
+obj-$(CONFIG_ARCH_HISI) += hisilicon/
 obj-$(CONFIG_RESET_LPC18XX) += reset-lpc18xx.o
 obj-$(CONFIG_RESET_MESON) += reset-meson.o
 obj-$(CONFIG_RESET_OXNAS) += reset-oxnas.o
drivers/reset/hisilicon/Makefile +1 -0
index c932f86..df511f5 100644
@@ -1 +1,2 @@
+obj-y	+= reset.o
 obj-$(CONFIG_COMMON_RESET_HI6220) += hi6220_reset.o
drivers/reset/hisilicon/reset.c new file +108 -0

108 lines not on this page · raw message

drivers/reset/hisilicon/reset.h new file +37 -0
new file mode 100644
index 0000000..77259ee
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2016-2017 Linaro Ltd.
+ * Copyright (c) 2016-2017 HiSilicon Technologies Co., Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef __HISILICON_RESET_H
+#define __HISILICON_RESET_H
+
+#include <linux/device.h>
+#include <linux/regmap.h>
+#include <linux/reset-controller.h>
+
+/* reset separated register offset is 0x4 */
+#define HISI_RST_SEP(off, bit)					\
+	{ .enable	= REG_FIELD(off, bit, bit),		\
+	  .disable	= REG_FIELD(off + 0x4, bit, bit),	\
+	  .status	= REG_FIELD(off + 0x8, bit, bit), }
+
+struct hisi_reset_channel_data {
+	struct reg_field enable;
+	struct reg_field disable;
+	struct reg_field status;
+};
+
+struct hisi_reset_controller_data {
+	int nr_channels;
+	const struct hisi_reset_channel_data *channels;
+};
+
+int hisi_reset_probe(struct platform_device *pdev);
+
+#endif /* __HISILICON_RESET_H */
Signature · 1 line
2.7.4
#2 lore raw

PATCH 1/6 reset: hisilicon: add reset core

drivers/reset/Makefile line 8

Quoted 10 lines · CET Zhangfei Gao
drivers/reset/Makefile +1 -1
@@ -1,8 +1,8 @@
 obj-y += core.o
-obj-y += hisilicon/
 obj-$(CONFIG_ARCH_STI) += sti/
 obj-$(CONFIG_RESET_ATH79) += reset-ath79.o
 obj-$(CONFIG_RESET_BERLIN) += reset-berlin.o
+obj-$(CONFIG_ARCH_HISI) += hisilicon/
 obj-$(CONFIG_RESET_LPC18XX) += reset-lpc18xx.o
 obj-$(CONFIG_RESET_MESON) += reset-meson.o
 obj-$(CONFIG_RESET_OXNAS) += reset-oxnas.o

Please leave the obj-y line, otherwise the COMPILE_TEST variant won't work.

Arnd

author
#3 lore raw

PATCH 1/6 reset: hisilicon: add reset core

Hi, Arnd

Quoted 12 lines · Arnd Bergmann

drivers/reset/Makefile line 8

Quoted 10 lines · CET Zhangfei Gao
drivers/reset/Makefile +1 -1
@@ -1,8 +1,8 @@
  obj-y += core.o
-obj-y += hisilicon/
  obj-$(CONFIG_ARCH_STI) += sti/
  obj-$(CONFIG_RESET_ATH79) += reset-ath79.o
  obj-$(CONFIG_RESET_BERLIN) += reset-berlin.o
+obj-$(CONFIG_ARCH_HISI) += hisilicon/
  obj-$(CONFIG_RESET_LPC18XX) += reset-lpc18xx.o
  obj-$(CONFIG_RESET_MESON) += reset-meson.o
  obj-$(CONFIG_RESET_OXNAS) += reset-oxnas.o

Please leave the obj-y line, otherwise the COMPILE_TEST variant won't work.

COMPILE_TEST is added in drivers/reset/hisilicon/Kconfig like
config COMMON_RESET_HI3660
tristate "Hi3660 Reset Driver"
depends on ARCH_HISI || COMPILE_TEST

The reason not using "obj-y" here is that reset.c will be compiled unconditionally.

drivers/reset/hisilicon/Makefile
obj-y += reset.o

Thanks

#4 lore raw

PATCH 1/6 reset: hisilicon: add reset core

Quoted 22 lines · CET zhangfei

Hi, Arnd

Quoted 12 lines · Arnd Bergmann

drivers/reset/Makefile line 8

Quoted 10 lines · CET Zhangfei Gao
drivers/reset/Makefile +1 -1
@@ -1,8 +1,8 @@
  obj-y += core.o
-obj-y += hisilicon/
  obj-$(CONFIG_ARCH_STI) += sti/
  obj-$(CONFIG_RESET_ATH79) += reset-ath79.o
  obj-$(CONFIG_RESET_BERLIN) += reset-berlin.o
+obj-$(CONFIG_ARCH_HISI) += hisilicon/
  obj-$(CONFIG_RESET_LPC18XX) += reset-lpc18xx.o
  obj-$(CONFIG_RESET_MESON) += reset-meson.o
  obj-$(CONFIG_RESET_OXNAS) += reset-oxnas.o

Please leave the obj-y line, otherwise the COMPILE_TEST variant won't work.

COMPILE_TEST is added in drivers/reset/hisilicon/Kconfig like
config COMMON_RESET_HI3660
tristate "Hi3660 Reset Driver"
depends on ARCH_HISI || COMPILE_TEST

Quoted 4 lines

The reason not using "obj-y" here is that reset.c will be compiled unconditionally.

drivers/reset/hisilicon/Makefile
obj-y += reset.o

Yes, that line has to change as well then, to only build it when one of the hardware specific drivers is enabled.

Arnd

maintainer
#5 lore raw

PATCH 1/6 reset: hisilicon: add reset core

In reply to Zhangfei Gao

Hi Zhangfei,

Am Dienstag, den 22.11.2016, 15:49 +0800 schrieb Zhangfei Gao:

Quoted 74 lines

reset.c will be shared by hisilicon chips like hi3660 and hi6220

---
 drivers/reset/Makefile           |   2 +-
 drivers/reset/hisilicon/Makefile |   1 +
 drivers/reset/hisilicon/reset.c  | 108 +++++++++++++++++++++++++++++++++++++++
 drivers/reset/hisilicon/reset.h  |  37 ++++++++++++++
 4 files changed, 147 insertions(+), 1 deletion(-)
 create mode 100644 drivers/reset/hisilicon/reset.c
 create mode 100644 drivers/reset/hisilicon/reset.h
drivers/reset/Makefile +1 -1
index bbe7026..7e3dc4e 100644
@@ -1,8 +1,8 @@
 obj-y += core.o
-obj-y += hisilicon/
 obj-$(CONFIG_ARCH_STI) += sti/
 obj-$(CONFIG_RESET_ATH79) += reset-ath79.o
 obj-$(CONFIG_RESET_BERLIN) += reset-berlin.o
+obj-$(CONFIG_ARCH_HISI) += hisilicon/
 obj-$(CONFIG_RESET_LPC18XX) += reset-lpc18xx.o
 obj-$(CONFIG_RESET_MESON) += reset-meson.o
 obj-$(CONFIG_RESET_OXNAS) += reset-oxnas.o
drivers/reset/hisilicon/Makefile +1 -0
index c932f86..df511f5 100644
@@ -1 +1,2 @@
+obj-y	+= reset.o
 obj-$(CONFIG_COMMON_RESET_HI6220) += hi6220_reset.o
drivers/reset/hisilicon/reset.c new file +35 -0
new file mode 100644
index 0000000..c4971c9
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2016-2017 Linaro Ltd.
+ * Copyright (c) 2016-2017 HiSilicon Technologies Co., Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+#include <linux/kernel.h>
+#include <linux/platform_device.h>
+#include <linux/module.h>
+#include <linux/err.h>
+#include <linux/types.h>
+#include <linux/of_device.h>
+#include <linux/mfd/syscon.h>
+
+#include "reset.h"
+
+struct hisi_reset_controller {
+	struct reset_controller_dev rst;
+	const struct hisi_reset_channel_data *channels;
+	struct regmap *map;
+};
+
+#define to_hisi_reset_controller(_rst) \
+	container_of(_rst, struct hisi_reset_controller, rst)
+
+static int hisi_reset_program_hw(struct reset_controller_dev *rcdev,
+				 unsigned long idx, bool assert)
+{
+	struct hisi_reset_controller *rc = to_hisi_reset_controller(rcdev);
+	const struct hisi_reset_channel_data *ch;
+
+	if (idx >= rcdev->nr_resets)

drivers/reset/hisilicon/reset.c line 45

Quoted 10 lines
drivers/reset/hisilicon/reset.c new file +10 -0
+		return -EINVAL;
+
+	ch = &rc->channels[idx];
+
+	if (assert)
+		return regmap_write(rc->map, ch->enable.reg,
+				    GENMASK(ch->enable.msb, ch->enable.lsb));
+	else
+		return regmap_write(rc->map, ch->disable.reg,
+				    GENMASK(ch->disable.msb, ch->disable.lsb));

These fields are always 1-bit wide and you are not using the regmap_field functions to access them, so I'd suggest to remove the struct reg_field indirection and overhead and just write

	if (assert)
		return regmap_write(rc->map, ch->enable_reg, ch->bit);
	else
		return regmap_write(rc->map, ch->disable_reg, ch->bit);

here.

Quoted 87 lines
drivers/reset/hisilicon/reset.c new file +63 -0
+}
+
+static int hisi_reset_assert(struct reset_controller_dev *rcdev,
+			     unsigned long idx)
+{
+	return hisi_reset_program_hw(rcdev, idx, true);
+}
+
+static int hisi_reset_deassert(struct reset_controller_dev *rcdev,
+			       unsigned long idx)
+{
+	return hisi_reset_program_hw(rcdev, idx, false);
+}
+
+static int hisi_reset_dev(struct reset_controller_dev *rcdev,
+			  unsigned long idx)
+{
+	int err;
+
+	err = hisi_reset_assert(rcdev, idx);
+	if (err)
+		return err;
+
+	return hisi_reset_deassert(rcdev, idx);
+}
+
+static struct reset_control_ops hisi_reset_ops = {
+	.reset    = hisi_reset_dev,
+	.assert   = hisi_reset_assert,
+	.deassert = hisi_reset_deassert,
+};
+
+int hisi_reset_probe(struct platform_device *pdev)
+{
+	struct hisi_reset_controller *rc;
+	struct device_node *np = pdev->dev.of_node;
+	struct hisi_reset_controller_data *d;
+	struct device *dev = &pdev->dev;
+	const struct of_device_id *match;
+
+	match = of_match_device(dev->driver->of_match_table, dev);
+	if (!match || !match->data)
+		return -EINVAL;
+
+	d = (struct hisi_reset_controller_data *)match->data;
+	rc = devm_kzalloc(dev, sizeof(*rc), GFP_KERNEL);
+	if (!rc)
+		return -ENOMEM;
+
+	rc->map = syscon_regmap_lookup_by_phandle(np, "hisi,rst-syscon");
+	if (IS_ERR(rc->map)) {
+		dev_err(dev, "failed to get hisi,rst-syscon\n");
+		return PTR_ERR(rc->map);
+	}
+
+	rc->rst.ops = &hisi_reset_ops,
+	rc->rst.of_node = np;
+	rc->rst.nr_resets = d->nr_channels;
+	rc->channels = d->channels;
+
+	return reset_controller_register(&rc->rst);
+}
+EXPORT_SYMBOL_GPL(hisi_reset_probe);
drivers/reset/hisilicon/reset.h new file +18 -0
new file mode 100644
index 0000000..77259ee
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2016-2017 Linaro Ltd.
+ * Copyright (c) 2016-2017 HiSilicon Technologies Co., Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef __HISILICON_RESET_H
+#define __HISILICON_RESET_H
+
+#include <linux/device.h>
+#include <linux/regmap.h>
+#include <linux/reset-controller.h>
+
+/* reset separated register offset is 0x4 */

drivers/reset/hisilicon/reset.h line 28

Quoted 10 lines
drivers/reset/hisilicon/reset.h new file +10 -0
+#define HISI_RST_SEP(off, bit)					\
+	{ .enable	= REG_FIELD(off, bit, bit),		\
+	  .disable	= REG_FIELD(off + 0x4, bit, bit),	\
+	  .status	= REG_FIELD(off + 0x8, bit, bit), }
+
+struct hisi_reset_channel_data {
+	struct reg_field enable;
+	struct reg_field disable;
+	struct reg_field status;
+};

Are you expecting the bits to be at different positions in the enable/disable/status registers? How about just

#define HISI_RST_SEP(off, _bit)		\
	{ .enable_reg	= (off),	\
	  .disable_reg	= (off) + 0x4,	\
	  .status_reg	= (off) + 0x8,	\
	  .bit		= (_bit), }
struct hisi_reset_channel_data {
	unsigned int enable_reg;
	unsigned int disable_reg;
	unsigned int status_reg;
	unsigned int bit;
};

as those struct reg_field are not accessed via regmap_field_* functions anyway.

drivers/reset/hisilicon/reset.h line 37

Quoted 9 lines
drivers/reset/hisilicon/reset.h new file +9 -0
+
+struct hisi_reset_controller_data {
+	int nr_channels;
+	const struct hisi_reset_channel_data *channels;
+};
+
+int hisi_reset_probe(struct platform_device *pdev);
+
+#endif /* __HISILICON_RESET_H */

regards
Philipp

maintainer
#6 lore raw

PATCH 1/6 reset: hisilicon: add reset core

In reply to Zhangfei Gao

Hi Zhangfei,

Am Dienstag, den 22.11.2016, 15:49 +0800 schrieb Zhangfei Gao:

Quoted 74 lines

reset.c will be shared by hisilicon chips like hi3660 and hi6220

---
 drivers/reset/Makefile           |   2 +-
 drivers/reset/hisilicon/Makefile |   1 +
 drivers/reset/hisilicon/reset.c  | 108 +++++++++++++++++++++++++++++++++++++++
 drivers/reset/hisilicon/reset.h  |  37 ++++++++++++++
 4 files changed, 147 insertions(+), 1 deletion(-)
 create mode 100644 drivers/reset/hisilicon/reset.c
 create mode 100644 drivers/reset/hisilicon/reset.h
drivers/reset/Makefile +1 -1
index bbe7026..7e3dc4e 100644
@@ -1,8 +1,8 @@
 obj-y += core.o
-obj-y += hisilicon/
 obj-$(CONFIG_ARCH_STI) += sti/
 obj-$(CONFIG_RESET_ATH79) += reset-ath79.o
 obj-$(CONFIG_RESET_BERLIN) += reset-berlin.o
+obj-$(CONFIG_ARCH_HISI) += hisilicon/
 obj-$(CONFIG_RESET_LPC18XX) += reset-lpc18xx.o
 obj-$(CONFIG_RESET_MESON) += reset-meson.o
 obj-$(CONFIG_RESET_OXNAS) += reset-oxnas.o
drivers/reset/hisilicon/Makefile +1 -0
index c932f86..df511f5 100644
@@ -1 +1,2 @@
+obj-y	+= reset.o
 obj-$(CONFIG_COMMON_RESET_HI6220) += hi6220_reset.o
drivers/reset/hisilicon/reset.c new file +35 -0
new file mode 100644
index 0000000..c4971c9
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2016-2017 Linaro Ltd.
+ * Copyright (c) 2016-2017 HiSilicon Technologies Co., Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+#include <linux/kernel.h>
+#include <linux/platform_device.h>
+#include <linux/module.h>
+#include <linux/err.h>
+#include <linux/types.h>
+#include <linux/of_device.h>
+#include <linux/mfd/syscon.h>
+
+#include "reset.h"
+
+struct hisi_reset_controller {
+	struct reset_controller_dev rst;
+	const struct hisi_reset_channel_data *channels;
+	struct regmap *map;
+};
+
+#define to_hisi_reset_controller(_rst) \
+	container_of(_rst, struct hisi_reset_controller, rst)
+
+static int hisi_reset_program_hw(struct reset_controller_dev *rcdev,
+				 unsigned long idx, bool assert)
+{
+	struct hisi_reset_controller *rc = to_hisi_reset_controller(rcdev);
+	const struct hisi_reset_channel_data *ch;
+
+	if (idx >= rcdev->nr_resets)

drivers/reset/hisilicon/reset.c line 45

Quoted 10 lines
drivers/reset/hisilicon/reset.c new file +10 -0
+		return -EINVAL;
+
+	ch = &rc->channels[idx];
+
+	if (assert)
+		return regmap_write(rc->map, ch->enable.reg,
+				    GENMASK(ch->enable.msb, ch->enable.lsb));
+	else
+		return regmap_write(rc->map, ch->disable.reg,
+				    GENMASK(ch->disable.msb, ch->disable.lsb));

These fields are always 1-bit wide and you are not using the regmap_field functions to access them, so I'd suggest to remove the struct reg_field indirection and overhead and just write

	if (assert)
		return regmap_write(rc->map, ch->enable_reg, ch->bit);
	else
		return regmap_write(rc->map, ch->disable_reg, ch->bit);

here.

Quoted 87 lines
drivers/reset/hisilicon/reset.c new file +63 -0
+}
+
+static int hisi_reset_assert(struct reset_controller_dev *rcdev,
+			     unsigned long idx)
+{
+	return hisi_reset_program_hw(rcdev, idx, true);
+}
+
+static int hisi_reset_deassert(struct reset_controller_dev *rcdev,
+			       unsigned long idx)
+{
+	return hisi_reset_program_hw(rcdev, idx, false);
+}
+
+static int hisi_reset_dev(struct reset_controller_dev *rcdev,
+			  unsigned long idx)
+{
+	int err;
+
+	err = hisi_reset_assert(rcdev, idx);
+	if (err)
+		return err;
+
+	return hisi_reset_deassert(rcdev, idx);
+}
+
+static struct reset_control_ops hisi_reset_ops = {
+	.reset    = hisi_reset_dev,
+	.assert   = hisi_reset_assert,
+	.deassert = hisi_reset_deassert,
+};
+
+int hisi_reset_probe(struct platform_device *pdev)
+{
+	struct hisi_reset_controller *rc;
+	struct device_node *np = pdev->dev.of_node;
+	struct hisi_reset_controller_data *d;
+	struct device *dev = &pdev->dev;
+	const struct of_device_id *match;
+
+	match = of_match_device(dev->driver->of_match_table, dev);
+	if (!match || !match->data)
+		return -EINVAL;
+
+	d = (struct hisi_reset_controller_data *)match->data;
+	rc = devm_kzalloc(dev, sizeof(*rc), GFP_KERNEL);
+	if (!rc)
+		return -ENOMEM;
+
+	rc->map = syscon_regmap_lookup_by_phandle(np, "hisi,rst-syscon");
+	if (IS_ERR(rc->map)) {
+		dev_err(dev, "failed to get hisi,rst-syscon\n");
+		return PTR_ERR(rc->map);
+	}
+
+	rc->rst.ops = &hisi_reset_ops,
+	rc->rst.of_node = np;
+	rc->rst.nr_resets = d->nr_channels;
+	rc->channels = d->channels;
+
+	return reset_controller_register(&rc->rst);
+}
+EXPORT_SYMBOL_GPL(hisi_reset_probe);
drivers/reset/hisilicon/reset.h new file +18 -0
new file mode 100644
index 0000000..77259ee
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2016-2017 Linaro Ltd.
+ * Copyright (c) 2016-2017 HiSilicon Technologies Co., Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef __HISILICON_RESET_H
+#define __HISILICON_RESET_H
+
+#include <linux/device.h>
+#include <linux/regmap.h>
+#include <linux/reset-controller.h>
+
+/* reset separated register offset is 0x4 */

drivers/reset/hisilicon/reset.h line 28

Quoted 10 lines
drivers/reset/hisilicon/reset.h new file +10 -0
+#define HISI_RST_SEP(off, bit)					\
+	{ .enable	= REG_FIELD(off, bit, bit),		\
+	  .disable	= REG_FIELD(off + 0x4, bit, bit),	\
+	  .status	= REG_FIELD(off + 0x8, bit, bit), }
+
+struct hisi_reset_channel_data {
+	struct reg_field enable;
+	struct reg_field disable;
+	struct reg_field status;
+};

Are you expecting the bits to be at different positions in the enable/disable/status registers? How about just

#define HISI_RST_SEP(off, _bit)		\
	{ .enable_reg	= (off),	\
	  .disable_reg	= (off) + 0x4,	\
	  .status_reg	= (off) + 0x8,	\
	  .bit		= (_bit), }
struct hisi_reset_channel_data {
	unsigned int enable_reg;
	unsigned int disable_reg;
	unsigned int status_reg;
	unsigned int bit;
};

as those struct reg_field are not accessed via regmap_field_* functions anyway.

drivers/reset/hisilicon/reset.h line 37

Quoted 9 lines
drivers/reset/hisilicon/reset.h new file +9 -0
+
+struct hisi_reset_controller_data {
+	int nr_channels;
+	const struct hisi_reset_channel_data *channels;
+};
+
+int hisi_reset_probe(struct platform_device *pdev);
+
+#endif /* __HISILICON_RESET_H */

regards
Philipp

#7 lore raw

PATCH 2/6 dt-bindings: Document the hi3660 reset bindings

In reply to Zhangfei Gao

Add DT bindings documentation for hi3660 SoC reset controller.

---
 .../bindings/reset/hisilicon,hi3660-reset.txt      | 42 ++++++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/reset/hisilicon,hi3660-reset.txt
Documentation/devicetree/bindings/reset/hisilicon,hi3660-reset.txt new file +42 -0
new file mode 100644
index 0000000..20e03a8
@@ -0,0 +1,42 @@
+Hisilicon System Reset Controller
+======================================
+
+Please also refer to reset.txt in this directory for common reset
+controller binding usage.
+
+The reset controller registers are part of the system-ctl block on
+hi3660 SoC.
+
+Required properties:
+- compatible: should be one of the following:
+  - "hisilicon,hi3660-reset-crgctrl : reset control for peripherals in crgctrl.
+  - "hisilicon,hi3660-reset-iomcu : reset control for peripherals in iomcu.
+- hisi,rst-syscon: phandle of the reset's syscon.
+- #reset-cells: 1, see below
+
+Example:
+	crg_ctrl: crg_ctrl at fff35000 {
+		compatible = "hisilicon,hi3660-crgctrl", "syscon";
+		reg = <0x0 0xfff35000 0x0 0x1000>;
+		#clock-cells = <1>;
+	};
+
+	crg_rst: crg_rst_controller {
+		compatible = "hisilicon,hi3660-reset-crgctrl";
+		#reset-cells = <1>;
+		hisi,rst-syscon = <&crg_ctrl>;
+	};
+
+Specifying reset lines connected to IP modules
+==============================================
+example:
+
+        ufs: ufs at ..... {
+                ...
+		resets = <&crg_rst HI3660_RST_UFS>,
+			 <&crg_rst HI3660_RST_UFS_ASSERT>;
+		reset-names = "rst", "assert";
+                ...
+        };
+
+The index could be found in <dt-bindings/reset/hisi,hi3660-resets.h>.
Signature · 1 line
2.7.4
#8 lore raw

PATCH 3/6 reset: hisilicon: add reset-hi3660

In reply to Zhangfei Gao

Add hi3660 reset driver based on common reset.c

---
 drivers/reset/hisilicon/Kconfig                |  7 +++
 drivers/reset/hisilicon/Makefile               |  1 +
 drivers/reset/hisilicon/reset-hi3660.c         | 78 ++++++++++++++++++++++++++
 include/dt-bindings/reset/hisi,hi3660-resets.h | 38 +++++++++++++
 4 files changed, 124 insertions(+)
 create mode 100644 drivers/reset/hisilicon/reset-hi3660.c
 create mode 100644 include/dt-bindings/reset/hisi,hi3660-resets.h
drivers/reset/hisilicon/Kconfig +7 -0
index 1ff8b0c..10134dc 100644
@@ -1,3 +1,10 @@
+config COMMON_RESET_HI3660
+	tristate "Hi3660 Reset Driver"
+	depends on ARCH_HISI || COMPILE_TEST
+	default ARCH_HISI
+	help
+	  Build the Hisilicon Hi3660 reset driver.
+
 config COMMON_RESET_HI6220
 	tristate "Hi6220 Reset Driver"
 	depends on ARCH_HISI || COMPILE_TEST
drivers/reset/hisilicon/Makefile +1 -0
index df511f5..57e9893 100644
@@ -1,2 +1,3 @@
 obj-y	+= reset.o
+obj-$(CONFIG_COMMON_RESET_HI3660) += reset-hi3660.o
 obj-$(CONFIG_COMMON_RESET_HI6220) += hi6220_reset.o
drivers/reset/hisilicon/reset-hi3660.c new file +78 -0

78 lines not on this page · raw message

include/dt-bindings/reset/hisi,hi3660-resets.h new file +38 -0
new file mode 100644
index 0000000..a65f382
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2016-2017 Linaro Ltd.
+ * Copyright (c) 2016-2017 HiSilicon Technologies Co., Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef _DT_BINDINGS_RESET_CONTROLLER_HI3660
+#define _DT_BINDINGS_RESET_CONTROLLER_HI3660
+
+/* reset in iomcu */
+#define HI3660_RST_I2C0		0
+#define HI3660_RST_I2C1		1
+#define HI3660_RST_I2C2		2
+#define HI3660_RST_I2C6		3
+
+
+/* reset in crgctrl */
+#define HI3660_RST_I2C3		0
+#define HI3660_RST_I2C4		1
+#define HI3660_RST_I2C7		2
+#define HI3660_RST_SD		3
+#define HI3660_RST_SDIO		4
+#define HI3660_RST_UFS		5
+#define HI3660_RST_UFS_ASSERT	6
+#define HI3660_RST_PCIE_SYS	7
+#define HI3660_RST_PCIE_PHY	8
+#define HI3660_RST_PCIE_BUS	9
+#define HI3660_RST_USB3OTG_PHY  10
+#define HI3660_RST_USB3OTG	11
+#define HI3660_RST_USB3OTG_32K	12
+#define HI3660_RST_USB3OTG_AHB	13
+#define HI3660_RST_USB3OTG_MUX	14
+
+#endif /*_DT_BINDINGS_RESET_CONTROLLER_HI3660*/
Signature · 1 line
2.7.4
#9 lore raw

PATCH 3/6 reset: hisilicon: add reset-hi3660

Quoted 20 lines · CET Zhangfei Gao
drivers/reset/hisilicon/reset-hi3660.c new file +19 -0
+static const struct hisi_reset_channel_data hi3660_iomcu_rst[] = {
+       [HI3660_RST_I2C0] = HISI_RST_SEP(0x20, 3),
+       [HI3660_RST_I2C1] = HISI_RST_SEP(0x20, 4),
+       [HI3660_RST_I2C2] = HISI_RST_SEP(0x20, 5),
+       [HI3660_RST_I2C6] = HISI_RST_SEP(0x20, 27),
+};
+
+static struct hisi_reset_controller_data hi3660_iomcu_controller = {
+       .nr_channels = ARRAY_SIZE(hi3660_iomcu_rst),
+       .channels = hi3660_iomcu_rst,
+};
+
+static const struct hisi_reset_channel_data hi3660_crgctrl_rst[] = {
+       [HI3660_RST_I2C3] = HISI_RST_SEP(0x78, 7),
+       [HI3660_RST_I2C4] = HISI_RST_SEP(0x78, 27),
+       [HI3660_RST_I2C7] = HISI_RST_SEP(0x60, 14),
+       [HI3660_RST_SD] = HISI_RST_SEP(0x90, 18),
+       [HI3660_RST_SDIO] = HISI_RST_SEP(0x90, 20),
+       [HI3660_RST_UFS] = HISI_RST_SEP(0x84, 12),

drivers/reset/hisilicon/reset-hi3660.c line 46

Quoted 10 lines
drivers/reset/hisilicon/reset-hi3660.c new file +10 -0
+       [HI3660_RST_UFS_ASSERT] = HISI_RST_SEP(0x84, 7),
+       [HI3660_RST_PCIE_SYS] = HISI_RST_SEP(0x84, 26),
+       [HI3660_RST_PCIE_PHY] = HISI_RST_SEP(0x84, 27),
+       [HI3660_RST_PCIE_BUS] = HISI_RST_SEP(0x84, 31),
+       [HI3660_RST_USB3OTG_PHY] = HISI_RST_SEP(0x90, 3),
+       [HI3660_RST_USB3OTG] = HISI_RST_SEP(0x90, 5),
+       [HI3660_RST_USB3OTG_32K] = HISI_RST_SEP(0x90, 6),
+       [HI3660_RST_USB3OTG_AHB] = HISI_RST_SEP(0x90, 7),
+       [HI3660_RST_USB3OTG_MUX] = HISI_RST_SEP(0x90, 8),
+};

I think you can avoid the trap of the ABI incompatibility if you just define those as in the binding as tuples, using #reset-cells=2.

In particular for the first set, it seems really silly to redefine the numbers when there is just a simple integer number.

Arnd

author
#10 lore raw

PATCH 3/6 reset: hisilicon: add reset-hi3660

Hi, Arnd

Quoted 33 lines · Arnd Bergmann
Quoted 19 lines · CET Zhangfei Gao
drivers/reset/hisilicon/reset-hi3660.c new file +19 -0
+static const struct hisi_reset_channel_data hi3660_iomcu_rst[] = {
+       [HI3660_RST_I2C0] = HISI_RST_SEP(0x20, 3),
+       [HI3660_RST_I2C1] = HISI_RST_SEP(0x20, 4),
+       [HI3660_RST_I2C2] = HISI_RST_SEP(0x20, 5),
+       [HI3660_RST_I2C6] = HISI_RST_SEP(0x20, 27),
+};
+
+static struct hisi_reset_controller_data hi3660_iomcu_controller = {
+       .nr_channels = ARRAY_SIZE(hi3660_iomcu_rst),
+       .channels = hi3660_iomcu_rst,
+};
+
+static const struct hisi_reset_channel_data hi3660_crgctrl_rst[] = {
+       [HI3660_RST_I2C3] = HISI_RST_SEP(0x78, 7),
+       [HI3660_RST_I2C4] = HISI_RST_SEP(0x78, 27),
+       [HI3660_RST_I2C7] = HISI_RST_SEP(0x60, 14),
+       [HI3660_RST_SD] = HISI_RST_SEP(0x90, 18),
+       [HI3660_RST_SDIO] = HISI_RST_SEP(0x90, 20),
+       [HI3660_RST_UFS] = HISI_RST_SEP(0x84, 12),

drivers/reset/hisilicon/reset-hi3660.c line 46

Quoted 10 lines
drivers/reset/hisilicon/reset-hi3660.c new file +10 -0
+       [HI3660_RST_UFS_ASSERT] = HISI_RST_SEP(0x84, 7),
+       [HI3660_RST_PCIE_SYS] = HISI_RST_SEP(0x84, 26),
+       [HI3660_RST_PCIE_PHY] = HISI_RST_SEP(0x84, 27),
+       [HI3660_RST_PCIE_BUS] = HISI_RST_SEP(0x84, 31),
+       [HI3660_RST_USB3OTG_PHY] = HISI_RST_SEP(0x90, 3),
+       [HI3660_RST_USB3OTG] = HISI_RST_SEP(0x90, 5),
+       [HI3660_RST_USB3OTG_32K] = HISI_RST_SEP(0x90, 6),
+       [HI3660_RST_USB3OTG_AHB] = HISI_RST_SEP(0x90, 7),
+       [HI3660_RST_USB3OTG_MUX] = HISI_RST_SEP(0x90, 8),
+};

I think you can avoid the trap of the ABI incompatibility if you just define those as in the binding as tuples, using #reset-cells=2.

Quoted 2 lines

In particular for the first set, it seems really silly to redefine the numbers when there is just a simple integer number.

Could you clarify more, still not understand.
The number is index of the arrays, and the index will be used in dts. The arrays lists the registers offset and bit shift.
For example:

[HI3660_RST_I2C0] = HISI_RST_SEP(0x20, 3), means register offset : 0x20, and bit shift = 3.

And Documentation/devicetree/bindings/reset/reset.txt Required properties:
#reset-cells: Number of cells in a reset specifier; Typically 0 for nodes
with a single reset output and 1 for nodes with multiple reset outputs.

Thanks

#11 lore raw

PATCH 3/6 reset: hisilicon: add reset-hi3660

Quoted 42 lines · CET zhangfei
Quoted 33 lines · Arnd Bergmann
Quoted 19 lines · CET Zhangfei Gao
drivers/reset/hisilicon/reset-hi3660.c new file +19 -0
+static const struct hisi_reset_channel_data hi3660_iomcu_rst[] = {
+       [HI3660_RST_I2C0] = HISI_RST_SEP(0x20, 3),
+       [HI3660_RST_I2C1] = HISI_RST_SEP(0x20, 4),
+       [HI3660_RST_I2C2] = HISI_RST_SEP(0x20, 5),
+       [HI3660_RST_I2C6] = HISI_RST_SEP(0x20, 27),
+};
+
+static struct hisi_reset_controller_data hi3660_iomcu_controller = {
+       .nr_channels = ARRAY_SIZE(hi3660_iomcu_rst),
+       .channels = hi3660_iomcu_rst,
+};
+
+static const struct hisi_reset_channel_data hi3660_crgctrl_rst[] = {
+       [HI3660_RST_I2C3] = HISI_RST_SEP(0x78, 7),
+       [HI3660_RST_I2C4] = HISI_RST_SEP(0x78, 27),
+       [HI3660_RST_I2C7] = HISI_RST_SEP(0x60, 14),
+       [HI3660_RST_SD] = HISI_RST_SEP(0x90, 18),
+       [HI3660_RST_SDIO] = HISI_RST_SEP(0x90, 20),
+       [HI3660_RST_UFS] = HISI_RST_SEP(0x84, 12),

drivers/reset/hisilicon/reset-hi3660.c line 46

Quoted 10 lines
drivers/reset/hisilicon/reset-hi3660.c new file +10 -0
+       [HI3660_RST_UFS_ASSERT] = HISI_RST_SEP(0x84, 7),
+       [HI3660_RST_PCIE_SYS] = HISI_RST_SEP(0x84, 26),
+       [HI3660_RST_PCIE_PHY] = HISI_RST_SEP(0x84, 27),
+       [HI3660_RST_PCIE_BUS] = HISI_RST_SEP(0x84, 31),
+       [HI3660_RST_USB3OTG_PHY] = HISI_RST_SEP(0x90, 3),
+       [HI3660_RST_USB3OTG] = HISI_RST_SEP(0x90, 5),
+       [HI3660_RST_USB3OTG_32K] = HISI_RST_SEP(0x90, 6),
+       [HI3660_RST_USB3OTG_AHB] = HISI_RST_SEP(0x90, 7),
+       [HI3660_RST_USB3OTG_MUX] = HISI_RST_SEP(0x90, 8),
+};

I think you can avoid the trap of the ABI incompatibility if you just define those as in the binding as tuples, using #reset-cells=2.

Quoted 2 lines

In particular for the first set, it seems really silly to redefine the numbers when there is just a simple integer number.

Could you clarify more, still not understand.
The number is index of the arrays, and the index will be used in dts. The arrays lists the registers offset and bit shift.
For example:

Quoted 7 lines

[HI3660_RST_I2C0] = HISI_RST_SEP(0x20, 3), means register offset : 0x20, and bit shift = 3.

And Documentation/devicetree/bindings/reset/reset.txt Required properties:
#reset-cells: Number of cells in a reset specifier; Typically 0 for nodes
with a single reset output and 1 for nodes with multiple reset outputs.

You can easily enumerate the registers that contain reset bits here, so just use one cell for the register and another one for the index.

Arnd

author
#12 lore raw

PATCH 3/6 reset: hisilicon: add reset-hi3660

Quoted 44 lines · Arnd Bergmann
Quoted 43 lines · CET zhangfei
Quoted 33 lines · Arnd Bergmann
Quoted 19 lines · CET Zhangfei Gao
drivers/reset/hisilicon/reset-hi3660.c new file +19 -0
+static const struct hisi_reset_channel_data hi3660_iomcu_rst[] = {
+       [HI3660_RST_I2C0] = HISI_RST_SEP(0x20, 3),
+       [HI3660_RST_I2C1] = HISI_RST_SEP(0x20, 4),
+       [HI3660_RST_I2C2] = HISI_RST_SEP(0x20, 5),
+       [HI3660_RST_I2C6] = HISI_RST_SEP(0x20, 27),
+};
+
+static struct hisi_reset_controller_data hi3660_iomcu_controller = {
+       .nr_channels = ARRAY_SIZE(hi3660_iomcu_rst),
+       .channels = hi3660_iomcu_rst,
+};
+
+static const struct hisi_reset_channel_data hi3660_crgctrl_rst[] = {
+       [HI3660_RST_I2C3] = HISI_RST_SEP(0x78, 7),
+       [HI3660_RST_I2C4] = HISI_RST_SEP(0x78, 27),
+       [HI3660_RST_I2C7] = HISI_RST_SEP(0x60, 14),
+       [HI3660_RST_SD] = HISI_RST_SEP(0x90, 18),
+       [HI3660_RST_SDIO] = HISI_RST_SEP(0x90, 20),
+       [HI3660_RST_UFS] = HISI_RST_SEP(0x84, 12),

drivers/reset/hisilicon/reset-hi3660.c line 46

Quoted 10 lines
drivers/reset/hisilicon/reset-hi3660.c new file +10 -0
+       [HI3660_RST_UFS_ASSERT] = HISI_RST_SEP(0x84, 7),
+       [HI3660_RST_PCIE_SYS] = HISI_RST_SEP(0x84, 26),
+       [HI3660_RST_PCIE_PHY] = HISI_RST_SEP(0x84, 27),
+       [HI3660_RST_PCIE_BUS] = HISI_RST_SEP(0x84, 31),
+       [HI3660_RST_USB3OTG_PHY] = HISI_RST_SEP(0x90, 3),
+       [HI3660_RST_USB3OTG] = HISI_RST_SEP(0x90, 5),
+       [HI3660_RST_USB3OTG_32K] = HISI_RST_SEP(0x90, 6),
+       [HI3660_RST_USB3OTG_AHB] = HISI_RST_SEP(0x90, 7),
+       [HI3660_RST_USB3OTG_MUX] = HISI_RST_SEP(0x90, 8),
+};

I think you can avoid the trap of the ABI incompatibility if you just define those as in the binding as tuples, using #reset-cells=2.

Quoted 2 lines

In particular for the first set, it seems really silly to redefine the numbers when there is just a simple integer number.

Could you clarify more, still not understand.
The number is index of the arrays, and the index will be used in dts. The arrays lists the registers offset and bit shift.
For example:

[HI3660_RST_I2C0] = HISI_RST_SEP(0x20, 3), means register offset : 0x20, and bit shift = 3.

Quoted 7 lines
Quoted 5 lines

And Documentation/devicetree/bindings/reset/reset.txt
Required properties:
#reset-cells: Number of cells in a reset specifier; Typically 0 for nodes
with a single reset output and 1 for nodes with multiple reset outputs.

You can easily enumerate the registers that contain reset bits here, so just use one cell for the register and another one for the index.

/* reset separated register offset is 0x4 */

#define HISI_RST_SEP(off, bit)                                  \
         { .enable       = REG_FIELD(off, bit, bit),             \
           .disable      = REG_FIELD(off + 0x4, bit, bit),       \
           .status       = REG_FIELD(off + 0x8, bit, bit), }

We not only provide the off and bit shift, but fulfill the members in the meantime.

Thanks

maintainer
#13 lore raw

PATCH 3/6 reset: hisilicon: add reset-hi3660

In reply to Arnd Bergmann

Am Dienstag, den 22.11.2016, 10:42 +0100 schrieb Arnd Bergmann:

Quoted 43 lines · CET zhangfei
Quoted 42 lines · Arnd Bergmann
Quoted 33 lines · CET Zhangfei Gao
Quoted 19 lines
drivers/reset/hisilicon/reset-hi3660.c new file +19 -0
+static const struct hisi_reset_channel_data hi3660_iomcu_rst[] = {
+       [HI3660_RST_I2C0] = HISI_RST_SEP(0x20, 3),
+       [HI3660_RST_I2C1] = HISI_RST_SEP(0x20, 4),
+       [HI3660_RST_I2C2] = HISI_RST_SEP(0x20, 5),
+       [HI3660_RST_I2C6] = HISI_RST_SEP(0x20, 27),
+};
+
+static struct hisi_reset_controller_data hi3660_iomcu_controller = {
+       .nr_channels = ARRAY_SIZE(hi3660_iomcu_rst),
+       .channels = hi3660_iomcu_rst,
+};
+
+static const struct hisi_reset_channel_data hi3660_crgctrl_rst[] = {
+       [HI3660_RST_I2C3] = HISI_RST_SEP(0x78, 7),
+       [HI3660_RST_I2C4] = HISI_RST_SEP(0x78, 27),
+       [HI3660_RST_I2C7] = HISI_RST_SEP(0x60, 14),
+       [HI3660_RST_SD] = HISI_RST_SEP(0x90, 18),
+       [HI3660_RST_SDIO] = HISI_RST_SEP(0x90, 20),
+       [HI3660_RST_UFS] = HISI_RST_SEP(0x84, 12),

drivers/reset/hisilicon/reset-hi3660.c line 46

Quoted 10 lines
drivers/reset/hisilicon/reset-hi3660.c new file +10 -0
+       [HI3660_RST_UFS_ASSERT] = HISI_RST_SEP(0x84, 7),
+       [HI3660_RST_PCIE_SYS] = HISI_RST_SEP(0x84, 26),
+       [HI3660_RST_PCIE_PHY] = HISI_RST_SEP(0x84, 27),
+       [HI3660_RST_PCIE_BUS] = HISI_RST_SEP(0x84, 31),
+       [HI3660_RST_USB3OTG_PHY] = HISI_RST_SEP(0x90, 3),
+       [HI3660_RST_USB3OTG] = HISI_RST_SEP(0x90, 5),
+       [HI3660_RST_USB3OTG_32K] = HISI_RST_SEP(0x90, 6),
+       [HI3660_RST_USB3OTG_AHB] = HISI_RST_SEP(0x90, 7),
+       [HI3660_RST_USB3OTG_MUX] = HISI_RST_SEP(0x90, 8),
+};

I think you can avoid the trap of the ABI incompatibility if you just define those as in the binding as tuples, using #reset-cells=2.

Quoted 2 lines

In particular for the first set, it seems really silly to redefine the numbers when there is just a simple integer number.

Could you clarify more, still not understand.
The number is index of the arrays, and the index will be used in dts. The arrays lists the registers offset and bit shift.
For example:

Quoted 7 lines
Quoted 7 lines

[HI3660_RST_I2C0] = HISI_RST_SEP(0x20, 3), means register offset : 0x20, and bit shift = 3.

And Documentation/devicetree/bindings/reset/reset.txt Required properties:
#reset-cells: Number of cells in a reset specifier; Typically 0 for nodes
with a single reset output and 1 for nodes with multiple reset outputs.

This is just a suggestion, for reset controllers where the reset lines can reasonably be enumerated by a single integer. If there is a good reason to use more complicated bindings, more cells can be used. That being said, I dislike having to spread register/bit information throughout the device trees at the consumer/phandle sites, if the register/bit information absolutely has to be put into the device tree, I'd prefer a binding similar to ti-syscon, where it's all in one place.

Quoted 2 lines

You can easily enumerate the registers that contain reset bits here, so just use one cell for the register and another one for the index.

Changing the reset cells is an incompatible change, and this is not a straight forward register/bit mapping in hardware either. There are currently three registers involved: enable (+0x0), disable (+0x4), and status (+0x8). Also, what if in the future one of these reset bits have to be handled inverted (as just happened for hi3519)?

regards
Philipp

author
#14 lore raw

PATCH 3/6 reset: hisilicon: add reset-hi3660

Hi, Philipp

Quoted 50 lines · Philipp Zabel

Am Dienstag, den 22.11.2016, 10:42 +0100 schrieb Arnd Bergmann:

Quoted 42 lines · CET zhangfei
Quoted 41 lines · Arnd Bergmann
Quoted 33 lines · CET Zhangfei Gao
Quoted 19 lines
drivers/reset/hisilicon/reset-hi3660.c new file +19 -0
+static const struct hisi_reset_channel_data hi3660_iomcu_rst[] = {
+       [HI3660_RST_I2C0] = HISI_RST_SEP(0x20, 3),
+       [HI3660_RST_I2C1] = HISI_RST_SEP(0x20, 4),
+       [HI3660_RST_I2C2] = HISI_RST_SEP(0x20, 5),
+       [HI3660_RST_I2C6] = HISI_RST_SEP(0x20, 27),
+};
+
+static struct hisi_reset_controller_data hi3660_iomcu_controller = {
+       .nr_channels = ARRAY_SIZE(hi3660_iomcu_rst),
+       .channels = hi3660_iomcu_rst,
+};
+
+static const struct hisi_reset_channel_data hi3660_crgctrl_rst[] = {
+       [HI3660_RST_I2C3] = HISI_RST_SEP(0x78, 7),
+       [HI3660_RST_I2C4] = HISI_RST_SEP(0x78, 27),
+       [HI3660_RST_I2C7] = HISI_RST_SEP(0x60, 14),
+       [HI3660_RST_SD] = HISI_RST_SEP(0x90, 18),
+       [HI3660_RST_SDIO] = HISI_RST_SEP(0x90, 20),
+       [HI3660_RST_UFS] = HISI_RST_SEP(0x84, 12),

drivers/reset/hisilicon/reset-hi3660.c line 46

Quoted 10 lines
drivers/reset/hisilicon/reset-hi3660.c new file +10 -0
+       [HI3660_RST_UFS_ASSERT] = HISI_RST_SEP(0x84, 7),
+       [HI3660_RST_PCIE_SYS] = HISI_RST_SEP(0x84, 26),
+       [HI3660_RST_PCIE_PHY] = HISI_RST_SEP(0x84, 27),
+       [HI3660_RST_PCIE_BUS] = HISI_RST_SEP(0x84, 31),
+       [HI3660_RST_USB3OTG_PHY] = HISI_RST_SEP(0x90, 3),
+       [HI3660_RST_USB3OTG] = HISI_RST_SEP(0x90, 5),
+       [HI3660_RST_USB3OTG_32K] = HISI_RST_SEP(0x90, 6),
+       [HI3660_RST_USB3OTG_AHB] = HISI_RST_SEP(0x90, 7),
+       [HI3660_RST_USB3OTG_MUX] = HISI_RST_SEP(0x90, 8),
+};

I think you can avoid the trap of the ABI incompatibility if you just define those as in the binding as tuples, using #reset-cells=2.

Quoted 2 lines

In particular for the first set, it seems really silly to redefine the numbers when there is just a simple integer number.

Could you clarify more, still not understand.
The number is index of the arrays, and the index will be used in dts. The arrays lists the registers offset and bit shift.
For example:

Quoted 7 lines
Quoted 7 lines

[HI3660_RST_I2C0] = HISI_RST_SEP(0x20, 3), means register offset : 0x20, and bit shift = 3.

And Documentation/devicetree/bindings/reset/reset.txt
Required properties:
#reset-cells: Number of cells in a reset specifier; Typically 0 for nodes
with a single reset output and 1 for nodes with multiple reset outputs.

Quoted 7 lines

This is just a suggestion, for reset controllers where the reset lines can reasonably be enumerated by a single integer. If there is a good reason to use more complicated bindings, more cells can be used. That being said, I dislike having to spread register/bit information throughout the device trees at the consumer/phandle sites, if the register/bit information absolutely has to be put into the device tree, I'd prefer a binding similar to ti-syscon, where it's all in one place.

Thanks for the suggestion.
Will use table in dts instead of
include/dt-bindings/reset/hisi,hi3660-resets.h
like

+               hisi,reset-bits = <0x20 0x8             /* 0: i2c0 */
+                                  0x20 0x10            /* 1: i2c1 */
+                                  0x20 0x20            /* 2: i2c2 */
+                                  0x20 0x8000000>;     /* 3: i2c6 */

To remove the potential ABI issue as pointed by Arnd.

Quoted 8 lines
Quoted 3 lines

You can easily enumerate the registers that contain reset bits here, so just use one cell for the register and another one for the index.

Changing the reset cells is an incompatible change, and this is not a straight forward register/bit mapping in hardware either. There are currently three registers involved: enable (+0x0), disable (+0x4), and status (+0x8). Also, what if in the future one of these reset bits have to be handled inverted (as just happened for hi3519)?

Discussed with Jianchen, we are only considering Kirin series now. The inverted in hi3519 is only for some line, not the whole controller. It is more like a bug and kirin does not have such issue.

Will send a new RFC, help take a look.

Thanks

#15 lore raw

PATCH 4/6 dt-bindings: change hi6220-reset.txt according to reset-hi6220.c

In reply to Zhangfei Gao
---
 .../devicetree/bindings/reset/hisilicon,hi6220-reset.txt   | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
Documentation/devicetree/bindings/reset/hisilicon,hi6220-reset.txt +9 -5
index c25da39..6a864f3 100644
@@ -9,10 +9,9 @@ hi6220 SoC.
 
 Required properties:
 - compatible: should be one of the following:
-  - "hisilicon,hi6220-sysctrl", "syscon" : For peripheral reset controller.
-  - "hisilicon,hi6220-mediactrl", "syscon" : For media reset controller.
-- reg: should be register base and length as documented in the
-  datasheet
+  - "hisilicon,hi6220-reset-sysctrl" : For peripheral reset controller.
+  - "hisilicon,hi6220-reset-mediactrl" : For media reset controller.
+- hisi,rst-syscon: phandle of the reset's syscon.
 - #reset-cells: 1, see below
 
 Example:
@@ -20,7 +19,12 @@ sys_ctrl: sys_ctrl at f7030000 {
 	compatible = "hisilicon,hi6220-sysctrl", "syscon";
 	reg = <0x0 0xf7030000 0x0 0x2000>;
 	#clock-cells = <1>;
+};
+
+sys_ctrl_rst: sys_rst_controller {
+	compatible = "hisilicon,hi6220-reset-sysctrl";
 	#reset-cells = <1>;
+	hisi,rst-syscon = <&sys_ctrl>;
 };
 
 Specifying reset lines connected to IP modules
@@ -29,7 +33,7 @@ example:
 
         uart1: serial at ..... {
                 ...
-                resets = <&sys_ctrl PERIPH_RSTEN3_UART1>;
+                resets = <&sys_ctrl_rst PERIPH_RSTEN3_UART1>;
                 ...
         };
 
Signature · 1 line
2.7.4
#16 lore raw

PATCH 4/6 dt-bindings: change hi6220-reset.txt according to reset-hi6220.c

Documentation/devicetree/bindings/reset/hisilicon,hi6220-reset.txt hi6220 SoC. · line 15

Quoted 11 lines · CET Zhangfei Gao

Required properties:
- compatible: should be one of the following:

Documentation/devicetree/bindings/reset/hisilicon,hi6220-reset.txt +3 -4
-  - "hisilicon,hi6220-sysctrl", "syscon" : For peripheral reset controller.
-  - "hisilicon,hi6220-mediactrl", "syscon" : For media reset controller.
-- reg: should be register base and length as documented in the
-  datasheet
+  - "hisilicon,hi6220-reset-sysctrl" : For peripheral reset controller.
+  - "hisilicon,hi6220-reset-mediactrl" : For media reset controller.
+- hisi,rst-syscon: phandle of the reset's syscon.
 - #reset-cells: 1, see below

Please keep the old strings around for compatibility.

Arnd

maintainer
#17 lore raw

PATCH 4/6 dt-bindings: change hi6220-reset.txt according to reset-hi6220.c

Quoted 13 lines · Arnd Bergmann

Documentation/devicetree/bindings/reset/hisilicon,hi6220-reset.txt hi6220 SoC. · line 15

Quoted 11 lines · CET Zhangfei Gao

Required properties:
- compatible: should be one of the following:

Documentation/devicetree/bindings/reset/hisilicon,hi6220-reset.txt +3 -4
-  - "hisilicon,hi6220-sysctrl", "syscon" : For peripheral reset controller.
-  - "hisilicon,hi6220-mediactrl", "syscon" : For media reset controller.
-- reg: should be register base and length as documented in the
-  datasheet
+  - "hisilicon,hi6220-reset-sysctrl" : For peripheral reset controller.
+  - "hisilicon,hi6220-reset-mediactrl" : For media reset controller.
+- hisi,rst-syscon: phandle of the reset's syscon.
 - #reset-cells: 1, see below
Quoted 1 line

Please keep the old strings around for compatibility.

Why are these even changing? The commit message should say why.

Rob

author
#18 lore raw

PATCH 4/6 dt-bindings: change hi6220-reset.txt according to reset-hi6220.c

Hi, Rob

Quoted 13 lines · Rob Herring
Quoted 12 lines · Arnd Bergmann
Quoted 11 lines · CET Zhangfei Gao

Required properties:
- compatible: should be one of the following:

Documentation/devicetree/bindings/reset/hisilicon,hi6220-reset.txt +3 -4
-  - "hisilicon,hi6220-sysctrl", "syscon" : For peripheral reset controller.
-  - "hisilicon,hi6220-mediactrl", "syscon" : For media reset controller.
-- reg: should be register base and length as documented in the
-  datasheet
+  - "hisilicon,hi6220-reset-sysctrl" : For peripheral reset controller.
+  - "hisilicon,hi6220-reset-mediactrl" : For media reset controller.
+- hisi,rst-syscon: phandle of the reset's syscon.
  - #reset-cells: 1, see below
Quoted 2 lines
Quoted 1 line

Please keep the old strings around for compatibility.

Why are these even changing? The commit message should say why.

Have send [RFC V2:PATCH 0/2] add reset-hi3660
Not touching this file any more.
Only handle hi3660.

But hi6220 can directly use the driver.
Only need list reset info to hi6220.dts, same as hi3660. Like
+ iomcu_rst: iomcu_rst_controller {

+               compatible = "hisilicon,hi3660-reset";
+               #reset-cells = <1>;
+               hisi,rst-syscon = <&iomcu>;
+               hisi,reset-bits = <0x20 0x8             /* 0: i2c0 */
+                                  0x20 0x10            /* 1: i2c1 */
+                                  0x20 0x20            /* 2: i2c2 */
+                                  0x20 0x8000000>;     /* 3: i2c6 */

+ };

Thanks

#19 lore raw

PATCH 5/6 reset: hisilicon: Use new driver reset-hi6222

In reply to Zhangfei Gao

Using new reset-hi6220 with common reset.c
And keeps the same reset define

dts hi6220.c should be updated with new node sys_ctrl_rst Solving potential issue of sys_ctrl can not be used as clock and reset at the same time.

sys_ctrl: sys_ctrl at f7030000 {
	compatible = "hisilicon,hi6220-sysctrl", "syscon";
	reg = <0x0 0xf7030000 0x0 0x2000>;
	#clock-cells = <1>;
};
sys_ctrl_rst: sys_rst_controller {
	compatible = "hisilicon,hi6220-reset-sysctrl";
	#reset-cells = <1>;
	hisi,rst-syscon = <&sys_ctrl>;
};
uart1: serial at ..... {
        ...
        resets = <&sys_ctrl_rst PERIPH_RSTEN3_UART1>;
        ...
};
---
 drivers/reset/hisilicon/Makefile               |   2 +-
 drivers/reset/hisilicon/hi6220_reset.c         | 157 -------------------------
 drivers/reset/hisilicon/reset-hi6220.c         | 123 +++++++++++++++++++
 include/dt-bindings/reset/hisi,hi6220-resets.h | 130 ++++++++++----------
 4 files changed, 190 insertions(+), 222 deletions(-)
 delete mode 100644 drivers/reset/hisilicon/hi6220_reset.c
 create mode 100644 drivers/reset/hisilicon/reset-hi6220.c
drivers/reset/hisilicon/Makefile +1 -1
index 57e9893..caddac1 100644
@@ -1,3 +1,3 @@
 obj-y	+= reset.o
 obj-$(CONFIG_COMMON_RESET_HI3660) += reset-hi3660.o
-obj-$(CONFIG_COMMON_RESET_HI6220) += hi6220_reset.o
+obj-$(CONFIG_COMMON_RESET_HI6220) += reset-hi6220.o
drivers/reset/hisilicon/hi6220_reset.c deleted +0 -157

157 lines not on this page · raw message

drivers/reset/hisilicon/reset-hi6220.c new file +123 -0

123 lines not on this page · raw message

include/dt-bindings/reset/hisi,hi6220-resets.h +66 -64

137 lines not on this page · raw message

Signature · 1 line
2.7.4
#20 lore raw

PATCH 5/6 reset: hisilicon: Use new driver reset-hi6222

Quoted 12 lines · CET Zhangfei Gao
include/dt-bindings/reset/hisi,hi6220-resets.h +0 -10
-#define PERIPH_RSTDIS0_MMC0             0x000
-#define PERIPH_RSTDIS0_MMC1             0x001
-#define PERIPH_RSTDIS0_MMC2             0x002
-#define PERIPH_RSTDIS0_NANDC            0x003
-#define PERIPH_RSTDIS0_USBOTG_BUS       0x004
-#define PERIPH_RSTDIS0_POR_PICOPHY      0x005
-#define PERIPH_RSTDIS0_USBOTG           0x006
-#define PERIPH_RSTDIS0_USBOTG_32K       0x007
-#define PERIPH_RSTDIS1_HIFI             0x100
-#define PERIPH_RSTDIS1_DIGACODEC        0x105
 

include/dt-bindings/reset/hisi,hi6220-resets.h line 18

Quoted 10 lines
include/dt-bindings/reset/hisi,hi6220-resets.h +10 -0
+/* reset in sysctrl */
+#define PERIPH_RSTDIS0_MMC0             0
+#define PERIPH_RSTDIS0_MMC1             1
+#define PERIPH_RSTDIS0_MMC2             2
+#define PERIPH_RSTDIS0_NANDC            3
+#define PERIPH_RSTDIS0_USBOTG_BUS       4
+#define PERIPH_RSTDIS0_POR_PICOPHY      5
+#define PERIPH_RSTDIS0_USBOTG           6
+#define PERIPH_RSTDIS0_USBOTG_32K       7
+#define PERIPH_RSTDIS1_HIFI             8

You can't redefined the binding here, this is part of the ABI. You can however add new numbers as long as the old ones keep working.

Arnd

author
#21 lore raw

PATCH 5/6 reset: hisilicon: Use new driver reset-hi6222

Quoted 16 lines · Arnd Bergmann
Quoted 15 lines · CET Zhangfei Gao
include/dt-bindings/reset/hisi,hi6220-resets.h +5 -10
-#define PERIPH_RSTDIS0_MMC0             0x000
-#define PERIPH_RSTDIS0_MMC1             0x001
-#define PERIPH_RSTDIS0_MMC2             0x002
-#define PERIPH_RSTDIS0_NANDC            0x003
-#define PERIPH_RSTDIS0_USBOTG_BUS       0x004
-#define PERIPH_RSTDIS0_POR_PICOPHY      0x005
-#define PERIPH_RSTDIS0_USBOTG           0x006
-#define PERIPH_RSTDIS0_USBOTG_32K       0x007
-#define PERIPH_RSTDIS1_HIFI             0x100
-#define PERIPH_RSTDIS1_DIGACODEC        0x105
+/* reset in sysctrl */
+#define PERIPH_RSTDIS0_MMC0             0
+#define PERIPH_RSTDIS0_MMC1             1
+#define PERIPH_RSTDIS0_MMC2             2
+#define PERIPH_RSTDIS0_NANDC            3
Quoted 8 lines

include/dt-bindings/reset/hisi,hi6220-resets.h line 18

Quoted 5 lines
include/dt-bindings/reset/hisi,hi6220-resets.h +5 -0
+#define PERIPH_RSTDIS0_USBOTG_BUS       4
+#define PERIPH_RSTDIS0_POR_PICOPHY      5
+#define PERIPH_RSTDIS0_USBOTG           6
+#define PERIPH_RSTDIS0_USBOTG_32K       7
+#define PERIPH_RSTDIS1_HIFI             8

You can't redefined the binding here, this is part of the ABI. You can however add new numbers as long as the old ones keep working.

The methods are different.
The original define is offset | bit_shift, and driver has to parse offset and bit shift.
The new define is just index of array, which is defined in the reset-xxx.c

Thanks

#22 lore raw

PATCH 5/6 reset: hisilicon: Use new driver reset-hi6222

Quoted 25 lines · CET zhangfei
Quoted 16 lines · Arnd Bergmann
Quoted 15 lines · CET Zhangfei Gao
include/dt-bindings/reset/hisi,hi6220-resets.h +5 -10
-#define PERIPH_RSTDIS0_MMC0             0x000
-#define PERIPH_RSTDIS0_MMC1             0x001
-#define PERIPH_RSTDIS0_MMC2             0x002
-#define PERIPH_RSTDIS0_NANDC            0x003
-#define PERIPH_RSTDIS0_USBOTG_BUS       0x004
-#define PERIPH_RSTDIS0_POR_PICOPHY      0x005
-#define PERIPH_RSTDIS0_USBOTG           0x006
-#define PERIPH_RSTDIS0_USBOTG_32K       0x007
-#define PERIPH_RSTDIS1_HIFI             0x100
-#define PERIPH_RSTDIS1_DIGACODEC        0x105
+/* reset in sysctrl */
+#define PERIPH_RSTDIS0_MMC0             0
+#define PERIPH_RSTDIS0_MMC1             1
+#define PERIPH_RSTDIS0_MMC2             2
+#define PERIPH_RSTDIS0_NANDC            3
Quoted 8 lines

include/dt-bindings/reset/hisi,hi6220-resets.h line 18

Quoted 5 lines
include/dt-bindings/reset/hisi,hi6220-resets.h +5 -0
+#define PERIPH_RSTDIS0_USBOTG_BUS       4
+#define PERIPH_RSTDIS0_POR_PICOPHY      5
+#define PERIPH_RSTDIS0_USBOTG           6
+#define PERIPH_RSTDIS0_USBOTG_32K       7
+#define PERIPH_RSTDIS1_HIFI             8

You can't redefined the binding here, this is part of the ABI. You can however add new numbers as long as the old ones keep working.

Quoted 4 lines

The methods are different.
The original define is offset | bit_shift, and driver has to parse offset and bit shift.
The new define is just index of array, which is defined in the reset-xxx.c

I understand that, what I mean is you have to find a way to let the new driver still support the old binding, you can't change it.

Arnd

#23 lore raw

PATCH 6/6 arm64: dts: hi6220: update reset node according to reset-hi6220.c

In reply to Zhangfei Gao
---
 arch/arm64/boot/dts/hisilicon/hi6220.dtsi | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)
arch/arm64/boot/dts/hisilicon/hi6220.dtsi +15 -5
index 17839db..7918043 100644
@@ -246,14 +246,24 @@
 			compatible = "hisilicon,hi6220-sysctrl", "syscon";
 			reg = <0x0 0xf7030000 0x0 0x2000>;
 			#clock-cells = <1>;
-			#reset-cells = <1>;
 		};
 
 		media_ctrl: media_ctrl at f4410000 {
 			compatible = "hisilicon,hi6220-mediactrl", "syscon";
 			reg = <0x0 0xf4410000 0x0 0x1000>;
 			#clock-cells = <1>;
+		};
+
+		sys_ctrl_rst: sys_rst_controller {
+			compatible = "hisilicon,hi6220-reset-sysctrl";
+			#reset-cells = <1>;
+			hisi,rst-syscon = <&sys_ctrl>;
+		};
+
+		media_ctrl_rst: media_rst_controller {
+			compatible = "hisilicon,hi6220-reset-mediactrl";
 			#reset-cells = <1>;
+			hisi,rst-syscon = <&media_ctrl>;
 		};
 
 		pm_ctrl: pm_ctrl at f7032000 {
@@ -771,7 +781,7 @@
 			interrupts = <0x0 0x48 0x4>;
 			clocks = <&sys_ctrl 2>, <&sys_ctrl 1>;
 			clock-names = "ciu", "biu";
-			resets = <&sys_ctrl PERIPH_RSTDIS0_MMC0>;
+			resets = <&sys_ctrl_rst PERIPH_RSTDIS0_MMC0>;
 			bus-width = <0x8>;
 			vmmc-supply = <&ldo19>;
 			pinctrl-names = "default";
@@ -794,7 +804,7 @@
 			#size-cells = <0x0>;
 			clocks = <&sys_ctrl 4>, <&sys_ctrl 3>;
 			clock-names = "ciu", "biu";
-			resets = <&sys_ctrl PERIPH_RSTDIS0_MMC1>;
+			resets = <&sys_ctrl_rst PERIPH_RSTDIS0_MMC1>;
 			vqmmc-supply = <&ldo7>;
 			vmmc-supply = <&ldo10>;
 			bus-width = <0x4>;
@@ -812,7 +822,7 @@
 			interrupts = <0x0 0x4a 0x4>;
 			clocks = <&sys_ctrl HI6220_MMC2_CIUCLK>, <&sys_ctrl HI6220_MMC2_CLK>;
 			clock-names = "ciu", "biu";
-			resets = <&sys_ctrl PERIPH_RSTDIS0_MMC2>;
+			resets = <&sys_ctrl_rst PERIPH_RSTDIS0_MMC2>;
 			bus-width = <0x4>;
 			broken-cd;
 			pinctrl-names = "default", "idle";
@@ -867,7 +877,7 @@
 			reg = <0x0 0xf4100000 0x0 0x7800>;
 			reg-names = "ade_base";
 			hisilicon,noc-syscon = <&medianoc_ade>;
-			resets = <&media_ctrl MEDIA_ADE>;
+			resets = <&media_ctrl_rst MEDIA_ADE>;
 			interrupts = <0 115 4>; /* ldi interrupt */
 
 			clocks = <&media_ctrl HI6220_ADE_CORE>,
Signature · 1 line
2.7.4