Re: [RESEND PATCH 6/7] mfd: cros_ec: Instantiate sub-devices from device tree

2014-08-22 Thread Javier Martinez Canillas
Hello Lee,

On 08/21/2014 04:25 PM, Lee Jones wrote:
  
  static const struct mfd_cell cros_devs[] = {
 -{
 -.name = cros-ec-keyb,
 -.id = 1,
 -.of_compatible = google,cros-ec-keyb,
 -},
 -{
 -.name = cros-ec-i2c-tunnel,
 -.id = 2,
 -.of_compatible = google,cros-ec-i2c-tunnel,
 -},
  };
 
 Why are you keeping this round if it's empty?


Right, I'll just remove it.

  }
 +#ifdef CONFIG_OF
 +/*
 + * Add sub-devices declared in the device tree.  NOTE they should NOT be
 + * declared in cros_devs
 + */
 +for_each_child_of_node(dev-of_node, node) {
 +char name[128];
 +struct mfd_cell cell = {
 +.id = 0,
 +.name = name,
 +};
 +
 +if (of_modalias_node(node, name, sizeof(name))  0) {
 +dev_err(dev, modalias failure on %s\n,
 +node-full_name);
 +continue;
 +}
 +dev_dbg(dev, adding MFD sub-device %s\n, node-name);
 +cell.of_compatible = of_get_property(node, compatible, NULL);
 +err = mfd_add_devices(dev, ++id, cell, 1, NULL, ec_dev-irq,
 +  NULL);
 +if (err)
 +dev_err(dev, fail to add %s\n, node-full_name);
 +}
 +#endif
 
 This is grim!
 
 Why don't you use of_platform_populate()?


Indeed, I think it may just work and all these is not needed.

Thanks for your feedback and best regards,
Javier
--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RESEND PATCH 6/7] mfd: cros_ec: Instantiate sub-devices from device tree

