Skip to content

Commit 0b47a62

Browse files
committed
Merge tag 'gpio-omap-descriptors-v6.5' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio into soc/arm
This removes all usage of global GPIO numbers from arch/arm/mach-omap[12]. The patches have been reviewed and tested by everyone who showed interest which was one person that tested on OSK1 and Nokia 770, and we smoked out the bugs and also addressed all review comments. Any remaining problems can certainly be fixed in-tree. * tag 'gpio-omap-descriptors-v6.5' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio: ARM/musb: omap2: Remove global GPIO numbers from TUSB6010 ARM: omap2: Rewrite WLAN quirk to use GPIO descriptors ARM: omap2: Get USB hub reset GPIO from descriptor ARM/gpio: Push OMAP2 quirk down into TWL4030 driver ARM: omap1: Exorcise the legacy GPIO header ARM: omap1: Make serial wakeup GPIOs use descriptors ARM: omap1: Fix up the Nokia 770 board device IRQs ARM/mmc: Convert old mmci-omap to GPIO descriptors Input: ads7846 - Convert to use software nodes ARM: omap1: Remove reliance on GPIO numbers from SX1 ARM: omap1: Remove reliance on GPIO numbers from PalmTE ARM: omap1: Drop header on AMS Delta ARM/mfd/gpio: Fixup TPS65010 regression on OMAP1 OSK1 Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2 parents 88813f0 + 8e0285a commit 0b47a62

32 files changed

Lines changed: 636 additions & 511 deletions

File tree

arch/arm/mach-omap1/board-ams-delta.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include <linux/gpio/driver.h>
1212
#include <linux/gpio/machine.h>
1313
#include <linux/gpio/consumer.h>
14-
#include <linux/gpio.h>
1514
#include <linux/kernel.h>
1615
#include <linux/init.h>
1716
#include <linux/input.h>

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

Lines changed: 130 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,18 @@
66
*/
77
#include <linux/clkdev.h>
88
#include <linux/irq.h>
9-
#include <linux/gpio.h>
9+
#include <linux/gpio/consumer.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

@@ -156,27 +184,23 @@ static struct omap_usb_config nokia770_usb_config __initdata = {
156184

157185
#if IS_ENABLED(CONFIG_MMC_OMAP)
158186

159-
#define NOKIA770_GPIO_MMC_POWER 41
160-
#define NOKIA770_GPIO_MMC_SWITCH 23
161-
162-
static int nokia770_mmc_set_power(struct device *dev, int slot, int power_on,
163-
int vdd)
164-
{
165-
gpio_set_value(NOKIA770_GPIO_MMC_POWER, power_on);
166-
return 0;
167-
}
168-
169-
static int nokia770_mmc_get_cover_state(struct device *dev, int slot)
170-
{
171-
return gpio_get_value(NOKIA770_GPIO_MMC_SWITCH);
172-
}
187+
static struct gpiod_lookup_table nokia770_mmc_gpio_table = {
188+
.dev_id = "mmci-omap.1",
189+
.table = {
190+
/* Slot index 0, VSD power, GPIO 41 */
191+
GPIO_LOOKUP_IDX("gpio-32-47", 9,
192+
"vsd", 0, GPIO_ACTIVE_HIGH),
193+
/* Slot index 0, switch, GPIO 23 */
194+
GPIO_LOOKUP_IDX("gpio-16-31", 7,
195+
"cover", 0, GPIO_ACTIVE_HIGH),
196+
{ }
197+
},
198+
};
173199

174200
static struct omap_mmc_platform_data nokia770_mmc2_data = {
175201
.nr_slots = 1,
176202
.max_freq = 12000000,
177203
.slots[0] = {
178-
.set_power = nokia770_mmc_set_power,
179-
.get_cover_state = nokia770_mmc_get_cover_state,
180204
.ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
181205
.name = "mmcblk",
182206
},
@@ -186,20 +210,7 @@ static struct omap_mmc_platform_data *nokia770_mmc_data[OMAP16XX_NR_MMC];
186210

187211
static void __init nokia770_mmc_init(void)
188212
{
189-
int ret;
190-
191-
ret = gpio_request(NOKIA770_GPIO_MMC_POWER, "MMC power");
192-
if (ret < 0)
193-
return;
194-
gpio_direction_output(NOKIA770_GPIO_MMC_POWER, 0);
195-
196-
ret = gpio_request(NOKIA770_GPIO_MMC_SWITCH, "MMC cover");
197-
if (ret < 0) {
198-
gpio_free(NOKIA770_GPIO_MMC_POWER);
199-
return;
200-
}
201-
gpio_direction_input(NOKIA770_GPIO_MMC_SWITCH);
202-
213+
gpiod_add_lookup_table(&nokia770_mmc_gpio_table);
203214
/* Only the second MMC controller is used */
204215
nokia770_mmc_data[1] = &nokia770_mmc2_data;
205216
omap1_init_mmc(nokia770_mmc_data, OMAP16XX_NR_MMC);
@@ -212,14 +223,16 @@ static inline void nokia770_mmc_init(void)
212223
#endif
213224

214225
#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-
},
226+
227+
static const struct software_node_ref_args nokia770_cbus_gpio_refs[] = {
228+
SOFTWARE_NODE_REFERENCE(&nokia770_mpuio_gpiochip_node, 9, 0),
229+
SOFTWARE_NODE_REFERENCE(&nokia770_mpuio_gpiochip_node, 10, 0),
230+
SOFTWARE_NODE_REFERENCE(&nokia770_mpuio_gpiochip_node, 11, 0),
231+
};
232+
233+
static const struct property_entry nokia770_cbus_props[] = {
234+
PROPERTY_ENTRY_REF_ARRAY("gpios", nokia770_cbus_gpio_refs),
235+
{ }
223236
};
224237

225238
static struct platform_device nokia770_cbus_device = {
@@ -238,22 +251,29 @@ static struct i2c_board_info nokia770_i2c_board_info_2[] __initdata = {
238251

239252
static void __init nokia770_cbus_init(void)
240253
{
241-
const int retu_irq_gpio = 62;
242-
const int tahvo_irq_gpio = 40;
243-
244-
if (gpio_request_one(retu_irq_gpio, GPIOF_IN, "Retu IRQ"))
245-
return;
246-
if (gpio_request_one(tahvo_irq_gpio, GPIOF_IN, "Tahvo IRQ")) {
247-
gpio_free(retu_irq_gpio);
248-
return;
254+
struct gpio_desc *d;
255+
int irq;
256+
257+
d = gpiod_get(NULL, "retu_irq", GPIOD_IN);
258+
if (IS_ERR(d)) {
259+
pr_err("Unable to get CBUS Retu IRQ GPIO descriptor\n");
260+
} else {
261+
irq = gpiod_to_irq(d);
262+
irq_set_irq_type(irq, IRQ_TYPE_EDGE_RISING);
263+
nokia770_i2c_board_info_2[0].irq = irq;
264+
}
265+
d = gpiod_get(NULL, "tahvo_irq", GPIOD_IN);
266+
if (IS_ERR(d)) {
267+
pr_err("Unable to get CBUS Tahvo IRQ GPIO descriptor\n");
268+
} else {
269+
irq = gpiod_to_irq(d);
270+
irq_set_irq_type(irq, IRQ_TYPE_EDGE_RISING);
271+
nokia770_i2c_board_info_2[1].irq = irq;
249272
}
250-
irq_set_irq_type(gpio_to_irq(retu_irq_gpio), IRQ_TYPE_EDGE_RISING);
251-
irq_set_irq_type(gpio_to_irq(tahvo_irq_gpio), IRQ_TYPE_EDGE_RISING);
252-
nokia770_i2c_board_info_2[0].irq = gpio_to_irq(retu_irq_gpio);
253-
nokia770_i2c_board_info_2[1].irq = gpio_to_irq(tahvo_irq_gpio);
254273
i2c_register_board_info(2, nokia770_i2c_board_info_2,
255274
ARRAY_SIZE(nokia770_i2c_board_info_2));
256-
gpiod_add_lookup_table(&nokia770_cbus_gpio_table);
275+
device_create_managed_software_node(&nokia770_cbus_device.dev,
276+
nokia770_cbus_props, NULL);
257277
platform_device_register(&nokia770_cbus_device);
258278
}
259279
#else /* CONFIG_I2C_CBUS_GPIO */
@@ -262,8 +282,33 @@ static void __init nokia770_cbus_init(void)
262282
}
263283
#endif /* CONFIG_I2C_CBUS_GPIO */
264284

285+
static struct gpiod_lookup_table nokia770_irq_gpio_table = {
286+
.dev_id = NULL,
287+
.table = {
288+
/* GPIO used by SPI device 1 */
289+
GPIO_LOOKUP("gpio-0-15", 15, "ads7846_irq",
290+
GPIO_ACTIVE_HIGH),
291+
/* GPIO used for retu IRQ */
292+
GPIO_LOOKUP("gpio-48-63", 15, "retu_irq",
293+
GPIO_ACTIVE_HIGH),
294+
/* GPIO used for tahvo IRQ */
295+
GPIO_LOOKUP("gpio-32-47", 8, "tahvo_irq",
296+
GPIO_ACTIVE_HIGH),
297+
/* GPIOs used by serial wakeup IRQs */
298+
GPIO_LOOKUP_IDX("gpio-32-47", 5, "wakeup", 0,
299+
GPIO_ACTIVE_HIGH),
300+
GPIO_LOOKUP_IDX("gpio-16-31", 2, "wakeup", 1,
301+
GPIO_ACTIVE_HIGH),
302+
GPIO_LOOKUP_IDX("gpio-48-63", 1, "wakeup", 2,
303+
GPIO_ACTIVE_HIGH),
304+
{ }
305+
},
306+
};
307+
265308
static void __init omap_nokia770_init(void)
266309
{
310+
struct gpio_desc *d;
311+
267312
/* On Nokia 770, the SleepX signal is masked with an
268313
* MPUIO line by default. It has to be unmasked for it
269314
* to become functional */
@@ -273,8 +318,16 @@ static void __init omap_nokia770_init(void)
273318
/* Unmask SleepX signal */
274319
omap_writew((omap_readw(0xfffb5004) & ~2), 0xfffb5004);
275320

321+
software_node_register_node_group(nokia770_gpiochip_nodes);
276322
platform_add_devices(nokia770_devices, ARRAY_SIZE(nokia770_devices));
277-
nokia770_spi_board_info[1].irq = gpio_to_irq(15);
323+
324+
gpiod_add_lookup_table(&nokia770_irq_gpio_table);
325+
d = gpiod_get(NULL, "ads7846_irq", GPIOD_IN);
326+
if (IS_ERR(d))
327+
pr_err("Unable to get ADS7846 IRQ GPIO descriptor\n");
328+
else
329+
nokia770_spi_board_info[1].irq = gpiod_to_irq(d);
330+
278331
spi_register_board_info(nokia770_spi_board_info,
279332
ARRAY_SIZE(nokia770_spi_board_info));
280333
omap_serial_init();

0 commit comments

Comments
 (0)