Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1194632pxb; Fri, 26 Feb 2021 05:07:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJxpyzXsEWGNplSoj8eNhB/Y3uLbfMNrEBw3lkcaqqFmVd47kPaLcBoO2cNX0XltuXGROEJq X-Received: by 2002:a50:ee16:: with SMTP id g22mr3336831eds.235.1614344858554; Fri, 26 Feb 2021 05:07:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614344858; cv=none; d=google.com; s=arc-20160816; b=JweWr1LzXKKuTRWK7lbq633soJmxkwo8P339X0qZ755zujaYTKRGtw3awskIuhpTGE LEhwASrHbnxVMjCFJkkBmreSOaEp1Qk3TxrVjTxuFfkJbdKFvc7/SZYeidXVdJasySyJ +ihg9yjLVUHfqWDRMkaTEJxdyTzQwW0PnU+ILxBk6DCtp+Jn0eO3FaKAfSv7eTRDjXS8 2aJtFsv7ovNBdamF1rwRYu3akwxxOeDFKo+7pfXwCVWHLGYjFQzykiYrZpU3pNzh0pxt lUjI9ql3QgDogzvS/aD2CklvgcnajmFcU11hTEGst0tHUoT6Ad9IMXUSGRUJjjuOqaYK a3sA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=xM/sjEHiF877eQT26YxoH8svJxeu8Y2PLjYY6WLJjuo=; b=G5b4XHNxdPpVevNwcI6VWfCLWoAhCvZEdHuPeBGDEvSLA3KbbltbwkWLJS0HQTvUhd 4E9pEdRrLv4MxXlQGbmqBAZpoKbEnjVhjFWMOR/4fZ22wBkkD0LzcupagnHPsAc7Q4sA iE6Myiv5wtHycnTHa/oZySznHSOebvIHwJSIPvb5f3hvtFXAz3oikBgOJA7zVJ20gG1I bkYWwefigbYip+9qivUgUoYqevZ0bwCnbNSPJnXtSKqtSkqlvSlE7i3Cq4qsAWJCuLv0 79Cf5fU0y/zLm/D4tUgf/2ZDA0E3D20rhEWsD8X6xrdQYcxQB+uyRmau/hHVUREppHrr yW1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@aruba.it header.s=a1 header.b="Bgn/1OvK"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t19si5106435ejd.179.2021.02.26.05.07.14; Fri, 26 Feb 2021 05:07:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@aruba.it header.s=a1 header.b="Bgn/1OvK"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230084AbhBZNEX (ORCPT + 99 others); Fri, 26 Feb 2021 08:04:23 -0500 Received: from smtpcmd03117.aruba.it ([62.149.158.117]:47112 "EHLO smtpcmd03117.aruba.it" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230079AbhBZNEO (ORCPT ); Fri, 26 Feb 2021 08:04:14 -0500 X-Greylist: delayed 573 seconds by postgrey-1.27 at vger.kernel.org; Fri, 26 Feb 2021 08:04:13 EST Received: from [192.168.1.133] ([79.10.42.7]) by Aruba Outgoing Smtp with ESMTPA id FccKlzwPoGnOmFccLlJn3t; Fri, 26 Feb 2021 13:53:17 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=aruba.it; s=a1; t=1614343997; bh=2rMVWXF8lNyJSU6nmJKiXTRpfRlzP9TAQ8yJ4iqi81E=; h=Subject:To:From:Date:MIME-Version:Content-Type; b=Bgn/1OvKfYcIJNO21gMdg2O88WFu3JpJ9dDm51f2mxa55QKDlLAQXiQUqUxKiz6de LOb7q1xcsELgYdKq3AL4bUezqyWIcxBabFmao0qCZBg+3t6RgFZ6/r98tSqaEkxUst VvE1xDXEGR7ShvfkOMgZmR54n5olw1jg5Wx6ZR+7H3shorJKhufOLQ+dYfeOtV26Go 52UBgAZkjcxuAhnTPVZFTFabrtBVEOTe4a5ynfZYQR7ZTnF3YluMV4qkKV4AXxSlZZ 9OxnYQwhDarwQnAri5u1MUuAH3bqtcJvgLsQstAg34uiF6B3IIE/pp/hCVq6/5vsVR SiABdtLR28qDg== Subject: Re: [PATCH] pinctrl/sunxi: adding input-debounce-ns property To: Maxime Ripard Cc: wens@csie.org, Jernej Skrabec , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20210114081732.9386-1-giulio.benetti@benettiengineering.com> <20210114114219.faulkwww3dhdqwmc@gilmour> <20210217110313.ly5ly5u5vyh2s7dh@gilmour> From: Marjan Pascolo Message-ID: <4171ad5c-97f1-5738-9127-078fea74bbf7@trexom.it> Date: Fri, 26 Feb 2021 13:53:00 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <20210217110313.ly5ly5u5vyh2s7dh@gilmour> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit Content-Language: it X-CMAE-Envelope: MS4wfPSXGG2O58ymEadOQn9t3b2CCvFJTGHtNrRAPDC5W/xe1ILKrHnZO0KXAe8IZ7oulpWh8RqmtHEnuIvk97tvC62odHVmCLVdoI3M0QHX730+Kygp5kgh Msq4dcnpSf2AM7oaZ0LSdE2MFzojJgb2G+zqw0V1G0ovJxbARr5yTzRrd2roX9Gw9TrpzKumr52fzykfGniU8F9w78D0RV+7jZo/e/9iHfbsTKynJmwiLqhJ G9OUDJSKoCd943+EFZMRjPLIzQz0mhi0TNAcHUW6UmC5dxGs5+UZw8fuAIcgJHg8Xc0qSARK+ljQWUy5DhwRplZqwagbtZ3IW0R0ye+xaYRlDwnfr6XQiVso gfa/ilDCq2nK0NHLUoZKWViwCQCPrA== Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Maxime, Il 17/02/2021 12:03, Maxime Ripard ha scritto: > Hi, > > On Wed, Feb 10, 2021 at 05:22:37PM +0100, Marjan Pascolo wrote: >> 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(-) >> >> 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 >> --- >> 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 >> + > This should be a separate patch, with the DT maintainers in Cc. > > You should enforce that the properties are mutually exclusive through > the schema too I'm sorry, I've ignored documentaion about /Documentation. I see that some additional YAML operator (like oneOf) are used. oneOf should fit the schema, but I can't understand if oneOf's options must be a literal value, or if could also be a node. Otherwise I'll use if ..then..else. > >> ?patternProperties: >> ?? # It's pretty scary, but the basic idea is that: >> ?? #?? - One node name can start with either s- or r- for PRCM nodes, >> 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 >> +??? ?*/ >> + > I'm not sure that comment should stay, the code is obvious enough > >> ???? /* 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; >> +??? } > This doesn't follow the kernel coding style, make sure to run > scripts/checkpatch.pl on your patches before sending them. Spaces between operators, right. After /Documentation submission I'll resubmit this one > > Maxime