From patchwork Wed Jun 1 19:17: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: 12867201 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 9A011C433EF for ; Wed, 1 Jun 2022 20:46:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230013AbiFAUqa (ORCPT ); Wed, 1 Jun 2022 16:46:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229606AbiFAUo1 (ORCPT ); Wed, 1 Jun 2022 16:44:27 -0400 Received: from mail-oa1-x32.google.com (mail-oa1-x32.google.com [IPv6:2001:4860:4864:20::32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A19F260CE2; Wed, 1 Jun 2022 13:29:35 -0700 (PDT) Received: by mail-oa1-x32.google.com with SMTP id 586e51a60fabf-e656032735so4305776fac.0; Wed, 01 Jun 2022 13:29:35 -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=c2gVDF8Gi6ZBDN7EWWtWy6JxYjUWjegDiiCN3IKGjD0=; b=d/v7A74aeA2RQcQ78lE6EEbkKb5PKlvcsVxqjShMRiKuz6c6KUEpmj+n9pl7mR7zhw ZDhLvxsllPWAT1eYekBujjWcudnFsyCmM5ujHO77Jp+Bs69ocF89732zcKYc6gK6qUr4 gbrjCTiAM1QeK/JvC+I8cToDBJ7zenOoQkMdg8ecl8TFAkhqJY+i+wwdgU5Fuykbl7Ob TwFzjwl7bSvwo7O8SWrkmqSUXAv4P+cEkLt9oK58iKhSLhSqAN9ujjCqpy7jAt7ye5TQ i206maVH3E8TAhJV+N4HKu+1+SJipAcI82ty3cxFaPocLhmJ/+wEArFXQaXMECuIMy6v /jqQ== 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=c2gVDF8Gi6ZBDN7EWWtWy6JxYjUWjegDiiCN3IKGjD0=; b=Znmje8DzrsmR/Hp2HOxuO70B/2wZLQcLU80t1myeSghMFXa5UWzxgnjefg28jUXlvz VKtTQbjhAovN8IYiUP1wtPfd+3pHo0bJQFIRlg7iYHwJFuUBSSiXVdYp3PBohf7+AgGt Tj1T9teVFp1oyUsPcoJilTya6MjtcCchofNErwS9vimP6NZGubqW4YkPs3oy8Ca63E5G 2NpLBmKU9To0hdUB6XcebSaHO3fosZJy8TTqKLHie6DGEhr0WkZhsvm+OrlBpMrW/w6L jc+WefZ2tVfwsOpiTj3zqDwgmfS8Rg1Be82kegMHh5lR9Pk7ZnQj3ZzmgQdISbtnq7U0 pKBA== X-Gm-Message-State: AOAM533Oby3fwqde5Y4exGTatOdEDu9QTV26XC4/KCkKOF5vCNovH4fS XPeyCcL8xgNjhqTEn6MJgzVW5JKAFZjR6w== X-Google-Smtp-Source: ABdhPJxX1tpY7gD2134GbLhvleB3mOZN8X57E0YYPIfMWta7WSJZMFjNI/IDgBsuRURT8W2lCbpCVQ== X-Received: by 2002:a05:6871:149:b0:f5:d454:d5ac with SMTP id z9-20020a056871014900b000f5d454d5acmr626744oab.76.1654111063134; Wed, 01 Jun 2022 12:17:43 -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 w41-20020a056830412900b005b22a0d826csm1194512ott.1.2022.06.01.12.17.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 12:17:42 -0700 (PDT) From: Chris Morgan To: linux-input@vger.kernel.org Cc: devicetree@vger.kernel.org, contact@artur-rojek.eu, heiko@sntech.de, krzysztof.kozlowski+dt@linaro.org, robh+dt@kernel.org, dmitry.torokhov@gmail.com, maccraft123mc@gmail.com, Chris Morgan Subject: [PATCH 1/3] dt-bindings: adc-joystick: bindings for adc-joystick-polled Date: Wed, 1 Jun 2022 14:17:28 -0500 Message-Id: <20220601191730.29721-2-macroalpha82@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220601191730.29721-1-macroalpha82@gmail.com> References: <20220601191730.29721-1-macroalpha82@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Chris Morgan Add devicetree bindings for adc-joystick-polled. Signed-off-by: Maya Matuszczyk Signed-off-by: Chris Morgan --- Documentation/devicetree/bindings/input/adc-joystick.yaml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/input/adc-joystick.yaml b/Documentation/devicetree/bindings/input/adc-joystick.yaml index 2ee04e03bc22..a9d2ac157322 100644 --- a/Documentation/devicetree/bindings/input/adc-joystick.yaml +++ b/Documentation/devicetree/bindings/input/adc-joystick.yaml @@ -12,11 +12,15 @@ maintainers: description: > Bindings for joystick devices connected to ADC controllers supporting - the Industrial I/O subsystem. + the Industrial I/O subsystem. Supports both polled devices where no + iio trigger is available and non-polled devices which are triggered + by iio. properties: compatible: - const: adc-joystick + enum: + - adc-joystick + - adc-joystick-polled io-channels: minItems: 1 From patchwork Wed Jun 1 19:17: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: 12867178 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 D257EC433EF for ; Wed, 1 Jun 2022 19:30:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229587AbiFATal (ORCPT ); Wed, 1 Jun 2022 15:30:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229463AbiFATae (ORCPT ); Wed, 1 Jun 2022 15:30:34 -0400 Received: from mail-oa1-f54.google.com (mail-oa1-f54.google.com [209.85.160.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7BEC17D3A8; Wed, 1 Jun 2022 12:28:36 -0700 (PDT) Received: by mail-oa1-f54.google.com with SMTP id 586e51a60fabf-f2a4c51c45so4010233fac.9; Wed, 01 Jun 2022 12:28:36 -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=XZHYlXGE/Gj6HgAtGn+s07Im2MDC4D0sr/Mr2hsyhJc=; b=FGGQMA136L0V8cOVVqL1HHuZRyAPa6flPt/N0VztaBi2WqmtubZhbRg5uDUnDTE8GF ym0LfjI/MBIHxhwLqvyUBwMRJb6Bdus3ICSlgriMdGcFb6pXvMgdlEapr9TTUVflk9Dj 4eu2EpazUuU5fNldQLVMLybM9MLAkRtnW6Wuz8uGS739h41Y2xYAyoEPEZhkfnMvxpUI sOInSICftmyxm/FgF95q9f8qb0AKBYMq6waXnWyQ0YKT3oehxm0V0T3KtynZIiCygNcY CadVeJgwpnUAoe8GEIP6b3tRFPII5SmEofOaQTfuanvSaDv01iwfE3meG7ZcbSGjDQhB 27Fw== 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=XZHYlXGE/Gj6HgAtGn+s07Im2MDC4D0sr/Mr2hsyhJc=; b=RrD9BZDkYzYYHGiTVPKABeUNFOXXB29ZpYUUH+UJ+nSjAFU2arFkdZaQWcZ9GAnC29 tHrKhmCe6YlOlw7zi/AbOl/07ML5VC9rd7emEv4CltlNgtIdkYbV9dqqbSlv8YjJoB/9 nZW/jsf5JKoa6Y9nNhMDBpLWfZSXp4u2hnGb+SrENRP2Z2TdWun17SbAkRucMWtJijNK ga2T7LHBa/NwfHoeZ0gXmU5zpvy3JYiu8d7eag4RSb4Pcft99fdrZ826bKD3T9LefuvZ 1twzIRHbTTuQItcoEJxUU5JfRUspuwM9WG4Op6cgSJ8yLlurKQCcMV6V7Az+ubx5bscT kbTg== X-Gm-Message-State: AOAM533ZplxVPjiGD7+T8BrO1fosRw6xaT9/YVaws7aNR9xPoGuqehcs 9+LpfDvg3etKbCvez0UHQXBoSi3NGMWOXA== X-Google-Smtp-Source: ABdhPJyLUivhx8v1SCAZrXKdj3/PkUpEYPIpZh8oD+1ERe7p+2gmN9TTFdzMCy/WyhmHx8KgNo/MHw== X-Received: by 2002:a05:6870:3293:b0:f2:dbc9:596f with SMTP id q19-20020a056870329300b000f2dbc9596fmr17556684oac.112.1654111064154; Wed, 01 Jun 2022 12:17:44 -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 w41-20020a056830412900b005b22a0d826csm1194512ott.1.2022.06.01.12.17.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 12:17:43 -0700 (PDT) From: Chris Morgan To: linux-input@vger.kernel.org Cc: devicetree@vger.kernel.org, contact@artur-rojek.eu, heiko@sntech.de, krzysztof.kozlowski+dt@linaro.org, robh+dt@kernel.org, dmitry.torokhov@gmail.com, maccraft123mc@gmail.com, Chris Morgan Subject: [PATCH 2/3] Input: adc-joystick - Add polled input device support Date: Wed, 1 Jun 2022 14:17:29 -0500 Message-Id: <20220601191730.29721-3-macroalpha82@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220601191730.29721-1-macroalpha82@gmail.com> References: <20220601191730.29721-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 | 53 +++++++++++++++++++++------ 1 file changed, 42 insertions(+), 11 deletions(-) diff --git a/drivers/input/joystick/adc-joystick.c b/drivers/input/joystick/adc-joystick.c index 78ebca7d400a..83a5a420141e 100644 --- a/drivers/input/joystick/adc-joystick.c +++ b/drivers/input/joystick/adc-joystick.c @@ -13,6 +13,10 @@ #include +#define ADC_JSK_POLL_INTERVAL 16 +#define ADC_JSK_POLL_MIN 8 +#define ADC_JSK_POLL_MAX 32 + struct adc_joystick_axis { u32 code; s32 range[2]; @@ -26,8 +30,21 @@ 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; + + for (i = 0; i < joy->num_chans; i++) { + iio_read_channel_raw(&joy->chans[i], &val); + 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; @@ -215,8 +232,19 @@ 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 (of_device_is_compatible(dev->of_node, "adc-joystick-polled")) + joy->polled = 1; + + if (joy->polled == 1) { + input_setup_polling(input, adc_joystick_poll); + input_set_poll_interval(input, ADC_JSK_POLL_INTERVAL); + input_set_min_poll_interval(input, ADC_JSK_POLL_MIN); + input_set_max_poll_interval(input, ADC_JSK_POLL_MAX); + } else { + input->open = adc_joystick_open; + input->close = adc_joystick_close; + } error = adc_joystick_set_axes(dev, joy); if (error) @@ -229,16 +257,18 @@ 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 == 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); - 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; @@ -246,6 +276,7 @@ static int adc_joystick_probe(struct platform_device *pdev) static const struct of_device_id adc_joystick_of_match[] = { { .compatible = "adc-joystick", }, + { .compatible = "adc-joystick-polled", }, { } }; MODULE_DEVICE_TABLE(of, adc_joystick_of_match); From patchwork Wed Jun 1 19:17: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: 12867200 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 BEDD6C43334 for ; Wed, 1 Jun 2022 20:44:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229903AbiFAUoP (ORCPT ); Wed, 1 Jun 2022 16:44:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229920AbiFAUno (ORCPT ); Wed, 1 Jun 2022 16:43:44 -0400 Received: from mail-oi1-x22f.google.com (mail-oi1-x22f.google.com [IPv6:2607:f8b0:4864:20::22f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B22A525A814; Wed, 1 Jun 2022 13:27:21 -0700 (PDT) Received: by mail-oi1-x22f.google.com with SMTP id s188so4134887oie.4; Wed, 01 Jun 2022 13:27:21 -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=xwzXnf3azVD6WfYhoQELh3wDWF/dpdqfOluzUPHPtRE=; b=qTZh3z5RwRy6KWlvAvHHj2W1Wlofy+evOE4qf/2EdqZHO9cOnqnJrB+Xk7G0QrUYsH XnzpuFEqv+wOVyflchOI04/wnM6Dq4zvBnHtnFudT8xyFwRsNDb+1iE9l1He/23RKXaM ogdgiY9IQWgxA8Kp4Y13OUg80tAwEhOgMuZ+uOBT3kdV9DjTLrrfKuuvqf1YXnHnBr9P 6HUm5lBkO9Lkx4FZd+W4VCLGvi+JIfv6IRXDMS0u7w8fEw0YV0xmfE9EUHuccYz97prj 9hhSU6kbAZCG7bn0hoi9KoWNSYkNEyR6VnvMbxxrzJuVEJsRFfEQGc8qViiNbbFE5ufG 0Gqw== 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=xwzXnf3azVD6WfYhoQELh3wDWF/dpdqfOluzUPHPtRE=; b=mjQgqilRhghReQY8WrcYYI7J2H69y3Iw4aBywC7JEEf4d9UY387K4HJHvHQVmHnPvP iMq0mnAZ7HCrArGynA6diq6zgQT6gWCRjRq32Q4HwAHEsD/Cuk10ju7d7Y72LqSnr4kB dyIo0qvnSPCye4+iRtXCNi72EAa6ByktCWtujSqeQQVtVCqASu97pSbg/ZzVaS85jLMh k3NgZocJjq/wx5imh8EMS2RldnmB/KAC5nZ84/OZ/Z21rCcdzahRRPCotzQifODOuJ+J 5fLqOGBQN3FtO7NGOA8NCQ5W6e9qgfUjxEFX/g6D30wGz7+7FgjWhFisiYK07MDOk/PB GsdQ== X-Gm-Message-State: AOAM532kcGsyxQ3L7/Rj4MlCmA9AUFBLTIN8Ikq9yp9eX5pXlMz0pSi0 6tgaLuP80UZ8wzaulm4SbgJmKoHpLBvLoQ== X-Google-Smtp-Source: ABdhPJyA57ak5ngD+SHlcaG7WTty94zQ0U4li7XCwx8r2A46BzhNpYPZKbss9DU/hsgej4pJ1Vkanw== X-Received: by 2002:a05:6808:1523:b0:32b:1a45:4bf6 with SMTP id u35-20020a056808152300b0032b1a454bf6mr606308oiw.282.1654111065150; Wed, 01 Jun 2022 12:17:45 -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 w41-20020a056830412900b005b22a0d826csm1194512ott.1.2022.06.01.12.17.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 12:17:44 -0700 (PDT) From: Chris Morgan To: linux-input@vger.kernel.org Cc: devicetree@vger.kernel.org, contact@artur-rojek.eu, heiko@sntech.de, krzysztof.kozlowski+dt@linaro.org, robh+dt@kernel.org, dmitry.torokhov@gmail.com, maccraft123mc@gmail.com, Chris Morgan Subject: [PATCH 3/3] arm64: dts: rockchip: Update joystick to polled for Odroid-Go2 Date: Wed, 1 Jun 2022 14:17:30 -0500 Message-Id: <20220601191730.29721-4-macroalpha82@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220601191730.29721-1-macroalpha82@gmail.com> References: <20220601191730.29721-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 the polled method from the adc-joystick driver. Signed-off-by: Chris Morgan Signed-off-by: Maya Matuszczyk --- arch/arm64/boot/dts/rockchip/rk3326-odroid-go2.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/boot/dts/rockchip/rk3326-odroid-go2.dts b/arch/arm64/boot/dts/rockchip/rk3326-odroid-go2.dts index ea0695b51ecd..9766f80166f8 100644 --- a/arch/arm64/boot/dts/rockchip/rk3326-odroid-go2.dts +++ b/arch/arm64/boot/dts/rockchip/rk3326-odroid-go2.dts @@ -23,7 +23,7 @@ chosen { }; adc-joystick { - compatible = "adc-joystick"; + compatible = "adc-joystick-polled"; io-channels = <&saradc 1>, <&saradc 2>; #address-cells = <1>;