Skip to content

Commit 767d833

Browse files
author
Linus Walleij
committed
Input: ads7846 - Convert to use software nodes
The Nokia 770 is using GPIOs from the global numberspace on the CBUS node to pass down to the LCD controller. This regresses when we let the OMAP GPIO driver use dynamic GPIO base. The Nokia 770 now has dynamic allocation of IRQ numbers, so this needs to be fixed for it to work. As this is the only user of LCD MIPID we can easily augment the driver to use a GPIO descriptor instead and resolve the issue. The platform data .shutdown() callback wasn't even used in the code, but we encode a shutdown asserting RESET in the remove() callback for completeness sake. The CBUS also has the ADS7846 touchscreen attached. Populate the devices on the Nokia 770 CBUS I2C using software nodes instead of platform data quirks. This includes the LCD and the ADS7846 touchscreen so the conversion just brings the LCD along with it as software nodes is an all-or-nothing design pattern. The ADS7846 has some limited support for using GPIO descriptors, let's convert it over completely to using device properties and then fix all remaining boardfile users to provide all platform data using software nodes. Dump the of includes and of_match_ptr() in the ADS7846 driver as part of the job. Since we have to move ADS7846 over to obtaining the GPIOs it is using exclusively from descriptors, we provide descriptor tables for the two remaining in-kernel boardfiles using ADS7846: - PXA Spitz - MIPS Alchemy DB1000 development board It was too hard for me to include software node conversion of these two remaining users at this time: the spitz is using a hscync callback in the platform data that would require further GPIO descriptor conversion of the Spitz, and moving the hsync callback down into the driver: it will just become too big of a job, but it can be done separately. The MIPS Alchemy DB1000 is simply something I cannot test, so take the easier approach of just providing some GPIO descriptors in this case as I don't want the patch to grow too intrusive. As we see that several device trees have incorrect polarity flags and just expect to bypass the gpiolib polarity handling, fix up all device trees too, in a separate patch. Suggested-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Fixes: 92bf78b ("gpio: omap: use dynamic allocation of base") Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Reviewed-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
1 parent 480c82d commit 767d833

7 files changed

Lines changed: 136 additions & 112 deletions

File tree

arch/arm/mach-omap1/board-nokia770.c

Lines changed: 65 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,16 @@
88
#include <linux/irq.h>
99
#include <linux/gpio.h>
1010
#include <linux/gpio/machine.h>
11+
#include <linux/gpio/property.h>
1112
#include <linux/kernel.h>
1213
#include <linux/init.h>
1314
#include <linux/mutex.h>
1415
#include <linux/platform_device.h>
16+
#include <linux/property.h>
1517
#include <linux/input.h>
1618
#include <linux/omapfb.h>
1719

1820
#include <linux/spi/spi.h>
19-
#include <linux/spi/ads7846.h>
2021
#include <linux/workqueue.h>
2122
#include <linux/delay.h>
2223

@@ -35,6 +36,25 @@
3536
#include "clock.h"
3637
#include "mmc.h"
3738

39+
static const struct software_node nokia770_mpuio_gpiochip_node = {
40+
.name = "mpuio",
41+
};
42+
43+
static const struct software_node nokia770_gpiochip1_node = {
44+
.name = "gpio-0-15",
45+
};
46+
47+
static const struct software_node nokia770_gpiochip2_node = {
48+
.name = "gpio-16-31",
49+
};
50+
51+
static const struct software_node *nokia770_gpiochip_nodes[] = {
52+
&nokia770_mpuio_gpiochip_node,
53+
&nokia770_gpiochip1_node,
54+
&nokia770_gpiochip2_node,
55+
NULL
56+
};
57+
3858
#define ADS7846_PENDOWN_GPIO 15
3959

