Re: GPIO support for HTC Dream

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Ryan Mallon
Date: Thursday, December 10, 2009 - 12:49 pm

Pavel Machek wrote:

Its not much work to go from generic gpio (which you have now) to
gpiolib, and in the end it will make the code simpler, more extensible,
you get sysfs access for free, etc. You will need to wrap up your
gpio_chip struct as I suggested:

struct msm_gpio_chip {
	struct gpio_chip;
	
	/* MSM/Dream/Trout(?) bits */
};
#define to_msm_gpio_chip(c, container_of(c, struct msm_gpio_chip, chip)

As an aside, I don't quite understand the naming conventions here. Is
the gpio stuff generic to the MSM chip, or specific to the Dream/Trout
board? It would be good if the gpio implementation could be completely
generic to the chip, and all the board specific bits be kept in the
board specific files.

You gpio_set, get, direction, etc functions become static:

static gpio_set_value(struct gpio_chip *chip, unsigned offset, int val)
{
	struct msm_gpio_chip *msm_chip = to_msm_gpio_chip(chip);
	
	...
}

and you have a descriptor for your chip (or an array of these if you
want multiple banks of gpios):

static struct msm_gpios = {
	.chip = {
		.label		= "msm_gpio",
		.set		= gpio_set_value,
		...
	},
	/* MSM specific bits */
};

void __init msm_init_gpio(void)
{
	gpiochip_add(&msm_gpios);

	/* Other setup, gpio irqs, etc */
}

Your msm_register_gpio_chip function should disappear and your
gpio_request and gpio_free functions can either be removed, or at least
become much simpler since gpiolib already handles most of what those
functions are doing.

Have a look at the other ARM chips which have gpiolib support for a
guide. The ep93xx and at91 ones which I did are reasonably simple to
follow, and also demonstrate how to use the debugfs hooks which you may
find useful. Also look at Documentation/gpio.txt which has some more
detailed information on gpiolib.

~Ryan

-- 
Bluewater Systems Ltd - ARM Technology Solution Centre

