From patchwork Tue Jan 11 11:22:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 531291 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 729FEC433FE for ; Tue, 11 Jan 2022 11:22:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238304AbiAKLWw (ORCPT ); Tue, 11 Jan 2022 06:22:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238685AbiAKLWw (ORCPT ); Tue, 11 Jan 2022 06:22:52 -0500 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27A4FC061748 for ; Tue, 11 Jan 2022 03:22:52 -0800 (PST) Received: by mail-pl1-x629.google.com with SMTP id l8so14450773plt.6 for ; Tue, 11 Jan 2022 03:22:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EMXmZlFguOt5qjM8Mju3XqareZLrVjvBoxrDlqW40Jg=; b=UFLB81h0iX3ZqYtdi07F/FwaSLK2hfrLHRXrm+quboO7VeHcwM5jwLhqE6NRgJ68Mm oqkmGHi0Tdk3gJKKrvD93cjMflMetaaCsTxWcDVX6A7icNVuGxJ+RZwWL+V0cK9L5FMx Cpv4tzns3Z9SVuL6P+y5hNNuU7+/6YWG9fuUw= 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=EMXmZlFguOt5qjM8Mju3XqareZLrVjvBoxrDlqW40Jg=; b=ZUTYp29Gl08UC3T5b2yBi0B+/B0IrXM68htFEE01Zpi4dRaU9sMabka4Ibpg6o73DJ Q6edBp3lJ1Xd+sFYoeG3hMPTCT347na2SrjRSQXIkTbi5kVYpkJqg4zml0bTeFbX7GyW E9cMJLVP3T/9h0QSwroawerqFHXSB26K2NTe2YP6lNQtMgpsmHH2e3scYKT1GU/EXSGI IHEybxGXYQ/ClkTHRc3zajN3A7zp2F7G83ea+wx9LPS1KcrW0PhjTigmD+Fj8MqDQYlh KcU4mHqXo98opnIJvlsE9DIYOiuzMjWfxuO3NLGKsfxwNdFp5PiU8ZJ51eIwOoa6SRQ6 EKwQ== X-Gm-Message-State: AOAM532Dnv4v8eJ7ITxBTXs4OK2jXAlATeHuzeC8zYop+YuKQKI6NjQ2 DYWRilGvD7yctFp2VCqz5Asiug== X-Google-Smtp-Source: ABdhPJyGUCS1OeFe84DG12JyMqhdck1JEx4lgTsvVydKsQtX3NxZFt66NL+LGUYUbSR71Xtv63tKYA== X-Received: by 2002:a17:902:7c05:b0:149:a3b4:934c with SMTP id x5-20020a1709027c0500b00149a3b4934cmr3888753pll.42.1641900171738; Tue, 11 Jan 2022 03:22:51 -0800 (PST) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:e7ee:1824:8575:bc5c]) by smtp.gmail.com with ESMTPSA id f9sm2053845pjh.18.2022.01.11.03.22.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jan 2022 03:22:51 -0800 (PST) From: Chen-Yu Tsai To: Sean Wang , Linus Walleij , Matthias Brugger Cc: Chen-Yu Tsai , linux-mediatek@lists.infradead.org, linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Zhiyong Tao , Guodong Liu Subject: [PATCH 1/7] pinctrl: pinconf-generic: Print arguments for bias-pull-* Date: Tue, 11 Jan 2022 19:22:38 +0800 Message-Id: <20220111112244.1483783-2-wenst@chromium.org> X-Mailer: git-send-email 2.34.1.575.g55b058a8bb-goog In-Reply-To: <20220111112244.1483783-1-wenst@chromium.org> References: <20220111112244.1483783-1-wenst@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org The bias-pull-* properties, or PIN_CONFIG_BIAS_PULL_* pin config parameters, accept optional arguments in ohms denoting the strength of the pin bias. Print these values out in debugfs as well. Fixes: eec450713e5c ("pinctrl: pinconf-generic: Add flag to print arguments") Signed-off-by: Chen-Yu Tsai --- drivers/pinctrl/pinconf-generic.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/pinctrl/pinconf-generic.c b/drivers/pinctrl/pinconf-generic.c index f8edcc88ac01..415d1df8f46a 100644 --- a/drivers/pinctrl/pinconf-generic.c +++ b/drivers/pinctrl/pinconf-generic.c @@ -30,10 +30,10 @@ static const struct pin_config_item conf_items[] = { PCONFDUMP(PIN_CONFIG_BIAS_BUS_HOLD, "input bias bus hold", NULL, false), PCONFDUMP(PIN_CONFIG_BIAS_DISABLE, "input bias disabled", NULL, false), PCONFDUMP(PIN_CONFIG_BIAS_HIGH_IMPEDANCE, "input bias high impedance", NULL, false), - PCONFDUMP(PIN_CONFIG_BIAS_PULL_DOWN, "input bias pull down", NULL, false), + PCONFDUMP(PIN_CONFIG_BIAS_PULL_DOWN, "input bias pull down", "ohms", true), PCONFDUMP(PIN_CONFIG_BIAS_PULL_PIN_DEFAULT, - "input bias pull to pin specific state", NULL, false), - PCONFDUMP(PIN_CONFIG_BIAS_PULL_UP, "input bias pull up", NULL, false), + "input bias pull to pin specific state", "ohms", true), + PCONFDUMP(PIN_CONFIG_BIAS_PULL_UP, "input bias pull up", "ohms", true), PCONFDUMP(PIN_CONFIG_DRIVE_OPEN_DRAIN, "output drive open drain", NULL, false), PCONFDUMP(PIN_CONFIG_DRIVE_OPEN_SOURCE, "output drive open source", NULL, false), PCONFDUMP(PIN_CONFIG_DRIVE_PUSH_PULL, "output drive push pull", NULL, false), From patchwork Tue Jan 11 11:22:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 531290 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 94737C433EF for ; Tue, 11 Jan 2022 11:23:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349408AbiAKLW7 (ORCPT ); Tue, 11 Jan 2022 06:22:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349354AbiAKLW4 (ORCPT ); Tue, 11 Jan 2022 06:22:56 -0500 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1C38C061748 for ; Tue, 11 Jan 2022 03:22:56 -0800 (PST) Received: by mail-pj1-x102b.google.com with SMTP id pj2so16633272pjb.2 for ; Tue, 11 Jan 2022 03:22:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YKaz4u+jHXBZ/hE7lcVwwzVS+M4mWSZteuvchYRq/nI=; b=gGo3fMPxrCjwBdkX5n77T17fwS1TD0PV3va335HdH7rjAjuCJ0jAPYlRuotwXbwx62 FR1Vw93XtwPIQGZzMkdQW3ZdXNdqz7TvjYROqPnDGb36AvEUnrzIgJVC7utxf6LpIJca Kthdo7em4vemrrx6zllmjUlfChywO4GB3GN2o= 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=YKaz4u+jHXBZ/hE7lcVwwzVS+M4mWSZteuvchYRq/nI=; b=4BoLqqxdF9AaLxOnl7K9XAyHkCYb6XKMe0aE9NTtp2kOAQc3AN1Wr8eUC3wHf3MX3h AYEGUHRAmBlwkSdeEg6EHzogavCRctH1JW0LEV88Ey7qE5VLAQN556VV+nVO7+GpjSV/ TqntFOWWK1Pntyq2jyeMBE9oEKsrnLeWfmEKy5eR8rmH84Go6MKLOXfUcErCayEv2lZu //KjbWT1mDDlg4JramAgPxaVzh6i5O0LA9QHrh5jR3iplVMS3V76H6sSo32hzUePf9gn lTZp5MeVujwkQzl/jjl2DJd1v/mjGR5czAEssx+melo10lLycS7AJTUqeXoaNRicphkQ cr8w== X-Gm-Message-State: AOAM530earoH6DlJm/dF0r1lOAYGV2gkJbB7mBFgkOUgoiVmedw+gBnp iQM012Og5zA3bCopXgIwJ3kqGg== X-Google-Smtp-Source: ABdhPJz5glPbeZkuNFNbmk+GbZakSX+Fxp59hDSbXI0GT47ku5rb9OI1mykAOShWopjv/FxhhGTH+g== X-Received: by 2002:a63:725a:: with SMTP id c26mr3569100pgn.611.1641900176245; Tue, 11 Jan 2022 03:22:56 -0800 (PST) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:e7ee:1824:8575:bc5c]) by smtp.gmail.com with ESMTPSA id f9sm2053845pjh.18.2022.01.11.03.22.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jan 2022 03:22:55 -0800 (PST) From: Chen-Yu Tsai To: Sean Wang , Linus Walleij , Matthias Brugger Cc: Chen-Yu Tsai , linux-mediatek@lists.infradead.org, linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Zhiyong Tao , Guodong Liu Subject: [PATCH 3/7] pinctrl: mediatek: paris: Fix "argument" argument type for mtk_pinconf_get() Date: Tue, 11 Jan 2022 19:22:40 +0800 Message-Id: <20220111112244.1483783-4-wenst@chromium.org> X-Mailer: git-send-email 2.34.1.575.g55b058a8bb-goog In-Reply-To: <20220111112244.1483783-1-wenst@chromium.org> References: <20220111112244.1483783-1-wenst@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org For mtk_pinconf_get(), the "argument" argument is typically returned by pinconf_to_config_argument(), which holds the value for a given pinconf parameter. It certainly should not have the type of "enum pin_config_param", which describes the type of the pinconf parameter itself. Change the type to u32, which matches the return type of pinconf_to_config_argument(). Fixes: 805250982bb5 ("pinctrl: mediatek: add pinctrl-paris that implements the vendor dt-bindings") Signed-off-by: Chen-Yu Tsai --- drivers/pinctrl/mediatek/pinctrl-paris.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/pinctrl/mediatek/pinctrl-paris.c b/drivers/pinctrl/mediatek/pinctrl-paris.c index 1ca598ea7ba7..d720624d8cd2 100644 --- a/drivers/pinctrl/mediatek/pinctrl-paris.c +++ b/drivers/pinctrl/mediatek/pinctrl-paris.c @@ -188,8 +188,7 @@ static int mtk_pinconf_get(struct pinctrl_dev *pctldev, } static int mtk_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin, - enum pin_config_param param, - enum pin_config_param arg) + enum pin_config_param param, u32 arg) { struct mtk_pinctrl *hw = pinctrl_dev_get_drvdata(pctldev); const struct mtk_pin_desc *desc; From patchwork Tue Jan 11 11:22:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 531289 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 8626EC433F5 for ; Tue, 11 Jan 2022 11:23:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349409AbiAKLXG (ORCPT ); Tue, 11 Jan 2022 06:23:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349440AbiAKLXC (ORCPT ); Tue, 11 Jan 2022 06:23:02 -0500 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A32F8C06175C for ; Tue, 11 Jan 2022 03:23:01 -0800 (PST) Received: by mail-pj1-x1034.google.com with SMTP id lr15-20020a17090b4b8f00b001b19671cbebso5251245pjb.1 for ; Tue, 11 Jan 2022 03:23:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1fEL/KVXQTE5AFQeTwaZaRarWCZCE1VjWBv8zykoqdY=; b=QvkvjmrvGZQq6KX1p+b9jRBnwdYwTHBqvdbuW/mMltZPFt0nG/YHdjgwUaIK+CXEbc RC96srRjO9HMfi5xOAbvokyZ4lS5um5OsYATwqKsAlnI0XrhDFMsS5udxTpXCST/JAio D5x9YVt4OjqNJiAHP0wwVs2J3PRVrLwrEPXjE= 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=1fEL/KVXQTE5AFQeTwaZaRarWCZCE1VjWBv8zykoqdY=; b=y5PWxiHnYlPbwVlCz2cAbRGZjx0j0WauZNCw+i9TCEGUXbdQ71ProWPcTciyibVfiY x/kzL25txcMMxiH1xajRYs4pDcQtQ3dSWpA7mQjFekWkMaEN5g8XfM68ZTkHYDg1qDg6 A9Zkq9GrTZLQezarfP2d5mIQCmJ9hbj+B4ZgJtDkfFHaFDKE1hVKPxIo5qi4tgGxXfuu BcEudUm6WNDZRC/8uqFvnhKZg3S6TMl9e1++k0RIxglQL4S+oa54Jx6Dkk+54avUENKj giBzXW4MyOr2zzdXXVclwcNIGrTqSeH1tPoS/Lg5bwASDrGc/n3nHXnzJBEEB2+EUmQX MpqQ== X-Gm-Message-State: AOAM533ldakQOdscSnbFGimgQ/H0EkWgM/M1oBuiQVa5NaF/qDG+f3TV B2N2lGC7FzpHqqaKinVGdvzXmw== X-Google-Smtp-Source: ABdhPJxDZb8hKxuj9Fyjpv8O0cKzuluDJhQ8YRywEa9PHkMM1/QHq5Y5ZmWv+lFYPzArvfca0QIniQ== X-Received: by 2002:a17:903:110d:b0:149:a833:af21 with SMTP id n13-20020a170903110d00b00149a833af21mr4177450plh.14.1641900181239; Tue, 11 Jan 2022 03:23:01 -0800 (PST) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:e7ee:1824:8575:bc5c]) by smtp.gmail.com with ESMTPSA id f9sm2053845pjh.18.2022.01.11.03.22.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jan 2022 03:23:00 -0800 (PST) From: Chen-Yu Tsai To: Sean Wang , Linus Walleij , Matthias Brugger Cc: Chen-Yu Tsai , linux-mediatek@lists.infradead.org, linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Zhiyong Tao , Guodong Liu Subject: [PATCH 5/7] pinctrl: mediatek: paris: Drop extra newline in mtk_pctrl_show_one_pin() Date: Tue, 11 Jan 2022 19:22:42 +0800 Message-Id: <20220111112244.1483783-6-wenst@chromium.org> X-Mailer: git-send-email 2.34.1.575.g55b058a8bb-goog In-Reply-To: <20220111112244.1483783-1-wenst@chromium.org> References: <20220111112244.1483783-1-wenst@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org The caller of mtk_pctrl_show_one_pin() is responsible for printing the full line. mtk_pctrl_show_one_pin(), called through mtk_pctrl_dbg_show(), should only produce a string containing the extra information the driver wants included. Drop the extra newlines. Fixes: 184d8e13f9b1 ("pinctrl: mediatek: Add support for pin configuration dump via debugfs.") Fixes: fb34a9ae383a ("pinctrl: mediatek: support rsel feature") Signed-off-by: Chen-Yu Tsai --- drivers/pinctrl/mediatek/pinctrl-paris.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/pinctrl/mediatek/pinctrl-paris.c b/drivers/pinctrl/mediatek/pinctrl-paris.c index d259f075c62d..1bacabfbc183 100644 --- a/drivers/pinctrl/mediatek/pinctrl-paris.c +++ b/drivers/pinctrl/mediatek/pinctrl-paris.c @@ -639,12 +639,10 @@ ssize_t mtk_pctrl_show_one_pin(struct mtk_pinctrl *hw, pullup); if (r1 != -1) { - len += scnprintf(buf + len, buf_len - len, " (%1d %1d)\n", + len += scnprintf(buf + len, buf_len - len, " (%1d %1d)", r1, r0); } else if (rsel != -1) { - len += scnprintf(buf + len, buf_len - len, " (%1d)\n", rsel); - } else { - len += scnprintf(buf + len, buf_len - len, "\n"); + len += scnprintf(buf + len, buf_len - len, " (%1d)", rsel); } return len; From patchwork Tue Jan 11 11:22:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 531288 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 0B9BAC433FE for ; Tue, 11 Jan 2022 11:23:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349456AbiAKLXI (ORCPT ); Tue, 11 Jan 2022 06:23:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349422AbiAKLXG (ORCPT ); Tue, 11 Jan 2022 06:23:06 -0500 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63A82C06173F for ; Tue, 11 Jan 2022 03:23:06 -0800 (PST) Received: by mail-pl1-x631.google.com with SMTP id e19so9966546plc.10 for ; Tue, 11 Jan 2022 03:23:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MO9C+/y7rlHj27Tk0Qv7Ks5nBGk0gl8cyNWfCGutHPg=; b=XMNyqW3ffjGD7aCP26DsYfNkvK9ie+mUzx3cG++ZVjFOqppMcKCPt/SaXT9UO5JD6W 13iklO18M+gyAsiV7wMHy5puKvT6Pt4MaWcgg5Rj/64i+CICBfFPyisF5bhP4SCLrPMJ 7dpzceifRZu8dB+5qU1lNWREKlqsVtIhxetVA= 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=MO9C+/y7rlHj27Tk0Qv7Ks5nBGk0gl8cyNWfCGutHPg=; b=K00IzkEhwRUR8IRrGgFLtgfr9yH/bLH122KHmI8+mqvlxqCxKXh7laIlS8okE21htc /xm+k4PmOqHWjGTo75UbmXebMePLmGPWHMr4CuMszhyrXqRU3XSnJ3s58x5NtnhiS4Lw MFxq44Z/86yZpPD3Y9yS7AkyRlmzDptrjXof+RI5eT3KnBsPWhYtCe7imCBB2WB9ffaG fjFRqdNNcXXWTttRf7O61v/Z/4sP6RfE3x4CZjou+F4CVpQli4IK2ZPEso9GHdWS1AU6 aVx9l4ahEX7OcpOSIMpxyAuPAHf1l1n00ap0HIOuJcq7LSX8lYWmtMTCLZhBEZVTr+DL h+qA== X-Gm-Message-State: AOAM531MRIU3ahJKPbZrhJgzpSVfbU9aPtQa6qNx1XtElhv1t9vVtKyU ZkzNnH8wgABLFdm415IKIaGTWA== X-Google-Smtp-Source: ABdhPJyjOgTnrtdJ0sLFZX6lDQMnLzWQ2b3meTpTPAGNIGTegsNduPt3LuE/Tfw99opR/kwqXQcJHg== X-Received: by 2002:a17:902:9a02:b0:14a:6a3:6c68 with SMTP id v2-20020a1709029a0200b0014a06a36c68mr4116724plp.138.1641900185952; Tue, 11 Jan 2022 03:23:05 -0800 (PST) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:e7ee:1824:8575:bc5c]) by smtp.gmail.com with ESMTPSA id f9sm2053845pjh.18.2022.01.11.03.23.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jan 2022 03:23:05 -0800 (PST) From: Chen-Yu Tsai To: Sean Wang , Linus Walleij , Matthias Brugger Cc: Chen-Yu Tsai , linux-mediatek@lists.infradead.org, linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Zhiyong Tao , Guodong Liu Subject: [PATCH 7/7] pinctrl: mediatek: paris: Support generic PIN_CONFIG_DRIVE_STRENGTH_UA Date: Tue, 11 Jan 2022 19:22:44 +0800 Message-Id: <20220111112244.1483783-8-wenst@chromium.org> X-Mailer: git-send-email 2.34.1.575.g55b058a8bb-goog In-Reply-To: <20220111112244.1483783-1-wenst@chromium.org> References: <20220111112244.1483783-1-wenst@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Some of the MediaTek chips that utilize the Paris pinctrl driver library support a lower drive strength (<= 1mA) than the standard drive strength settings (2~16 mA) on certain pins. This was previously supported by the custom MTK_PIN_CONFIG_DRV_ADV parameter along with the "mediatek,drive-strength-adv" device tree property. The drive strength values for this hardware are 125, 250, 500, and 1000 mA, and can be readily described by the existing "drive-strength-microamp", which then gets parsed by the generic pinconf library into the parameter PIN_CONFIG_DRIVE_STRENGTH_UA. Add support for PIN_CONFIG_DRIVE_STRENGTH_UA while keeping the old custom parameter around for backward compatibility. Signed-off-by: Chen-Yu Tsai --- The indentation in the switch/case blocks is getting somewhat out of control. I also have some cleanup changes to reverse the logic of the if/break statements. Not sure if it should be done before or after this patch though. --- drivers/pinctrl/mediatek/pinctrl-paris.c | 84 ++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/drivers/pinctrl/mediatek/pinctrl-paris.c b/drivers/pinctrl/mediatek/pinctrl-paris.c index 678c8aa33012..5a94903ae372 100644 --- a/drivers/pinctrl/mediatek/pinctrl-paris.c +++ b/drivers/pinctrl/mediatek/pinctrl-paris.c @@ -48,6 +48,53 @@ static const char * const mtk_gpio_functions[] = { "func12", "func13", "func14", "func15", }; +/* + * This section supports converting to/from custom MTK_PIN_CONFIG_DRV_ADV + * and standard PIN_CONFIG_DRIVE_STRENGTH_UA pin configs. + * + * The custom value encodes three hardware bits as follows: + * + * | Bits | + * | 2 (E1) | 1 (E0) | 0 (EN) | drive strength (uA) + * ------------------------------------------------ + * | x | x | 0 | disabled, use standard drive strength + * ------------------------------------- + * | 0 | 0 | 1 | 125 uA + * | 0 | 1 | 1 | 250 uA + * | 1 | 0 | 1 | 500 uA + * | 1 | 1 | 1 | 1000 uA + */ +static const int mtk_drv_adv_uA[] = { 125, 250, 500, 1000 }; + +static int mtk_drv_adv_to_uA(int val) +{ + /* This should never happen. */ + if (WARN_ON_ONCE(val < 0 || val > 7)) + return -EINVAL; + + /* Bit 0 simply enables this hardware part */ + if (!(val & BIT(0))) + return -EINVAL; + + return mtk_drv_adv_uA[(val >> 1)]; +} + +static int mtk_drv_uA_to_adv(int val) +{ + switch (val) { + case 125: + return 0x1; + case 250: + return 0x3; + case 500: + return 0x5; + case 1000: + return 0x7; + } + + return -EINVAL; +} + static int mtk_pinmux_gpio_request_enable(struct pinctrl_dev *pctldev, struct pinctrl_gpio_range *range, unsigned int pin) @@ -151,11 +198,38 @@ static int mtk_pinconf_get(struct pinctrl_dev *pctldev, break; case PIN_CONFIG_DRIVE_STRENGTH: + if (hw->soc->adv_drive_get) { + err = hw->soc->adv_drive_get(hw, desc, &ret); + if (!err) { + err = mtk_drv_adv_to_uA(ret); + if (err > 0) { + /* PIN_CONFIG_DRIVE_STRENGTH_UA used */ + err = -EINVAL; + break; + } + } + } + if (hw->soc->drive_get) err = hw->soc->drive_get(hw, desc, &ret); else err = -ENOTSUPP; break; + case PIN_CONFIG_DRIVE_STRENGTH_UA: + if (hw->soc->adv_drive_get) { + err = hw->soc->adv_drive_get(hw, desc, &ret); + if (err) + break; + err = mtk_drv_adv_to_uA(ret); + if (err < 0) + break; + + ret = err; + err = 0; + } else { + err = -ENOTSUPP; + } + break; case MTK_PIN_CONFIG_TDSEL: case MTK_PIN_CONFIG_RDSEL: reg = (param == MTK_PIN_CONFIG_TDSEL) ? @@ -271,6 +345,16 @@ static int mtk_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin, else err = -ENOTSUPP; break; + case PIN_CONFIG_DRIVE_STRENGTH_UA: + if (hw->soc->adv_drive_set) { + err = mtk_drv_uA_to_adv(arg); + if (err < 0) + break; + err = hw->soc->adv_drive_set(hw, desc, err); + } else { + err = -ENOTSUPP; + } + break; case MTK_PIN_CONFIG_TDSEL: case MTK_PIN_CONFIG_RDSEL: reg = (param == MTK_PIN_CONFIG_TDSEL) ?