Patchwork [1/2] i2c: omap: convert to module_platform_driver()

login
register
mail settings
Submitter Grygorii Strashko
Date June 4, 2013, 11:32 a.m.
Message ID <51ADD06B.3000201@ti.com>
Download mbox | patch
Permalink /patch/248539/
State Deferred
Headers show

Comments

Grygorii Strashko - June 4, 2013, 11:32 a.m.
Hi Kevin,
On 06/03/2013 11:59 PM, Kevin Hilman wrote:
> Grygorii Strashko <grygorii.strashko@ti.com> writes:
>
>> The OMAP I2C driver has a relation to pinctrl-single driver. As result,
>> its probe will be deferred during system boot until late init time,
>> because the pinctrl-single is initizalized as moudle/device init time.
>> This, in turn, will delay initialization of all I2C devices (like mfd,
>> I2C regulators and etc.) and cause boot delay (more over, it can broken
>> initialization of drivers which are not ready to use deferred probe
>> mechanism yet, for example DSS).
>>
>> There are no sense to keep OMAP I2C initialization on subsys init layer
>> any more, hence shift it to module/device layer where the i2c <-->
>> pinctrl-single dependency is resolved in drivers/Makefile now.
>>
>> Cc: Wolfram Sang <wsa@the-dreams.de>
>> Cc: "Ben Dooks (embedded platforms)" <ben-linux@fluff.org>
>> Cc: Santosh Shilimkar <santosh.shilimkar@ti.com>
>> Cc: linux-omap@vger.kernel.org
>> Cc: linux-i2c@vger.kernel.org
>> Cc: linux-kernel@vger.kernel.org
>>
>> Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
> Testing this patch with PATCH 1/2, the twl_rtc driver fails to correctly
> initialize on OMAP3:
>
>           twl_rtc rtc.22: hctosys: invalid date/time
>
> instead of the expected result:
>
>            twl_rtc rtc.22: setting system clock to 2000-01-01 00:00:00 UTC (946684800)
>
> so something is still not right for the init sequence.
>
> Kevin
I think, the root cause of the problem isn't this patch - it's just yet 
another side effect
of using deferred probes :). I've taken a look on twl-rtc code and found 
possible error place
static int __init twl_rtc_init(void)
{
     if (twl_class_is_4030()) <------ here,
         rtc_reg_map = (u8 *) twl4030_rtc_reg_map;
     else
         rtc_reg_map = (u8 *) twl6030_rtc_reg_map;

     return platform_driver_register(&twl4030rtc_driver);
}
In drivers/Makefile:
obj-$(CONFIG_RTC_LIB)        += rtc/  <------ RTC is placed before I2C
obj-y                += i2c/ media/ <----- and only here I2C bus 
instantiates TWL-core device
and configures twl_priv->twl_id

Thats why it's working on my OMAP4/twl6030 board. Could you check if 
below fix will work on OMAP3:

Unfortunately, I have no OMAP3 HW and can't check it.

Regards,
-grygorii


--
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
Kevin Hilman - June 4, 2013, 6:29 p.m.
Grygorii Strashko <grygorii.strashko@ti.com> writes:

> Hi Kevin,
> On 06/03/2013 11:59 PM, Kevin Hilman wrote:
>> Grygorii Strashko <grygorii.strashko@ti.com> writes:
>>
>>> The OMAP I2C driver has a relation to pinctrl-single driver. As result,
>>> its probe will be deferred during system boot until late init time,
>>> because the pinctrl-single is initizalized as moudle/device init time.
>>> This, in turn, will delay initialization of all I2C devices (like mfd,
>>> I2C regulators and etc.) and cause boot delay (more over, it can broken
>>> initialization of drivers which are not ready to use deferred probe
>>> mechanism yet, for example DSS).
>>>
>>> There are no sense to keep OMAP I2C initialization on subsys init layer
>>> any more, hence shift it to module/device layer where the i2c <-->
>>> pinctrl-single dependency is resolved in drivers/Makefile now.
>>>
>>> Cc: Wolfram Sang <wsa@the-dreams.de>
>>> Cc: "Ben Dooks (embedded platforms)" <ben-linux@fluff.org>
>>> Cc: Santosh Shilimkar <santosh.shilimkar@ti.com>
>>> Cc: linux-omap@vger.kernel.org
>>> Cc: linux-i2c@vger.kernel.org
>>> Cc: linux-kernel@vger.kernel.org
>>>
>>> Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
>> Testing this patch with PATCH 1/2, the twl_rtc driver fails to correctly
>> initialize on OMAP3:
>>
>>           twl_rtc rtc.22: hctosys: invalid date/time
>>
>> instead of the expected result:
>>
>>            twl_rtc rtc.22: setting system clock to 2000-01-01 00:00:00 UTC (946684800)
>>
>> so something is still not right for the init sequence.
>>
>> Kevin
> I think, the root cause of the problem isn't this patch - it's just
> yet another side effect
> of using deferred probes :). I've taken a look on twl-rtc code and
> found possible error place
> static int __init twl_rtc_init(void)
> {
>     if (twl_class_is_4030()) <------ here,
>         rtc_reg_map = (u8 *) twl4030_rtc_reg_map;
>     else
>         rtc_reg_map = (u8 *) twl6030_rtc_reg_map;
>
>     return platform_driver_register(&twl4030rtc_driver);
> }
> In drivers/Makefile:
> obj-$(CONFIG_RTC_LIB)        += rtc/  <------ RTC is placed before I2C
> obj-y                += i2c/ media/ <----- and only here I2C bus
> instantiates TWL-core device
> and configures twl_priv->twl_id
>
> Thats why it's working on my OMAP4/twl6030 board. Could you check if
> below fix will work on OMAP3:

Yes, your fix works.  Thanks for digging into it.

Care to send a proper patch?  Please be sure to send to Andrew Morton
also, since he'll be the one to queue the RTC patch.

> diff --git a/drivers/rtc/rtc-twl.c b/drivers/rtc/rtc-twl.c
> index 8751a52..aaa5015 100644
> --- a/drivers/rtc/rtc-twl.c
> +++ b/drivers/rtc/rtc-twl.c
> @@ -469,6 +469,11 @@ static int twl_rtc_probe(struct platform_device *pdev)
>         if (irq <= 0)
>                 goto out1;
>
> +       if (twl_class_is_4030())
> +               rtc_reg_map = (u8 *) twl4030_rtc_reg_map;
> +       else
> +               rtc_reg_map = (u8 *) twl6030_rtc_reg_map;
> +
>         ret = twl_rtc_read_u8(&rd_reg, REG_RTC_STATUS_REG);
>         if (ret < 0)
>                 goto out1;
> @@ -610,11 +615,6 @@ static struct platform_driver twl4030rtc_driver = {
>
>  static int __init twl_rtc_init(void)
>  {
> -       if (twl_class_is_4030())
> -               rtc_reg_map = (u8 *) twl4030_rtc_reg_map;
> -       else
> -               rtc_reg_map = (u8 *) twl6030_rtc_reg_map;
> -
>         return platform_driver_register(&twl4030rtc_driver);
>  }
>  module_init(twl_rtc_init);
>
> Unfortunately, I have no OMAP3 HW and can't check it.

I suggest you find a Beagle or Gumstix/Overo type board someplace.
There is an abundance of cheap OMAP3 hardware available.

Kevin

--
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
Grygorii Strashko - June 5, 2013, 11:28 a.m.
On 06/04/2013 09:29 PM, Kevin Hilman wrote:
> Grygorii Strashko <grygorii.strashko@ti.com> writes:
>
>> Hi Kevin,
>> On 06/03/2013 11:59 PM, Kevin Hilman wrote:
>>> Grygorii Strashko <grygorii.strashko@ti.com> writes:
>>>
>>>> The OMAP I2C driver has a relation to pinctrl-single driver. As result,
>>>> its probe will be deferred during system boot until late init time,
>>>> because the pinctrl-single is initizalized as moudle/device init time.
>>>> This, in turn, will delay initialization of all I2C devices (like mfd,
>>>> I2C regulators and etc.) and cause boot delay (more over, it can broken
>>>> initialization of drivers which are not ready to use deferred probe
>>>> mechanism yet, for example DSS).
>>>>
>>>> There are no sense to keep OMAP I2C initialization on subsys init layer
>>>> any more, hence shift it to module/device layer where the i2c <-->
>>>> pinctrl-single dependency is resolved in drivers/Makefile now.
>>>>
>>>> Cc: Wolfram Sang <wsa@the-dreams.de>
>>>> Cc: "Ben Dooks (embedded platforms)" <ben-linux@fluff.org>
>>>> Cc: Santosh Shilimkar <santosh.shilimkar@ti.com>
>>>> Cc: linux-omap@vger.kernel.org
>>>> Cc: linux-i2c@vger.kernel.org
>>>> Cc: linux-kernel@vger.kernel.org
>>>>
>>>> Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
>>> Testing this patch with PATCH 1/2, the twl_rtc driver fails to correctly
>>> initialize on OMAP3:
>>>
>>>            twl_rtc rtc.22: hctosys: invalid date/time
>>>
>>> instead of the expected result:
>>>
>>>             twl_rtc rtc.22: setting system clock to 2000-01-01 00:00:00 UTC (946684800)
>>>
>>> so something is still not right for the init sequence.
>>>
>>> Kevin
>> I think, the root cause of the problem isn't this patch - it's just
>> yet another side effect
>> of using deferred probes :). I've taken a look on twl-rtc code and
>> found possible error place
>> static int __init twl_rtc_init(void)
>> {
>>      if (twl_class_is_4030()) <------ here,
>>          rtc_reg_map = (u8 *) twl4030_rtc_reg_map;
>>      else
>>          rtc_reg_map = (u8 *) twl6030_rtc_reg_map;
>>
>>      return platform_driver_register(&twl4030rtc_driver);
>> }
>> In drivers/Makefile:
>> obj-$(CONFIG_RTC_LIB)        += rtc/  <------ RTC is placed before I2C
>> obj-y                += i2c/ media/ <----- and only here I2C bus
>> instantiates TWL-core device
>> and configures twl_priv->twl_id
>>
>> Thats why it's working on my OMAP4/twl6030 board. Could you check if
>> below fix will work on OMAP3:
> Yes, your fix works.  Thanks for digging into it.
>
> Care to send a proper patch?  Please be sure to send to Andrew Morton
> also, since he'll be the one to queue the RTC patch.
Hi Kevin,

The similar patch already exists:
https://patchwork.kernel.org/patch/2448251/ - [v2,1/2] RTC: rtc-twl: Fix 
rtc_reg_map initialization
from Peter Ujfalusi

-grygorii

>
>> diff --git a/drivers/rtc/rtc-twl.c b/drivers/rtc/rtc-twl.c
>> index 8751a52..aaa5015 100644
>> --- a/drivers/rtc/rtc-twl.c
>> +++ b/drivers/rtc/rtc-twl.c
>> @@ -469,6 +469,11 @@ static int twl_rtc_probe(struct platform_device *pdev)
>>          if (irq <= 0)
>>                  goto out1;
>>
>> +       if (twl_class_is_4030())
>> +               rtc_reg_map = (u8 *) twl4030_rtc_reg_map;
>> +       else
>> +               rtc_reg_map = (u8 *) twl6030_rtc_reg_map;
>> +
>>          ret = twl_rtc_read_u8(&rd_reg, REG_RTC_STATUS_REG);
>>          if (ret < 0)
>>                  goto out1;
>> @@ -610,11 +615,6 @@ static struct platform_driver twl4030rtc_driver = {
>>
>>   static int __init twl_rtc_init(void)
>>   {
>> -       if (twl_class_is_4030())
>> -               rtc_reg_map = (u8 *) twl4030_rtc_reg_map;
>> -       else
>> -               rtc_reg_map = (u8 *) twl6030_rtc_reg_map;
>> -
>>          return platform_driver_register(&twl4030rtc_driver);
>>   }
>>   module_init(twl_rtc_init);
>>
>> Unfortunately, I have no OMAP3 HW and can't check it.
> I suggest you find a Beagle or Gumstix/Overo type board someplace.
> There is an abundance of cheap OMAP3 hardware available.
>
> Kevin
>

--
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
Wolfram Sang - June 5, 2013, 1:50 p.m.
> The similar patch already exists:
> https://patchwork.kernel.org/patch/2448251/ - [v2,1/2] RTC: rtc-twl:
> Fix rtc_reg_map initialization
> from Peter Ujfalusi

So, I think it is best if you resend this patch after all the fixes it
needs are applied or you resend the series with all patches it depends
on. Which should then probably go via arm-soc. Or?
Grygorii Strashko - June 6, 2013, 2:58 p.m.
On 06/05/2013 04:50 PM, Wolfram Sang wrote:
>> The similar patch already exists:
>> https://patchwork.kernel.org/patch/2448251/ - [v2,1/2] RTC: rtc-twl:
>> Fix rtc_reg_map initialization
>> from Peter Ujfalusi
> So, I think it is best if you resend this patch after all the fixes it
> needs are applied or you resend the series with all patches it depends
> on. Which should then probably go via arm-soc. Or?
>
It can wait - I'll track and resend after twl-rtc patches.

-grygorii

--
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

Patch

diff --git a/drivers/rtc/rtc-twl.c b/drivers/rtc/rtc-twl.c
index 8751a52..aaa5015 100644
--- a/drivers/rtc/rtc-twl.c
+++ b/drivers/rtc/rtc-twl.c
@@ -469,6 +469,11 @@  static int twl_rtc_probe(struct platform_device *pdev)
         if (irq <= 0)
                 goto out1;

+       if (twl_class_is_4030())
+               rtc_reg_map = (u8 *) twl4030_rtc_reg_map;
+       else
+               rtc_reg_map = (u8 *) twl6030_rtc_reg_map;
+
         ret = twl_rtc_read_u8(&rd_reg, REG_RTC_STATUS_REG);
         if (ret < 0)
                 goto out1;
@@ -610,11 +615,6 @@  static struct platform_driver twl4030rtc_driver = {

  static int __init twl_rtc_init(void)
  {
-       if (twl_class_is_4030())
-               rtc_reg_map = (u8 *) twl4030_rtc_reg_map;
-       else
-               rtc_reg_map = (u8 *) twl6030_rtc_reg_map;
-
         return platform_driver_register(&twl4030rtc_driver);
  }
  module_init(twl_rtc_init);