From patchwork Fri Aug 5 17:10:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Morgan X-Patchwork-Id: 12937582 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 A9B73C25B07 for ; Fri, 5 Aug 2022 17:10:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234130AbiHERK1 (ORCPT ); Fri, 5 Aug 2022 13:10:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238324AbiHERK1 (ORCPT ); Fri, 5 Aug 2022 13:10:27 -0400 Received: from mail-ot1-x334.google.com (mail-ot1-x334.google.com [IPv6:2607:f8b0:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31C95EE3C; Fri, 5 Aug 2022 10:10:26 -0700 (PDT) Received: by mail-ot1-x334.google.com with SMTP id a14-20020a0568300b8e00b0061c4e3eb52aso2314489otv.3; Fri, 05 Aug 2022 10:10:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=FmXpKV8L1ROy4Dh0Qt2TT7rzbx5rKU4HTkrXEsPEgGo=; b=fGtFjqjUZTaE+1OJmQbScVxWkhWw9cvHaiQtdBl8c8HnSzeu/0x5UwQ3IctHW0AmeN 02La85NrT2JBh+V2FV1ki7Z8Q4497+xsl0XBdhbUODzzYOlCS+pHKqVY1EJvhtcnDMZK oCuMpGKmFA79GqgnbyXvMgKetOld3XXUhEJi/zjSK+SvZwl5WYLPdFstGsLkNeF6gKop 1mqXwCPLEOzYe+Zp08FOxcbmmO8pNwP+LwqctLd8PL83olZz2DoDoRz71lHkYgf4rp/f 61wvySHKOati7bs7YN+9C+kI+rGyplIm4Y5ZCF4OyV/PPq2YuaTidL31c25rAp26XSy0 VV6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=FmXpKV8L1ROy4Dh0Qt2TT7rzbx5rKU4HTkrXEsPEgGo=; b=2c9BXikMfuZRLOvzkRHtx25boFilqDTCzC2vcnHSM/OqU+YiKWW/1A70J4CifiwgeN 7LYIhcaJTnt+t26AW3EKAGJT4WqgIQ1G63nsf2RV3NNitvsiV/qwiUl/PMGArQzaxcXH j9D5KeWItMOZlH/9PnOWYWzbpb44tYbNW3t5ECvYd6/u8VfSxmp7LjlsEhH8X0x8FsWd 4StzEoozOiVLdoW4ptSswb4GUmw5JRlb9AjAqv3yaZkBYiKar6ejQ9x1o03TGU1B/osY LxlywvtrfTkbI5W9YXdh+UDeMqnQENOAMY8/xCx3tcYAJ0WLwxscTNh4Zz107h4mpaes CnQA== X-Gm-Message-State: ACgBeo1SUQXP+eeQmZHi3t+SEpcFXhaEVfrupUk1oturbG5q+69M/vRi 8xwf6rOFjdXABk4wRCb82ouabIqWFaY= X-Google-Smtp-Source: AA6agR6LkOM+saSc5rblBs8RK/FEZBpOZxpuQChaHMMcgkCFLIKJsxa+FQuIUqvAFzwl5WkSFD+O3Q== X-Received: by 2002:a9d:14b:0:b0:61c:9129:c974 with SMTP id 69-20020a9d014b000000b0061c9129c974mr2923892otu.231.1659719425169; Fri, 05 Aug 2022 10:10:25 -0700 (PDT) Received: from wintermute.localdomain (cpe-76-183-134-35.tx.res.rr.com. [76.183.134.35]) by smtp.gmail.com with ESMTPSA id r32-20020a056870e9a000b0010e046491f8sm794126oao.57.2022.08.05.10.10.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 10:10:24 -0700 (PDT) From: Chris Morgan To: linux-input@vger.kernel.org Cc: linux-iio@vger.kernel.org, dmitry.torokhov@gmail.com, contact@artur-rojek.eu, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, heiko@sntech.de, jic23@kernel.org, paul@crapouillou.net, Chris Morgan , Maya Matuszczyk , Rob Herring Subject: [PATCH v12 1/3] dt-bindings: adc-joystick: add poll-interval Date: Fri, 5 Aug 2022 12:10:14 -0500 Message-Id: <20220805171016.21217-2-macroalpha82@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220805171016.21217-1-macroalpha82@gmail.com> References: <20220805171016.21217-1-macroalpha82@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Chris Morgan 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 buffers). If this value is provided, the adc-joystick driver is polled at the specified interval. The existing attribute of "poll-interval" was used instead of complying with property-units.yaml after discussion of the issue on the mailing list. Signed-off-by: Maya Matuszczyk Signed-off-by: Chris Morgan Reviewed-by: Rob Herring Acked-by: Artur Rojek --- 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..ab5caad055ea 100644 --- a/Documentation/devicetree/bindings/input/adc-joystick.yaml +++ b/Documentation/devicetree/bindings/input/adc-joystick.yaml @@ -14,6 +14,9 @@ description: > Bindings for joystick devices connected to ADC controllers supporting the Industrial I/O subsystem. +allOf: + - $ref: input.yaml# + properties: compatible: const: adc-joystick @@ -28,6 +31,8 @@ properties: https://github.com/devicetree-org/dt-schema/blob/master/schemas/iio/iio-consumer.yaml for details. + poll-interval: true + '#address-cells': const: 1 From patchwork Fri Aug 5 17:10:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Morgan X-Patchwork-Id: 12937583 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 9DF40C25B0C for ; Fri, 5 Aug 2022 17:10:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238324AbiHERK2 (ORCPT ); Fri, 5 Aug 2022 13:10:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240932AbiHERK2 (ORCPT ); Fri, 5 Aug 2022 13:10:28 -0400 Received: from mail-oi1-x22b.google.com (mail-oi1-x22b.google.com [IPv6:2607:f8b0:4864:20::22b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51164F585; Fri, 5 Aug 2022 10:10:27 -0700 (PDT) Received: by mail-oi1-x22b.google.com with SMTP id u9so3270278oiv.12; Fri, 05 Aug 2022 10:10:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=nwHryU0bZnt309RGGOE8P70CLHk18q0nOqSgqZBBh4U=; b=S9zGs8fsYEoYd4D3BNp4/n7jchmKkbi2ThFLepv76FDKXZxprLdYG/kwiRjid5p53y s1UJOQYijp3xNZvgmpphxKAh67V4KSEiSVMk5KpYAKE3WMOVWa879EgNrAYks7WntNId OK2Po+sfpbRmDryEhD8wrtek5e4vxiL9Pmdypt4VWHSGKJGXcPYQ/WV8Nb4SvnRti4bx y9l8MsO/xeNOHn6iyIkkcSvAdJXI/NeOhfyrKvZyDUQBUG2V2w8ob7FA//WukSlLcQcD EWkgFbfeMmiXi6p7AYW0c4qJCfYCVxqvcB+16P6qA1BtV190mA/2OmyPoDoSfKvcfmbC ZTsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=nwHryU0bZnt309RGGOE8P70CLHk18q0nOqSgqZBBh4U=; b=h67DpQ1AI3umoVw7m1L5R3cVDDByFIMw94fz6kRNlESpm1YQ8TBUY2auicB6AC6xLn Kmj34jZ8hQiPtSGIdWGEw2uH26ffiJ4oNC7SOKgqoB6s4JpxI7hOeMYpLJ78ZPTyDrDA TGSZz7grKHOPnYxlu48k9yyM+RDKA/J4P6dQV5VW/1KxOb/HlYJiGbYZg8S5nqlVoINR 7AyRFmIikzTBdXVgLFKLB+/sO21VsrIlP8DE+bxYfEBzdWfhE9OjnN2qViWe0bo/ENfX XEWxEYEw71FRFXtEwNVyAqtv0sQrmS3g6ExMAemrRfCl1vq2xRb0g99sYFjwEUp0+jJ6 wlwg== X-Gm-Message-State: ACgBeo0VYeDo/UtoBihPmbNDmXu/p5RhCM9sCeRGIe4aVNZ/9ovTrfC9 LlasuYFyLrRREFJXiWKKCVxXkkkHF4w= X-Google-Smtp-Source: AA6agR5OkvP5Tp6ugZ1RX+TQ1iE2gbHX3JU6h+49ij0VCVhhmjdPMDCBo3i+zDaxdj6QymHDlPFpjg== X-Received: by 2002:a54:4715:0:b0:342:b1b2:acfe with SMTP id k21-20020a544715000000b00342b1b2acfemr3080919oik.73.1659719426353; Fri, 05 Aug 2022 10:10:26 -0700 (PDT) Received: from wintermute.localdomain (cpe-76-183-134-35.tx.res.rr.com. [76.183.134.35]) by smtp.gmail.com with ESMTPSA id r32-20020a056870e9a000b0010e046491f8sm794126oao.57.2022.08.05.10.10.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 10:10:25 -0700 (PDT) From: Chris Morgan To: linux-input@vger.kernel.org Cc: linux-iio@vger.kernel.org, dmitry.torokhov@gmail.com, contact@artur-rojek.eu, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, heiko@sntech.de, jic23@kernel.org, paul@crapouillou.net, Chris Morgan , Maya Matuszczyk Subject: [PATCH v12 2/3] Input: adc-joystick - Add polled input device support Date: Fri, 5 Aug 2022 12:10:15 -0500 Message-Id: <20220805171016.21217-3-macroalpha82@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220805171016.21217-1-macroalpha82@gmail.com> References: <20220805171016.21217-1-macroalpha82@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Chris Morgan 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 Reviewed-by: Jonathan Cameron --- drivers/input/joystick/adc-joystick.c | 44 +++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/drivers/input/joystick/adc-joystick.c b/drivers/input/joystick/adc-joystick.c index 78ebca7d400a..77dfb7dd96eb 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) @@ -192,8 +208,21 @@ static int adc_joystick_probe(struct platform_device *pdev) return error; } - /* Count how many channels we got. NULL terminated. */ + if (device_property_present(dev, "poll-interval")) { + error = device_property_read_u32(dev, "poll-interval", + &poll_interval); + if (error) + return error; + joy->polled = true; + } + + /* + * Count how many channels we got. NULL terminated. + * Do not check the storage size if using polling. + */ for (i = 0; joy->chans[i].indio_dev; i++) { + if (joy->polled) + continue; bits = joy->chans[i].channel->scan_type.storagebits; if (!bits || bits > 16) { dev_err(dev, "Unsupported channel storage size\n"); @@ -215,8 +244,14 @@ 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; + + 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,6 +264,9 @@ static int adc_joystick_probe(struct platform_device *pdev) return error; } + if (joy->polled) + return 0; + 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"); From patchwork Fri Aug 5 17:10:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Morgan X-Patchwork-Id: 12937584 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 014FBC25B0F for ; Fri, 5 Aug 2022 17:10:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240932AbiHERKa (ORCPT ); Fri, 5 Aug 2022 13:10:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240754AbiHERK3 (ORCPT ); Fri, 5 Aug 2022 13:10:29 -0400 Received: from mail-oi1-x229.google.com (mail-oi1-x229.google.com [IPv6:2607:f8b0:4864:20::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A73DF585; Fri, 5 Aug 2022 10:10:28 -0700 (PDT) Received: by mail-oi1-x229.google.com with SMTP id q184so3326665oif.1; Fri, 05 Aug 2022 10:10:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=yrhBL50UTTJaHzMh461WNNj8NIR2DIRZ1vY8GGWYUG8=; b=mIGjGFg02sqAPbhUSNTDaS3/qe+y4bTX1TzDIb+Et33IvTDUPkrlCnPrS4yd7IHRHS t01d7Z7s+fZQGgfWPpZl/PafjNjLNyyvXZUhqLdgeifW9w32p1Gfuwxnj9vC/bmr3fOC +obdjyeDxGBBmShNA2vrOdKPAui0a+kmlXiY9CF9Ej4zZe184rIs3QQ8x5VYec/aSBxY kzYHKdPuoIaTq3Pe2isEMfWLSZ0z4umpkxUCOCcSWDL1FmlX8slSBD4iD1ScTNJeuJM6 4l+C34RoDhDzN5aQM+eFjmC7Vjpdog/BNRtzwZLaEWjWXin+XVjhSSoV0NhVTe93Rhss 6ijg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=yrhBL50UTTJaHzMh461WNNj8NIR2DIRZ1vY8GGWYUG8=; b=GTGjz4c+s4IAPoiFVo8BwxA9PVc1IYr6Ojd6zcm64eHmthNedup0Vu4rmbzYsfgqUw m79yO56u6dJmBmDVGOkwQrxxnYkX+4St245nniUnSY42OQwpQX0fNYyv3I13EbB/l/FR tflshddz/iijbe0AqnSpA52gWehJgo0zgg3ZM75Fu27xwH4oIM0rTWwStGZY7lAKd3Pw 7u0hAT3V3qyoLjH4Qj6dHo6o9UyWsNVRglqozZ2RYOhIozfp1TbDNRN4U3TFlW+qJxZE duvSjynj43vSJKDxleuuS0c/FNeDkQVDoOxkUNoITGGqD8V/dctehQwYviXGx+itsEvx wYmQ== X-Gm-Message-State: ACgBeo0U+tC7YVABhRbj/wWFe8iWyIdUxAJreZmtBY5oip727xN5e7yN apBKuLjWKqmJbXtUpbpg/0wEVW3g4FM= X-Google-Smtp-Source: AA6agR5XPEWVJrEpt91ff0jdaKGEJFkP25ScqpyRE4I/WTkKJJ0d3sfqEmRaVjA0KXVwK515koIbFQ== X-Received: by 2002:aca:ab8c:0:b0:342:a1ad:cbef with SMTP id u134-20020acaab8c000000b00342a1adcbefmr3406341oie.97.1659719427604; Fri, 05 Aug 2022 10:10:27 -0700 (PDT) Received: from wintermute.localdomain (cpe-76-183-134-35.tx.res.rr.com. [76.183.134.35]) by smtp.gmail.com with ESMTPSA id r32-20020a056870e9a000b0010e046491f8sm794126oao.57.2022.08.05.10.10.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 10:10:26 -0700 (PDT) From: Chris Morgan To: linux-input@vger.kernel.org Cc: linux-iio@vger.kernel.org, dmitry.torokhov@gmail.com, contact@artur-rojek.eu, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, heiko@sntech.de, jic23@kernel.org, paul@crapouillou.net, Chris Morgan , Maya Matuszczyk Subject: [PATCH v12 3/3] arm64: dts: rockchip: Update joystick to polled for OG2 Date: Fri, 5 Aug 2022 12:10:16 -0500 Message-Id: <20220805171016.21217-4-macroalpha82@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220805171016.21217-1-macroalpha82@gmail.com> References: <20220805171016.21217-1-macroalpha82@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Chris Morgan Update the Odroid Go Advance to use "poll-interval" 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 415aa9ff8bd4..3389755dbdc8 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 = <60>; #address-cells = <1>; #size-cells = <0>;