From patchwork Wed Jun 1 20:49:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Morgan X-Patchwork-Id: 577908 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 21272CCA479 for ; Wed, 1 Jun 2022 20:52:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230163AbiFAUwi (ORCPT ); Wed, 1 Jun 2022 16:52:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230206AbiFAUvQ (ORCPT ); Wed, 1 Jun 2022 16:51:16 -0400 Received: from mail-ot1-x32f.google.com (mail-ot1-x32f.google.com [IPv6:2607:f8b0:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A22E2789A4; Wed, 1 Jun 2022 13:49:36 -0700 (PDT) Received: by mail-ot1-x32f.google.com with SMTP id h9-20020a056830400900b0060b03bfe792so2066069ots.12; Wed, 01 Jun 2022 13:49: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=HfXAhGZstKpwrUHgURvDPoLbikylL/iicCOJA8WsIcY=; b=HhfRdIgpmpyKARVdrEED/uPp+WUPM0DPB5J6H6xjUEdHvNRce1VZMJg6EYTT7B+NMZ IJj7Al0Nv3hTyM1A1OlKoHlIceftPOJt0EC27yaeEIFobdD4XKNQPVQTyY4J6VWUdTSD BbmG8Fc7Mv1a9+J3UDxDFOfW4r4VqeIth3VDIZZvu1kUICqwiZbfPRm5r4n9l9deAUy2 79uKI5moGUJX6i/wXBEuatxgt1ZJ7VPMbL4LMO9aElI4GjB4XzsQObpb1YRmhzvBcbkq zuHIOgflhWLOdQbdbADFpfenhOk0sgIf5vwoULKxDY6OAvck/geZCkgLQlJdTK7ubT/6 nq+A== 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=HfXAhGZstKpwrUHgURvDPoLbikylL/iicCOJA8WsIcY=; b=mJHfJdvV8F8SSaqmpfHCyJ3WrS8W5Q/V1Qd4MkYoyBMumBD1GBZaweArmwrtLn6lnn dF0K2lCkcORWETk2HuQHoXl2czaIjDykLRoTsawWpsI36ImKEBeEfC+l9yME3rBZ1iCd ugVCHMCTKeZbKFZCBM764tP53JGshFqlqktjdm57f+0FZFlNmZTqw1l4I6Y7gEF1/dOk ivejvc1MKKwF4wu39cqaS7AnBJcJzJ/87+efcvXRoREHlYi1HYomWrAA6DZn1GsR0aWS Vk5qJjitSjBfgEYkcu0GqvrVZeW914V5kKzmbfsGkFGvjPPVFq5UpAAbmK8W4KuMVNI4 uZag== X-Gm-Message-State: AOAM5338uVbi3GuJshxjUm7JaCdu20VkE+D/r0tyJcxU/gchBt54kFM8 YZJ7bb++1aNmGTOHkDhruHVZooXZQvnOQQ== X-Google-Smtp-Source: ABdhPJyRknbuKUl+bIxjAPXCiccyukwjL3N8F0BaIT9XZ3J9uLdhIrewDB8j8OUo6Iwzu+C0Ckep7A== X-Received: by 2002:a05:6830:2002:b0:60a:df8c:18f8 with SMTP id e2-20020a056830200200b0060adf8c18f8mr727455otp.184.1654116572066; Wed, 01 Jun 2022 13:49:32 -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 3-20020a9d0b83000000b0060603221279sm1222157oth.73.2022.06.01.13.49.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 13:49:31 -0700 (PDT) From: Chris Morgan To: linux-input@vger.kernel.org Cc: devicetree@vger.kernel.org, dmitry.torokhov@gmail.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, heiko@sntech.de, maccraft123mc@gmail.com, contact@artur-rojek.eu, Chris Morgan Subject: [PATCH v2 1/3] dt-bindings: adc-joystick: add adc-joystick,polled option Date: Wed, 1 Jun 2022 15:49:25 -0500 Message-Id: <20220601204927.10256-2-macroalpha82@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220601204927.10256-1-macroalpha82@gmail.com> References: <20220601204927.10256-1-macroalpha82@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Chris Morgan Add documentation for adc-joystick,polled. New device-tree properties have been added. - adc-joystick,polled: A boolean value noting the joystick device should be polled rather than use a triggered buffer. Signed-off-by: Maya Matuszczyk Signed-off-by: Chris Morgan --- .../devicetree/bindings/input/adc-joystick.yaml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/input/adc-joystick.yaml b/Documentation/devicetree/bindings/input/adc-joystick.yaml index 2ee04e03bc22..4f49a1a5772e 100644 --- a/Documentation/devicetree/bindings/input/adc-joystick.yaml +++ b/Documentation/devicetree/bindings/input/adc-joystick.yaml @@ -12,12 +12,19 @@ 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 + adc-joystick,polled: + type: boolean + description: + If the device does not support triggered buffers and needs to be polled. + io-channels: minItems: 1 maxItems: 1024 From patchwork Wed Jun 1 20:49:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Morgan X-Patchwork-Id: 577909 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 430CACCA473 for ; Wed, 1 Jun 2022 20:52:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230104AbiFAUwh (ORCPT ); Wed, 1 Jun 2022 16:52:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230059AbiFAUvQ (ORCPT ); Wed, 1 Jun 2022 16:51:16 -0400 Received: from mail-ot1-x32c.google.com (mail-ot1-x32c.google.com [IPv6:2607:f8b0:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 892EC915A5; Wed, 1 Jun 2022 13:49:37 -0700 (PDT) Received: by mail-ot1-x32c.google.com with SMTP id g13-20020a9d6b0d000000b0060b13026e0dso2073209otp.8; Wed, 01 Jun 2022 13:49:37 -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=ZGf5MMy759Vak/8WG6t17kedCivIjuKTblPpyCYJaes=; b=J2fKaNhWDhRft6hDjRM9ZNJGoOgBHXelVqIY268qnVeCckiE9C2bMns1rzvvL9DyUo p4k3ntHHHcmje64V8krloMOpD5PW1qZfGuZmxNMIh+MvkAA9X5vROdvLxUHxb3L2BANG /xgUzRnQ/llYx2pSAnn4YyPUcjddUbidXhO18/Edfuy5mwb6wO7twfDwwSQpNUZPDPQY UR7LxSSOG3wmE5fIicv8281EOurq443e7BTxGJ4DcjddJiEnXujiqfxLUX4Axjw3bCSE vkqvJp9LrEANYR1n73MvTt1uLrMJAS4K1R61uC+u5QEcs89PHMWkarjVc86fpNPcNQGn LNfw== 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=ZGf5MMy759Vak/8WG6t17kedCivIjuKTblPpyCYJaes=; b=m+WMmGrwtiK1MWSw8MwmLDubgHhPNiBbPqEOoVVSXU8EsCeZli2SxVD1KvKt8z4YaK mS1zjJl6PuAmatYlu0v4P0IBv3JO2SYr0Ze8Wq0kRHdaq8SDnP8ny+9i9MlJJrGwRu2N iT1ru3EytV+auB8ZO5WiP+DXKasktvu8gn2VloLCMtDA7SHqk0JDs61L387MI+rCNF7R 8lELVJBCLPg4EdFCeUmluYkvBZ4EHngGvT+r+AJYN6KNxCeFf9NN/poRhdJpmZU3MMs3 moWgdtdTxvUb2q4HygNKCU08E/ln5O/sh/jiRocNt2gRXGVhWTCO9nfbYeaiXmdUPfSj kK/g== X-Gm-Message-State: AOAM531mNVK08Cd5WMb2JwYttpaLrHgOxwjyImBvgxdJKUBnWycu6rhw HpPsrNr40klWmKPIuWen29z7bdI98c5odw== X-Google-Smtp-Source: ABdhPJyz+rqZUxiv4Tm150IHWMdoiW1+APtpcoXxpsn302eVa2pWCQsV0HLu01o04+9oUE1w0yLwqQ== X-Received: by 2002:a05:6830:2708:b0:606:621f:b634 with SMTP id j8-20020a056830270800b00606621fb634mr743463otu.1.1654116573156; Wed, 01 Jun 2022 13:49:33 -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 3-20020a9d0b83000000b0060603221279sm1222157oth.73.2022.06.01.13.49.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 13:49:32 -0700 (PDT) From: Chris Morgan To: linux-input@vger.kernel.org Cc: devicetree@vger.kernel.org, dmitry.torokhov@gmail.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, heiko@sntech.de, maccraft123mc@gmail.com, contact@artur-rojek.eu, Chris Morgan Subject: [PATCH v2 2/3] Input: adc-joystick - Add polled input device support Date: Wed, 1 Jun 2022 15:49:26 -0500 Message-Id: <20220601204927.10256-3-macroalpha82@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220601204927.10256-1-macroalpha82@gmail.com> References: <20220601204927.10256-1-macroalpha82@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@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 | 52 +++++++++++++++++++++------ 1 file changed, 41 insertions(+), 11 deletions(-) diff --git a/drivers/input/joystick/adc-joystick.c b/drivers/input/joystick/adc-joystick.c index 78ebca7d400a..5a28fe7b8ebc 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 (device_property_read_bool(dev, "adc-joystick,polled")) + joy->polled = 1; + + if (joy->polled) { + 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) { + 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;