Re: [PATCH v6 10/12] reset: Add Nuvoton ma35d1 reset driver support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dear Philipp,



On 2023/4/25 上午 04:02, Philipp Zabel wrote:
Hi Jacky,

On Tue, Mar 28, 2023 at 02:19:10AM +0000, Jacky Huang wrote:
From: Jacky Huang <ychuang3@xxxxxxxxxxx>

This driver supports individual IP reset for ma35d1. The reset
control registers is a subset of system control registers.

Signed-off-by: Jacky Huang <ychuang3@xxxxxxxxxxx>
---
  drivers/reset/Kconfig        |   6 ++
  drivers/reset/Makefile       |   1 +
  drivers/reset/reset-ma35d1.c | 152 +++++++++++++++++++++++++++++++++++
  3 files changed, 159 insertions(+)
  create mode 100644 drivers/reset/reset-ma35d1.c

[...]
diff --git a/drivers/reset/reset-ma35d1.c b/drivers/reset/reset-ma35d1.c
new file mode 100644
index 000000000000..221299e7b873
--- /dev/null
+++ b/drivers/reset/reset-ma35d1.c
@@ -0,0 +1,152 @@
[...]
+static int ma35d1_reset_update(struct reset_controller_dev *rcdev,
+			       unsigned long id, bool assert)
+{
+	unsigned int reg;
+	int ret;
+	int offset = (id / RST_PRE_REG) * 4;
+	struct ma35d1_reset_data *data =
+			container_of(rcdev, struct ma35d1_reset_data, rcdev);
+
+	ret = regmap_read(data->regmap, REG_SYS_IPRST0 + offset, &reg);
+	if (ret < 0)
+		return ret;
+	if (assert)
+		reg |= 1 << (id % RST_PRE_REG);
+	else
+		reg &= ~(1 << (id % RST_PRE_REG));
+
+	return regmap_write(data->regmap, REG_SYS_IPRST0 + offset, reg);
This should use regmap_update_bits().

[...]
+static int ma35d1_reset_status(struct reset_controller_dev *rcdev,
+			      unsigned long id)
+{
+	int reg, ret;
+	int offset = id / RST_PRE_REG;
Should this be

	int offset = (id / RST_PRE_REG) * 4;

?

Yes, here is a coding mistake.
As the register offset was modified to be indexed by lookup table in v7, this
code was obsoleted.
Thank you for pointing out this.

+static int ma35d1_reset_probe(struct platform_device *pdev)
+{
+	int err;
+	struct device *dev = &pdev->dev;
+	struct device_node *parent;
+	struct ma35d1_reset_data *reset_data;
+	struct ma35d1_reboot_data *reboot_data;
+
+	if (!pdev->dev.of_node) {
+		dev_err(&pdev->dev, "Device tree node not found\n");
+		return -EINVAL;
+	}
+
+	reset_data = devm_kzalloc(dev, sizeof(*reset_data), GFP_KERNEL);
+	if (!reset_data)
+		return -ENOMEM;
+
+	reboot_data = devm_kzalloc(dev, sizeof(*reboot_data), GFP_KERNEL);
+	if (!reboot_data)
+		return -ENOMEM;
These structures could be combined into one.

OK, we will combine them into one.

regards
Philipp

Best regards,
Jacky Huang





[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux