From patchwork Wed Jun 29 22:29:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Morgan X-Patchwork-Id: 12900716 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 848B9CCA481 for ; Wed, 29 Jun 2022 22:29:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229864AbiF2W3t (ORCPT ); Wed, 29 Jun 2022 18:29:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229632AbiF2W3s (ORCPT ); Wed, 29 Jun 2022 18:29:48 -0400 Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5AA9211445; Wed, 29 Jun 2022 15:29:48 -0700 (PDT) Received: by mail-io1-xd2e.google.com with SMTP id d3so926020ioi.9; Wed, 29 Jun 2022 15:29:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wX0odF7wthixWZk8JyeUhLRGFHhQJVbnFoKyCcuBnOA=; b=RbGa9a5kRYa8NliKqHBm8bd8VaBfAQe38vjltzGe4dF3ufbZPRpEHiy1VhAcKeueRt K+B5n1gh7zLr842aKeS+RtMv6Hhok0pX+9JKTqaotMWlSFUgbBRJ/YOiBa1KqYIaqiO8 lXCeDavRo/CZzDzlHEcWGVODM+V1Zha1e00ivzIZ4Qs4hjTRAaEibBi2mmWjtWaOWbFA PCsVg6iQSSXPcy1hP9BPgQAZaDCMrA5qKUG7HAUHUSiU46yWSFLKq3UsKbPwnYJSeSJp cxE1xGIVIxpNftqa8uoRWxeMNUWzIby1RjvWBzZz/9ZQJmt4kqcSLCgEv4urT6ujOPy8 mEDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wX0odF7wthixWZk8JyeUhLRGFHhQJVbnFoKyCcuBnOA=; b=HaVnHGZphpK0M37zIYaXZ+Kgh3l9WzQ0gLgdPr3geVlyvk+mlGNzFjijqH0jYaVNhB +k8BiMpFq7OijZXKCiv0U+GT1S5rFcHcYQkHfB7oOoWW620nUs8AT7TVxcqd0vO4TFEW xVIHrXBAL6El1EFqvQZFBWbWAbAd9Xm9AYWokjNY0hc5mEm7K0FCTVWwpQrYVKpR3JED Cp527/9HaE2X1fmywsNgHAkOunRvnnfRTQ2GiB+H3XrsLlLjQsaqZ+WdDnmCopBnoWJa MriN7dcJNwgZYU3cNzyRWnU9VxgzHddyR+BMr9B5cR4zJByOT2o+pYkMjy8gyQDBWLMB GTNw== X-Gm-Message-State: AJIora/wG2YlmVG/8ddxP21DkAHUFMwCCIaiKEYq2Xvp3ZmciOQm4SRa Xlov6BSMfGQuXNu6laVVwtUmQpqGMPo= X-Google-Smtp-Source: AGRyM1tgIDgtzB7HsYoFjw1ihODd9IB82ev6OqJ465C0TcFx1ulqBMy6ZF4yFHBe+aUDMfVkFxpvcQ== X-Received: by 2002:a5d:8053:0:b0:675:56b8:8355 with SMTP id b19-20020a5d8053000000b0067556b88355mr2696032ior.83.1656541787428; Wed, 29 Jun 2022 15:29:47 -0700 (PDT) Received: from Dixie.. ([2604:2d80:a188:fd00:2d4b:b7b2:944:3519]) by smtp.gmail.com with ESMTPSA id ca19-20020a0566381c1300b0033158c4a312sm7845597jab.55.2022.06.29.15.29.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jun 2022 15:29:47 -0700 (PDT) From: Chris Morgan To: linux-input@vger.kernel.org Cc: devicetree@vger.kernel.org, contact@artur-rojek.eu, maccraft123mc@gmail.com, heiko@sntech.de, krzysztof.kozlowski+dt@linaro.org, robh+dt@kernel.org, dmitry.torokhov@gmail.com, paul@crapouillou.net, jic23@kernel.org, linux-iio@vger.kernel.org, Chris Morgan , Chris Morgan Subject: [PATCH v6 1/3] dt-bindings: adc-joystick: add poll-interval-ms Date: Wed, 29 Jun 2022 17:29:28 -0500 Message-Id: <20220629222931.30599-2-macroalpha82@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220629222931.30599-1-macroalpha82@gmail.com> References: <20220629222931.30599-1-macroalpha82@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org New devicetree attribute of "poll-interval-ms". Add poll-interval support for the adc-joystick documentation. This is an optional value and if not provided the adc-joystick works as it does today (with triggered buffers). If this value is provided, the adc-joystick driver is polled at the specified interval. A new attribute was added instead of using the existing attribute of "poll-interval" to comply with rules detailed in property-units.yaml. Signed-off-by: Maya Matuszczyk Signed-off-by: Chris Morgan --- Documentation/devicetree/bindings/input/adc-joystick.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Documentation/devicetree/bindings/input/adc-joystick.yaml b/Documentation/devicetree/bindings/input/adc-joystick.yaml index 2ee04e03bc22..9a34b928b15b 100644 --- a/Documentation/devicetree/bindings/input/adc-joystick.yaml +++ b/Documentation/devicetree/bindings/input/adc-joystick.yaml @@ -18,6 +18,11 @@ properties: compatible: const: adc-joystick + poll-interval-ms: + description: + Poll interval time in milliseconds. If not specified, device will use + iio buffer. + io-channels: minItems: 1 maxItems: 1024 From patchwork Wed Jun 29 22:29:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Morgan X-Patchwork-Id: 12900717 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 81CCDCCA483 for ; Wed, 29 Jun 2022 22:29:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230004AbiF2W3u (ORCPT ); Wed, 29 Jun 2022 18:29:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229632AbiF2W3u (ORCPT ); Wed, 29 Jun 2022 18:29:50 -0400 Received: from mail-io1-xd2c.google.com (mail-io1-xd2c.google.com [IPv6:2607:f8b0:4864:20::d2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84E7CD117; Wed, 29 Jun 2022 15:29:49 -0700 (PDT) Received: by mail-io1-xd2c.google.com with SMTP id r133so17458697iod.3; Wed, 29 Jun 2022 15:29:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EVo7+DXyQxi73eOfnv2V979PsitDnvN1mrlQN40qb5E=; b=Ln2+54UcaNqgRmSN+xlJ47bbYr7xeUeYdHyVyI3jmVUk/oI75lUzFiRd9ySk/uQuEp iy89UVQx7GWGfEHY3/PDrNHIYOGrrjG8GkJW01qgnv9JlMXQT6cgL9Js0bJXXohtSDeK YzKTvNR5+HY9jltv/YWaoGvebQITe73KjytEsFkVW/R6ZIQeJ/Eych7eQjBLeo6Q3Df/ M1YbvR5+rJSRhKhGS9nlAaO5HALwAv7uWM8NmoVmdHK0YAG53BjX9q6q07ASpIaunYUd AadAHA9lof6Pl/jDjxVJioIaceppGZFTEMOs6slgEE9AracySIHMjQtZTQDhAo15X8LA GHuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EVo7+DXyQxi73eOfnv2V979PsitDnvN1mrlQN40qb5E=; b=4npp+f9tqoMnoXG5Ltf3d/ndZKnMWuxVN/RWZqwmWwYifLtXXGGXlAAmDbWdojU2lF UrUVFgcIoAkioCmhh6NmHQ/3jLIsXanQrlrsJ8J9KWoUI03xsnjpzOMTy9DEZeam+K3E gp2h/xSqZD2fUYrn/QjNj/ySFfLdpem2SRzvtzwPq5klM5KGdUBAdIXSkp/D2Fqf6pRp WMmv/thGtZlyBZrjCBh6XIpwAqEBG1eeZ2ebcm3t1V9Y4CEMJFO4HbDHqgXxT7IKIsuq m3N+hUHJDVSUrg9hJmlRUVmHAtiiaZKpY/PGCDwnzAudC7IDSMhuJjiJOP7XKaYKeEsl CrvQ== X-Gm-Message-State: AJIora+agD6+NJqKY9hz/FgAsNqiDudTJDC5n8tQESloNHYCYJvbqd6n UzbJ8j3A4PgYMscxoqYP/GCQX4WPfiQ= X-Google-Smtp-Source: AGRyM1usQ3nvh7WnzCe9WTvh5nuNFzQWQ3fi6AtY4mRGfQfyLpXyPcLKcwkCZu8eHfSGt8kdQMqdIg== X-Received: by 2002:a05:6638:3a0a:b0:339:ec66:febd with SMTP id cn10-20020a0566383a0a00b00339ec66febdmr3146723jab.313.1656541788742; Wed, 29 Jun 2022 15:29:48 -0700 (PDT) Received: from Dixie.. ([2604:2d80:a188:fd00:2d4b:b7b2:944:3519]) by smtp.gmail.com with ESMTPSA id ca19-20020a0566381c1300b0033158c4a312sm7845597jab.55.2022.06.29.15.29.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jun 2022 15:29:48 -0700 (PDT) From: Chris Morgan To: linux-input@vger.kernel.org Cc: devicetree@vger.kernel.org, contact@artur-rojek.eu, maccraft123mc@gmail.com, heiko@sntech.de, krzysztof.kozlowski+dt@linaro.org, robh+dt@kernel.org, dmitry.torokhov@gmail.com, paul@crapouillou.net, jic23@kernel.org, linux-iio@vger.kernel.org, Chris Morgan , Chris Morgan Subject: [PATCH v6 2/3] Input: adc-joystick - Add polled input device support Date: Wed, 29 Jun 2022 17:29:29 -0500 Message-Id: <20220629222931.30599-3-macroalpha82@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220629222931.30599-1-macroalpha82@gmail.com> References: <20220629222931.30599-1-macroalpha82@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Add polled input device support to the adc-joystick driver. This is useful for devices which do not have hardware capable triggers on their SARADC. Code modified from adc-joystick.c changes made by Maya Matuszczyk. Signed-off-by: Maya Matuszczyk Signed-off-by: Chris Morgan Acked-by: Artur Rojek --- drivers/input/joystick/adc-joystick.c | 51 +++++++++++++++++++++------ 1 file changed, 40 insertions(+), 11 deletions(-) diff --git a/drivers/input/joystick/adc-joystick.c b/drivers/input/joystick/adc-joystick.c index 78ebca7d400a..e52f8b2b5563 100644 --- a/drivers/input/joystick/adc-joystick.c +++ b/drivers/input/joystick/adc-joystick.c @@ -26,8 +26,23 @@ struct adc_joystick { struct adc_joystick_axis *axes; struct iio_channel *chans; int num_chans; + bool polled; }; +static void adc_joystick_poll(struct input_dev *input) +{ + struct adc_joystick *joy = input_get_drvdata(input); + int i, val, ret; + + for (i = 0; i < joy->num_chans; i++) { + ret = iio_read_channel_raw(&joy->chans[i], &val); + if (ret < 0) + return; + input_report_abs(input, joy->axes[i].code, val); + } + input_sync(input); +} + static int adc_joystick_handle(const void *data, void *private) { struct adc_joystick *joy = private; @@ -179,6 +194,7 @@ static int adc_joystick_probe(struct platform_device *pdev) int error; int bits; int i; + unsigned int poll_interval; joy = devm_kzalloc(dev, sizeof(*joy), GFP_KERNEL); if (!joy) @@ -215,8 +231,17 @@ static int adc_joystick_probe(struct platform_device *pdev) joy->input = input; input->name = pdev->name; input->id.bustype = BUS_HOST; - input->open = adc_joystick_open; - input->close = adc_joystick_close; + + joy->polled = !device_property_read_u32(dev, "poll-interval-ms", + &poll_interval); + + if (joy->polled) { + input_setup_polling(input, adc_joystick_poll); + input_set_poll_interval(input, poll_interval); + } else { + input->open = adc_joystick_open; + input->close = adc_joystick_close; + } error = adc_joystick_set_axes(dev, joy); if (error) @@ -229,16 +254,20 @@ static int adc_joystick_probe(struct platform_device *pdev) return error; } - joy->buffer = iio_channel_get_all_cb(dev, adc_joystick_handle, joy); - if (IS_ERR(joy->buffer)) { - dev_err(dev, "Unable to allocate callback buffer\n"); - return PTR_ERR(joy->buffer); - } + if (!joy->polled) { + joy->buffer = iio_channel_get_all_cb(dev, adc_joystick_handle, + joy); + if (IS_ERR(joy->buffer)) { + dev_err(dev, "Unable to allocate callback buffer\n"); + return PTR_ERR(joy->buffer); + } - error = devm_add_action_or_reset(dev, adc_joystick_cleanup, joy->buffer); - if (error) { - dev_err(dev, "Unable to add action\n"); - return error; + error = devm_add_action_or_reset(dev, adc_joystick_cleanup, + joy->buffer); + if (error) { + dev_err(dev, "Unable to add action\n"); + return error; + } } return 0; From patchwork Wed Jun 29 22:29:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Morgan X-Patchwork-Id: 12900718 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1ADAACCA480 for ; Wed, 29 Jun 2022 22:29:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230080AbiF2W3v (ORCPT ); Wed, 29 Jun 2022 18:29:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229632AbiF2W3v (ORCPT ); Wed, 29 Jun 2022 18:29:51 -0400 Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6EAC311445; Wed, 29 Jun 2022 15:29:50 -0700 (PDT) Received: by mail-io1-xd35.google.com with SMTP id z191so17426545iof.6; Wed, 29 Jun 2022 15:29:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=O8oHayPC4C21GwTuqNIRSpYwzaW9xbbGy2tBzWRNTi0=; b=bxcr/9oI2ms0V3MJbjc+RmrHuuY+gw53i6lUlfk1x+4wM8qIxLhu9s3f6m8THf6Ive KSNk5EMtBzTWdLo3L8pX7FenGAf2nmv3rXPdpS8XNdTByVGUdmoK/UQroqAAvtL5mjsy fKshAQmheFp1n6xwcBLAqroRbWTLGce7bxWWX5/lBLo86g0c25wNVLXd+94pvuYC6tHE AFBor0j8hD7awptqtBpvzu928nOEVdUSPGonYYToN7ucgPgb4ivaYe5R7nF28IjQRqRZ YDNovFmsjS7n1o5TvErT2P3Hlarp/f/3M3A4LYdoGW+RizQUC0lfQK2TuNcv0d3oN0G8 OiIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=O8oHayPC4C21GwTuqNIRSpYwzaW9xbbGy2tBzWRNTi0=; b=uKoK3eN8zbYGp5lgJoKsx9AVNUUMXNZXgSvfVG3AK4QNhmq6YLAe5RnV6pq3F7uYOG uL8hGg3TF7NeAsdEMeMXS+61yjwvvm/Uc6ieoQkvYKWHtnf+VWqD7q7Labmc4OJsJVff 7MmjiBE/gPYM9ibTB+7DhQDsFECWQf/MprwUNCi9p9TImsKIhfL9EvVuW10jXN0SSMYT pBq1SWQY8ltdrK409ITzQGuP9vW8SX30Z5BwNeyfNim/wtRFNyKSsXM+fnywxp8XPCPb BdFSjvZ715yrNVKKX8Lxc3iE7AJa5SH5JsgSifbdnVaeAN6vQsEpVUqJAtBmK6SebRqM wyBg== X-Gm-Message-State: AJIora9JJi30x+e1PGuGcKQhF1LzD1Val328DaukZFWJKE5VbZh9v4zB olo5uvuc+zQgSlxNyD49N2PAGFHG5Ek= X-Google-Smtp-Source: AGRyM1uAcFxQchmC9Hsey2b3E1qiT3/BFfWCMALO+0ThlJ/e8EykSPpfetn0jvdS5Cfk7wBr8GqAdg== X-Received: by 2002:a05:6638:1691:b0:333:f345:ef6c with SMTP id f17-20020a056638169100b00333f345ef6cmr3317153jat.7.1656541789958; Wed, 29 Jun 2022 15:29:49 -0700 (PDT) Received: from Dixie.. ([2604:2d80:a188:fd00:2d4b:b7b2:944:3519]) by smtp.gmail.com with ESMTPSA id ca19-20020a0566381c1300b0033158c4a312sm7845597jab.55.2022.06.29.15.29.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jun 2022 15:29:49 -0700 (PDT) From: Chris Morgan To: linux-input@vger.kernel.org Cc: devicetree@vger.kernel.org, contact@artur-rojek.eu, maccraft123mc@gmail.com, heiko@sntech.de, krzysztof.kozlowski+dt@linaro.org, robh+dt@kernel.org, dmitry.torokhov@gmail.com, paul@crapouillou.net, jic23@kernel.org, linux-iio@vger.kernel.org, Chris Morgan , Chris Morgan Subject: [PATCH v6 3/3] arm64: dts: rockchip: Update joystick to polled for OG2 Date: Wed, 29 Jun 2022 17:29:30 -0500 Message-Id: <20220629222931.30599-4-macroalpha82@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220629222931.30599-1-macroalpha82@gmail.com> References: <20220629222931.30599-1-macroalpha82@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Update the Odroid Go Advance to use "poll-interval-ms" from the adc-joystick driver. Signed-off-by: Chris Morgan Signed-off-by: Maya Matuszczyk --- arch/arm64/boot/dts/rockchip/rk3326-odroid-go2.dts | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/boot/dts/rockchip/rk3326-odroid-go2.dts b/arch/arm64/boot/dts/rockchip/rk3326-odroid-go2.dts index ea0695b51ecd..5a4f81861e07 100644 --- a/arch/arm64/boot/dts/rockchip/rk3326-odroid-go2.dts +++ b/arch/arm64/boot/dts/rockchip/rk3326-odroid-go2.dts @@ -26,6 +26,7 @@ adc-joystick { compatible = "adc-joystick"; io-channels = <&saradc 1>, <&saradc 2>; + poll-interval-ms = <60>; #address-cells = <1>; #size-cells = <0>;