[ARM] pxa/palmtx: misc fixes to use generic GPIO API

Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
Signed-off-by: Eric Miao <eric.miao@marvell.com>

authored by Marek Vasut and committed by Eric Miao a730b327 2fd36a5d

+118 -32
+118 -32
arch/arm/mach-pxa/palmtx.c
··· 56 56 GPIO110_MMC_DAT_2, 57 57 GPIO111_MMC_DAT_3, 58 58 GPIO112_MMC_CMD, 59 + GPIO14_GPIO, /* SD detect */ 60 + GPIO114_GPIO, /* SD power */ 61 + GPIO115_GPIO, /* SD r/o switch */ 59 62 60 63 /* AC97 */ 61 64 GPIO28_AC97_BITCLK, ··· 67 64 GPIO31_AC97_SYNC, 68 65 69 66 /* IrDA */ 67 + GPIO40_GPIO, /* ir disable */ 70 68 GPIO46_FICP_RXD, 71 69 GPIO47_FICP_TXD, 72 70 ··· 75 71 GPIO16_PWM0_OUT, 76 72 77 73 /* USB */ 78 - GPIO13_GPIO, 74 + GPIO13_GPIO, /* usb detect */ 75 + GPIO95_GPIO, /* usb power */ 79 76 80 77 /* PCMCIA */ 81 78 GPIO48_nPOE, ··· 89 84 GPIO55_nPREG, 90 85 GPIO56_nPWAIT, 91 86 GPIO57_nIOIS16, 87 + GPIO94_GPIO, /* wifi power 1 */ 88 + GPIO108_GPIO, /* wifi power 2 */ 89 + GPIO116_GPIO, /* wifi ready */ 90 + 91 + /* MATRIX KEYPAD */ 92 + GPIO100_KP_MKIN_0, 93 + GPIO101_KP_MKIN_1, 94 + GPIO102_KP_MKIN_2, 95 + GPIO97_KP_MKIN_3, 96 + GPIO103_KP_MKOUT_0, 97 + GPIO104_KP_MKOUT_1, 98 + GPIO105_KP_MKOUT_2, 99 + 100 + /* LCD */ 101 + GPIO58_LCD_LDD_0, 102 + GPIO59_LCD_LDD_1, 103 + GPIO60_LCD_LDD_2, 104 + GPIO61_LCD_LDD_3, 105 + GPIO62_LCD_LDD_4, 106 + GPIO63_LCD_LDD_5, 107 + GPIO64_LCD_LDD_6, 108 + GPIO65_LCD_LDD_7, 109 + GPIO66_LCD_LDD_8, 110 + GPIO67_LCD_LDD_9, 111 + GPIO68_LCD_LDD_10, 112 + GPIO69_LCD_LDD_11, 113 + GPIO70_LCD_LDD_12, 114 + GPIO71_LCD_LDD_13, 115 + GPIO72_LCD_LDD_14, 116 + GPIO73_LCD_LDD_15, 117 + GPIO74_LCD_FCLK, 118 + GPIO75_LCD_LCLK, 119 + GPIO76_LCD_PCLK, 120 + GPIO77_LCD_BIAS, 121 + 122 + /* MISC. */ 123 + GPIO10_GPIO, /* hotsync button */ 124 + GPIO12_GPIO, /* power detect */ 125 + GPIO107_GPIO, /* earphone detect */ 92 126 }; 93 127 94 128 /****************************************************************************** ··· 139 95 int err = 0; 140 96 141 97 /* Setup an interrupt for detecting card insert/remove events */ 142 - err = request_irq(IRQ_GPIO_PALMTX_SD_DETECT_N, palmtx_detect_int, 143 - IRQF_DISABLED | IRQF_SAMPLE_RANDOM | 98 + err = gpio_request(GPIO_NR_PALMTX_SD_DETECT_N, "SD IRQ"); 99 + if (err) 100 + goto err; 101 + err = gpio_direction_input(GPIO_NR_PALMTX_SD_DETECT_N); 102 + if (err) 103 + goto err2; 104 + err = request_irq(gpio_to_irq(GPIO_NR_PALMTX_SD_DETECT_N), 105 + palmtx_detect_int, IRQF_DISABLED | IRQF_SAMPLE_RANDOM | 144 106 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING, 145 107 "SD/MMC card detect", data); 146 108 if (err) { 147 109 printk(KERN_ERR "%s: cannot request SD/MMC card detect IRQ\n", 148 110 __func__); 149 - return err; 111 + goto err2; 150 112 } 151 113 152 114 err = gpio_request(GPIO_NR_PALMTX_SD_POWER, "SD_POWER"); 153 115 if (err) 154 - goto pwr_err; 116 + goto err3; 117 + err = gpio_direction_output(GPIO_NR_PALMTX_SD_POWER, 0); 118 + if (err) 119 + goto err4; 155 120 156 121 err = gpio_request(GPIO_NR_PALMTX_SD_READONLY, "SD_READONLY"); 157 122 if (err) 158 - goto ro_err; 123 + goto err4; 124 + err = gpio_direction_input(GPIO_NR_PALMTX_SD_READONLY); 125 + if (err) 126 + goto err5; 159 127 160 128 printk(KERN_DEBUG "%s: irq registered\n", __func__); 161 129 162 130 return 0; 163 131 164 - ro_err: 132 + err5: 133 + gpio_free(GPIO_NR_PALMTX_SD_READONLY); 134 + err4: 165 135 gpio_free(GPIO_NR_PALMTX_SD_POWER); 166 - pwr_err: 167 - free_irq(IRQ_GPIO_PALMTX_SD_DETECT_N, data); 136 + err3: 137 + free_irq(gpio_to_irq(GPIO_NR_PALMTX_SD_DETECT_N), data); 138 + err2: 139 + gpio_free(GPIO_NR_PALMTX_SD_DETECT_N); 140 + err: 168 141 return err; 169 142 } 170 143 ··· 189 128 { 190 129 gpio_free(GPIO_NR_PALMTX_SD_READONLY); 191 130 gpio_free(GPIO_NR_PALMTX_SD_POWER); 192 - free_irq(IRQ_GPIO_PALMTX_SD_DETECT_N, data); 131 + free_irq(gpio_to_irq(GPIO_NR_PALMTX_SD_DETECT_N), data); 132 + gpio_free(GPIO_NR_PALMTX_SD_DETECT_N); 193 133 } 194 134 195 135 static void palmtx_mci_power(struct device *dev, unsigned int vdd) ··· 229 167 230 168 KEY(3, 0, KEY_RIGHT), 231 169 KEY(3, 2, KEY_LEFT), 232 - 233 170 }; 234 171 235 172 static struct pxa27x_keypad_platform_data palmtx_keypad_platform_data = { ··· 270 209 ret = gpio_request(GPIO_NR_PALMTX_BL_POWER, "BL POWER"); 271 210 if (ret) 272 211 goto err; 212 + ret = gpio_direction_output(GPIO_NR_PALMTX_BL_POWER, 0); 213 + if (ret) 214 + goto err2; 273 215 ret = gpio_request(GPIO_NR_PALMTX_LCD_POWER, "LCD POWER"); 274 216 if (ret) 275 217 goto err2; 218 + ret = gpio_direction_output(GPIO_NR_PALMTX_LCD_POWER, 0); 219 + if (ret) 220 + goto err3; 276 221 277 222 return 0; 223 + err3: 224 + gpio_free(GPIO_NR_PALMTX_LCD_POWER); 278 225 err2: 279 226 gpio_free(GPIO_NR_PALMTX_BL_POWER); 280 227 err: ··· 323 254 /****************************************************************************** 324 255 * IrDA 325 256 ******************************************************************************/ 257 + static int palmtx_irda_startup(struct device *dev) 258 + { 259 + int err; 260 + err = gpio_request(GPIO_NR_PALMTX_IR_DISABLE, "IR DISABLE"); 261 + if (err) 262 + goto err; 263 + err = gpio_direction_output(GPIO_NR_PALMTX_IR_DISABLE, 1); 264 + if (err) 265 + gpio_free(GPIO_NR_PALMTX_IR_DISABLE); 266 + err: 267 + return err; 268 + } 269 + 270 + static void palmtx_irda_shutdown(struct device *dev) 271 + { 272 + gpio_free(GPIO_NR_PALMTX_IR_DISABLE); 273 + } 274 + 326 275 static void palmtx_irda_transceiver_mode(struct device *dev, int mode) 327 276 { 328 277 gpio_set_value(GPIO_NR_PALMTX_IR_DISABLE, mode & IR_OFF); ··· 348 261 } 349 262 350 263 static struct pxaficp_platform_data palmtx_ficp_platform_data = { 264 + .startup = palmtx_irda_startup, 265 + .shutdown = palmtx_irda_shutdown, 351 266 .transceiver_cap = IR_SIRMODE | IR_FIRMODE | IR_OFF, 352 267 .transceiver_mode = palmtx_irda_transceiver_mode, 353 268 }; ··· 357 268 /****************************************************************************** 358 269 * UDC 359 270 ******************************************************************************/ 360 - static void palmtx_udc_command(int cmd) 361 - { 362 - gpio_set_value(GPIO_NR_PALMTX_USB_POWER, !cmd); 363 - udelay(50); 364 - gpio_set_value(GPIO_NR_PALMTX_USB_PULLUP, !cmd); 365 - } 366 - 367 271 static struct pxa2xx_udc_mach_info palmtx_udc_info __initdata = { 368 272 .gpio_vbus = GPIO_NR_PALMTX_USB_DETECT_N, 369 273 .gpio_vbus_inverted = 1, 370 - .udc_command = palmtx_udc_command, 274 + .gpio_pullup = GPIO_NR_PALMTX_USB_POWER, 275 + .gpio_pullup_inverted = 0, 371 276 }; 372 277 373 278 /****************************************************************************** ··· 373 290 374 291 ret = gpio_request(GPIO_NR_PALMTX_POWER_DETECT, "CABLE_STATE_AC"); 375 292 if (ret) 376 - goto err_cs_ac; 377 - 378 - ret = gpio_request(GPIO_NR_PALMTX_USB_DETECT_N, "CABLE_STATE_USB"); 293 + goto err1; 294 + ret = gpio_direction_input(GPIO_NR_PALMTX_POWER_DETECT); 379 295 if (ret) 380 - goto err_cs_usb; 296 + goto err2; 381 297 382 298 return 0; 383 299 384 - err_cs_usb: 300 + err2: 385 301 gpio_free(GPIO_NR_PALMTX_POWER_DETECT); 386 - err_cs_ac: 302 + err1: 387 303 return ret; 388 304 } 389 305 ··· 391 309 return gpio_get_value(GPIO_NR_PALMTX_POWER_DETECT); 392 310 } 393 311 394 - static int palmtx_is_usb_online(void) 395 - { 396 - return !gpio_get_value(GPIO_NR_PALMTX_USB_DETECT_N); 397 - } 398 - 399 312 static void power_supply_exit(struct device *dev) 400 313 { 401 - gpio_free(GPIO_NR_PALMTX_USB_DETECT_N); 402 314 gpio_free(GPIO_NR_PALMTX_POWER_DETECT); 403 315 } 404 316 ··· 403 327 static struct pda_power_pdata power_supply_info = { 404 328 .init = power_supply_init, 405 329 .is_ac_online = palmtx_is_ac_online, 406 - .is_usb_online = palmtx_is_usb_online, 407 330 .exit = power_supply_exit, 408 331 .supplied_to = palmtx_supplicants, 409 332 .num_supplicants = ARRAY_SIZE(palmtx_supplicants), ··· 485 410 iotable_init(palmtx_io_desc, ARRAY_SIZE(palmtx_io_desc)); 486 411 } 487 412 413 + /* setup udc GPIOs initial state */ 414 + static void __init palmtx_udc_init(void) 415 + { 416 + if (!gpio_request(GPIO_NR_PALMTX_USB_POWER, "UDC Vbus")) { 417 + gpio_direction_output(GPIO_NR_PALMTX_USB_POWER, 1); 418 + gpio_free(GPIO_NR_PALMTX_USB_POWER); 419 + } 420 + } 421 + 422 + 488 423 static void __init palmtx_init(void) 489 424 { 490 425 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmtx_pin_config)); 491 426 492 427 set_pxa_fb_info(&palmtx_lcd_screen); 493 428 pxa_set_mci_info(&palmtx_mci_platform_data); 429 + palmtx_udc_init(); 494 430 pxa_set_udc_info(&palmtx_udc_info); 495 431 pxa_set_ac97_info(NULL); 496 432 pxa_set_ficp_info(&palmtx_ficp_platform_data);