Skip to content

Commit

Permalink
Merge tag 'gpio-for-linus' of git://git.secretlab.ca/git/linux
Browse files Browse the repository at this point in the history
Pull GPIO changes from Grant Likely:
 "The usual selection of bug fixes and driver updates for GPIO.  Nothing
  really stands out except the addition of the GRGPIO driver and some
  enhacements to ACPI support"

I'm pulling this despite the earlier mess.  Let's hope it compiles these
days.

* tag 'gpio-for-linus' of git://git.secretlab.ca/git/linux: (46 commits)
  gpio: grgpio: Add irq support
  gpio: grgpio: Add device driver for GRGPIO cores
  gpiolib-acpi: introduce acpi_get_gpio_by_index() helper
  GPIO: gpio-generic: remove kfree() from bgpio_remove call
  gpio / ACPI: Handle ACPI events in accordance with the spec
  gpio: lpc32xx: Fix off-by-one valid range checking for bank
  gpio: mcp23s08: convert driver to DT
  gpio/omap: force restore if context loss is not detectable
  gpio/omap: optimise interrupt service routine
  gpio/omap: remove extra context restores in *_runtime_resume()
  gpio/omap: free irq domain in probe() failure paths
  gpio: gpio-generic: Add 16 and 32 bit big endian byte order support
  gpio: samsung: Add terminating entry for exynos_pinctrl_ids
  gpio: mvebu: add dbg_show function
  MAX7301 GPIO: Do not force SPI speed when using OF Platform
  gpio: gpio-tps65910.c: fix checkpatch error
  gpio: gpio-timberdale.c: fix checkpatch error
  gpio: gpio-tc3589x.c: fix checkpatch errors
  gpio: gpio-stp-xway.c: fix checkpatch error
  gpio: gpio-sch.c: fix checkpatch error
  ...
  • Loading branch information