Ryan Mallon         		5 Amuri Park, 404 Barbadoes St
ryan@bluewatersys.com         	PO Box 13 889, Christchurch 8013
http://www.bluewatersys.com	New Zealand
Phone: +64 3 3779127		Freecall: Australia 1800 148 751
Fax:   +64 3 3779135			  USA 1800 261 2934
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
GPIO support for HTC Dream, Pavel Machek, (Tue Dec 8, 3:28 am)
Re: GPIO support for HTC Dream, Ryan Mallon, (Tue Dec 8, 1:22 pm)
Re: GPIO support for HTC Dream, Pavel Machek, (Tue Dec 8, 2:37 pm)
Re: GPIO support for HTC Dream, Pavel Machek, (Tue Dec 8, 2:46 pm)
Re: GPIO support for HTC Dream, Ryan Mallon, (Tue Dec 8, 2:53 pm)
Re: GPIO support for HTC Dream, =?ISO-8859-1?Q?Arve_ ..., (Tue Dec 8, 2:56 pm)
Re: GPIO support for HTC Dream, Joe Perches, (Tue Dec 8, 3:03 pm)
Re: GPIO support for HTC Dream, Ryan Mallon, (Tue Dec 8, 3:10 pm)
Re: GPIO support for HTC Dream, Russell King - ARM Linux, (Tue Dec 8, 3:45 pm)
Re: GPIO support for HTC Dream, =?ISO-8859-1?Q?Arve_ ..., (Tue Dec 8, 5:39 pm)
Re: GPIO support for HTC Dream, Pavel Machek, (Wed Dec 9, 4:32 am)
Re: GPIO support for HTC Dream, Pavel Machek, (Wed Dec 9, 4:37 am)
Re: GPIO support for HTC Dream, Pavel Machek, (Wed Dec 9, 4:41 am)
Re: GPIO support for HTC Dream, =?ISO-8859-1?Q?Arve_ ..., (Wed Dec 9, 4:42 am)
Re: GPIO support for HTC Dream, Pavel Machek, (Wed Dec 9, 4:46 am)
Re: GPIO support for HTC Dream, Daniel Walker, (Wed Dec 9, 9:18 am)
Re: GPIO support for HTC Dream, Ryan Mallon, (Wed Dec 9, 4:40 pm)
Re: GPIO support for HTC Dream, Pavel Machek, (Thu Dec 10, 9:26 am)
Re: GPIO support for HTC Dream, Pavel Machek, (Thu Dec 10, 9:27 am)
Re: GPIO support for HTC Dream, Pavel Machek, (Thu Dec 10, 9:57 am)
Re: GPIO support for HTC Dream, Pavel Machek, (Thu Dec 10, 10:24 am)
Re: GPIO support for HTC Dream, Mark Brown, (Thu Dec 10, 10:41 am)
Re: GPIO support for HTC Dream, Ryan Mallon, (Thu Dec 10, 12:49 pm)
RE: GPIO support for HTC Dream, H Hartley Sweeten, (Thu Dec 10, 4:14 pm)
Re: GPIO support for HTC Dream, Pavel Machek, (Fri Dec 11, 12:58 pm)
Re: GPIO support for HTC Dream, Pavel Machek, (Fri Dec 11, 3:10 pm)
Re: GPIO support for HTC Dream, =?ISO-8859-1?Q?Arve_ ..., (Fri Dec 11, 3:40 pm)
RE: GPIO support for HTC Dream, H Hartley Sweeten, (Fri Dec 11, 4:04 pm)
RE: GPIO support for HTC Dream, H Hartley Sweeten, (Fri Dec 11, 4:12 pm)
Re: GPIO support for HTC Dream, Russell King - ARM Linux, (Fri Dec 11, 4:28 pm)
RE: GPIO support for HTC Dream, H Hartley Sweeten, (Fri Dec 11, 4:50 pm)
Re: GPIO support for HTC Dream, Pavel Machek, (Sun Dec 13, 2:29 pm)
Re: GPIO support for HTC Dream, Brian Swetland, (Sun Dec 13, 2:38 pm)
Re: GPIO support for HTC Dream, Pavel Machek, (Sun Dec 13, 11:24 pm)
Re: GPIO support for HTC Dream, Pavel Machek, (Sun Dec 13, 11:45 pm)
Re: GPIO support for HTC Dream, Daniel Walker, (Mon Dec 14, 10:40 am)
Re: GPIO support for HTC Dream, Daniel Walker, (Mon Dec 14, 10:54 am)
RE: GPIO support for HTC Dream, H Hartley Sweeten, (Mon Dec 14, 11:12 am)
RE: GPIO support for HTC Dream, H Hartley Sweeten, (Mon Dec 14, 12:00 pm)
Re: GPIO support for HTC Dream, =?ISO-8859-1?Q?Arve_ ..., (Mon Dec 14, 11:40 pm)
Re: GPIO support for HTC Dream, =?ISO-8859-1?Q?Arve_ ..., (Mon Dec 14, 11:48 pm)
Re: GPIO support for HTC Dream, Pavel Machek, (Tue Dec 15, 12:09 pm)
Re: GPIO support for HTC Dream, Pavel Machek, (Tue Dec 15, 12:10 pm)
Re: GPIO support for HTC Dream, Pavel Machek, (Tue Dec 15, 12:12 pm)
Re: GPIO support for HTC Dream, Pavel Machek, (Tue Dec 15, 12:47 pm)
Re: GPIO support for HTC Dream, Daniel Walker, (Tue Dec 15, 1:07 pm)
RE: GPIO support for HTC Dream, H Hartley Sweeten, (Tue Dec 15, 1:15 pm)
Re: GPIO support for HTC Dream, Ryan Mallon, (Tue Dec 15, 1:24 pm)
Re: GPIO support for HTC Dream, Pavel Machek, (Tue Dec 15, 1:44 pm)
Re: GPIO support for HTC Dream, Pavel Machek, (Tue Dec 15, 1:47 pm)
Re: GPIO support for HTC Dream, Jamie Lokier, (Tue Dec 15, 1:48 pm)
Re: GPIO support for HTC Dream, Brian Swetland, (Tue Dec 15, 2:07 pm)
[patch] GPIO support for HTC Dream, Pavel Machek, (Tue Dec 15, 2:16 pm)
Re: GPIO support for HTC Dream, Pavel Machek, (Tue Dec 15, 2:21 pm)
Re: GPIO support for HTC Dream, Pavel Machek, (Wed Dec 16, 3:53 pm)
Re: GPIO support for HTC Dream, Daniel Walker, (Wed Dec 16, 4:03 pm)
Re: [patch] GPIO support for HTC Dream, Pavel Machek, (Fri Dec 25, 10:10 am)
Re: [patch] GPIO support for HTC Dream, Daniel Walker, (Fri Dec 25, 4:49 pm)
Re: [patch] GPIO support for HTC Dream, Pavel Machek, (Sat Dec 26, 1:51 am)