Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1701376 > unrolled thread

Re: [PATCH] gpio: add gpio_add_lookup_tables() to add several tables at once

Started byDmitry Torokhov <dmitry.torokhov@gmail.com>
First post2017-08-01 21:30 +0200
Last post2017-08-07 14:20 +0200
Articles 3 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH] gpio: add gpio_add_lookup_tables() to add several tables  at once Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2017-08-01 21:30 +0200
    Re: [PATCH] gpio: add gpio_add_lookup_tables() to add several  tables at once Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2017-08-02 14:20 +0200
      Re: [PATCH] gpio: add gpio_add_lookup_tables() to add several tables  at once Linus Walleij <linus.walleij@linaro.org> - 2017-08-07 14:20 +0200

#1701376 — Re: [PATCH] gpio: add gpio_add_lookup_tables() to add several tables at once

FromDmitry Torokhov <dmitry.torokhov@gmail.com>
Date2017-08-01 21:30 +0200
SubjectRe: [PATCH] gpio: add gpio_add_lookup_tables() to add several tables at once
Message-ID<u9L1D-85L-5@gated-at.bofh.it>
On Wed, Jul 26, 2017 at 01:21:37PM +0300, Andy Shevchenko wrote:
> On Tue, 2017-07-25 at 13:58 -0700, Dmitry Torokhov wrote:
> > When converting legacy board to use gpiod API() there migt be several
> > lookup tables in board file, let's provide a way to register them all
> > at
> > once.
> 
> Looking into the code which is using several GPIO look up tables I
> noticed that the pattern often something like
> 
> 
> gpiod_add_lookup_table(x_tbl);
> platform_device_register(x_dev);
> 
> ...
> 
> gpiod_add_lookup_table(y_tbl);
> platform_device_register(y_dev);
> 
> which looks also logical.
> 
> So, I have no strong opinion here, though it would be nice to have an
> example where it makes sense.

Here is an example. It actually does not have multiple GPIO tables, but
it allows to keep the structure of init sequence for the board, which
relies on having series of arrays conditionally populated with devices
and other data that need to be registered.

static int __init tll6527m_init(void)
{
	printk(KERN_INFO "%s(): registering device resources\n", __func__);
	gpiod_add_lookup_tables(tll6527m_gpio_tables,
				AERRAY_SIZE(tll6527m_gpio_tables));
	i2c_register_board_info(0, bfin_i2c_board_info,
				ARRAY_SIZE(bfin_i2c_board_info));
	platform_add_devices(tll6527m_devices, ARRAY_SIZE(tll6527m_devices));
	spi_register_board_info(bfin_spi_board_info,
				ARRAY_SIZE(bfin_spi_board_info));
	return 0;
}

--->8---------------------->8---------------------->8-----------------

blackfin: tll6527m: switch to using generic gpio-backlight driver

From: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Instead of having lq035q1 control backlight, let's use standard
gpio-backlight driver.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 arch/blackfin/mach-bf527/boards/tll6527m.c |   44 +++++++++++++++++++++-------
 arch/sh/boards/mach-ecovec24/setup.c       |    2 +
 2 files changed, 34 insertions(+), 12 deletions(-)

diff --git a/arch/blackfin/mach-bf527/boards/tll6527m.c b/arch/blackfin/mach-bf527/boards/tll6527m.c
index c1acce4c2e45..d7fd705a79e4 100644
--- a/arch/blackfin/mach-bf527/boards/tll6527m.c
+++ b/arch/blackfin/mach-bf527/boards/tll6527m.c
@@ -10,11 +10,13 @@
 #include <linux/device.h>
 #include <linux/export.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/partitions.h>
 #include <linux/mtd/physmap.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/flash.h>
+#include <linux/gpio/machine.h>
 #include <linux/i2c.h>
 #include <linux/irq.h>
 #include <linux/interrupt.h>
@@ -28,14 +30,6 @@
 #include <asm/portmux.h>
 #include <asm/dpmc.h>
 