Linus Torvalds committed May 6, 2013
2 parents f87bb9e + 08ffb22 commit 30c67e9
Show file tree
Hide file tree
Showing 36 changed files with 1,293 additions and 293 deletions.
32 changes: 31 additions & 1 deletion Documentation/acpi/enumeration.txt
Original file line number Diff line number Diff line change
Expand Up @@ -199,17 +199,29 @@ the device to the driver. For example:
{
Name (SBUF, ResourceTemplate()
{
...
// Used to power on/off the device
GpioIo (Exclusive, PullDefault, 0x0000, 0x0000,
IoRestrictionOutputOnly, "\\_SB.PCI0.GPI0",
0x00, ResourceConsumer,,)
{
// Pin List
0x0055
}

// Interrupt for the device
GpioInt (Edge, ActiveHigh, ExclusiveAndWake, PullNone,
0x0000, "\\_SB.PCI0.GPI0", 0x00, ResourceConsumer,,)
{
// Pin list
0x0058
}

...

Return (SBUF)
}

Return (SBUF)
}

These GPIO numbers are controller relative and path "\\_SB.PCI0.GPI0"
Expand All @@ -220,6 +232,24 @@ The driver can do this by including <linux/acpi_gpio.h> and then calling
acpi_get_gpio(path, gpio). This will return the Linux GPIO number or
negative errno if there was no translation found.

In a simple case of just getting the Linux GPIO number from device
resources one can use acpi_get_gpio_by_index() helper function. It takes
pointer to the device and index of the GpioIo/GpioInt descriptor in the
device resources list. For example:

int gpio_irq, gpio_power;
int ret;

gpio_irq = acpi_get_gpio_by_index(dev, 1, NULL);
if (gpio_irq < 0)
/* handle error */

gpio_power = acpi_get_gpio_by_index(dev, 0, NULL);
if (gpio_power < 0)
/* handle error */

/* Now we can use the GPIO numbers */

Other GpioIo parameters must be converted first by the driver to be
suitable to the gpiolib before passing them.

Expand Down
26 changes: 26 additions & 0 deletions Documentation/devicetree/bindings/gpio/gpio-grgpio.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Aeroflex Gaisler GRGPIO General Purpose I/O cores.

The GRGPIO GPIO core is available in the GRLIB VHDL IP core library.

Note: In the ordinary environment for the GRGPIO core, a Leon SPARC system,
these properties are built from information in the AMBA plug&play.

Required properties:

- name : Should be "GAISLER_GPIO" or "01_01a"

- reg : Address and length of the register set for the device

- interrupts : Interrupt numbers for this device

Optional properties:

- nbits : The number of gpio lines. If not present driver assumes 32 lines.

- irqmap : An array with an index for each gpio line. An index is either a valid
index into the interrupts property array, or 0xffffffff that indicates
no irq for that line. Driver provides no interrupt support if not
present.

For further information look in the documentation for the GLIB IP core library:
http://www.gaisler.com/products/grlib/grip.pdf
47 changes: 47 additions & 0 deletions Documentation/devicetree/bindings/gpio/gpio-mcp23s08.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
Microchip MCP2308/MCP23S08/MCP23017/MCP23S17 driver for
8-/16-bit I/O expander with serial interface (I2C/SPI)

Required properties:
- compatible : Should be
- "mcp,mcp23s08" for 8 GPIO SPI version
- "mcp,mcp23s17" for 16 GPIO SPI version
- "mcp,mcp23008" for 8 GPIO I2C version or
- "mcp,mcp23017" for 16 GPIO I2C version of the chip
- #gpio-cells : Should be two.
- first cell is the pin number
- second cell is used to specify flags. Flags are currently unused.
- gpio-controller : Marks the device node as a GPIO controller.
- reg : For an address on its bus. I2C uses this a the I2C address of the chip.
SPI uses this to specify the chipselect line which the chip is
connected to. The driver and the SPI variant of the chip support
multiple chips on the same chipselect. Have a look at
mcp,spi-present-mask below.

Required device specific properties (only for SPI chips):
- mcp,spi-present-mask : This is a present flag, that makes only sense for SPI
chips - as the name suggests. Multiple SPI chips can share the same
SPI chipselect. Set a bit in bit0-7 in this mask to 1 if there is a
chip connected with the corresponding spi address set. For example if
you have a chip with address 3 connected, you have to set bit3 to 1,
which is 0x08. mcp23s08 chip variant only supports bits 0-3. It is not
possible to mix mcp23s08 and mcp23s17 on the same chipselect. Set at
least one bit to 1 for SPI chips.
- spi-max-frequency = The maximum frequency this chip is able to handle

Example I2C:
gpiom1: gpio@20 {
compatible = "mcp,mcp23017";
gpio-controller;
#gpio-cells = <2>;
reg = <0x20>;
};

Example SPI:
gpiom1: gpio@0 {
compatible = "mcp,mcp23s17";
gpio-controller;
#gpio-cells = <2>;
spi-present-mask = <0x01>;
reg = <0>;
spi-max-frequency = <1000000>;
};
7 changes: 5 additions & 2 deletions Documentation/devicetree/bindings/gpio/gpio-omap.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ Required properties:
8 = active low level-sensitive.

OMAP specific properties:
- ti,hwmods: Name of the hwmod associated to the GPIO:
"gpio<X>", <X> being the 1-based instance number from the HW spec
- ti,hwmods: Name of the hwmod associated to the GPIO:
"gpio<X>", <X> being the 1-based instance number
from the HW spec.
- ti,gpio-always-on: Indicates if a GPIO bank is always powered and
so will never lose its logic state.


Example:
Expand Down
11 changes: 10 additions & 1 deletion drivers/gpio/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -297,12 +297,21 @@ config GPIO_GE_FPGA

config GPIO_LYNXPOINT
bool "Intel Lynxpoint GPIO support"
depends on ACPI
depends on ACPI && X86
select IRQ_DOMAIN
help
driver for GPIO functionality on Intel Lynxpoint PCH chipset
Requires ACPI device enumeration code to set up a platform device.

config GPIO_GRGPIO
tristate "Aeroflex Gaisler GRGPIO support"
depends on OF
select GPIO_GENERIC
select IRQ_DOMAIN
help
Select this to support Aeroflex Gaisler GRGPIO cores from the GRLIB
VHDL IP core library.

comment "I2C GPIO expanders:"

config GPIO_ARIZONA
Expand Down
1 change: 1 addition & 0 deletions drivers/gpio/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ obj-$(CONFIG_ARCH_DAVINCI) += gpio-davinci.o
obj-$(CONFIG_GPIO_EM) += gpio-em.o
obj-$(CONFIG_GPIO_EP93XX) += gpio-ep93xx.o
obj-$(CONFIG_GPIO_GE_FPGA) += gpio-ge.o
obj-$(CONFIG_GPIO_GRGPIO) += gpio-grgpio.o
obj-$(CONFIG_GPIO_ICH) += gpio-ich.o
obj-$(CONFIG_GPIO_IT8761E) += gpio-it8761e.o
obj-$(CONFIG_GPIO_JANZ_TTL) += gpio-janz-ttl.o
Expand Down
8 changes: 4 additions & 4 deletions drivers/gpio/gpio-74x164.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ static int gen_74x164_probe(struct spi_device *spi)

mutex_init(&chip->lock);

dev_set_drvdata(&spi->dev, chip);
spi_set_drvdata(spi, chip);

chip->spi = spi;

Expand Down Expand Up @@ -176,7 +176,7 @@ static int gen_74x164_probe(struct spi_device *spi)
return ret;

exit_destroy:
dev_set_drvdata(&spi->dev, NULL);
spi_set_drvdata(spi, NULL);
mutex_destroy(&chip->lock);
return ret;
}
Expand All @@ -186,11 +186,11 @@ static int gen_74x164_remove(struct spi_device *spi)
struct gen_74x164_chip *chip;
int ret;

chip = dev_get_drvdata(&spi->dev);
chip = spi_get_drvdata(spi);
if (chip == NULL)
return -ENODEV;

dev_set_drvdata(&spi->dev, NULL);
spi_set_drvdata(spi, NULL);

ret = gpiochip_remove(&chip->gpio_chip);
if (!ret)
Expand Down
4 changes: 1 addition & 3 deletions drivers/gpio/gpio-adp5520.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ static int adp5520_gpio_probe(struct platform_device *pdev)
return -ENODEV;
}

dev = kzalloc(sizeof(*dev), GFP_KERNEL);
dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
if (dev == NULL) {
dev_err(&pdev->dev, "failed to alloc memory\n");
return -ENOMEM;
Expand Down Expand Up @@ -163,7 +163,6 @@ static int adp5520_gpio_probe(struct platform_device *pdev)
return 0;

err:
kfree(dev);
return ret;
}

Expand All @@ -180,7 +179,6 @@ static int adp5520_gpio_remove(struct platform_device *pdev)
return ret;
}

kfree(dev);
return 0;
}

Expand Down
Loading

0 comments on commit 30c67e9

Please sign in to comment.