From patchwork Thu Jul 21 16:46:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Morgan X-Patchwork-Id: 592248 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 22CF6CCA488 for ; Thu, 21 Jul 2022 16:46:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231678AbiGUQqR (ORCPT ); Thu, 21 Jul 2022 12:46:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229715AbiGUQqM (ORCPT ); Thu, 21 Jul 2022 12:46:12 -0400 Received: from mail-oa1-x2d.google.com (mail-oa1-x2d.google.com [IPv6:2001:4860:4864:20::2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F41D88101; Thu, 21 Jul 2022 09:46:12 -0700 (PDT) Received: by mail-oa1-x2d.google.com with SMTP id 586e51a60fabf-10d6ddda695so3207423fac.0; Thu, 21 Jul 2022 09:46:12 -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=FmXpKV8L1ROy4Dh0Qt2TT7rzbx5rKU4HTkrXEsPEgGo=; b=SiFGahuH5PdKcRpgSbKIXKVarUDcfraqAzK34hwJqu2u5LSEqNYvmTi8a89CD9kZQc TtKs7+v6pNsSPw4fbFVJ2V+XDQOSwVUmDrf1sk96V9Gy92j5vuat7tyvnj5iKk625CAJ 4H7A7wo++73OfxVcw8E25q/rcgPX6L4XnvraOthMYNylQ5Js3PRx8zTmReaB1EyfDmPJ s6SAYkheSACrvMtQNjYrDwtM+U6xOq0xK2aCvtYC9V+q6yZibFfD+QpTZFJrR/IySLoI Q/MoI7vkrNxWUiy+R62uarFrNyZBXSXgh2KVxOXg8YnWI7BXiLncHptkrhBeDE2vzndj XsHQ== 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=FmXpKV8L1ROy4Dh0Qt2TT7rzbx5rKU4HTkrXEsPEgGo=; b=u3+m4EJB99+IJ3BUetFb/GHz5dxQldzLMug2jP3HwW3d6lZNQJa7vPdrZZZnI5d4f7 pGV5odQsuyzimZcpRVPplHiAfLrPxgS4neSWVdouIDwK+P9hLQazdDEvtNYKcvMhVah0 53xTxuCJ/C2l4egvJb4SIxaCAbGJWnAbWs6c3MX7wunh7jVQiVs8eV4fSYPNTDbJvHH6 eXzyEYYwTCp6pmDb+fUk9bsZguFG4dqAFi0pVgUDiLvB8queWTr+h6BXPeOp2g4ARFcc rPVWcUQG+gkUY9Udw1QIdOEgH3WrJSdRjeX+WQwUQyZ3HE0iYTlmaqgeeV0HyYMHc3sC XT7Q== X-Gm-Message-State: AJIora9ZHBqwJoycaDLyQxlzJThkQ1e/C6Cj7sUL4nUYXK00kVX/IchA dNh8krXzjC0abM3GlQ1S7QyrU3xoaIQ= X-Google-Smtp-Source: AGRyM1ucs7lTKF+U+AYUFgLdecTXONK3OQu+4kv91tPDZ8cv7M1e7yq5yVrvUzclv0qf6IwesAqpBQ== X-Received: by 2002:a05:6870:829e:b0:10c:240b:cbb9 with SMTP id q30-20020a056870829e00b0010c240bcbb9mr5464805oae.115.1658421971030; Thu, 21 Jul 2022 09:46:11 -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 f189-20020aca38c6000000b0033a45705cb2sm831512oia.8.2022.07.21.09.46.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Jul 2022 09:46:10 -0700 (PDT) From: Chris Morgan To: linux-input@vger.kernel.org Cc: dmitry.torokhov@gmail.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, heiko@sntech.de, contact@artur-rojek.eu, jic23@kernel.org, paul@crapouillou.net, linux-iio@vger.kernel.org, Chris Morgan , Maya Matuszczyk , Rob Herring Subject: [PATCH v8 1/3] dt-bindings: adc-joystick: add poll-interval Date: Thu, 21 Jul 2022 11:46:01 -0500 Message-Id: <20220721164603.13534-2-macroalpha82@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220721164603.13534-1-macroalpha82@gmail.com> References: <20220721164603.13534-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 Jul 21 16:46:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Morgan X-Patchwork-Id: 592653 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 6C9B3CCA487 for ; Thu, 21 Jul 2022 16:46:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231499AbiGUQqQ (ORCPT ); Thu, 21 Jul 2022 12:46:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230217AbiGUQqO (ORCPT ); Thu, 21 Jul 2022 12:46:14 -0400 Received: from mail-oa1-x31.google.com (mail-oa1-x31.google.com [IPv6:2001:4860:4864:20::31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F400388102; Thu, 21 Jul 2022 09:46:12 -0700 (PDT) Received: by mail-oa1-x31.google.com with SMTP id 586e51a60fabf-10cf9f5b500so3154971fac.2; Thu, 21 Jul 2022 09:46:12 -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=bn5dzO1DvZMCQuqiDHL4eb767GRAGDv6mTm1J8YKIeM=; b=LdRjmKVLwSjr+016c5CwB8eUtqczUA+1PZno6U3lYFMfWQ7yuU/xR52SAF6wjBXKF0 6zMdoeWS3NL+WNSbIN1T1F4vAt0hWC4898rm8Xijqq1yAbShU2DtQOECIDtmW2kBAtuQ skMTBK4lZ/QEKHCEMgUlh80hxrNqnAkpjFzzPRWDn0XBWmMpgRDL4CyJeXeFD28u0xn9 BvkUIX+d+Mc5/M3peQx8QFH4eFFPowjsiQHYXJ8OadL1XReNsG9A/B9P/5z888/5AnY2 ziwxbtRd0CMpxIIZB2ijts34aZgooDiIftgFdZd/0S3oqKXmbYFKzkYCMiAdLXlRA5Ao ITLg== 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=bn5dzO1DvZMCQuqiDHL4eb767GRAGDv6mTm1J8YKIeM=; b=sMEctI+cICTy/8yWCVfpW+aSaEdLmJIOe5JRvMzd/g6ltZrIR/eNNW/ixZEje1e9ys 89qY9ciy0Mfq1BucLmGqlK+w3LDbOrzFmu1yTwJWJCPweFjwmbqBHlg85HSLIrXJmh3X ywv0kVOjazW3IHE1Dgq7PqImCjRTJ8P/YK9+tRG/uAJ4qe6BUAainSQw8ousoqjktO7R ZZ80S43djYdcIGXo3JFFtZEFhPXPVj4L6Iyy4W1uja0BqErCP9hAcCHGyn4PbLTcLJAw SyZihAnWwY4DiZEV3Z1DshlEiXiijpSy9jpYK+HcwbG1boxavlo2AeJHDzzbHa2chrJu Fe8Q== X-Gm-Message-State: AJIora8MrM4QGfnXtYmLs0DMCv0WyN5WECPq9AF9zpTSiSbitpy3Y6L6 qh5kPCIGzBnZag6v8ac2va8Jmxbrk60= X-Google-Smtp-Source: AGRyM1ss7FtGgsBlwnStWCgP6CQbgLH1iXm55RRErUI/60rXXvKKYIMpYUrn4hNw/0I54OQHfClyBw== X-Received: by 2002:a05:6870:c391:b0:10c:a937:aaf1 with SMTP id g17-20020a056870c39100b0010ca937aaf1mr5520749oao.272.1658421972047; Thu, 21 Jul 2022 09:46:12 -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 f189-20020aca38c6000000b0033a45705cb2sm831512oia.8.2022.07.21.09.46.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Jul 2022 09:46:11 -0700 (PDT) From: Chris Morgan To: linux-input@vger.kernel.org Cc: dmitry.torokhov@gmail.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, heiko@sntech.de, contact@artur-rojek.eu, jic23@kernel.org, paul@crapouillou.net, linux-iio@vger.kernel.org, Chris Morgan , Maya Matuszczyk Subject: [PATCH v8 2/3] Input: adc-joystick - Add polled input device support Date: Thu, 21 Jul 2022 11:46:02 -0500 Message-Id: <20220721164603.13534-3-macroalpha82@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220721164603.13534-1-macroalpha82@gmail.com> References: <20220721164603.13534-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 | 82 ++++++++++++++++++++------- 1 file changed, 62 insertions(+), 20 deletions(-) diff --git a/drivers/input/joystick/adc-joystick.c b/drivers/input/joystick/adc-joystick.c index 78ebca7d400a..085b8e10dfb5 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; @@ -178,7 +193,9 @@ static int adc_joystick_probe(struct platform_device *pdev) struct input_dev *input; int error; int bits; + int chan_storage; int i; + unsigned int poll_interval; joy = devm_kzalloc(dev, sizeof(*joy), GFP_KERNEL); if (!joy) @@ -192,16 +209,31 @@ 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. + */ + chan_storage = joy->chans[0].channel->scan_type.storagebits; for (i = 0; joy->chans[i].indio_dev; i++) { - bits = joy->chans[i].channel->scan_type.storagebits; - if (!bits || bits > 16) { - dev_err(dev, "Unsupported channel storage size\n"); - return -EINVAL; - } - if (bits != joy->chans[0].channel->scan_type.storagebits) { - dev_err(dev, "Channels must have equal storage size\n"); - return -EINVAL; + if (!joy->polled) { + bits = joy->chans[i].channel->scan_type.storagebits; + if (!bits || bits > 16) { + dev_err(dev, + "Unsupported channel storage size\n"); + return -EINVAL; + } + if (bits != chan_storage) { + dev_err(dev, + "Channels must be equal size\n"); + return -EINVAL; + } } } joy->num_chans = i; @@ -215,8 +247,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,16 +267,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 Thu Jul 21 16:46:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Morgan X-Patchwork-Id: 592247 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 DEDD4C43334 for ; Thu, 21 Jul 2022 16:46:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232240AbiGUQqS (ORCPT ); Thu, 21 Jul 2022 12:46:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230482AbiGUQqO (ORCPT ); Thu, 21 Jul 2022 12:46:14 -0400 Received: from mail-oa1-x2a.google.com (mail-oa1-x2a.google.com [IPv6:2001:4860:4864:20::2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05A771A053; Thu, 21 Jul 2022 09:46:14 -0700 (PDT) Received: by mail-oa1-x2a.google.com with SMTP id 586e51a60fabf-10d83692d5aso3174453fac.1; Thu, 21 Jul 2022 09:46:13 -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=6KSnMu0007NUX3n6VG0MmgWubuiJ/ZN6YblN0CfQJME=; b=H10ibcbgHEISxcCf5ZrlhXrz/41lGJ/Xw7l1FUk7tl3FFBsdczPR0YEGBKi7T7xNt0 +T8fHBfGuCjgckA/HrKJGmdPdNjpdH9oFuMkLgOHpuLpLISer2jBKEyvNDVxOpFZzeys B4e1Uj8f9HvhEt37RpeJ6kJb/Zm97LrfwUo1PWfArlFYbtZME9NxkZM0DNa6cxO9gjwQ Veyo0nwTXlP4YKH2qd6TLer3V16a244t4iOmWLZDEFZEvwl9T51nRk9QFrGcEbmve3Rt OlSit2R7wUL5jVFQpx+d8MwAV/6idsHz3ijfKXIkEUwFIa7yWauM2OEBMUqfp2knjJsY f16Q== 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=6KSnMu0007NUX3n6VG0MmgWubuiJ/ZN6YblN0CfQJME=; b=EQdujh8r+pgtcOYyjOV2Y4/efe1d77ew/NsqpeSPYVSXutrc/WubpkkMtEHRnam5HS 9FJ7ZfpBCM2SFpzPAuufug3TdlnTvXqRwDsKUpUrDu0FpuaQYNp53pYteOVGqbUDWebu 4RdnxwzPeRYP0pahvwSNYW0F3XEN56fXLilIwnylMfN3Z1sH8tggTNtg2fgMrvOiM4C1 6Wl5MRxB/BJuGo+qvXOOdeOyObuk6KvkUZQSS9jxUPz+r7XTGO/ZfxQCqSAGKnSyjX7D +bVTti6G7jJXi9j0NAuxrqPHmUDnfxjNti1OqTxy2IrXOO5jPnJesiXb5DyfJjXAiYwE Efcw== X-Gm-Message-State: AJIora/JUxKRKfjLewq/3dNl4PLAk1pRfc0AX4B/B41IapEboz4bqpEX 4FpdoZ6BwMdKYmU2oIpm/XodZT+iNKI= X-Google-Smtp-Source: AGRyM1vuY1J0I3qYchHhOXPwCiBeigMHOP+C2hRExkM+3m5nLB73AAKM+GNYjYzvi3BlwWsJkGOYTQ== X-Received: by 2002:a05:6870:6195:b0:100:ee8a:ce6d with SMTP id a21-20020a056870619500b00100ee8ace6dmr5632240oah.155.1658421973065; Thu, 21 Jul 2022 09:46:13 -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 f189-20020aca38c6000000b0033a45705cb2sm831512oia.8.2022.07.21.09.46.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Jul 2022 09:46:12 -0700 (PDT) From: Chris Morgan To: linux-input@vger.kernel.org Cc: dmitry.torokhov@gmail.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, heiko@sntech.de, contact@artur-rojek.eu, jic23@kernel.org, paul@crapouillou.net, linux-iio@vger.kernel.org, Chris Morgan , Maya Matuszczyk Subject: [PATCH v8 3/3] arm64: dts: rockchip: Update joystick to polled for OG2 Date: Thu, 21 Jul 2022 11:46:03 -0500 Message-Id: <20220721164603.13534-4-macroalpha82@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220721164603.13534-1-macroalpha82@gmail.com> References: <20220721164603.13534-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 ea0695b51ecd..61583c3f24e6 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>;