Re: [v2,5/6] reset-controller: ti: Introduce force-update method

2020-09-02 Thread Suman Anna
Hi Crystal,

On 8/10/20 1:57 AM, Crystal Guo wrote:
> On Tue, 2020-08-04 at 15:03 +0800, Philipp Zabel wrote:
>> Hi Crystal,
>>
>> On Mon, 2020-08-03 at 14:15 +0800, Crystal Guo wrote:
>>> Introduce force-update method for assert and deassert interface,
>>> which force the write operation in case the read already happens
>>> to return the correct value.
>>>
>>> Signed-off-by: Crystal Guo 
>>
>> Added Suman and Andrew for confirmation: I think writing unconditionally
>> can't break any existing user. Just changing to regmap_write_bits()
>> instead of adding the update-force property as in v1 should be fine.
>>
>> regards
>> Philipp
>>
> Hi Suman, Andrew,
> 
> Can you help to give some suggestions about this change.
> Is this can be changed to write unconditionally, or should I add a
> update-force property to force the write operation.

Sorry for the delay on this one, I have tested your latest v4, and everything is
functional on the TI SoCs. We do use the same register for asserting and
deasserting and is not self-clearing, and have additional non-reset related bits
in the register, so this change doesn't impact us. I have some minor
comments/questions that I will post on your v4.

Removing Andrew to not have the emails bounce.

regards
Suman

