Re: [PATCH 1/2] cs5535-gpio: add AMD CS5535/CS5536 GPIO driver support
From: Tobias MÃller
Date: Thu Jun 11 2009 - 16:12:18 EST
>> Â#define DRV_NAME "cs5535-gpio"
>> Â#define GPIO_BAR 1
>> +#define GPIO_DEFAULT_MASK 0x0B003C66
>
> Where does this mask of available GPIOs originate from?
I had a comment in my original patch:
/**
* Some GPIO pins
* 31-29,23 : reserved (always mask out)
* 28 : Power Button
* 26 : PME#
* 22-16 : LPC
* 14,15 : SMBus
* 9,8 : UART1
* 7 : PCI INTB
* 3,4 : UART2/DDC
* 2 : IDE_IRQ0
* 1 : AC_BEEP
* 0 : PCI INTA
*
* If a mask was not specified, be conservative and only allow:
* 1,2,5,6,10-13,24,25,27
*/
I'll add this in my patch to clear it out.
>> + Â Â spin_lock_irqsave(&chip->lock, flags);
>> +
>> + Â Â /* check if this pin is available */
>> + Â Â if ((mask & (1 << offset)) == 0) {
>> + Â Â Â Â Â Â printk(KERN_INFO DRV_NAME
>> + Â Â Â Â Â Â Â Â Â Â": pin %u is not available (check mask)\n",
>> offset);
>> + Â Â Â Â Â Â return -EINVAL;
>
> There's a locking error here; you really want to spin_unlock_irqrestore
> before returning.
Thanks.
>> + Â Â /* disable output aux 1 & 2 on this pin */
>> + Â Â __cs5535_gpio_clear(chip, offset, GPIO_OUTPUT_AUX1);
>> + Â Â __cs5535_gpio_clear(chip, offset, GPIO_OUTPUT_AUX2);
>> +
>> + Â Â /* disable input aux 1 on this pin */
>> + Â Â __cs5535_gpio_clear(chip, offset, GPIO_INPUT_AUX1);
>> +
>> + Â Â /* disable output */
>> + Â Â __cs5535_gpio_clear(chip, offset, GPIO_OUTPUT_ENABLE);
>> +
>> + Â Â /* enable input */
>> + Â Â __cs5535_gpio_set(chip, offset, GPIO_INPUT_ENABLE);
>
> I don't think this is the right place for all of this. ÂYour earlier
> email mentioned disabling OUT_AUX{1,2} for outputs, and IN_AUX for
> inputs. ÂI'm fine with doing that here, but I don't see why you're also
> disabling output and enabling input by default.
I mentioned this in an ealier mail too. When I request the GPIO from
userspace the direction file always contains "in", so I thought
this is the standard direction after resetting as I should be in a
defined state after requesting. But I didn't found anything
about this in GPIO lib documentation, so I would be fine to change
this if there is any common default behavoir.
>> - Â Â Â Â Â Â .ngpio = 28,
>> + Â Â Â Â Â Â .ngpio = 32,
>
> Since GPIOs 29-31 aren't externally available, and 28 is
> unavailable anyways, shouldn't we just set ngpio to 28?
I thought that 32 is in consistency with the datasheet as it always
talks about 32 GPIO pins.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/