[PATCH 3/3] [POWERPC] QE: implement GPIO LIB API

Jochen Friedrich jochen at scram.de
Mon Jan 28 00:42:12 EST 2008


Hi Anton,

> +static void qe_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
> +{
> +	struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
> +	struct port_regs *regs = mm_gc->regs;
> +	u32 pin_mask;
> +	u32 tmp_val;
> +
> +	/* calculate pin location */
> +	pin_mask = (u32) (1 << (NUM_OF_PINS - 1 - gpio));
> +
> +	tmp_val = in_be32(&regs->cpdata);
> +
> +	if (val == 0)
> +		out_be32(&regs->cpdata, ~pin_mask & tmp_val);
> +	else
> +		out_be32(&regs->cpdata, pin_mask | tmp_val);
> +}

I see a possible problem with this (and in the corresponding call in CPM1, as well):

if there is a pin configured as open drain, you might accidently switch this pin to 0
while switching a different pin, if an external device is pulling the pin to 0.

i2c-gpio.c and w1-gpio.c (in -mm) are examples of drivers which use open drain pins
and which would fail if another pin on the same port would be set during a transfer.

Thanks,
Jochen



More information about the Linuxppc-dev mailing list