Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2166043ybb; Thu, 2 Apr 2020 14:35:12 -0700 (PDT) X-Google-Smtp-Source: APiQypLK2GsIFPfkGk1q9zDiQLZy9dwudfOqSy1nPx8h0TDg8lRrJXN+45l3ARv62U7MBSYGThfr X-Received: by 2002:a9d:6c4c:: with SMTP id g12mr3785518otq.351.1585863311891; Thu, 02 Apr 2020 14:35:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585863311; cv=none; d=google.com; s=arc-20160816; b=zUdUCrJLVsLgzFCLcYMEALCKSAh4O4JKR30jkOa0lAZB24UHf3fpqwRBfGyRqC28ms JkQ9KrHLtnImcemKKMmw2y9IlOvJm5YtRa9bkOBvZEdk6tDa5oGXFMTVqQwcAiTG6C8C d3zCmFRM6ujtC5dVfrt0n5BH6R9WASEijKyG6lNL/NUweebbsVTM3UoJtThNkIpZpbjo t0Pa1PDT5NIAWm1usyZiuWt6F7lCHZ9qR5YquNxwp32VtR7gl28HdDvJ8mzc2aZjCLHX iFSaZxjlrqj2Aa1YYei5xBwDMTQ0QrNM4hlwnQLUCMYqT/4Gcis5whtOW+Xqx9EHxPUt sY1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=+JsxtmrcmdlqGDA3+mJbsMgOiKYPHhkHfTuXPyU1zmg=; b=Jp9lQ5XskLcQvAgE5xtPzOEpl7AKAPD0FxakATyPizF0oH28J6xFw4Q975Y3udrv33 4n2wqA+W2+MFMt5fC8c9TjDdfYL2ECk4MJP5vZMiVsZp5ctlgNP7tkkCfTkSbqi9WfKw bYgyoHP9l0v8zVVNueXKCU1dtLjqDR45p1ajQXstFuNg1dELR65CwVPvef2r6VI6CGiK oUZvofa18A4dfapMgey5rYUpGlva24A2FYYaJBGBoQZRdJ+ZKj86JFpFLu3dX9T87z1R pvrEz6PCl6wzDP70mgrmcZEMtHbVPgfKCFIWW7OT6oupO6uR+c93tlPW6jeugvG+yy3q dvzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="auTMkc/6"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l6si2730894otf.248.2020.04.02.14.34.58; Thu, 02 Apr 2020 14:35:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="auTMkc/6"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388698AbgDBVdP (ORCPT + 99 others); Thu, 2 Apr 2020 17:33:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:41412 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726963AbgDBVdO (ORCPT ); Thu, 2 Apr 2020 17:33:14 -0400 Received: from mail-io1-f49.google.com (mail-io1-f49.google.com [209.85.166.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 818A0208E0; Thu, 2 Apr 2020 21:33:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585863193; bh=sEbEJDY3uNsFFQnIzWiH4TyvsZPJRza9p71kK+FQIQs=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=auTMkc/6TL7cwsVXVtygaZtVE/9AzLt81Z/XNW07UPnrdMbVjTiL7U0M76RnFoOvX wzlk5B3vIBkru25w47rgFhHhba5hb5bfo3PFYA4NlbbpkxF3/XKI7wACPLPYTIeYzB nCf1vrK6BtDg4hGPROfuKSOBxnAeUFnPPqE/7NrE= Received: by mail-io1-f49.google.com with SMTP id y14so5239456iol.12; Thu, 02 Apr 2020 14:33:13 -0700 (PDT) X-Gm-Message-State: AGi0PuZlKhqO5UdIbjK7owat12387u3j0MSr8lVGFf47tuQiG8pMLugB ZToCUMT3jaNigg3tkk2UzPQ5qaSoWRxJbRrIHBM= X-Received: by 2002:a02:a785:: with SMTP id e5mr5232296jaj.97.1585863192871; Thu, 02 Apr 2020 14:33:12 -0700 (PDT) MIME-Version: 1.0 References: <1585128694-13881-1-git-send-email-hanks.chen@mediatek.com> <1585128694-13881-4-git-send-email-hanks.chen@mediatek.com> In-Reply-To: <1585128694-13881-4-git-send-email-hanks.chen@mediatek.com> From: Sean Wang Date: Thu, 2 Apr 2020 14:33:01 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v5 3/6] pinctrl: mediatek: avoid virtual gpio trying to set reg To: Hanks Chen Cc: Linus Walleij , Rob Herring , Mark Rutland , Matthias Brugger , Andy Teng , lkml , "moderated list:ARM/Mediatek SoC support" , devicetree@vger.kernel.org, wsd_upstream@mediatek.com, Mars Cheng Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Hanks, On Wed, Mar 25, 2020 at 2:31 AM Hanks Chen wrote: > > for virtual gpios, they should not do reg setting and > should behave as expected for eint function. > > Signed-off-by: Hanks Chen > Signed-off-by: Mars Cheng > --- > drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c | 28 ++++++++++++++++++++++ > drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h | 1 + > drivers/pinctrl/mediatek/pinctrl-paris.c | 7 ++++++ > 3 files changed, 36 insertions(+) > > diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c > index 20e1c89..087d233 100644 > --- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c > +++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c > @@ -226,6 +226,31 @@ static int mtk_xt_find_eint_num(struct mtk_pinctrl *hw, unsigned long eint_n) > return EINT_NA; > } > > +/* > + * Virtual GPIO only used inside SOC and not being exported to outside SOC. > + * Some modules use virtual GPIO as eint (e.g. pmif or usb). > + * In MTK platform, external interrupt (EINT) and GPIO is 1-1 mapping > + * and we can set GPIO as eint. > + * But some modules use specific eint which doesn't have real GPIO pin. > + * So we use virtual GPIO to map it. > + */ > + > +bool mtk_is_virt_gpio(struct mtk_pinctrl *hw, unsigned int gpio_n) > +{ > + const struct mtk_pin_desc *desc; > + bool virt_gpio = false; > + > + if (gpio_n >= hw->soc->npins) > + return virt_gpio; gpio_n should always be less than hw-> soc-> npins, right? If so, we can delete the condition from here. > + > + desc = (const struct mtk_pin_desc *)&hw->soc->pins[gpio_n]; > + > + if (desc->funcs && !desc->funcs[desc->eint.eint_m].name) > + virt_gpio = true; > + > + return virt_gpio; > +} > + > static int mtk_xt_get_gpio_n(void *data, unsigned long eint_n, > unsigned int *gpio_n, > struct gpio_chip **gpio_chip) > @@ -278,6 +303,9 @@ static int mtk_xt_set_gpio_as_eint(void *data, unsigned long eint_n) > if (err) > return err; > > + if (mtk_is_virt_gpio(hw, gpio_n)) > + return 0; > + > desc = (const struct mtk_pin_desc *)&hw->soc->pins[gpio_n]; > > err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_MODE, > diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h > index 1b7da42..cda1c7a0 100644 > --- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h > +++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h > @@ -299,4 +299,5 @@ int mtk_pinconf_adv_drive_set(struct mtk_pinctrl *hw, > int mtk_pinconf_adv_drive_get(struct mtk_pinctrl *hw, > const struct mtk_pin_desc *desc, u32 *val); > > +bool mtk_is_virt_gpio(struct mtk_pinctrl *hw, unsigned int gpio_n); > #endif /* __PINCTRL_MTK_COMMON_V2_H */ > diff --git a/drivers/pinctrl/mediatek/pinctrl-paris.c b/drivers/pinctrl/mediatek/pinctrl-paris.c > index 923264d..7fba76d 100644 > --- a/drivers/pinctrl/mediatek/pinctrl-paris.c > +++ b/drivers/pinctrl/mediatek/pinctrl-paris.c > @@ -693,6 +693,13 @@ static int mtk_gpio_get_direction(struct gpio_chip *chip, unsigned int gpio) > const struct mtk_pin_desc *desc; > int value, err; > > + /* > + * "Virtual" GPIOs are always and only used for interrupts > + * Since they are only used for interrupts, they are always inputs > + */ > + if (mtk_is_virt_gpio(hw, gpio)) > + return 1; > + > desc = (const struct mtk_pin_desc *)&hw->soc->pins[gpio]; > > err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_DIR, &value); > -- > 1.7.9.5