Re: [PATCH v2] i2c: aspeed: Deassert reset in probe

2017-10-29 Thread Joel Stanley
On Fri, Oct 27, 2017 at 7:23 AM, Wolfram Sang  wrote:
>> > +   bus->rst = devm_reset_control_get_optional_shared(>dev, 
>> > NULL);
>>
>> This could return error values in case of broken device trees, so you
>> may want to check IS_ERR(bus->rst) and handle the error here.

>From my understanding the optional variant of the API will set
silently fail. That was my intention - an outdated device tree would
result in the same behaviour as the old driver.

>>
>> > +   reset_control_deassert(bus->rst);
>>
>> Otherwise this will dump a warning.
>>
>> > +
>> > ret = of_property_read_u32(pdev->dev.of_node,
>> >"bus-frequency", >bus_frequency);
>> > if (ret < 0) {
>> > @@ -919,6 +925,8 @@ static int aspeed_i2c_remove_bus(struct 
>> > platform_device *pdev)
>> >
>> > i2c_del_adapter(>adap);
>> >
>> > +   reset_control_assert(bus->rst);
>>
>> As will this.
>>
>> Reviewed-by: Philipp Zabel 
>
> Joel, do you want to fix it? I'd think it makes sense...

Sorry, I've been on vacation. I thought the _optional variant of the
API would do the right thing for my use case (silently fail on old
device trees), but I'll add a check.

v3 incoming.

Cheers,

Joel


Re: [PATCH v2] i2c: aspeed: Deassert reset in probe

2017-10-29 Thread Joel Stanley
On Fri, Oct 27, 2017 at 7:23 AM, Wolfram Sang  wrote:
>> > +   bus->rst = devm_reset_control_get_optional_shared(>dev, 
>> > NULL);
>>
>> This could return error values in case of broken device trees, so you
>> may want to check IS_ERR(bus->rst) and handle the error here.

>From my understanding the optional variant of the API will set
silently fail. That was my intention - an outdated device tree would
result in the same behaviour as the old driver.

>>
>> > +   reset_control_deassert(bus->rst);
>>
>> Otherwise this will dump a warning.
>>
>> > +
>> > ret = of_property_read_u32(pdev->dev.of_node,
>> >"bus-frequency", >bus_frequency);
>> > if (ret < 0) {
>> > @@ -919,6 +925,8 @@ static int aspeed_i2c_remove_bus(struct 
>> > platform_device *pdev)
>> >
>> > i2c_del_adapter(>adap);
>> >
>> > +   reset_control_assert(bus->rst);
>>
>> As will this.
>>
>> Reviewed-by: Philipp Zabel 
>
> Joel, do you want to fix it? I'd think it makes sense...

Sorry, I've been on vacation. I thought the _optional variant of the
API would do the right thing for my use case (silently fail on old
device trees), but I'll add a check.

v3 incoming.

Cheers,

Joel


Re: [PATCH v2] i2c: aspeed: Deassert reset in probe

2017-10-26 Thread Wolfram Sang
> > +   bus->rst = devm_reset_control_get_optional_shared(>dev, NULL);
> 
> This could return error values in case of broken device trees, so you
> may want to check IS_ERR(bus->rst) and handle the error here.
> 
> > +   reset_control_deassert(bus->rst);
> 
> Otherwise this will dump a warning.
> 
> > +
> > ret = of_property_read_u32(pdev->dev.of_node,
> >"bus-frequency", >bus_frequency);
> > if (ret < 0) {
> > @@ -919,6 +925,8 @@ static int aspeed_i2c_remove_bus(struct platform_device 
> > *pdev)
> >
> > i2c_del_adapter(>adap);
> >
> > +   reset_control_assert(bus->rst);
> 
> As will this.
> 
> Reviewed-by: Philipp Zabel 

Joel, do you want to fix it? I'd think it makes sense...



signature.asc
Description: PGP signature


Re: [PATCH v2] i2c: aspeed: Deassert reset in probe

2017-10-26 Thread Wolfram Sang
> > +   bus->rst = devm_reset_control_get_optional_shared(>dev, NULL);
> 
> This could return error values in case of broken device trees, so you
> may want to check IS_ERR(bus->rst) and handle the error here.
> 
> > +   reset_control_deassert(bus->rst);
> 
> Otherwise this will dump a warning.
> 
> > +
> > ret = of_property_read_u32(pdev->dev.of_node,
> >"bus-frequency", >bus_frequency);
> > if (ret < 0) {
> > @@ -919,6 +925,8 @@ static int aspeed_i2c_remove_bus(struct platform_device 
> > *pdev)
> >
> > i2c_del_adapter(>adap);
> >
> > +   reset_control_assert(bus->rst);
> 
> As will this.
> 
> Reviewed-by: Philipp Zabel 

Joel, do you want to fix it? I'd think it makes sense...



signature.asc
Description: PGP signature


Re: [PATCH v2] i2c: aspeed: Deassert reset in probe

2017-10-18 Thread Philipp Zabel
On Wed, Oct 18, 2017 at 4:29 PM, Joel Stanley  wrote:
> In order to use i2c from a cold boot, the i2c peripheral must be taken
> out of reset. We request a shared reset controller each time a bus
> driver is loaded, as the reset is shared between the 14 i2c buses.
>
> On remove the reset is asserted, which only touches the hardware once
> the last i2c bus is removed.
>
> The request is optional, so if a device tree does not specify a reset
> controller (or the driver is not built in), the driver continues to
> probe.
>
> Signed-off-by: Joel Stanley 
> ---
> v2: Sort the headers
>
>  drivers/i2c/busses/i2c-aspeed.c | 8 
>  1 file changed, 8 insertions(+)
>
> diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c
> index 284f8670dbeb..a2006376322f 100644
> --- a/drivers/i2c/busses/i2c-aspeed.c
> +++ b/drivers/i2c/busses/i2c-aspeed.c
> @@ -12,6 +12,7 @@
>
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -27,6 +28,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>
>  /* I2C Register */
> @@ -132,6 +134,7 @@ struct aspeed_i2c_bus {
> struct i2c_adapter  adap;
> struct device   *dev;
> void __iomem*base;
> +   struct reset_control*rst;
> /* Synchronizes I/O mem access to base. */
> spinlock_t  lock;
> struct completion   cmd_complete;
> @@ -847,6 +850,9 @@ static int aspeed_i2c_probe_bus(struct platform_device 
> *pdev)
> /* We just need the clock rate, we don't actually use the clk object. 
> */
> devm_clk_put(>dev, parent_clk);
>
> +   bus->rst = devm_reset_control_get_optional_shared(>dev, NULL);

This could return error values in case of broken device trees, so you
may want to check IS_ERR(bus->rst) and handle the error here.

> +   reset_control_deassert(bus->rst);

Otherwise this will dump a warning.

> +
> ret = of_property_read_u32(pdev->dev.of_node,
>"bus-frequency", >bus_frequency);
> if (ret < 0) {
> @@ -919,6 +925,8 @@ static int aspeed_i2c_remove_bus(struct platform_device 
> *pdev)
>
> i2c_del_adapter(>adap);
>
> +   reset_control_assert(bus->rst);

As will this.

Reviewed-by: Philipp Zabel 

regards
Philipp


Re: [PATCH v2] i2c: aspeed: Deassert reset in probe

2017-10-18 Thread Philipp Zabel
On Wed, Oct 18, 2017 at 4:29 PM, Joel Stanley  wrote:
> In order to use i2c from a cold boot, the i2c peripheral must be taken
> out of reset. We request a shared reset controller each time a bus
> driver is loaded, as the reset is shared between the 14 i2c buses.
>
> On remove the reset is asserted, which only touches the hardware once
> the last i2c bus is removed.
>
> The request is optional, so if a device tree does not specify a reset
> controller (or the driver is not built in), the driver continues to
> probe.
>
> Signed-off-by: Joel Stanley 
> ---
> v2: Sort the headers
>
>  drivers/i2c/busses/i2c-aspeed.c | 8 
>  1 file changed, 8 insertions(+)
>
> diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c
> index 284f8670dbeb..a2006376322f 100644
> --- a/drivers/i2c/busses/i2c-aspeed.c
> +++ b/drivers/i2c/busses/i2c-aspeed.c
> @@ -12,6 +12,7 @@
>
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -27,6 +28,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>
>  /* I2C Register */
> @@ -132,6 +134,7 @@ struct aspeed_i2c_bus {
> struct i2c_adapter  adap;
> struct device   *dev;
> void __iomem*base;
> +   struct reset_control*rst;
> /* Synchronizes I/O mem access to base. */
> spinlock_t  lock;
> struct completion   cmd_complete;
> @@ -847,6 +850,9 @@ static int aspeed_i2c_probe_bus(struct platform_device 
> *pdev)
> /* We just need the clock rate, we don't actually use the clk object. 
> */
> devm_clk_put(>dev, parent_clk);
>
> +   bus->rst = devm_reset_control_get_optional_shared(>dev, NULL);

This could return error values in case of broken device trees, so you
may want to check IS_ERR(bus->rst) and handle the error here.

> +   reset_control_deassert(bus->rst);

Otherwise this will dump a warning.

> +
> ret = of_property_read_u32(pdev->dev.of_node,
>"bus-frequency", >bus_frequency);
> if (ret < 0) {
> @@ -919,6 +925,8 @@ static int aspeed_i2c_remove_bus(struct platform_device 
> *pdev)
>
> i2c_del_adapter(>adap);
>
> +   reset_control_assert(bus->rst);

As will this.

Reviewed-by: Philipp Zabel 

regards
Philipp


Re: [PATCH v2] i2c: aspeed: Deassert reset in probe

2017-10-18 Thread Brendan Higgins
On Wed, Oct 18, 2017 at 7:29 AM, Joel Stanley  wrote:
> In order to use i2c from a cold boot, the i2c peripheral must be taken
> out of reset. We request a shared reset controller each time a bus
> driver is loaded, as the reset is shared between the 14 i2c buses.
>
> On remove the reset is asserted, which only touches the hardware once
> the last i2c bus is removed.
>
> The request is optional, so if a device tree does not specify a reset
> controller (or the driver is not built in), the driver continues to
> probe.
>
> Signed-off-by: Joel Stanley 
> ---
> v2: Sort the headers
>
>  drivers/i2c/busses/i2c-aspeed.c | 8 
>  1 file changed, 8 insertions(+)
>
> diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c
> index 284f8670dbeb..a2006376322f 100644
> --- a/drivers/i2c/busses/i2c-aspeed.c
> +++ b/drivers/i2c/busses/i2c-aspeed.c
> @@ -12,6 +12,7 @@
>
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -27,6 +28,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>
>  /* I2C Register */
> @@ -132,6 +134,7 @@ struct aspeed_i2c_bus {
> struct i2c_adapter  adap;
> struct device   *dev;
> void __iomem*base;
> +   struct reset_control*rst;
> /* Synchronizes I/O mem access to base. */
> spinlock_t  lock;
> struct completion   cmd_complete;
> @@ -847,6 +850,9 @@ static int aspeed_i2c_probe_bus(struct platform_device 
> *pdev)
> /* We just need the clock rate, we don't actually use the clk object. 
> */
> devm_clk_put(>dev, parent_clk);
>
> +   bus->rst = devm_reset_control_get_optional_shared(>dev, NULL);
> +   reset_control_deassert(bus->rst);
> +
> ret = of_property_read_u32(pdev->dev.of_node,
>"bus-frequency", >bus_frequency);
> if (ret < 0) {
> @@ -919,6 +925,8 @@ static int aspeed_i2c_remove_bus(struct platform_device 
> *pdev)
>
> i2c_del_adapter(>adap);
>
> +   reset_control_assert(bus->rst);
> +
> return 0;
>  }
>
> --
> 2.14.1
>
Reviewed-by: Brendan Higgins 


Re: [PATCH v2] i2c: aspeed: Deassert reset in probe

2017-10-18 Thread Brendan Higgins
On Wed, Oct 18, 2017 at 7:29 AM, Joel Stanley  wrote:
> In order to use i2c from a cold boot, the i2c peripheral must be taken
> out of reset. We request a shared reset controller each time a bus
> driver is loaded, as the reset is shared between the 14 i2c buses.
>
> On remove the reset is asserted, which only touches the hardware once
> the last i2c bus is removed.
>
> The request is optional, so if a device tree does not specify a reset
> controller (or the driver is not built in), the driver continues to
> probe.
>
> Signed-off-by: Joel Stanley 
> ---
> v2: Sort the headers
>
>  drivers/i2c/busses/i2c-aspeed.c | 8 
>  1 file changed, 8 insertions(+)
>
> diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c
> index 284f8670dbeb..a2006376322f 100644
> --- a/drivers/i2c/busses/i2c-aspeed.c
> +++ b/drivers/i2c/busses/i2c-aspeed.c
> @@ -12,6 +12,7 @@
>
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -27,6 +28,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>
>  /* I2C Register */
> @@ -132,6 +134,7 @@ struct aspeed_i2c_bus {
> struct i2c_adapter  adap;
> struct device   *dev;
> void __iomem*base;
> +   struct reset_control*rst;
> /* Synchronizes I/O mem access to base. */
> spinlock_t  lock;
> struct completion   cmd_complete;
> @@ -847,6 +850,9 @@ static int aspeed_i2c_probe_bus(struct platform_device 
> *pdev)
> /* We just need the clock rate, we don't actually use the clk object. 
> */
> devm_clk_put(>dev, parent_clk);
>
> +   bus->rst = devm_reset_control_get_optional_shared(>dev, NULL);
> +   reset_control_deassert(bus->rst);
> +
> ret = of_property_read_u32(pdev->dev.of_node,
>"bus-frequency", >bus_frequency);
> if (ret < 0) {
> @@ -919,6 +925,8 @@ static int aspeed_i2c_remove_bus(struct platform_device 
> *pdev)
>
> i2c_del_adapter(>adap);
>
> +   reset_control_assert(bus->rst);
> +
> return 0;
>  }
>
> --
> 2.14.1
>
Reviewed-by: Brendan Higgins 


[PATCH v2] i2c: aspeed: Deassert reset in probe

2017-10-18 Thread Joel Stanley
In order to use i2c from a cold boot, the i2c peripheral must be taken
out of reset. We request a shared reset controller each time a bus
driver is loaded, as the reset is shared between the 14 i2c buses.

On remove the reset is asserted, which only touches the hardware once
the last i2c bus is removed.

The request is optional, so if a device tree does not specify a reset
controller (or the driver is not built in), the driver continues to
probe.

Signed-off-by: Joel Stanley 
---
v2: Sort the headers

 drivers/i2c/busses/i2c-aspeed.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c
index 284f8670dbeb..a2006376322f 100644
--- a/drivers/i2c/busses/i2c-aspeed.c
+++ b/drivers/i2c/busses/i2c-aspeed.c
@@ -12,6 +12,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -27,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 /* I2C Register */
@@ -132,6 +134,7 @@ struct aspeed_i2c_bus {
struct i2c_adapter  adap;
struct device   *dev;
void __iomem*base;
+   struct reset_control*rst;
/* Synchronizes I/O mem access to base. */
spinlock_t  lock;
struct completion   cmd_complete;
@@ -847,6 +850,9 @@ static int aspeed_i2c_probe_bus(struct platform_device 
*pdev)
/* We just need the clock rate, we don't actually use the clk object. */
devm_clk_put(>dev, parent_clk);
 
+   bus->rst = devm_reset_control_get_optional_shared(>dev, NULL);
+   reset_control_deassert(bus->rst);
+
ret = of_property_read_u32(pdev->dev.of_node,
   "bus-frequency", >bus_frequency);
if (ret < 0) {
@@ -919,6 +925,8 @@ static int aspeed_i2c_remove_bus(struct platform_device 
*pdev)
 
i2c_del_adapter(>adap);
 
+   reset_control_assert(bus->rst);
+
return 0;
 }
 
-- 
2.14.1



[PATCH v2] i2c: aspeed: Deassert reset in probe

2017-10-18 Thread Joel Stanley
In order to use i2c from a cold boot, the i2c peripheral must be taken
out of reset. We request a shared reset controller each time a bus
driver is loaded, as the reset is shared between the 14 i2c buses.

On remove the reset is asserted, which only touches the hardware once
the last i2c bus is removed.

The request is optional, so if a device tree does not specify a reset
controller (or the driver is not built in), the driver continues to
probe.

Signed-off-by: Joel Stanley 
---
v2: Sort the headers

 drivers/i2c/busses/i2c-aspeed.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c
index 284f8670dbeb..a2006376322f 100644
--- a/drivers/i2c/busses/i2c-aspeed.c
+++ b/drivers/i2c/busses/i2c-aspeed.c
@@ -12,6 +12,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -27,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 /* I2C Register */
@@ -132,6 +134,7 @@ struct aspeed_i2c_bus {
struct i2c_adapter  adap;
struct device   *dev;
void __iomem*base;
+   struct reset_control*rst;
/* Synchronizes I/O mem access to base. */
spinlock_t  lock;
struct completion   cmd_complete;
@@ -847,6 +850,9 @@ static int aspeed_i2c_probe_bus(struct platform_device 
*pdev)
/* We just need the clock rate, we don't actually use the clk object. */
devm_clk_put(>dev, parent_clk);
 
+   bus->rst = devm_reset_control_get_optional_shared(>dev, NULL);
+   reset_control_deassert(bus->rst);
+
ret = of_property_read_u32(pdev->dev.of_node,
   "bus-frequency", >bus_frequency);
if (ret < 0) {
@@ -919,6 +925,8 @@ static int aspeed_i2c_remove_bus(struct platform_device 
*pdev)
 
i2c_del_adapter(>adap);
 
+   reset_control_assert(bus->rst);
+
return 0;
 }
 
-- 
2.14.1