diff mbox

[4/4] i2c: qup: Add command-line parameter to override SCL frequency

Message ID 1524604882-25377-5-git-send-email-austinwc@codeaurora.org (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Austin Christ April 24, 2018, 9:21 p.m. UTC
Add a module parameter to override SCL frequency provided by firmware.
This can be useful when testing spec compliance for I2C modes or when
debugging issues across multiple operating frequencies.

Signed-off-by: Austin Christ <austinwc@codeaurora.org>
---
 drivers/i2c/busses/i2c-qup.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

Comments

Sricharan Ramabadhran April 25, 2018, 10:57 a.m. UTC | #1
On 4/25/2018 2:51 AM, Austin Christ wrote:
> Add a module parameter to override SCL frequency provided by firmware.
> This can be useful when testing spec compliance for I2C modes or when
> debugging issues across multiple operating frequencies.
> 
> Signed-off-by: Austin Christ <austinwc@codeaurora.org>
> ---
>  drivers/i2c/busses/i2c-qup.c | 19 ++++++++++++++-----
>  1 file changed, 14 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-qup.c b/drivers/i2c/busses/i2c-qup.c
> index f87f29f..da4cc57 100644
> --- a/drivers/i2c/busses/i2c-qup.c
> +++ b/drivers/i2c/busses/i2c-qup.c
> @@ -155,6 +155,10 @@
>  /* TAG length for DATA READ in RX FIFO  */
>  #define READ_RX_TAGS_LEN		2
>  
> +static unsigned int scl_freq;
> +module_param_named(scl_freq, scl_freq, uint, 0444);

Instead of hard coding the permission constants, macro can be used.

Otherwise,

 Reviewed-by: Sricharan R <sricharan@codeaurora.org>

Regards,
 Sricharan


> +MODULE_PARM_DESC(scl_freq, "SCL frequency override");
> +
>  /*
>   * count: no of blocks
>   * pos: current block number
> @@ -1682,11 +1686,16 @@ static int qup_i2c_probe(struct platform_device *pdev)
>  	init_completion(&qup->xfer);
>  	platform_set_drvdata(pdev, qup);
>  
> -	ret = device_property_read_u32(qup->dev, "clock-frequency", &clk_freq);
> -	if (ret) {
> -		dev_notice(qup->dev, "using default clock-frequency %d",
> -			DEFAULT_CLK_FREQ);
> -	}
> +	if (scl_freq) {
> +		dev_notice(qup->dev, "Using override frequency of %u\n", scl_freq);
> +		clk_freq = scl_freq;
> +	} else {
> +		ret = device_property_read_u32(qup->dev, "clock-frequency", &clk_freq);
> +		if (ret) {
> +			dev_notice(qup->dev, "using default clock-frequency %d",
> +				DEFAULT_CLK_FREQ);
> +		}
> +	}
>  
>  	if (of_device_is_compatible(pdev->dev.of_node, "qcom,i2c-qup-v1.1.1")) {
>  		qup->adap.algo = &qup_i2c_algo;
>
Austin Christ April 25, 2018, 3:07 p.m. UTC | #2
Hey Sricharan,

On 4/25/2018 4:57 AM, Sricharan R wrote:
> 
> 
> On 4/25/2018 2:51 AM, Austin Christ wrote:
>> Add a module parameter to override SCL frequency provided by firmware.
>> This can be useful when testing spec compliance for I2C modes or when
>> debugging issues across multiple operating frequencies.
>>
>> Signed-off-by: Austin Christ <austinwc@codeaurora.org>
>> ---
>>   drivers/i2c/busses/i2c-qup.c | 19 ++++++++++++++-----
>>   1 file changed, 14 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/i2c/busses/i2c-qup.c b/drivers/i2c/busses/i2c-qup.c
>> index f87f29f..da4cc57 100644
>> --- a/drivers/i2c/busses/i2c-qup.c
>> +++ b/drivers/i2c/busses/i2c-qup.c
>> @@ -155,6 +155,10 @@
>>   /* TAG length for DATA READ in RX FIFO  */
>>   #define READ_RX_TAGS_LEN		2
>>   
>> +static unsigned int scl_freq;
>> +module_param_named(scl_freq, scl_freq, uint, 0444);
> 
> Instead of hard coding the permission constants, macro can be used.
> 
> Otherwise,
> 
>   Reviewed-by: Sricharan R <sricharan@codeaurora.org>
> 
> Regards,
>   Sricharan
> 

Ok I'll switch it. I originally switched to 0444 based on a 
recommendation from checkpatch.
> 
>> +MODULE_PARM_DESC(scl_freq, "SCL frequency override");
>> +
>>   /*
>>    * count: no of blocks
>>    * pos: current block number
>> @@ -1682,11 +1686,16 @@ static int qup_i2c_probe(struct platform_device *pdev)
>>   	init_completion(&qup->xfer);
>>   	platform_set_drvdata(pdev, qup);
>>   
>> -	ret = device_property_read_u32(qup->dev, "clock-frequency", &clk_freq);
>> -	if (ret) {
>> -		dev_notice(qup->dev, "using default clock-frequency %d",
>> -			DEFAULT_CLK_FREQ);
>> -	}
>> +	if (scl_freq) {
>> +		dev_notice(qup->dev, "Using override frequency of %u\n", scl_freq);
>> +		clk_freq = scl_freq;
>> +	} else {
>> +		ret = device_property_read_u32(qup->dev, "clock-frequency", &clk_freq);
>> +		if (ret) {
>> +			dev_notice(qup->dev, "using default clock-frequency %d",
>> +				DEFAULT_CLK_FREQ);
>> +		}
>> +	}
>>   
>>   	if (of_device_is_compatible(pdev->dev.of_node, "qcom,i2c-qup-v1.1.1")) {
>>   		qup->adap.algo = &qup_i2c_algo;
>>
>
Sricharan Ramabadhran April 25, 2018, 3:30 p.m. UTC | #3
Hi Austin,

On 4/25/2018 8:37 PM, Christ, Austin wrote:
> Hey Sricharan,
> 
> On 4/25/2018 4:57 AM, Sricharan R wrote:
>>
>>
>> On 4/25/2018 2:51 AM, Austin Christ wrote:
>>> Add a module parameter to override SCL frequency provided by firmware.
>>> This can be useful when testing spec compliance for I2C modes or when
>>> debugging issues across multiple operating frequencies.
>>>
>>> Signed-off-by: Austin Christ <austinwc@codeaurora.org>
>>> ---
>>>   drivers/i2c/busses/i2c-qup.c | 19 ++++++++++++++-----
>>>   1 file changed, 14 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/drivers/i2c/busses/i2c-qup.c b/drivers/i2c/busses/i2c-qup.c
>>> index f87f29f..da4cc57 100644
>>> --- a/drivers/i2c/busses/i2c-qup.c
>>> +++ b/drivers/i2c/busses/i2c-qup.c
>>> @@ -155,6 +155,10 @@
>>>   /* TAG length for DATA READ in RX FIFO  */
>>>   #define READ_RX_TAGS_LEN        2
>>>   +static unsigned int scl_freq;
>>> +module_param_named(scl_freq, scl_freq, uint, 0444);
>>
>> Instead of hard coding the permission constants, macro can be used.
>>
>> Otherwise,
>>
>>   Reviewed-by: Sricharan R <sricharan@codeaurora.org>
>>
>> Regards,
>>   Sricharan
>>
> 
> Ok I'll switch it. I originally switched to 0444 based on a recommendation from checkpatch.
>>

 hmm, guess i was wrong there. sorry. Better to stick to octal then as you already have.

Regards,
 Sricharan


>>> +MODULE_PARM_DESC(scl_freq, "SCL frequency override");
>>> +
>>>   /*
>>>    * count: no of blocks
>>>    * pos: current block number
>>> @@ -1682,11 +1686,16 @@ static int qup_i2c_probe(struct platform_device *pdev)
>>>       init_completion(&qup->xfer);
>>>       platform_set_drvdata(pdev, qup);
>>>   -    ret = device_property_read_u32(qup->dev, "clock-frequency", &clk_freq);
>>> -    if (ret) {
>>> -        dev_notice(qup->dev, "using default clock-frequency %d",
>>> -            DEFAULT_CLK_FREQ);
>>> -    }
>>> +    if (scl_freq) {
>>> +        dev_notice(qup->dev, "Using override frequency of %u\n", scl_freq);
>>> +        clk_freq = scl_freq;
>>> +    } else {
>>> +        ret = device_property_read_u32(qup->dev, "clock-frequency", &clk_freq);
>>> +        if (ret) {
>>> +            dev_notice(qup->dev, "using default clock-frequency %d",
>>> +                DEFAULT_CLK_FREQ);
>>> +        }
>>> +    }
>>>         if (of_device_is_compatible(pdev->dev.of_node, "qcom,i2c-qup-v1.1.1")) {
>>>           qup->adap.algo = &qup_i2c_algo;
>>>
>>
>
diff mbox

Patch

diff --git a/drivers/i2c/busses/i2c-qup.c b/drivers/i2c/busses/i2c-qup.c
index f87f29f..da4cc57 100644
--- a/drivers/i2c/busses/i2c-qup.c
+++ b/drivers/i2c/busses/i2c-qup.c
@@ -155,6 +155,10 @@ 
 /* TAG length for DATA READ in RX FIFO  */
 #define READ_RX_TAGS_LEN		2
 
+static unsigned int scl_freq;
+module_param_named(scl_freq, scl_freq, uint, 0444);
+MODULE_PARM_DESC(scl_freq, "SCL frequency override");
+
 /*
  * count: no of blocks
  * pos: current block number
@@ -1682,11 +1686,16 @@  static int qup_i2c_probe(struct platform_device *pdev)
 	init_completion(&qup->xfer);
 	platform_set_drvdata(pdev, qup);
 
-	ret = device_property_read_u32(qup->dev, "clock-frequency", &clk_freq);
-	if (ret) {
-		dev_notice(qup->dev, "using default clock-frequency %d",
-			DEFAULT_CLK_FREQ);
-	}
+	if (scl_freq) {
+		dev_notice(qup->dev, "Using override frequency of %u\n", scl_freq);
+		clk_freq = scl_freq;
+	} else {
+		ret = device_property_read_u32(qup->dev, "clock-frequency", &clk_freq);
+		if (ret) {
+			dev_notice(qup->dev, "using default clock-frequency %d",
+				DEFAULT_CLK_FREQ);
+		}
+	}
 
 	if (of_device_is_compatible(pdev->dev.of_node, "qcom,i2c-qup-v1.1.1")) {
 		qup->adap.algo = &qup_i2c_algo;