From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
Linus Walleij <linus.walleij@linaro.org>
Cc: Alexandre Courbot <gnurou@gmail.com>,
linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org,
Mika Westerberg <mika.westerberg@linux.intel.com>
Subject: [PATCH 2/5] ACPI / gpio: Add support for naming GPIOs
Date: Fri, 23 Sep 2016 17:57:07 +0300 [thread overview]
Message-ID: <20160923145710.105489-3-mika.westerberg@linux.intel.com> (raw)
In-Reply-To: <20160923145710.105489-1-mika.westerberg@linux.intel.com>
DT has property 'gpio-line-names' to name GPIO lines the controller has if
present. Use this very same property in ACPI as well to provide nice names
for the GPIOS.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
Documentation/acpi/gpio-properties.txt | 21 +++++++++++++++++
drivers/gpio/gpiolib-acpi.c | 43 ++++++++++++++++++++++++++++++++++
2 files changed, 64 insertions(+)
diff --git a/Documentation/acpi/gpio-properties.txt b/Documentation/acpi/gpio-properties.txt
index 5aafe0b351a1..7875974823ae 100644
--- a/Documentation/acpi/gpio-properties.txt
+++ b/Documentation/acpi/gpio-properties.txt
@@ -51,6 +51,27 @@ 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.
+Other supported properties
+--------------------------
+
+Following Device Tree compatible device properties are also supported by
+_DSD device properties for GPIO controllers:
+
+- 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.
+
ACPI GPIO Mappings Provided by Drivers
--------------------------------------
diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
index af514618d7fb..202cf1b842de 100644
--- a/drivers/gpio/gpiolib-acpi.c
+++ b/drivers/gpio/gpiolib-acpi.c
@@ -805,6 +805,46 @@ static void acpi_gpiochip_free_regions(struct acpi_gpio_chip *achip)
}
}
+static void acpi_gpiochip_set_names(struct acpi_gpio_chip *achip)
+{
+ struct gpio_chip *chip = achip->chip;
+ struct gpio_device *gdev = chip->gpiodev;
+ const char **names;
+ int ret, i;
+
+ ret = device_property_read_string_array(chip->parent, "gpio-line-names",
+ NULL, 0);
+ if (ret < 0)
+ return;
+
+ if (ret != gdev->ngpio) {
+ dev_warn(chip->parent,
+ "names %d do not match number of GPIOs %d\n", ret,
+ gdev->ngpio);
+ return;
+ }
+
+ names = kcalloc(gdev->ngpio, sizeof(*names), GFP_KERNEL);
+ if (!names)
+ return;
+
+ ret = device_property_read_string_array(chip->parent, "gpio-line-names",
+ names, gdev->ngpio);
+ if (ret < 0) {
+ dev_warn(chip->parent, "Failed to read GPIO line names\n");
+ return;
+ }
+
+ /*
+ * It is fine to assign the name, it will be allocated as long as
+ * the ACPI device exists.
+ */
+ for (i = 0; i < gdev->ngpio; i++)
+ gdev->descs[i].name = names[i];
+
+ kfree(names);
+}
+
void acpi_gpiochip_add(struct gpio_chip *chip)
{
struct acpi_gpio_chip *acpi_gpio;
@@ -835,6 +875,9 @@ void acpi_gpiochip_add(struct gpio_chip *chip)
return;
}
+ if (!chip->names)
+ acpi_gpiochip_set_names(acpi_gpio);
+
acpi_gpiochip_request_regions(acpi_gpio);
acpi_walk_dep_device_list(handle);
}
--
2.9.3
next prev parent reply other threads:[~2016-09-23 14:57 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-23 14:57 [PATCH 0/5] ACPI / gpio: Updates to properties Mika Westerberg
2016-09-23 14:57 ` [PATCH 1/5] ACPI / documentation: Use recommended name in GPIO property names Mika Westerberg
2016-09-23 14:57 ` Mika Westerberg [this message]
2016-09-23 14:57 ` [PATCH 3/5] ACPI / gpio: Add hogging support Mika Westerberg
2016-09-23 14:57 ` [PATCH 4/5] ACPI / property: Allow holes in reference properties Mika Westerberg
2016-09-28 21:36 ` Rafael J. Wysocki
2016-09-29 6:48 ` Mika Westerberg
2016-09-29 11:53 ` Rafael J. Wysocki
2016-09-29 11:56 ` Mika Westerberg
2016-09-29 12:33 ` Rafael J. Wysocki
2016-09-23 14:57 ` [PATCH 5/5] ACPI / gpio: Allow holes in list of GPIOs for a device Mika Westerberg
2016-09-28 21:32 ` [PATCH 0/5] ACPI / gpio: Updates to properties Rafael J. Wysocki
2016-09-29 7:00 ` Mika Westerberg
2016-09-29 12:26 ` Rafael J. Wysocki
2016-10-19 12:41 ` Mika Westerberg
2016-10-19 21:22 ` Rafael J. Wysocki
2016-10-20 7:46 ` Mika Westerberg
2016-10-20 12:17 ` Linus Walleij
2016-10-20 12:35 ` Mika Westerberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160923145710.105489-3-mika.westerberg@linux.intel.com \
--to=mika.westerberg@linux.intel.com \
--cc=gnurou@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rjw@rjwysocki.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).