4060
static const unsigned int nokia770_keymap[] = {
@@ -85,40 +105,47 @@ static struct platform_device *nokia770_devices[] __initdata = {
85105
&nokia770_kp_device,
86106
};
87107

88-
static void mipid_shutdown(struct mipid_platform_data *pdata)
89-
{
90-
if (pdata->nreset_gpio != -1) {
91-
printk(KERN_INFO "shutdown LCD\n");
92-
gpio_set_value(pdata->nreset_gpio, 0);
93-
msleep(120);
94-
}
95-
}
96-
97-
static struct mipid_platform_data nokia770_mipid_platform_data = {
98-
.shutdown = mipid_shutdown,
99-
};
108+
static struct mipid_platform_data nokia770_mipid_platform_data = { };
100109

101110
static const struct omap_lcd_config nokia770_lcd_config __initconst = {
102111
.ctrl_name = "hwa742",
103112
};
104113

114+
static const struct property_entry nokia770_mipid_props[] = {
115+
PROPERTY_ENTRY_GPIO("reset-gpios", &nokia770_gpiochip1_node,
116+
13, GPIO_ACTIVE_LOW),
117+
{ }
118+
};
119+
120+
static const struct software_node nokia770_mipid_swnode = {
121+
.name = "lcd_mipid",
122+
.properties = nokia770_mipid_props,
123+
};
124+
105125
static void __init mipid_dev_init(void)
106126
{
107-
nokia770_mipid_platform_data.nreset_gpio = 13;
108127
nokia770_mipid_platform_data.data_lines = 16;
109128

110129
omapfb_set_lcd_config(&nokia770_lcd_config);
111130
}
112131

113-
static struct ads7846_platform_data nokia770_ads7846_platform_data __initdata = {
114-
.x_max = 0x0fff,
115-
.y_max = 0x0fff,
116-
.x_plate_ohms = 180,
117-
.pressure_max = 255,
118-
.debounce_max = 10,
119-
.debounce_tol = 3,
120-
.debounce_rep = 1,
121-
.gpio_pendown = ADS7846_PENDOWN_GPIO,
132+
static const struct property_entry nokia770_ads7846_props[] = {
133+
PROPERTY_ENTRY_STRING("compatible", "ti,ads7846"),
134+
PROPERTY_ENTRY_U32("touchscreen-size-x", 4096),
135+
PROPERTY_ENTRY_U32("touchscreen-size-y", 4096),
136+
PROPERTY_ENTRY_U32("touchscreen-max-pressure", 256),
137+
PROPERTY_ENTRY_U32("touchscreen-average-samples", 10),
138+
PROPERTY_ENTRY_U16("ti,x-plate-ohms", 180),
139+
PROPERTY_ENTRY_U16("ti,debounce-tol", 3),
140+
PROPERTY_ENTRY_U16("ti,debounce-rep", 1),
141+
PROPERTY_ENTRY_GPIO("pendown-gpios", &nokia770_gpiochip1_node,
142+
ADS7846_PENDOWN_GPIO, GPIO_ACTIVE_LOW),
143+
{ }
144+
};
145+
146+
static const struct software_node nokia770_ads7846_swnode = {
147+
.name = "ads7846",
148+
.properties = nokia770_ads7846_props,
122149
};
123150

124151
static struct spi_board_info nokia770_spi_board_info[] __initdata = {
@@ -128,13 +155,14 @@ static struct spi_board_info nokia770_spi_board_info[] __initdata = {
128155
.chip_select = 3,
129156
.max_speed_hz = 12000000,
130157
.platform_data = &nokia770_mipid_platform_data,
158+
.swnode = &nokia770_mipid_swnode,
131159
},
132160
[1] = {
133161
.modalias = "ads7846",
134162
.bus_num = 2,
135163
.chip_select = 0,
136164
.max_speed_hz = 2500000,
137-
.platform_data = &nokia770_ads7846_platform_data,
165+
.swnode = &nokia770_ads7846_swnode,
138166
},
139167
};
140168

@@ -212,14 +240,16 @@ static inline void nokia770_mmc_init(void)
212240
#endif
213241

214242
#if IS_ENABLED(CONFIG_I2C_CBUS_GPIO)
215-
static struct gpiod_lookup_table nokia770_cbus_gpio_table = {
216-
.dev_id = "i2c-cbus-gpio.2",
217-
.table = {
218-
GPIO_LOOKUP_IDX("mpuio", 9, NULL, 0, 0), /* clk */
219-
GPIO_LOOKUP_IDX("mpuio", 10, NULL, 1, 0), /* dat */
220-
GPIO_LOOKUP_IDX("mpuio", 11, NULL, 2, 0), /* sel */
221-
{ },
222-
},
243+
244+
static const struct software_node_ref_args nokia770_cbus_gpio_refs[] = {
245+
SOFTWARE_NODE_REFERENCE(&nokia770_mpuio_gpiochip_node, 9, 0),
246+
SOFTWARE_NODE_REFERENCE(&nokia770_mpuio_gpiochip_node, 10, 0),
247+
SOFTWARE_NODE_REFERENCE(&nokia770_mpuio_gpiochip_node, 11, 0),
248+
};
249+
250+
static const struct property_entry nokia770_cbus_props[] = {
251+
PROPERTY_ENTRY_REF_ARRAY("gpios", nokia770_cbus_gpio_refs),
252+
{ }
223253
};
224254

225255
static struct platform_device nokia770_cbus_device = {
@@ -253,7 +283,8 @@ static void __init nokia770_cbus_init(void)
253283
nokia770_i2c_board_info_2[1].irq = gpio_to_irq(tahvo_irq_gpio);
254284
i2c_register_board_info(2, nokia770_i2c_board_info_2,
255285
ARRAY_SIZE(nokia770_i2c_board_info_2));
256-
gpiod_add_lookup_table(&nokia770_cbus_gpio_table);
286+
device_create_managed_software_node(&nokia770_cbus_device.dev,
287+
nokia770_cbus_props, NULL);
257288
platform_device_register(&nokia770_cbus_device);
258289
}
259290
#else /* CONFIG_I2C_CBUS_GPIO */
@@ -273,8 +304,8 @@ static void __init omap_nokia770_init(void)
273304
/* Unmask SleepX signal */
274305
omap_writew((omap_readw(0xfffb5004) & ~2), 0xfffb5004);
275306

307+
software_node_register_node_group(nokia770_gpiochip_nodes);
276308
platform_add_devices(nokia770_devices, ARRAY_SIZE(nokia770_devices));
277-
nokia770_spi_board_info[1].irq = gpio_to_irq(15);
278309
spi_register_board_info(nokia770_spi_board_info,
279310
ARRAY_SIZE(nokia770_spi_board_info));
280311
omap_serial_init();

arch/arm/mach-pxa/spitz.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,10 +506,18 @@ static struct ads7846_platform_data spitz_ads7846_info = {
506506
.x_plate_ohms = 419,
507507
.y_plate_ohms = 486,
508508
.pressure_max = 1024,
509-
.gpio_pendown = SPITZ_GPIO_TP_INT,
510509
.wait_for_sync = spitz_ads7846_wait_for_hsync,
511510
};
512511

512+
static struct gpiod_lookup_table spitz_ads7846_gpio_table = {
513+
.dev_id = "spi2.0",
514+
.table = {
515+
GPIO_LOOKUP("gpio-pxa", SPITZ_GPIO_TP_INT,
516+
"pendown", GPIO_ACTIVE_LOW),
517+
{ }
518+
},
519+
};
520+
513521
static void spitz_bl_kick_battery(void)
514522
{
515523
void (*kick_batt)(void);
@@ -594,6 +602,7 @@ static void __init spitz_spi_init(void)
594602
else
595603
gpiod_add_lookup_table(&spitz_lcdcon_gpio_table);
596604

605+
gpiod_add_lookup_table(&spitz_ads7846_gpio_table);
597606
gpiod_add_lookup_table(&spitz_spi_gpio_table);
598607
pxa2xx_set_spi_info(2, &spitz_spi_info);
599608
spi_register_board_info(ARRAY_AND_SIZE(spitz_spi_devices));

arch/mips/alchemy/devboards/db1000.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,13 +381,21 @@ static struct platform_device db1100_mmc1_dev = {
381381
static struct ads7846_platform_data db1100_touch_pd = {
382382
.model = 7846,
383383
.vref_mv = 3300,
384-
.gpio_pendown = 21,
385384
};
386385

387386
static struct spi_gpio_platform_data db1100_spictl_pd = {
388387
.num_chipselect = 1,
389388
};
390389

390+
static struct gpiod_lookup_table db1100_touch_gpio_table = {
391+
.dev_id = "spi0.0",
392+
.table = {
393+
GPIO_LOOKUP("alchemy-gpio2", 21,
394+
"pendown", GPIO_ACTIVE_LOW),
395+
{ }
396+
},
397+
};
398+
391399
static struct spi_board_info db1100_spi_info[] __initdata = {
392400
[0] = {
393401
.modalias = "ads7846",
@@ -474,6 +482,7 @@ int __init db1000_dev_setup(void)
474482
pfc |= (1 << 0); /* SSI0 pins as GPIOs */
475483
alchemy_wrsys(pfc, AU1000_SYS_PINFUNC);
476484

485+
gpiod_add_lookup_table(&db1100_touch_gpio_table);
477486
spi_register_board_info(db1100_spi_info,
478487
ARRAY_SIZE(db1100_spi_info));
479488

0 commit comments

Comments
 (0)