* [PATCH] ARM: davinci: dm646x: Convert LEDs to GPIO descriptor table
@ 2020-07-27 7:13 Linus Walleij
2020-08-03 19:48 ` Bartosz Golaszewski
2020-09-03 6:21 ` Sekhar Nori
0 siblings, 2 replies; 7+ messages in thread
From: Linus Walleij @ 2020-07-27 7:13 UTC (permalink / raw)
To: Sekhar Nori, Bartosz Golaszewski; +Cc: Linus Walleij, linux-arm-kernel
This converts the DaVinci DM646x LEDs to use GPIO
descriptor look-ups.
Cc: Sekhar Nori <nsekhar@ti.com>
Cc: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
arch/arm/mach-davinci/board-dm646x-evm.c | 33 +++++++++++++++++-------
1 file changed, 24 insertions(+), 9 deletions(-)
diff --git a/arch/arm/mach-davinci/board-dm646x-evm.c b/arch/arm/mach-davinci/board-dm646x-evm.c
index 4600b617f9b4..c303828140ac 100644
--- a/arch/arm/mach-davinci/board-dm646x-evm.c
+++ b/arch/arm/mach-davinci/board-dm646x-evm.c
@@ -20,6 +20,7 @@
#include <linux/init.h>
#include <linux/leds.h>
#include <linux/gpio.h>
+#include <linux/gpio/machine.h>
#include <linux/platform_device.h>
#include <linux/i2c.h>
#include <linux/property.h>
@@ -203,10 +204,10 @@ static struct i2c_driver dm6467evm_cpld_driver = {
/* LEDS */
static struct gpio_led evm_leds[] = {
- { .name = "DS1", .active_low = 1, },
- { .name = "DS2", .active_low = 1, },
- { .name = "DS3", .active_low = 1, },
- { .name = "DS4", .active_low = 1, },
+ { .name = "DS1" },
+ { .name = "DS2" },
+ { .name = "DS3" },
+ { .name = "DS4" },
};
static const struct gpio_led_platform_data evm_led_data = {
@@ -214,18 +215,32 @@ static const struct gpio_led_platform_data evm_led_data = {
.leds = evm_leds,
};
+static struct gpiod_lookup_table evm_leds_gpio_table = {
+ .dev_id = "leds-gpio.0",
+ .table = {
+ /*
+ * These GPIOs are on a PCF8574a GPIO expander, which
+ * is in turn named after the I2C device name. This is
+ * device "u2" on I2C bus 1 with address 0x38. These
+ * leds are at offset 4, 5, 6, 7.
+ */
+ GPIO_LOOKUP_IDX("1-0038", 4, NULL, 0, GPIO_ACTIVE_LOW),
+ GPIO_LOOKUP_IDX("1-0038", 5, NULL, 1, GPIO_ACTIVE_LOW),
+ GPIO_LOOKUP_IDX("1-0038", 6, NULL, 2, GPIO_ACTIVE_LOW),
+ GPIO_LOOKUP_IDX("1-0038", 7, NULL, 3, GPIO_ACTIVE_LOW),
+ { },
+ },
+};
+
static struct platform_device *evm_led_dev;
static int evm_led_setup(struct i2c_client *client, int gpio,
unsigned int ngpio, void *c)
{
- struct gpio_led *leds = evm_leds;
int status;
- while (ngpio--) {
- leds->gpio = gpio++;
- leds++;
- }
+ /* Add the lookup table */
+ gpiod_add_lookup_table(&evm_leds_gpio_table);
evm_led_dev = platform_device_alloc("leds-gpio", 0);
platform_device_add_data(evm_led_dev, &evm_led_data,
--
2.26.2
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] ARM: davinci: dm646x: Convert LEDs to GPIO descriptor table
2020-07-27 7:13 [PATCH] ARM: davinci: dm646x: Convert LEDs to GPIO descriptor table Linus Walleij
@ 2020-08-03 19:48 ` Bartosz Golaszewski
2020-09-03 6:21 ` Sekhar Nori
1 sibling, 0 replies; 7+ messages in thread
From: Bartosz Golaszewski @ 2020-08-03 19:48 UTC (permalink / raw)
To: Linus Walleij; +Cc: Sekhar Nori, arm-soc
On Mon, Jul 27, 2020 at 9:15 AM Linus Walleij <linus.walleij@linaro.org> wrote:
>
> This converts the DaVinci DM646x LEDs to use GPIO
> descriptor look-ups.
>
> Cc: Sekhar Nori <nsekhar@ti.com>
> Cc: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> arch/arm/mach-davinci/board-dm646x-evm.c | 33 +++++++++++++++++-------
> 1 file changed, 24 insertions(+), 9 deletions(-)
>
> diff --git a/arch/arm/mach-davinci/board-dm646x-evm.c b/arch/arm/mach-davinci/board-dm646x-evm.c
> index 4600b617f9b4..c303828140ac 100644
> --- a/arch/arm/mach-davinci/board-dm646x-evm.c
> +++ b/arch/arm/mach-davinci/board-dm646x-evm.c
> @@ -20,6 +20,7 @@
> #include <linux/init.h>
> #include <linux/leds.h>
> #include <linux/gpio.h>
> +#include <linux/gpio/machine.h>
> #include <linux/platform_device.h>
> #include <linux/i2c.h>
> #include <linux/property.h>
> @@ -203,10 +204,10 @@ static struct i2c_driver dm6467evm_cpld_driver = {
> /* LEDS */
>
> static struct gpio_led evm_leds[] = {
> - { .name = "DS1", .active_low = 1, },
> - { .name = "DS2", .active_low = 1, },
> - { .name = "DS3", .active_low = 1, },
> - { .name = "DS4", .active_low = 1, },
> + { .name = "DS1" },
> + { .name = "DS2" },
> + { .name = "DS3" },
> + { .name = "DS4" },
> };
>
> static const struct gpio_led_platform_data evm_led_data = {
> @@ -214,18 +215,32 @@ static const struct gpio_led_platform_data evm_led_data = {
> .leds = evm_leds,
> };
>
> +static struct gpiod_lookup_table evm_leds_gpio_table = {
> + .dev_id = "leds-gpio.0",
> + .table = {
> + /*
> + * These GPIOs are on a PCF8574a GPIO expander, which
> + * is in turn named after the I2C device name. This is
> + * device "u2" on I2C bus 1 with address 0x38. These
> + * leds are at offset 4, 5, 6, 7.
> + */
> + GPIO_LOOKUP_IDX("1-0038", 4, NULL, 0, GPIO_ACTIVE_LOW),
> + GPIO_LOOKUP_IDX("1-0038", 5, NULL, 1, GPIO_ACTIVE_LOW),
> + GPIO_LOOKUP_IDX("1-0038", 6, NULL, 2, GPIO_ACTIVE_LOW),
> + GPIO_LOOKUP_IDX("1-0038", 7, NULL, 3, GPIO_ACTIVE_LOW),
> + { },
> + },
> +};
> +
> static struct platform_device *evm_led_dev;
>
> static int evm_led_setup(struct i2c_client *client, int gpio,
> unsigned int ngpio, void *c)
> {
> - struct gpio_led *leds = evm_leds;
> int status;
>
> - while (ngpio--) {
> - leds->gpio = gpio++;
> - leds++;
> - }
> + /* Add the lookup table */
> + gpiod_add_lookup_table(&evm_leds_gpio_table);
>
> evm_led_dev = platform_device_alloc("leds-gpio", 0);
> platform_device_add_data(evm_led_dev, &evm_led_data,
> --
> 2.26.2
>
Looks good to me. Unfortunately I don't have this specific davinci board.
Reviewed-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] ARM: davinci: dm646x: Convert LEDs to GPIO descriptor table
2020-07-27 7:13 [PATCH] ARM: davinci: dm646x: Convert LEDs to GPIO descriptor table Linus Walleij
2020-08-03 19:48 ` Bartosz Golaszewski
@ 2020-09-03 6:21 ` Sekhar Nori
2020-09-03 6:23 ` Sekhar Nori
2020-09-03 19:49 ` Linus Walleij
1 sibling, 2 replies; 7+ messages in thread
From: Sekhar Nori @ 2020-09-03 6:21 UTC (permalink / raw)
To: Linus Walleij, Bartosz Golaszewski; +Cc: linux-arm-kernel
Hi Linus,
On 27/07/20 12:43 PM, Linus Walleij wrote:
> This converts the DaVinci DM646x LEDs to use GPIO
> descriptor look-ups.
>
> Cc: Sekhar Nori <nsekhar@ti.com>
> Cc: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
With this patch, I see during boot:
leds-gpio leds-gpio.0: cannot find GPIO chip 1-0038, deferring
leds-gpio leds-gpio.0: Skipping unavailable LED gpio 0 (DS8)
SCSI subsystem initialized
leds-gpio leds-gpio.0: cannot find GPIO chip 1-0038, deferring
leds-gpio leds-gpio.0: Skipping unavailable LED gpio 0 (DS7)
leds-gpio leds-gpio.0: cannot find GPIO chip 1-0038, deferring
leds-gpio leds-gpio.0: Skipping unavailable LED gpio 0 (DS6)
leds-gpio leds-gpio.0: cannot find GPIO chip 1-0038, deferring
leds-gpio leds-gpio.0: Skipping unavailable LED gpio 0 (DS5)
leds-gpio leds-gpio.0: cannot find GPIO chip 1-0038, deferring
leds-gpio leds-gpio.0: Skipping unavailable LED gpio 0 (DS4)
leds-gpio leds-gpio.0: cannot find GPIO chip 1-0038, deferring
leds-gpio leds-gpio.0: Skipping unavailable LED gpio 0 (DS3)
leds-gpio leds-gpio.0: cannot find GPIO chip 1-0038, deferring
scsi host0: pata_bk3710
ata1: PATA max UDMA/66 cmd 0xfec661f0 ctl 0xfec663f6 irq 38
leds-gpio leds-gpio.0: Skipping unavailable LED gpio 0 (DS2)
leds-gpio leds-gpio.0: cannot find GPIO chip 1-0038, deferring
leds-gpio leds-gpio.0: Skipping unavailable LED gpio 0 (DS1)
sysfs entries:
# ls /sys/class/i2c-dev/i2c-1/device/1-0038/
driver gpio gpiochip1 leds-gpio.0 modalias name power subsystem uevent
# cat /sys/class/i2c-dev/i2c-1/device/1-0038/leds-gpio.0/
driver/ modalias subsystem/
driver_override power/ uevent
Full boot log: https://pastebin.ubuntu.com/p/Tm6NtYS3Bq/
Log without the patch (including sysfs entries): https://pastebin.ubuntu.com/p/QsHTNhM4pD/
Thanks,
Sekhar
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] ARM: davinci: dm646x: Convert LEDs to GPIO descriptor table
2020-09-03 6:21 ` Sekhar Nori
@ 2020-09-03 6:23 ` Sekhar Nori
2020-09-03 19:49 ` Linus Walleij
1 sibling, 0 replies; 7+ messages in thread
From: Sekhar Nori @ 2020-09-03 6:23 UTC (permalink / raw)
To: Linus Walleij, Bartosz Golaszewski; +Cc: linux-arm-kernel
On 03/09/20 11:51 AM, Sekhar Nori wrote:
> Hi Linus,
>
> On 27/07/20 12:43 PM, Linus Walleij wrote:
>> This converts the DaVinci DM646x LEDs to use GPIO
>> descriptor look-ups.
>>
>> Cc: Sekhar Nori <nsekhar@ti.com>
>> Cc: Bartosz Golaszewski <bgolaszewski@baylibre.com>
>> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
>
> With this patch, I see during boot:
Oops, I replied to the wrong patch. This result is for the very similar
patch "[PATCH] ARM: davinci: dm644x: Convert LEDs to GPIO descriptor table".
Something wrong with my DM6467 board, not able to boot it. Will test
this patch once I fix that.
Thanks,
Sekhar
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] ARM: davinci: dm646x: Convert LEDs to GPIO descriptor table
2020-09-03 6:21 ` Sekhar Nori
2020-09-03 6:23 ` Sekhar Nori
@ 2020-09-03 19:49 ` Linus Walleij
2020-09-08 4:18 ` Sekhar Nori
1 sibling, 1 reply; 7+ messages in thread
From: Linus Walleij @ 2020-09-03 19:49 UTC (permalink / raw)
To: Sekhar Nori; +Cc: Bartosz Golaszewski, Linux ARM
On Thu, Sep 3, 2020 at 8:21 AM Sekhar Nori <nsekhar@ti.com> wrote:
> With this patch, I see during boot:
>
> leds-gpio leds-gpio.0: cannot find GPIO chip 1-0038, deferring
How annoying :(
Yet this is in the boot log:
pcf857x 1-0038: probed
And when I look inte pcf857x driver I see this:
gpio->chip.label = client->name;
So it "should" be named "1-0038".
Can you check in /sys/kernel/debug/gpio what name this
GPIO chip actually gets?
Yours,
Linus Walleij
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] ARM: davinci: dm646x: Convert LEDs to GPIO descriptor table
2020-09-03 19:49 ` Linus Walleij
@ 2020-09-08 4:18 ` Sekhar Nori
0 siblings, 0 replies; 7+ messages in thread
From: Sekhar Nori @ 2020-09-08 4:18 UTC (permalink / raw)
To: Linus Walleij; +Cc: Bartosz Golaszewski, Linux ARM
Hi Linus,
On 04/09/20 1:19 AM, Linus Walleij wrote:
> On Thu, Sep 3, 2020 at 8:21 AM Sekhar Nori <nsekhar@ti.com> wrote:
>
>> With this patch, I see during boot:
>>
>> leds-gpio leds-gpio.0: cannot find GPIO chip 1-0038, deferring
>
> How annoying :(
>
> Yet this is in the boot log:
>
> pcf857x 1-0038: probed
>
> And when I look inte pcf857x driver I see this:
>
> gpio->chip.label = client->name;
>
> So it "should" be named "1-0038".
>
> Can you check in /sys/kernel/debug/gpio what name this
> GPIO chip actually gets?
Here is the output. With patches applied:
# cat /sys/kernel/debug/gpio
gpiochip0: GPIOs 0-70, parent: platform/davinci_gpio, davinci_gpio:
gpio-43 ( |scl ) out lo
gpio-44 ( |sda ) in lo
gpiochip1: GPIOs 144-151, parent: i2c/1-0038, pcf8574, can sleep:
gpiochip2: GPIOs 152-159, parent: i2c/1-0039, pcf8574, can sleep:
gpio-153 ( |pll_sr ) out lo
gpio-154 ( |pll_fs1 ) out lo
gpio-155 ( |pll_fs2 ) out lo
gpio-159 ( |user_sw ) in hi
gpiochip3: GPIOs 160-167, parent: i2c/1-003a, pcf8574, can sleep:
gpio-160 ( |nDRV_VBUS ) out hi
gpio-161 ( |VDDIMX_EN ) out hi
gpio-162 ( |VLYNQ_EN ) out hi
gpio-163 ( |nCF_RESET ) out lo
gpio-165 ( |WLAN_RESET ) out hi
gpio-166 ( |nATA_SEL ) out lo
gpio-167 ( |nCF_SEL ) out hi
Without patches applied:
# cat /sys/kernel/debug/gpio
gpiochip0: GPIOs 0-70, parent: platform/davinci_gpio, davinci_gpio:
gpio-43 ( |scl ) out lo
gpio-44 ( |sda ) in lo
gpiochip1: GPIOs 144-151, parent: i2c/1-0038, pcf8574, can sleep:
gpio-144 ( |DS8 ) out hi ACTIVE LOW
gpio-145 ( |DS7 ) out hi ACTIVE LOW
gpio-146 ( |DS6 ) out hi ACTIVE LOW
gpio-147 ( |DS5 ) out hi ACTIVE LOW
gpio-148 ( |DS4 ) out hi ACTIVE LOW
gpio-149 ( |DS3 ) out hi ACTIVE LOW
gpio-150 ( |DS2 ) out hi ACTIVE LOW
gpio-151 ( |DS1 ) out hi ACTIVE LOW
gpiochip2: GPIOs 152-159, parent: i2c/1-0039, pcf8574, can sleep:
gpio-153 ( |pll_sr ) out lo
gpio-154 ( |pll_fs1 ) out lo
gpio-155 ( |pll_fs2 ) out lo
gpio-159 ( |user_sw ) in hi
gpiochip3: GPIOs 160-167, parent: i2c/1-003a, pcf8574, can sleep:
gpio-160 ( |nDRV_VBUS ) out hi
gpio-161 ( |VDDIMX_EN ) out hi
gpio-162 ( |VLYNQ_EN ) out hi
gpio-163 ( |nCF_RESET ) out lo
gpio-165 ( |WLAN_RESET ) out hi
gpio-166 ( |nATA_SEL ) out lo
gpio-167 ( |nCF_SEL ) out hi
Thanks,
Sekhar
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] ARM: davinci: dm646x: Convert LEDs to GPIO descriptor table
@ 2020-08-26 14:31 Linus Walleij
0 siblings, 0 replies; 7+ messages in thread
From: Linus Walleij @ 2020-08-26 14:31 UTC (permalink / raw)
To: Sekhar Nori, Bartosz Golaszewski; +Cc: Linus Walleij, linux-arm-kernel
This converts the DaVinci DM646x LEDs to use GPIO
descriptor look-ups.
Cc: Sekhar Nori <nsekhar@ti.com>
Cc: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Reviewed-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
ChangeLog v1->v2:
- Collect Bartosz' review tag
- Rebase on v5.9-rc1
- Resend
---
arch/arm/mach-davinci/board-dm646x-evm.c | 33 +++++++++++++++++-------
1 file changed, 24 insertions(+), 9 deletions(-)
diff --git a/arch/arm/mach-davinci/board-dm646x-evm.c b/arch/arm/mach-davinci/board-dm646x-evm.c
index dd7d60f4139a..1395352723b0 100644
--- a/arch/arm/mach-davinci/board-dm646x-evm.c
+++ b/arch/arm/mach-davinci/board-dm646x-evm.c
@@ -20,6 +20,7 @@
#include <linux/init.h>
#include <linux/leds.h>
#include <linux/gpio.h>
+#include <linux/gpio/machine.h>
#include <linux/platform_device.h>
#include <linux/i2c.h>
#include <linux/property.h>
@@ -203,10 +204,10 @@ static struct i2c_driver dm6467evm_cpld_driver = {
/* LEDS */
static struct gpio_led evm_leds[] = {
- { .name = "DS1", .active_low = 1, },
- { .name = "DS2", .active_low = 1, },
- { .name = "DS3", .active_low = 1, },
- { .name = "DS4", .active_low = 1, },
+ { .name = "DS1" },
+ { .name = "DS2" },
+ { .name = "DS3" },
+ { .name = "DS4" },
};
static const struct gpio_led_platform_data evm_led_data = {
@@ -214,18 +215,32 @@ static const struct gpio_led_platform_data evm_led_data = {
.leds = evm_leds,
};
+static struct gpiod_lookup_table evm_leds_gpio_table = {
+ .dev_id = "leds-gpio.0",
+ .table = {
+ /*
+ * These GPIOs are on a PCF8574a GPIO expander, which
+ * is in turn named after the I2C device name. This is
+ * device "u2" on I2C bus 1 with address 0x38. These
+ * leds are at offset 4, 5, 6, 7.
+ */
+ GPIO_LOOKUP_IDX("1-0038", 4, NULL, 0, GPIO_ACTIVE_LOW),
+ GPIO_LOOKUP_IDX("1-0038", 5, NULL, 1, GPIO_ACTIVE_LOW),
+ GPIO_LOOKUP_IDX("1-0038", 6, NULL, 2, GPIO_ACTIVE_LOW),
+ GPIO_LOOKUP_IDX("1-0038", 7, NULL, 3, GPIO_ACTIVE_LOW),
+ { },
+ },
+};
+
static struct platform_device *evm_led_dev;
static int evm_led_setup(struct i2c_client *client, int gpio,
unsigned int ngpio, void *c)
{
- struct gpio_led *leds = evm_leds;
int status;
- while (ngpio--) {
- leds->gpio = gpio++;
- leds++;
- }
+ /* Add the lookup table */
+ gpiod_add_lookup_table(&evm_leds_gpio_table);
evm_led_dev = platform_device_alloc("leds-gpio", 0);
platform_device_add_data(evm_led_dev, &evm_led_data,
--
2.26.2
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2020-09-08 4:20 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-27 7:13 [PATCH] ARM: davinci: dm646x: Convert LEDs to GPIO descriptor table Linus Walleij
2020-08-03 19:48 ` Bartosz Golaszewski
2020-09-03 6:21 ` Sekhar Nori
2020-09-03 6:23 ` Sekhar Nori
2020-09-03 19:49 ` Linus Walleij
2020-09-08 4:18 ` Sekhar Nori
2020-08-26 14:31 Linus Walleij
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).