From patchwork Mon May 30 12:34:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabien Parent X-Patchwork-Id: 12864587 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9BE29C433F5 for ; Mon, 30 May 2022 12:36:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=Eidt8wrbk2qvA9D8totYjkug24e6DI+6VSCXnebY/S0=; b=ewjblwYINXHkWW o4sGfxU14MRzO0sPu9t7pf9duU8Eg/69Qkq2/bAOzIoxaKDHhTb1lDnRFF9X1KXekDAVroxitAVwO CrjKeGbppGrQ/Flbg8uksXbNCoueXFPlAEjXHJFvaZgW/kaWx9JQUL9fHC4Z3kkoWJQ1SAfO62VpB BxTqxGcw2CUjCaRB4WlPwWym4B1lOfwwrnPy3I+y2p/u91zHXJ7HCoYTxUGBZaPgCj1ttrx49fomU HyD2T9X8CkL+AwGieO3xmzq97TtaWuFcI9CR1rsRr02rFEOApfNsTNFs6qysQq1h8UWnM41vejcM4 5AqxawHdIMOh/Zi/S0vg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nvecG-006WTi-3G; Mon, 30 May 2022 12:35:24 +0000 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nveby-006WPq-1K for linux-arm-kernel@lists.infradead.org; Mon, 30 May 2022 12:35:13 +0000 Received: by mail-wr1-x431.google.com with SMTP id s24so7137719wrb.10 for ; Mon, 30 May 2022 05:35:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=4ZpnujIPcolEhKbIJZUfooL6oIUs8mzgT5bxqd2OLwk=; b=civVMl7MXBedL2Fy/RdMR2hvoMq61sw/bSOuRyUnGfnpbQlu1B1vaETDk2eoLtMg61 xxvEM0CcGiuHnAv6EMTxHCVekfHJ443IW5HAHw1nPPodMQDAgQb/Z8wkdyR2n2oVdc02 rEchF77XObT5skBCADYM/9HeAkGoea+j9J1auHdrH25hfsrcuBh06zz0PQOUIkBpRAHo 9mlga4VSDuJ7sjz7UYdmr50MV3YV9+ezDISlXifrMQirUadM1ssMASjkx+97cXDUuyeb JhphSXc6/ervgN2b3jAzZSnPdDVaaUjM91vEkyX+Un5qEiD2lJPkDNrYMhf/x2hF+OXy 7cRQ== 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:mime-version :content-transfer-encoding; bh=4ZpnujIPcolEhKbIJZUfooL6oIUs8mzgT5bxqd2OLwk=; b=GbEdMDyTRqIN695pKJYaOJpl88vPRN8PbaQDkLItPJSllObp0HNVDbMTkbFCsiYL3z eTPkFsWndjFMmn/M9BZQaive04NTTlan+UDYFF3Kxv9COvb56mybEaPVUoPgXkwACuNl 09skePKiDlu/FbSbGv/uc+nv7qdqeRGK63LXv7qqWl73xHG4gXPKr/ZD1MK1k//9l5wF WHa32bcCzKtFhi+1eEq903dBh5xPdoS2fK7LlVBl//Ye7s8CRC2mqRwARA0hush8BVlN S1jFi0zRrOJRJZ4rXHBM7EF3uh4wS+FezF2/HGUSxKF0C1ejlUrbcwEme52lF6CfPLcv waTQ== X-Gm-Message-State: AOAM531rMms5gNSf3Z93nRwhG0D/UPacdbu3gyZCxsRgZjThYgY24aGh aRouh6KYjL+9xVK4rXvvGG3H8Q== X-Google-Smtp-Source: ABdhPJxvnP7l8SO28NpVJS5NOclYzbNoRLMyWaTv8lhRa6I5+hFmHhKsWwpdaDK81i85ecqujt0hRA== X-Received: by 2002:a05:6000:1611:b0:210:28cc:65dd with SMTP id u17-20020a056000161100b0021028cc65ddmr8793920wrb.700.1653914102514; Mon, 30 May 2022 05:35:02 -0700 (PDT) Received: from helium.lan ([88.160.162.107]) by smtp.gmail.com with ESMTPSA id o3-20020a5d47c3000000b0020d0cdbf7eesm9380895wrc.111.2022.05.30.05.35.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 May 2022 05:35:01 -0700 (PDT) From: Fabien Parent To: Sean Wang , Linus Walleij , Matthias Brugger Cc: Fabien Parent , linux-mediatek@lists.infradead.org, linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] pinctrl: mediatek: common: add quirk for broken set/clr modes Date: Mon, 30 May 2022 14:34:24 +0200 Message-Id: <20220530123425.689459-1-fparent@baylibre.com> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220530_053506_343167_728B485A X-CRM114-Status: GOOD ( 15.03 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On MT8365, the SET/CLR of the mode is broken and some pin modes won't be set correctly. Add a quirk for such SoCs, so that instead of using the SET/CLR register use the main R/W register to read/update/write the modes. Signed-off-by: Fabien Parent --- drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 46 ++++++++++++------- drivers/pinctrl/mediatek/pinctrl-mtk-common.h | 3 ++ 2 files changed, 33 insertions(+), 16 deletions(-) diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c index f25b3e09386b..156627d9c552 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c +++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c @@ -330,23 +330,37 @@ static int mtk_pconf_set_pull_select(struct mtk_pinctrl *pctl, return -EINVAL; } - bit = BIT(pin & pctl->devdata->mode_mask); - if (enable) - reg_pullen = SET_ADDR(mtk_get_port(pctl, pin) + - pctl->devdata->pullen_offset, pctl); - else - reg_pullen = CLR_ADDR(mtk_get_port(pctl, pin) + - pctl->devdata->pullen_offset, pctl); - - if (isup) - reg_pullsel = SET_ADDR(mtk_get_port(pctl, pin) + - pctl->devdata->pullsel_offset, pctl); - else - reg_pullsel = CLR_ADDR(mtk_get_port(pctl, pin) + - pctl->devdata->pullsel_offset, pctl); + if (pctl->devdata->quirks & MTK_PINCTRL_MODE_SET_CLR_BROKEN) { + bit = pin & pctl->devdata->mode_mask; + reg_pullen = mtk_get_port(pctl, pin) + + pctl->devdata->pullen_offset; + reg_pullsel = mtk_get_port(pctl, pin) + + pctl->devdata->pullsel_offset; + + regmap_update_bits(mtk_get_regmap(pctl, pin), reg_pullen, + BIT(bit), enable << bit); + regmap_update_bits(mtk_get_regmap(pctl, pin), reg_pullsel, + BIT(bit), isup << bit); + } else { + bit = BIT(pin & pctl->devdata->mode_mask); + if (enable) + reg_pullen = SET_ADDR(mtk_get_port(pctl, pin) + + pctl->devdata->pullen_offset, pctl); + else + reg_pullen = CLR_ADDR(mtk_get_port(pctl, pin) + + pctl->devdata->pullen_offset, pctl); + + if (isup) + reg_pullsel = SET_ADDR(mtk_get_port(pctl, pin) + + pctl->devdata->pullsel_offset, pctl); + else + reg_pullsel = CLR_ADDR(mtk_get_port(pctl, pin) + + pctl->devdata->pullsel_offset, pctl); + + regmap_write(mtk_get_regmap(pctl, pin), reg_pullen, bit); + regmap_write(mtk_get_regmap(pctl, pin), reg_pullsel, bit); + } - regmap_write(mtk_get_regmap(pctl, pin), reg_pullen, bit); - regmap_write(mtk_get_regmap(pctl, pin), reg_pullsel, bit); return 0; } diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common.h b/drivers/pinctrl/mediatek/pinctrl-mtk-common.h index 6fe8564334c9..cc0dce8818c6 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.h +++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.h @@ -22,6 +22,8 @@ #define MTK_PINCTRL_NOT_SUPPORT (0xffff) +#define MTK_PINCTRL_MODE_SET_CLR_BROKEN BIT(0) + struct mtk_desc_function { const char *name; unsigned char muxval; @@ -271,6 +273,7 @@ struct mtk_pinctrl_devdata { unsigned int mode_mask; unsigned int mode_per_reg; unsigned int mode_shf; + unsigned long quirks; }; struct mtk_pinctrl { From patchwork Mon May 30 12:34:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabien Parent X-Patchwork-Id: 12864586 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3B5F6C433F5 for ; Mon, 30 May 2022 12:36:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=PHzoowKM2CJuPmIDiZ1BQCaQdKUZ8Zy610qCfX6KW64=; b=1U9fFWKWU3CtFz YM226b4q0L4wtXF4yGKL/OU+2o7qQ0CkFEQ6KRIqotpwYL8E8NKbvJIE3PIBYCggc8cFxR40ZkqlV dtN35eHbbUH+lsfjxWnSBIR2sJi8s10VJQoHShjBgmjcXa0j3n9PsC3oBUXWF32FK42RQFee7luq0 Bk+XgZTkzQzInflXy4HuFSHzsM7KTt2aEawGbzY1jCdOEtOqQ2wonzKXcAyfWYHkNVui5+1LQLT71 KyJNK9wdJOpsbXYcjnWvNyvKQFcryoR3LBHNSo4FZ5xAiMd4pO9WzroKZOKQqG9wbWbnXF5nO69dH wZP+30fry9KwI+lAA6DQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nvec7-006WRt-S1; Mon, 30 May 2022 12:35:15 +0000 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nvebz-006WPw-EM for linux-arm-kernel@lists.infradead.org; Mon, 30 May 2022 12:35:12 +0000 Received: by mail-wr1-x435.google.com with SMTP id s24so7137802wrb.10 for ; Mon, 30 May 2022 05:35:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lbYsntMLq1GN0TWediUrrDdKB95gK6V8mOFIJ/plIGA=; b=6PIvfuSRJgpUpEkUtolL+elU452K0LIs/Lk0e8ySI1W8R7XRUH431mK1hLv3cpfqv0 2ZivpNy+gpcusmBB8mk0Ew4hQQzierrs2JMj4MSTb5RaE1pnm5r4BB+rMCLfpOATrfQ1 fdgRBLMqOOfK4fOdnWAONoFqqYZa441FyfaRHJHwcNmWWpMHldEdkBWgLnLLoV6jgILp UhF1HWrNlnLykhYQKA9UwLBePuuFaE0k468BQeVRY9pdlVrIjvnbtqfZHqI9FifYwY0d RBeEm4ojUdqz9Xr9zBAlKsKLKwezW2a8pkmUhSR3NeD6xwpo7+xnIR9BI4/jC0QQ716W 7sXw== 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=lbYsntMLq1GN0TWediUrrDdKB95gK6V8mOFIJ/plIGA=; b=RAPpXtoW/6m/x2HOH0SjENCrEoKwUSalBG/dn7nF6mpHnc6LbF6aTBvjsPfA0BCuRN Q7TrM+J3pARArP7QWwuMgbmJDRUXcS0PbSIEuiVgivFjHbEjoSbmkl1vMUDp+tJgQXqA 8vCM36NooaNCS85ZBGxTXt2FB07Y9r8cRkC6ZAECC2eWAxJH+SUmQ6OXdjXHXx3OsY+U pfxUwA0hjGo6FGVQkmg1HaSL+D0uhbQe8+YZmPvcaKi7XMta0LjsZVZR4bZHsEFKSpX8 X27WxoTq2C+ayNl/wC9XwmQQvye3yoa4xeYhT2w+Mf2C7RkqCfSclSFZkdQEe0D+Md0c xMcA== X-Gm-Message-State: AOAM5330dapYc8k4xtwbV0wk3MeDoWYWmtQdmI6GnjVt8mOd8hXiHetZ 6N9oPj2D5IU0WGbuxsx4yjJKdg== X-Google-Smtp-Source: ABdhPJylyu+I3dilKUdZVnw2PpnKf2fn0YNljSSTog9+EycAuB0MX1E9Uhj466cMXJhLxItBU/M5Yg== X-Received: by 2002:a5d:648a:0:b0:210:2c59:a07a with SMTP id o10-20020a5d648a000000b002102c59a07amr7301097wri.195.1653914103914; Mon, 30 May 2022 05:35:03 -0700 (PDT) Received: from helium.lan ([88.160.162.107]) by smtp.gmail.com with ESMTPSA id o3-20020a5d47c3000000b0020d0cdbf7eesm9380895wrc.111.2022.05.30.05.35.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 May 2022 05:35:03 -0700 (PDT) From: Fabien Parent To: Sean Wang , Linus Walleij , Matthias Brugger Cc: Fabien Parent , linux-mediatek@lists.infradead.org, linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] pinctrl: mediatek: mt8365: use MTK_PINCTRL_MODE_SET_CLR_BROKEN quirk Date: Mon, 30 May 2022 14:34:25 +0200 Message-Id: <20220530123425.689459-2-fparent@baylibre.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220530123425.689459-1-fparent@baylibre.com> References: <20220530123425.689459-1-fparent@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220530_053507_511000_BC925FAF X-CRM114-Status: GOOD ( 11.84 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On MT8365, the GPIO64 modes cannot be set using the SET/CLR register. Use the MTK_PINCTRL_MODE_SET_CLR_BROKEN quirk to workaround it. Signed-off-by: Fabien Parent --- drivers/pinctrl/mediatek/pinctrl-mt8365.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8365.c b/drivers/pinctrl/mediatek/pinctrl-mt8365.c index 57f37a294063..a49fa685f5f5 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mt8365.c +++ b/drivers/pinctrl/mediatek/pinctrl-mt8365.c @@ -454,6 +454,7 @@ static const struct mtk_pinctrl_devdata mt8365_pinctrl_data = { .ap_num = 160, .db_cnt = 160, }, + .quirks = MTK_PINCTRL_MODE_SET_CLR_BROKEN, }; static const struct of_device_id mt8365_pctrl_match[] = {