ACPI / gpio: Updates to properties
Subsystems (3)
v3 cover ACPI / gpio: Updates to properties
Hi,
This series brings couple of useful GPIO related properties from Device Tree to ACPI _DSD device properties:
- Names for GPIO lines
- GPIO hogging
- Holes in GPIO property lists
We are using these to get Intel Galileo better supported in the mainline kernel (but these may be useful for other boards as well). For example SPI chip select on Galileo is connected to a GPIO line so we need to be able to describe it in ACPI, and at the same time allow native chip selects.
GPIO hogging can be used to set initial state of certain GPIOs available on the headers regardless of the BIOS settings (which may be wrong as it knows nothing about which devices have been connected).
The previous versions can be found here:
v2: http://www.spinics.net/lists/linux-acpi/msg69469.html
v1: http://www.spinics.net/lists/linux-acpi/msg69385.html
Changes from v2:
- Rebased on top of v4.9-rc1 and dropped the already applied patches.
- Reordered the series so that GPIO names which touches DT code is moved to be last one.
- Renamed acpi_gpiochip_set_names() to devprop_gpiochip_set_names() and moved it to a new file: gpiolib-devprop.c.
- Changed of_gpiochip_add() to call devprop_gpiochip_set_names() and removed of_gpiochip_set_names().
- Added ACKs from Rafael to patches 1 and 2. I did not add ACK for patches 3 and 4 because they are changed from the previous version.
The DT part is compile tested only so it would be nice if someone with ARM board could try if the GPIO names still work as expected.
Changes from v1:
- Drop patch [1/5] as it has been applied already.
- Move patch [4/5] to be the first.
- Rename acpi_data_get_property_reference() to __acpi_node_get_property_reference().
- Drop acpi_node_get_property_reference() as it is not necessary anymore.
- Add static inline wrapper acpi_node_get_property_reference() that calls the previous passing MAX_ACPI_REFERENCE_ARGS to support existing drivers.
Mika Westerberg (4):
ACPI / gpio: Allow holes in list of GPIOs for a device ACPI / gpio: Add hogging support
gpio: Rework of_gpiochip_set_names() to use device property accessors ACPI / gpio: Add support for naming GPIOs
Documentation/acpi/gpio-properties.txt | 62 +++++++++++++++++++ drivers/gpio/Makefile | 1 + drivers/gpio/gpiolib-acpi.c | 106 +++++++++++++++++++++++++++++---- drivers/gpio/gpiolib-devprop.c | 62 +++++++++++++++++++ drivers/gpio/gpiolib-of.c | 47 +-------------- drivers/gpio/gpiolib.h | 2 + 6 files changed, 223 insertions(+), 57 deletions(-) create mode 100644 drivers/gpio/gpiolib-devprop.c
Signature · 1 line
2.9.3
PATCH v3 1/4 ACPI / gpio: Allow holes in list of GPIOs for a device
Make it possible to have an empty GPIOs in a GPIO list for device. For example a SPI master may use both GPIOs and native pins as chip selects and we need to be able to distinguish between the two.
This makes it mandatory to have exactly 3 arguments for GPIOs and then converts gpiolib to use of __acpi_node_get_property_reference() instead. In addition we make acpi_gpio_package_count() to handle holes as well (this matches the DT version).
--- Documentation/acpi/gpio-properties.txt | 15 +++++++++++++++ drivers/gpio/gpiolib-acpi.c | 32 +++++++++++++++++++++----------- 2 files changed, 36 insertions(+), 11 deletions(-)
Documentation/acpi/gpio-properties.txt +15 -0
@@ -51,6 +51,21 @@ it to 1 marks the GPIO as active low. In our Bluetooth example the "reset-gpios" refers to the second GpioIo() resource, second pin in that resource with the GPIO number of 31. +It is possible to leave holes in the array of GPIOs. This is useful in +cases like with SPI host controllers where some chip selects may be +implemented as GPIOs and some as native signals. For example a SPI host +controller can have chip selects 0 and 2 implemented as GPIOs and 1 as +native: + + Package () { + "cs-gpios", + Package () { + ^GPIO, 19, 0, 0, // chip select 0: GPIO + 0, // chip select 1: native signal + ^GPIO, 20, 0, 0, // chip select 2: GPIO + } + } + ACPI GPIO Mappings Provided by Drivers --------------------------------------
drivers/gpio/gpiolib-acpi.c +21 -11
@@ -468,7 +468,8 @@ static int acpi_gpio_property_lookup(struct fwnode_handle *fwnode,int ret;memset (&args,0 ,sizeof (args)); - ret =acpi_node_get_property_reference (fwnode, propname, index, &args); + ret =__acpi_node_get_property_reference (fwnode, propname, index,3 , + &args);if (ret) {struct acpi_device *adev =to_acpi_device_node (fwnode);
@@ -483,13 +484,13 @@ static int acpi_gpio_property_lookup(struct fwnode_handle *fwnode,* on returned args. */ lookup->adev = args.adev; -if (args.nargs >=2 ) { - lookup->index = args.args[0 ]; - lookup->pin_index = args.args[1 ]; -/* 3rd argument, if present is used to specify active_low. */ -if (args.nargs >=3 ) - lookup->active_low = !!args.args[2 ]; - } +if (args.nargs !=3 ) +return -EPROTO ; + + lookup->index = args.args[0 ]; + lookup->pin_index = args.args[1 ]; + lookup->active_low = !!args.args[2 ]; +return 0 ; }
@@ -915,18 +916,27 @@ void acpi_gpiochip_remove(struct gpio_chip *chip)kfree (acpi_gpio); } -static unsigned int acpi_gpio_package_count (const union acpi_object *obj) +static int acpi_gpio_package_count (const union acpi_object *obj) {const union acpi_object *element = obj->package.elements;const union acpi_object *end = element + obj->package.count;unsigned int count =0 ;while (element < end) { -if (element->type ==ACPI_TYPE_LOCAL_REFERENCE ) +switch (element->type) { +case ACPI_TYPE_LOCAL_REFERENCE : + element +=3 ; +/* Fallthrough */ +case ACPI_TYPE_INTEGER : + element++; count++; +break ; - element++; +default : +return -EPROTO ; + } } +return count; }
Signature · 1 line
2.9.3
Re: [PATCH v3 1/4] ACPI / gpio: Allow holes in list of GPIOs for a device
Quoted 11 lines · Mika Westerberg
Make it possible to have an empty GPIOs in a GPIO list for device. For example a SPI master may use both GPIOs and native pins as chip selects and we need to be able to distinguish between the two.
This makes it mandatory to have exactly 3 arguments for GPIOs and then converts gpiolib to use of
__acpi_node_get_property_reference()instead. In addition we makeacpi_gpio_package_count()to handle holes as well (this matches the DT version).Signed-off-by Mika Westerberg <[email protected]>
Patch applied.
Yours,
Linus Walleij
PATCH v3 2/4 ACPI / gpio: Add hogging support
In reply to Mika WesterbergGPIO hogging means that the GPIO controller can "hog" and configure certain GPIOs without need for a driver or userspace to do that. This is useful in open-connected boards where BIOS cannot possibly know beforehand which devices will be connected to the board.
This adds GPIO hogging mechanism to ACPI analogous to Device Tree.
--- Documentation/acpi/gpio-properties.txt | 35 +++++++++++++++++ drivers/gpio/gpiolib-acpi.c | 71 ++++++++++++++++++++++++++++++++++ 2 files changed, 106 insertions(+)
Documentation/acpi/gpio-properties.txt +35 -0
@@ -66,6 +66,41 @@ native: } } +Other supported properties +-------------------------- + +Following Device Tree compatible device properties are also supported by +_DSD device properties for GPIO controllers: + +- gpio-hog +- output-high +- output-low +- input +- line-name + +Example: + + Name (_DSD, Package () { + // _DSD Hierarchical Properties Extension UUID + ToUUID("dbb8e3e6-5886-4ba6-8795-1319f52a966b"), + Package () { + Package () {"hog-gpio8", "G8PU"} + } + }) + + Name (G8PU, Package () { + ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), + Package () { + Package () {"gpio-hog", 1}, + Package () {"gpios", Package () {8, 0}}, + Package () {"output-high", 1}, + Package () {"line-name", "gpio8-pullup"}, + } + }) + +See Documentation/devicetree/bindings/gpio/gpio.tx for more information +about these properties. + ACPI GPIO Mappings Provided by Drivers --------------------------------------
drivers/gpio/gpiolib-acpi.c +71 -0
83 lines not on this page · raw message
Signature · 1 line
2.9.3
Re: [PATCH v3 2/4] ACPI / gpio: Add hogging support
Quoted 1 line · Mika Westerberg
+See
Documentation/devicetree/bindings/gpio/gpio.txfor more information
Andy noticed there is a typo in the above, should be .txt instead. Let me know if you want me to resend the series with this fixed.
Re: [PATCH v3 2/4] ACPI / gpio: Add hogging support
In reply to Mika WesterbergQuoted 9 lines · Mika Westerberg
GPIO hogging means that the GPIO controller can "hog" and configure certain GPIOs without need for a driver or userspace to do that. This is useful in open-connected boards where BIOS cannot possibly know beforehand which devices will be connected to the board.
This adds GPIO hogging mechanism to ACPI analogous to Device Tree.
Signed-off-by Mika Westerberg <[email protected]>
Patch applied.
Fixed the small typo in the process. No need to resend.
Yours,
Linus Walleij
PATCH v3 3/4 gpio: Rework of_gpiochip_set_names() to use device property accessors
In reply to Mika WesterbergIn order to use "gpio-line-names" property in systems not having DT as their boot firmware, rework of_gpiochip_set_names() to use device property accessors. This reworked function is placed in a separate file making it clear it deals with universal device properties.
--- drivers/gpio/Makefile | 1 + drivers/gpio/gpiolib-devprop.c | 62 ++++++++++++++++++++++++++++++++++++++++++ drivers/gpio/gpiolib-of.c | 47 +------------------------------- drivers/gpio/gpiolib.h | 2 ++ 4 files changed, 66 insertions(+), 46 deletions(-) create mode 100644 drivers/gpio/gpiolib-devprop.c
drivers/gpio/Makefile +1 -0
@@ -5,6 +5,7 @@ ccflags-$(CONFIG_DEBUG_GPIO) += -DDEBUG obj-$(CONFIG_GPIO_DEVRES) += devres.o obj-$(CONFIG_GPIOLIB) += gpiolib.o obj-$(CONFIG_GPIOLIB) += gpiolib-legacy.o +obj-$(CONFIG_GPIOLIB) += gpiolib-devprop.o obj-$(CONFIG_OF_GPIO) += gpiolib-of.o obj-$(CONFIG_GPIO_SYSFS) += gpiolib-sysfs.o obj-$(CONFIG_GPIO_ACPI) += gpiolib-acpi.o
drivers/gpio/gpiolib-devprop.c new file +62 -0
62 lines not on this page · raw message
drivers/gpio/gpiolib-of.c +1 -46
59 lines not on this page · raw message
drivers/gpio/gpiolib.h +2 -0
@@ -209,6 +209,8 @@ static int __maybe_unused gpio_chip_hwgpio(const struct gpio_desc *desc)return desc - &desc->gdev->descs[0 ]; } +void devprop_gpiochip_set_names (struct gpio_chip *chip); +/* With descriptor prefix */ #define gpiod_emerg (desc, fmt, ...) \
Signature · 1 line
2.9.3
Re: [PATCH v3 3/4] gpio: Rework of_gpiochip_set_names() to use device property accessors
Quoted 6 lines · Mika Westerberg
In order to use "gpio-line-names" property in systems not having DT as their boot firmware, rework
of_gpiochip_set_names()to use device property accessors. This reworked function is placed in a separate file making it clear it deals with universal device properties.Signed-off-by Mika Westerberg <[email protected]>
Exactly like this, thanks!
Patch applied.
Yours,
Linus Walleij
PATCH v3 4/4 ACPI / gpio: Add support for naming GPIOs
In reply to Mika WesterbergNow that we have the new helper function that sets nice names for GPIO lines based on "gpio-line-names" device property, we can take advantage of this in acpi_gpiochip_add().
--- Documentation/acpi/gpio-properties.txt | 12 ++++++++++++ drivers/gpio/gpiolib-acpi.c | 3 +++ 2 files changed, 15 insertions(+)
Documentation/acpi/gpio-properties.txt +12 -0
@@ -98,6 +98,18 @@ Example: } }) +- gpio-line-names + +Example: + + Package () { + "gpio-line-names", + Package () { + "SPI0_CS_N", "EXP2_INT", "MUX6_IO", "UART0_RXD", "MUX7_IO", + "LVL_C_A1", "MUX0_IO", "SPI1_MISO" + } + } + See Documentation/devicetree/bindings/gpio/gpio.tx for more information about these properties.
drivers/gpio/gpiolib-acpi.c +3 -0
@@ -957,6 +957,9 @@ void acpi_gpiochip_add(struct gpio_chip *chip)return ; } +if (!chip->names) +devprop_gpiochip_set_names (chip); +acpi_gpiochip_request_regions (acpi_gpio);acpi_gpiochip_scan_gpios (acpi_gpio);acpi_walk_dep_device_list (handle);
Signature · 1 line
2.9.3
Re: [PATCH v3 4/4] ACPI / gpio: Add support for naming GPIOs
Quoted 5 lines · Mika Westerberg
Now that we have the new helper function that sets nice names for GPIO lines based on "gpio-line-names" device property, we can take advantage of this in
acpi_gpiochip_add().Signed-off-by Mika Westerberg <[email protected]>
Sweet!
Patch applied.
Yours,
Linus Walleij