From patchwork Fri Oct 6 13:44:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Duje_Mihanovi=C4=87?= X-Patchwork-Id: 149247 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp341882vqo; Fri, 6 Oct 2023 06:45:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFn7xMccC4W5BvFScl5Xd1Da3eGm4OdfC2orsMJtXk5AN42TanXiZ7Aycm53o3WI+4r/+Pf X-Received: by 2002:a05:6a20:1611:b0:15a:13f3:49ca with SMTP id l17-20020a056a20161100b0015a13f349camr10662124pzj.9.1696599951137; Fri, 06 Oct 2023 06:45:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696599951; cv=none; d=google.com; s=arc-20160816; b=JazvOvgmHKKPKaXimNysibhqIhUwLnvSv5ZGx5zPI1ieKYAmHn4A0ZAGaIhc1E8YbQ BvBlkNolkUxUBozLQNl5nTkPQMwtkIdyIZPkA24s0wl3lr1rOnmPBLRFINLDmgVdBnlS 6klofMQb6QKpVtGzaBWamJOLWaNh3oP/GBRnnsYvbaYjooctOEnM2Wiu+zLuwFCLvwff r5/qyYXKC+JSrvfgOY6++M9t+BpMcmJLGWJWuXRXQovyfeLc+x5jTF2z3Ml+IE3BJR54 8JDItt9bynoYf++8trBkbA7loCXDyQDo5rAfXORvqaSmxw5XCMkMmnR/l3cnyCGT5KFh 4eOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from; bh=xvvmSvXQZhWRUIeuuQIPdxLV7y8eVQPa+AATjpSobWs=; fh=1i6b6fQBnaiq0xRa3ncF4yVLO4LQ/VVJhygl9h24PAo=; b=dCO9eMT93A1iER9UVebQz73oacjtYI+jFf8qvlOcEyeJIHgPG3OE+p7yGVmt0dPLbH RhTK5KPOK2qtTccWV+p2q2pwiw6PJWenEgdaAUhw+bv8nxbvPnIFwI3nZ9x2Xyi7uwi3 eBc8qR/3AMfLSV7AxnF6FAqcVDQJF1A4chnRQZwj7bsVpwszu2GckuD1DnE3Ux6q8Ps8 Hb11MzhqTmDp6pznUM1GXoy4x8sAAuILw+kN6nGRKvdIcGXKJY1akTz0t+y+Fkm7iRr5 V6ghxVSVvJ9HSyhsyjl11l4AJoVPw1FA24TXwtr1Zgsmghiz1ePiJDP8sptnhuvDjg+S hHwg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id l13-20020a170903244d00b001c413905d87si4031059pls.49.2023.10.06.06.45.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 06:45:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id D69F88051AB4; Fri, 6 Oct 2023 06:45:47 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232532AbjJFNpf (ORCPT + 18 others); Fri, 6 Oct 2023 09:45:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232489AbjJFNpT (ORCPT ); Fri, 6 Oct 2023 09:45:19 -0400 Received: from mx.skole.hr (mx2.hosting.skole.hr [161.53.165.186]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5A24A6; Fri, 6 Oct 2023 06:45:16 -0700 (PDT) Received: from mx2.hosting.skole.hr (localhost.localdomain [127.0.0.1]) by mx.skole.hr (mx.skole.hr) with ESMTP id 5F65E83F72; Fri, 6 Oct 2023 15:45:15 +0200 (CEST) From: =?utf-8?q?Duje_Mihanovi=C4=87?= Date: Fri, 06 Oct 2023 15:44:30 +0200 Subject: [PATCH RFT v6 6/6] input: ads7846: Move wait_for_sync() logic to driver MIME-Version: 1.0 Message-Id: <20231006-pxa-gpio-v6-6-981b4910d599@skole.hr> References: <20231006-pxa-gpio-v6-0-981b4910d599@skole.hr> In-Reply-To: <20231006-pxa-gpio-v6-0-981b4910d599@skole.hr> To: Daniel Mack , Haojian Zhuang , Robert Jarzmik , Russell King , Alan Stern , Greg Kroah-Hartman , Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Dmitry Torokhov , Mark Brown Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, linux-gpio@vger.kernel.org, linux-input@vger.kernel.org, linux-spi@vger.kernel.org, =?utf-8?q?Duje_Miha?= =?utf-8?q?novi=C4=87?= , Bartosz Golaszewski X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=4335; i=duje.mihanovic@skole.hr; h=from:subject:message-id; bh=WwErEB93WBzHtWVtjMPvyswbjztvxyH9/d5QcCsmPgU=; b=owEBbQKS/ZANAwAIAZoRnrBCLZbhAcsmYgBlIA9dQzEhg6l+OrzvF2JShhkoAwCrJEaY0qPfq gZNy0RyIi+JAjMEAAEIAB0WIQRT351NnD/hEPs2LXiaEZ6wQi2W4QUCZSAPXQAKCRCaEZ6wQi2W 4aVDEACQfgzF2JA5g5+/dfFTyPeP0PogzvS5djifnaCN3JXzeeIoGz1pU4mb/GKYWVi9mMKLTlr VPt6O8txKZnXT5QEoEj+U6TWF/LHHxio+PAsAxcbBMSEnS+dRQ61Dl/lbr2+9aAxgoWY7Bld509 EKvs6Ekyw1paOlFd6m3MyghWmJUfOq7Juy4eGZJZo9vsT4kyJt9fh1uI19Fh8nlI29xzWKNu9Iy Sv2iQ9rbSli9QmJ0P59ZXElNrYXFbug4xAcR0AVKYGS2ChY1RTB2eVHE8vHjEaRos5Qzh6i3QQN +xpPKrpZgyDeIxr53qcb3NEweUl14AYck44Zcy6XfW3Kc71VGw5Y/RMvfziRHApAwuwPXVxtKul LZY1KOwZQjcNGx3Y9TIk+qRUQP7XvKonUnIALLmTvCas7Ra7vQt64Y1pBQxVzcxNy7sIoLFI8Op CltdNofYhKksbhGIOd/Fgu/NlfnIxVk0A4OY1lhCxDXGXDtiroHylTSZmi2uK+g/l3SDhxInrqB ky6o/tVci3yGmuEEd7EnwgAdanlUCxy4S2fOm+QLhWKSvGcsLrxb5A119ZL5BpzzPtAhRz5ARDk CTxQIrdQr2UseEUle2BO9EodzcpMHUooUV6tFeH0LyHjjTRXZIAbM1puEtO13WR5G8ohuudp8Xc oPO56adG7O8KNvQ== X-Developer-Key: i=duje.mihanovic@skole.hr; a=openpgp; fpr=53DF9D4D9C3FE110FB362D789A119EB0422D96E1 X-Spam-Status: No, score=2.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Fri, 06 Oct 2023 06:45:47 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779013990091189191 X-GMAIL-MSGID: 1779013990091189191 If this code is left in the board file, the sync GPIO would have to be separated into another lookup table during conversion to the GPIO descriptor API (which is also done in this patch). The only user of this code (Sharp Spitz) is also converted in this patch. Suggested-by: Linus Walleij Reviewed-by: Linus Walleij Acked-by: Mark Brown Reviewed-by: Bartosz Golaszewski Signed-off-by: Duje Mihanović --- arch/arm/mach-pxa/spitz.c | 12 ++---------- drivers/input/touchscreen/ads7846.c | 22 +++++++++++++++------- include/linux/spi/ads7846.h | 1 - 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/arch/arm/mach-pxa/spitz.c b/arch/arm/mach-pxa/spitz.c index 554a4b9782c5..1df72d4d6a35 100644 --- a/arch/arm/mach-pxa/spitz.c +++ b/arch/arm/mach-pxa/spitz.c @@ -522,22 +522,12 @@ static inline void spitz_leds_init(void) {} * SSP Devices ******************************************************************************/ #if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE) -static void spitz_ads7846_wait_for_hsync(void) -{ - while (gpio_get_value(SPITZ_GPIO_HSYNC)) - cpu_relax(); - - while (!gpio_get_value(SPITZ_GPIO_HSYNC)) - cpu_relax(); -} - static struct ads7846_platform_data spitz_ads7846_info = { .model = 7846, .vref_delay_usecs = 100, .x_plate_ohms = 419, .y_plate_ohms = 486, .pressure_max = 1024, - .wait_for_sync = spitz_ads7846_wait_for_hsync, }; static struct gpiod_lookup_table spitz_ads7846_gpio_table = { @@ -545,6 +535,8 @@ static struct gpiod_lookup_table spitz_ads7846_gpio_table = { .table = { GPIO_LOOKUP("gpio-pxa", SPITZ_GPIO_TP_INT, "pendown", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("gpio-pxa", SPITZ_GPIO_HSYNC, + "sync", GPIO_ACTIVE_LOW), { } }, }; diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c index faea40dd66d0..139b0f3735d0 100644 --- a/drivers/input/touchscreen/ads7846.c +++ b/drivers/input/touchscreen/ads7846.c @@ -138,8 +138,7 @@ struct ads7846 { void *filter_data; int (*get_pendown_state)(void); struct gpio_desc *gpio_pendown; - - void (*wait_for_sync)(void); + struct gpio_desc *sync; }; enum ads7846_filter { @@ -636,9 +635,15 @@ static const struct attribute_group ads784x_attr_group = { }; /*--------------------------------------------------------------------------*/ - -static void null_wait_for_sync(void) +static void ads7846_wait_for_sync_gpio(struct ads7846 *ts) { + if (!ts->sync) + return; + while (!gpiod_get_value(ts->sync)) + cpu_relax(); + + while (gpiod_get_value(ts->sync)) + cpu_relax(); } static int ads7846_debounce_filter(void *ads, int data_idx, int *val) @@ -803,7 +808,7 @@ static void ads7846_read_state(struct ads7846 *ts) packet->last_cmd_idx = 0; while (true) { - ts->wait_for_sync(); + ads7846_wait_for_sync_gpio(ts); m = &ts->msg[msg_idx]; error = spi_sync(ts->spi, m); @@ -1261,8 +1266,6 @@ static int ads7846_probe(struct spi_device *spi) ts->penirq_recheck_delay_usecs = pdata->penirq_recheck_delay_usecs; - ts->wait_for_sync = pdata->wait_for_sync ? : null_wait_for_sync; - snprintf(ts->phys, sizeof(ts->phys), "%s/input0", dev_name(dev)); snprintf(ts->name, sizeof(ts->name), "ADS%d Touchscreen", ts->model); @@ -1361,6 +1364,11 @@ static int ads7846_probe(struct spi_device *spi) if (err) return err; + ts->sync = devm_gpiod_get_optional(dev, "sync", GPIOD_IN); + if (IS_ERR(ts->sync)) + return dev_err_probe(dev, PTR_ERR(ts->sync), + "Failed to get sync GPIO"); + err = input_register_device(input_dev); if (err) return err; diff --git a/include/linux/spi/ads7846.h b/include/linux/spi/ads7846.h index a04c1c34c344..fa7c4f119023 100644 --- a/include/linux/spi/ads7846.h +++ b/include/linux/spi/ads7846.h @@ -38,7 +38,6 @@ struct ads7846_platform_data { int gpio_pendown_debounce; /* platform specific debounce time for * the gpio_pendown */ int (*get_pendown_state)(void); - void (*wait_for_sync)(void); bool wakeup; unsigned long irq_flags; };