> 
> Best regards
> Crystal.
> 
>>> ---
>>>  drivers/reset/reset-ti-syscon.c | 15 +--
>>>  1 file changed, 13 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/reset/reset-ti-syscon.c 
>>> b/drivers/reset/reset-ti-syscon.c
>>> index 1c74bcb9a6c3..f4baf78afd14 100644
>>> --- a/drivers/reset/reset-ti-syscon.c
>>> +++ b/drivers/reset/reset-ti-syscon.c
>>> @@ -57,6 +57,7 @@ struct ti_syscon_reset_data {
>>> struct ti_syscon_reset_control *controls;
>>> unsigned int nr_controls;
>>> bool assert_deassert_together;
>>> +   bool update_force;
>>>  };
>>>  
>>>  #define to_ti_syscon_reset_data(rcdev) \
>>> @@ -90,7 +91,10 @@ static int ti_syscon_reset_assert(struct 
>>> reset_controller_dev *rcdev,
>>> mask = BIT(control->assert_bit);
>>> value = (control->flags & ASSERT_SET) ? mask : 0x0;
>>>  
>>> -   return regmap_update_bits(data->regmap, control->assert_offset, mask, 
>>> value);
>>> +   if (data->update_force)
>>> +   return regmap_write_bits(data->regmap, control->assert_offset, 
>>> mask, value);
>>> +   else
>>> +   return regmap_update_bits(data->regmap, control->assert_offset, 
>>> mask, value);
>>>  }
>>>  
>>>  /**
>>> @@ -121,7 +125,10 @@ static int ti_syscon_reset_deassert(struct 
>>> reset_controller_dev *rcdev,
>>> mask = BIT(control->deassert_bit);
>>> value = (control->flags & DEASSERT_SET) ? mask : 0x0;
>>>  
>>> -   return regmap_update_bits(data->regmap, control->deassert_offset, mask, 
>>> value);
>>> +   if (data->update_force)
>>> +   return regmap_write_bits(data->regmap, 
>>> control->deassert_offset, mask, value);
>>> +   else
>>> +   return regmap_update_bits(data->regmap, 
>>> control->deassert_offset, mask, value);
>>>  }
>>>  
>>>  /**
>>> @@ -223,6 +230,10 @@ static int ti_syscon_reset_probe(struct 
>>> platform_device *pdev)
>>> data->assert_deassert_together = true;
>>> else
>>> data->assert_deassert_together = false;
>>> +   if (of_property_read_bool(np, "update-force"))
>>> +   data->update_force = true;
>>> +   else
>>> +   data->update_force = false;
>>>  
>>> data->rcdev.ops = _syscon_reset_ops;
>>> data->rcdev.owner = THIS_MODULE;
>>> -- 
>>> 2.18.0
> 



Re: [v2,5/6] reset-controller: ti: Introduce force-update method

2020-08-10 Thread Crystal Guo
On Tue, 2020-08-04 at 15:03 +0800, Philipp Zabel wrote:
> Hi Crystal,
> 
> On Mon, 2020-08-03 at 14:15 +0800, Crystal Guo wrote:
> > Introduce force-update method for assert and deassert interface,
> > which force the write operation in case the read already happens
> > to return the correct value.
> > 
> > Signed-off-by: Crystal Guo 
> 
> Added Suman and Andrew for confirmation: I think writing unconditionally
> can't break any existing user. Just changing to regmap_write_bits()
> instead of adding the update-force property as in v1 should be fine.
> 
> regards
> Philipp
> 
Hi Suman, Andrew,

Can you help to give some suggestions about this change.
Is this can be changed to write unconditionally, or should I add a
update-force property to force the write operation.

Best regards
Crystal.

> > ---
> >  drivers/reset/reset-ti-syscon.c | 15 +--
> >  1 file changed, 13 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/reset/reset-ti-syscon.c 
> > b/drivers/reset/reset-ti-syscon.c
> > index 1c74bcb9a6c3..f4baf78afd14 100644
> > --- a/drivers/reset/reset-ti-syscon.c
> > +++ b/drivers/reset/reset-ti-syscon.c
> > @@ -57,6 +57,7 @@ struct ti_syscon_reset_data {
> > struct ti_syscon_reset_control *controls;
> > unsigned int nr_controls;
> > bool assert_deassert_together;
> > +   bool update_force;
> >  };
> >  
> >  #define to_ti_syscon_reset_data(rcdev) \
> > @@ -90,7 +91,10 @@ static int ti_syscon_reset_assert(struct 
> > reset_controller_dev *rcdev,
> > mask = BIT(control->assert_bit);
> > value = (control->flags & ASSERT_SET) ? mask : 0x0;
> >  
> > -   return regmap_update_bits(data->regmap, control->assert_offset, mask, 
> > value);
> > +   if (data->update_force)
> > +   return regmap_write_bits(data->regmap, control->assert_offset, 
> > mask, value);
> > +   else
> > +   return regmap_update_bits(data->regmap, control->assert_offset, 
> > mask, value);
> >  }
> >  
> >  /**
> > @@ -121,7 +125,10 @@ static int ti_syscon_reset_deassert(struct 
> > reset_controller_dev *rcdev,
> > mask = BIT(control->deassert_bit);
> > value = (control->flags & DEASSERT_SET) ? mask : 0x0;
> >  
> > -   return regmap_update_bits(data->regmap, control->deassert_offset, mask, 
> > value);
> > +   if (data->update_force)
> > +   return regmap_write_bits(data->regmap, 
> > control->deassert_offset, mask, value);
> > +   else
> > +   return regmap_update_bits(data->regmap, 
> > control->deassert_offset, mask, value);
> >  }
> >  
> >  /**
> > @@ -223,6 +230,10 @@ static int ti_syscon_reset_probe(struct 
> > platform_device *pdev)
> > data->assert_deassert_together = true;
> > else
> > data->assert_deassert_together = false;
> > +   if (of_property_read_bool(np, "update-force"))
> > +   data->update_force = true;
> > +   else
> > +   data->update_force = false;
> >  
> > data->rcdev.ops = _syscon_reset_ops;
> > data->rcdev.owner = THIS_MODULE;
> > -- 
> > 2.18.0



Re: [v2,5/6] reset-controller: ti: Introduce force-update method

2020-08-04 Thread Yingjoe Chen
On Mon, 2020-08-03 at 14:15 +0800, Crystal Guo wrote:
> Introduce force-update method for assert and deassert interface,
> which force the write operation in case the read already happens
> to return the correct value.
> 
> Signed-off-by: Crystal Guo 
> ---
>  drivers/reset/reset-ti-syscon.c | 15 +--
>  1 file changed, 13 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/reset/reset-ti-syscon.c b/drivers/reset/reset-ti-syscon.c
> index 1c74bcb9a6c3..f4baf78afd14 100644
> --- a/drivers/reset/reset-ti-syscon.c
> +++ b/drivers/reset/reset-ti-syscon.c
> @@ -57,6 +57,7 @@ struct ti_syscon_reset_data {
>   struct ti_syscon_reset_control *controls;
>   unsigned int nr_controls;
>   bool assert_deassert_together;
> + bool update_force;
>  };
>  
>  #define to_ti_syscon_reset_data(rcdev)   \
> @@ -90,7 +91,10 @@ static int ti_syscon_reset_assert(struct 
> reset_controller_dev *rcdev,
>   mask = BIT(control->assert_bit);
>   value = (control->flags & ASSERT_SET) ? mask : 0x0;
>  
> - return regmap_update_bits(data->regmap, control->assert_offset, mask, 
> value);
> + if (data->update_force)
> + return regmap_write_bits(data->regmap, control->assert_offset, 
> mask, value);
> + else
> + return regmap_update_bits(data->regmap, control->assert_offset, 
> mask, value);
>  }
>  
>  /**
> @@ -121,7 +125,10 @@ static int ti_syscon_reset_deassert(struct 
> reset_controller_dev *rcdev,
>   mask = BIT(control->deassert_bit);
>   value = (control->flags & DEASSERT_SET) ? mask : 0x0;
>  
> - return regmap_update_bits(data->regmap, control->deassert_offset, mask, 
> value);
> + if (data->update_force)
> + return regmap_write_bits(data->regmap, 
> control->deassert_offset, mask, value);
> + else
> + return regmap_update_bits(data->regmap, 
> control->deassert_offset, mask, value);
>  }
>  
>  /**
> @@ -223,6 +230,10 @@ static int ti_syscon_reset_probe(struct platform_device 
> *pdev)
>   data->assert_deassert_together = true;
>   else
>   data->assert_deassert_together = false;
> + if (of_property_read_bool(np, "update-force"))
> + data->update_force = true;
> + else
> + data->update_force = false;

You are using 'force-update' in commit message, and I think that a
better one.
Please change it if we still need this one

Joe.C


Re: [v2,5/6] reset-controller: ti: Introduce force-update method

2020-08-04 Thread Philipp Zabel
Hi Crystal,

On Mon, 2020-08-03 at 14:15 +0800, Crystal Guo wrote:
> Introduce force-update method for assert and deassert interface,
> which force the write operation in case the read already happens
> to return the correct value.
> 
> Signed-off-by: Crystal Guo 

Added Suman and Andrew for confirmation: I think writing unconditionally
can't break any existing user. Just changing to regmap_write_bits()
instead of adding the update-force property as in v1 should be fine.

regards
Philipp

> ---
>  drivers/reset/reset-ti-syscon.c | 15 +--
>  1 file changed, 13 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/reset/reset-ti-syscon.c b/drivers/reset/reset-ti-syscon.c
> index 1c74bcb9a6c3..f4baf78afd14 100644
> --- a/drivers/reset/reset-ti-syscon.c
> +++ b/drivers/reset/reset-ti-syscon.c
> @@ -57,6 +57,7 @@ struct ti_syscon_reset_data {
>   struct ti_syscon_reset_control *controls;
>   unsigned int nr_controls;
>   bool assert_deassert_together;
> + bool update_force;
>  };
>  
>  #define to_ti_syscon_reset_data(rcdev)   \
> @@ -90,7 +91,10 @@ static int ti_syscon_reset_assert(struct 
> reset_controller_dev *rcdev,
>   mask = BIT(control->assert_bit);
>   value = (control->flags & ASSERT_SET) ? mask : 0x0;
>  
> - return regmap_update_bits(data->regmap, control->assert_offset, mask, 
> value);
> + if (data->update_force)
> + return regmap_write_bits(data->regmap, control->assert_offset, 
> mask, value);
> + else
> + return regmap_update_bits(data->regmap, control->assert_offset, 
> mask, value);
>  }
>  
>  /**
> @@ -121,7 +125,10 @@ static int ti_syscon_reset_deassert(struct 
> reset_controller_dev *rcdev,
>   mask = BIT(control->deassert_bit);
>   value = (control->flags & DEASSERT_SET) ? mask : 0x0;
>  
> - return regmap_update_bits(data->regmap, control->deassert_offset, mask, 
> value);
> + if (data->update_force)
> + return regmap_write_bits(data->regmap, 
> control->deassert_offset, mask, value);
> + else
> + return regmap_update_bits(data->regmap, 
> control->deassert_offset, mask, value);
>  }
>  
>  /**
> @@ -223,6 +230,10 @@ static int ti_syscon_reset_probe(struct platform_device 
> *pdev)
>   data->assert_deassert_together = true;
>   else
>   data->assert_deassert_together = false;
> + if (of_property_read_bool(np, "update-force"))
> + data->update_force = true;
> + else
> + data->update_force = false;
>  
>   data->rcdev.ops = _syscon_reset_ops;
>   data->rcdev.owner = THIS_MODULE;
> -- 
> 2.18.0


Re: [v2,5/6] reset-controller: ti: Introduce force-update method

2020-08-03 Thread Stanley Chu
On Mon, 2020-08-03 at 14:15 +0800, Crystal Guo wrote:
> Introduce force-update method for assert and deassert interface,
> which force the write operation in case the read already happens
> to return the correct value.
> 
> Signed-off-by: Crystal Guo 
> ---
>  drivers/reset/reset-ti-syscon.c | 15 +--
>  1 file changed, 13 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/reset/reset-ti-syscon.c b/drivers/reset/reset-ti-syscon.c
> index 1c74bcb9a6c3..f4baf78afd14 100644
> --- a/drivers/reset/reset-ti-syscon.c
> +++ b/drivers/reset/reset-ti-syscon.c
> @@ -57,6 +57,7 @@ struct ti_syscon_reset_data {
>   struct ti_syscon_reset_control *controls;
>   unsigned int nr_controls;
>   bool assert_deassert_together;
> + bool update_force;
>  };
>  
>  #define to_ti_syscon_reset_data(rcdev)   \
> @@ -90,7 +91,10 @@ static int ti_syscon_reset_assert(struct 
> reset_controller_dev *rcdev,
>   mask = BIT(control->assert_bit);
>   value = (control->flags & ASSERT_SET) ? mask : 0x0;
>  
> - return regmap_update_bits(data->regmap, control->assert_offset, mask, 
> value);
> + if (data->update_force)
> + return regmap_write_bits(data->regmap, control->assert_offset, 
> mask, value);
> + else
> + return regmap_update_bits(data->regmap, control->assert_offset, 
> mask, value);
>  }
>  
>  /**
> @@ -121,7 +125,10 @@ static int ti_syscon_reset_deassert(struct 
> reset_controller_dev *rcdev,
>   mask = BIT(control->deassert_bit);
>   value = (control->flags & DEASSERT_SET) ? mask : 0x0;
>  
> - return regmap_update_bits(data->regmap, control->deassert_offset, mask, 
> value);
> + if (data->update_force)
> + return regmap_write_bits(data->regmap, 
> control->deassert_offset, mask, value);
> + else
> + return regmap_update_bits(data->regmap, 
> control->deassert_offset, mask, value);
>  }
>  
>  /**
> @@ -223,6 +230,10 @@ static int ti_syscon_reset_probe(struct platform_device 
> *pdev)
>   data->assert_deassert_together = true;
>   else
>   data->assert_deassert_together = false;
> + if (of_property_read_bool(np, "update-force"))
> + data->update_force = true;
> + else
> + data->update_force = false;
>  
>   data->rcdev.ops = _syscon_reset_ops;
>   data->rcdev.owner = THIS_MODULE;

This patch is good to help MediaTek drivers' transition to use
ti-syscon-reset-controller, also not have side effect to existed users.

Acked-by: Stanley Chu 




[v2,5/6] reset-controller: ti: Introduce force-update method

2020-08-03 Thread Crystal Guo
Introduce force-update method for assert and deassert interface,
which force the write operation in case the read already happens
to return the correct value.

Signed-off-by: Crystal Guo 
---
 drivers/reset/reset-ti-syscon.c | 15 +--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/reset/reset-ti-syscon.c b/drivers/reset/reset-ti-syscon.c
index 1c74bcb9a6c3..f4baf78afd14 100644
--- a/drivers/reset/reset-ti-syscon.c
+++ b/drivers/reset/reset-ti-syscon.c
@@ -57,6 +57,7 @@ struct ti_syscon_reset_data {
struct ti_syscon_reset_control *controls;
unsigned int nr_controls;
bool assert_deassert_together;
+   bool update_force;
 };
 
 #define to_ti_syscon_reset_data(rcdev) \
@@ -90,7 +91,10 @@ static int ti_syscon_reset_assert(struct 
reset_controller_dev *rcdev,
mask = BIT(control->assert_bit);
value = (control->flags & ASSERT_SET) ? mask : 0x0;
 
-   return regmap_update_bits(data->regmap, control->assert_offset, mask, 
value);
+   if (data->update_force)
+   return regmap_write_bits(data->regmap, control->assert_offset, 
mask, value);
+   else
+   return regmap_update_bits(data->regmap, control->assert_offset, 
mask, value);
 }
 
 /**
@@ -121,7 +125,10 @@ static int ti_syscon_reset_deassert(struct 
reset_controller_dev *rcdev,
mask = BIT(control->deassert_bit);
value = (control->flags & DEASSERT_SET) ? mask : 0x0;
 
-   return regmap_update_bits(data->regmap, control->deassert_offset, mask, 
value);
+   if (data->update_force)
+   return regmap_write_bits(data->regmap, 
control->deassert_offset, mask, value);
+   else
+   return regmap_update_bits(data->regmap, 
control->deassert_offset, mask, value);
 }
 
 /**
@@ -223,6 +230,10 @@ static int ti_syscon_reset_probe(struct platform_device 
*pdev)
data->assert_deassert_together = true;
else
data->assert_deassert_together = false;
+   if (of_property_read_bool(np, "update-force"))
+   data->update_force = true;
+   else
+   data->update_force = false;
 
data->rcdev.ops = _syscon_reset_ops;
data->rcdev.owner = THIS_MODULE;
-- 
2.18.0