* [PATCH 1/2] i2c: cadence: Fix the Documentation
@ 2016-03-01 6:32 Shubhrajyoti Datta
2016-03-01 6:32 ` [PATCH 2/2] i2c: cadence: Implement save restore Shubhrajyoti Datta
2016-03-01 7:33 ` [PATCH 1/2] i2c: cadence: Fix the Documentation Michal Simek
0 siblings, 2 replies; 6+ messages in thread
From: Shubhrajyoti Datta @ 2016-03-01 6:32 UTC (permalink / raw)
To: linux-i2c; +Cc: soren.brinkmann, michal.simek, wsa, Shubhrajyoti Datta
The runtime adaptation patch missed the documentation update.
This fixes the same.
No functional change.
Signed-off-by: Shubhrajyoti Datta <shubhraj@xilinx.com>
---
drivers/i2c/busses/i2c-cadence.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c
index 6b08d16..a761520 100644
--- a/drivers/i2c/busses/i2c-cadence.c
+++ b/drivers/i2c/busses/i2c-cadence.c
@@ -815,7 +815,7 @@ static int cdns_i2c_clk_notifier_cb(struct notifier_block *nb, unsigned long
}
/**
- * cdns_i2c_suspend - Suspend method for the driver
+ * cdns_i2c_runtime_suspend - Runtime suspend method for the driver
* @_dev: Address of the platform_device structure
*
* Put the driver into low power mode.
@@ -833,7 +833,7 @@ static int __maybe_unused cdns_i2c_runtime_suspend(struct device *dev)
}
/**
- * cdns_i2c_resume - Resume from suspend
+ * cdns_i2c_runtime_resume - Runtime resume
* @_dev: Address of the platform_device structure
*
* Resume operation after suspend.
--
1.7.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] i2c: cadence: Implement save restore
2016-03-01 6:32 [PATCH 1/2] i2c: cadence: Fix the Documentation Shubhrajyoti Datta
@ 2016-03-01 6:32 ` Shubhrajyoti Datta
2016-03-01 7:34 ` Michal Simek
2016-03-01 7:33 ` [PATCH 1/2] i2c: cadence: Fix the Documentation Michal Simek
1 sibling, 1 reply; 6+ messages in thread
From: Shubhrajyoti Datta @ 2016-03-01 6:32 UTC (permalink / raw)
To: linux-i2c; +Cc: soren.brinkmann, michal.simek, wsa, Shubhrajyoti Datta
Implement save restore for i2c module.
Since we have only a couple of registers
an unconditional restore is done.
Signed-off-by: Shubhrajyoti Datta <shubhraj@xilinx.com>
---
zynq-mp has the capability of going off.
the current kernel does not hit off however some day it will.
since the overhead of having the support is not much may be it is better
to have it in the kernel.
drivers/i2c/busses/i2c-cadence.c | 32 ++++++++++++++++++--------------
1 files changed, 18 insertions(+), 14 deletions(-)
diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c
index a761520..3d50914 100644
--- a/drivers/i2c/busses/i2c-cadence.c
+++ b/drivers/i2c/busses/i2c-cadence.c
@@ -161,6 +161,7 @@ struct cdns_i2c {
struct clk *clk;
struct notifier_block clk_rate_change_nb;
u32 quirks;
+ u32 ctrl_reg;
};
struct cdns_platform_data {
@@ -743,12 +744,11 @@ static int cdns_i2c_setclk(unsigned long clk_in, struct cdns_i2c *id)
if (ret)
return ret;
- ctrl_reg = cdns_i2c_readreg(CDNS_I2C_CR_OFFSET);
+ ctrl_reg = id->ctrl_reg;
ctrl_reg &= ~(CDNS_I2C_CR_DIVA_MASK | CDNS_I2C_CR_DIVB_MASK);
ctrl_reg |= ((div_a << CDNS_I2C_CR_DIVA_SHIFT) |
(div_b << CDNS_I2C_CR_DIVB_SHIFT));
- cdns_i2c_writereg(ctrl_reg, CDNS_I2C_CR_OFFSET);
-
+ id->ctrl_reg = ctrl_reg;
return 0;
}
@@ -831,6 +831,18 @@ static int __maybe_unused cdns_i2c_runtime_suspend(struct device *dev)
return 0;
}
+static void cdns_i2c_init(struct cdns_i2c *id)
+{
+ cdns_i2c_writereg(id->ctrl_reg, CDNS_I2C_CR_OFFSET);
+ /*
+ * Cadence I2C controller has a bug wherein it generates
+ * invalid read transaction after HW timeout in master receiver mode.
+ * HW timeout is not used by this driver and the interrupt is disabled.
+ * But the feature itself cannot be disabled. Hence maximum value
+ * is written to this register to reduce the chances of error.
+ */
+ cdns_i2c_writereg(CDNS_I2C_TIMEOUT_MAX, CDNS_I2C_TIME_OUT_OFFSET);
+}
/**
* cdns_i2c_runtime_resume - Runtime resume
@@ -851,6 +863,7 @@ static int __maybe_unused cdns_i2c_runtime_resume(struct device *dev)
dev_err(dev, "Cannot enable clock.\n");
return ret;
}
+ cdns_i2c_init(xi2c);
return 0;
}
@@ -943,8 +956,7 @@ static int cdns_i2c_probe(struct platform_device *pdev)
if (ret || (id->i2c_clk > CDNS_I2C_SPEED_MAX))
id->i2c_clk = CDNS_I2C_SPEED_DEFAULT;
- cdns_i2c_writereg(CDNS_I2C_CR_ACK_EN | CDNS_I2C_CR_NEA | CDNS_I2C_CR_MS,
- CDNS_I2C_CR_OFFSET);
+ id->ctrl_reg = CDNS_I2C_CR_ACK_EN | CDNS_I2C_CR_NEA | CDNS_I2C_CR_MS;
ret = cdns_i2c_setclk(id->input_clk, id);
if (ret) {
@@ -965,15 +977,7 @@ static int cdns_i2c_probe(struct platform_device *pdev)
dev_err(&pdev->dev, "reg adap failed: %d\n", ret);
goto err_clk_dis;
}
-
- /*
- * Cadence I2C controller has a bug wherein it generates
- * invalid read transaction after HW timeout in master receiver mode.
- * HW timeout is not used by this driver and the interrupt is disabled.
- * But the feature itself cannot be disabled. Hence maximum value
- * is written to this register to reduce the chances of error.
- */
- cdns_i2c_writereg(CDNS_I2C_TIMEOUT_MAX, CDNS_I2C_TIME_OUT_OFFSET);
+ cdns_i2c_init(id);
dev_info(&pdev->dev, "%u kHz mmio %08lx irq %d\n",
id->i2c_clk / 1000, (unsigned long)r_mem->start, id->irq);
--
1.7.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] i2c: cadence: Fix the Documentation
2016-03-01 6:32 [PATCH 1/2] i2c: cadence: Fix the Documentation Shubhrajyoti Datta
2016-03-01 6:32 ` [PATCH 2/2] i2c: cadence: Implement save restore Shubhrajyoti Datta
@ 2016-03-01 7:33 ` Michal Simek
2016-03-01 9:23 ` Shubhrajyoti Datta
1 sibling, 1 reply; 6+ messages in thread
From: Michal Simek @ 2016-03-01 7:33 UTC (permalink / raw)
To: Shubhrajyoti Datta, linux-i2c
Cc: soren.brinkmann, michal.simek, wsa, Shubhrajyoti Datta
On 1.3.2016 07:32, Shubhrajyoti Datta wrote:
> The runtime adaptation patch missed the documentation update.
> This fixes the same.
> No functional change.
>
> Signed-off-by: Shubhrajyoti Datta <shubhraj@xilinx.com>
> ---
> drivers/i2c/busses/i2c-cadence.c | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c
> index 6b08d16..a761520 100644
> --- a/drivers/i2c/busses/i2c-cadence.c
> +++ b/drivers/i2c/busses/i2c-cadence.c
> @@ -815,7 +815,7 @@ static int cdns_i2c_clk_notifier_cb(struct notifier_block *nb, unsigned long
> }
>
> /**
> - * cdns_i2c_suspend - Suspend method for the driver
> + * cdns_i2c_runtime_suspend - Runtime suspend method for the driver
> * @_dev: Address of the platform_device structure
you should fix this parameter too.
> *
> * Put the driver into low power mode.
> @@ -833,7 +833,7 @@ static int __maybe_unused cdns_i2c_runtime_suspend(struct device *dev)
> }
>
> /**
> - * cdns_i2c_resume - Resume from suspend
> + * cdns_i2c_runtime_resume - Runtime resume
> * @_dev: Address of the platform_device structure
and here too.
> *
> * Resume operation after suspend.
>
There is also undocumented dev. Please fix it too.
drivers/i2c/busses/i2c-cadence.c:126: info: Scanning doc for struct cdns_i2c
drivers/i2c/busses/i2c-cadence.c:164: warning: No description found for
parameter 'dev'
Thanks,
Michal
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] i2c: cadence: Implement save restore
2016-03-01 6:32 ` [PATCH 2/2] i2c: cadence: Implement save restore Shubhrajyoti Datta
@ 2016-03-01 7:34 ` Michal Simek
2016-03-01 9:25 ` Shubhrajyoti Datta
0 siblings, 1 reply; 6+ messages in thread
From: Michal Simek @ 2016-03-01 7:34 UTC (permalink / raw)
To: Shubhrajyoti Datta, linux-i2c
Cc: soren.brinkmann, michal.simek, wsa, Shubhrajyoti Datta
On 1.3.2016 07:32, Shubhrajyoti Datta wrote:
> Implement save restore for i2c module.
> Since we have only a couple of registers
> an unconditional restore is done.
>
> Signed-off-by: Shubhrajyoti Datta <shubhraj@xilinx.com>
> ---
> zynq-mp has the capability of going off.
> the current kernel does not hit off however some day it will.
> since the overhead of having the support is not much may be it is better
> to have it in the kernel.
>
> drivers/i2c/busses/i2c-cadence.c | 32 ++++++++++++++++++--------------
> 1 files changed, 18 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c
> index a761520..3d50914 100644
> --- a/drivers/i2c/busses/i2c-cadence.c
> +++ b/drivers/i2c/busses/i2c-cadence.c
> @@ -161,6 +161,7 @@ struct cdns_i2c {
> struct clk *clk;
> struct notifier_block clk_rate_change_nb;
> u32 quirks;
> + u32 ctrl_reg;
kernel-doc update too.
> };
>
> struct cdns_platform_data {
> @@ -743,12 +744,11 @@ static int cdns_i2c_setclk(unsigned long clk_in, struct cdns_i2c *id)
> if (ret)
> return ret;
>
> - ctrl_reg = cdns_i2c_readreg(CDNS_I2C_CR_OFFSET);
> + ctrl_reg = id->ctrl_reg;
> ctrl_reg &= ~(CDNS_I2C_CR_DIVA_MASK | CDNS_I2C_CR_DIVB_MASK);
> ctrl_reg |= ((div_a << CDNS_I2C_CR_DIVA_SHIFT) |
> (div_b << CDNS_I2C_CR_DIVB_SHIFT));
> - cdns_i2c_writereg(ctrl_reg, CDNS_I2C_CR_OFFSET);
> -
> + id->ctrl_reg = ctrl_reg;
> return 0;
> }
>
> @@ -831,6 +831,18 @@ static int __maybe_unused cdns_i2c_runtime_suspend(struct device *dev)
>
> return 0;
> }
You probably want to put empty line here. And most of functions have
kernel-doc and will be good to follow this up.
> +static void cdns_i2c_init(struct cdns_i2c *id)
> +{
> + cdns_i2c_writereg(id->ctrl_reg, CDNS_I2C_CR_OFFSET);
> + /*
> + * Cadence I2C controller has a bug wherein it generates
> + * invalid read transaction after HW timeout in master receiver mode.
> + * HW timeout is not used by this driver and the interrupt is disabled.
> + * But the feature itself cannot be disabled. Hence maximum value
> + * is written to this register to reduce the chances of error.
> + */
> + cdns_i2c_writereg(CDNS_I2C_TIMEOUT_MAX, CDNS_I2C_TIME_OUT_OFFSET);
> +}
>
> /**
> * cdns_i2c_runtime_resume - Runtime resume
> @@ -851,6 +863,7 @@ static int __maybe_unused cdns_i2c_runtime_resume(struct device *dev)
> dev_err(dev, "Cannot enable clock.\n");
> return ret;
> }
> + cdns_i2c_init(xi2c);
>
> return 0;
> }
> @@ -943,8 +956,7 @@ static int cdns_i2c_probe(struct platform_device *pdev)
> if (ret || (id->i2c_clk > CDNS_I2C_SPEED_MAX))
> id->i2c_clk = CDNS_I2C_SPEED_DEFAULT;
>
> - cdns_i2c_writereg(CDNS_I2C_CR_ACK_EN | CDNS_I2C_CR_NEA | CDNS_I2C_CR_MS,
> - CDNS_I2C_CR_OFFSET);
> + id->ctrl_reg = CDNS_I2C_CR_ACK_EN | CDNS_I2C_CR_NEA | CDNS_I2C_CR_MS;
>
> ret = cdns_i2c_setclk(id->input_clk, id);
> if (ret) {
> @@ -965,15 +977,7 @@ static int cdns_i2c_probe(struct platform_device *pdev)
> dev_err(&pdev->dev, "reg adap failed: %d\n", ret);
> goto err_clk_dis;
> }
> -
> - /*
> - * Cadence I2C controller has a bug wherein it generates
> - * invalid read transaction after HW timeout in master receiver mode.
> - * HW timeout is not used by this driver and the interrupt is disabled.
> - * But the feature itself cannot be disabled. Hence maximum value
> - * is written to this register to reduce the chances of error.
> - */
> - cdns_i2c_writereg(CDNS_I2C_TIMEOUT_MAX, CDNS_I2C_TIME_OUT_OFFSET);
> + cdns_i2c_init(id);
>
> dev_info(&pdev->dev, "%u kHz mmio %08lx irq %d\n",
> id->i2c_clk / 1000, (unsigned long)r_mem->start, id->irq);
>
Thanks,
Michal
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] i2c: cadence: Fix the Documentation
2016-03-01 7:33 ` [PATCH 1/2] i2c: cadence: Fix the Documentation Michal Simek
@ 2016-03-01 9:23 ` Shubhrajyoti Datta
0 siblings, 0 replies; 6+ messages in thread
From: Shubhrajyoti Datta @ 2016-03-01 9:23 UTC (permalink / raw)
To: Michal Simek
Cc: Shubhrajyoti Datta, linux-i2c, Sören Brinkmann, Wolfram Sang,
Shubhrajyoti Datta
On Tue, Mar 1, 2016 at 1:03 PM, Michal Simek <michal.simek@xilinx.com> wrote:
> On 1.3.2016 07:32, Shubhrajyoti Datta wrote:
>> The runtime adaptation patch missed the documentation update.
>> This fixes the same.
>> No functional change.
>>
>> Signed-off-by: Shubhrajyoti Datta <shubhraj@xilinx.com>
>> ---
>> drivers/i2c/busses/i2c-cadence.c | 4 ++--
>> 1 files changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c
>> index 6b08d16..a761520 100644
>> --- a/drivers/i2c/busses/i2c-cadence.c
>> +++ b/drivers/i2c/busses/i2c-cadence.c
>> @@ -815,7 +815,7 @@ static int cdns_i2c_clk_notifier_cb(struct notifier_block *nb, unsigned long
>> }
>>
>> /**
>> - * cdns_i2c_suspend - Suspend method for the driver
>> + * cdns_i2c_runtime_suspend - Runtime suspend method for the driver
>> * @_dev: Address of the platform_device structure
>
> you should fix this parameter too.
yes
>
>> *
>> * Put the driver into low power mode.
>> @@ -833,7 +833,7 @@ static int __maybe_unused cdns_i2c_runtime_suspend(struct device *dev)
>> }
>>
>> /**
>> - * cdns_i2c_resume - Resume from suspend
>> + * cdns_i2c_runtime_resume - Runtime resume
>> * @_dev: Address of the platform_device structure
>
> and here too.
ok
>
>> *
>> * Resume operation after suspend.
>>
>
> There is also undocumented dev. Please fix it too.
> drivers/i2c/busses/i2c-cadence.c:126: info: Scanning doc for struct cdns_i2c
> drivers/i2c/busses/i2c-cadence.c:164: warning: No description found for
> parameter 'dev'
Sent a v2 fixing all the comments.
Thanks for the review
>
> Thanks,
> Michal
> --
> To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] i2c: cadence: Implement save restore
2016-03-01 7:34 ` Michal Simek
@ 2016-03-01 9:25 ` Shubhrajyoti Datta
0 siblings, 0 replies; 6+ messages in thread
From: Shubhrajyoti Datta @ 2016-03-01 9:25 UTC (permalink / raw)
To: Michal Simek
Cc: Shubhrajyoti Datta, linux-i2c, Sören Brinkmann, Wolfram Sang,
Shubhrajyoti Datta
On Tue, Mar 1, 2016 at 1:04 PM, Michal Simek <michal.simek@xilinx.com> wrote:
> On 1.3.2016 07:32, Shubhrajyoti Datta wrote:
>> Implement save restore for i2c module.
>> Since we have only a couple of registers
>> an unconditional restore is done.
>>
>> Signed-off-by: Shubhrajyoti Datta <shubhraj@xilinx.com>
>> ---
>> zynq-mp has the capability of going off.
>> the current kernel does not hit off however some day it will.
>> since the overhead of having the support is not much may be it is better
>> to have it in the kernel.
>>
>> drivers/i2c/busses/i2c-cadence.c | 32 ++++++++++++++++++--------------
>> 1 files changed, 18 insertions(+), 14 deletions(-)
>>
>> diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c
>> index a761520..3d50914 100644
>> --- a/drivers/i2c/busses/i2c-cadence.c
>> +++ b/drivers/i2c/busses/i2c-cadence.c
>> @@ -161,6 +161,7 @@ struct cdns_i2c {
>> struct clk *clk;
>> struct notifier_block clk_rate_change_nb;
>> u32 quirks;
>> + u32 ctrl_reg;
>
> kernel-doc update too.
missed it fixed in v2
>
>> };
>>
>> struct cdns_platform_data {
>> @@ -743,12 +744,11 @@ static int cdns_i2c_setclk(unsigned long clk_in, struct cdns_i2c *id)
>> if (ret)
>> return ret;
>>
>> - ctrl_reg = cdns_i2c_readreg(CDNS_I2C_CR_OFFSET);
>> + ctrl_reg = id->ctrl_reg;
>> ctrl_reg &= ~(CDNS_I2C_CR_DIVA_MASK | CDNS_I2C_CR_DIVB_MASK);
>> ctrl_reg |= ((div_a << CDNS_I2C_CR_DIVA_SHIFT) |
>> (div_b << CDNS_I2C_CR_DIVB_SHIFT));
>> - cdns_i2c_writereg(ctrl_reg, CDNS_I2C_CR_OFFSET);
>> -
>> + id->ctrl_reg = ctrl_reg;
>> return 0;
>> }
>>
>> @@ -831,6 +831,18 @@ static int __maybe_unused cdns_i2c_runtime_suspend(struct device *dev)
>>
>> return 0;
>> }
>
> You probably want to put empty line here. And most of functions have
> kernel-doc and will be good to follow this up.
>
Agree sent v2 fixing the same.
Thanks for review
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-03-01 9:25 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-01 6:32 [PATCH 1/2] i2c: cadence: Fix the Documentation Shubhrajyoti Datta
2016-03-01 6:32 ` [PATCH 2/2] i2c: cadence: Implement save restore Shubhrajyoti Datta
2016-03-01 7:34 ` Michal Simek
2016-03-01 9:25 ` Shubhrajyoti Datta
2016-03-01 7:33 ` [PATCH 1/2] i2c: cadence: Fix the Documentation Michal Simek
2016-03-01 9:23 ` Shubhrajyoti Datta
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox