From: Wolfram Sang on
On Wed, May 26, 2010 at 06:39:13PM -0700, Robert Emanuele wrote:

> Still the framebuffer device would initialize first and it would lack
> having the i2c chips it needs ready. That is the order I'm trying to
> straighten out.

Understood. Our pointers were probably not precise enough, sorry. Please try
this patch and give a Tested-by-tag if it solves your problems.

From: Wolfram Sang <w.sang(a)pengutronix.de>
Date: Thu, 27 May 2010 06:03:48 +0200
Subject: [PATCH] i2c-at91: use subsys_initcall() for early initialization

I2C needs to be available early, so other subsystems can access it.

Signed-off-by: Wolfram Sang <w.sang(a)pengutronix.de>
Cc: Robert Emanuele <rob(a)emanuele.us>
Cc: Ben Dooks <ben-linux(a)fluff.org>
---

drivers/i2c/busses/i2c-at91.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
index 305c075..bea5794 100644
--- a/drivers/i2c/busses/i2c-at91.c
+++ b/drivers/i2c/busses/i2c-at91.c
@@ -313,13 +313,12 @@ static int __init at91_i2c_init(void)
{
return platform_driver_register(&at91_i2c_driver);
}
+subsys_initcall(at91_i2c_init);

static void __exit at91_i2c_exit(void)
{
platform_driver_unregister(&at91_i2c_driver);
}
-
-module_init(at91_i2c_init);
module_exit(at91_i2c_exit);

MODULE_AUTHOR("Rick Bronson");


--
Pengutronix e.K. | Wolfram Sang |
Industrial Linux Solutions | http://www.pengutronix.de/ |
From: Robert Emanuele on
Hi Wolfram,

I am using the i2c-gpio.c driver, not the i2c-at91 driver. The Atmel
folks have expressed concerns over their i2c silicon and wrote a gpio
version.

Anyway, I better understand the subsys_initcall now and applied that
to the i2c-gpio and my i2c chip driver. That worked perfectly for my
issue. I'd be happy to return a patch of this. Would be this the
sort of thing that would benefit from a config option? Something
like:

#if defined(CONFIG_EARLY_i2C_GPIO)
subsys_initcall(i2c_gpio_init);
#else
module_init(i2c_gpio_init);
#endif

I appreciate your help and direction.

Thank you,

Rob

On Wed, May 26, 2010 at 9:13 PM, Wolfram Sang <w.sang(a)pengutronix.de> wrote:
> On Wed, May 26, 2010 at 06:39:13PM -0700, Robert Emanuele wrote:
>
>> Still the framebuffer device would initialize first and it would lack
>> having the i2c chips it needs ready. �That is the order I'm trying to
>> straighten out.
>
> Understood. Our pointers were probably not precise enough, sorry. Please try
> this patch and give a Tested-by-tag if it solves your problems.
>
> From: Wolfram Sang <w.sang(a)pengutronix.de>
> Date: Thu, 27 May 2010 06:03:48 +0200
> Subject: [PATCH] i2c-at91: use subsys_initcall() for early initialization
>
> I2C needs to be available early, so other subsystems can access it.
>
> Signed-off-by: Wolfram Sang <w.sang(a)pengutronix.de>
> Cc: Robert Emanuele <rob(a)emanuele.us>
> Cc: Ben Dooks <ben-linux(a)fluff.org>
> ---
>
> �drivers/i2c/busses/i2c-at91.c | � �3 +--
> �1 files changed, 1 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
> index 305c075..bea5794 100644
> --- a/drivers/i2c/busses/i2c-at91.c
> +++ b/drivers/i2c/busses/i2c-at91.c
> @@ -313,13 +313,12 @@ static int __init at91_i2c_init(void)
> �{
> � � � �return platform_driver_register(&at91_i2c_driver);
> �}
> +subsys_initcall(at91_i2c_init);
>
> �static void __exit at91_i2c_exit(void)
> �{
> � � � �platform_driver_unregister(&at91_i2c_driver);
> �}
> -
> -module_init(at91_i2c_init);
> �module_exit(at91_i2c_exit);
>
> �MODULE_AUTHOR("Rick Bronson");
>
>
> --
> Pengutronix e.K. � � � � � � � � � � � � � | Wolfram Sang � � � � � � � �|
> Industrial Linux Solutions � � � � � � � � | http://www.pengutronix.de/ �|
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (GNU/Linux)
>
> iEYEARECAAYFAkv98YYACgkQD27XaX1/VRsvlwCffUOH2qAsWbaG2EmIf1Cl2H+I
> 8P4AoInnCS69XCfq6wIFku1hUgeT8hlG
> =vGcD
> -----END PGP SIGNATURE-----
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Wolfram Sang on
> Anyway, I better understand the subsys_initcall now and applied that
> to the i2c-gpio and my i2c chip driver. That worked perfectly for my

With chip-driver you mean the PMIC? Yes, that is probably needed there, too.
Which driver is it?

> issue. I'd be happy to return a patch of this. Would be this the
> sort of thing that would benefit from a config option? Something

Nope, there is no bigger drawback to this and probably a number of useres
wouldn't know what to select here. Just patch the module_init() away.

Kind regards,

Wolfram

--
Pengutronix e.K. | Wolfram Sang |
Industrial Linux Solutions | http://www.pengutronix.de/ |
From: Ryan Mallon on
Robert Emanuele wrote:
> Hi Wolfram,
>
> I am using the i2c-gpio.c driver, not the i2c-at91 driver. The Atmel
> folks have expressed concerns over their i2c silicon and wrote a gpio
> version.
>
> Anyway, I better understand the subsys_initcall now and applied that
> to the i2c-gpio and my i2c chip driver. That worked perfectly for my
> issue. I'd be happy to return a patch of this. Would be this the
> sort of thing that would benefit from a config option? Something
> like:
>
> #if defined(CONFIG_EARLY_i2C_GPIO)
> subsys_initcall(i2c_gpio_init);
> #else
> module_init(i2c_gpio_init);
> #endif

Looks like this has already been done:
http://www.mail-archive.com/linux-i2c(a)vger.kernel.org/msg03056.html

There was a discussion a while back to make all of the embedded i2c
busses be subsys_initcall since i2c is often a system bus on embedded
devices. Looks the i2c_gpio driver got missed the first time round.

~Ryan

--
Bluewater Systems Ltd - ARM Technology Solution Centre

Ryan Mallon 5 Amuri Park, 404 Barbadoes St
ryan(a)bluewatersys.com PO Box 13 889, Christchurch 8013
http://www.bluewatersys.com New Zealand
Phone: +64 3 3779127 Freecall: Australia 1800 148 751
Fax: +64 3 3779135 USA 1800 261 2934
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Wolfram Sang on

> Looks like this has already been done:
> http://www.mail-archive.com/linux-i2c(a)vger.kernel.org/msg03056.html

Always ask which kernel is used, sigh...

>
> There was a discussion a while back to make all of the embedded i2c
> busses be subsys_initcall since i2c is often a system bus on embedded

Oh, where was that? Can't recall (but couldn't recall that I acked the i2c-gpio
patch above as well ;))

--
Pengutronix e.K. | Wolfram Sang |
Industrial Linux Solutions | http://www.pengutronix.de/ |