From patchwork Mon Oct 9 18:34:03 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: 13414285 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 67F3A3B7AF for ; Mon, 9 Oct 2023 18:34:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=none Received: from mx.skole.hr (mx1.hosting.skole.hr [161.53.165.185]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE263A4; Mon, 9 Oct 2023 11:34:21 -0700 (PDT) Received: from mx1.hosting.skole.hr (localhost.localdomain [127.0.0.1]) by mx.skole.hr (mx.skole.hr) with ESMTP id 6460084F8D; Mon, 9 Oct 2023 20:34:20 +0200 (CEST) From: =?utf-8?q?Duje_Mihanovi=C4=87?= Date: Mon, 09 Oct 2023 20:34:03 +0200 Subject: [PATCH RFT v7 6/6] input: ads7846: Move wait_for_sync() logic to driver Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231009-pxa-gpio-v7-6-c8f5f403e856@skole.hr> References: <20231009-pxa-gpio-v7-0-c8f5f403e856@skole.hr> In-Reply-To: <20231009-pxa-gpio-v7-0-c8f5f403e856@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_Mih?= =?utf-8?q?anovi=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=NcbDmKIXdGdWL8XSS8YJEjNbViubL11WglEHV7KUeoM=; b=owEBbQKS/ZANAwAIAZoRnrBCLZbhAcsmYgBlJEebyeOXePkL+aYreAXfS84hKPxe/toDWYaiA EkA/bPFQkGJAjMEAAEIAB0WIQRT351NnD/hEPs2LXiaEZ6wQi2W4QUCZSRHmwAKCRCaEZ6wQi2W 4VQgEACDVvtipcfd9IumqldOY0O+UDknBZPOMqclvchmm27kuH/w4yf9VcBBfFYIUsYdjTt9Z+J PxGgKjf1AIwJEwqnXeWkh+v5S0IBhZ9cZ7PeG4uavj/bCuSbo0y51EC32bfvj/x+mVlCmBgCP1R W0MmCbgfdevP5nlGK+vfwxchz0abE0ga171R16RmRTPac8XxdV/1LzdwSRzGq76Iw+oCDd2hQFn LtwnUbu4MvRcR/lSlBZiV9OCDx+Dcp+qF1DeWAq5YQn4kHkZ8xHu2I2OItOyvdQ5xPD0r+mc2rA Nm7SxpCstNy4N/tszrA9yrOnK9T2/ma451e1TZZOtsOarQNJil757769VzQTPhbBSQ6HyziO0wW 4Us80MDfg/aB8jib/KsLtHlcceLSaVxr51/XcZyswHmOXpDuHXzS0Z2lr1YQlzgxpxgEa37k0ej JWnIbA6hyVX1qfbC1WpKVt5XrJI31RlR2Mhlw3Q2VqPHFrNOvAeOrOPDZWu4ZCURvJxJi6BI2hV L1pKN99cD6OrGE9npk85vEa9rPvXRoGxqgYgke2iGSLOyJAWKRWA6dDz8MP1NS5IbzXiLu4rftS rkh2ye+OKNAdVw4ojBGrVoxTOBrzWWzo9o56veT7ZhaXrCx7NClPeFowOSAkuobOOL6gT9MwDNj xTtTUuxbQ0P0CrQ== X-Developer-Key: i=duje.mihanovic@skole.hr; a=openpgp; fpr=53DF9D4D9C3FE110FB362D789A119EB0422D96E1 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 4b6360821396..44336a498699 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; };