diff mbox series

[1/4,1/4] reset: simple: Add syscon device compatible

Message ID 20250214065833.530276-3-dingwei@marvell.com (mailing list archive)
State New
Headers show
Series Add Armada8K reset controller support | expand

Commit Message

Wilson Ding Feb. 14, 2025, 6:58 a.m. UTC
Introduce the new ops for updating reset line and getting status. Thus,
the reset controller can be accessed through either direct I/O or regmap
interfaces. It enables the support of the syscon devices with the simple
reset code. To adapt the DT binding of the syscon device, the number of
reset lines must be specified in device data.

Signed-off-by: Wilson Ding <dingwei@marvell.com>
---
 drivers/reset/reset-simple.c       | 117 +++++++++++++++++++++++------
 include/linux/reset/reset-simple.h |  11 +++
 2 files changed, 107 insertions(+), 21 deletions(-)

Comments

Krzysztof Kozlowski Feb. 14, 2025, 8:48 a.m. UTC | #1
On Thu, Feb 13, 2025 at 10:58:30PM -0800, Wilson Ding wrote:
>  #define SOCFPGA_NR_BANKS	8
> @@ -171,26 +221,51 @@ static int reset_simple_probe(struct platform_device *pdev)
>  	if (!data)
>  		return -ENOMEM;
>  
> -	membase = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
> -	if (IS_ERR(membase))
> -		return PTR_ERR(membase);
> +	if (devdata && devdata->syscon_dev) {
> +		data->regmap = syscon_node_to_regmap(pdev->dev.parent->of_node);
> +		if (IS_ERR(data->regmap))
> +			return PTR_ERR(data->regmap);
>  
> -	spin_lock_init(&data->lock);
> -	data->membase = membase;
> -	data->rcdev.owner = THIS_MODULE;
> -	data->rcdev.nr_resets = resource_size(res) * BITS_PER_BYTE;
> -	data->rcdev.ops = &reset_simple_ops;
> -	data->rcdev.of_node = dev->of_node;
> +		if (device_property_read_u32(&pdev->dev, "offset",

Where is this binding documented? This is patch #1, so something anywy
is wrong here (see submitting patches for bindings).

> +					     &data->reg_offset))
> +			data->reg_offset = devdata->reg_offset;
>  
> -	if (devdata) {
> -		reg_offset = devdata->reg_offset;
> -		if (devdata->nr_resets)
> -			data->rcdev.nr_resets = devdata->nr_resets;
> +		if (devdata->nr_resets == 0) {
> +			dev_err(dev, "no reset line\n");
> +			return -EINVAL;
> +		}

Best regards,
Krzysztof
Philipp Zabel Feb. 14, 2025, 11:54 a.m. UTC | #2
On Do, 2025-02-13 at 22:58 -0800, Wilson Ding wrote:
> Introduce the new ops for updating reset line and getting status. Thus,
> the reset controller can be accessed through either direct I/O or regmap
> interfaces.

Please don't add a new layer of function pointer indirection, just add
a new struct reset_control_ops for the regmap variant.

> It enables the support of the syscon devices with the simple
> reset code. To adapt the DT binding of the syscon device, the number of
> reset lines must be specified in device data.

If the DT node had a reg property, number of reset lines could be
determined from its size, like for MMIO.

> Signed-off-by: Wilson Ding <dingwei@marvell.com>
> ---
>  drivers/reset/reset-simple.c       | 117 +++++++++++++++++++++++------
>  include/linux/reset/reset-simple.h |  11 +++
>  2 files changed, 107 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/reset/reset-simple.c b/drivers/reset/reset-simple.c
> index 276067839830..e4e777d40a79 100644
> --- a/drivers/reset/reset-simple.c
> +++ b/drivers/reset/reset-simple.c
> @@ -15,8 +15,10 @@
>  #include <linux/device.h>
>  #include <linux/err.h>
>  #include <linux/io.h>
> +#include <linux/mfd/syscon.h>
>  #include <linux/of.h>
>  #include <linux/platform_device.h>
> +#include <linux/regmap.h>
>  #include <linux/reset-controller.h>
>  #include <linux/reset/reset-simple.h>
>  #include <linux/spinlock.h>
> @@ -27,10 +29,9 @@ to_reset_simple_data(struct reset_controller_dev *rcdev)
>  	return container_of(rcdev, struct reset_simple_data, rcdev);
>  }
>  
> -static int reset_simple_update(struct reset_controller_dev *rcdev,
> +static int reset_simple_update_mmio(struct reset_simple_data *data,
>  			       unsigned long id, bool assert)

No need to rename or change the function prototype.

>  {
> -	struct reset_simple_data *data = to_reset_simple_data(rcdev);
>  	int reg_width = sizeof(u32);
>  	int bank = id / (reg_width * BITS_PER_BYTE);
>  	int offset = id % (reg_width * BITS_PER_BYTE);
> @@ -51,16 +52,40 @@ static int reset_simple_update(struct reset_controller_dev *rcdev,
>  	return 0;
>  }
>  
> +static int reset_simple_update_regmap(struct reset_simple_data *data,
> +				      unsigned long id, bool assert)

I'd call this reset_simple_regmap_update().

> +{
> +	int reg_width = sizeof(u32);
> +	int bank = id / (reg_width * BITS_PER_BYTE);
> +	int offset = id % (reg_width * BITS_PER_BYTE);
> +	u32 mask, val;
> +
> +	mask = BIT(offset);
> +
> +	if (assert ^ data->active_low)
> +		val = mask;
> +	else
> +		val = 0;
> +
> +	return regmap_write_bits(data->regmap,
> +				 data->reg_offset + (bank * reg_width),
> +				 mask, val);
> +}
> +
>  static int reset_simple_assert(struct reset_controller_dev *rcdev,
>  			       unsigned long id)
>  {
> -	return reset_simple_update(rcdev, id, true);
> +	struct reset_simple_data *data = to_reset_simple_data(rcdev);
> +
> +	return data->ops.update(data, id, true);
>  }
>  
>  static int reset_simple_deassert(struct reset_controller_dev *rcdev,
>  				 unsigned long id)
>  {
> -	return reset_simple_update(rcdev, id, false);
> +	struct reset_simple_data *data = to_reset_simple_data(rcdev);
> +
> +	return data->ops.update(data, id, false);
>  }

No need for indirection. Better to just add separate
reset_simple_regmap_assert/deassert() functions.

>  static int reset_simple_reset(struct reset_controller_dev *rcdev,
> @@ -81,10 +106,9 @@ static int reset_simple_reset(struct reset_controller_dev *rcdev,
>  	return reset_simple_deassert(rcdev, id);
>  }
>  
> -static int reset_simple_status(struct reset_controller_dev *rcdev,
> -			       unsigned long id)
> +static int reset_simple_status_mmio(struct reset_simple_data *data,
> +			     unsigned long id)
>  {
> -	struct reset_simple_data *data = to_reset_simple_data(rcdev);
>  	int reg_width = sizeof(u32);
>  	int bank = id / (reg_width * BITS_PER_BYTE);
>  	int offset = id % (reg_width * BITS_PER_BYTE);
> @@ -95,6 +119,31 @@ static int reset_simple_status(struct reset_controller_dev *rcdev,
>  	return !(reg & BIT(offset)) ^ !data->status_active_low;
>  }
>  
> +static int reset_simple_status_regmap(struct reset_simple_data *data,
> +				    unsigned long id)
> +{
> +	int reg_width = sizeof(u32);
> +	int bank = id / (reg_width * BITS_PER_BYTE);
> +	int offset = id % (reg_width * BITS_PER_BYTE);
> +	u32 reg;
> +	int ret;
> +
> +	ret = regmap_read(data->regmap, data->reg_offset + (bank * reg_width),
> +			  &reg);
> +	if (ret)
> +		return ret;
> +
> +	return !(reg & BIT(offset)) ^ !data->status_active_low;
> +}
> +
> +static int reset_simple_status(struct reset_controller_dev *rcdev,
> +			       unsigned long id)
> +{
> +	struct reset_simple_data *data = to_reset_simple_data(rcdev);
> +
> +	return data->ops.status(data, id);
> +}

Same as above, no need for indirection.
Just add separate reset_simple_regmap_assert/deassert() functions ...

> +
>  const struct reset_control_ops reset_simple_ops = {
>  	.assert		= reset_simple_assert,
>  	.deassert	= reset_simple_deassert,

... and add a const struct reset_control_ops reset_simple_regmap_ops.

regards
Philipp
Wilson Ding Feb. 14, 2025, 5:13 p.m. UTC | #3
> -----Original Message-----
> From: Philipp Zabel <p.zabel@pengutronix.de>
> Sent: Friday, February 14, 2025 3:54 AM
> To: Wilson Ding <dingwei@marvell.com>; linux-kernel@vger.kernel.org;
> devicetree@vger.kernel.org; linux-arm-kernel@lists.infradead.org
> Cc: andrew@lunn.ch; gregory.clement@bootlin.com;
> sebastian.hesselbarth@gmail.com; robh@kernel.org; krzk+dt@kernel.org;
> conor+dt@kernel.org; Sanghoon Lee <salee@marvell.com>; Geethasowjanya
> Akula <gakula@marvell.com>
> Subject: [EXTERNAL] Re: [PATCH 1/4] [PATCH 1/4] reset: simple: Add syscon
> device compatible
> 
> On Do, 2025-02-13 at 22:58 -0800, Wilson Ding wrote:
> > Introduce the new ops for updating reset line and getting status.
> > Thus, the reset controller can be accessed through either direct I/O
> > or regmap interfaces.
> 
> Please don't add a new layer of function pointer indirection, just add a new
> struct reset_control_ops for the regmap variant.
> 

If just adding a new struct reset_control_ops for the regmap variant, almost
all the functions will be duplicated for regmap variant. 
Besides reset_simple_regmap_assert/deassert(), we also need to have the
regmap version of reset_simple_update(). Since reset_simple_reset() invokes
reset_simple_regmap_assert/deassert(), it also needs to be duplicated.
In this case, there will be too many redundant codes in this file. I doubt if
it is worth to use the reset simple code. Maybe it's better to fork a new file
for the syscon device, such as 'reset-simple-syscon.c'. What do you say?

> > It enables the support of the syscon devices with the simple reset
> > code. To adapt the DT binding of the syscon device, the number of
> > reset lines must be specified in device data.
> 
> If the DT node had a reg property, number of reset lines could be determined
> from its size, like for MMIO.
> 
> > Signed-off-by: Wilson Ding <dingwei@marvell.com>
> > ---
> >  drivers/reset/reset-simple.c       | 117 +++++++++++++++++++++++------
> >  include/linux/reset/reset-simple.h |  11 +++
> >  2 files changed, 107 insertions(+), 21 deletions(-)
> >
> > diff --git a/drivers/reset/reset-simple.c
> > b/drivers/reset/reset-simple.c index 276067839830..e4e777d40a79
> 100644
> > --- a/drivers/reset/reset-simple.c
> > +++ b/drivers/reset/reset-simple.c
> > @@ -15,8 +15,10 @@
> >  #include <linux/device.h>
> >  #include <linux/err.h>
> >  #include <linux/io.h>
> > +#include <linux/mfd/syscon.h>
> >  #include <linux/of.h>
> >  #include <linux/platform_device.h>
> > +#include <linux/regmap.h>
> >  #include <linux/reset-controller.h>
> >  #include <linux/reset/reset-simple.h>  #include <linux/spinlock.h> @@
> > -27,10 +29,9 @@ to_reset_simple_data(struct reset_controller_dev *rcdev)
> >  	return container_of(rcdev, struct reset_simple_data, rcdev);  }
> >
> > -static int reset_simple_update(struct reset_controller_dev *rcdev,
> > +static int reset_simple_update_mmio(struct reset_simple_data *data,
> >  			       unsigned long id, bool assert)
> 
> No need to rename or change the function prototype.
> 
> >  {
> > -	struct reset_simple_data *data = to_reset_simple_data(rcdev);
> >  	int reg_width = sizeof(u32);
> >  	int bank = id / (reg_width * BITS_PER_BYTE);
> >  	int offset = id % (reg_width * BITS_PER_BYTE); @@ -51,16 +52,40
> @@
> > static int reset_simple_update(struct reset_controller_dev *rcdev,
> >  	return 0;
> >  }
> >
> > +static int reset_simple_update_regmap(struct reset_simple_data *data,
> > +				      unsigned long id, bool assert)
> 
> I'd call this reset_simple_regmap_update().
> 
> > +{
> > +	int reg_width = sizeof(u32);
> > +	int bank = id / (reg_width * BITS_PER_BYTE);
> > +	int offset = id % (reg_width * BITS_PER_BYTE);
> > +	u32 mask, val;
> > +
> > +	mask = BIT(offset);
> > +
> > +	if (assert ^ data->active_low)
> > +		val = mask;
> > +	else
> > +		val = 0;
> > +
> > +	return regmap_write_bits(data->regmap,
> > +				 data->reg_offset + (bank * reg_width),
> > +				 mask, val);
> > +}
> > +
> >  static int reset_simple_assert(struct reset_controller_dev *rcdev,
> >  			       unsigned long id)
> >  {
> > -	return reset_simple_update(rcdev, id, true);
> > +	struct reset_simple_data *data = to_reset_simple_data(rcdev);
> > +
> > +	return data->ops.update(data, id, true);
> >  }
> >
> >  static int reset_simple_deassert(struct reset_controller_dev *rcdev,
> >  				 unsigned long id)
> >  {
> > -	return reset_simple_update(rcdev, id, false);
> > +	struct reset_simple_data *data = to_reset_simple_data(rcdev);
> > +
> > +	return data->ops.update(data, id, false);
> >  }
> 
> No need for indirection. Better to just add separate
> reset_simple_regmap_assert/deassert() functions.
> 

See my reply to the first comment.

> >  static int reset_simple_reset(struct reset_controller_dev *rcdev, @@
> > -81,10 +106,9 @@ static int reset_simple_reset(struct reset_controller_dev
> *rcdev,
> >  	return reset_simple_deassert(rcdev, id);  }
> >
> > -static int reset_simple_status(struct reset_controller_dev *rcdev,
> > -			       unsigned long id)
> > +static int reset_simple_status_mmio(struct reset_simple_data *data,
> > +			     unsigned long id)
> >  {
> > -	struct reset_simple_data *data = to_reset_simple_data(rcdev);
> >  	int reg_width = sizeof(u32);
> >  	int bank = id / (reg_width * BITS_PER_BYTE);
> >  	int offset = id % (reg_width * BITS_PER_BYTE); @@ -95,6 +119,31
> @@
> > static int reset_simple_status(struct reset_controller_dev *rcdev,
> >  	return !(reg & BIT(offset)) ^ !data->status_active_low;  }
> >
> > +static int reset_simple_status_regmap(struct reset_simple_data *data,
> > +				    unsigned long id)
> > +{
> > +	int reg_width = sizeof(u32);
> > +	int bank = id / (reg_width * BITS_PER_BYTE);
> > +	int offset = id % (reg_width * BITS_PER_BYTE);
> > +	u32 reg;
> > +	int ret;
> > +
> > +	ret = regmap_read(data->regmap, data->reg_offset + (bank *
> reg_width),
> > +			  &reg);
> > +	if (ret)
> > +		return ret;
> > +
> > +	return !(reg & BIT(offset)) ^ !data->status_active_low; }
> > +
> > +static int reset_simple_status(struct reset_controller_dev *rcdev,
> > +			       unsigned long id)
> > +{
> > +	struct reset_simple_data *data = to_reset_simple_data(rcdev);
> > +
> > +	return data->ops.status(data, id);
> > +}
> 
> Same as above, no need for indirection.
> Just add separate reset_simple_regmap_assert/deassert() functions ...
> 

See my reply to the first comment.

> > +
> >  const struct reset_control_ops reset_simple_ops = {
> >  	.assert		= reset_simple_assert,
> >  	.deassert	= reset_simple_deassert,
> 
> ... and add a const struct reset_control_ops reset_simple_regmap_ops.
> 

See my reply to the first comment.

> regards
> Philipp

- Wilson
Philipp Zabel Feb. 14, 2025, 6:03 p.m. UTC | #4
On Fr, 2025-02-14 at 17:13 +0000, Wilson Ding wrote:
> 
> > -----Original Message-----
> > From: Philipp Zabel <p.zabel@pengutronix.de>
> > Sent: Friday, February 14, 2025 3:54 AM
> > To: Wilson Ding <dingwei@marvell.com>; linux-kernel@vger.kernel.org;
> > devicetree@vger.kernel.org; linux-arm-kernel@lists.infradead.org
> > Cc: andrew@lunn.ch; gregory.clement@bootlin.com;
> > sebastian.hesselbarth@gmail.com; robh@kernel.org; krzk+dt@kernel.org;
> > conor+dt@kernel.org; Sanghoon Lee <salee@marvell.com>; Geethasowjanya
> > Akula <gakula@marvell.com>
> > Subject: [EXTERNAL] Re: [PATCH 1/4] [PATCH 1/4] reset: simple: Add syscon
> > device compatible
> > 
> > On Do, 2025-02-13 at 22:58 -0800, Wilson Ding wrote:
> > > Introduce the new ops for updating reset line and getting status.
> > > Thus, the reset controller can be accessed through either direct I/O
> > > or regmap interfaces.
> > 
> > Please don't add a new layer of function pointer indirection, just add a new
> > struct reset_control_ops for the regmap variant.
> > 
> 
> If just adding a new struct reset_control_ops for the regmap variant, almost
> all the functions will be duplicated for regmap variant. 
> Besides reset_simple_regmap_assert/deassert(), we also need to have the
> regmap version of reset_simple_update().

Yes. You could also duplicate/fold update() into assert/deassert().
It is trivial enough and the compiler will do that anyway.

> Since reset_simple_reset() invokes
> reset_simple_regmap_assert/deassert(), it also needs to be
> duplicated.

That one could go through the data->rcdev.ops->assert/deassert function
pointers and be reused. But I wonder if that one function is worth the
added complexity.

> In this case, there will be too many redundant codes in this file. I doubt if
> it is worth to use the reset simple code. Maybe it's better to fork a new file
> for the syscon device, such as 'reset-simple-syscon.c'. What do you say?

That sounds sensible to me.

regards
Philipp
Wilson Ding Feb. 14, 2025, 6:40 p.m. UTC | #5
> -----Original Message-----
> From: Philipp Zabel <p.zabel@pengutronix.de>
> Sent: Friday, February 14, 2025 10:03 AM
> To: Wilson Ding <dingwei@marvell.com>; linux-kernel@vger.kernel.org;
> devicetree@vger.kernel.org; linux-arm-kernel@lists.infradead.org
> Cc: andrew@lunn.ch; gregory.clement@bootlin.com;
> sebastian.hesselbarth@gmail.com; robh@kernel.org; krzk+dt@kernel.org;
> conor+dt@kernel.org; Sanghoon Lee <salee@marvell.com>; Geethasowjanya
> Akula <gakula@marvell.com>
> Subject: [EXTERNAL] Re: [PATCH 1/4] [PATCH 1/4] reset: simple: Add syscon
> device compatible
> 
> On Fr, 2025-02-14 at 17: 13 +0000, Wilson Ding wrote: > > > -----Original
> Message----- > > From: Philipp Zabel <p. zabel@ pengutronix. de> > > Sent:
> Friday, February 14, 2025 3: 54 AM > > To: Wilson Ding
> <dingwei@ marvell. com>; 
> On Fr, 2025-02-14 at 17:13 +0000, Wilson Ding wrote:
> >
> > > -----Original Message-----
> > > From: Philipp Zabel <p.zabel@pengutronix.de>
> > > Sent: Friday, February 14, 2025 3:54 AM
> > > To: Wilson Ding <dingwei@marvell.com>; linux-kernel@vger.kernel.org;
> > > devicetree@vger.kernel.org; linux-arm-kernel@lists.infradead.org
> > > Cc: andrew@lunn.ch; gregory.clement@bootlin.com;
> > > sebastian.hesselbarth@gmail.com; robh@kernel.org;
> > > krzk+dt@kernel.org;
> > > conor+dt@kernel.org; Sanghoon Lee <salee@marvell.com>;
> > > conor+Geethasowjanya
> > > Akula <gakula@marvell.com>
> > > Subject: [EXTERNAL] Re: [PATCH 1/4] [PATCH 1/4] reset: simple: Add
> > > syscon device compatible
> > >
> > > On Do, 2025-02-13 at 22:58 -0800, Wilson Ding wrote:
> > > > Introduce the new ops for updating reset line and getting status.
> > > > Thus, the reset controller can be accessed through either direct
> > > > I/O or regmap interfaces.
> > >
> > > Please don't add a new layer of function pointer indirection, just
> > > add a new struct reset_control_ops for the regmap variant.
> > >
> >
> > If just adding a new struct reset_control_ops for the regmap variant,
> > almost all the functions will be duplicated for regmap variant.
> > Besides reset_simple_regmap_assert/deassert(), we also need to have
> > the regmap version of reset_simple_update().
> 
> Yes. You could also duplicate/fold update() into assert/deassert().
> It is trivial enough and the compiler will do that anyway.
> 
> > Since reset_simple_reset() invokes
> > reset_simple_regmap_assert/deassert(), it also needs to be duplicated.
> 
> That one could go through the data->rcdev.ops->assert/deassert function
> pointers and be reused. But I wonder if that one function is worth the added
> complexity.
> 
> > In this case, there will be too many redundant codes in this file. I
> > doubt if it is worth to use the reset simple code. Maybe it's better
> > to fork a new file for the syscon device, such as 'reset-simple-syscon.c'. What
> do you say?
> 
> That sounds sensible to me.
> 

Well. I will go with the approach of a new driver, which avoids all the
unnecessary complexity and redundance. Thank!

> regards
> Philipp
diff mbox series

Patch

diff --git a/drivers/reset/reset-simple.c b/drivers/reset/reset-simple.c
index 276067839830..e4e777d40a79 100644
--- a/drivers/reset/reset-simple.c
+++ b/drivers/reset/reset-simple.c
@@ -15,8 +15,10 @@ 
 #include <linux/device.h>
 #include <linux/err.h>
 #include <linux/io.h>
+#include <linux/mfd/syscon.h>
 #include <linux/of.h>
 #include <linux/platform_device.h>
+#include <linux/regmap.h>
 #include <linux/reset-controller.h>
 #include <linux/reset/reset-simple.h>
 #include <linux/spinlock.h>
@@ -27,10 +29,9 @@  to_reset_simple_data(struct reset_controller_dev *rcdev)
 	return container_of(rcdev, struct reset_simple_data, rcdev);
 }
 
-static int reset_simple_update(struct reset_controller_dev *rcdev,
+static int reset_simple_update_mmio(struct reset_simple_data *data,
 			       unsigned long id, bool assert)
 {
-	struct reset_simple_data *data = to_reset_simple_data(rcdev);
 	int reg_width = sizeof(u32);
 	int bank = id / (reg_width * BITS_PER_BYTE);
 	int offset = id % (reg_width * BITS_PER_BYTE);
@@ -51,16 +52,40 @@  static int reset_simple_update(struct reset_controller_dev *rcdev,
 	return 0;
 }
 
+static int reset_simple_update_regmap(struct reset_simple_data *data,
+				      unsigned long id, bool assert)
+{
+	int reg_width = sizeof(u32);
+	int bank = id / (reg_width * BITS_PER_BYTE);
+	int offset = id % (reg_width * BITS_PER_BYTE);
+	u32 mask, val;
+
+	mask = BIT(offset);
+
+	if (assert ^ data->active_low)
+		val = mask;
+	else
+		val = 0;
+
+	return regmap_write_bits(data->regmap,
+				 data->reg_offset + (bank * reg_width),
+				 mask, val);
+}
+
 static int reset_simple_assert(struct reset_controller_dev *rcdev,
 			       unsigned long id)
 {
-	return reset_simple_update(rcdev, id, true);
+	struct reset_simple_data *data = to_reset_simple_data(rcdev);
+
+	return data->ops.update(data, id, true);
 }
 
 static int reset_simple_deassert(struct reset_controller_dev *rcdev,
 				 unsigned long id)
 {
-	return reset_simple_update(rcdev, id, false);
+	struct reset_simple_data *data = to_reset_simple_data(rcdev);
+
+	return data->ops.update(data, id, false);
 }
 
 static int reset_simple_reset(struct reset_controller_dev *rcdev,
@@ -81,10 +106,9 @@  static int reset_simple_reset(struct reset_controller_dev *rcdev,
 	return reset_simple_deassert(rcdev, id);
 }
 
-static int reset_simple_status(struct reset_controller_dev *rcdev,
-			       unsigned long id)
+static int reset_simple_status_mmio(struct reset_simple_data *data,
+			     unsigned long id)
 {
-	struct reset_simple_data *data = to_reset_simple_data(rcdev);
 	int reg_width = sizeof(u32);
 	int bank = id / (reg_width * BITS_PER_BYTE);
 	int offset = id % (reg_width * BITS_PER_BYTE);
@@ -95,6 +119,31 @@  static int reset_simple_status(struct reset_controller_dev *rcdev,
 	return !(reg & BIT(offset)) ^ !data->status_active_low;
 }
 
+static int reset_simple_status_regmap(struct reset_simple_data *data,
+				    unsigned long id)
+{
+	int reg_width = sizeof(u32);
+	int bank = id / (reg_width * BITS_PER_BYTE);
+	int offset = id % (reg_width * BITS_PER_BYTE);
+	u32 reg;
+	int ret;
+
+	ret = regmap_read(data->regmap, data->reg_offset + (bank * reg_width),
+			  &reg);
+	if (ret)
+		return ret;
+
+	return !(reg & BIT(offset)) ^ !data->status_active_low;
+}
+
+static int reset_simple_status(struct reset_controller_dev *rcdev,
+			       unsigned long id)
+{
+	struct reset_simple_data *data = to_reset_simple_data(rcdev);
+
+	return data->ops.status(data, id);
+}
+
 const struct reset_control_ops reset_simple_ops = {
 	.assert		= reset_simple_assert,
 	.deassert	= reset_simple_deassert,
@@ -118,6 +167,7 @@  struct reset_simple_devdata {
 	u32 nr_resets;
 	bool active_low;
 	bool status_active_low;
+	bool syscon_dev;
 };
 
 #define SOCFPGA_NR_BANKS	8
@@ -171,26 +221,51 @@  static int reset_simple_probe(struct platform_device *pdev)
 	if (!data)
 		return -ENOMEM;
 
-	membase = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
-	if (IS_ERR(membase))
-		return PTR_ERR(membase);
+	if (devdata && devdata->syscon_dev) {
+		data->regmap = syscon_node_to_regmap(pdev->dev.parent->of_node);
+		if (IS_ERR(data->regmap))
+			return PTR_ERR(data->regmap);
 
-	spin_lock_init(&data->lock);
-	data->membase = membase;
-	data->rcdev.owner = THIS_MODULE;
-	data->rcdev.nr_resets = resource_size(res) * BITS_PER_BYTE;
-	data->rcdev.ops = &reset_simple_ops;
-	data->rcdev.of_node = dev->of_node;
+		if (device_property_read_u32(&pdev->dev, "offset",
+					     &data->reg_offset))
+			data->reg_offset = devdata->reg_offset;
 
-	if (devdata) {
-		reg_offset = devdata->reg_offset;
-		if (devdata->nr_resets)
-			data->rcdev.nr_resets = devdata->nr_resets;
+		if (devdata->nr_resets == 0) {
+			dev_err(dev, "no reset line\n");
+			return -EINVAL;
+		}
+
+		data->rcdev.nr_resets = devdata->nr_resets;
 		data->active_low = devdata->active_low;
 		data->status_active_low = devdata->status_active_low;
+
+		data->ops.update = reset_simple_update_regmap;
+		data->ops.status = reset_simple_status_regmap;
+	} else {
+		membase = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
+		if (IS_ERR(membase))
+			return PTR_ERR(membase);
+		data->membase = membase;
+		data->rcdev.nr_resets = resource_size(res) * BITS_PER_BYTE;
+
+		if (devdata) {
+			reg_offset = devdata->reg_offset;
+			if (devdata->nr_resets)
+				data->rcdev.nr_resets = devdata->nr_resets;
+			data->active_low = devdata->active_low;
+			data->status_active_low = devdata->status_active_low;
+		}
+
+		data->membase += reg_offset;
+
+		data->ops.update = reset_simple_update_mmio;
+		data->ops.status = reset_simple_status_mmio;
 	}
 
-	data->membase += reg_offset;
+	spin_lock_init(&data->lock);
+	data->rcdev.owner = THIS_MODULE;
+	data->rcdev.ops = &reset_simple_ops;
+	data->rcdev.of_node = dev->of_node;
 
 	return devm_reset_controller_register(dev, &data->rcdev);
 }
diff --git a/include/linux/reset/reset-simple.h b/include/linux/reset/reset-simple.h
index c3e44f45b0f7..cbcf9e364dd4 100644
--- a/include/linux/reset/reset-simple.h
+++ b/include/linux/reset/reset-simple.h
@@ -13,9 +13,17 @@ 
 #define __RESET_SIMPLE_H__
 
 #include <linux/io.h>
+#include <linux/regmap.h>
 #include <linux/reset-controller.h>
 #include <linux/spinlock.h>
 
+struct reset_simple_data;
+
+struct reset_simple_line_ops {
+	int (*update)(struct reset_simple_data *data, unsigned long id, bool assert);
+	int (*status)(struct reset_simple_data *data, unsigned long id);
+};
+
 /**
  * struct reset_simple_data - driver data for simple reset controllers
  * @lock: spinlock to protect registers during read-modify-write cycles
@@ -37,6 +45,9 @@ 
 struct reset_simple_data {
 	spinlock_t			lock;
 	void __iomem			*membase;
+	struct regmap			*regmap;
+	u32				reg_offset;
+	struct reset_simple_line_ops	ops;
 	struct reset_controller_dev	rcdev;
 	bool				active_low;
 	bool				status_active_low;