[PATCH 1/2] Convert i2c-mpc from a platform driver into a of_platform driver, V4

2008-06-30 Thread Jon Smirl
Convert i2c-mpc to an of_platform driver. Utilize the code in drivers/of-i2c.c 
to make i2c modules dynamically loadable by the device tree.

Signed-off-by: Jon Smirl <[EMAIL PROTECTED]>
---

 arch/powerpc/sysdev/fsl_soc.c |  122 -
 drivers/i2c/busses/i2c-mpc.c  |  104 ---
 2 files changed, 60 insertions(+), 166 deletions(-)

diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c
index 3a7054e..ebcec73 100644
--- a/arch/powerpc/sysdev/fsl_soc.c
+++ b/arch/powerpc/sysdev/fsl_soc.c
@@ -414,128 +414,6 @@ err:
 
 arch_initcall(gfar_of_init);
 
-#ifdef CONFIG_I2C_BOARDINFO
-#include 
-struct i2c_driver_device {
-   char*of_device;
-   char*i2c_type;
-};
-
-static struct i2c_driver_device i2c_devices[] __initdata = {
-   {"ricoh,rs5c372a", "rs5c372a"},
-   {"ricoh,rs5c372b", "rs5c372b"},
-   {"ricoh,rv5c386",  "rv5c386"},
-   {"ricoh,rv5c387a", "rv5c387a"},
-   {"dallas,ds1307",  "ds1307"},
-   {"dallas,ds1337",  "ds1337"},
-   {"dallas,ds1338",  "ds1338"},
-   {"dallas,ds1339",  "ds1339"},
-   {"dallas,ds1340",  "ds1340"},
-   {"stm,m41t00", "m41t00"},
-   {"dallas,ds1374",  "rtc-ds1374"},
-};
-
-static int __init of_find_i2c_driver(struct device_node *node,
-struct i2c_board_info *info)
-{
-   int i;
-
-   for (i = 0; i < ARRAY_SIZE(i2c_devices); i++) {
-   if (!of_device_is_compatible(node, i2c_devices[i].of_device))
-   continue;
-   if (strlcpy(info->type, i2c_devices[i].i2c_type,
-   I2C_NAME_SIZE) >= I2C_NAME_SIZE)
-   return -ENOMEM;
-   return 0;
-   }
-   return -ENODEV;
-}
-
-static void __init of_register_i2c_devices(struct device_node *adap_node,
-  int bus_num)
-{
-   struct device_node *node = NULL;
-
-   while ((node = of_get_next_child(adap_node, node))) {
-   struct i2c_board_info info = {};
-   const u32 *addr;
-   int len;
-
-   addr = of_get_property(node, "reg", &len);
-   if (!addr || len < sizeof(int) || *addr > (1 << 10) - 1) {
-   printk(KERN_WARNING "fsl_soc.c: invalid i2c device 
entry\n");
-   continue;
-   }
-
-   info.irq = irq_of_parse_and_map(node, 0);
-   if (info.irq == NO_IRQ)
-   info.irq = -1;
-
-   if (of_find_i2c_driver(node, &info) < 0)
-   continue;
-
-   info.addr = *addr;
-
-   i2c_register_board_info(bus_num, &info, 1);
-   }
-}
-
-static int __init fsl_i2c_of_init(void)
-{
-   struct device_node *np;
-   unsigned int i = 0;
-   struct platform_device *i2c_dev;
-   int ret;
-
-   for_each_compatible_node(np, NULL, "fsl-i2c") {
-   struct resource r[2];
-   struct fsl_i2c_platform_data i2c_data;
-   const unsigned char *flags = NULL;
-
-   memset(&r, 0, sizeof(r));
-   memset(&i2c_data, 0, sizeof(i2c_data));
-
-   ret = of_address_to_resource(np, 0, &r[0]);
-   if (ret)
-   goto err;
-
-   of_irq_to_resource(np, 0, &r[1]);
-
-   i2c_dev = platform_device_register_simple("fsl-i2c", i, r, 2);
-   if (IS_ERR(i2c_dev)) {
-   ret = PTR_ERR(i2c_dev);
-   goto err;
-   }
-
-   i2c_data.device_flags = 0;
-   flags = of_get_property(np, "dfsrr", NULL);
-   if (flags)
-   i2c_data.device_flags |= FSL_I2C_DEV_SEPARATE_DFSRR;
-
-   flags = of_get_property(np, "fsl5200-clocking", NULL);
-   if (flags)
-   i2c_data.device_flags |= FSL_I2C_DEV_CLOCK_5200;
-
-   ret =
-   platform_device_add_data(i2c_dev, &i2c_data,
-sizeof(struct
-   fsl_i2c_platform_data));
-   if (ret)
-   goto unreg;
-
-   of_register_i2c_devices(np, i++);
-   }
-
-   return 0;
-
-unreg:
-   platform_device_unregister(i2c_dev);
-err:
-   return ret;
-}
-
-arch_initcall(fsl_i2c_of_init);
-#endif
 
 #ifdef CONFIG_PPC_83xx
 static int __init mpc83xx_wdt_init(void)
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index a076129..4fdfb62 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -17,7 +17,8 @@
 #include 
 #include 
 #include 
-#include 
+#include 
+#include 
 
 #include 
 #include 
@@ -25,13 +26,13 @@
 #include 
 #include 
 
-#define MPC_I2C_ADDR  0x00
+#define DRV_NAME "mpc-i2c"
+
 #define MPC_I2C_FDR0x04
 #def

Re: [PATCH 1/2] Convert i2c-mpc from a platform driver into a of_platform driver, V4

2008-07-01 Thread Jean Delvare
Hi Jon,

On Mon, 30 Jun 2008 19:01:26 -0400, Jon Smirl wrote:
> Convert i2c-mpc to an of_platform driver. Utilize the code in drivers/of-i2c.c
> to make i2c modules dynamically loadable by the device tree.
> 
> Signed-off-by: Jon Smirl <[EMAIL PROTECTED]>
> ---
> 
>  arch/powerpc/sysdev/fsl_soc.c |  122 
> -
>  drivers/i2c/busses/i2c-mpc.c  |  104 ---
>  2 files changed, 60 insertions(+), 166 deletions(-)
> 
> diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c
> index 3a7054e..ebcec73 100644
> --- a/arch/powerpc/sysdev/fsl_soc.c
> +++ b/arch/powerpc/sysdev/fsl_soc.c
> @@ -414,128 +414,6 @@ err:
>  
>  arch_initcall(gfar_of_init);
>  
> -#ifdef CONFIG_I2C_BOARDINFO
> -#include 
> -struct i2c_driver_device {
> - char*of_device;
> - char*i2c_type;
> -};
> -
> -static struct i2c_driver_device i2c_devices[] __initdata = {
> - {"ricoh,rs5c372a", "rs5c372a"},
> - {"ricoh,rs5c372b", "rs5c372b"},
> - {"ricoh,rv5c386",  "rv5c386"},
> - {"ricoh,rv5c387a", "rv5c387a"},
> - {"dallas,ds1307",  "ds1307"},
> - {"dallas,ds1337",  "ds1337"},
> - {"dallas,ds1338",  "ds1338"},
> - {"dallas,ds1339",  "ds1339"},
> - {"dallas,ds1340",  "ds1340"},
> - {"stm,m41t00", "m41t00"},
> - {"dallas,ds1374",  "rtc-ds1374"},
> -};
> -
> -static int __init of_find_i2c_driver(struct device_node *node,
> -  struct i2c_board_info *info)
> -{
> - int i;
> -
> - for (i = 0; i < ARRAY_SIZE(i2c_devices); i++) {
> - if (!of_device_is_compatible(node, i2c_devices[i].of_device))
> - continue;
> - if (strlcpy(info->type, i2c_devices[i].i2c_type,
> - I2C_NAME_SIZE) >= I2C_NAME_SIZE)
> - return -ENOMEM;
> - return 0;
> - }
> - return -ENODEV;
> -}
> -
> -static void __init of_register_i2c_devices(struct device_node *adap_node,
> -int bus_num)
> -{
> - struct device_node *node = NULL;
> -
> - while ((node = of_get_next_child(adap_node, node))) {
> - struct i2c_board_info info = {};
> - const u32 *addr;
> - int len;
> -
> - addr = of_get_property(node, "reg", &len);
> - if (!addr || len < sizeof(int) || *addr > (1 << 10) - 1) {
> - printk(KERN_WARNING "fsl_soc.c: invalid i2c device 
> entry\n");
> - continue;
> - }
> -
> - info.irq = irq_of_parse_and_map(node, 0);
> - if (info.irq == NO_IRQ)
> - info.irq = -1;
> -
> - if (of_find_i2c_driver(node, &info) < 0)
> - continue;
> -
> - info.addr = *addr;
> -
> - i2c_register_board_info(bus_num, &info, 1);
> - }
> -}
> -
> -static int __init fsl_i2c_of_init(void)
> -{
> - struct device_node *np;
> - unsigned int i = 0;
> - struct platform_device *i2c_dev;
> - int ret;
> -
> - for_each_compatible_node(np, NULL, "fsl-i2c") {
> - struct resource r[2];
> - struct fsl_i2c_platform_data i2c_data;
> - const unsigned char *flags = NULL;
> -
> - memset(&r, 0, sizeof(r));
> - memset(&i2c_data, 0, sizeof(i2c_data));
> -
> - ret = of_address_to_resource(np, 0, &r[0]);
> - if (ret)
> - goto err;
> -
> - of_irq_to_resource(np, 0, &r[1]);
> -
> - i2c_dev = platform_device_register_simple("fsl-i2c", i, r, 2);
> - if (IS_ERR(i2c_dev)) {
> - ret = PTR_ERR(i2c_dev);
> - goto err;
> - }
> -
> - i2c_data.device_flags = 0;
> - flags = of_get_property(np, "dfsrr", NULL);
> - if (flags)
> - i2c_data.device_flags |= FSL_I2C_DEV_SEPARATE_DFSRR;
> -
> - flags = of_get_property(np, "fsl5200-clocking", NULL);
> - if (flags)
> - i2c_data.device_flags |= FSL_I2C_DEV_CLOCK_5200;
> -
> - ret =
> - platform_device_add_data(i2c_dev, &i2c_data,
> -  sizeof(struct
> - fsl_i2c_platform_data));
> - if (ret)
> - goto unreg;
> -
> - of_register_i2c_devices(np, i++);
> - }
> -
> - return 0;
> -
> -unreg:
> - platform_device_unregister(i2c_dev);
> -err:
> - return ret;
> -}
> -
> -arch_initcall(fsl_i2c_of_init);
> -#endif
>  
>  #ifdef CONFIG_PPC_83xx
>  static int __init mpc83xx_wdt_init(void)
> diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
> index a076129..4fdfb62 100644
> --- a/drivers/i2c/busses/i2c-mpc.c
> +++ b/drivers/i2c/busses/i2c-mpc.c
> @@ -17,7 +17,8 @@
>  #include 
>  #include

Re: [PATCH 1/2] Convert i2c-mpc from a platform driver into a of_platform driver, V4

2008-07-02 Thread Jean Delvare
On Wed, 2 Jul 2008 15:33:43 +0200, Wolfram Sang wrote:
> Hi Jean,
> 
> On Tue, Jul 01, 2008 at 06:14:44PM +0200, Jean Delvare wrote:
> 
> > Applied, after fixing the patch so that it applies, fixing it again so
> > that it is correct in the polling case, and fixing it again to make it
> > pass checkpatch.pl.
> So, it cannot be applied directly? :(
> 
> Could you repost the correct version perhaps? I'd like to test it, but
> can't find it at http://khali.linux-fr.org/devel/linux-2.6/jdelvare-i2c/
> (because it is scheduled for 2.6.27?).

It's at:
http://khali.linux-fr.org/devel/linux-2.6/jdelvare-i2c/i2c-mpc-convert-to-an-of_platform-driver.patch

It was simply a couple days since I had updated this public directory,
sorry.

-- 
Jean Delvare
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH 1/2] Convert i2c-mpc from a platform driver into a of_platform driver, V4

2008-07-09 Thread Grant Likely
On Mon, Jun 30, 2008 at 5:01 PM, Jon Smirl <[EMAIL PROTECTED]> wrote:
> Convert i2c-mpc to an of_platform driver. Utilize the code in 
> drivers/of-i2c.c to make i2c modules dynamically loadable by the device tree.

Timur, can you please test this one on an 83xx platform?  It works on
5200, but I want to make sure 83xx doesn't break before I pick it up.

Thanks,
g.

>
> Signed-off-by: Jon Smirl <[EMAIL PROTECTED]>
> ---
>
>  arch/powerpc/sysdev/fsl_soc.c |  122 
> -
>  drivers/i2c/busses/i2c-mpc.c  |  104 ---
>  2 files changed, 60 insertions(+), 166 deletions(-)
>
> diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c
> index 3a7054e..ebcec73 100644
> --- a/arch/powerpc/sysdev/fsl_soc.c
> +++ b/arch/powerpc/sysdev/fsl_soc.c
> @@ -414,128 +414,6 @@ err:
>
>  arch_initcall(gfar_of_init);
>
> -#ifdef CONFIG_I2C_BOARDINFO
> -#include 
> -struct i2c_driver_device {
> -   char*of_device;
> -   char*i2c_type;
> -};
> -
> -static struct i2c_driver_device i2c_devices[] __initdata = {
> -   {"ricoh,rs5c372a", "rs5c372a"},
> -   {"ricoh,rs5c372b", "rs5c372b"},
> -   {"ricoh,rv5c386",  "rv5c386"},
> -   {"ricoh,rv5c387a", "rv5c387a"},
> -   {"dallas,ds1307",  "ds1307"},
> -   {"dallas,ds1337",  "ds1337"},
> -   {"dallas,ds1338",  "ds1338"},
> -   {"dallas,ds1339",  "ds1339"},
> -   {"dallas,ds1340",  "ds1340"},
> -   {"stm,m41t00", "m41t00"},
> -   {"dallas,ds1374",  "rtc-ds1374"},
> -};
> -
> -static int __init of_find_i2c_driver(struct device_node *node,
> -struct i2c_board_info *info)
> -{
> -   int i;
> -
> -   for (i = 0; i < ARRAY_SIZE(i2c_devices); i++) {
> -   if (!of_device_is_compatible(node, i2c_devices[i].of_device))
> -   continue;
> -   if (strlcpy(info->type, i2c_devices[i].i2c_type,
> -   I2C_NAME_SIZE) >= I2C_NAME_SIZE)
> -   return -ENOMEM;
> -   return 0;
> -   }
> -   return -ENODEV;
> -}
> -
> -static void __init of_register_i2c_devices(struct device_node *adap_node,
> -  int bus_num)
> -{
> -   struct device_node *node = NULL;
> -
> -   while ((node = of_get_next_child(adap_node, node))) {
> -   struct i2c_board_info info = {};
> -   const u32 *addr;
> -   int len;
> -
> -   addr = of_get_property(node, "reg", &len);
> -   if (!addr || len < sizeof(int) || *addr > (1 << 10) - 1) {
> -   printk(KERN_WARNING "fsl_soc.c: invalid i2c device 
> entry\n");
> -   continue;
> -   }
> -
> -   info.irq = irq_of_parse_and_map(node, 0);
> -   if (info.irq == NO_IRQ)
> -   info.irq = -1;
> -
> -   if (of_find_i2c_driver(node, &info) < 0)
> -   continue;
> -
> -   info.addr = *addr;
> -
> -   i2c_register_board_info(bus_num, &info, 1);
> -   }
> -}
> -
> -static int __init fsl_i2c_of_init(void)
> -{
> -   struct device_node *np;
> -   unsigned int i = 0;
> -   struct platform_device *i2c_dev;
> -   int ret;
> -
> -   for_each_compatible_node(np, NULL, "fsl-i2c") {
> -   struct resource r[2];
> -   struct fsl_i2c_platform_data i2c_data;
> -   const unsigned char *flags = NULL;
> -
> -   memset(&r, 0, sizeof(r));
> -   memset(&i2c_data, 0, sizeof(i2c_data));
> -
> -   ret = of_address_to_resource(np, 0, &r[0]);
> -   if (ret)
> -   goto err;
> -
> -   of_irq_to_resource(np, 0, &r[1]);
> -
> -   i2c_dev = platform_device_register_simple("fsl-i2c", i, r, 2);
> -   if (IS_ERR(i2c_dev)) {
> -   ret = PTR_ERR(i2c_dev);
> -   goto err;
> -   }
> -
> -   i2c_data.device_flags = 0;
> -   flags = of_get_property(np, "dfsrr", NULL);
> -   if (flags)
> -   i2c_data.device_flags |= FSL_I2C_DEV_SEPARATE_DFSRR;
> -
> -   flags = of_get_property(np, "fsl5200-clocking", NULL);
> -   if (flags)
> -   i2c_data.device_flags |= FSL_I2C_DEV_CLOCK_5200;
> -
> -   ret =
> -   platform_device_add_data(i2c_dev, &i2c_data,
> -sizeof(struct
> -   fsl_i2c_platform_data));
> -   if (ret)
> -   goto unreg;
> -
> -   of_register_i2c_devices(np, i++);
> -   }
> -
> -   return 0;
> -
> -unreg:
> -   platform_device_unregister(i2c_dev);
> -err:
> -   return ret;
> -}
> -
> -arch_initcall(fsl_i2c_of_

Re: [PATCH 1/2] Convert i2c-mpc from a platform driver into a of_platform driver, V4

2008-07-10 Thread Timur Tabi


On Jul 9, 2008, at 1:22 PM, Grant Likely wrote:


On Mon, Jun 30, 2008 at 5:01 PM, Jon Smirl <[EMAIL PROTECTED]> wrote:
Convert i2c-mpc to an of_platform driver. Utilize the code in  
drivers/of-i2c.c to make i2c modules dynamically loadable by the  
device tree.


Timur, can you please test this one on an 83xx platform?  It works on
5200, but I want to make sure 83xx doesn't break before I pick it up.


I'm on vacation this week, so I'll have to deal with it next week,  
after I've handled higher-priority issues.


___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH 1/2] Convert i2c-mpc from a platform driver into a of_platform driver, V4

2008-07-11 Thread Grant Likely
On Thu, Jul 10, 2008 at 12:36:58PM -0400, Timur Tabi wrote:
>
> On Jul 9, 2008, at 1:22 PM, Grant Likely wrote:
>
>> On Mon, Jun 30, 2008 at 5:01 PM, Jon Smirl <[EMAIL PROTECTED]> wrote:
>>> Convert i2c-mpc to an of_platform driver. Utilize the code in  
>>> drivers/of-i2c.c to make i2c modules dynamically loadable by the  
>>> device tree.
>>
>> Timur, can you please test this one on an 83xx platform?  It works on
>> 5200, but I want to make sure 83xx doesn't break before I pick it up.
>
> I'm on vacation this week, so I'll have to deal with it next week, after 
> I've handled higher-priority issues.

Kumar, is there anyone else who can test this out before the merge
window opens?

OTOH, it should be pretty safe.  It's been tested on 5200.  I could just
pick it up without 8xxx testing if you're okay with it.

g.
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH 1/2] Convert i2c-mpc from a platform driver into a of_platform driver, V4

2008-07-11 Thread Anton Vorontsov
On Fri, Jul 11, 2008 at 12:12:14PM -0600, Grant Likely wrote:
> On Thu, Jul 10, 2008 at 12:36:58PM -0400, Timur Tabi wrote:
> >
> > On Jul 9, 2008, at 1:22 PM, Grant Likely wrote:
> >
> >> On Mon, Jun 30, 2008 at 5:01 PM, Jon Smirl <[EMAIL PROTECTED]> wrote:
> >>> Convert i2c-mpc to an of_platform driver. Utilize the code in  
> >>> drivers/of-i2c.c to make i2c modules dynamically loadable by the  
> >>> device tree.
> >>
> >> Timur, can you please test this one on an 83xx platform?  It works on
> >> 5200, but I want to make sure 83xx doesn't break before I pick it up.
> >
> > I'm on vacation this week, so I'll have to deal with it next week, after 
> > I've handled higher-priority issues.
> 
> Kumar, is there anyone else who can test this out before the merge
> window opens?

FWIW, they seem to work for me. At least RTC still works.


p.s. [1/2] conflicts with fsl_soc.c. And these patches will
conflict a bit more (now with of_i2c.c), if/when
"[PATCH] of/i2c: don't pass -1 to irq_dispose_mapping, otherwise kernel
kernel will oops"

will be applied to 2.6.26.

-- 
Anton Vorontsov
email: [EMAIL PROTECTED]
irc://irc.freenode.net/bd2
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH 1/2] Convert i2c-mpc from a platform driver into a of_platform driver, V4

2008-07-11 Thread Grant Likely
On Fri, Jul 11, 2008 at 10:45:56PM +0400, Anton Vorontsov wrote:
> On Fri, Jul 11, 2008 at 12:12:14PM -0600, Grant Likely wrote:
> > On Thu, Jul 10, 2008 at 12:36:58PM -0400, Timur Tabi wrote:
> > >
> > > On Jul 9, 2008, at 1:22 PM, Grant Likely wrote:
> > >
> > >> On Mon, Jun 30, 2008 at 5:01 PM, Jon Smirl <[EMAIL PROTECTED]> wrote:
> > >>> Convert i2c-mpc to an of_platform driver. Utilize the code in  
> > >>> drivers/of-i2c.c to make i2c modules dynamically loadable by the  
> > >>> device tree.
> > >>
> > >> Timur, can you please test this one on an 83xx platform?  It works on
> > >> 5200, but I want to make sure 83xx doesn't break before I pick it up.
> > >
> > > I'm on vacation this week, so I'll have to deal with it next week, after 
> > > I've handled higher-priority issues.
> > 
> > Kumar, is there anyone else who can test this out before the merge
> > window opens?
> 
> FWIW, they seem to work for me. At least RTC still works.

Good enough for me.  Unless someone screams really loudly I'm going to
go ahead and pick it up.

Cheers,
g.
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [i2c] [PATCH 1/2] Convert i2c-mpc from a platform driver into a of_platform driver, V4

2008-07-02 Thread Wolfram Sang
Hi Jean,

On Tue, Jul 01, 2008 at 06:14:44PM +0200, Jean Delvare wrote:

> Applied, after fixing the patch so that it applies, fixing it again so
> that it is correct in the polling case, and fixing it again to make it
> pass checkpatch.pl.
So, it cannot be applied directly? :(

Could you repost the correct version perhaps? I'd like to test it, but
can't find it at http://khali.linux-fr.org/devel/linux-2.6/jdelvare-i2c/
(because it is scheduled for 2.6.27?).

All the best,

   Wolfram

-- 
  Dipl.-Ing. Wolfram Sang | http://www.pengutronix.de
 Pengutronix - Linux Solutions for Science and Industry


signature.asc
Description: Digital signature
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev