linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc: i2c-ibm_iic register child nodes
@ 2008-07-08 18:46 Sean MacLennan
  2008-07-08 20:22 ` Sean MacLennan
  2008-07-10 11:49 ` Jean Delvare
  0 siblings, 2 replies; 4+ messages in thread
From: Sean MacLennan @ 2008-07-08 18:46 UTC (permalink / raw)
  To: linuxppc-dev, Jean Delvare

This patch completes the conversion of the IBM IIC driver to an
of-platform driver.

It removes the index from the IBM IIC driver and makes it an unnumbered
driver. It then calls of_register_i2c_devices to properly register all
the child nodes in the DTS.

Signed-off-by: Sean MacLennan <smaclennan@pikatech.com>
---

diff --git a/drivers/i2c/busses/i2c-ibm_iic.c b/drivers/i2c/busses/i2c-ibm_iic.c
index 070f078..651f2f1 100644
--- a/drivers/i2c/busses/i2c-ibm_iic.c
+++ b/drivers/i2c/busses/i2c-ibm_iic.c
@@ -43,6 +43,7 @@
 #include <linux/i2c.h>
 #include <linux/i2c-id.h>
 #include <linux/of_platform.h>
+#include <linux/of_i2c.h>
 
 #include "i2c-ibm_iic.h"
 
