From patchwork Tue Jun 28 19:14:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Morgan X-Patchwork-Id: 12898806 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 35B46CCA479 for ; Tue, 28 Jun 2022 19:15:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235273AbiF1TP2 (ORCPT ); Tue, 28 Jun 2022 15:15:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238225AbiF1TPG (ORCPT ); Tue, 28 Jun 2022 15:15:06 -0400 Received: from mail-il1-x12a.google.com (mail-il1-x12a.google.com [IPv6:2607:f8b0:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E993FB5B; Tue, 28 Jun 2022 12:15:05 -0700 (PDT) Received: by mail-il1-x12a.google.com with SMTP id a7so3727518ilj.2; Tue, 28 Jun 2022 12:15:05 -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=/n4ZGb/068nKpvUj2aEVlkDxH0ZLUUwUoAPZOtzHeaw=; b=FreFHvJED6l8YeDZnVOHuHLKagfq/efvYJ1oMCwGE+Z5d5eIv7A6xSeRuEstULrwbr L+ViFaEi2OPPO7EXllvmzn2X2btIjj6YXbxksYmpq1MyvNk4JGvtM9UjdnzhQ8TYd0x2 SXGZROUDIH36+o47065wJrb6qZGn4Q+x4cRCI3p3WEaDs9nRyAlEC5vERW2FLKsfDyIA ake1Jo/bc6iifmrUblRLJirP2CjjN6u7yvRi407Wlv5VKihURklf1HpkgnVJO+37Iggw 8hVP2Yqa+feaDtHkopbRBC7O5jTM+pW37140Pvhwjve00QrzqrHj7SG46+26PHP4+eBk 0ZgA== 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=/n4ZGb/068nKpvUj2aEVlkDxH0ZLUUwUoAPZOtzHeaw=; b=NalsJ8l68/wzIDnAnWb7uhi+4u94wwlPe701kN8Dffl/WjQLzB53EYwkNnjQ9/kgb0 CP9+0MrpuQERoY998y+seFm4iCWkUIUe7N0s1wJocu2gvUKPtAVW4D99tEaZS/vL/Atq i/q7h3IMr8JAeKx3mkxaQqk95h/6RHt8/UQtGN1zgF4IqDjY2YwXKrvtWXwAg9JlVL/r UOdTXpM34ECfa2phXwu1nWyjv5GeTNdW1izXKSTZ5+G0n05RFRbZghyQh58uHuZa/ddf fYHY9SS1EZWmHNv9jz8ttnwUux49FK00Da/MQJ3IoKM0WJ3ZppwaODp+9xVl9rluR61K svVw== X-Gm-Message-State: AJIora+jHE1Gi9btDJ1hnmc0x/GMVHzdq3HPb0QXxLWHO2EveMhkgPZi 3iVA8bu2c8NYaBo4vms8cmptJFpzPGI= X-Google-Smtp-Source: AGRyM1txgww6e5MmaT16qH4j1VatQDpetfmdZN/OVKb1BVkQJvXq01cSMk5Wi6nRTCX2f/cWgiLb5w== X-Received: by 2002:a92:b00e:0:b0:2d6:538b:b866 with SMTP id x14-20020a92b00e000000b002d6538bb866mr11059856ilh.199.1656443705116; Tue, 28 Jun 2022 12:15:05 -0700 (PDT) Received: from Dixie.. ([2604:2d80:a188:fd00:5448:c223:9fa4:5f87]) by smtp.gmail.com with ESMTPSA id c97-20020a02966a000000b0032b74686763sm6396009jai.76.2022.06.28.12.15.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jun 2022 12:15:04 -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 v5 1/3] dt-bindings: adc-joystick: add poll-interval-ms Date: Tue, 28 Jun 2022 14:14:58 -0500 Message-Id: <20220628191500.69831-2-macroalpha82@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220628191500.69831-1-macroalpha82@gmail.com> References: <20220628191500.69831-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 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/devicetree/bindings/input/adc-joystick.yaml b/Documentation/devicetree/bindings/input/adc-joystick.yaml index 2ee04e03bc22..cfd8d1af5d2c 100644 --- a/Documentation/devicetree/bindings/input/adc-joystick.yaml +++ b/Documentation/devicetree/bindings/input/adc-joystick.yaml @@ -18,6 +18,12 @@ properties: compatible: const: adc-joystick + poll-interval-ms: + description: + Poll interval time in milliseconds. If not specified, device will use + iio buffer. + $ref: /schemas/types.yaml#/definitions/uint32 + io-channels: minItems: 1 maxItems: 1024 From patchwork Tue Jun 28 19:14:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Morgan X-Patchwork-Id: 12898805 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 B9CA2CCA47E for ; Tue, 28 Jun 2022 19:15:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235291AbiF1TP3 (ORCPT ); Tue, 28 Jun 2022 15:15:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238237AbiF1TPI (ORCPT ); Tue, 28 Jun 2022 15:15:08 -0400 Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DC55B6E; Tue, 28 Jun 2022 12:15:07 -0700 (PDT) Received: by mail-io1-xd34.google.com with SMTP id i194so13804445ioa.12; Tue, 28 Jun 2022 12:15:07 -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=X39lEbxy8L1hbkkrIqrd19do6eZEZZKlQL34ZYzhRo3tQDsf7hjHlYIKpGbhIWA4Ru VWYv5AzSs5wikIOHeQpO7NzJp3NCnKzhRffiqWRPsO5Q1oxY4pDfi5JzmQBK79bRjBJm w7ckdNDd43kIQXxxmpO7bidGGjfd6N3tCnkP5AwDjbxAcZriMRhTXrPmeVODySFeSZqA wwbYc7/5S3SkaxECEQ7UeyvaogCTiAlKqKNXb/iaWcXTva8p51c7NKm7P5Km4zggEgex BeEQvGq6KnuPI6M6rN1Dbg8xcnmMHsYTZFDWCO6BFpLXbURqGFogzsNiwqyJa2la0aZI HGXw== 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=wSFoGFymGaUmsIPsjK9U90EGnOBEQ35xqZE1k8BkESMro+WrACprPEZsHBYAbMW4Vo tSMk4oekl/Vdsa6C0vESvYimvM+jGmpiqszFSoUDTuYN+7s9ZcDah92W7OVC1WB/39q/ EDhMnWwk7/fjlNYCw8Q/GVWH1o1s6y7wBpJN8bYfn5dnPdZMM8FGSZooYoel+0ZOv1TS El/iy36NYiv2+jLqT3KhtRsRCEpRhhYoaHFW5jJfiOXRvFUpJ8EugSwCVmurBzRZ7dBm BLeOEmsO6U6gttzPxOwSw/i3GeHszXRKoMyHf6qCHa4CvickQK9Gcuj2VxSKDu4QJHTB Wy6w== X-Gm-Message-State: AJIora/9Hu6hGA7bkwGdL6mKqmRBidSPX6QkYwfdi3Z7rbNNk0AfqhHC i7/kpAIAJBc9tLmrWopYAEJTZMZhgW4= X-Google-Smtp-Source: AGRyM1sgL09VDiqSgeEEm5ubd1+MoFbIm5CeK2alfflHKWbL/MFgKbSUjo/L/6EeNSYwfPrSSJMGoA== X-Received: by 2002:a05:6602:2e8e:b0:669:d5b1:3fc9 with SMTP id m14-20020a0566022e8e00b00669d5b13fc9mr10316935iow.210.1656443706557; Tue, 28 Jun 2022 12:15:06 -0700 (PDT) Received: from Dixie.. ([2604:2d80:a188:fd00:5448:c223:9fa4:5f87]) by smtp.gmail.com with ESMTPSA id c97-20020a02966a000000b0032b74686763sm6396009jai.76.2022.06.28.12.15.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jun 2022 12:15:06 -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 v5 2/3] Input: adc-joystick - Add polled input device support Date: Tue, 28 Jun 2022 14:14:59 -0500 Message-Id: <20220628191500.69831-3-macroalpha82@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220628191500.69831-1-macroalpha82@gmail.com> References: <20220628191500.69831-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 --- 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 Tue Jun 28 19:15:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Morgan X-Patchwork-Id: 12898807 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 BBC97C43334 for ; Tue, 28 Jun 2022 19:15:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235307AbiF1TP3 (ORCPT ); Tue, 28 Jun 2022 15:15:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238248AbiF1TPJ (ORCPT ); Tue, 28 Jun 2022 15:15:09 -0400 Received: from mail-il1-x134.google.com (mail-il1-x134.google.com [IPv6:2607:f8b0:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE63AB70; Tue, 28 Jun 2022 12:15:08 -0700 (PDT) Received: by mail-il1-x134.google.com with SMTP id w10so8822700ilj.4; Tue, 28 Jun 2022 12:15:08 -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=f/C5Lq3rXiFfjdyJhtf/aKXekBMizvPbGJRee/3Ow4A+CBcFEBdMDX8kMcRC36C4L2 D8OfptHIsh7JibPBuxL9Nu7BI/kJqI7b6XvUNNWADk2Xsk4RvyyRof6vxyzJBRlejlR1 melId5+WMeOyZK4S6TUXyVDnSkDfE/s3WiZIo8TzInphtQT5CtZZho2/J6Z9E2V/ZzK0 4tX8pv4SdL980rm5r46Jf9BAo+qkXMl41MIjL0h/aDDObZ8hVxL8DHo5jcM+BHbBxMSO aWnSCYDTFgbXwRXlM6nZ6wLyq7A7/jc2XysWmvHx8voWjQ6j0ALn83THDVHBNxRAMq5o /MhQ== 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=A5cdK8o7Jk6E55Dc8JY03Fm1IynPWycE77RYejs1C3FcdgxudwaXhfXwqVmY+7QVtC DH9AwYGYXuBwTUgn7aNzyTH8aGw/WYDO/rGzpIT7/95Eysdo20kR0VMkGWtJQ3p3+aTV LYIpUfLYXocOeojjOh8XJ/Zd1t0ixiXMdPMOEx/NqZ9QouFRS8zektT+DNF5SshA5a+2 sVilW5jnAdHZgmrGbP44MKyooD5NicW3OPgaPbXdt86o1uKbEAqLvYZrk9kpIgO+PBR7 6k4KmSQ9bNEE9raLCiwKfi1bmBnqUDwwqROYWvbx4Zc5iWO5D572VbOXnCyvZRIs688T enGQ== X-Gm-Message-State: AJIora9O61IJpdwvsdFiWpMWJG63135T50wUXGYidrO+EaPFQ0JCwM1Y RCI9e+zo/u0hDrf/NreSNs29UEhnUbE= X-Google-Smtp-Source: AGRyM1s34UtjOt/L6zJK43lP2yb8JESjRKuvugNJzxDCMyYEXOn7J+2oI58ymx8nfgOcfXp6W0nwnQ== X-Received: by 2002:a92:d10a:0:b0:2d9:1332:d339 with SMTP id a10-20020a92d10a000000b002d91332d339mr11893345ilb.110.1656443707878; Tue, 28 Jun 2022 12:15:07 -0700 (PDT) Received: from Dixie.. ([2604:2d80:a188:fd00:5448:c223:9fa4:5f87]) by smtp.gmail.com with ESMTPSA id c97-20020a02966a000000b0032b74686763sm6396009jai.76.2022.06.28.12.15.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jun 2022 12:15:07 -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 v5 3/3] arm64: dts: rockchip: Update joystick to polled for OG2 Date: Tue, 28 Jun 2022 14:15:00 -0500 Message-Id: <20220628191500.69831-4-macroalpha82@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220628191500.69831-1-macroalpha82@gmail.com> References: <20220628191500.69831-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>;