Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp2511680ybh; Mon, 5 Aug 2019 02:14:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqzPj05aYfx7yqrPT1Ukx1lusBnJU6gOkRW3gtJpCmRdyHaEO7IdjPvkUoRhrDx1DJ7nwEUg X-Received: by 2002:a63:b919:: with SMTP id z25mr134299524pge.201.1564996482358; Mon, 05 Aug 2019 02:14:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564996482; cv=none; d=google.com; s=arc-20160816; b=ss3MtjVb73AQqmRWfaAe07HxMoeaJx9uy3WNCTYnpapn8LE3Fh6iCSMnkkRn2KD5QK ym7TmNJ56kmTLJeg7h4KBEVHghVpxOv2yuoeWgrWgbrlPe2RW8VO+WEbM2GUxZ/Ebtr9 6XWC15g0IxcL+GYdZlay2NoxcggBXQ5rJ8ifrubjjoIdmOfZbpXIrHVKdKWfFk1KehNF BbP3A5s7FsnNrghwpXUSGOT2a/gjvjvgbGn18ai3miBhEbW8GzUmm5jzXQcmTD08WDdv nez+/Y/c2M3fe3kMRIg/EV5gvl2ffBdKptU5SnKNNA/FRwXt27nVj2ASN5nHzO/C6/8+ 45gQ== 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=fZ3lRUO4nAHcipkgvS4PYohzdRw6MfM2jFBXSk/EzxMFP9fG95D9PGBmKz5q8qttwP 3/hrpGVf4UMJZ/F4KHEYNDtVSy+nuxR6RlVYaU9dwoXNC+T2R2f141D+8zQj5Vsf7qRG wMsz/7Qmsx0LeplJTln5Ewd8uLhlgGCARMfJqQBPhf1ISPqLBlTNJcgg7vG/4zZL0jTz NrJ2kI86SVy6WX5RRnVJIlbIZZfSRbPqgjhwe/8UxKGinxY4lzw9MAD9rEtYUAH+eybs 10QPJ5FVeu5wJlTqkmG8ZgS+W2aQIBm+sWIFPnuwu4Vq3XLaU5LoEH9T8jnZxg1gw+qX nP6A== 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 n18si40855899plp.215.2019.08.05.02.14.27; Mon, 05 Aug 2019 02:14:42 -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 S1728355AbfHEJNZ (ORCPT + 99 others); Mon, 5 Aug 2019 05:13:25 -0400 Received: from mailgw01.mediatek.com ([210.61.82.183]:62353 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728055AbfHEJMO (ORCPT ); Mon, 5 Aug 2019 05:12:14 -0400 X-UUID: e40aa37123ff4715962cb4b8709f0b49-20190805 X-UUID: e40aa37123ff4715962cb4b8709f0b49-20190805 Received: from mtkcas07.mediatek.inc [(172.21.101.84)] by mailgw01.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0707 with TLS) with ESMTP id 1727178972; Mon, 05 Aug 2019 17:12:04 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs08n2.mediatek.inc (172.21.101.56) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Mon, 5 Aug 2019 17:12:06 +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, 5 Aug 2019 17:12:06 +0800 From: Mars Cheng To: Matthias Brugger CC: CC Hwang , Loda Chou , , , , , Wendell Lin , Ivan Tseng , Mars Cheng Subject: [PATCH 05/11] pinctrl: mediatek: avoid virtual gpio trying to set reg Date: Mon, 5 Aug 2019 17:11:54 +0800 Message-ID: <1564996320-10897-6-git-send-email-mars.cheng@mediatek.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1564996320-10897-1-git-send-email-mars.cheng@mediatek.com> References: <1564996320-10897-1-git-send-email-mars.cheng@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-SNTS-SMTP: E75AC4FAB53DC0AF429D6F290F51CB7C7CF6026E8BAF35E3D58736348825D0CF2000:8 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