@@ -696,7 +697,7 @@ static int __devinit iic_probe(struct of_device *ofdev,
 	struct device_node *np = ofdev->node;
 	struct ibm_iic_private *dev;
 	struct i2c_adapter *adap;
-	const u32 *indexp, *freq;
+	const u32 *freq;
 	int ret;
 
 	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
@@ -707,14 +708,6 @@ static int __devinit iic_probe(struct of_device *ofdev,
 
 	dev_set_drvdata(&ofdev->dev, dev);
 
-	indexp = of_get_property(np, "index", NULL);
-	if (!indexp) {
-		dev_err(&ofdev->dev, "no index specified\n");
-		ret = -EINVAL;
-		goto error_cleanup;
-	}
-	dev->idx = *indexp;
-
 	dev->vaddr = of_iomap(np, 0);
 	if (dev->vaddr == NULL) {
 		dev_err(&ofdev->dev, "failed to iomap device\n");
@@ -757,14 +750,16 @@ static int __devinit iic_probe(struct of_device *ofdev,
 	adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD;
 	adap->algo = &iic_algo;
 	adap->timeout = 1;
-	adap->nr = dev->idx;
 
-	ret = i2c_add_numbered_adapter(adap);
+	ret = i2c_add_adapter(adap);
 	if (ret  < 0) {
 		dev_err(&ofdev->dev, "failed to register i2c adapter\n");
 		goto error_cleanup;
 	}
 
+	/* Now register all the child nodes */
+	of_register_i2c_devices(adap, np);
+
 	dev_info(&ofdev->dev, "using %s mode\n",
 		 dev->fast_mode ? "fast (400 kHz)" : "standard (100 kHz)");
 

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] powerpc: i2c-ibm_iic register child nodes
  2008-07-08 18:46 [PATCH] powerpc: i2c-ibm_iic register child nodes Sean MacLennan
@ 2008-07-08 20:22 ` Sean MacLennan
  2008-07-09  0:04   ` Josh Boyer
  2008-07-10 11:49 ` Jean Delvare
  1 sibling, 1 reply; 4+ messages in thread
From: Sean MacLennan @ 2008-07-08 20:22 UTC (permalink / raw)
  Cc: linuxppc-dev

Update the warp to use the new IBM IIC driver. We no longer need to
register the I2C devices in the platform code.

Also adds a small bugfix for the i2c code if the i2c read fails.

Signed-off-by: Sean MacLennan <smaclennan@pikatech.com>
---

diff --git a/arch/powerpc/platforms/44x/warp.c b/arch/powerpc/platforms/44x/warp.c
index 9565995..960edf8 100644
--- a/arch/powerpc/platforms/44x/warp.c
+++ b/arch/powerpc/platforms/44x/warp.c
@@ -30,18 +30,6 @@ static __initdata struct of_device_id warp_of_bus[] = {
 	{},
 };
 
-static __initdata struct i2c_board_info warp_i2c_info[] = {
-	{ I2C_BOARD_INFO("ad7414", 0x4a) }
-};
-
-static int __init warp_arch_init(void)
-{
-	/* This should go away once support is moved to the dts. */
-	i2c_register_board_info(0, warp_i2c_info, ARRAY_SIZE(warp_i2c_info));
-	return 0;
-}
-machine_arch_initcall(warp, warp_arch_init);
-
 static int __init warp_device_probe(void)
 {
 	of_platform_bus_probe(NULL, warp_of_bus, NULL);
@@ -223,7 +211,7 @@ static void pika_setup_critical_temp(struct i2c_client *client)
 
 	/* These registers are in 1 degree increments. */
 	i2c_smbus_write_byte_data(client, 2, 65); /* Thigh */
-	i2c_smbus_write_byte_data(client, 3, 55); /* Tlow */
+	i2c_smbus_write_byte_data(client, 3,  0); /* Tlow */
 
 	np = of_find_compatible_node(NULL, NULL, "adi,ad7414");
 	if (np == NULL) {
@@ -289,8 +277,15 @@ found_it:
 	printk(KERN_INFO "PIKA DTM thread running.\n");
 
 	while (!kthread_should_stop()) {
-		u16 temp = swab16(i2c_smbus_read_word_data(client, 0));
-		out_be32(fpga + 0x20, temp);
+		int val;
+
+		val = i2c_smbus_read_word_data(client, 0);
+		if (val < 0)
+			dev_dbg(&client->dev, "DTM read temp failed.\n");
+		else {
+			s16 temp = swab16(val);
+			out_be32(fpga + 0x20, temp);
+		}
 
 		pika_dtm_check_fan(fpga);
 

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] powerpc: i2c-ibm_iic register child nodes
  2008-07-08 20:22 ` Sean MacLennan
@ 2008-07-09  0:04   ` Josh Boyer
  0 siblings, 0 replies; 4+ messages in thread
From: Josh Boyer @ 2008-07-09  0:04 UTC (permalink / raw)
  To: Sean MacLennan; +Cc: linuxppc-dev

On Tue, 8 Jul 2008 16:22:40 -0400
Sean MacLennan <smaclennan@pikatech.com> wrote:

> Update the warp to use the new IBM IIC driver. We no longer need to
> register the I2C devices in the platform code.
> 
> Also adds a small bugfix for the i2c code if the i2c read fails.

I'll queue this up after Jean pulls in the i2c patch.

josh

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] powerpc: i2c-ibm_iic register child nodes
  2008-07-08 18:46 [PATCH] powerpc: i2c-ibm_iic register child nodes Sean MacLennan
  2008-07-08 20:22 ` Sean MacLennan
@ 2008-07-10 11:49 ` Jean Delvare
  1 sibling, 0 replies; 4+ messages in thread
From: Jean Delvare @ 2008-07-10 11:49 UTC (permalink / raw)
  To: Sean MacLennan; +Cc: linuxppc-dev, Linux I2C, Ben Dooks

Hi Sean,

On Tue, 8 Jul 2008 14:46:09 -0400, Sean MacLennan wrote:
> This patch completes the conversion of the IBM IIC driver to an
> of-platform driver.
> 
> It removes the index from the IBM IIC driver and makes it an unnumbered
> driver. It then calls of_register_i2c_devices to properly register all
> the child nodes in the DTS.
> 
> Signed-off-by: Sean MacLennan <smaclennan@pikatech.com>
> ---
> 
> diff --git a/drivers/i2c/busses/i2c-ibm_iic.c b/drivers/i2c/busses/i2c-ibm_iic.c
> index 070f078..651f2f1 100644
> --- a/drivers/i2c/busses/i2c-ibm_iic.c
> +++ b/drivers/i2c/busses/i2c-ibm_iic.c
> @@ -43,6 +43,7 @@
>  #include <linux/i2c.h>
>  #include <linux/i2c-id.h>
>  #include <linux/of_platform.h>
> +#include <linux/of_i2c.h>
>  
>  #include "i2c-ibm_iic.h"
>  
> @@ -696,7 +697,7 @@ static int __devinit iic_probe(struct of_device *ofdev,
>  	struct device_node *np = ofdev->node;
>  	struct ibm_iic_private *dev;
>  	struct i2c_adapter *adap;
> -	const u32 *indexp, *freq;
> +	const u32 *freq;
>  	int ret;
>  
>  	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
> @@ -707,14 +708,6 @@ static int __devinit iic_probe(struct of_device *ofdev,
>  
>  	dev_set_drvdata(&ofdev->dev, dev);
>  
> -	indexp = of_get_property(np, "index", NULL);
> -	if (!indexp) {
> -		dev_err(&ofdev->dev, "no index specified\n");
> -		ret = -EINVAL;
> -		goto error_cleanup;
> -	}
> -	dev->idx = *indexp;
> -
>  	dev->vaddr = of_iomap(np, 0);
>  	if (dev->vaddr == NULL) {
>  		dev_err(&ofdev->dev, "failed to iomap device\n");
> @@ -757,14 +750,16 @@ static int __devinit iic_probe(struct of_device *ofdev,
>  	adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD;
>  	adap->algo = &iic_algo;
>  	adap->timeout = 1;
> -	adap->nr = dev->idx;
>  
> -	ret = i2c_add_numbered_adapter(adap);
> +	ret = i2c_add_adapter(adap);
>  	if (ret  < 0) {
>  		dev_err(&ofdev->dev, "failed to register i2c adapter\n");
>  		goto error_cleanup;
>  	}
>  
> +	/* Now register all the child nodes */
> +	of_register_i2c_devices(adap, np);
> +
>  	dev_info(&ofdev->dev, "using %s mode\n",
>  		 dev->fast_mode ? "fast (400 kHz)" : "standard (100 kHz)");
>  

Looks OK. As I already have patches touching
drivers/i2c/busses/i2c-ibm_iic.c in my tree, I'm taking this patch
also. I will push it upstream during the 2.6.27 merge window.

Thanks,
-- 
Jean Delvare

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-07-10 11:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-08 18:46 [PATCH] powerpc: i2c-ibm_iic register child nodes Sean MacLennan
2008-07-08 20:22 ` Sean MacLennan
2008-07-09  0:04   ` Josh Boyer
2008-07-10 11:49 ` Jean Delvare

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).