-#if IS_ENABLED(CONFIG_TOUCHSCREEN_AD7879)
-#include <linux/platform_data/ad7879.h>
-#define LCD_BACKLIGHT_GPIO 0x40
-/* TLL6527M uses TLL7UIQ35 / ADI LCD EZ Extender. AD7879 AUX GPIO is used for
- * LCD Backlight Enable
- */
-#endif
-
 /*
  * Name the Board for the /proc/cpuinfo
  */
@@ -109,8 +103,6 @@ static struct platform_device musb_device = {
 static struct bfin_lq035q1fb_disp_info bfin_lq035q1_data = {
 	.mode = LQ035_NORM | LQ035_RGB | LQ035_RL | LQ035_TB,
 	.ppi_mode = USE_RGB565_16_BIT_PPI,
-	.use_bl = 1,
-	.gpio_bl = LCD_BACKLIGHT_GPIO,
 };
 
 static struct resource bfin_lq035q1_resources[] = {
@@ -132,6 +124,23 @@ static struct platform_device bfin_lq035q1_device = {
 };
 #endif
 
+#if IS_ENABLED(CONFIG_BACKLIGHT_GPIO)
+/* TLL6527M uses TLL7UIQ35 / ADI LCD EZ Extender. AD7879 AUX GPIO is used for
+ * LCD Backlight Enable
+ */
+static struct gpiod_lookup_table bfin_gpio_backlight_gpios_table = {
+	.dev_id = "gpio-backlight.0",
+	.table = {
+		GPIO_LOOKUP("AD7879-GPIO", 0, NULL, GPIO_ACTIVE_HIGH),
+		{ }
+	},
+};
+
+static struct platform_device bfin_gpio_backlight_device = {
+	.name		= "gpio-backlight",
+};
+#endif
+
 #if IS_ENABLED(CONFIG_MTD_GPIO_ADDR)
 static struct mtd_partition tll6527m_partitions[] = {
 	{
@@ -323,6 +332,7 @@ static struct bfin5xx_spi_chip  mmc_spi_chip_info = {
 #endif
 
 #if IS_ENABLED(CONFIG_TOUCHSCREEN_AD7879)
+#include <linux/platform_data/ad7879.h>
 static const struct ad7879_platform_data bfin_ad7879_ts_info = {
 	.model			= 7879,	/* Model = AD7879 */
 	.x_plate_ohms		= 620,	/* 620 Ohm from the touch datasheet */
@@ -336,7 +346,7 @@ static const struct ad7879_platform_data bfin_ad7879_ts_info = {
 				/* take the average of 4 middle samples */
 	.pen_down_acc_interval	= 255,	/* 9.4 ms */
 	.gpio_export		= 1,	/* configure AUX as GPIO output*/
-	.gpio_base		= LCD_BACKLIGHT_GPIO,
+	.gpio_base		= -1,
 };
 #endif
 
@@ -836,6 +846,10 @@ static struct platform_device *tll6527m_devices[] __initdata = {
 	&bfin_lq035q1_device,
 #endif
 
+#if IS_ENABLED(CONFIG_BACKLIGHT_GPIO)
+	&bfin_gpio_backlight_device,
+#endif
+
 #if IS_ENABLED(CONFIG_SERIAL_BFIN)
 #ifdef CONFIG_SERIAL_BFIN_UART0
 	&bfin_uart0_device,
@@ -880,9 +894,17 @@ static struct platform_device *tll6527m_devices[] __initdata = {
 #endif
 };
 
+static struct gpiod_lookup_table *tll6527m_gpio_tables[] = {
+#if IS_ENABLED(CONFIG_BACKLIGHT_GPIO)
+	&bfin_gpio_backlight_gpios_table,
+#endif
+};
+
 static int __init tll6527m_init(void)
 {
 	printk(KERN_INFO "%s(): registering device resources\n", __func__);
+	gpiod_add_lookup_tables(tll6527m_gpio_tables,
+				AERRAY_SIZE(tll6527m_gpio_tables));
 	i2c_register_board_info(0, bfin_i2c_board_info,
 				ARRAY_SIZE(bfin_i2c_board_info));
 	platform_add_devices(tll6527m_devices, ARRAY_SIZE(tll6527m_devices));
diff --git a/arch/sh/boards/mach-ecovec24/setup.c b/arch/sh/boards/mach-ecovec24/setup.c
index f59494dbfc0b..4724f8f93fd9 100644
--- a/arch/sh/boards/mach-ecovec24/setup.c
+++ b/arch/sh/boards/mach-ecovec24/setup.c
@@ -372,7 +372,7 @@ static struct platform_device lcdc_device = {
 static struct gpiod_lookup_table gpio_backlight_gpios_table = {
 	.dev_id = "gpio-backlight.0",
 	.table = {
-		GPIO_LOOKUP_IDX("sh7724_pfc", GPIO_PTR1, NULL, 0, GPIO_ACTIVE_HIGH);
+		GPIO_LOOKUP("sh7724_pfc", GPIO_PTR1, NULL, GPIO_ACTIVE_HIGH),
 		{ }
 	},
 };

-- 
Dmitry

[toc] | [next] | [standalone]


#1702068 — Re: [PATCH] gpio: add gpio_add_lookup_tables() to add several tables at once

FromAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Date2017-08-02 14:20 +0200
SubjectRe: [PATCH] gpio: add gpio_add_lookup_tables() to add several tables at once
Message-ID<ua0N4-1m9-21@gated-at.bofh.it>
In reply to#1701376
On Tue, 2017-08-01 at 12:24 -0700, Dmitry Torokhov wrote:
> On Wed, Jul 26, 2017 at 01:21:37PM +0300, Andy Shevchenko wrote:
> > On Tue, 2017-07-25 at 13:58 -0700, Dmitry Torokhov wrote:
> > > When converting legacy board to use gpiod API() there migt be
> > > several
> > > lookup tables in board file, let's provide a way to register them
> > > all
> > > at
> > > once.
> > 
> > Looking into the code which is using several GPIO look up tables I
> > noticed that the pattern often something like
> > 
> > 
> > gpiod_add_lookup_table(x_tbl);
> > platform_device_register(x_dev);
> > 
> > ...
> > 
> > gpiod_add_lookup_table(y_tbl);
> > platform_device_register(y_dev);
> > 
> > which looks also logical.
> > 
> > So, I have no strong opinion here, though it would be nice to have
> > an
> > example where it makes sense.
> 
> Here is an example. It actually does not have multiple GPIO tables,
> but
> it allows to keep the structure of init sequence for the board, which
> relies on having series of arrays conditionally populated with devices
> and other data that need to be registered.

I see your point. Okay, no objections from me.

Please, add a stub for !GPIOLIB case.

After addressing it, 

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

[toc] | [prev] | [next] | [standalone]


#1705425

FromLinus Walleij <linus.walleij@linaro.org>
Date2017-08-07 14:20 +0200
Message-ID<ubPaO-83T-13@gated-at.bofh.it>
In reply to#1702068
On Wed, Aug 2, 2017 at 2:06 PM, Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
> On Tue, 2017-08-01 at 12:24 -0700, Dmitry Torokhov wrote:
>> On Wed, Jul 26, 2017 at 01:21:37PM +0300, Andy Shevchenko wrote:
>> > On Tue, 2017-07-25 at 13:58 -0700, Dmitry Torokhov wrote:
>> > > When converting legacy board to use gpiod API() there migt be
>> > > several
>> > > lookup tables in board file, let's provide a way to register them
>> > > all
>> > > at
>> > > once.
>> >
>> > Looking into the code which is using several GPIO look up tables I
>> > noticed that the pattern often something like
>> >
>> >
>> > gpiod_add_lookup_table(x_tbl);
>> > platform_device_register(x_dev);
>> >
>> > ...
>> >
>> > gpiod_add_lookup_table(y_tbl);
>> > platform_device_register(y_dev);
>> >
>> > which looks also logical.
>> >
>> > So, I have no strong opinion here, though it would be nice to have
>> > an
>> > example where it makes sense.
>>
>> Here is an example. It actually does not have multiple GPIO tables,
>> but
>> it allows to keep the structure of init sequence for the board, which
>> relies on having series of arrays conditionally populated with devices
>> and other data that need to be registered.
>
> I see your point. Okay, no objections from me.
>
> Please, add a stub for !GPIOLIB case.
>
> After addressing it,
>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

OK I wait for the stub-inclusive patch.

Yours,
Linus Walleij

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web