Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2461216ybl; Mon, 19 Aug 2019 02:24:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqz6mYTFy8saKuYnMEJ3grHZjXFMudFvpIorYCoHqBJj4Yee8iPJHBsfMyo/ABv6lYMuowj4 X-Received: by 2002:a17:90a:240e:: with SMTP id h14mr20660581pje.9.1566206676721; Mon, 19 Aug 2019 02:24:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566206676; cv=none; d=google.com; s=arc-20160816; b=LjxWxd8ekhQ5kENT+RM1Sr0auUVCEyNE2nFc5Mgf+Bdmum0a3fkKPatVHD+wLt/VQn x24Kn2VJsZ/sFDr61bqSDXqey8d514GlXwSXv2vOvl7g1WWU6ZzZ98JjkrmMKH8vv3Zc zfdbkuiofKBzNXyiIJBcLYsVhEFhaczqsFXaFwCiHUBle9G4Mhz4zwSUAarIcOU0YWbw /8YAIhYxXcLMzwjY4owZIH5OZKkQHnGhfj5PKEMOpY97Hxho+YBn1oPe/HMn0sBzWLWb bLgPPivpEDXUwdaUiC0IDs9GuBk5vBPWAGdVV2kMx1oeEP7VgAzne9n0pmo8HOC/OC8w ekFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=23dHaY3O4EQi5wkrojgOizTJlDyX1RosPEvzhwuCKdw=; b=ZfCYY83yqL0jwNRy+zHu17whw7kjINP7kwx8kNHy5fNW+dl8ZYVA+e5yGVuOK9V8p6 giXE5G584kHct/qXG6WGfkAQ0AQR4kW4S+s7komsj/WW2oWzmLcVaeaywEVMoJXfrl5i yojuchPAAe9sQuuI3e1QoFysAyXG8TaqUUyAwXPCdNzHndOinPDIQrvrk1qYp/3vnZYL 9aRCXNbf/Mz6Fk407kblAbaACnpseqJy36q9BYS1gZ8LYOGPu0vuP1qb4F0yOaj1nS1C ImzwuwCMw+0wXbRts8XURAUiEOytqIKY8hxmmKaJmVJPICAvrJDgSBNe5serIaa2dTbd 3GSw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cm1si8460158pjb.12.2019.08.19.02.24.21; Mon, 19 Aug 2019 02:24:36 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727391AbfHSJWP (ORCPT + 99 others); Mon, 19 Aug 2019 05:22:15 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:37221 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1727440AbfHSJWN (ORCPT ); Mon, 19 Aug 2019 05:22:13 -0400 X-UUID: abfc1859baa44d10b49e1a535d29edd7-20190819 X-UUID: abfc1859baa44d10b49e1a535d29edd7-20190819 Received: from mtkexhb02.mediatek.inc [(172.21.101.103)] by mailgw02.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0707 with TLS) with ESMTP id 957109249; Mon, 19 Aug 2019 17:22:00 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs08n1.mediatek.inc (172.21.101.55) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Mon, 19 Aug 2019 17:22:00 +0800 Received: from mtkswgap22.mediatek.inc (172.21.77.33) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Mon, 19 Aug 2019 17:22:00 +0800 From: Mars Cheng To: Matthias Brugger , Rob Herring , Marc Zyngier , Stephen Boyd , Sean Wang , Linus Walleij CC: CC Hwang , Loda Chou , , , , , mtk01761 , , Mars Cheng Subject: [PATCH v2 05/11] pinctrl: mediatek: avoid virtual gpio trying to set reg Date: Mon, 19 Aug 2019 17:21:36 +0800 Message-ID: <1566206502-4347-6-git-send-email-mars.cheng@mediatek.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1566206502-4347-1-git-send-email-mars.cheng@mediatek.com> References: <1566206502-4347-1-git-send-email-mars.cheng@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org for virtual gpios, they should not do reg setting and should behave as expected for eint function. Signed-off-by: Mars Cheng --- drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c | 20 ++++++++++++++++++++ drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h | 1 + drivers/pinctrl/mediatek/pinctrl-paris.c | 3 +++ 3 files changed, 24 insertions(+) diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c index 20e1c89..04948a6 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c +++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c @@ -226,6 +226,23 @@ static int mtk_xt_find_eint_num(struct mtk_pinctrl *hw, unsigned long eint_n) return EINT_NA; } +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; + + desc = (const struct mtk_pin_desc *)&hw->soc->pins[gpio_n]; + + if (desc->funcs && + desc->funcs[desc->eint.eint_m].name == 0) + 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 +295,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..ef479ea 100644 --- a/drivers/pinctrl/mediatek/pinctrl-paris.c +++ b/drivers/pinctrl/mediatek/pinctrl-paris.c @@ -693,6 +693,9 @@ static int mtk_gpio_get_direction(struct gpio_chip *chip, unsigned int gpio) const struct mtk_pin_desc *desc; int value, err; + 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