Skip to contentSkip to conversation

gpio: pca953x: Don't flip bits on PCA957x GPIO expanders when probing them.

PATCH In review Graeme Smecher 3 participants 7 messages Sep 13, 2013 – Sep 23, 2013 GPIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gpio: pca953x: Don't flip bits on PCA957x GPIO expanders when probing them.

The pca957x driver supports a handful of I2C GPIO expanders from NXP, Maxim, and TI. For the PCA9574 and PCA9575 devices only, the driver resets the GPIO level and direction in the pca957x_probe function. This seems like the wrong thing to do, since it can cause hardware bit twiddles during warm reboots when the chip state and reset values don't match.

This kind of initialization is best left upstream (in a bootloader) or downstream (in userspace). It's also an inconsistency across devices supported by this driver.

This patch is NOT boot-tested: the SoC I'm using is stuck on 2.6.37, and the patch doesn't apply trivially.

---
 drivers/gpio/gpio-pca953x.c |   11 -----------
 1 file changed, 11 deletions(-)
drivers/gpio/gpio-pca953x.c +0 -11
index cdd1aa1..6e48c07 100644
@@ -683,17 +683,6 @@ static int device_pca957x_init(struct pca953x_chip *chip, u32 invert)
 	int ret;
 	u8 val[MAX_BANK];
 
-	/* Let every port in proper state, that could save power */
-	memset(val, 0, NBANK(chip));
-	pca953x_write_regs(chip, PCA957X_PUPD, val);
-	memset(val, 0xFF, NBANK(chip));
-	pca953x_write_regs(chip, PCA957X_CFG, val);
-	memset(val, 0, NBANK(chip));
-	pca953x_write_regs(chip, PCA957X_OUT, val);
-
-	ret = pca953x_read_regs(chip, PCA957X_IN, val);
-	if (ret)
-		goto out;
 	ret = pca953x_read_regs(chip, PCA957X_OUT, chip->reg_output);
 	if (ret)
 		goto out;
Signature · 1 line
1.7.10.4
#1 lore raw
Quoted 10 lines · Graeme Smecher

The pca957x driver supports a handful of I2C GPIO expanders from NXP, Maxim, and TI. For the PCA9574 and PCA9575 devices only, the driver resets the GPIO level and direction in the pca957x_probe function. This seems like the wrong thing to do, since it can cause hardware bit twiddles during warm reboots when the chip state and reset values don't match.

This kind of initialization is best left upstream (in a bootloader) or downstream (in userspace). It's also an inconsistency across devices supported by this driver.

Quoted 5 lines

This patch is NOT boot-tested: the SoC I'm using is stuck on 2.6.37, and the patch doesn't apply trivially.

Looks like you're deleting code from Gregory CLEMENT, Gregory what do you say about this?

Yours,
Linus Walleij

#2 lore raw

Hi Linus,

Quoted 13 lines · Linus Walleij
Quoted 10 lines · Graeme Smecher

The pca957x driver supports a handful of I2C GPIO expanders from NXP, Maxim, and TI. For the PCA9574 and PCA9575 devices only, the driver resets the GPIO level and direction in the pca957x_probe function. This seems like the wrong thing to do, since it can cause hardware bit twiddles during warm reboots when the chip state and reset values don't match.

This kind of initialization is best left upstream (in a bootloader) or downstream (in userspace). It's also an inconsistency across devices supported by this driver.

Quoted 8 lines
Quoted 5 lines

This patch is NOT boot-tested: the SoC I'm using is stuck on 2.6.37, and the patch doesn't apply trivially.

Looks like you're deleting code from Gregory CLEMENT, Gregory what do you say about this?

Thanks to point me this patch, I didn't have noticed it. The code being removed is mine because I change it to take care of the multiple bankd. I didn't change the functionality. The original code was from Haojian Zhuang so as he gave his acked-by it should be fine.

However could you wait for until the end of this week end, to let me test it on a real hardware?

Thanks,

Gregory

Signature · 4 lines
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
#3 lore raw
Quoted 2 lines · Gregory CLEMENT

However could you wait for until the end of this week end, to let me test it on a real hardware?

Sure, no hurry.

Yours,
Linus Walleij

Tested-by
#4 lore raw

Hi,

Quoted 8 lines · Linus Walleij
Quoted 2 lines · Gregory CLEMENT

However could you wait for until the end of this week end, to let me test it on a real hardware?

Sure, no hurry.

I tested the patch using the GPIO box connected to the Mirabox and I didn't see any regression. So you can add my:

Thanks,

Quoted 3 lines

Yours,
Linus Walleij

Signature · 4 lines
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
#5 lore raw
In reply to Graeme Smecher
Quoted 10 lines · Graeme Smecher

The pca957x driver supports a handful of I2C GPIO expanders from NXP, Maxim, and TI. For the PCA9574 and PCA9575 devices only, the driver resets the GPIO level and direction in the pca957x_probe function. This seems like the wrong thing to do, since it can cause hardware bit twiddles during warm reboots when the chip state and reset values don't match.

This kind of initialization is best left upstream (in a bootloader) or downstream (in userspace). It's also an inconsistency across devices supported by this driver.

Quoted 5 lines

This patch is NOT boot-tested: the SoC I'm using is stuck on 2.6.37, and the patch doesn't apply trivially.

Patch applied with Gregory's Tested-by tag!

Yours,
Linus Walleij

#6 lore raw

Hi,

Quoted 13 lines · Linus Walleij
Quoted 10 lines · Graeme Smecher

The pca957x driver supports a handful of I2C GPIO expanders from NXP, Maxim, and TI. For the PCA9574 and PCA9575 devices only, the driver resets the GPIO level and direction in the pca957x_probe function. This seems like the wrong thing to do, since it can cause hardware bit twiddles during warm reboots when the chip state and reset values don't match.

This kind of initialization is best left upstream (in a bootloader) or downstream (in userspace). It's also an inconsistency across devices supported by this driver.

Quoted 6 lines
Quoted 5 lines

This patch is NOT boot-tested: the SoC I'm using is stuck on 2.6.37, and the patch doesn't apply trivially.

Patch applied with Gregory's Tested-by tag!

Thanks all!

cheers,
Graeme