2014-08-21 Thread Lee Jones
On Wed, 20 Aug 2014, Javier Martinez Canillas wrote:

 From: Todd Broch tbr...@chromium.org
 
 If the EC device tree node has sub-nodes, try to instantiate them as
 MFD sub-devices.  We can configure the EC features provided by the board.
 
 Signed-off-by: Todd Broch tbr...@chromium.org
 Signed-off-by: Javier Martinez Canillas javier.marti...@collabora.co.uk
 ---
  drivers/mfd/cros_ec.c | 40 ++--
  1 file changed, 30 insertions(+), 10 deletions(-)
 
 diff --git a/drivers/mfd/cros_ec.c b/drivers/mfd/cros_ec.c
 index 634c434..96c926c 100644
 --- a/drivers/mfd/cros_ec.c
 +++ b/drivers/mfd/cros_ec.c
 @@ -21,6 +21,7 @@
  #include linux/slab.h
  #include linux/module.h
  #include linux/mfd/core.h
 +#include linux/of_platform.h
  #include linux/mfd/cros_ec.h
  #include linux/mfd/cros_ec_commands.h
  #include linux/delay.h
 @@ -109,22 +110,16 @@ int cros_ec_cmd_xfer(struct cros_ec_device *ec_dev,
  EXPORT_SYMBOL(cros_ec_cmd_xfer);
  
  static const struct mfd_cell cros_devs[] = {
 - {
 - .name = cros-ec-keyb,
 - .id = 1,
 - .of_compatible = google,cros-ec-keyb,
 - },
 - {
 - .name = cros-ec-i2c-tunnel,
 - .id = 2,
 - .of_compatible = google,cros-ec-i2c-tunnel,
 - },
  };

Why are you keeping this round if it's empty?

  int cros_ec_register(struct cros_ec_device *ec_dev)
  {
   struct device *dev = ec_dev-dev;
   int err = 0;
 +#ifdef CONFIG_OF
 + struct device_node *node;
 + int id = ARRAY_SIZE(cros_devs);
 +#endif
  
   if (ec_dev-din_size) {
   ec_dev-din = devm_kzalloc(dev, ec_dev-din_size, GFP_KERNEL);
 @@ -146,6 +141,31 @@ int cros_ec_register(struct cros_ec_device *ec_dev)
   dev_err(dev, failed to add mfd devices\n);
   return err;
   }
 +#ifdef CONFIG_OF
 + /*
 +  * Add sub-devices declared in the device tree.  NOTE they should NOT be
 +  * declared in cros_devs
 +  */
 + for_each_child_of_node(dev-of_node, node) {
 + char name[128];
 + struct mfd_cell cell = {
 + .id = 0,
 + .name = name,
 + };
 +
 + if (of_modalias_node(node, name, sizeof(name))  0) {
 + dev_err(dev, modalias failure on %s\n,
 + node-full_name);
 + continue;
 + }
 + dev_dbg(dev, adding MFD sub-device %s\n, node-name);
 + cell.of_compatible = of_get_property(node, compatible, NULL);
 + err = mfd_add_devices(dev, ++id, cell, 1, NULL, ec_dev-irq,
 +   NULL);
 + if (err)
 + dev_err(dev, fail to add %s\n, node-full_name);
 + }
 +#endif

This is grim!

Why don't you use of_platform_populate()?

   dev_info(dev, Chrome EC device registered\n);
  

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RESEND PATCH 6/7] mfd: cros_ec: Instantiate sub-devices from device tree

2014-08-20 Thread Javier Martinez Canillas
From: Todd Broch tbr...@chromium.org

If the EC device tree node has sub-nodes, try to instantiate them as
MFD sub-devices.  We can configure the EC features provided by the board.

Signed-off-by: Todd Broch tbr...@chromium.org
Signed-off-by: Javier Martinez Canillas javier.marti...@collabora.co.uk
---
 drivers/mfd/cros_ec.c | 40 ++--
 1 file changed, 30 insertions(+), 10 deletions(-)

diff --git a/drivers/mfd/cros_ec.c b/drivers/mfd/cros_ec.c
index 634c434..96c926c 100644
--- a/drivers/mfd/cros_ec.c
+++ b/drivers/mfd/cros_ec.c
@@ -21,6 +21,7 @@
 #include linux/slab.h
 #include linux/module.h
 #include linux/mfd/core.h
+#include linux/of_platform.h
 #include linux/mfd/cros_ec.h
 #include linux/mfd/cros_ec_commands.h
 #include linux/delay.h
@@ -109,22 +110,16 @@ int cros_ec_cmd_xfer(struct cros_ec_device *ec_dev,
 EXPORT_SYMBOL(cros_ec_cmd_xfer);
 
 static const struct mfd_cell cros_devs[] = {
-   {
-   .name = cros-ec-keyb,
-   .id = 1,
-   .of_compatible = google,cros-ec-keyb,
-   },
-   {
-   .name = cros-ec-i2c-tunnel,
-   .id = 2,
-   .of_compatible = google,cros-ec-i2c-tunnel,
-   },
 };
 
 int cros_ec_register(struct cros_ec_device *ec_dev)
 {
struct device *dev = ec_dev-dev;
int err = 0;
+#ifdef CONFIG_OF
+   struct device_node *node;
+   int id = ARRAY_SIZE(cros_devs);
+#endif
 
if (ec_dev-din_size) {
ec_dev-din = devm_kzalloc(dev, ec_dev-din_size, GFP_KERNEL);
@@ -146,6 +141,31 @@ int cros_ec_register(struct cros_ec_device *ec_dev)
dev_err(dev, failed to add mfd devices\n);
return err;
}
+#ifdef CONFIG_OF
+   /*
+* Add sub-devices declared in the device tree.  NOTE they should NOT be
+* declared in cros_devs
+*/
+   for_each_child_of_node(dev-of_node, node) {
+   char name[128];
+   struct mfd_cell cell = {
+   .id = 0,
+   .name = name,
+   };
+
+   if (of_modalias_node(node, name, sizeof(name))  0) {
+   dev_err(dev, modalias failure on %s\n,
+   node-full_name);
+   continue;
+   }
+   dev_dbg(dev, adding MFD sub-device %s\n, node-name);
+   cell.of_compatible = of_get_property(node, compatible, NULL);
+   err = mfd_add_devices(dev, ++id, cell, 1, NULL, ec_dev-irq,
+ NULL);
+   if (err)
+   dev_err(dev, fail to add %s\n, node-full_name);
+   }
+#endif
 
dev_info(dev, Chrome EC device registered\n);
 
-- 
2.0.1

--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 6/7] mfd: cros_ec: Instantiate sub-devices from device tree

2014-07-29 Thread Andreas Färber
Hi Javier,

Am 28.07.2014 14:19, schrieb Javier Martinez Canillas:
 From: Todd Broch tbr...@chromium.org
 
 If the EC device tree node has sub-nodes, try to instantiate them as
 MFD sub-devices.  We can configure the EC features provided by the board.
 
 Signed-off-by: Todd Broch tbr...@chromium.org

This is provoking the blunt question: What sub-devices is it good for?
I.e., do you have a matching DT patchset that adds such devices?

In particular I'm wondering whether that would help with the tps65090 on
Spring? It's a power-regulator sub-node of cros-ec in 3.8.

Thanks,
Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 6/7] mfd: cros_ec: Instantiate sub-devices from device tree

2014-07-29 Thread Javier Martinez Canillas
Hello Andreas,

On 07/29/2014 02:34 PM, Andreas Färber wrote:
 Hi Javier,
 
 Am 28.07.2014 14:19, schrieb Javier Martinez Canillas:
 From: Todd Broch tbr...@chromium.org
 
 If the EC device tree node has sub-nodes, try to instantiate them as
 MFD sub-devices.  We can configure the EC features provided by the board.
 
 Signed-off-by: Todd Broch tbr...@chromium.org
 
 This is provoking the blunt question: What sub-devices is it good for?
 I.e., do you have a matching DT patchset that adds such devices?
 

For Peach Pit and Pi, the matching DTS changes is [0]. But answering your
question it is to instantiate the subdevices that can be child nodes of either
cros-ec-spi or cros-ec-i2c. So for the devices that are directly connected to
the EC Cortex-M through i2c.

 In particular I'm wondering whether that would help with the tps65090 on
 Spring? It's a power-regulator sub-node of cros-ec in 3.8.
 

Spring is a little more complicated since the EC in Spring don't have the full
EC_CMD_I2C_PASSTHRU. So the downstream Chrome OS 3.8 kernel has a forked
tps65090 driver (drivers/regulator/cros_ec-tps65090.c) that talks directly with
the cros_ec MFD driver, you can get more info from [1] in the About Spring
section.

 Thanks,
 Andreas
 

Best regards,
Javier

[0]:
https://git.kernel.org/cgit/linux/kernel/git/kgene/linux-samsung.git/commit/?h=for-nextid=8060098bbb564d27a287057a93d4fe3bfd266290
[1]: http://code.google.com/p/chromium/issues/detail?id=391797
--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 6/7] mfd: cros_ec: Instantiate sub-devices from device tree

