hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/input/touchscreen/gt1x/gt1x.c
....@@ -33,6 +33,7 @@
3333 bool gt1x_gt5688;
3434 int gt1x_rst_gpio;
3535 int gt1x_int_gpio;
36
+static bool power_invert;
3637 #endif
3738
3839 static int gt1x_register_powermanger(void);
....@@ -323,9 +324,15 @@
323324 gt1x_int_gpio = of_get_named_gpio(np, "goodix,irq-gpio", 0);
324325 gt1x_rst_gpio = of_get_named_gpio(np, "goodix,rst-gpio", 0);
325326
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)) {
327328 GTP_ERROR("Invalid GPIO, irq-gpio:%d, rst-gpio:%d",
328329 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);
329336 return -EINVAL;
330337 }
331338
....@@ -336,6 +343,9 @@
336343 if (PTR_ERR(vdd_ana) == -ENODEV) {
337344 GTP_ERROR("power not specified, ignore power ctrl");
338345 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");
339349 }
340350 }
341351 if (IS_ERR(vdd_ana)) {
....@@ -364,7 +374,7 @@
364374 */
365375 int gt1x_power_switch(int on)
366376 {
367
- int ret;
377
+ int ret = 0;
368378 struct i2c_client *client = gt1x_i2c_client;
369379
370380 if (!client || !vdd_ana)
....@@ -372,10 +382,20 @@
372382
373383 if (on) {
374384 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
+ }
376391 } else {
377392 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
+ }
379399 }
380400 return ret;
381401 }
....@@ -411,14 +431,17 @@
411431 GTP_GPIO_AS_INT(GTP_INT_PORT);
412432 gt1x_i2c_client->irq = GTP_INT_IRQ;
413433
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
+ }
420441
421442 GTP_GPIO_AS_INPUT(GTP_RST_PORT);
443
+ }
444
+
422445 return 0;
423446 }
424447
....@@ -633,6 +656,18 @@
633656 }
634657
635658 #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
+
636671 /* frame buffer notifier block control the suspend/resume procedure */
637672 static struct notifier_block gt1x_fb_notifier;
638673 static int tp_status;
....@@ -663,7 +698,7 @@
663698 if (*blank == FB_BLANK_UNBLANK) {
664699 tp_status = *blank;
665700 GTP_DEBUG("Resume by fb notifier.");
666
- gt1x_resume();
701
+ async_schedule(gt1x_resume_async, NULL);
667702 }
668703 }
669704 #endif
....@@ -674,7 +709,7 @@
674709 if (*blank == FB_BLANK_POWERDOWN) {
675710 tp_status = *blank;
676711 GTP_DEBUG("Suspend by fb notifier.");
677
- gt1x_suspend();
712
+ async_schedule(gt1x_suspend_async, NULL);
678713 }
679714 }
680715
....@@ -807,3 +842,4 @@
807842
808843 MODULE_DESCRIPTION("GTP Series Driver");
809844 MODULE_LICENSE("GPL");
845
+MODULE_IMPORT_NS(VFS_internal_I_am_really_a_filesystem_and_am_NOT_a_driver);