gpiolib: add gpio_desc[]
Subsystems (6)
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/6 gpiolib: add gpio_desc[]
From: David Brownell <[email protected]>
Update gpiolib to use a table of per-GPIO "struct gpio_desc" instead of a table of "struct gpio_chip".
- Change "is_out" and "requested" from arrays in "struct gpio_chip" to bit fields in "struct gpio_desc", eliminating ARCH_GPIOS_PER_CHIP.
- Stop overloading "requested" flag with "label" tracked for debugfs.
- Change gpiochip_is_requested() into a regular function, since it now accesses data that's not exported from the gpiolib code. Also change its signature, for the same reason.
- Reduce default ARCH_NR_GPIOS to 256 to shrink gpio_desc table cost. On 32-bit platforms without debugfs, that table size is 2KB.
This makes it easier to work with chips with different numbers of GPIOs, and to avoid holes in GPIOs number sequences. Those holes can cost a lot of unusable irq_desc space for GPIOs that act as IRQs; and needing the can cause surprises when trying to set up multiple GPIO controllers.
Based on a patch from Eric Miao.
--- arch/avr32/mach-at32ap/pio.c | 7 - include/asm-avr32/arch-at32ap/gpio.h | 2 include/asm-generic/gpio.h | 49 +------- lib/gpiolib.c | 213 ++++++++++++++++++++--------------- 4 files changed, 139 insertions(+), 132 deletions(-)
arch/avr32/mach-at32ap/pio.c +5 -2
@@ -315,12 +315,15 @@ static void pio_bank_show(struct seq_fil bank ='A' + pio->pdev->id;for (i =0 , mask =1 ; i <32 ; i++, mask <<=1 ) { -if (!gpiochip_is_requested (chip, i)) +const char *label; + + label =gpiochip_is_requested (chip, i); +if (!label)continue ;seq_printf (s," gpio-%-3d P%c%-2d (%-12s) %s %s %s" , chip->base + i, bank, i, - chip->requested[i], + label, (osr & mask) ?"out" :"in " , (mask & pdsr) ?"hi" :"lo" , (mask & pusr) ?" " :"up" );
include/asm-avr32/arch-at32ap/gpio.h +1 -1
@@ -8,7 +8,7 @@/* Some GPIO chips can manage IRQs; some can't. The exact numbers can * be changed if needed, but for the moment they're not configurable. */ -#define ARCH_NR_GPIOS (NR_GPIO_IRQS + 2 * ARCH_GPIOS_PER_CHIP) +#define ARCH_NR_GPIOS (NR_GPIO_IRQS + 2 * 32)/* Arch-neutral GPIO API, supporting both "native" and external GPIOs. */
include/asm-generic/gpio.h +10 -39
83 lines not on this page · raw message
lib/gpiolib.c +123 -90
362 lines not on this page · raw message
PATCH 2/6 gpiolib: more CONFIG_DEBUG_GPIO diagnostics
In reply to a message not in the archiveFrom: David Brownell <[email protected]>
Update gpiolib behavior with CONFIG_DEBUG_GPIO to include messages on some fault paths that are common during bringup: gpiochip_add, gpio_request, and the two gpio_direction_* calls.
Also morph that CONFIG symbol into compile-time -DDEBUG.
--- lib/Kconfig.debug | 10 ++++++---- lib/Makefile | 4 ++++ lib/gpiolib.c | 33 ++++++++++++++++++++++++++++----- 3 files changed, 38 insertions(+), 9 deletions(-)
lib/Kconfig.debug +6 -4
@@ -160,10 +160,12 @@ config DEBUG_GPIO bool "Debug GPIO calls" depends on DEBUG_KERNEL && GPIO_LIB help - Say Y here to add some extra checks to GPIO calls, ensuring that - GPIOs have been properly initialized before they are used and - that sleeping calls aren't made from nonsleeping contexts. This - can make bitbanged serial protocols slower. + Say Y here to add some extra checks and diagnostics to GPIO calls. + The checks help ensure that GPIOs have been properly initialized + before they are used and that sleeping calls aren't made from + nonsleeping contexts. They can make bitbanged serial protocols + slower. The diagnostics help catch the type of setup errors + that are most common when setting up new platforms or boards. config DEBUG_SLAB_LEAK bool "Memory leak debugging"
lib/Makefile +4 -0
@@ -68,6 +68,10 @@ obj-$(CONFIG_FAULT_INJECTION) += fault-i lib-$(CONFIG_GENERIC_BUG) += bug.o +ifeq ($(CONFIG_DEBUG_GPIO),y) +CFLAGS_gpiolib.o += -DDEBUG +endif + lib-$(CONFIG_GPIO_LIB) += gpiolib.o hostprogs-y := gen_crc32table
lib/gpiolib.c +28 -5
@@ -20,9 +20,12 @@/* When debugging, extend minimal trust to callers and platform code. +* Also emit diagnostic messages that may help initial bringup, when +* board setup or driver bugs are most common. +* * Otherwise, minimize overhead in what may be bitbanging codepaths. */ -#ifdef CONFIG_DEBUG_GPIO +#ifdef DEBUG #define extra_checks 1#else #define extra_checks 0
@@ -48,8 +51,11 @@ struct gpio_desc {static struct gpio_desc gpio_desc[ARCH_NR_GPIOS ]; -/* Warn when drivers omit gpio_request() calls -- legal but -* ill-advised when setting direction, and otherwise illegal. +/* Warn when drivers omit gpio_request() calls -- legal but ill-advised +* when setting direction, and otherwise illegal. Until board setup code +* and drivers use explicit requests everywhere (which won't happen when +* those calls have no teeth) we can't avoid autorequesting. This nag +* message should motivate switching to explicit requests... */ static void gpio_ensure_requested (struct gpio_desc *desc) {
@@ -86,8 +92,10 @@ int gpiochip_add(struct gpio_chip *chip)* dynamic allocation. We don't currently support that. */ -if (chip->base <0 || (chip->base + chip->ngpio) >=ARCH_NR_GPIOS ) -return -EINVAL ; +if (chip->base <0 || (chip->base + chip->ngpio) >=ARCH_NR_GPIOS ) { + status = -EINVAL ; + goto fail; + }spin_lock_irqsave (&gpio_lock, flags);
@@ -106,6 +114,12 @@ int gpiochip_add(struct gpio_chip *chip) }spin_unlock_irqrestore (&gpio_lock, flags); +fail: +/* failures here can mean systems won't boot... */ +if (status) +pr_err ("gpiochip_add: gpios %d..%d (%s) not registered\n" , + chip->base, chip->base + chip->ngpio, + chip->label ? :"generic" );return status; }EXPORT_SYMBOL_GPL (gpiochip_add);
@@ -172,6 +186,9 @@ int gpio_request(unsigned gpio, const ch status = -EBUSY ; done: +if (status) +pr_debug ("gpio_request: gpio-%d (%s) status %d\n" , + gpio, label ? :"?" , status);spin_unlock_irqrestore (&gpio_lock, flags);return status; }
@@ -272,6 +289,9 @@ int gpio_direction_input(unsigned gpio)return status; fail:spin_unlock_irqrestore (&gpio_lock, flags); +if (status) +pr_debug ("%s: gpio-%d status %d\n" , + __FUNCTION__, gpio, status);return status; }EXPORT_SYMBOL_GPL (gpio_direction_input);
@@ -307,6 +327,9 @@ int gpio_direction_output(unsigned gpio,return status; fail:spin_unlock_irqrestore (&gpio_lock, flags); +if (status) +pr_debug ("%s: gpio-%d status %d\n" , + __FUNCTION__, gpio, status);return status; }EXPORT_SYMBOL_GPL (gpio_direction_output);
PATCH 3/6 gpiolib: implementor-oriented documentation
In reply to a message not in the archiveFrom: David Brownell <[email protected]>
Add some documentation highlighting implementors' views of the new gpiolib stuff. Such developers may be supporting new gpio controllers, platforms, or boards. Obviously there's often some overlap there, but the concerns for each task aren't identical.
This also fixes a minor bug, which turned up as a discrepancy against the documentation: if a gpio_chip doesn't have a get() method, just return zero when asked to read its value.
--- Documentation/gpio.txt | 103 ++++++++++++++++++++++++++++++++++++++++++++++--- lib/gpiolib.c | 29 +++++++++++++ 2 files changed, 126 insertions(+), 6 deletions(-)
Documentation/gpio.txt +98 -5
@@ -32,7 +32,7 @@ The exact capabilities of GPIOs vary bet - Input values are likewise readable (1, 0). Some chips support readback of pins configured as "output", which is very useful in such "wire-OR" cases (to support bidirectional signaling). GPIO controllers may have - input de-glitch logic, sometimes with software controls. + input de-glitch/debounce logic, sometimes with software controls. - Inputs can often be used as IRQ signals, often edge triggered but sometimes level triggered. Such IRQs may be configurable as system
@@ -60,12 +60,13 @@ used on a board that's wired differently functionality can be very portable. Other features are platform-specific, and that can be critical for glue logic. -Plus, this doesn't define an implementation framework, just an interface. +Plus, this doesn't require any implementation framework, just an interface. One platform might implement it as simple inline functions accessing chip registers; another might implement it by delegating through abstractions used for several very different kinds of GPIO controller. (There is some -library code supporting such an implementation strategy, but drivers acting -as clients to the GPIO interface should not care how it's implemented.) +optional code supporting such an implementation strategy, described later +in this document, but drivers acting as clients to the GPIO interface must +not care how it's implemented.) That said, if the convention is supported on their platform, drivers should use it when possible. Platforms should declare GENERIC_GPIO support in
@@ -152,7 +153,7 @@ Use these calls to access such GPIOs: The values are boolean, zero for low, nonzero for high. When reading the value of an output pin, the value returned should be what's seen on the pin ... that won't always match the specified output value, because of -issues including wire-OR and output latencies. +issues including open-drain signaling and output latencies. The get/set calls have no error returns because "invalid GPIO" should have been reported earlier from gpio_direction_*(). However, note that not all
@@ -328,3 +329,95 @@ a side effect of configuring an add-on b These calls are purely for kernel space, but a userspace API could be built on top of them. + + +GPIO implementor's framework (OPTIONAL) +======================================= +As noted earlier, there is an optional implementation framework making it +easier for platforms to support different kinds of GPIO controller using +the same programming interface. + +As a debugging aid, if debugfs is available a /sys/kernel/debug/gpio file +will be found there. That will list all the controllers registered through +this framework, and the state of the GPIOs currently in use. + + +Controller Drivers: gpio_chip +----------------------------- +In this framework each GPIO controller is packaged as a "struct gpio_chip" +with information common to each controller of that type: + + - methods to establish GPIO direction + - methods used to access GPIO values + - flag saying whether calls to its methods may sleep + - optional debugfs dump method (showing extra state like pullup config) + - label for diagnostics + +There is also per-instance data, which may come from device.platform_data: +the number of its first GPIO, and how many GPIOs it exposes. + +The code implementing a gpio_chip should support multiple instances of the +controller, possibly using the driver model. That code will configure each +gpio_chip and issue gpiochip_add(). Removing a GPIO controller should be +rare; use gpiochip_remove() when it is unavoidable. + +Normally a gpio_chip is part of an instance-specific structure with state +not exposed by the GPIO interfaces, such as addressing, power management, +and more. Chips such as codecs will have complex non-GPIO state, + +Any debugfs dump method should normally ignore signals which haven't been +requested as GPIOs. They can use gpiochip_is_requested(), which returns +either NULL or the label associated with that GPIO when it was requested. + + +Platform Support +---------------- +To support this framework, a platform's Kconfig will "select GPIO_LIB" and +arrange that its <asm/gpio.h> then include <asm-generic/gpio.h> and define +three functions: gpio_get_value(), gpio_set_value(), and gpio_cansleep(). +They may also want to provide a custom value for ARCH_NR_GPIOS. + +Trivial implementations of those functions can directly use framework +code, which always dispatches through the gpio_chip: + + #define gpio_get_value __gpio_get_value + #define gpio_set_value __gpio_set_value + #define gpio_cansleep __gpio_cansleep + +Fancier implementations could instead define those as inline functions with +logic optimizing access to specific SOC-based GPIOs. For example, if the +referenced GPIO is the constant "12", getting or setting its value could +cost as little as two or three instructions, never sleeping. When such an +optimization is not possible those calls must delegate to the framework +code, costing probably a few dozen instructions. For bitbanged I/O, such +instruction savings can be significant. + +For SOCs, platform-specific code defines and registers gpio_chip instances +for each bank of on-chip GPIOs. Those GPIOs should be numbered/labeled to +match chip vendor documentation, and directly match board schematics. They +probably start at zero and go up to a platform-specific limit. Such GPIOs +are normally integrated into platform initialization so these GPIOs are +always available, from arch_initcall() or earlier, and can serve as IRQs. + + +Board Support +------------- +For external GPIO controllers -- such as I2C or SPI expanders, ASICs, multi +function devices, FPGAs or CPLDs -- board-specific code is responsible for +registering controller devices and ensuring their drivers know what GPIO +numbers to use with gpiochip_add(). Their numbers usually start right after +platform-specific GPIOs. + +For example, their I2C or SPI board_info structures would pass platform_data +identifying the range of GPIOs that chip will expose. The board setup code +uses those structs to assign each GPIO expander chip a set of GPIOs; then the +chip's driver passes that data to gpiochip_add() from probe(). + +Initialization order can be important. For example, when a device relies on +an I2C-based GPIO, its probe() routine should only be called after that GPIO +becomes available. That probably means the device should not be registered +until calls for that GPIO can work. One way to address such dependencies is +for such gpio_chip controllers to provide setup() and teardown() callbacks to +board specific code; those board specific callbacks would register devices +once all the necessary resources are available. +
lib/gpiolib.c +28 -1
@@ -356,16 +356,35 @@ EXPORT_SYMBOL_GPL(gpio_direction_output)* REVISIT when debugging, consider adding some instrumentation to ensure * that the GPIO was actually requested. */ + +/** +* __gpio_get_value() - return a gpio's value +* @gpio: gpio whose value will be returned +* Context: any +* +* This is used directly or indirectly to implement gpio_get_value(). +* It returns the zero or nonzero value provided by the associated +* gpio_chip.get() method; or zero if no such method is provided. +*/ int __gpio_get_value (unsigned gpio) {struct gpio_chip *chip; chip =gpio_to_chip (gpio);WARN_ON (extra_checks && chip->can_sleep); -return chip->get (chip, gpio - chip->base); +return chip->get ? chip->get (chip, gpio - chip->base) :0 ; }EXPORT_SYMBOL_GPL (__gpio_get_value); +/** +* __gpio_set_value() - assign a gpio's value +* @gpio: gpio whose value will be assigned +* @value: value to assign +* Context: any +* +* This is used directly or indirectly to implement gpio_set_value(). +* It invokes the associated gpio_chip.set() method. +*/ void __gpio_set_value (unsigned gpio,int value) {struct gpio_chip *chip;
@@ -376,6 +395,14 @@ void __gpio_set_value(unsigned gpio, int }EXPORT_SYMBOL_GPL (__gpio_set_value); +/** +* __gpio_cansleep() - report whether gpio value access will sleep +* @gpio: gpio in question +* Context: any +* +* This is used directly or indirectly to implement gpio_cansleep(). It +* returns nonzero if access reading or writing the GPIO value can sleep. +*/ int __gpio_cansleep (unsigned gpio) {struct gpio_chip *chip;
PATCH 4/6 gpiolib: create empty drivers/gpio
In reply to a message not in the archiveFrom: David Brownell <[email protected]>
Add an empty drivers/gpio directory for gpiolib based GPIO expanders. We already have three of them (two I2C, one SPI), and there are dozens of similar chips that only exist for GPIO expansion.
This won't be the only place to hold such gpio_chip code. Many external chips add a few GPIOs as secondary functionality, and platform code frequently needs to closely integrate GPIO and IRQ support.
This is placed *early* in the build/link sequence since it's common for other drivers to depend on GPIOs to do their work, so they need to be initialized early in the device_initcall() sequence.
--- arch/arm/Kconfig | 2 ++ drivers/Kconfig | 2 ++ drivers/Makefile | 1 + drivers/gpio/Kconfig | 14 ++++++++++++++ drivers/gpio/Makefile | 1 + 5 files changed, 20 insertions(+)
arch/arm/Kconfig +2 -0
@@ -1034,6 +1034,8 @@ source "drivers/i2c/Kconfig" source "drivers/spi/Kconfig" +source "drivers/gpio/Kconfig" + source "drivers/w1/Kconfig" source "drivers/power/Kconfig"
drivers/Kconfig +2 -0
@@ -52,6 +52,8 @@ source "drivers/i2c/Kconfig" source "drivers/spi/Kconfig" +source "drivers/gpio/Kconfig" + source "drivers/w1/Kconfig" source "drivers/power/Kconfig"
drivers/Makefile +1 -0
@@ -5,6 +5,7 @@ # Rewritten to use lists instead of if-statements. # +obj-$(CONFIG_GPIO_LIB) += gpio/ obj-$(CONFIG_PCI) += pci/ obj-$(CONFIG_PARISC) += parisc/ obj-$(CONFIG_RAPIDIO) += rapidio/
drivers/gpio/Kconfig new file +14 -0
@@ -0,0 +1,14 @@ +# +# platform-neutral GPIO support +# + +menu "GPIO Expanders" + depends on GPIO_LIB + +# put expanders in the right section, in alphabetical order + +comment "I2C GPIO expanders:" + +comment "SPI GPIO expanders:" + +endmenu
drivers/gpio/Makefile new file +1 -0
@@ -0,0 +1 @@ +# gpio support: dedicated expander chips, etc
Re: [patch 2.6.24-rc4-mm 4/6] gpiolib: create empty drivers/gpio
Hi David,
Quoted 6 lines · David Brownell
From: David Brownell <[email protected]>
Add an empty
drivers/gpiodirectory for gpiolib based GPIO expanders. We already have three of them (two I2C, one SPI), and there are dozens of similar chips that only exist for GPIO expansion.
Quoted 7 lines
This won't be the only place to hold such
gpio_chipcode. Many external chips add a few GPIOs as secondary functionality, and platform code frequently needs to closely integrate GPIO and IRQ support.This is placed *early* in the build/link sequence since it's common for other drivers to depend on GPIOs to do their work, so they need to be initialized early in the
device_initcall()sequence.
Note that I foresee potential problems with this. These GPIO drivers need I2C or SPI to be initialized before they can load. However on some systems, I2C or SPI buses are hanging off GPIOs, meaning that these GPIOS need to be initialized before I2C or SPI, respectively. I can imagine weird setups where for example an SPI bus would be driven by an I2C-based GPIO chip, or vice-versa. I sure hope that nobody does this, but you never know... And I'm not sure how we would possibly support this.
Signature · 1 line
Jean Delvare
Re: [patch 2.6.24-rc4-mm 4/6] gpiolib: create empty drivers/gpio
Quoted 8 lines
Quoted 8 lines
Add an empty
drivers/gpiodirectory for gpiolib based GPIO expanders. We already have three of them (two I2C, one SPI), and there are dozens of similar chips that only exist for GPIO expansion.This won't be the only place to hold such
gpio_chipcode. Many external chips add a few GPIOs as secondary functionality, and platform code frequently needs to closely integrate GPIO and IRQ support.
Quoted 8 lines
Quoted 3 lines
This is placed *early* in the build/link sequence since it's common for other drivers to depend on GPIOs to do their work, so they need to be initialized early in the
device_initcall()sequence.Note that I foresee potential problems with this. These GPIO drivers need I2C or SPI to be initialized before they can load. However on some systems, I2C or SPI buses are hanging off GPIOs, meaning that these GPIOS need to be initialized before I2C or SPI, respectively.
In those cases the I2C (or SPI) bus will normally be hanging off some arch/XX/mach-YY/gpio.c platform code, which will usually be set up so it's "always there". (As noted by the docs in patch 3/6 of this series.) Such code often initializes very early, sometimes even before IRQs are enabled or kmalloc works.
Bitbanging through an I2C or SPI expander would be possible, but doesn't seem especially practical. :)
Quoted 5 lines
I can
imagine weird setups where for example an SPI bus would be driven by an I2C-based GPIO chip, or vice-versa. I sure hope that nobody does this, but you never know... And I'm not sure how we would possibly support this.
It's just a routine case of init this before that. Again, the dependency issue is noted in the docs in patch 3/6 of this series. Linking these expanders early reduces such problems, it can never get rid of them.
It's really no different than needing to hold off initialization of any other device until the I2C based GPIOs are ready, like the leds-gpio example [1] I posted some time ago.
- Dave
[1] http://marc.info/?l=linux-kernel&m=119370944606415&w=2
See evm_led_setup(), setting up the leds-gpio device as a child of the GPIO expander; and evm_u18_setup(), setting up a switch attribute as a child of a different expander.
PATCH 5/6 gpiolib: pcf857x i2c expander driver
In reply to a message not in the archiveFrom: David Brownell <[email protected]>
This is a new-style I2C driver for most common 8 and 16 bit I2C based "quasi-bidirectional" GPIO expanders: pcf8574 or pcf8575, and several compatible models (mostly faster, supporting I2C at up to 1 MHz).
The driver exposes the GPIO signals using the platform-neutral GPIO programming interface, so they are easily accessed by other kernel code. The lack of such a flexible kernel API has been a big factor in the proliferation of board-specific drivers for these chips... stuff that rarely makes it upstream since it's so ugly. This driver will let such boards use standard calls.
Since it's a new-style driver, these devices must be configured as part of board-specific init. That eliminates the need for error-prone manual configuration of module parameters, and makes compatibility with legacy drivers (pcf8574.c, pc8575.c) for these chips easier (there's a clear either/or disjunction).
--- drivers/gpio/Kconfig | 23 +++ drivers/gpio/Makefile | 2 drivers/gpio/pcf857x.c | 330 ++++++++++++++++++++++++++++++++++++++++++++ include/linux/i2c/pcf857x.h | 45 ++++++ 4 files changed, 400 insertions(+)
drivers/gpio/Kconfig +23 -0
@@ -9,6 +9,29 @@ menu "GPIO Expanders" comment "I2C GPIO expanders:" +config GPIO_PCF857X + tristate "PCF857x, PCA857x, and PCA967x I2C GPIO expanders" + depends on I2C + help + Say yes here to provide access to most "quasi-bidirectional" I2C + GPIO expanders used for additional digital outputs or inputs. + Most of these parts are from NXP, though TI is a second source for + some of them. Compatible models include: + + 8 bits: pcf8574, pcf8574a, pca8574, pca8574a, + pca9670, pca9672, pca9674, pca9674a + + 16 bits: pcf8575, pcf8575c, pca8575, + pca9671, pca9673, pca9675 + + Your board setup code will need to declare the expanders in + use, and assign numbers to the GPIOs they expose. Those GPIOs + can then be used from drivers and other kernel code, just like + other GPIOs, but only accessible from task contexts. + + This driver provides an in-kernel interface to those GPIOs using + platform-neutral GPIO calls. + comment "SPI GPIO expanders:" endmenu
drivers/gpio/Makefile +2 -0
@@ -1 +1,3 @@ # gpio support: dedicated expander chips, etc + +obj-$(CONFIG_GPIO_PCF857X) += pcf857x.o
drivers/gpio/pcf857x.c new file +330 -0
330 lines not on this page · raw message
include/linux/i2c/pcf857x.h new file +45 -0
45 lines not on this page · raw message
PATCH 6/6 gpiolib: replacement mcp23s08 driver
In reply to a message not in the archiveFrom: David Brownell <[email protected]>
Basic driver for 8-bit SPI based MCP23S08 GPIO expander, without support for IRQs or the shared chipselect mechanism.
---
Other than the new directory and Kconfig symbol, this is identical to the code currently in MM except for: (a) gpio_desc[] related changes, and
(b) now using module_init(), since this directory is initialzed earlier.
drivers/gpio/Kconfig | 7 drivers/gpio/Makefile | 1 drivers/gpio/mcp23s08.c | 357 +++++++++++++++++++++++++++++++++++++++++++ include/linux/spi/mcp23s08.h | 24 ++ 4 files changed, 389 insertions(+)
drivers/gpio/Kconfig +7 -0
@@ -34,4 +34,11 @@ config GPIO_PCF857X comment "SPI GPIO expanders:" +config GPIO_MCP23S08 + tristate "Microchip MCP23S08 I/O expander" + depends on SPI_MASTER + help + SPI driver for Microchip MCP23S08 I/O expander. This provides + a GPIO interface supporting inputs and outputs. + endmenu
drivers/gpio/Makefile +1 -0
@@ -1,3 +1,4 @@ # gpio support: dedicated expander chips, etc +obj-$(CONFIG_GPIO_MCP23S08) += mcp23s08.o obj-$(CONFIG_GPIO_PCF857X) += pcf857x.o
drivers/gpio/mcp23s08.c new file +357 -0
357 lines not on this page · raw message
include/linux/spi/mcp23s08.h new file +24 -0
@@ -0,0 +1,24 @@ + +/* FIXME driver should be able to handle all four slaves that +* can be hooked up to each chipselect, as well as IRQs... +*/ + +struct mcp23s08_platform_data { +/* four slaves can share one SPI chipselect */ +u8 slave; + +/* number assigned to the first GPIO */ +unsigned base; + +/* pins with pullups */ +u8 pullups; + +void *context;/* param to setup/teardown */ + +int (*setup)(struct spi_device *spi, +int gpio,unsigned ngpio, +void *context); +int (*teardown)(struct spi_device *spi, +int gpio,unsigned ngpio, +void *context); +};