From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY, URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 14AEAC4338F for ; Fri, 20 Aug 2021 07:53:04 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id C453260FF2 for ; Fri, 20 Aug 2021 07:53:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C453260FF2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org 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=YrDocEuDD6r3BO4wENyye39wAKVIZfAZ7UoBW62xrzs=; b=QfZ9F+OvEaVaEC V6FzFI+L1vF9nohuWlJpaRZWXaso5OH1miyv3JfmHRcv6enFAhvB8Ipm24Vm9birA5/bW/uZwIHN9 HHwMO0J257XY3KG89hE3mggkaaVl4CA6bLQrnhrh7Go4v3a0LeBcNlmgbeJ3W7VYU4qRD9PIteqeu oSNaEM7lW+7xfkRpO+waOrvUuwnV7aGUh06x1gvqNZwhdNxT1E5nAeKJL5y6Ep3Qcy2KM9GVQnG0k Wpvit0FQuDJcYamxW06dUrmhkrsa6et55rtR423OQO/tzf47GGGTpDWz38fonXCmASwcuCJ5of+1l olQt7uN/pWviQfll4oAg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mGzIj-00AI0F-8T; Fri, 20 Aug 2021 07:50:53 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mGzIc-00AHyp-JJ; Fri, 20 Aug 2021 07:50:50 +0000 X-UUID: 49d331425d744a22b2468890b75f2891-20210820 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=aWI+nLQxJwuF/D2oO97VvU9t2UsJ672LX+eRfkwY/xY=; b=ZewXmADtYusS9Q5ZUd/LGz0VZiV+1Ys6Zh1EM3BondQv7uhVA3tDehuLCEuwOqYoEM2g4TeRyeQDHVUkxCLdTC20NlebJk7kefDQG6WS8c5GtNAFQsyFvLtqE94dy9puFyOYvr7i08TEpjWxX40/hLqDxegcnrled9nL+2KJwLY=; X-UUID: 49d331425d744a22b2468890b75f2891-20210820 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1183179748; Fri, 20 Aug 2021 00:50:44 -0700 Received: from mtkmbs05n1.mediatek.inc (172.21.101.15) by MTKMBS62N2.mediatek.inc (172.29.193.42) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 20 Aug 2021 00:50:42 -0700 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs05n1.mediatek.inc (172.21.101.15) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 20 Aug 2021 15:50:40 +0800 Received: from mtkswgap22.mediatek.inc (172.21.77.33) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 20 Aug 2021 15:50:40 +0800 From: To: CC: , , , , , , , , , , , , , , , , , , , , , , , , , , Sean Wang Subject: Re: [v2,06/12] pinctrl: mediatek: add support for MT7986 SoC Date: Fri, 20 Aug 2021 15:50:40 +0800 Message-ID: <1629445840-25510-1-git-send-email-sean.wang@mediatek.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <20210817074557.30953-5-sam.shih@mediatek.com--annotate> References: <20210817074557.30953-5-sam.shih@mediatek.com--annotate> MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210820_005046_698610_296F2103 X-CRM114-Status: GOOD ( 16.75 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Sean Wang >This commit includes pinctrl driver for Mediatek MT7986 > >The difference of pinctrl between mt7986a and mt7986b >is that pin-41 to pin-65 do not exist on mt7986b > >Signed-off-by: Sam Shih > >--- >v2: applied the comment suggested by reviewers: > - for the pins not ballout, we can fill .name in struct mtk_pin_desc > as NULL and return -ENOTSUPP in gpio/pinconf ops. > >--- > drivers/pinctrl/mediatek/Kconfig | 7 + > drivers/pinctrl/mediatek/Makefile | 1 + > drivers/pinctrl/mediatek/pinctrl-mt7986.c | 1217 +++++++++++++++++++++ > 3 files changed, 1225 insertions(+) > create mode 100644 drivers/pinctrl/mediatek/pinctrl-mt7986.c > >diff --git a/drivers/pinctrl/mediatek/Kconfig b/drivers/pinctrl/mediatek/Kconfig >index 7040a7a7bd5d..66db4ac5d169 100644 >--- a/drivers/pinctrl/mediatek/Kconfig >+++ b/drivers/pinctrl/mediatek/Kconfig >@@ -119,6 +119,13 @@ config PINCTRL_MT7622 > default ARM64 && ARCH_MEDIATEK > select PINCTRL_MTK_MOORE > >+config PINCTRL_MT7986 >+ bool "Mediatek MT7986 pin control" >+ depends on OF >+ depends on ARM64 || COMPILE_TEST >+ default ARM64 && ARCH_MEDIATEK >+ select PINCTRL_MTK_MOORE >+ > config PINCTRL_MT8167 > bool "Mediatek MT8167 pin control" > depends on OF >diff --git a/drivers/pinctrl/mediatek/Makefile b/drivers/pinctrl/mediatek/Makefile >index 1bb7f9c65bc2..1e3931d924e7 100644 >--- a/drivers/pinctrl/mediatek/Makefile >+++ b/drivers/pinctrl/mediatek/Makefile >@@ -17,6 +17,7 @@ obj-$(CONFIG_PINCTRL_MT6797) += pinctrl-mt6797.o > obj-$(CONFIG_PINCTRL_MT7622) += pinctrl-mt7622.o > obj-$(CONFIG_PINCTRL_MT7623) += pinctrl-mt7623.o > obj-$(CONFIG_PINCTRL_MT7629) += pinctrl-mt7629.o >+obj-$(CONFIG_PINCTRL_MT7986) += pinctrl-mt7986.o > obj-$(CONFIG_PINCTRL_MT8167) += pinctrl-mt8167.o > obj-$(CONFIG_PINCTRL_MT8173) += pinctrl-mt8173.o > obj-$(CONFIG_PINCTRL_MT8183) += pinctrl-mt8183.o >diff --git a/drivers/pinctrl/mediatek/pinctrl-mt7986.c b/drivers/pinctrl/mediatek/pinctrl-mt7986.c >new file mode 100644 >index 000000000000..808ae4e03eb2 >--- /dev/null >+++ b/drivers/pinctrl/mediatek/pinctrl-mt7986.c >@@ -0,0 +1,1217 @@ >+// SPDX-License-Identifier: GPL-2.0 >+/* >+ * The MT7986 driver based on Linux generic pinctrl binding. >+ * >+ * Copyright (C) 2021 MediaTek Inc. >+ * Author: Sam Shih >+ */ >+ >+#include "pinctrl-moore.h" >+ >+#define MT7986_PIN(_number, _name) MTK_PIN(_number, _name, 0, _number, DRV_GRP4) >+#define MT7986_NOT_BALLOUT_PIN(_number) { .number = _number } I preferred explict set .name to NULL to indicate the pin is not ball out. >+ >+#define PIN_FIELD_BASE(_s_pin, _e_pin, _i_base, _s_addr, _x_addrs, _s_bit, \ >+ _x_bits) \ >+ PIN_FIELD_CALC(_s_pin, _e_pin, _i_base, _s_addr, _x_addrs, _s_bit, \ >+ _x_bits, 32, 0) >+ >+/** >+ * enum - Locking variants of the iocfg bases >+ * >+ * MT7986 have multiple bases to program pin configuration listed as the below: >+ * iocfg_rt:0x11c30000, iocfg_rb:0x11c40000, iocfg_lt:0x11e20000, >+ * iocfg_lb:0x11e30000, iocfg_tr:0x11f00000, iocfg_tl:0x11f10000, >+ * _i_based could be used to indicate what base the pin should be mapped into. >+ * >+ * Each iocfg register base control different group of pads on the SoC >+ * >+ * >+ * chip carrier >+ * >+ * A B C D E F G H >+ * +------------------------+ >+ * 8 | o o o o o o o o | >+ * 7 | o o o o o o o o | >+ * 6 | o o o o o o o o | >+ * 5 | o o o o o o o o | >+ * 4 | o o o o o o o o | >+ * 3 | o o o o o o o o | >+ * 2 | o o o o o o o o | >+ * 1 | o o o o o o o o | >+ * +------------------------+ >+ * >+ * inside Chip carrier >+ * >+ * A B C D E F G H >+ * +------------------------+ >+ * 8 | | >+ * 7 | TL TR | >+ * 6 | +---------+ | >+ * 5 | LT | | RT | >+ * 4 | | | | >+ * 3 | LB | | RB | >+ * 2 | +---------+ | >+ * 1 | | >+ * +------------------------+ >+ * >+ */ >+ >+enum { >+ GPIO_BASE, >+ IOCFG_RT_BASE, >+ IOCFG_RB_BASE, >+ IOCFG_LT_BASE, >+ IOCFG_LB_BASE, >+ IOCFG_TR_BASE, >+ IOCFG_TL_BASE, >+}; >+ >+static const char *const mt7986_pinctrl_register_base_names[] = { >+ "gpio_base", "iocfg_rt_base", "iocfg_rb_base", "iocfg_lt_base", >+ "iocfg_lb_base", "iocfg_tr_base", "iocfg_tl_base", >+}; >+ >+static const struct mtk_pin_field_calc mt7986_pin_mode_range[] = { >+ PIN_FIELD(0, 40, 0x300, 0x10, 0, 4), >+ PIN_FIELD(41, 65, 0x350, 0x10, 4, 4), >+ PIN_FIELD(66, 68, 0x380, 0x10, 8, 4), >+ PIN_FIELD(69, 100, 0x380, 0x10, 20, 4), >+}; >+ >+static const struct mtk_pin_field_calc mt7986_pin_dir_range[] = { >+ PIN_FIELD(0, 40, 0x0, 0x10, 0, 1), >+ PIN_FIELD(41, 65, 0x10, 0x10, 9, 1), >+ PIN_FIELD(66, 68, 0x20, 0x10, 2, 1), >+ PIN_FIELD(69, 100, 0x20, 0x10, 5, 1), >+}; >+ >+static const struct mtk_pin_field_calc mt7986_pin_di_range[] = { >+ PIN_FIELD(0, 40, 0x200, 0x10, 0, 1), >+ PIN_FIELD(41, 65, 0x210, 0x10, 9, 1), >+ PIN_FIELD(66, 68, 0x220, 0x10, 2, 1), >+ PIN_FIELD(69, 100, 0x220, 0x10, 5, 1), >+}; >+ >+static const struct mtk_pin_field_calc mt7986_pin_do_range[] = { >+ PIN_FIELD(0, 40, 0x100, 0x10, 0, 1), >+ PIN_FIELD(41, 65, 0x110, 0x10, 9, 1), >+ PIN_FIELD(66, 68, 0x120, 0x10, 2, 1), >+ PIN_FIELD(69, 100, 0x120, 0x10, 5, 1), >+}; >+ >+static const struct mtk_pin_field_calc mt7986_pin_ies_range[] = { >+ PIN_FIELD_BASE(0, 0, IOCFG_RB_BASE, 0x40, 0x10, 17, 1), >+ PIN_FIELD_BASE(1, 1, IOCFG_LT_BASE, 0x20, 0x10, 10, 1), >+ PIN_FIELD_BASE(2, 2, IOCFG_LT_BASE, 0x20, 0x10, 11, 1), >+ PIN_FIELD_BASE(3, 3, IOCFG_LB_BASE, 0x20, 0x10, 0, 1), >+ PIN_FIELD_BASE(4, 4, IOCFG_LB_BASE, 0x20, 0x10, 1, 1), >+ PIN_FIELD_BASE(5, 5, IOCFG_RB_BASE, 0x40, 0x10, 0, 1), >+ PIN_FIELD_BASE(6, 6, IOCFG_RB_BASE, 0x40, 0x10, 1, 1), >+ PIN_FIELD_BASE(7, 7, IOCFG_LT_BASE, 0x20, 0x10, 0, 1), >+ PIN_FIELD_BASE(8, 8, IOCFG_LT_BASE, 0x20, 0x10, 1, 1), >+ PIN_FIELD_BASE(9, 9, IOCFG_LT_BASE, 0x20, 0x10, 2, 1), >+ PIN_FIELD_BASE(10, 10, IOCFG_LT_BASE, 0x20, 0x10, 3, 1), >+ PIN_FIELD_BASE(11, 11, IOCFG_RB_BASE, 0x40, 0x10, 8, 1), >+ PIN_FIELD_BASE(12, 12, IOCFG_RB_BASE, 0x40, 0x10, 9, 1), >+ PIN_FIELD_BASE(13, 13, IOCFG_RB_BASE, 0x40, 0x10, 10, 1), >+ PIN_FIELD_BASE(14, 14, IOCFG_RB_BASE, 0x40, 0x10, 11, 1), >+ PIN_FIELD_BASE(15, 15, IOCFG_RB_BASE, 0x40, 0x10, 2, 1), >+ PIN_FIELD_BASE(16, 16, IOCFG_RB_BASE, 0x40, 0x10, 3, 1), >+ PIN_FIELD_BASE(17, 17, IOCFG_RB_BASE, 0x40, 0x10, 4, 1), >+ PIN_FIELD_BASE(18, 18, IOCFG_RB_BASE, 0x40, 0x10, 5, 1), >+ PIN_FIELD_BASE(19, 19, IOCFG_RB_BASE, 0x40, 0x10, 6, 1), >+ PIN_FIELD_BASE(20, 20, IOCFG_RB_BASE, 0x40, 0x10, 7, 1), Actually, we can merge the consecutive entries into one to reduce the table size For example, we can merge those entries pin 15 ~ 20 into one, from PIN_FIELD_BASE(15, 15, IOCFG_RB_BASE, 0x40, 0x10, 2, 1), PIN_FIELD_BASE(16, 16, IOCFG_RB_BASE, 0x40, 0x10, 3, 1), PIN_FIELD_BASE(17, 17, IOCFG_RB_BASE, 0x40, 0x10, 4, 1), PIN_FIELD_BASE(18, 18, IOCFG_RB_BASE, 0x40, 0x10, 5, 1), PIN_FIELD_BASE(19, 19, IOCFG_RB_BASE, 0x40, 0x10, 6, 1), PIN_FIELD_BASE(20, 20, IOCFG_RB_BASE, 0x40, 0x10, 7, 1), to PIN_FIELD_BASE(15, 20, IOCFG_RB_BASE, 0x40, 0x10, 2, 1). Also please consider merging all the similar occurrences elsewhere to optimize them. >+ PIN_FIELD_BASE(21, 21, IOCFG_RT_BASE, 0x30, 0x10, 12, 1), >+ PIN_FIELD_BASE(22, 22, IOCFG_RT_BASE, 0x30, 0x10, 13, 1), >+ PIN_FIELD_BASE(23, 23, IOCFG_RT_BASE, 0x30, 0x10, 14, 1), >+ PIN_FIELD_BASE(24, 24, IOCFG_RT_BASE, 0x30, 0x10, 18, 1), >+ PIN_FIELD_BASE(25, 25, IOCFG_RT_BASE, 0x30, 0x10, 17, 1), >+ PIN_FIELD_BASE(26, 26, IOCFG_RT_BASE, 0x30, 0x10, 15, 1), >+ PIN_FIELD_BASE(27, 27, IOCFG_RT_BASE, 0x30, 0x10, 16, 1), _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel