From 4b8c9ca83c5bb67a05d138959dc4c2d8314d9e32 Mon Sep 17 00:00:00 2001 From: Mason Wang Date: Tue, 8 Nov 2022 17:38:01 +0800 Subject: touch/TBN: Double check the value of aoc2ap_gpio when timeout To verify the value of aoc2ap_gpio again when TBN operation is timeout to judge the AP requests/releases bus successfully or not. Bug: 257076750 Test: Basic touch operation and wake-up gesture are working well Signed-off-by: Mason Wang Change-Id: I5a895b9360c7abbb7b9b502862a1212ca2e7175a --- touch_bus_negotiator.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/touch_bus_negotiator.c b/touch_bus_negotiator.c index 375095a..cae8435 100644 --- a/touch_bus_negotiator.c +++ b/touch_bus_negotiator.c @@ -94,15 +94,26 @@ int tbn_handshaking(struct tbn_context *tbn, enum tbn_operation operation) reinit_completion(wait_for_completion); if (tbn->mode == TBN_MODE_GPIO) { + int ap2aoc_val_org = gpio_get_value(tbn->ap2aoc_gpio); + int aoc2ap_val_org = gpio_get_value(tbn->aoc2ap_gpio); + irq_set_irq_type(tbn->aoc2ap_irq, irq_type); enable_irq(tbn->aoc2ap_irq); gpio_direction_output(tbn->ap2aoc_gpio, bus_owner); if (wait_for_completion_timeout(wait_for_completion, - msecs_to_jiffies(timeout)) == 0) { - dev_err(tbn->dev, "AP %s bus ... timeout!, aoc2ap_gpio=%d\n", - msg, gpio_get_value(tbn->aoc2ap_gpio)); + msecs_to_jiffies(timeout)) == 0) { + int ap2aoc_val = gpio_get_value(tbn->ap2aoc_gpio); + int aoc2ap_val = gpio_get_value(tbn->aoc2ap_gpio); + complete_all(wait_for_completion); - ret = -ETIMEDOUT; + if (bus_owner == aoc2ap_val) + ret = 0; + else + ret = -ETIMEDOUT; + dev_err(tbn->dev, "AP %s bus ... timeout!, ap2aoc_gpio(B:%d,A:%d)" + " aoc2ap_gpio(B:%d,A:%d), ret=%d\n", + msg, ap2aoc_val_org, ap2aoc_val, aoc2ap_val_org, + aoc2ap_val, ret); } else dev_info(tbn->dev, "AP %s bus ... SUCCESS!\n", msg); disable_irq_nosync(tbn->aoc2ap_irq); -- cgit v1.2.3