2014-07-28 Thread Javier Martinez Canillas
From: Todd Broch tbr...@chromium.org

If the EC device tree node has sub-nodes, try to instantiate them as
MFD sub-devices.  We can configure the EC features provided by the board.

Signed-off-by: Todd Broch tbr...@chromium.org
---
 drivers/mfd/cros_ec.c | 40 ++--
 1 file changed, 30 insertions(+), 10 deletions(-)

diff --git a/drivers/mfd/cros_ec.c b/drivers/mfd/cros_ec.c
index 634c434..96c926c 100644
--- a/drivers/mfd/cros_ec.c
+++ b/drivers/mfd/cros_ec.c
@@ -21,6 +21,7 @@
 #include linux/slab.h
 #include linux/module.h
 #include linux/mfd/core.h
+#include linux/of_platform.h
 #include linux/mfd/cros_ec.h
 #include linux/mfd/cros_ec_commands.h
 #include linux/delay.h
@@ -109,22 +110,16 @@ int cros_ec_cmd_xfer(struct cros_ec_device *ec_dev,
 EXPORT_SYMBOL(cros_ec_cmd_xfer);
 
 static const struct mfd_cell cros_devs[] = {
-   {
-   .name = cros-ec-keyb,
-   .id = 1,
-   .of_compatible = google,cros-ec-keyb,
-   },
-   {
-   .name = cros-ec-i2c-tunnel,
-   .id = 2,
-   .of_compatible = google,cros-ec-i2c-tunnel,
-   },
 };
 
 int cros_ec_register(struct cros_ec_device *ec_dev)
 {
struct device *dev = ec_dev-dev;
int err = 0;
+#ifdef CONFIG_OF
+   struct device_node *node;
+   int id = ARRAY_SIZE(cros_devs);
+#endif
 
if (ec_dev-din_size) {
ec_dev-din = devm_kzalloc(dev, ec_dev-din_size, GFP_KERNEL);
@@ -146,6 +141,31 @@ int cros_ec_register(struct cros_ec_device *ec_dev)
dev_err(dev, failed to add mfd devices\n);
return err;
}
+#ifdef CONFIG_OF
+   /*
+* Add sub-devices declared in the device tree.  NOTE they should NOT be
+* declared in cros_devs
+*/
+   for_each_child_of_node(dev-of_node, node) {
+   char name[128];
+   struct mfd_cell cell = {
+   .id = 0,
+   .name = name,
+   };
+
+   if (of_modalias_node(node, name, sizeof(name))  0) {
+   dev_err(dev, modalias failure on %s\n,
+   node-full_name);
+   continue;
+   }
+   dev_dbg(dev, adding MFD sub-device %s\n, node-name);
+   cell.of_compatible = of_get_property(node, compatible, NULL);
+   err = mfd_add_devices(dev, ++id, cell, 1, NULL, ec_dev-irq,
+ NULL);
+   if (err)
+   dev_err(dev, fail to add %s\n, node-full_name);
+   }
+#endif
 
dev_info(dev, Chrome EC device registered\n);
 
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html