| .. | .. |
|---|
| 33 | 33 | bool gt1x_gt5688; |
|---|
| 34 | 34 | int gt1x_rst_gpio; |
|---|
| 35 | 35 | int gt1x_int_gpio; |
|---|
| 36 | +static bool power_invert; |
|---|
| 36 | 37 | #endif |
|---|
| 37 | 38 | |
|---|
| 38 | 39 | static int gt1x_register_powermanger(void); |
|---|
| .. | .. |
|---|
| 323 | 324 | gt1x_int_gpio = of_get_named_gpio(np, "goodix,irq-gpio", 0); |
|---|
| 324 | 325 | gt1x_rst_gpio = of_get_named_gpio(np, "goodix,rst-gpio", 0); |
|---|
| 325 | 326 | |
|---|
| 326 | | - if (!gpio_is_valid(gt1x_int_gpio) || !gpio_is_valid(gt1x_rst_gpio)) { |
|---|
| 327 | + if (!gpio_is_valid(gt1x_int_gpio) && !gpio_is_valid(gt1x_rst_gpio)) { |
|---|
| 327 | 328 | GTP_ERROR("Invalid GPIO, irq-gpio:%d, rst-gpio:%d", |
|---|
| 328 | 329 | gt1x_int_gpio, gt1x_rst_gpio); |
|---|
| 330 | + return -EINVAL; |
|---|
| 331 | + } |
|---|
| 332 | + |
|---|
| 333 | + if (!gpio_is_valid(gt1x_int_gpio)) { |
|---|
| 334 | + GTP_ERROR("Invalid GPIO, irq-gpio:%d", |
|---|
| 335 | + gt1x_int_gpio); |
|---|
| 329 | 336 | return -EINVAL; |
|---|
| 330 | 337 | } |
|---|
| 331 | 338 | |
|---|
| .. | .. |
|---|
| 336 | 343 | if (PTR_ERR(vdd_ana) == -ENODEV) { |
|---|
| 337 | 344 | GTP_ERROR("power not specified, ignore power ctrl"); |
|---|
| 338 | 345 | vdd_ana = NULL; |
|---|
| 346 | + } else { |
|---|
| 347 | + power_invert = of_property_read_bool(np, "power-invert"); |
|---|
| 348 | + GTP_INFO("Power Invert,%s ", power_invert ? "yes" : "no"); |
|---|
| 339 | 349 | } |
|---|
| 340 | 350 | } |
|---|
| 341 | 351 | if (IS_ERR(vdd_ana)) { |
|---|
| .. | .. |
|---|
| 364 | 374 | */ |
|---|
| 365 | 375 | int gt1x_power_switch(int on) |
|---|
| 366 | 376 | { |
|---|
| 367 | | - int ret; |
|---|
| 377 | + int ret = 0; |
|---|
| 368 | 378 | struct i2c_client *client = gt1x_i2c_client; |
|---|
| 369 | 379 | |
|---|
| 370 | 380 | if (!client || !vdd_ana) |
|---|
| .. | .. |
|---|
| 372 | 382 | |
|---|
| 373 | 383 | if (on) { |
|---|
| 374 | 384 | GTP_DEBUG("GTP power on."); |
|---|
| 375 | | - ret = regulator_enable(vdd_ana); |
|---|
| 385 | + if (power_invert) { |
|---|
| 386 | + if (regulator_is_enabled(vdd_ana) > 0) |
|---|
| 387 | + ret = regulator_disable(vdd_ana); |
|---|
| 388 | + } else { |
|---|
| 389 | + ret = regulator_enable(vdd_ana); |
|---|
| 390 | + } |
|---|
| 376 | 391 | } else { |
|---|
| 377 | 392 | GTP_DEBUG("GTP power off."); |
|---|
| 378 | | - ret = regulator_disable(vdd_ana); |
|---|
| 393 | + if (power_invert) { |
|---|
| 394 | + if (!regulator_is_enabled(vdd_ana)) |
|---|
| 395 | + ret = regulator_enable(vdd_ana); |
|---|
| 396 | + } else { |
|---|
| 397 | + ret = regulator_disable(vdd_ana); |
|---|
| 398 | + } |
|---|
| 379 | 399 | } |
|---|
| 380 | 400 | return ret; |
|---|
| 381 | 401 | } |
|---|
| .. | .. |
|---|
| 411 | 431 | GTP_GPIO_AS_INT(GTP_INT_PORT); |
|---|
| 412 | 432 | gt1x_i2c_client->irq = GTP_INT_IRQ; |
|---|
| 413 | 433 | |
|---|
| 414 | | - ret = gpio_request(GTP_RST_PORT, "GTP_RST_PORT"); |
|---|
| 415 | | - if (ret < 0) { |
|---|
| 416 | | - GTP_ERROR("Failed to request GPIO:%d, ERRNO:%d", (s32) GTP_RST_PORT, ret); |
|---|
| 417 | | - gpio_free(GTP_INT_PORT); |
|---|
| 418 | | - return ret; |
|---|
| 419 | | - } |
|---|
| 434 | + if (gpio_is_valid(gt1x_rst_gpio)) { |
|---|
| 435 | + ret = gpio_request(GTP_RST_PORT, "GTP_RST_PORT"); |
|---|
| 436 | + if (ret < 0) { |
|---|
| 437 | + GTP_ERROR("Failed to request GPIO:%d, ERRNO:%d", (s32) GTP_RST_PORT, ret); |
|---|
| 438 | + gpio_free(GTP_INT_PORT); |
|---|
| 439 | + return ret; |
|---|
| 440 | + } |
|---|
| 420 | 441 | |
|---|
| 421 | 442 | GTP_GPIO_AS_INPUT(GTP_RST_PORT); |
|---|
| 443 | + } |
|---|
| 444 | + |
|---|
| 422 | 445 | return 0; |
|---|
| 423 | 446 | } |
|---|
| 424 | 447 | |
|---|
| .. | .. |
|---|
| 633 | 656 | } |
|---|
| 634 | 657 | |
|---|
| 635 | 658 | #if defined(CONFIG_FB) |
|---|
| 659 | +#include <linux/async.h> |
|---|
| 660 | + |
|---|
| 661 | +static void gt1x_resume_async(void *data, async_cookie_t cookie) |
|---|
| 662 | +{ |
|---|
| 663 | + gt1x_resume(); |
|---|
| 664 | +} |
|---|
| 665 | + |
|---|
| 666 | +static void gt1x_suspend_async(void *data, async_cookie_t cookie) |
|---|
| 667 | +{ |
|---|
| 668 | + gt1x_suspend(); |
|---|
| 669 | +} |
|---|
| 670 | + |
|---|
| 636 | 671 | /* frame buffer notifier block control the suspend/resume procedure */ |
|---|
| 637 | 672 | static struct notifier_block gt1x_fb_notifier; |
|---|
| 638 | 673 | static int tp_status; |
|---|
| .. | .. |
|---|
| 663 | 698 | if (*blank == FB_BLANK_UNBLANK) { |
|---|
| 664 | 699 | tp_status = *blank; |
|---|
| 665 | 700 | GTP_DEBUG("Resume by fb notifier."); |
|---|
| 666 | | - gt1x_resume(); |
|---|
| 701 | + async_schedule(gt1x_resume_async, NULL); |
|---|
| 667 | 702 | } |
|---|
| 668 | 703 | } |
|---|
| 669 | 704 | #endif |
|---|
| .. | .. |
|---|
| 674 | 709 | if (*blank == FB_BLANK_POWERDOWN) { |
|---|
| 675 | 710 | tp_status = *blank; |
|---|
| 676 | 711 | GTP_DEBUG("Suspend by fb notifier."); |
|---|
| 677 | | - gt1x_suspend(); |
|---|
| 712 | + async_schedule(gt1x_suspend_async, NULL); |
|---|
| 678 | 713 | } |
|---|
| 679 | 714 | } |
|---|
| 680 | 715 | |
|---|
| .. | .. |
|---|
| 807 | 842 | |
|---|
| 808 | 843 | MODULE_DESCRIPTION("GTP Series Driver"); |
|---|
| 809 | 844 | MODULE_LICENSE("GPL"); |
|---|
| 845 | +MODULE_IMPORT_NS(VFS_internal_I_am_really_a_filesystem_and_am_NOT_a_driver); |
|---|