From patchwork Wed Feb 10 16:22:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Marjan Pascolo X-Patchwork-Id: 12081153 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31968C433DB for ; Wed, 10 Feb 2021 16:27:54 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E2F1760C3F for ; Wed, 10 Feb 2021 16:27:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E2F1760C3F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=trexom.it Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4E9676ECB6; Wed, 10 Feb 2021 16:27:53 +0000 (UTC) Received: from smtpcmd0642.aruba.it (smtpcmd0642.aruba.it [62.149.156.42]) by gabe.freedesktop.org (Postfix) with ESMTP id 804876E0BC for ; Wed, 10 Feb 2021 16:22:42 +0000 (UTC) Received: from [192.168.1.184] ([79.10.42.7]) by Aruba Outgoing Smtp with ESMTPA id 9sGEl0x2gl6ts9sGElboW6; Wed, 10 Feb 2021 17:22:40 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=aruba.it; s=a1; t=1612974160; bh=+zT/ViXdsyEqsM0XxHGfPKmXnHFZ85zQgkpYMgBh4Oo=; h=Subject:To:From:Date:MIME-Version:Content-Type; b=KZRe+R9tdGmlGRClWHts7qbM0AWGy6q8nqNyi04jXGTU8LIdASdhyQ7BH+gCswyha kzN4Ke8kQ2Cy6eyOZI5MTXLqzpf4XW49Cic0UNmD5KyChQzHoSgOCk1krEtxJ9K4/c WBNiWfoTdcpwDI/kSTmjTVSDLv7s0UdXpp5iDzV/DPmigVnHDOzMoiQaORVFFTgpOz UUnyr2bf3j/0N0BXfwZdCRU1+On7qJguMG53FMBaGgZZNBN5bCZBSQF6/93Nlm0O3D 7q1CsUjb/FAiDXdCOCsZ7aU5By1owYruUoJemu7wLTcT5SUbG/H1MN4wzwh5tJxOhB KvChlSqrzX+Yg== Subject: [PATCH] pinctrl/sunxi: adding input-debounce-ns property To: Maxime Ripard , wens@csie.org, Jernej Skrabec References: <20210114081732.9386-1-giulio.benetti@benettiengineering.com> <20210114114219.faulkwww3dhdqwmc@gilmour> From: Marjan Pascolo Message-ID: Date: Wed, 10 Feb 2021 17:22:37 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-Version: 1.0 In-Reply-To: <20210114114219.faulkwww3dhdqwmc@gilmour> Content-Language: it X-CMAE-Envelope: MS4wfH6oTAFv1UAc1UHjeT7fAUES0ERDDBsJcmnoqFOgFC4ptHAeVTLQat5FeTa3CPXA5acPN5BTNTXELXNkmdiwK4JcdZovN+luGUaxplPcy95PLoftAoUr M5mpLLDSjADTP7z+8Ou0rzlTA6ofdIK6AiHqwlfsmOEPQTGD1feR+1zp6kUEs0dQHr2AL3VLgpUIt+qQ3qqNqRGPF41/LkEK0HuBtmvn4CvQ875aG7XWb59t uneMi4ET4xtInHSFyOf7NCULykYkLkFIP+EqY+ygFeWFqUada0m8ywN0eWwtru5r261rWaqYkbSJX4sxRnxsXxD0yJb/FalRjeGQ8RHOhJlYTdMjMcaEPKtK R/CH/zYX3rdF0oGLCcE1ErnL8nsZBA== X-Mailman-Approved-At: Wed, 10 Feb 2021 16:27:52 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Allwinner SoC interrupt debounce can be controlled by two oscillator (32KHz and 24MHz) and a prescale divider. Oscillator and prescale divider are set through device tree property "input-debounce" which have 1uS accuracy. For acheive nS precision a new device tree poperty is made named "input-debounce-ns". "input-debounce-ns" is checked only if "input-debounce" property is not defined. Suggested-by: Maxime Ripard Signed-off-by: Marjan Pascolo --- ---  .../pinctrl/allwinner,sun4i-a10-pinctrl.yaml  |  9 +++++++  drivers/pinctrl/sunxi/pinctrl-sunxi.c         | 25 ++++++++++++++++---  2 files changed, 30 insertions(+), 4 deletions(-) a/Documentation/devicetree/bindings/pinctrl/allwinner,sun4i-a10-pinctrl.yaml +++ b/Documentation/devicetree/bindings/pinctrl/allwinner,sun4i-a10-pinctrl.yaml @@ -93,6 +93,15 @@ properties:      minItems: 1      maxItems: 5 +  input-debounce-ns: +    description: +      Debouncing periods in nanoseconds, one period per interrupt +      bank found in the controller. +      Only checked if input-debounce is not present +    $ref: /schemas/types.yaml#/definitions/uint32-array +    minItems: 1 +    maxItems: 5 +  patternProperties:    # It's pretty scary, but the basic idea is that:    #   - One node name can start with either s- or r- for PRCM nodes,      if (IS_ERR(losc)) @@ -1356,7 +1373,7 @@ static int sunxi_pinctrl_setup_debounce(struct sunxi_pinctrl *pctl,          unsigned long debounce_freq;          u32 debounce; -        ret = of_property_read_u32_index(node, "input-debounce", +        ret = of_property_read_u32_index(node, debounce_prop_name,                           i, &debounce);          if (ret)              return ret; @@ -1364,7 +1381,7 @@ static int sunxi_pinctrl_setup_debounce(struct sunxi_pinctrl *pctl,          if (!debounce)              continue; -        debounce_freq = DIV_ROUND_CLOSEST(USEC_PER_SEC, debounce); +        debounce_freq = DIV_ROUND_CLOSEST(debounce_dividend, debounce);          losc_div = sunxi_pinctrl_get_debounce_div(losc,                                debounce_freq,                                &losc_diff); diff --git a/Documentation/devicetree/bindings/pinctrl/allwinner,sun4i-a10-pinctrl.yaml b/Documentation/devicetree/bindings/pinctrl/allwinner,sun4i-a10-pinctrl.yaml index 5240487dfe50..346776de3a44 100644 --- diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c b/drivers/pinctrl/sunxi/pinctrl-sunxi.c index dc8d39ae045b..869b6d5743ba 100644 --- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c +++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c @@ -1335,14 +1335,31 @@ static int sunxi_pinctrl_setup_debounce(struct sunxi_pinctrl *pctl,      struct clk *hosc, *losc;      u8 div, src;      int i, ret; +    /* Keeping for loop below clean */ +    const char* debounce_prop_name; +    unsigned long debounce_dividend;      /* Deal with old DTs that didn't have the oscillators */      if (of_clk_get_parent_count(node) != 3)          return 0; +    /* +     * Distinguish between simple input-debounce +     * and new input-debounce-ns +     */ +      /* If we don't have any setup, bail out */ -    if (!of_find_property(node, "input-debounce", NULL)) -        return 0; +    if (!of_find_property(node, "input-debounce", NULL)) { +        if(!of_find_property(node, "input-debounce-ns", NULL)) { +            return 0; +        } else { +            debounce_prop_name="input-debounce-ns"; +            debounce_dividend=NSEC_PER_SEC; +        } +    } else { +        debounce_prop_name="input-debounce"; +        debounce_dividend=USEC_PER_SEC; +    }      losc = devm_clk_get(pctl->dev, "losc");