From patchwork Tue Apr 9 19:10:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Klinger X-Patchwork-Id: 10891927 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 14DDF922 for ; Tue, 9 Apr 2019 19:10:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 013F8287FD for ; Tue, 9 Apr 2019 19:10:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E6CE028924; Tue, 9 Apr 2019 19:10:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 77E84287FD for ; Tue, 9 Apr 2019 19:10:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726875AbfDITKs (ORCPT ); Tue, 9 Apr 2019 15:10:48 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:55749 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726497AbfDITKs (ORCPT ); Tue, 9 Apr 2019 15:10:48 -0400 Received: from localhost ([2.171.41.193]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1N1Ok1-1gluix10nL-012lfk; Tue, 09 Apr 2019 21:10:24 +0200 Date: Tue, 9 Apr 2019 21:10:22 +0200 From: Andreas Klinger To: jic23@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com Cc: knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net, songqiang1304521@gmail.com, robh@kernel.org, m.othacehe@gmail.com, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH 1/3] srf04.c: add maxbotix ultrasonic sensors Message-ID: <20190409191021.w6phf2q4m2pxcrkq@arbad> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20170113 (1.7.2) X-Provags-ID: V03:K1:pBHh8YUyJ5asc3vB4tRHolmNO9Q4UOo/6jjRPdC6UmKbIrRZiig +XDMS2OaOC2qi8SncL71WKwNt/q7QMs9wOuzJu0gFj8vJ+pWAuJzg4kTsOhSb3VcjrVOzoS bU2LXFMqjHl1VkHZYjhWMhWAuqaKgXRQWyUDwAfSYHBpNfsyUumVhR4slUKkTa3TOjCjc4N fX5i1xdJLokufAiQF1ZDg== X-UI-Out-Filterresults: notjunk:1;V03:K0:WHm4lkGAv6M=:D+Ao2kP1Il/d3ZamGcS0Pu mYQIp312F7ECCFM1wUuJHEatndYcobA3Fc9lwZc/utL7yi+QYMIm+kZLRXFmaYG+b1sZC3YMf uss2dGCloI+zVlSd8mK91JJlPfQy3gIXjwPKNQFFHYB/KsHLS+qPZudscefB2SH009gXaG3DN jwm/irSi4I+0os7res0b/iPGwIB5Z0KTVqcrXuKqN0fPa/9KHf5KxZeEqw5A/uv1eknLVo+Ks HJEAwKpG++w6rlO4BlH8JiExEftmyvMh00iXHHbjr3sYowRP6liMKXN1z54hDtd8aJgPpD5Sk krHhD1YptlkK17bWqnNnHIbd8BTw90nbFuodrM2AdpT8HXHMxdEpZAkWEcunbiSA6KLRjKUAL yerta8Nbf/2IE1NnZ0eiCXEj7mA5lsp+oQ6vqtGLgGd/vWyEJmc7shWC4JExvgzqRuB/VURVZ PWTIdvrfiojWjafnCUaIvic6rTZzWfWTxql16FMjt5+8trmp19eEjyeQbHL/HAUerQsicrqKj S7mL+jM0azCzuQOQ1PkOWHNJ3nElfi86rxqLknE4QGf6YXPgBN3N1yQmqN0BFPtpqhFZ/Yqbr D1GzHbt4jdE1xYF8mqnFtif7DXveJ/EAgQg3YoA6QZrC5BNhIAruXPvTsQw0PDvwL585BH4Os FpX2H+/boU1K9wk+drbe2KWn8vZzsE62rj3EABAr7PEz8co2RtvWXLbAfOIHPpP3WNxXp+ajB 79i6+He+qevMgGO1VXOV7Oe/c5Bys8rlhn2ziA== Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP add Maxbotix LV ultrasonic sensor types mb1000, mb1010, mb1020, mb1030 and mb1040 add a configuration struct with the different trigger pulse lengths Signed-off-by: Andreas Klinger --- drivers/iio/proximity/srf04.c | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/drivers/iio/proximity/srf04.c b/drivers/iio/proximity/srf04.c index 09c7b9c095b0..1bad4018d1aa 100644 --- a/drivers/iio/proximity/srf04.c +++ b/drivers/iio/proximity/srf04.c @@ -23,7 +23,7 @@ * trig: --+ +------------------------------------------------------ * ^ ^ * |<->| - * udelay(10) + * udelay(trigger_pulse_us) * * ultra +-+ +-+ +-+ * sonic | | | | | | @@ -48,6 +48,7 @@ #include #include #include +#include #include #include #include @@ -56,6 +57,10 @@ #include #include +struct srf04_cfg { + unsigned long trigger_pulse_us; +}; + struct srf04_data { struct device *dev; struct gpio_desc *gpiod_trig; @@ -66,6 +71,15 @@ struct srf04_data { ktime_t ts_falling; struct completion rising; struct completion falling; + const struct srf04_cfg *cfg; +}; + +static const struct srf04_cfg srf04_cfg = { + .trigger_pulse_us = 10, +}; + +static const struct srf04_cfg mb_lv_cfg = { + .trigger_pulse_us = 20, }; static irqreturn_t srf04_handle_irq(int irq, void *dev_id) @@ -102,7 +116,7 @@ static int srf04_read(struct srf04_data *data) reinit_completion(&data->falling); gpiod_set_value(data->gpiod_trig, 1); - udelay(10); + udelay(data->cfg->trigger_pulse_us); gpiod_set_value(data->gpiod_trig, 0); /* it cannot take more than 20 ms */ @@ -215,6 +229,18 @@ static const struct iio_chan_spec srf04_chan_spec[] = { }, }; +static const struct of_device_id of_srf04_match[] = { + { .compatible = "devantech,srf04", .data = &srf04_cfg}, + { .compatible = "maxbotix,mb1000", .data = &mb_lv_cfg}, + { .compatible = "maxbotix,mb1010", .data = &mb_lv_cfg}, + { .compatible = "maxbotix,mb1020", .data = &mb_lv_cfg}, + { .compatible = "maxbotix,mb1030", .data = &mb_lv_cfg}, + { .compatible = "maxbotix,mb1040", .data = &mb_lv_cfg}, + {}, +}; + +MODULE_DEVICE_TABLE(of, of_srf04_match); + static int srf04_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -230,6 +256,7 @@ static int srf04_probe(struct platform_device *pdev) data = iio_priv(indio_dev); data->dev = dev; + data->cfg = of_match_device(of_srf04_match, dev)->data; mutex_init(&data->lock); init_completion(&data->rising); @@ -280,13 +307,6 @@ static int srf04_probe(struct platform_device *pdev) return devm_iio_device_register(dev, indio_dev); } -static const struct of_device_id of_srf04_match[] = { - { .compatible = "devantech,srf04", }, - {}, -}; - -MODULE_DEVICE_TABLE(of, of_srf04_match); - static struct platform_driver srf04_driver = { .probe = srf04_probe, .driver = { From patchwork Tue Apr 9 19:10:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Klinger X-Patchwork-Id: 10891929 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4D1BE922 for ; Tue, 9 Apr 2019 19:11:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3A1D22880D for ; Tue, 9 Apr 2019 19:11:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2E37F28938; Tue, 9 Apr 2019 19:11:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BAD5F2880D for ; Tue, 9 Apr 2019 19:11:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726857AbfDITLV (ORCPT ); Tue, 9 Apr 2019 15:11:21 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:44423 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726497AbfDITLV (ORCPT ); Tue, 9 Apr 2019 15:11:21 -0400 Received: from localhost ([2.171.41.193]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MfZ9C-1ggoK83GMS-00g2KU; Tue, 09 Apr 2019 21:10:56 +0200 Date: Tue, 9 Apr 2019 21:10:55 +0200 From: Andreas Klinger To: jic23@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com Cc: knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net, songqiang1304521@gmail.com, robh@kernel.org, m.othacehe@gmail.com, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH 2/3] devantech-srf04.yaml: add Maxbotix ultrasonic iio proximity sensors Message-ID: <20190409191054.va6y2l5lyhyoo5p4@arbad> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20170113 (1.7.2) X-Provags-ID: V03:K1:p1NqKgFr89i3dKH9K5oUkFO5Im4IcAVaAra/mTLITGBfWBekWkN jJsnO8i9Z/EeSt5ozmCNVXqjK6T4VLxb2wGhz4aRxR+/DZCE/LafvYRSQFaxFvv0zA9aOy6 fk+CTEQPLV5nS2MDgZgFQ3RetfaAowWP98crSjjR4hvR0nZu0ft2PhjWB5crVrShaTxLWNh YAoh73LNsJmu9CwmfcASg== X-UI-Out-Filterresults: notjunk:1;V03:K0:SBxbRLpUIns=:+yqKsjmR38CQ3XPYj3JT9x JMyrgxsa0VSs87kpDoCquMXz/gLDiPSHE4kNAkDhZOqI0Xrm4uEWisla02Z9dM3WncA4d7BPt aF/4RQyuaYW6tbvYAW7Pcz//4/QIMrUpDvFuRdit6uTVIGnSyp3CFzzJfxRMdkpuO0lJo9ZDb NzqAOV4AncVZQgMK52Y6ar9U2ISwTDaCFwtG9Z+cue03z9tLYhlx+DOw6ttKxB/Dzj5ki+53r zJfOCZQuDCYxoOE7j9e3+/x/PLFr8erq4uMtyGJQgzI85HnebGjR41mFFJWz1uNPN2u+qHk7b nULVEK2vrABmTQiQFgp0UfZOhOyBfhsaALdFIL+MQVXkU9iSqJnYzf6Zc1Gl6A5/32ZhyM3W8 Xgl8DfaaGh0cFInzDXwFPAjgNpaySRvg9aeCFkEBSRA//2DV4QDorTTsuhwxoAS7pMGeO8S15 mol6eTiqOtloKNvMCv4MFunUZF2zO77vDCAC6zYmh7FliqQJ+NZ3dr4lYINhzJKwYbNgBKGjQ MZW0hJrSpmKB1blGmNnD3mzT7VLdoXawSMaoCgePDwe0XgQn9/5rI70nMZm/OKoea4FC+n8O+ P5m5cXdzd4UMggBGNhbvmAaj8udPHIe3lLc41vjylV7UWz0K1tMuyHDEzXnNbXT/TvgB0HDwM DtKNGbNhjDnczYpygUXeKZvxpVDDYX4oCoICxXI/NjhxFfbp1SPmWUY6quYckAMQeszcJURwU BZ1RDKqRqRt95ZjsPY3FMif/PICKrgK6Gdurrg== Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP add compatibles for Maxbotix ultrasonic iio sensor types to yaml documentation Signed-off-by: Andreas Klinger Reviewed-by: Rob Herring --- .../bindings/iio/proximity/devantech-srf04.yaml | 25 ++++++++++++++-------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/Documentation/devicetree/bindings/iio/proximity/devantech-srf04.yaml b/Documentation/devicetree/bindings/iio/proximity/devantech-srf04.yaml index e7aab785c97d..4e80ea7c1475 100644 --- a/Documentation/devicetree/bindings/iio/proximity/devantech-srf04.yaml +++ b/Documentation/devicetree/bindings/iio/proximity/devantech-srf04.yaml @@ -4,7 +4,7 @@ $id: http://devicetree.org/schemas/iio/proximity/devantech-srf04.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# -title: Devantech SRF04 ultrasonic range finder +title: Devantech SRF04 and Maxbotix mb1000 ultrasonic range finder maintainers: - Andreas Klinger @@ -16,19 +16,28 @@ description: | - echo-gpio is held high by the sensor after sending ultrasonic burst until it is received once again - Specifications about the driver can be found at: + Specifications about the devices can be found at: http://www.robot-electronics.co.uk/htm/srf04tech.htm + http://www.maxbotix.com/documents/LV-MaxSonar-EZ_Datasheet.pdf + properties: compatible: - items: - - const: devantech,srf04 + enum: + - devantech,srf04 + - maxbotix,mb1000 + - maxbotix,mb1010 + - maxbotix,mb1020 + - maxbotix,mb1030 + - maxbotix,mb1040 trig-gpios: description: - Definition of the GPIO for the triggering (output) This GPIO is set - for about 10 us by the driver to tell the device it should initiate - the measurement cycle. + Definition of the GPIO for the triggering (output) + This GPIO is set for about 10 us by the driver to tell the device it + should initiate the measurement cycle. + See Documentation/devicetree/bindings/gpio/gpio.txt for information + on how to specify a consumer gpio. maxItems: 1 echo-gpios: @@ -40,8 +49,6 @@ properties: trip. It needs to be an GPIO which is able to deliver an interrupt because the time between two interrupts is measured in the driver. - See Documentation/devicetree/bindings/gpio/gpio.txt for information - on how to specify a consumer gpio. maxItems: 1 required: From patchwork Tue Apr 9 19:11:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Klinger X-Patchwork-Id: 10891931 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5E295922 for ; Tue, 9 Apr 2019 19:12:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 49FFC2880D for ; Tue, 9 Apr 2019 19:12:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3E1E52893A; Tue, 9 Apr 2019 19:12:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6BEC32880D for ; Tue, 9 Apr 2019 19:11:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726756AbfDITLx (ORCPT ); Tue, 9 Apr 2019 15:11:53 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:42221 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726947AbfDITLw (ORCPT ); Tue, 9 Apr 2019 15:11:52 -0400 Received: from localhost ([2.171.41.193]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MV6G0-1hM4nu3Y86-00S7xH; Tue, 09 Apr 2019 21:11:29 +0200 Date: Tue, 9 Apr 2019 21:11:28 +0200 From: Andreas Klinger To: jic23@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com Cc: knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net, songqiang1304521@gmail.com, robh@kernel.org, m.othacehe@gmail.com, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH 3/3] Kconfig: change configuration of srf04 ultrasonic iio sensor Message-ID: <20190409191126.lkjujjnvjyxua3fn@arbad> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20170113 (1.7.2) X-Provags-ID: V03:K1:tQ+PdOMlJh44Sw5kkguM4eGYVVeX0cKfISKrqG3IW5nQW7ntndl 5InQkROY01TnimtECvpWmMBeargImLBQyBZGjwpi65Bx6Kq6692ozKJpr8zj6CUiPOVQiCF yel49EncHLXXFOPvv7K7Li99qKtB86nMamZuI8yeaxxxwBuIS56NpHVrwemY/oDJErYJc1m co/T2mMBGZtBQeVkDh86A== X-UI-Out-Filterresults: notjunk:1;V03:K0:6wylmMkoAoU=:mvlTplnkKZB98DuZw2GK7k YbzLWnw5S7KMD3ZDKOKRKFNQ4GSVR3/OTHl6D3lZNTdQw7qVkWBfuPxwoedbZD3jvLp3SoceA 47ct3PICLmNodVHyW6SKq9WRToDHr/vz+1+ee819WrQbzUvMEpzLZcRm45mY82fqROUzuwaGb 7j0CqPLtildl8xmaqM20enAuC5aNJVrQxadlaeEEyavr3+n1PNC1PeEieJsSctAbBoN3+Le4d at44BQoHiSYuOTAC44DYTUC3DxYSmItGJVzpz+EidhFQWLAiw9RyaBkXc/aNVvwyQVUTV8eo8 xxpQklT/5u8yIqbm1Kdcz3Lj/Y9vqz0cNuKP8Ia8hK/0QA5aokn2R22vOi6F6EU/rQNMP9iJy +ps8OQltblpjcX03L5yVQRa5EN9Elt7TLRUzbXuLjEP/kcuFW6DJJCXJanp3rNFrC0i5dJyrj 2AnrsTZSDyx1BJ8lPl3YX9ONXwFZNuN3jra5IKAqVMavknORYp18C4i9iXdMJgCfDk2kkieaW bY+XRB5BRQLc6480YQj8wCBkdwlwggfrEfYUSolMBFFP+/UI2FLdBQwet48JUXsB52dIe9/Of 9NwZ0BQAofPHqFkznEJpf141GC/8okEX/uOuU6O4IoLKmZHvbW6nIs9Mf5bFHG7hVbwszGzXI cA3pRJ7vcQdeM8xKtZ7KyhORjIWE+F0t3A9dK9QHiq5qbKFOJ2OTghh5Et+VOiRvTsCvOox0F pM1Y9jyN00m9CZ+k3Jq0q/VJ9U7RGzRPyTN/vw== Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP reword configuration option for SRF04 list supported types in help text Signed-off-by: Andreas Klinger --- drivers/iio/proximity/Kconfig | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/iio/proximity/Kconfig b/drivers/iio/proximity/Kconfig index 12a3d3d40a91..e9f254ae3892 100644 --- a/drivers/iio/proximity/Kconfig +++ b/drivers/iio/proximity/Kconfig @@ -68,12 +68,19 @@ config RFD77402 module will be called rfd77402. config SRF04 - tristate "Devantech SRF04 ultrasonic ranger sensor" + tristate "GPIO bitbanged ultrasonic ranger sensor (SRF04, MB1000)" depends on GPIOLIB help - Say Y here to build a driver for Devantech SRF04 ultrasonic + Say Y here to build a driver for GPIO bitbanged ultrasonic ranger sensor. This driver can be used to measure the distance of objects. It is using two GPIOs. + Actually Supported types are: + - Devantech SRF04 + - Maxbotix mb1000 + - Maxbotix mb1010 + - Maxbotix mb1020 + - Maxbotix mb1030 + - Maxbotix mb1040 To compile this driver as a module, choose M here: the module will be called srf04.