Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+636 -511
-1
arch/arm/mach-omap1/board-ams-delta.c
··· 11 11 #include <linux/gpio/driver.h> 12 12 #include <linux/gpio/machine.h> 13 13 #include <linux/gpio/consumer.h> 14 - #include <linux/gpio.h> 15 14 #include <linux/kernel.h> 16 15 #include <linux/init.h> 17 16 #include <linux/input.h>
+129 -76
arch/arm/mach-omap1/board-nokia770.c
··· 6 6 */ 7 7 #include <linux/clkdev.h> 8 8 #include <linux/irq.h> 9 - #include <linux/gpio.h> 9 + #include <linux/gpio/consumer.h> 10 10 #include <linux/gpio/machine.h> 11 + #include <linux/gpio/property.h> 11 12 #include <linux/kernel.h> 12 13 #include <linux/init.h> 13 14 #include <linux/mutex.h> 14 15 #include <linux/platform_device.h> 16 + #include <linux/property.h> 15 17 #include <linux/input.h> 16 18 #include <linux/omapfb.h> 17 19 18 20 #include <linux/spi/spi.h> 19 - #include <linux/spi/ads7846.h> 20 21 #include <linux/workqueue.h> 21 22 #include <linux/delay.h> 22 23 ··· 35 34 #include "common.h" 36 35 #include "clock.h" 37 36 #include "mmc.h" 37 + 38 + static const struct software_node nokia770_mpuio_gpiochip_node = { 39 + .name = "mpuio", 40 + }; 41 + 42 + static const struct software_node nokia770_gpiochip1_node = { 43 + .name = "gpio-0-15", 44 + }; 45 + 46 + static const struct software_node nokia770_gpiochip2_node = { 47 + .name = "gpio-16-31", 48 + }; 49 + 50 + static const struct software_node *nokia770_gpiochip_nodes[] = { 51 + &nokia770_mpuio_gpiochip_node, 52 + &nokia770_gpiochip1_node, 53 + &nokia770_gpiochip2_node, 54 + NULL 55 + }; 38 56 39 57 #define ADS7846_PENDOWN_GPIO 15 40 58 ··· 105 85 &nokia770_kp_device, 106 86 }; 107 87 108 - static void mipid_shutdown(struct mipid_platform_data *pdata) 109 - { 110 - if (pdata->nreset_gpio != -1) { 111 - printk(KERN_INFO "shutdown LCD\n"); 112 - gpio_set_value(pdata->nreset_gpio, 0); 113 - msleep(120); 114 - } 115 - } 116 - 117 - static struct mipid_platform_data nokia770_mipid_platform_data = { 118 - .shutdown = mipid_shutdown, 119 - }; 88 + static struct mipid_platform_data nokia770_mipid_platform_data = { }; 120 89 121 90 static const struct omap_lcd_config nokia770_lcd_config __initconst = { 122 91 .ctrl_name = "hwa742", 123 92 }; 124 93 94 + static const struct property_entry nokia770_mipid_props[] = { 95 + PROPERTY_ENTRY_GPIO("reset-gpios", &nokia770_gpiochip1_node, 96 + 13, GPIO_ACTIVE_LOW), 97 + { } 98 + }; 99 + 100 + static const struct software_node nokia770_mipid_swnode = { 101 + .name = "lcd_mipid", 102 + .properties = nokia770_mipid_props, 103 + }; 104 + 125 105 static void __init mipid_dev_init(void) 126 106 { 127 - nokia770_mipid_platform_data.nreset_gpio = 13; 128 107 nokia770_mipid_platform_data.data_lines = 16; 129 108 130 109 omapfb_set_lcd_config(&nokia770_lcd_config); 131 110 } 132 111 133 - static struct ads7846_platform_data nokia770_ads7846_platform_data __initdata = { 134 - .x_max = 0x0fff, 135 - .y_max = 0x0fff, 136 - .x_plate_ohms = 180, 137 - .pressure_max = 255, 138 - .debounce_max = 10, 139 - .debounce_tol = 3, 140 - .debounce_rep = 1, 141 - .gpio_pendown = ADS7846_PENDOWN_GPIO, 112 + static const struct property_entry nokia770_ads7846_props[] = { 113 + PROPERTY_ENTRY_STRING("compatible", "ti,ads7846"), 114 + PROPERTY_ENTRY_U32("touchscreen-size-x", 4096), 115 + PROPERTY_ENTRY_U32("touchscreen-size-y", 4096), 116 + PROPERTY_ENTRY_U32("touchscreen-max-pressure", 256), 117 + PROPERTY_ENTRY_U32("touchscreen-average-samples", 10), 118 + PROPERTY_ENTRY_U16("ti,x-plate-ohms", 180), 119 + PROPERTY_ENTRY_U16("ti,debounce-tol", 3), 120 + PROPERTY_ENTRY_U16("ti,debounce-rep", 1), 121 + PROPERTY_ENTRY_GPIO("pendown-gpios", &nokia770_gpiochip1_node, 122 + ADS7846_PENDOWN_GPIO, GPIO_ACTIVE_LOW), 123 + { } 124 + }; 125 + 126 + static const struct software_node nokia770_ads7846_swnode = { 127 + .name = "ads7846", 128 + .properties = nokia770_ads7846_props, 142 129 }; 143 130 144 131 static struct spi_board_info nokia770_spi_board_info[] __initdata = { ··· 155 128 .chip_select = 3, 156 129 .max_speed_hz = 12000000, 157 130 .platform_data = &nokia770_mipid_platform_data, 131 + .swnode = &nokia770_mipid_swnode, 158 132 }, 159 133 [1] = { 160 134 .modalias = "ads7846", 161 135 .bus_num = 2, 162 136 .chip_select = 0, 163 137 .max_speed_hz = 2500000, 164 - .platform_data = &nokia770_ads7846_platform_data, 138 + .swnode = &nokia770_ads7846_swnode, 165 139 }, 166 140 }; 167 141 ··· 184 156 185 157 #if IS_ENABLED(CONFIG_MMC_OMAP) 186 158 187 - #define NOKIA770_GPIO_MMC_POWER 41 188 - #define NOKIA770_GPIO_MMC_SWITCH 23 189 - 190 - static int nokia770_mmc_set_power(struct device *dev, int slot, int power_on, 191 - int vdd) 192 - { 193 - gpio_set_value(NOKIA770_GPIO_MMC_POWER, power_on); 194 - return 0; 195 - } 196 - 197 - static int nokia770_mmc_get_cover_state(struct device *dev, int slot) 198 - { 199 - return gpio_get_value(NOKIA770_GPIO_MMC_SWITCH); 200 - } 159 + static struct gpiod_lookup_table nokia770_mmc_gpio_table = { 160 + .dev_id = "mmci-omap.1", 161 + .table = { 162 + /* Slot index 0, VSD power, GPIO 41 */ 163 + GPIO_LOOKUP_IDX("gpio-32-47", 9, 164 + "vsd", 0, GPIO_ACTIVE_HIGH), 165 + /* Slot index 0, switch, GPIO 23 */ 166 + GPIO_LOOKUP_IDX("gpio-16-31", 7, 167 + "cover", 0, GPIO_ACTIVE_HIGH), 168 + { } 169 + }, 170 + }; 201 171 202 172 static struct omap_mmc_platform_data nokia770_mmc2_data = { 203 173 .nr_slots = 1, 204 174 .max_freq = 12000000, 205 175 .slots[0] = { 206 - .set_power = nokia770_mmc_set_power, 207 - .get_cover_state = nokia770_mmc_get_cover_state, 208 176 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, 209 177 .name = "mmcblk", 210 178 }, ··· 210 186 211 187 static void __init nokia770_mmc_init(void) 212 188 { 213 - int ret; 214 - 215 - ret = gpio_request(NOKIA770_GPIO_MMC_POWER, "MMC power"); 216 - if (ret < 0) 217 - return; 218 - gpio_direction_output(NOKIA770_GPIO_MMC_POWER, 0); 219 - 220 - ret = gpio_request(NOKIA770_GPIO_MMC_SWITCH, "MMC cover"); 221 - if (ret < 0) { 222 - gpio_free(NOKIA770_GPIO_MMC_POWER); 223 - return; 224 - } 225 - gpio_direction_input(NOKIA770_GPIO_MMC_SWITCH); 226 - 189 + gpiod_add_lookup_table(&nokia770_mmc_gpio_table); 227 190 /* Only the second MMC controller is used */ 228 191 nokia770_mmc_data[1] = &nokia770_mmc2_data; 229 192 omap1_init_mmc(nokia770_mmc_data, OMAP16XX_NR_MMC); ··· 223 212 #endif 224 213 225 214 #if IS_ENABLED(CONFIG_I2C_CBUS_GPIO) 226 - static struct gpiod_lookup_table nokia770_cbus_gpio_table = { 227 - .dev_id = "i2c-cbus-gpio.2", 228 - .table = { 229 - GPIO_LOOKUP_IDX("mpuio", 9, NULL, 0, 0), /* clk */ 230 - GPIO_LOOKUP_IDX("mpuio", 10, NULL, 1, 0), /* dat */ 231 - GPIO_LOOKUP_IDX("mpuio", 11, NULL, 2, 0), /* sel */ 232 - { }, 233 - }, 215 + 216 + static const struct software_node_ref_args nokia770_cbus_gpio_refs[] = { 217 + SOFTWARE_NODE_REFERENCE(&nokia770_mpuio_gpiochip_node, 9, 0), 218 + SOFTWARE_NODE_REFERENCE(&nokia770_mpuio_gpiochip_node, 10, 0), 219 + SOFTWARE_NODE_REFERENCE(&nokia770_mpuio_gpiochip_node, 11, 0), 220 + }; 221 + 222 + static const struct property_entry nokia770_cbus_props[] = { 223 + PROPERTY_ENTRY_REF_ARRAY("gpios", nokia770_cbus_gpio_refs), 224 + { } 234 225 }; 235 226 236 227 static struct platform_device nokia770_cbus_device = { ··· 251 238 252 239 static void __init nokia770_cbus_init(void) 253 240 { 254 - const int retu_irq_gpio = 62; 255 - const int tahvo_irq_gpio = 40; 241 + struct gpio_desc *d; 242 + int irq; 256 243 257 - if (gpio_request_one(retu_irq_gpio, GPIOF_IN, "Retu IRQ")) 258 - return; 259 - if (gpio_request_one(tahvo_irq_gpio, GPIOF_IN, "Tahvo IRQ")) { 260 - gpio_free(retu_irq_gpio); 261 - return; 244 + d = gpiod_get(NULL, "retu_irq", GPIOD_IN); 245 + if (IS_ERR(d)) { 246 + pr_err("Unable to get CBUS Retu IRQ GPIO descriptor\n"); 247 + } else { 248 + irq = gpiod_to_irq(d); 249 + irq_set_irq_type(irq, IRQ_TYPE_EDGE_RISING); 250 + nokia770_i2c_board_info_2[0].irq = irq; 262 251 } 263 - irq_set_irq_type(gpio_to_irq(retu_irq_gpio), IRQ_TYPE_EDGE_RISING); 264 - irq_set_irq_type(gpio_to_irq(tahvo_irq_gpio), IRQ_TYPE_EDGE_RISING); 265 - nokia770_i2c_board_info_2[0].irq = gpio_to_irq(retu_irq_gpio); 266 - nokia770_i2c_board_info_2[1].irq = gpio_to_irq(tahvo_irq_gpio); 252 + d = gpiod_get(NULL, "tahvo_irq", GPIOD_IN); 253 + if (IS_ERR(d)) { 254 + pr_err("Unable to get CBUS Tahvo IRQ GPIO descriptor\n"); 255 + } else { 256 + irq = gpiod_to_irq(d); 257 + irq_set_irq_type(irq, IRQ_TYPE_EDGE_RISING); 258 + nokia770_i2c_board_info_2[1].irq = irq; 259 + } 267 260 i2c_register_board_info(2, nokia770_i2c_board_info_2, 268 261 ARRAY_SIZE(nokia770_i2c_board_info_2)); 269 - gpiod_add_lookup_table(&nokia770_cbus_gpio_table); 262 + device_create_managed_software_node(&nokia770_cbus_device.dev, 263 + nokia770_cbus_props, NULL); 270 264 platform_device_register(&nokia770_cbus_device); 271 265 } 272 266 #else /* CONFIG_I2C_CBUS_GPIO */ ··· 282 262 } 283 263 #endif /* CONFIG_I2C_CBUS_GPIO */ 284 264 265 + static struct gpiod_lookup_table nokia770_irq_gpio_table = { 266 + .dev_id = NULL, 267 + .table = { 268 + /* GPIO used by SPI device 1 */ 269 + GPIO_LOOKUP("gpio-0-15", 15, "ads7846_irq", 270 + GPIO_ACTIVE_HIGH), 271 + /* GPIO used for retu IRQ */ 272 + GPIO_LOOKUP("gpio-48-63", 15, "retu_irq", 273 + GPIO_ACTIVE_HIGH), 274 + /* GPIO used for tahvo IRQ */ 275 + GPIO_LOOKUP("gpio-32-47", 8, "tahvo_irq", 276 + GPIO_ACTIVE_HIGH), 277 + /* GPIOs used by serial wakeup IRQs */ 278 + GPIO_LOOKUP_IDX("gpio-32-47", 5, "wakeup", 0, 279 + GPIO_ACTIVE_HIGH), 280 + GPIO_LOOKUP_IDX("gpio-16-31", 2, "wakeup", 1, 281 + GPIO_ACTIVE_HIGH), 282 + GPIO_LOOKUP_IDX("gpio-48-63", 1, "wakeup", 2, 283 + GPIO_ACTIVE_HIGH), 284 + { } 285 + }, 286 + }; 287 + 285 288 static void __init omap_nokia770_init(void) 286 289 { 290 + struct gpio_desc *d; 291 + 287 292 /* On Nokia 770, the SleepX signal is masked with an 288 293 * MPUIO line by default. It has to be unmasked for it 289 294 * to become functional */ ··· 318 273 /* Unmask SleepX signal */ 319 274 omap_writew((omap_readw(0xfffb5004) & ~2), 0xfffb5004); 320 275 276 + software_node_register_node_group(nokia770_gpiochip_nodes); 321 277 platform_add_devices(nokia770_devices, ARRAY_SIZE(nokia770_devices)); 322 - nokia770_spi_board_info[1].irq = gpio_to_irq(15); 278 + 279 + gpiod_add_lookup_table(&nokia770_irq_gpio_table); 280 + d = gpiod_get(NULL, "ads7846_irq", GPIOD_IN); 281 + if (IS_ERR(d)) 282 + pr_err("Unable to get ADS7846 IRQ GPIO descriptor\n"); 283 + else 284 + nokia770_spi_board_info[1].irq = gpiod_to_irq(d); 285 + 323 286 spi_register_board_info(nokia770_spi_board_info, 324 287 ARRAY_SIZE(nokia770_spi_board_info)); 325 288 omap_serial_init();
+102 -44
arch/arm/mach-omap1/board-osk.c
··· 25 25 * with this program; if not, write to the Free Software Foundation, Inc., 26 26 * 675 Mass Ave, Cambridge, MA 02139, USA. 27 27 */ 28 - #include <linux/gpio.h> 28 + #include <linux/gpio/consumer.h> 29 + #include <linux/gpio/driver.h> 29 30 #include <linux/gpio/machine.h> 30 31 #include <linux/kernel.h> 31 32 #include <linux/init.h> ··· 65 64 /* TPS65010 has four GPIOs. nPG and LED2 can be treated like GPIOs with 66 65 * alternate pin configurations for hardware-controlled blinking. 67 66 */ 68 - #define OSK_TPS_GPIO_BASE (OMAP_MAX_GPIO_LINES + 16 /* MPUIO */) 69 - # define OSK_TPS_GPIO_USB_PWR_EN (OSK_TPS_GPIO_BASE + 0) 70 - # define OSK_TPS_GPIO_LED_D3 (OSK_TPS_GPIO_BASE + 1) 71 - # define OSK_TPS_GPIO_LAN_RESET (OSK_TPS_GPIO_BASE + 2) 72 - # define OSK_TPS_GPIO_DSP_PWR_EN (OSK_TPS_GPIO_BASE + 3) 73 - # define OSK_TPS_GPIO_LED_D9 (OSK_TPS_GPIO_BASE + 4) 74 - # define OSK_TPS_GPIO_LED_D2 (OSK_TPS_GPIO_BASE + 5) 67 + #define OSK_TPS_GPIO_USB_PWR_EN 0 68 + #define OSK_TPS_GPIO_LED_D3 1 69 + #define OSK_TPS_GPIO_LAN_RESET 2 70 + #define OSK_TPS_GPIO_DSP_PWR_EN 3 71 + #define OSK_TPS_GPIO_LED_D9 4 72 + #define OSK_TPS_GPIO_LED_D2 5 75 73 76 74 static struct mtd_partition osk_partitions[] = { 77 75 /* bootloader (U-Boot, etc) in first sector */ ··· 174 174 /* NOTE: D9 and D2 have hardware blink support. 175 175 * Also, D9 requires non-battery power. 176 176 */ 177 - { .gpio = OSK_TPS_GPIO_LED_D9, .name = "d9", 178 - .default_trigger = "disk-activity", }, 179 - { .gpio = OSK_TPS_GPIO_LED_D2, .name = "d2", }, 180 - { .gpio = OSK_TPS_GPIO_LED_D3, .name = "d3", .active_low = 1, 181 - .default_trigger = "heartbeat", }, 177 + { .name = "d9", .default_trigger = "disk-activity", }, 178 + { .name = "d2", }, 179 + { .name = "d3", .default_trigger = "heartbeat", }, 180 + }; 181 + 182 + static struct gpiod_lookup_table tps_leds_gpio_table = { 183 + .dev_id = "leds-gpio", 184 + .table = { 185 + /* Use local offsets on TPS65010 */ 186 + GPIO_LOOKUP_IDX("tps65010", OSK_TPS_GPIO_LED_D9, NULL, 0, GPIO_ACTIVE_HIGH), 187 + GPIO_LOOKUP_IDX("tps65010", OSK_TPS_GPIO_LED_D2, NULL, 1, GPIO_ACTIVE_HIGH), 188 + GPIO_LOOKUP_IDX("tps65010", OSK_TPS_GPIO_LED_D3, NULL, 2, GPIO_ACTIVE_LOW), 189 + { } 190 + }, 182 191 }; 183 192 184 193 static struct gpio_led_platform_data tps_leds_data = { ··· 201 192 .dev.platform_data = &tps_leds_data, 202 193 }; 203 194 204 - static int osk_tps_setup(struct i2c_client *client, void *context) 195 + /* The board just hold these GPIOs hogged from setup to teardown */ 196 + static struct gpio_desc *eth_reset; 197 + static struct gpio_desc *vdd_dsp; 198 + 199 + static int osk_tps_setup(struct i2c_client *client, struct gpio_chip *gc) 205 200 { 201 + struct gpio_desc *d; 206 202 if (!IS_BUILTIN(CONFIG_TPS65010)) 207 203 return -ENOSYS; 208 204 209 205 /* Set GPIO 1 HIGH to disable VBUS power supply; 210 206 * OHCI driver powers it up/down as needed. 211 207 */ 212 - gpio_request(OSK_TPS_GPIO_USB_PWR_EN, "n_vbus_en"); 213 - gpio_direction_output(OSK_TPS_GPIO_USB_PWR_EN, 1); 208 + d = gpiochip_request_own_desc(gc, OSK_TPS_GPIO_USB_PWR_EN, "n_vbus_en", 209 + GPIO_ACTIVE_HIGH, GPIOD_OUT_HIGH); 214 210 /* Free the GPIO again as the driver will request it */ 215 - gpio_free(OSK_TPS_GPIO_USB_PWR_EN); 211 + gpiochip_free_own_desc(d); 216 212 217 213 /* Set GPIO 2 high so LED D3 is off by default */ 218 214 tps65010_set_gpio_out_value(GPIO2, HIGH); 219 215 220 216 /* Set GPIO 3 low to take ethernet out of reset */ 221 - gpio_request(OSK_TPS_GPIO_LAN_RESET, "smc_reset"); 222 - gpio_direction_output(OSK_TPS_GPIO_LAN_RESET, 0); 217 + eth_reset = gpiochip_request_own_desc(gc, OSK_TPS_GPIO_LAN_RESET, "smc_reset", 218 + GPIO_ACTIVE_HIGH, GPIOD_OUT_LOW); 223 219 224 220 /* GPIO4 is VDD_DSP */ 225 - gpio_request(OSK_TPS_GPIO_DSP_PWR_EN, "dsp_power"); 226 - gpio_direction_output(OSK_TPS_GPIO_DSP_PWR_EN, 1); 221 + vdd_dsp = gpiochip_request_own_desc(gc, OSK_TPS_GPIO_DSP_PWR_EN, "dsp_power", 222 + GPIO_ACTIVE_HIGH, GPIOD_OUT_HIGH); 227 223 /* REVISIT if DSP support isn't configured, power it off ... */ 228 224 229 225 /* Let LED1 (D9) blink; leds-gpio may override it */ ··· 246 232 247 233 /* register these three LEDs */ 248 234 osk5912_tps_leds.dev.parent = &client->dev; 235 + gpiod_add_lookup_table(&tps_leds_gpio_table); 249 236 platform_device_register(&osk5912_tps_leds); 250 237 251 238 return 0; 252 239 } 253 240 241 + static void osk_tps_teardown(struct i2c_client *client, struct gpio_chip *gc) 242 + { 243 + gpiochip_free_own_desc(eth_reset); 244 + gpiochip_free_own_desc(vdd_dsp); 245 + } 246 + 254 247 static struct tps65010_board tps_board = { 255 - .base = OSK_TPS_GPIO_BASE, 256 248 .outmask = 0x0f, 257 249 .setup = osk_tps_setup, 250 + .teardown = osk_tps_teardown, 258 251 }; 259 252 260 253 static struct i2c_board_info __initdata osk_i2c_board_info[] = { ··· 284 263 { 285 264 u32 l; 286 265 287 - if ((gpio_request(0, "smc_irq")) < 0) { 288 - printk("Error requesting gpio 0 for smc91x irq\n"); 289 - return; 290 - } 291 - 292 266 /* Check EMIFS wait states to fix errors with SMC_GET_PKT_HDR */ 293 267 l = omap_readl(EMIFS_CCS(1)); 294 268 l |= 0x3; ··· 295 279 struct resource *res = &osk5912_cf_resources[1]; 296 280 297 281 omap_cfg_reg(M7_1610_GPIO62); 298 - if ((gpio_request(62, "cf_irq")) < 0) { 299 - printk("Error requesting gpio 62 for CF irq\n"); 300 - return; 301 - } 302 282 303 283 switch (seg) { 304 284 /* NOTE: CS0 could be configured too ... */ ··· 320 308 seg, omap_readl(EMIFS_CCS(seg)), omap_readl(EMIFS_ACS(seg))); 321 309 omap_writel(0x0004a1b3, EMIFS_CCS(seg)); /* synch mode 4 etc */ 322 310 omap_writel(0x00000000, EMIFS_ACS(seg)); /* OE hold/setup */ 323 - 324 - /* the CF I/O IRQ is really active-low */ 325 - irq_set_irq_type(gpio_to_irq(62), IRQ_TYPE_EDGE_FALLING); 326 311 } 327 312 328 313 static struct gpiod_lookup_table osk_usb_gpio_table = { 329 314 .dev_id = "ohci", 330 315 .table = { 331 316 /* Power GPIO on the I2C-attached TPS65010 */ 332 - GPIO_LOOKUP("tps65010", 0, "power", GPIO_ACTIVE_HIGH), 317 + GPIO_LOOKUP("tps65010", OSK_TPS_GPIO_USB_PWR_EN, "power", 318 + GPIO_ACTIVE_HIGH), 333 319 GPIO_LOOKUP(OMAP_GPIO_LABEL, 9, "overcurrent", 334 320 GPIO_ACTIVE_HIGH), 321 + { } 335 322 }, 336 323 }; 337 324 ··· 352 341 353 342 #define EMIFS_CS3_VAL (0x88013141) 354 343 344 + static struct gpiod_lookup_table osk_irq_gpio_table = { 345 + .dev_id = NULL, 346 + .table = { 347 + /* GPIO used for SMC91x IRQ */ 348 + GPIO_LOOKUP(OMAP_GPIO_LABEL, 0, "smc_irq", 349 + GPIO_ACTIVE_HIGH), 350 + /* GPIO used for CF IRQ */ 351 + GPIO_LOOKUP("gpio-48-63", 14, "cf_irq", 352 + GPIO_ACTIVE_HIGH), 353 + /* GPIO used by the TPS65010 chip */ 354 + GPIO_LOOKUP("mpuio", 1, "tps65010", 355 + GPIO_ACTIVE_HIGH), 356 + /* GPIOs used for serial wakeup IRQs */ 357 + GPIO_LOOKUP_IDX("gpio-32-47", 5, "wakeup", 0, 358 + GPIO_ACTIVE_HIGH), 359 + GPIO_LOOKUP_IDX("gpio-16-31", 2, "wakeup", 1, 360 + GPIO_ACTIVE_HIGH), 361 + GPIO_LOOKUP_IDX("gpio-48-63", 1, "wakeup", 2, 362 + GPIO_ACTIVE_HIGH), 363 + { } 364 + }, 365 + }; 366 + 355 367 static void __init osk_init(void) 356 368 { 369 + struct gpio_desc *d; 357 370 u32 l; 358 371 359 372 osk_init_smc91x(); ··· 394 359 395 360 osk_flash_resource.end = osk_flash_resource.start = omap_cs3_phys(); 396 361 osk_flash_resource.end += SZ_32M - 1; 397 - osk5912_smc91x_resources[1].start = gpio_to_irq(0); 398 - osk5912_smc91x_resources[1].end = gpio_to_irq(0); 399 - osk5912_cf_resources[0].start = gpio_to_irq(62); 400 - osk5912_cf_resources[0].end = gpio_to_irq(62); 362 + 363 + /* 364 + * Add the GPIOs to be used as IRQs and immediately look them up 365 + * to be passed as an IRQ resource. This is ugly but should work 366 + * until the day we convert to device tree. 367 + */ 368 + gpiod_add_lookup_table(&osk_irq_gpio_table); 369 + 370 + d = gpiod_get(NULL, "smc_irq", GPIOD_IN); 371 + if (IS_ERR(d)) { 372 + pr_err("Unable to get SMC IRQ GPIO descriptor\n"); 373 + } else { 374 + irq_set_irq_type(gpiod_to_irq(d), IRQ_TYPE_EDGE_RISING); 375 + osk5912_smc91x_resources[1] = DEFINE_RES_IRQ(gpiod_to_irq(d)); 376 + } 377 + 378 + d = gpiod_get(NULL, "cf_irq", GPIOD_IN); 379 + if (IS_ERR(d)) { 380 + pr_err("Unable to get CF IRQ GPIO descriptor\n"); 381 + } else { 382 + /* the CF I/O IRQ is really active-low */ 383 + irq_set_irq_type(gpiod_to_irq(d), IRQ_TYPE_EDGE_FALLING); 384 + osk5912_cf_resources[0] = DEFINE_RES_IRQ(gpiod_to_irq(d)); 385 + } 386 + 401 387 platform_add_devices(osk5912_devices, ARRAY_SIZE(osk5912_devices)); 402 388 403 389 l = omap_readl(USB_TRANSCEIVER_CTRL); ··· 428 372 gpiod_add_lookup_table(&osk_usb_gpio_table); 429 373 omap1_usb_init(&osk_usb_config); 430 374 375 + omap_serial_init(); 376 + 431 377 /* irq for tps65010 chip */ 432 378 /* bootloader effectively does: omap_cfg_reg(U19_1610_MPUIO1); */ 433 - if (gpio_request(OMAP_MPUIO(1), "tps65010") == 0) 434 - gpio_direction_input(OMAP_MPUIO(1)); 435 - 436 - omap_serial_init(); 437 - osk_i2c_board_info[0].irq = gpio_to_irq(OMAP_MPUIO(1)); 379 + d = gpiod_get(NULL, "tps65010", GPIOD_IN); 380 + if (IS_ERR(d)) 381 + pr_err("Unable to get TPS65010 IRQ GPIO descriptor\n"); 382 + else 383 + osk_i2c_board_info[0].irq = gpiod_to_irq(d); 438 384 omap_register_i2c_bus(1, 400, osk_i2c_board_info, 439 385 ARRAY_SIZE(osk_i2c_board_info)); 440 386 }
+31 -20
arch/arm/mach-omap1/board-palmte.c
··· 13 13 * 14 14 * Copyright (c) 2006 Andrzej Zaborowski <balrog@zabor.org> 15 15 */ 16 - #include <linux/gpio.h> 16 + #include <linux/gpio/machine.h> 17 + #include <linux/gpio/consumer.h> 17 18 #include <linux/kernel.h> 18 19 #include <linux/init.h> 19 20 #include <linux/input.h> ··· 188 187 }, 189 188 }; 190 189 191 - static void __init palmte_misc_gpio_setup(void) 192 - { 193 - /* Set TSC2102 PINTDAV pin as input (used by TSC2102 driver) */ 194 - if (gpio_request(PALMTE_PINTDAV_GPIO, "TSC2102 PINTDAV") < 0) { 195 - printk(KERN_ERR "Could not reserve PINTDAV GPIO!\n"); 196 - return; 197 - } 198 - gpio_direction_input(PALMTE_PINTDAV_GPIO); 199 - 200 - /* Set USB-or-DC-IN pin as input (unused) */ 201 - if (gpio_request(PALMTE_USB_OR_DC_GPIO, "USB/DC-IN") < 0) { 202 - printk(KERN_ERR "Could not reserve cable signal GPIO!\n"); 203 - return; 204 - } 205 - gpio_direction_input(PALMTE_USB_OR_DC_GPIO); 206 - } 207 - 208 190 #if IS_ENABLED(CONFIG_MMC_OMAP) 209 191 210 192 static struct omap_mmc_platform_data _palmte_mmc_config = { ··· 215 231 216 232 #endif /* CONFIG_MMC_OMAP */ 217 233 234 + static struct gpiod_lookup_table palmte_irq_gpio_table = { 235 + .dev_id = NULL, 236 + .table = { 237 + /* GPIO used for TSC2102 PINTDAV IRQ */ 238 + GPIO_LOOKUP("gpio-0-15", PALMTE_PINTDAV_GPIO, "tsc2102_irq", 239 + GPIO_ACTIVE_HIGH), 240 + /* GPIO used for USB or DC input detection */ 241 + GPIO_LOOKUP("gpio-0-15", PALMTE_USB_OR_DC_GPIO, "usb_dc_irq", 242 + GPIO_ACTIVE_HIGH), 243 + { } 244 + }, 245 + }; 246 + 218 247 static void __init omap_palmte_init(void) 219 248 { 249 + struct gpio_desc *d; 250 + 220 251 /* mux pins for uarts */ 221 252 omap_cfg_reg(UART1_TX); 222 253 omap_cfg_reg(UART1_RTS); ··· 242 243 243 244 platform_add_devices(palmte_devices, ARRAY_SIZE(palmte_devices)); 244 245 245 - palmte_spi_info[0].irq = gpio_to_irq(PALMTE_PINTDAV_GPIO); 246 + gpiod_add_lookup_table(&palmte_irq_gpio_table); 247 + d = gpiod_get(NULL, "tsc2102_irq", GPIOD_IN); 248 + if (IS_ERR(d)) 249 + pr_err("Unable to get TSC2102 IRQ GPIO descriptor\n"); 250 + else 251 + palmte_spi_info[0].irq = gpiod_to_irq(d); 246 252 spi_register_board_info(palmte_spi_info, ARRAY_SIZE(palmte_spi_info)); 247 - palmte_misc_gpio_setup(); 253 + 254 + /* We are getting this just to set it up as input */ 255 + d = gpiod_get(NULL, "usb_dc_irq", GPIOD_IN); 256 + if (IS_ERR(d)) 257 + pr_err("Unable to get USB/DC IRQ GPIO descriptor\n"); 258 + else 259 + gpiod_put(d); 260 + 248 261 omap_serial_init(); 249 262 omap1_usb_init(&palmte_usb_config); 250 263 omap_register_i2c_bus(1, 100, NULL, 0);
-1
arch/arm/mach-omap1/board-sx1-mmc.c
··· 9 9 * Copyright (C) 2007 Instituto Nokia de Tecnologia - INdT 10 10 */ 11 11 12 - #include <linux/gpio.h> 13 12 #include <linux/platform_device.h> 14 13 15 14 #include "hardware.h"
+33 -7
arch/arm/mach-omap1/board-sx1.c
··· 11 11 * Maintainters : Vladimir Ananiev (aka Vovan888), Sergge 12 12 * oslik.ru 13 13 */ 14 - #include <linux/gpio.h> 14 + #include <linux/gpio/machine.h> 15 + #include <linux/gpio/consumer.h> 15 16 #include <linux/kernel.h> 16 17 #include <linux/init.h> 17 18 #include <linux/input.h> ··· 305 304 306 305 /*-----------------------------------------*/ 307 306 307 + static struct gpiod_lookup_table sx1_gpio_table = { 308 + .dev_id = NULL, 309 + .table = { 310 + GPIO_LOOKUP("gpio-0-15", 1, "irda_off", 311 + GPIO_ACTIVE_HIGH), 312 + GPIO_LOOKUP("gpio-0-15", 11, "switch", 313 + GPIO_ACTIVE_HIGH), 314 + GPIO_LOOKUP("gpio-0-15", 15, "usb_on", 315 + GPIO_ACTIVE_HIGH), 316 + { } 317 + }, 318 + }; 319 + 308 320 static void __init omap_sx1_init(void) 309 321 { 322 + struct gpio_desc *d; 323 + 310 324 /* mux pins for uarts */ 311 325 omap_cfg_reg(UART1_TX); 312 326 omap_cfg_reg(UART1_RTS); ··· 336 320 omap_register_i2c_bus(1, 100, NULL, 0); 337 321 omap1_usb_init(&sx1_usb_config); 338 322 sx1_mmc_init(); 323 + gpiod_add_lookup_table(&sx1_gpio_table); 339 324 340 325 /* turn on USB power */ 341 326 /* sx1_setusbpower(1); can't do it here because i2c is not ready */ 342 - gpio_request(1, "A_IRDA_OFF"); 343 - gpio_request(11, "A_SWITCH"); 344 - gpio_request(15, "A_USB_ON"); 345 - gpio_direction_output(1, 1); /*A_IRDA_OFF = 1 */ 346 - gpio_direction_output(11, 0); /*A_SWITCH = 0 */ 347 - gpio_direction_output(15, 0); /*A_USB_ON = 0 */ 327 + d = gpiod_get(NULL, "irda_off", GPIOD_OUT_HIGH); 328 + if (IS_ERR(d)) 329 + pr_err("Unable to get IRDA OFF GPIO descriptor\n"); 330 + else 331 + gpiod_put(d); 332 + d = gpiod_get(NULL, "switch", GPIOD_OUT_LOW); 333 + if (IS_ERR(d)) 334 + pr_err("Unable to get SWITCH GPIO descriptor\n"); 335 + else 336 + gpiod_put(d); 337 + d = gpiod_get(NULL, "usb_on", GPIOD_OUT_LOW); 338 + if (IS_ERR(d)) 339 + pr_err("Unable to get USB ON GPIO descriptor\n"); 340 + else 341 + gpiod_put(d); 348 342 349 343 omapfb_set_lcd_config(&sx1_lcd_config); 350 344 }
-1
arch/arm/mach-omap1/devices.c
··· 6 6 */ 7 7 8 8 #include <linux/dma-mapping.h> 9 - #include <linux/gpio.h> 10 9 #include <linux/module.h> 11 10 #include <linux/kernel.h> 12 11 #include <linux/init.h>
-1
arch/arm/mach-omap1/gpio15xx.c
··· 8 8 * Charulatha V <charu@ti.com> 9 9 */ 10 10 11 - #include <linux/gpio.h> 12 11 #include <linux/platform_data/gpio-omap.h> 13 12 #include <linux/soc/ti/omap1-soc.h> 14 13 #include <asm/irq.h>
-1
arch/arm/mach-omap1/gpio16xx.c
··· 8 8 * Charulatha V <charu@ti.com> 9 9 */ 10 10 11 - #include <linux/gpio.h> 12 11 #include <linux/platform_data/gpio-omap.h> 13 12 #include <linux/soc/ti/omap1-io.h> 14 13
-1
arch/arm/mach-omap1/irq.c
··· 35 35 * with this program; if not, write to the Free Software Foundation, Inc., 36 36 * 675 Mass Ave, Cambridge, MA 02139, USA. 37 37 */ 38 - #include <linux/gpio.h> 39 38 #include <linux/init.h> 40 39 #include <linux/module.h> 41 40 #include <linux/sched.h>
+15 -15
arch/arm/mach-omap1/serial.c
··· 4 4 * 5 5 * OMAP1 serial support. 6 6 */ 7 - #include <linux/gpio.h> 7 + #include <linux/gpio/machine.h> 8 + #include <linux/gpio/consumer.h> 8 9 #include <linux/module.h> 9 10 #include <linux/kernel.h> 10 11 #include <linux/init.h> ··· 198 197 } 199 198 } 200 199 201 - static void __init omap_serial_set_port_wakeup(int gpio_nr) 200 + static void __init omap_serial_set_port_wakeup(int idx) 202 201 { 202 + struct gpio_desc *d; 203 203 int ret; 204 204 205 - ret = gpio_request(gpio_nr, "UART wake"); 206 - if (ret < 0) { 207 - printk(KERN_ERR "Could not request UART wake GPIO: %i\n", 208 - gpio_nr); 205 + d = gpiod_get_index(NULL, "wakeup", idx, GPIOD_IN); 206 + if (IS_ERR(d)) { 207 + pr_err("Unable to get UART wakeup GPIO descriptor\n"); 209 208 return; 210 209 } 211 - gpio_direction_input(gpio_nr); 212 - ret = request_irq(gpio_to_irq(gpio_nr), &omap_serial_wake_interrupt, 210 + ret = request_irq(gpiod_to_irq(d), &omap_serial_wake_interrupt, 213 211 IRQF_TRIGGER_RISING, "serial wakeup", NULL); 214 212 if (ret) { 215 - gpio_free(gpio_nr); 216 - printk(KERN_ERR "No interrupt for UART wake GPIO: %i\n", 217 - gpio_nr); 213 + gpiod_put(d); 214 + pr_err("No interrupt for UART%d wake GPIO\n", idx + 1); 218 215 return; 219 216 } 220 - enable_irq_wake(gpio_to_irq(gpio_nr)); 217 + enable_irq_wake(gpiod_to_irq(d)); 221 218 } 219 + 222 220 223 221 int __init omap_serial_wakeup_init(void) 224 222 { ··· 225 225 return 0; 226 226 227 227 if (uart1_ck != NULL) 228 - omap_serial_set_port_wakeup(37); 228 + omap_serial_set_port_wakeup(0); 229 229 if (uart2_ck != NULL) 230 - omap_serial_set_port_wakeup(18); 230 + omap_serial_set_port_wakeup(1); 231 231 if (uart3_ck != NULL) 232 - omap_serial_set_port_wakeup(49); 232 + omap_serial_set_port_wakeup(2); 233 233 234 234 return 0; 235 235 }
+44 -112
arch/arm/mach-omap2/board-n8x0.c
··· 10 10 11 11 #include <linux/clk.h> 12 12 #include <linux/delay.h> 13 - #include <linux/gpio.h> 13 + #include <linux/gpio/machine.h> 14 + #include <linux/gpio/consumer.h> 14 15 #include <linux/init.h> 15 16 #include <linux/io.h> 16 17 #include <linux/irq.h> ··· 29 28 30 29 #include "common.h" 31 30 #include "mmc.h" 31 + #include "usb-tusb6010.h" 32 32 #include "soc.h" 33 33 #include "common-board-devices.h" 34 34 35 35 #define TUSB6010_ASYNC_CS 1 36 36 #define TUSB6010_SYNC_CS 4 37 - #define TUSB6010_GPIO_INT 58 38 - #define TUSB6010_GPIO_ENABLE 0 39 37 #define TUSB6010_DMACHAN 0x3f 40 38 41 39 #define NOKIA_N810_WIMAX (1 << 2) ··· 61 61 } 62 62 63 63 #if IS_ENABLED(CONFIG_USB_MUSB_TUSB6010) 64 - /* 65 - * Enable or disable power to TUSB6010. When enabling, turn on 3.3 V and 66 - * 1.5 V voltage regulators of PM companion chip. Companion chip will then 67 - * provide then PGOOD signal to TUSB6010 which will release it from reset. 68 - */ 69 - static int tusb_set_power(int state) 70 - { 71 - int i, retval = 0; 72 - 73 - if (state) { 74 - gpio_set_value(TUSB6010_GPIO_ENABLE, 1); 75 - msleep(1); 76 - 77 - /* Wait until TUSB6010 pulls INT pin down */ 78 - i = 100; 79 - while (i && gpio_get_value(TUSB6010_GPIO_INT)) { 80 - msleep(1); 81 - i--; 82 - } 83 - 84 - if (!i) { 85 - printk(KERN_ERR "tusb: powerup failed\n"); 86 - retval = -ENODEV; 87 - } 88 - } else { 89 - gpio_set_value(TUSB6010_GPIO_ENABLE, 0); 90 - msleep(10); 91 - } 92 - 93 - return retval; 94 - } 95 64 96 65 static struct musb_hdrc_config musb_config = { 97 66 .multipoint = 1, ··· 71 102 72 103 static struct musb_hdrc_platform_data tusb_data = { 73 104 .mode = MUSB_OTG, 74 - .set_power = tusb_set_power, 75 105 .min_power = 25, /* x2 = 50 mA drawn from VBUS as peripheral */ 76 106 .power = 100, /* Max 100 mA VBUS for host mode */ 77 107 .config = &musb_config, 78 108 }; 79 109 110 + static struct gpiod_lookup_table tusb_gpio_table = { 111 + .dev_id = "musb-tusb", 112 + .table = { 113 + GPIO_LOOKUP("gpio-0-15", 0, "enable", 114 + GPIO_ACTIVE_HIGH), 115 + GPIO_LOOKUP("gpio-48-63", 10, "int", 116 + GPIO_ACTIVE_HIGH), 117 + { } 118 + }, 119 + }; 120 + 80 121 static void __init n8x0_usb_init(void) 81 122 { 82 123 int ret = 0; 83 - static const char announce[] __initconst = KERN_INFO "TUSB 6010\n"; 84 124 85 - /* PM companion chip power control pin */ 86 - ret = gpio_request_one(TUSB6010_GPIO_ENABLE, GPIOF_OUT_INIT_LOW, 87 - "TUSB6010 enable"); 88 - if (ret != 0) { 89 - printk(KERN_ERR "Could not get TUSB power GPIO%i\n", 90 - TUSB6010_GPIO_ENABLE); 91 - return; 92 - } 93 - tusb_set_power(0); 94 - 125 + gpiod_add_lookup_table(&tusb_gpio_table); 95 126 ret = tusb6010_setup_interface(&tusb_data, TUSB6010_REFCLK_19, 2, 96 - TUSB6010_ASYNC_CS, TUSB6010_SYNC_CS, 97 - TUSB6010_GPIO_INT, TUSB6010_DMACHAN); 127 + TUSB6010_ASYNC_CS, TUSB6010_SYNC_CS, 128 + TUSB6010_DMACHAN); 98 129 if (ret != 0) 99 - goto err; 130 + return; 100 131 101 - printk(announce); 132 + pr_info("TUSB 6010\n"); 102 133 103 134 return; 104 - 105 - err: 106 - gpio_free(TUSB6010_GPIO_ENABLE); 107 135 } 108 136 #else 109 137 ··· 136 170 * GPIO23 and GPIO9 slot 2 EMMC on N810 137 171 * 138 172 */ 139 - #define N8X0_SLOT_SWITCH_GPIO 96 140 - #define N810_EMMC_VSD_GPIO 23 141 - #define N810_EMMC_VIO_GPIO 9 142 - 143 173 static int slot1_cover_open; 144 174 static int slot2_cover_open; 145 175 static struct device *mmc_device; 146 176 147 - static int n8x0_mmc_switch_slot(struct device *dev, int slot) 148 - { 149 - #ifdef CONFIG_MMC_DEBUG 150 - dev_dbg(dev, "Choose slot %d\n", slot + 1); 151 - #endif 152 - gpio_set_value(N8X0_SLOT_SWITCH_GPIO, slot); 153 - return 0; 154 - } 177 + static struct gpiod_lookup_table nokia8xx_mmc_gpio_table = { 178 + .dev_id = "mmci-omap.0", 179 + .table = { 180 + /* Slot switch, GPIO 96 */ 181 + GPIO_LOOKUP("gpio-80-111", 16, 182 + "switch", GPIO_ACTIVE_HIGH), 183 + { } 184 + }, 185 + }; 186 + 187 + static struct gpiod_lookup_table nokia810_mmc_gpio_table = { 188 + .dev_id = "mmci-omap.0", 189 + .table = { 190 + /* Slot index 1, VSD power, GPIO 23 */ 191 + GPIO_LOOKUP_IDX("gpio-16-31", 7, 192 + "vsd", 1, GPIO_ACTIVE_HIGH), 193 + /* Slot index 1, VIO power, GPIO 9 */ 194 + GPIO_LOOKUP_IDX("gpio-0-15", 9, 195 + "vsd", 1, GPIO_ACTIVE_HIGH), 196 + { } 197 + }, 198 + }; 155 199 156 200 static int n8x0_mmc_set_power_menelaus(struct device *dev, int slot, 157 201 int power_on, int vdd) ··· 232 256 return 0; 233 257 } 234 258 235 - static void n810_set_power_emmc(struct device *dev, 236 - int power_on) 237 - { 238 - dev_dbg(dev, "Set EMMC power %s\n", power_on ? "on" : "off"); 239 - 240 - if (power_on) { 241 - gpio_set_value(N810_EMMC_VSD_GPIO, 1); 242 - msleep(1); 243 - gpio_set_value(N810_EMMC_VIO_GPIO, 1); 244 - msleep(1); 245 - } else { 246 - gpio_set_value(N810_EMMC_VIO_GPIO, 0); 247 - msleep(50); 248 - gpio_set_value(N810_EMMC_VSD_GPIO, 0); 249 - msleep(50); 250 - } 251 - } 252 - 253 259 static int n8x0_mmc_set_power(struct device *dev, int slot, int power_on, 254 260 int vdd) 255 261 { 256 262 if (board_is_n800() || slot == 0) 257 263 return n8x0_mmc_set_power_menelaus(dev, slot, power_on, vdd); 258 264 259 - n810_set_power_emmc(dev, power_on); 265 + /* The n810 power will be handled by GPIO code in the driver */ 260 266 261 267 return 0; 262 268 } ··· 376 418 static void n8x0_mmc_cleanup(struct device *dev) 377 419 { 378 420 menelaus_unregister_mmc_callback(); 379 - 380 - gpio_free(N8X0_SLOT_SWITCH_GPIO); 381 - 382 - if (board_is_n810()) { 383 - gpio_free(N810_EMMC_VSD_GPIO); 384 - gpio_free(N810_EMMC_VIO_GPIO); 385 - } 386 421 } 387 422 388 423 /* ··· 384 433 */ 385 434 static struct omap_mmc_platform_data mmc1_data = { 386 435 .nr_slots = 0, 387 - .switch_slot = n8x0_mmc_switch_slot, 388 436 .init = n8x0_mmc_late_init, 389 437 .cleanup = n8x0_mmc_cleanup, 390 438 .shutdown = n8x0_mmc_shutdown, ··· 413 463 414 464 static struct omap_mmc_platform_data *mmc_data[OMAP24XX_NR_MMC]; 415 465 416 - static struct gpio n810_emmc_gpios[] __initdata = { 417 - { N810_EMMC_VSD_GPIO, GPIOF_OUT_INIT_LOW, "MMC slot 2 Vddf" }, 418 - { N810_EMMC_VIO_GPIO, GPIOF_OUT_INIT_LOW, "MMC slot 2 Vdd" }, 419 - }; 420 - 421 466 static void __init n8x0_mmc_init(void) 422 467 { 423 - int err; 468 + gpiod_add_lookup_table(&nokia8xx_mmc_gpio_table); 424 469 425 470 if (board_is_n810()) { 426 471 mmc1_data.slots[0].name = "external"; ··· 428 483 */ 429 484 mmc1_data.slots[1].name = "internal"; 430 485 mmc1_data.slots[1].ban_openended = 1; 431 - } 432 - 433 - err = gpio_request_one(N8X0_SLOT_SWITCH_GPIO, GPIOF_OUT_INIT_LOW, 434 - "MMC slot switch"); 435 - if (err) 436 - return; 437 - 438 - if (board_is_n810()) { 439 - err = gpio_request_array(n810_emmc_gpios, 440 - ARRAY_SIZE(n810_emmc_gpios)); 441 - if (err) { 442 - gpio_free(N8X0_SLOT_SWITCH_GPIO); 443 - return; 444 - } 486 + gpiod_add_lookup_table(&nokia810_mmc_gpio_table); 445 487 } 446 488 447 489 mmc1_data.nr_slots = 2;
-1
arch/arm/mach-omap2/omap_device.c
··· 244 244 case BUS_NOTIFY_ADD_DEVICE: 245 245 if (pdev->dev.of_node) 246 246 omap_device_build_from_dt(pdev); 247 - omap_auxdata_legacy_init(dev); 248 247 fallthrough; 249 248 default: 250 249 od = to_omap_device(pdev);
+65 -65
arch/arm/mach-omap2/pdata-quirks.c
··· 6 6 */ 7 7 #include <linux/clk.h> 8 8 #include <linux/davinci_emac.h> 9 + #include <linux/gpio/machine.h> 9 10 #include <linux/gpio/consumer.h> 10 - #include <linux/gpio.h> 11 11 #include <linux/init.h> 12 12 #include <linux/kernel.h> 13 13 #include <linux/of_platform.h> ··· 41 41 }; 42 42 43 43 static struct of_dev_auxdata omap_auxdata_lookup[]; 44 - static struct twl4030_gpio_platform_data twl_gpio_auxdata; 45 44 46 45 #ifdef CONFIG_MACH_NOKIA_N8X0 47 46 static void __init omap2420_n8x0_legacy_init(void) ··· 97 98 }; 98 99 #endif 99 100 100 - static int omap3_sbc_t3730_twl_callback(struct device *dev, 101 - unsigned gpio, 102 - unsigned ngpio) 101 + static void __init omap3_sbc_t3x_usb_hub_init(char *hub_name, int idx) 103 102 { 104 - int res; 103 + struct gpio_desc *d; 105 104 106 - res = gpio_request_one(gpio + 2, GPIOF_OUT_INIT_HIGH, 107 - "wlan pwr"); 108 - if (res) 109 - return res; 110 - 111 - gpiod_export(gpio_to_desc(gpio), 0); 112 - 113 - return 0; 114 - } 115 - 116 - static void __init omap3_sbc_t3x_usb_hub_init(int gpio, char *hub_name) 117 - { 118 - int err = gpio_request_one(gpio, GPIOF_OUT_INIT_LOW, hub_name); 119 - 120 - if (err) { 121 - pr_err("SBC-T3x: %s reset gpio request failed: %d\n", 122 - hub_name, err); 105 + /* This asserts the RESET line (reverse polarity) */ 106 + d = gpiod_get_index(NULL, "reset", idx, GPIOD_OUT_HIGH); 107 + if (IS_ERR(d)) { 108 + pr_err("Unable to get T3x USB reset GPIO descriptor\n"); 123 109 return; 124 110 } 125 - 126 - gpiod_export(gpio_to_desc(gpio), 0); 127 - 111 + gpiod_set_consumer_name(d, hub_name); 112 + gpiod_export(d, 0); 128 113 udelay(10); 129 - gpio_set_value(gpio, 1); 114 + /* De-assert RESET */ 115 + gpiod_set_value(d, 0); 130 116 msleep(1); 131 117 } 132 118 133 - static void __init omap3_sbc_t3730_twl_init(void) 134 - { 135 - twl_gpio_auxdata.setup = omap3_sbc_t3730_twl_callback; 136 - } 119 + static struct gpiod_lookup_table omap3_sbc_t3x_usb_gpio_table = { 120 + .dev_id = NULL, 121 + .table = { 122 + GPIO_LOOKUP_IDX("gpio-160-175", 7, "reset", 0, 123 + GPIO_ACTIVE_LOW), 124 + { } 125 + }, 126 + }; 137 127 138 128 static void __init omap3_sbc_t3730_legacy_init(void) 139 129 { 140 - omap3_sbc_t3x_usb_hub_init(167, "sb-t35 usb hub"); 130 + gpiod_add_lookup_table(&omap3_sbc_t3x_usb_gpio_table); 131 + omap3_sbc_t3x_usb_hub_init("sb-t35 usb hub", 0); 141 132 } 142 133 143 134 static void __init omap3_sbc_t3530_legacy_init(void) 144 135 { 145 - omap3_sbc_t3x_usb_hub_init(167, "sb-t35 usb hub"); 136 + gpiod_add_lookup_table(&omap3_sbc_t3x_usb_gpio_table); 137 + omap3_sbc_t3x_usb_hub_init("sb-t35 usb hub", 0); 146 138 } 147 139 148 140 static void __init omap3_evm_legacy_init(void) ··· 177 187 omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET); /* OCP barrier */ 178 188 } 179 189 180 - static struct gpio cm_t3517_wlan_gpios[] __initdata = { 181 - { 56, GPIOF_OUT_INIT_HIGH, "wlan pwr" }, 182 - { 4, GPIOF_OUT_INIT_HIGH, "xcvr noe" }, 190 + static struct gpiod_lookup_table cm_t3517_wlan_gpio_table = { 191 + .dev_id = NULL, 192 + .table = { 193 + GPIO_LOOKUP("gpio-48-53", 8, "power", 194 + GPIO_ACTIVE_HIGH), 195 + GPIO_LOOKUP("gpio-0-15", 4, "noe", 196 + GPIO_ACTIVE_HIGH), 197 + { } 198 + }, 183 199 }; 184 200 185 201 static void __init omap3_sbc_t3517_wifi_init(void) 186 202 { 187 - int err = gpio_request_array(cm_t3517_wlan_gpios, 188 - ARRAY_SIZE(cm_t3517_wlan_gpios)); 189 - if (err) { 190 - pr_err("SBC-T3517: wl12xx gpios request failed: %d\n", err); 191 - return; 203 + struct gpio_desc *d; 204 + 205 + gpiod_add_lookup_table(&cm_t3517_wlan_gpio_table); 206 + 207 + /* This asserts the RESET line (reverse polarity) */ 208 + d = gpiod_get(NULL, "power", GPIOD_OUT_HIGH); 209 + if (IS_ERR(d)) { 210 + pr_err("Unable to get CM T3517 WLAN power GPIO descriptor\n"); 211 + } else { 212 + gpiod_set_consumer_name(d, "wlan pwr"); 213 + gpiod_export(d, 0); 192 214 } 193 215 194 - gpiod_export(gpio_to_desc(cm_t3517_wlan_gpios[0].gpio), 0); 195 - gpiod_export(gpio_to_desc(cm_t3517_wlan_gpios[1].gpio), 0); 196 - 216 + d = gpiod_get(NULL, "noe", GPIOD_OUT_HIGH); 217 + if (IS_ERR(d)) { 218 + pr_err("Unable to get CM T3517 WLAN XCVR NOE GPIO descriptor\n"); 219 + } else { 220 + gpiod_set_consumer_name(d, "xcvr noe"); 221 + gpiod_export(d, 0); 222 + } 197 223 msleep(100); 198 - gpio_set_value(cm_t3517_wlan_gpios[1].gpio, 0); 224 + gpiod_set_value(d, 0); 199 225 } 226 + 227 + static struct gpiod_lookup_table omap3_sbc_t3517_usb_gpio_table = { 228 + .dev_id = NULL, 229 + .table = { 230 + GPIO_LOOKUP_IDX("gpio-144-159", 8, "reset", 0, 231 + GPIO_ACTIVE_LOW), 232 + GPIO_LOOKUP_IDX("gpio-96-111", 2, "reset", 1, 233 + GPIO_ACTIVE_LOW), 234 + { } 235 + }, 236 + }; 200 237 201 238 static void __init omap3_sbc_t3517_legacy_init(void) 202 239 { 203 - omap3_sbc_t3x_usb_hub_init(152, "cm-t3517 usb hub"); 204 - omap3_sbc_t3x_usb_hub_init(98, "sb-t35 usb hub"); 240 + gpiod_add_lookup_table(&omap3_sbc_t3517_usb_gpio_table); 241 + omap3_sbc_t3x_usb_hub_init("cm-t3517 usb hub", 0); 242 + omap3_sbc_t3x_usb_hub_init("sb-t35 usb hub", 1); 205 243 am35xx_emac_reset(); 206 244 hsmmc2_internal_input_clk(); 207 245 omap3_sbc_t3517_wifi_init(); ··· 411 393 .clkdm_lookup = clkdm_lookup, 412 394 }; 413 395 414 - /* 415 - * GPIOs for TWL are initialized by the I2C bus and need custom 416 - * handing until DSS has device tree bindings. 417 - */ 418 - void omap_auxdata_legacy_init(struct device *dev) 419 - { 420 - if (dev->platform_data) 421 - return; 422 - 423 - if (strcmp("twl4030-gpio", dev_name(dev))) 424 - return; 425 - 426 - dev->platform_data = &twl_gpio_auxdata; 427 - } 428 - 429 396 #if defined(CONFIG_ARCH_OMAP3) && IS_ENABLED(CONFIG_SND_SOC_OMAP_MCBSP) 430 397 static struct omap_mcbsp_platform_data mcbsp_pdata; 431 398 static void __init omap3_mcbsp_init(void) ··· 430 427 { "nokia,n800", omap2420_n8x0_legacy_init, }, 431 428 { "nokia,n810", omap2420_n8x0_legacy_init, }, 432 429 { "nokia,n810-wimax", omap2420_n8x0_legacy_init, }, 433 - #endif 434 - #ifdef CONFIG_ARCH_OMAP3 435 - { "compulab,omap3-sbc-t3730", omap3_sbc_t3730_twl_init, }, 436 430 #endif 437 431 { /* sentinel */ }, 438 432 };
+4 -16
arch/arm/mach-omap2/usb-tusb6010.c
··· 11 11 #include <linux/errno.h> 12 12 #include <linux/delay.h> 13 13 #include <linux/platform_device.h> 14 - #include <linux/gpio.h> 15 14 #include <linux/export.h> 16 15 #include <linux/platform_data/usb-omap.h> 17 16 18 17 #include <linux/usb/musb.h> 19 18 19 + #include "usb-tusb6010.h" 20 20 #include "gpmc.h" 21 21 22 22 static u8 async_cs, sync_cs; ··· 132 132 { /* Synchronous access */ 133 133 .flags = IORESOURCE_MEM, 134 134 }, 135 - { /* IRQ */ 136 - .name = "mc", 137 - .flags = IORESOURCE_IRQ, 138 - }, 139 135 }; 140 136 141 137 static u64 tusb_dmamask = ~(u32)0; ··· 150 154 151 155 /* this may be called only from board-*.c setup code */ 152 156 int __init tusb6010_setup_interface(struct musb_hdrc_platform_data *data, 153 - unsigned ps_refclk, unsigned waitpin, 154 - unsigned async, unsigned sync, 155 - unsigned irq, unsigned dmachan) 157 + unsigned int ps_refclk, unsigned int waitpin, 158 + unsigned int async, unsigned int sync, 159 + unsigned int dmachan) 156 160 { 157 161 int status; 158 162 static char error[] __initdata = ··· 187 191 status = gpmc_cs_program_settings(sync_cs, &tusb_sync); 188 192 if (status < 0) 189 193 return status; 190 - 191 - /* IRQ */ 192 - status = gpio_request_one(irq, GPIOF_IN, "TUSB6010 irq"); 193 - if (status < 0) { 194 - printk(error, 3, status); 195 - return status; 196 - } 197 - tusb_resources[2].start = gpio_to_irq(irq); 198 194 199 195 /* set up memory timings ... can speed them up later */ 200 196 if (!ps_refclk) {
+12
arch/arm/mach-omap2/usb-tusb6010.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + 3 + #ifndef __USB_TUSB6010_H 4 + #define __USB_TUSB6010_H 5 + 6 + extern int __init tusb6010_setup_interface( 7 + struct musb_hdrc_platform_data *data, 8 + unsigned int ps_refclk, unsigned int waitpin, 9 + unsigned int async_cs, unsigned int sync_cs, 10 + unsigned int dmachan); 11 + 12 + #endif /* __USB_TUSB6010_H */
+10 -1
arch/arm/mach-pxa/spitz.c
··· 506 506 .x_plate_ohms = 419, 507 507 .y_plate_ohms = 486, 508 508 .pressure_max = 1024, 509 - .gpio_pendown = SPITZ_GPIO_TP_INT, 510 509 .wait_for_sync = spitz_ads7846_wait_for_hsync, 510 + }; 511 + 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 + }, 511 519 }; 512 520 513 521 static void spitz_bl_kick_battery(void) ··· 602 594 else 603 595 gpiod_add_lookup_table(&spitz_lcdcon_gpio_table); 604 596 597 + gpiod_add_lookup_table(&spitz_ads7846_gpio_table); 605 598 gpiod_add_lookup_table(&spitz_spi_gpio_table); 606 599 pxa2xx_set_spi_info(2, &spitz_spi_info); 607 600 spi_register_board_info(ARRAY_AND_SIZE(spitz_spi_devices));
+10 -1
arch/mips/alchemy/devboards/db1000.c
··· 381 381 static struct ads7846_platform_data db1100_touch_pd = { 382 382 .model = 7846, 383 383 .vref_mv = 3300, 384 - .gpio_pendown = 21, 385 384 }; 386 385 387 386 static struct spi_gpio_platform_data db1100_spictl_pd = { 388 387 .num_chipselect = 1, 388 + }; 389 + 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 + }, 389 397 }; 390 398 391 399 static struct spi_board_info db1100_spi_info[] __initdata = { ··· 482 474 pfc |= (1 << 0); /* SSI0 pins as GPIOs */ 483 475 alchemy_wrsys(pfc, AU1000_SYS_PINFUNC); 484 476 477 + gpiod_add_lookup_table(&db1100_touch_gpio_table); 485 478 spi_register_board_info(db1100_spi_info, 486 479 ARRAY_SIZE(db1100_spi_info)); 487 480
+36 -16
drivers/gpio/gpio-twl4030.c
··· 17 17 #include <linux/interrupt.h> 18 18 #include <linux/kthread.h> 19 19 #include <linux/irq.h> 20 + #include <linux/gpio/machine.h> 20 21 #include <linux/gpio/driver.h> 22 + #include <linux/gpio/consumer.h> 21 23 #include <linux/platform_device.h> 22 24 #include <linux/of.h> 23 25 #include <linux/irqdomain.h> ··· 467 465 REG_GPIO_DEBEN1, 3); 468 466 } 469 467 470 - static struct twl4030_gpio_platform_data *of_gpio_twl4030(struct device *dev, 471 - struct twl4030_gpio_platform_data *pdata) 468 + static struct twl4030_gpio_platform_data *of_gpio_twl4030(struct device *dev) 472 469 { 473 470 struct twl4030_gpio_platform_data *omap_twl_info; 474 471 475 472 omap_twl_info = devm_kzalloc(dev, sizeof(*omap_twl_info), GFP_KERNEL); 476 473 if (!omap_twl_info) 477 474 return NULL; 478 - 479 - if (pdata) 480 - *omap_twl_info = *pdata; 481 475 482 476 omap_twl_info->use_leds = of_property_read_bool(dev->of_node, 483 477 "ti,use-leds"); ··· 502 504 return 0; 503 505 } 504 506 507 + /* Called from the registered devm action */ 508 + static void gpio_twl4030_power_off_action(void *data) 509 + { 510 + struct gpio_desc *d = data; 511 + 512 + gpiod_unexport(d); 513 + gpiochip_free_own_desc(d); 514 + } 515 + 505 516 static int gpio_twl4030_probe(struct platform_device *pdev) 506 517 { 507 - struct twl4030_gpio_platform_data *pdata = dev_get_platdata(&pdev->dev); 518 + struct twl4030_gpio_platform_data *pdata; 508 519 struct device_node *node = pdev->dev.of_node; 509 520 struct gpio_twl4030_priv *priv; 510 521 int ret, irq_base; ··· 553 546 554 547 mutex_init(&priv->mutex); 555 548 556 - if (node) 557 - pdata = of_gpio_twl4030(&pdev->dev, pdata); 558 - 549 + pdata = of_gpio_twl4030(&pdev->dev); 559 550 if (pdata == NULL) { 560 551 dev_err(&pdev->dev, "Platform data is missing\n"); 561 552 return -ENXIO; ··· 590 585 goto out; 591 586 } 592 587 593 - platform_set_drvdata(pdev, priv); 588 + /* 589 + * Special quirk for the OMAP3 to hog and export a WLAN power 590 + * GPIO. 591 + */ 592 + if (IS_ENABLED(CONFIG_ARCH_OMAP3) && 593 + of_machine_is_compatible("compulab,omap3-sbc-t3730")) { 594 + struct gpio_desc *d; 594 595 595 - if (pdata->setup) { 596 - int status; 596 + d = gpiochip_request_own_desc(&priv->gpio_chip, 597 + 2, "wlan pwr", 598 + GPIO_ACTIVE_HIGH, 599 + GPIOD_OUT_HIGH); 600 + if (IS_ERR(d)) 601 + return dev_err_probe(&pdev->dev, PTR_ERR(d), 602 + "unable to hog wlan pwr GPIO\n"); 597 603 598 - status = pdata->setup(&pdev->dev, priv->gpio_chip.base, 599 - TWL4030_GPIO_MAX); 600 - if (status) 601 - dev_dbg(&pdev->dev, "setup --> %d\n", status); 604 + gpiod_export(d, 0); 605 + 606 + ret = devm_add_action_or_reset(&pdev->dev, gpio_twl4030_power_off_action, d); 607 + if (ret) 608 + return dev_err_probe(&pdev->dev, ret, 609 + "failed to install power off handler\n"); 610 + 602 611 } 603 612 613 + platform_set_drvdata(pdev, priv); 604 614 out: 605 615 return ret; 606 616 }
+43 -74
drivers/input/touchscreen/ads7846.c
··· 24 24 #include <linux/interrupt.h> 25 25 #include <linux/slab.h> 26 26 #include <linux/pm.h> 27 - #include <linux/of.h> 28 - #include <linux/of_gpio.h> 29 - #include <linux/of_device.h> 27 + #include <linux/property.h> 30 28 #include <linux/gpio/consumer.h> 31 - #include <linux/gpio.h> 32 29 #include <linux/spi/spi.h> 33 30 #include <linux/spi/ads7846.h> 34 31 #include <linux/regulator/consumer.h> ··· 137 140 int (*filter)(void *data, int data_idx, int *val); 138 141 void *filter_data; 139 142 int (*get_pendown_state)(void); 140 - int gpio_pendown; 143 + struct gpio_desc *gpio_pendown; 141 144 142 145 void (*wait_for_sync)(void); 143 146 }; ··· 220 223 if (ts->get_pendown_state) 221 224 return ts->get_pendown_state(); 222 225 223 - return !gpio_get_value(ts->gpio_pendown); 226 + return gpiod_get_value(ts->gpio_pendown); 224 227 } 225 228 226 229 static void ads7846_report_pen_up(struct ads7846 *ts) ··· 986 989 struct ads7846 *ts, 987 990 const struct ads7846_platform_data *pdata) 988 991 { 989 - int err; 990 - 991 992 /* 992 993 * REVISIT when the irq can be triggered active-low, or if for some 993 994 * reason the touchscreen isn't hooked up, we don't need to access ··· 994 999 995 1000 if (pdata->get_pendown_state) { 996 1001 ts->get_pendown_state = pdata->get_pendown_state; 997 - } else if (gpio_is_valid(pdata->gpio_pendown)) { 998 - 999 - err = devm_gpio_request_one(&spi->dev, pdata->gpio_pendown, 1000 - GPIOF_IN, "ads7846_pendown"); 1001 - if (err) { 1002 - dev_err(&spi->dev, 1003 - "failed to request/setup pendown GPIO%d: %d\n", 1004 - pdata->gpio_pendown, err); 1005 - return err; 1006 - } 1007 - 1008 - ts->gpio_pendown = pdata->gpio_pendown; 1009 - 1010 - if (pdata->gpio_pendown_debounce) 1011 - gpiod_set_debounce(gpio_to_desc(ts->gpio_pendown), 1012 - pdata->gpio_pendown_debounce); 1013 1002 } else { 1014 - dev_err(&spi->dev, "no get_pendown_state nor gpio_pendown?\n"); 1015 - return -EINVAL; 1003 + ts->gpio_pendown = gpiod_get(&spi->dev, "pendown", GPIOD_IN); 1004 + if (IS_ERR(ts->gpio_pendown)) { 1005 + dev_err(&spi->dev, "failed to request pendown GPIO\n"); 1006 + return PTR_ERR(ts->gpio_pendown); 1007 + } 1008 + if (pdata->gpio_pendown_debounce) 1009 + gpiod_set_debounce(ts->gpio_pendown, 1010 + pdata->gpio_pendown_debounce); 1016 1011 } 1017 1012 1018 1013 return 0; ··· 1104 1119 return 0; 1105 1120 } 1106 1121 1107 - #ifdef CONFIG_OF 1108 1122 static const struct of_device_id ads7846_dt_ids[] = { 1109 1123 { .compatible = "ti,tsc2046", .data = (void *) 7846 }, 1110 1124 { .compatible = "ti,ads7843", .data = (void *) 7843 }, ··· 1114 1130 }; 1115 1131 MODULE_DEVICE_TABLE(of, ads7846_dt_ids); 1116 1132 1117 - static const struct ads7846_platform_data *ads7846_probe_dt(struct device *dev) 1133 + static const struct ads7846_platform_data *ads7846_get_props(struct device *dev) 1118 1134 { 1119 1135 struct ads7846_platform_data *pdata; 1120 - struct device_node *node = dev->of_node; 1121 - const struct of_device_id *match; 1136 + const struct platform_device_id *pdev_id; 1122 1137 u32 value; 1123 1138 1124 - if (!node) { 1125 - dev_err(dev, "Device does not have associated DT data\n"); 1126 - return ERR_PTR(-EINVAL); 1127 - } 1128 - 1129 - match = of_match_device(ads7846_dt_ids, dev); 1130 - if (!match) { 1139 + pdev_id = device_get_match_data(dev); 1140 + if (!pdev_id) { 1131 1141 dev_err(dev, "Unknown device model\n"); 1132 1142 return ERR_PTR(-EINVAL); 1133 1143 } ··· 1130 1152 if (!pdata) 1131 1153 return ERR_PTR(-ENOMEM); 1132 1154 1133 - pdata->model = (unsigned long)match->data; 1155 + pdata->model = (unsigned long)pdev_id->driver_data; 1134 1156 1135 - of_property_read_u16(node, "ti,vref-delay-usecs", 1136 - &pdata->vref_delay_usecs); 1137 - of_property_read_u16(node, "ti,vref-mv", &pdata->vref_mv); 1138 - pdata->keep_vref_on = of_property_read_bool(node, "ti,keep-vref-on"); 1157 + device_property_read_u16(dev, "ti,vref-delay-usecs", 1158 + &pdata->vref_delay_usecs); 1159 + device_property_read_u16(dev, "ti,vref-mv", &pdata->vref_mv); 1160 + pdata->keep_vref_on = device_property_read_bool(dev, "ti,keep-vref-on"); 1139 1161 1140 - pdata->swap_xy = of_property_read_bool(node, "ti,swap-xy"); 1162 + pdata->swap_xy = device_property_read_bool(dev, "ti,swap-xy"); 1141 1163 1142 - of_property_read_u16(node, "ti,settle-delay-usec", 1143 - &pdata->settle_delay_usecs); 1144 - of_property_read_u16(node, "ti,penirq-recheck-delay-usecs", 1145 - &pdata->penirq_recheck_delay_usecs); 1164 + device_property_read_u16(dev, "ti,settle-delay-usec", 1165 + &pdata->settle_delay_usecs); 1166 + device_property_read_u16(dev, "ti,penirq-recheck-delay-usecs", 1167 + &pdata->penirq_recheck_delay_usecs); 1146 1168 1147 - of_property_read_u16(node, "ti,x-plate-ohms", &pdata->x_plate_ohms); 1148 - of_property_read_u16(node, "ti,y-plate-ohms", &pdata->y_plate_ohms); 1169 + device_property_read_u16(dev, "ti,x-plate-ohms", &pdata->x_plate_ohms); 1170 + device_property_read_u16(dev, "ti,y-plate-ohms", &pdata->y_plate_ohms); 1149 1171 1150 - of_property_read_u16(node, "ti,x-min", &pdata->x_min); 1151 - of_property_read_u16(node, "ti,y-min", &pdata->y_min); 1152 - of_property_read_u16(node, "ti,x-max", &pdata->x_max); 1153 - of_property_read_u16(node, "ti,y-max", &pdata->y_max); 1172 + device_property_read_u16(dev, "ti,x-min", &pdata->x_min); 1173 + device_property_read_u16(dev, "ti,y-min", &pdata->y_min); 1174 + device_property_read_u16(dev, "ti,x-max", &pdata->x_max); 1175 + device_property_read_u16(dev, "ti,y-max", &pdata->y_max); 1154 1176 1155 1177 /* 1156 1178 * touchscreen-max-pressure gets parsed during 1157 1179 * touchscreen_parse_properties() 1158 1180 */ 1159 - of_property_read_u16(node, "ti,pressure-min", &pdata->pressure_min); 1160 - if (!of_property_read_u32(node, "touchscreen-min-pressure", &value)) 1181 + device_property_read_u16(dev, "ti,pressure-min", &pdata->pressure_min); 1182 + if (!device_property_read_u32(dev, "touchscreen-min-pressure", &value)) 1161 1183 pdata->pressure_min = (u16) value; 1162 - of_property_read_u16(node, "ti,pressure-max", &pdata->pressure_max); 1184 + device_property_read_u16(dev, "ti,pressure-max", &pdata->pressure_max); 1163 1185 1164 - of_property_read_u16(node, "ti,debounce-max", &pdata->debounce_max); 1165 - if (!of_property_read_u32(node, "touchscreen-average-samples", &value)) 1186 + device_property_read_u16(dev, "ti,debounce-max", &pdata->debounce_max); 1187 + if (!device_property_read_u32(dev, "touchscreen-average-samples", &value)) 1166 1188 pdata->debounce_max = (u16) value; 1167 - of_property_read_u16(node, "ti,debounce-tol", &pdata->debounce_tol); 1168 - of_property_read_u16(node, "ti,debounce-rep", &pdata->debounce_rep); 1189 + device_property_read_u16(dev, "ti,debounce-tol", &pdata->debounce_tol); 1190 + device_property_read_u16(dev, "ti,debounce-rep", &pdata->debounce_rep); 1169 1191 1170 - of_property_read_u32(node, "ti,pendown-gpio-debounce", 1192 + device_property_read_u32(dev, "ti,pendown-gpio-debounce", 1171 1193 &pdata->gpio_pendown_debounce); 1172 1194 1173 - pdata->wakeup = of_property_read_bool(node, "wakeup-source") || 1174 - of_property_read_bool(node, "linux,wakeup"); 1175 - 1176 - pdata->gpio_pendown = of_get_named_gpio(dev->of_node, "pendown-gpio", 0); 1195 + pdata->wakeup = device_property_read_bool(dev, "wakeup-source") || 1196 + device_property_read_bool(dev, "linux,wakeup"); 1177 1197 1178 1198 return pdata; 1179 1199 } 1180 - #else 1181 - static const struct ads7846_platform_data *ads7846_probe_dt(struct device *dev) 1182 - { 1183 - dev_err(dev, "no platform data defined\n"); 1184 - return ERR_PTR(-EINVAL); 1185 - } 1186 - #endif 1187 1200 1188 1201 static void ads7846_regulator_disable(void *regulator) 1189 1202 { ··· 1238 1269 1239 1270 pdata = dev_get_platdata(dev); 1240 1271 if (!pdata) { 1241 - pdata = ads7846_probe_dt(dev); 1272 + pdata = ads7846_get_props(dev); 1242 1273 if (IS_ERR(pdata)) 1243 1274 return PTR_ERR(pdata); 1244 1275 } ··· 1395 1426 .driver = { 1396 1427 .name = "ads7846", 1397 1428 .pm = pm_sleep_ptr(&ads7846_pm), 1398 - .of_match_table = of_match_ptr(ads7846_dt_ids), 1429 + .of_match_table = ads7846_dt_ids, 1399 1430 }, 1400 1431 .probe = ads7846_probe, 1401 1432 .remove = ads7846_remove,
+5 -9
drivers/mfd/tps65010.c
··· 506 506 struct tps65010 *tps = i2c_get_clientdata(client); 507 507 struct tps65010_board *board = dev_get_platdata(&client->dev); 508 508 509 - if (board && board->teardown) { 510 - int status = board->teardown(client, board->context); 511 - if (status < 0) 512 - dev_dbg(&client->dev, "board %s %s err %d\n", 513 - "teardown", client->name, status); 514 - } 509 + if (board && board->teardown) 510 + board->teardown(client, &tps->chip); 515 511 if (client->irq > 0) 516 512 free_irq(client->irq, tps); 517 513 cancel_delayed_work_sync(&tps->work); ··· 615 619 tps, DEBUG_FOPS); 616 620 617 621 /* optionally register GPIOs */ 618 - if (board && board->base != 0) { 622 + if (board) { 619 623 tps->outmask = board->outmask; 620 624 621 625 tps->chip.label = client->name; ··· 628 632 /* NOTE: only partial support for inputs; nyet IRQs */ 629 633 tps->chip.get = tps65010_gpio_get; 630 634 631 - tps->chip.base = board->base; 635 + tps->chip.base = -1; 632 636 tps->chip.ngpio = 7; 633 637 tps->chip.can_sleep = 1; 634 638 ··· 637 641 dev_err(&client->dev, "can't add gpiochip, err %d\n", 638 642 status); 639 643 else if (board->setup) { 640 - status = board->setup(client, board->context); 644 + status = board->setup(client, &tps->chip); 641 645 if (status < 0) { 642 646 dev_dbg(&client->dev, 643 647 "board %s %s err %d\n",
+44 -2
drivers/mmc/host/omap.c
··· 26 26 #include <linux/clk.h> 27 27 #include <linux/scatterlist.h> 28 28 #include <linux/slab.h> 29 + #include <linux/gpio/consumer.h> 29 30 #include <linux/platform_data/mmc-omap.h> 30 31 31 32 ··· 112 111 struct mmc_request *mrq; 113 112 struct mmc_omap_host *host; 114 113 struct mmc_host *mmc; 114 + struct gpio_desc *vsd; 115 + struct gpio_desc *vio; 116 + struct gpio_desc *cover; 115 117 struct omap_mmc_slot_data *pdata; 116 118 }; 117 119 ··· 137 133 int irq; 138 134 unsigned char bus_mode; 139 135 unsigned int reg_shift; 136 + struct gpio_desc *slot_switch; 140 137 141 138 struct work_struct cmd_abort_work; 142 139 unsigned abort:1; ··· 221 216 222 217 if (host->current_slot != slot) { 223 218 OMAP_MMC_WRITE(host, CON, slot->saved_con & 0xFC00); 224 - if (host->pdata->switch_slot != NULL) 225 - host->pdata->switch_slot(mmc_dev(slot->mmc), slot->id); 219 + if (host->slot_switch) 220 + /* 221 + * With two slots and a simple GPIO switch, setting 222 + * the GPIO to 0 selects slot ID 0, setting it to 1 223 + * selects slot ID 1. 224 + */ 225 + gpiod_set_value(host->slot_switch, slot->id); 226 226 host->current_slot = slot; 227 227 } 228 228 ··· 307 297 static inline 308 298 int mmc_omap_cover_is_open(struct mmc_omap_slot *slot) 309 299 { 300 + /* If we have a GPIO then use that */ 301 + if (slot->cover) 302 + return gpiod_get_value(slot->cover); 310 303 if (slot->pdata->get_cover_state) 311 304 return slot->pdata->get_cover_state(mmc_dev(slot->mmc), 312 305 slot->id); ··· 1119 1106 1120 1107 host = slot->host; 1121 1108 1109 + if (slot->vsd) 1110 + gpiod_set_value(slot->vsd, power_on); 1111 + if (slot->vio) 1112 + gpiod_set_value(slot->vio, power_on); 1113 + 1122 1114 if (slot->pdata->set_power != NULL) 1123 1115 slot->pdata->set_power(mmc_dev(slot->mmc), slot->id, power_on, 1124 1116 vdd); ··· 1258 1240 slot->power_mode = MMC_POWER_UNDEFINED; 1259 1241 slot->pdata = &host->pdata->slots[id]; 1260 1242 1243 + /* Check for some optional GPIO controls */ 1244 + slot->vsd = gpiod_get_index_optional(host->dev, "vsd", 1245 + id, GPIOD_OUT_LOW); 1246 + if (IS_ERR(slot->vsd)) 1247 + return dev_err_probe(host->dev, PTR_ERR(slot->vsd), 1248 + "error looking up VSD GPIO\n"); 1249 + slot->vio = gpiod_get_index_optional(host->dev, "vio", 1250 + id, GPIOD_OUT_LOW); 1251 + if (IS_ERR(slot->vio)) 1252 + return dev_err_probe(host->dev, PTR_ERR(slot->vio), 1253 + "error looking up VIO GPIO\n"); 1254 + slot->cover = gpiod_get_index_optional(host->dev, "cover", 1255 + id, GPIOD_IN); 1256 + if (IS_ERR(slot->cover)) 1257 + return dev_err_probe(host->dev, PTR_ERR(slot->cover), 1258 + "error looking up cover switch GPIO\n"); 1259 + 1261 1260 host->slots[id] = slot; 1262 1261 1263 1262 mmc->caps = 0; ··· 1383 1348 host->virt_base = devm_platform_get_and_ioremap_resource(pdev, 0, &res); 1384 1349 if (IS_ERR(host->virt_base)) 1385 1350 return PTR_ERR(host->virt_base); 1351 + 1352 + host->slot_switch = gpiod_get_optional(host->dev, "switch", 1353 + GPIOD_OUT_LOW); 1354 + if (IS_ERR(host->slot_switch)) 1355 + return dev_err_probe(host->dev, PTR_ERR(host->slot_switch), 1356 + "error looking up slot switch GPIO\n"); 1357 + 1386 1358 1387 1359 INIT_WORK(&host->slot_release_work, mmc_omap_slot_release_work); 1388 1360 INIT_WORK(&host->send_stop_work, mmc_omap_send_stop_work);
-1
drivers/usb/musb/musb_core.c
··· 2330 2330 2331 2331 spin_lock_init(&musb->lock); 2332 2332 spin_lock_init(&musb->list_lock); 2333 - musb->board_set_power = plat->set_power; 2334 2333 musb->min_power = plat->min_power; 2335 2334 musb->ops = plat->platform_ops; 2336 2335 musb->port_mode = plat->mode;
-2
drivers/usb/musb/musb_core.h
··· 352 352 u16 epmask; 353 353 u8 nr_endpoints; 354 354 355 - int (*board_set_power)(int state); 356 - 357 355 u8 min_power; /* vbus for periph, in mA/2 */ 358 356 359 357 enum musb_mode port_mode;
+39 -14
drivers/usb/musb/tusb6010.c
··· 11 11 * interface. 12 12 */ 13 13 14 + #include <linux/gpio/consumer.h> 15 + #include <linux/delay.h> 14 16 #include <linux/module.h> 15 17 #include <linux/kernel.h> 16 18 #include <linux/errno.h> ··· 32 30 struct device *dev; 33 31 struct platform_device *musb; 34 32 struct platform_device *phy; 33 + struct gpio_desc *enable; 34 + struct gpio_desc *intpin; 35 35 }; 36 36 37 37 static void tusb_musb_set_vbus(struct musb *musb, int is_on); ··· 1025 1021 1026 1022 static int tusb_musb_start(struct musb *musb) 1027 1023 { 1024 + struct tusb6010_glue *glue = dev_get_drvdata(musb->controller->parent); 1028 1025 void __iomem *tbase = musb->ctrl_base; 1029 - int ret = 0; 1030 1026 unsigned long flags; 1031 1027 u32 reg; 1028 + int i; 1032 1029 1033 - if (musb->board_set_power) 1034 - ret = musb->board_set_power(1); 1035 - if (ret != 0) { 1036 - printk(KERN_ERR "tusb: Cannot enable TUSB6010\n"); 1037 - return ret; 1030 + /* 1031 + * Enable or disable power to TUSB6010. When enabling, turn on 3.3 V and 1032 + * 1.5 V voltage regulators of PM companion chip. Companion chip will then 1033 + * provide then PGOOD signal to TUSB6010 which will release it from reset. 1034 + */ 1035 + gpiod_set_value(glue->enable, 1); 1036 + msleep(1); 1037 + 1038 + /* Wait for 100ms until TUSB6010 pulls INT pin down */ 1039 + i = 100; 1040 + while (i && gpiod_get_value(glue->intpin)) { 1041 + msleep(1); 1042 + i--; 1043 + } 1044 + if (!i) { 1045 + pr_err("tusb: Powerup respones failed\n"); 1046 + return -ENODEV; 1038 1047 } 1039 1048 1040 1049 spin_lock_irqsave(&musb->lock, flags); ··· 1100 1083 err: 1101 1084 spin_unlock_irqrestore(&musb->lock, flags); 1102 1085 1103 - if (musb->board_set_power) 1104 - musb->board_set_power(0); 1086 + gpiod_set_value(glue->enable, 0); 1087 + msleep(10); 1105 1088 1106 1089 return -ENODEV; 1107 1090 } ··· 1175 1158 1176 1159 static int tusb_musb_exit(struct musb *musb) 1177 1160 { 1161 + struct tusb6010_glue *glue = dev_get_drvdata(musb->controller->parent); 1162 + 1178 1163 del_timer_sync(&musb->dev_timer); 1179 1164 the_musb = NULL; 1180 1165 1181 - if (musb->board_set_power) 1182 - musb->board_set_power(0); 1166 + gpiod_set_value(glue->enable, 0); 1167 + msleep(10); 1183 1168 1184 1169 iounmap(musb->sync_va); 1185 1170 ··· 1237 1218 1238 1219 glue->dev = &pdev->dev; 1239 1220 1221 + glue->enable = devm_gpiod_get(glue->dev, "enable", GPIOD_OUT_LOW); 1222 + if (IS_ERR(glue->enable)) 1223 + return dev_err_probe(glue->dev, PTR_ERR(glue->enable), 1224 + "could not obtain power on/off GPIO\n"); 1225 + glue->intpin = devm_gpiod_get(glue->dev, "int", GPIOD_IN); 1226 + if (IS_ERR(glue->intpin)) 1227 + return dev_err_probe(glue->dev, PTR_ERR(glue->intpin), 1228 + "could not obtain INT GPIO\n"); 1229 + 1240 1230 pdata->platform_ops = &tusb_ops; 1241 1231 1242 1232 usb_phy_generic_register(); ··· 1264 1236 musb_resources[1].end = pdev->resource[1].end; 1265 1237 musb_resources[1].flags = pdev->resource[1].flags; 1266 1238 1267 - musb_resources[2].name = pdev->resource[2].name; 1268 - musb_resources[2].start = pdev->resource[2].start; 1269 - musb_resources[2].end = pdev->resource[2].end; 1270 - musb_resources[2].flags = pdev->resource[2].flags; 1239 + musb_resources[2] = DEFINE_RES_IRQ_NAMED(gpiod_to_irq(glue->intpin), "mc"); 1271 1240 1272 1241 pinfo = tusb_dev_info; 1273 1242 pinfo.parent = &pdev->dev;
+10
drivers/video/fbdev/omap/lcd_mipid.c
··· 7 7 */ 8 8 #include <linux/device.h> 9 9 #include <linux/delay.h> 10 + #include <linux/gpio/consumer.h> 10 11 #include <linux/slab.h> 11 12 #include <linux/workqueue.h> 12 13 #include <linux/spi/spi.h> ··· 42 41 when we can issue the 43 42 next sleep in/out command */ 44 43 unsigned long hw_guard_wait; /* max guard time in jiffies */ 44 + struct gpio_desc *reset; 45 45 46 46 struct omapfb_device *fbdev; 47 47 struct spi_device *spi; ··· 558 556 return -ENOMEM; 559 557 } 560 558 559 + /* This will de-assert RESET if active */ 560 + md->reset = gpiod_get(&spi->dev, "reset", GPIOD_OUT_LOW); 561 + if (IS_ERR(md->reset)) 562 + return dev_err_probe(&spi->dev, PTR_ERR(md->reset), 563 + "no reset GPIO line\n"); 564 + 561 565 spi->mode = SPI_MODE_0; 562 566 md->spi = spi; 563 567 dev_set_drvdata(&spi->dev, md); ··· 582 574 { 583 575 struct mipid_device *md = dev_get_drvdata(&spi->dev); 584 576 577 + /* Asserts RESET */ 578 + gpiod_set_value(md->reset, 1); 585 579 mipid_disable(&md->panel); 586 580 kfree(md); 587 581 }
+4 -7
include/linux/mfd/tps65010.h
··· 28 28 #ifndef __LINUX_I2C_TPS65010_H 29 29 #define __LINUX_I2C_TPS65010_H 30 30 31 + struct gpio_chip; 32 + 31 33 /* 32 34 * ---------------------------------------------------------------------------- 33 35 * Registers, all 8 bits ··· 178 176 179 177 /** 180 178 * struct tps65010_board - packages GPIO and LED lines 181 - * @base: the GPIO number to assign to GPIO-1 182 179 * @outmask: bit (N-1) is set to allow GPIO-N to be used as an 183 180 * (open drain) output 184 181 * @setup: optional callback issued once the GPIOs are valid 185 182 * @teardown: optional callback issued before the GPIOs are invalidated 186 - * @context: optional parameter passed to setup() and teardown() 187 183 * 188 184 * Board data may be used to package the GPIO (and LED) lines for use 189 185 * in by the generic GPIO and LED frameworks. The first four GPIOs ··· 193 193 * devices in their initial states using these GPIOs. 194 194 */ 195 195 struct tps65010_board { 196 - int base; 197 196 unsigned outmask; 198 - 199 - int (*setup)(struct i2c_client *client, void *context); 200 - int (*teardown)(struct i2c_client *client, void *context); 201 - void *context; 197 + int (*setup)(struct i2c_client *client, struct gpio_chip *gc); 198 + void (*teardown)(struct i2c_client *client, struct gpio_chip *gc); 202 199 }; 203 200 204 201 #endif /* __LINUX_I2C_TPS65010_H */
-3
include/linux/mfd/twl.h
··· 593 593 */ 594 594 u32 pullups; 595 595 u32 pulldowns; 596 - 597 - int (*setup)(struct device *dev, 598 - unsigned gpio, unsigned ngpio); 599 596 }; 600 597 601 598 struct twl4030_madc_platform_data {
-2
include/linux/platform_data/lcd-mipid.h
··· 15 15 #ifdef __KERNEL__ 16 16 17 17 struct mipid_platform_data { 18 - int nreset_gpio; 19 18 int data_lines; 20 19 21 - void (*shutdown)(struct mipid_platform_data *pdata); 22 20 void (*set_bklight_level)(struct mipid_platform_data *pdata, 23 21 int level); 24 22 int (*get_bklight_level)(struct mipid_platform_data *pdata);
-2
include/linux/platform_data/mmc-omap.h
··· 20 20 * maximum frequency on the MMC bus */ 21 21 unsigned int max_freq; 22 22 23 - /* switch the bus to a new slot */ 24 - int (*switch_slot)(struct device *dev, int slot); 25 23 /* initialize board-specific MMC functionality, can be NULL if 26 24 * not supported */ 27 25 int (*init)(struct device *dev);
-2
include/linux/spi/ads7846.h
··· 35 35 u16 debounce_tol; /* tolerance used for filtering */ 36 36 u16 debounce_rep; /* additional consecutive good readings 37 37 * required after the first two */ 38 - int gpio_pendown; /* the GPIO used to decide the pendown 39 - * state if get_pendown_state == NULL */ 40 38 int gpio_pendown_debounce; /* platform specific debounce time for 41 39 * the gpio_pendown */ 42 40 int (*get_pendown_state)(void);
-13
include/linux/usb/musb.h
··· 99 99 /* (HOST or OTG) program PHY for external Vbus */ 100 100 unsigned extvbus:1; 101 101 102 - /* Power the device on or off */ 103 - int (*set_power)(int state); 104 - 105 102 /* MUSB configuration-specific details */ 106 103 const struct musb_hdrc_config *config; 107 104 ··· 131 134 #define TUSB6010_OSCCLK_60 16667 /* psec/clk @ 60.0 MHz */ 132 135 #define TUSB6010_REFCLK_24 41667 /* psec/clk @ 24.0 MHz XI */ 133 136 #define TUSB6010_REFCLK_19 52083 /* psec/clk @ 19.2 MHz CLKIN */ 134 - 135 - #ifdef CONFIG_ARCH_OMAP2 136 - 137 - extern int __init tusb6010_setup_interface( 138 - struct musb_hdrc_platform_data *data, 139 - unsigned ps_refclk, unsigned waitpin, 140 - unsigned async_cs, unsigned sync_cs, 141 - unsigned irq, unsigned dmachan); 142 - 143 - #endif /* OMAP2 */ 144 137 145 138 #endif /* __LINUX_USB_MUSB_H */