From patchwork Thu Aug 4 18:46:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Morgan X-Patchwork-Id: 595961 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 56AA3C25B0C for ; Thu, 4 Aug 2022 18:47:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234380AbiHDSrA (ORCPT ); Thu, 4 Aug 2022 14:47:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237266AbiHDSq4 (ORCPT ); Thu, 4 Aug 2022 14:46:56 -0400 Received: from mail-oi1-x22d.google.com (mail-oi1-x22d.google.com [IPv6:2607:f8b0:4864:20::22d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F2746D55F; Thu, 4 Aug 2022 11:46:53 -0700 (PDT) Received: by mail-oi1-x22d.google.com with SMTP id s204so375377oif.5; Thu, 04 Aug 2022 11:46:53 -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=gu0lwnTLaZR0SB/xx8VrbkOfRzdVruFSaSEgi9k6XPiTtEfHlhV9rpMR3WLGlEq1pt I0eMeP0keV+n0OJ71fg7C4j9bYzywWTpH9pyRJTxHYxGIvTVGIXj4T80XE/aegW1b8c9 Xpd8uS4qRMHwP0KCxjxqbLb+QVGn/P0GN0MAHsb/7KjQuCRm1Qy3vRegsmGMPd8jQqHT /s2Tno6iZ/c0d9Eulk5dcF/EW3g2lszOaFAmtSOiG1MP9SKNhdpg70dl7zaGJzNdKuOM nNg/H2lu5fYxx6uJPzuobk6HvQUBD5dRSHVz1sTBjkUUTFMgC9Ef61IbuCp9BMS3Mcxc jfow== 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=L5qHBQfYG7TPoUCKA/rxzjVVVXtCpoTrAjR7+aM0ZZfdawHFJZNFDZ4uEYexc4SdVB 1vKyg3BWvsu7oZ4Nr9ygyJYKTUD4VI7kCpu1H//wRC6yg1HbSaiMJSQwNqRhfQrHrBWB VZPDKvnNHOzVONWNfd49f+ksEBJhTH6qdzTjljz0lf7LsGCE2WJH/EiocqGvO0PkYN1z KPudpgXyfgakz87+LzuekTk76b11S0IWtmCDLXuKaxQ7lGBQzG0Ro7fi5iUrchrZdaco E6CCE1+rURRikYwjITFfAkgwHNXTxAtFZOnBFAYj6BVudC2R7ku6qlXOi0a9D+f8tMGU DGcQ== X-Gm-Message-State: ACgBeo3QpI7d6FQl91Sy28v0IZbTIFu01zXU9dY88m9ceJbs9BnydOQu G3NHc6xpCEfjQyHO40e3JoTNCL6Grv4= X-Google-Smtp-Source: AA6agR4omTSKKaM3a/8G45yQ2MgleXqYT+VPZwIyu5qymdesExa2dXUnAkRJRa9FY8b791mIDJaYEg== X-Received: by 2002:a05:6808:21a3:b0:33e:b0ea:7ce3 with SMTP id be35-20020a05680821a300b0033eb0ea7ce3mr4782116oib.46.1659638812428; Thu, 04 Aug 2022 11:46:52 -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 p17-20020a9d76d1000000b00636a8dafdc9sm87945otl.2.2022.08.04.11.46.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Aug 2022 11:46:52 -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 v11 1/3] dt-bindings: adc-joystick: add poll-interval Date: Thu, 4 Aug 2022 13:46:42 -0500 Message-Id: <20220804184644.20710-2-macroalpha82@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220804184644.20710-1-macroalpha82@gmail.com> References: <20220804184644.20710-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 Thu Aug 4 18:46:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Morgan X-Patchwork-Id: 595419 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 DB2CAC25B0D for ; Thu, 4 Aug 2022 18:47:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239904AbiHDSq7 (ORCPT ); Thu, 4 Aug 2022 14:46:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234380AbiHDSq4 (ORCPT ); Thu, 4 Aug 2022 14:46:56 -0400 Received: from mail-oi1-x233.google.com (mail-oi1-x233.google.com [IPv6:2607:f8b0:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E1546D560; Thu, 4 Aug 2022 11:46:54 -0700 (PDT) Received: by mail-oi1-x233.google.com with SMTP id h188so333037oia.13; Thu, 04 Aug 2022 11:46:54 -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=KT5o4rt36m7BxJc04DTnWf34jJojmIKYLK34WwqIMFI=; b=q5GrPO/DfnDGyvG4h2SPRbu2Q20kTghMRgkNVC4VX9T8TKPXry2BUTZKxdd2xrEM1e adLD5l5L6Wk8Qm9i+gWuVzqNd/D3aBd0IrSUVHClIGPFSG14rYIshmDJR+6n8bL9jTpH m6gk+zYXf17gKTLkbmHXlfBStcsf+pL+W7JMiuNiZg4H+dEOoNPAoBq60ypvgxJZEHTw zC/AJjWlQNrVyGoVpJFsKZDRzHjbuN0tW8A1UtJaiHlet5DiR+hnfI2x5M4ejboKCTzL vmFsOvUzjoG+4MfWkGoMQQo0w+cy7C/K1iEQlAxDgV9HcN9ZFOlp4gO/WZvTx4wAmtsO Ct6A== 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=KT5o4rt36m7BxJc04DTnWf34jJojmIKYLK34WwqIMFI=; b=QdszYlbQqNjfSoGDp/HDJWycpzyrEqOse5HpxGFLCZL3AYEW4AjfPSrujZnlTJIDod G/uOsk9KWSO8Tll0M1YtT5SWSLUc0r11Lvi5J+niYRRVG5HrJ6fmFCU/KxEx3tM2LiUO +jkr5/VtbQZfNXZaKCwOUhPfyKn72+dUCvdAFW2B4fmQMn5A8ZT/uKIJIlOQvqRl2cT8 Zu98aXvRWm/lNqdE5/bKZJBroolz+6jL8TQfQrFIfEJlEIaMfIun1UfV6sbldMQ9EnGO n6I15YVlrTEzomh6S2Patxvfp/8w2lInyyaE09A3a7NAMkEA0WyaFwXrmeL3XeKKfR41 N53g== X-Gm-Message-State: ACgBeo3a+qQh70Jj7P3fjzCp2oJW1BpKumxaVIZyokYb0jItAjxP+7K+ bO2xcGMLtIyOyPksZOrxRHAaXSxDphs= X-Google-Smtp-Source: AA6agR53g+VDUkpCcMYALLnH5bKGh/VPOjRUVeOasumAfHiaUe7YbbKkOXKfNXrUV86gvFb5uVXjLw== X-Received: by 2002:a54:4015:0:b0:340:2eb7:62e9 with SMTP id x21-20020a544015000000b003402eb762e9mr1458628oie.65.1659638813391; Thu, 04 Aug 2022 11:46:53 -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 p17-20020a9d76d1000000b00636a8dafdc9sm87945otl.2.2022.08.04.11.46.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Aug 2022 11:46:53 -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 v11 2/3] Input: adc-joystick - Add polled input device support Date: Thu, 4 Aug 2022 13:46:43 -0500 Message-Id: <20220804184644.20710-3-macroalpha82@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220804184644.20710-1-macroalpha82@gmail.com> References: <20220804184644.20710-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 --- drivers/input/joystick/adc-joystick.c | 47 ++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/drivers/input/joystick/adc-joystick.c b/drivers/input/joystick/adc-joystick.c index 78ebca7d400a..1094d0fb78ed 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,13 +264,17 @@ 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"); return PTR_ERR(joy->buffer); } - error = devm_add_action_or_reset(dev, adc_joystick_cleanup, 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; From patchwork Thu Aug 4 18:46:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Morgan X-Patchwork-Id: 595420 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 2FA2DC19F2A for ; Thu, 4 Aug 2022 18:46:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238388AbiHDSq6 (ORCPT ); Thu, 4 Aug 2022 14:46:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234918AbiHDSq4 (ORCPT ); Thu, 4 Aug 2022 14:46:56 -0400 Received: from mail-oi1-x236.google.com (mail-oi1-x236.google.com [IPv6:2607:f8b0:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BB896D561; Thu, 4 Aug 2022 11:46:55 -0700 (PDT) Received: by mail-oi1-x236.google.com with SMTP id u9so339182oiv.12; Thu, 04 Aug 2022 11:46:55 -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=kPgwJwi8cH3nQMG8047Ci4ChTjm/z/z4X9S5omCPPRH9+8MlV3YSgwZgCP36/fDNcn OBNz4TSZw8lvI7HDKEjz5g8NkuCCMU8gutxgimyGs8NrCTvOykFDVXcFZG5Tzo5mCCBY XnMNkpTLOwWQbBZ2A6hssJfwp34FZN/YKavrZi5g02sTYE0gMBvapMpcPvjMFY02jCYU UWsWRqRY8GtEZQ7AX2yXsVUSNGaZfe4u/SEv1aLCDp0GrK8gR2zhnrsI83qwxDlMQNvP u8OI9xZ/Ecdf+adNVLSLeWZbZP6ttfxScZBchDU2QQ5w+WyeiVzA9LdX06vWF7RWUnS/ 6AhQ== 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=nZFv7ZZPDl/aPduu1P2Dk3Vnn0IwnbBQmw4LGxKPjJ2BUErWjbgasmo10dE1ek0G3z 5AtaXFJYiVGsJow3gj3EIV19KGYZjP+6UEktw2d6lMyy9Lce01NYDKTdp7Zy8qY1/jCf uALIXUHlYFlau1ats0bB6n5b5jZ6t0nUytZr+Jlatv2vL5/68yzCVn2I8HJVnIGsSPF7 3C/QvxshAdNyX83iDLfCed+fdP/2yOdd886YqK4bD4JRa553gh8/YQ0Q4gaWXmolYzx6 9Iue2zX1KI4RE10GiYkoOSX+pSi/mGIRui6RGteFRpmoA4yVzkWC8OEWmmwBRYsExLCW 2pyQ== X-Gm-Message-State: ACgBeo1f3ThzYIlScK7NbHKnZDt0/l6JLBNiiPIDhFD1DuKMmP/lKYlE lyWPlUiBe1KTIYmtXX+g1Ftu5y3POsc= X-Google-Smtp-Source: AA6agR7qEcF+xFl8S0+7b0/FI7+zGh11rJ/0mFnE8PfpUAJaRHKdR/MwgfasJqdrsV32vqgiSkxO+Q== X-Received: by 2002:a05:6808:300f:b0:2f9:81c1:7691 with SMTP id ay15-20020a056808300f00b002f981c17691mr4618142oib.208.1659638814350; Thu, 04 Aug 2022 11:46:54 -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 p17-20020a9d76d1000000b00636a8dafdc9sm87945otl.2.2022.08.04.11.46.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Aug 2022 11:46:53 -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 v11 3/3] arm64: dts: rockchip: Update joystick to polled for OG2 Date: Thu, 4 Aug 2022 13:46:44 -0500 Message-Id: <20220804184644.20710-4-macroalpha82@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220804184644.20710-1-macroalpha82@gmail.com> References: <20220804184644.20710-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>;