From patchwork Fri Oct 16 07:36:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?V2VpamllIEdhbyAo6auY5oOf5p2wKQ==?= X-Patchwork-Id: 1383154 X-Patchwork-Delegate: daniel.schwierzeck@googlemail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=mediatek.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=mediatek.com header.i=@mediatek.com header.a=rsa-sha256 header.s=dk header.b=U2Ko7ziU; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CCJ0D5CRsz9sTL for ; Fri, 16 Oct 2020 18:37:48 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 85B9182439; Fri, 16 Oct 2020 09:36:33 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=mediatek.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=mediatek.com header.i=@mediatek.com header.b="U2Ko7ziU"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8ACB1823DD; Fri, 16 Oct 2020 09:36:31 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=0.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MIME_BASE64_TEXT,RDNS_NONE,SPF_HELO_NONE, UNPARSEABLE_RELAY,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from mailgw01.mediatek.com (unknown [1.203.163.78]) by phobos.denx.de (Postfix) with ESMTP id 4960B82437 for ; Fri, 16 Oct 2020 09:36:27 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=mediatek.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=weijie.gao@mediatek.com X-UUID: 4f5b4dc754e74267811767113ea65109-20201016 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:Message-ID:Date:Subject:CC:To:From; bh=BUwuvJthB8i+FpsBr3SzcbpBa5audQv8KjGZA6gAKLI=; b=U2Ko7ziUTKm7ZwTysy8gRVhexFS+fa4mvTVziOug0p2PvAeCEC4uV/aNWSt+WRLCxhxRrkI6FD3z+8xD3diRamQFMYtjyS0D/tqCDwiTXh8NKDGS3yVQ6amLGIRwmudBLOb6WpA4p0subbwyJinkKWdwxXFKMPUWWEVLYW3uowE=; X-UUID: 4f5b4dc754e74267811767113ea65109-20201016 Received: from mtkcas36.mediatek.inc [(172.27.4.253)] by mailgw01.mediatek.com (envelope-from ) (mailgw01.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1640666741; Fri, 16 Oct 2020 15:36:23 +0800 Received: from MTKCAS32.mediatek.inc (172.27.4.184) by MTKMBS31N1.mediatek.inc (172.27.4.69) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 16 Oct 2020 15:36:21 +0800 Received: from mcddlt001.mediatek.inc (10.19.240.15) by MTKCAS32.mediatek.inc (172.27.4.170) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 16 Oct 2020 15:36:20 +0800 From: Weijie Gao To: CC: GSS_MTK_Uboot_upstream , Daniel Schwierzeck , Stefan Roese , Stefan Roese , Stefan Roese , Weijie Gao Subject: [PATCH 11/18] pinctrl: mtmips: add support for MediaTek MT7620 SoC Date: Fri, 16 Oct 2020 15:36:20 +0800 Message-ID: <1602833780-19485-1-git-send-email-weijie.gao@mediatek.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-TM-SNTS-SMTP: 500A9D731B43276831A2A4B488BAC1B04C11F3544D4876B3A36FD1B0038F0C692000:8 X-MTK: N X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean This patch adds pinctrl support for MediaTek MT7620 SoC. The MT7620 SoC supports only pinmux. Signed-off-by: Weijie Gao --- drivers/pinctrl/mtmips/Kconfig | 9 ++ drivers/pinctrl/mtmips/Makefile | 1 + drivers/pinctrl/mtmips/pinctrl-mt7620.c | 199 ++++++++++++++++++++++++ 3 files changed, 209 insertions(+) create mode 100644 drivers/pinctrl/mtmips/pinctrl-mt7620.c diff --git a/drivers/pinctrl/mtmips/Kconfig b/drivers/pinctrl/mtmips/Kconfig index 8482a38ebc..844d5b743f 100644 --- a/drivers/pinctrl/mtmips/Kconfig +++ b/drivers/pinctrl/mtmips/Kconfig @@ -3,6 +3,15 @@ config PINCTRL_MTMIPS depends on ARCH_MTMIPS bool +config PINCTRL_MT7620 + bool "MediaTek MT7620 pin control driver" + select PINCTRL_MTMIPS + depends on SOC_MT7620 && PINCTRL_GENERIC + help + Support pin multiplexing control on MediaTek MT7620. + The driver is controlled by a device tree node which contains + the pin mux functions for each available pin groups. + config PINCTRL_MT7628 bool "MediaTek MT7628 pin control driver" select PINCTRL_MTMIPS diff --git a/drivers/pinctrl/mtmips/Makefile b/drivers/pinctrl/mtmips/Makefile index 3ba5c0c66d..ba945a89a7 100644 --- a/drivers/pinctrl/mtmips/Makefile +++ b/drivers/pinctrl/mtmips/Makefile @@ -4,4 +4,5 @@ obj-$(CONFIG_PINCTRL_MTMIPS) += pinctrl-mtmips-common.o # SoC Drivers +obj-$(CONFIG_PINCTRL_MT7620) += pinctrl-mt7620.o obj-$(CONFIG_PINCTRL_MT7628) += pinctrl-mt7628.o diff --git a/drivers/pinctrl/mtmips/pinctrl-mt7620.c b/drivers/pinctrl/mtmips/pinctrl-mt7620.c new file mode 100644 index 0000000000..92e019b779 --- /dev/null +++ b/drivers/pinctrl/mtmips/pinctrl-mt7620.c @@ -0,0 +1,199 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2020 MediaTek Inc. All Rights Reserved. + * + * Author: Weijie Gao + */ + +#include +#include +#include +#include + +#include "pinctrl-mtmips-common.h" + +#define SUTIF_SHIFT 30 +#define WDT_RST_SHIFT 21 +#define PA_G_SHIFT 20 +#define NAND_SD_SHIFT 18 +#define PERST_SHIFT 16 +#define EPHY_LED_SHIFT 15 +#define WLED_SHIFT 13 +#define SPI_CS1_SHIFT 12 +#define SPI_SHIFT 11 +#define RGMII2_SHIFT 10 +#define RGMII1_SHIFT 9 +#define MDIO_SHIFT 7 +#define UARTL_SHIFT 5 +#define UARTF_SHIFT 2 +#define I2C_SHIFT 0 + +#define GM4_MASK 3 +#define GM8_MASK 7 + +#if CONFIG_IS_ENABLED(PINMUX) +static const struct mtmips_pmx_func sutif_grp[] = { + FUNC("i2c", 2), + FUNC("uartl", 1), + FUNC("none", 0), +}; + +static const struct mtmips_pmx_func wdt_rst_grp[] = { + FUNC("gpio", 2), + FUNC("refclk", 1), + FUNC("wdt rst", 0), +}; + +static const struct mtmips_pmx_func pa_g_grp[] = { + FUNC("gpio", 1), + FUNC("pa", 0), +}; + +static const struct mtmips_pmx_func nand_sd_grp[] = { + FUNC("gpio", 2), + FUNC("sd", 1), + FUNC("nand", 0), +}; + +static const struct mtmips_pmx_func perst_grp[] = { + FUNC("gpio", 2), + FUNC("refclk", 1), + FUNC("perst", 0), +}; + +static const struct mtmips_pmx_func ephy_led_grp[] = { + FUNC("gpio", 1), + FUNC("led", 0), +}; + +static const struct mtmips_pmx_func wled_grp[] = { + FUNC("gpio", 1), + FUNC("led", 0), +}; + +static const struct mtmips_pmx_func spi_cs1_grp[] = { + FUNC("refclk", 1), + FUNC("spi cs1", 0), +}; + +static const struct mtmips_pmx_func spi_grp[] = { + FUNC("gpio", 1), + FUNC("spi", 0), +}; + +static const struct mtmips_pmx_func rgmii2_grp[] = { + FUNC("gpio", 1), + FUNC("rgmii2", 0), +}; + +static const struct mtmips_pmx_func rgmii1_grp[] = { + FUNC("gpio", 1), + FUNC("rgmii1", 0), +}; + +static const struct mtmips_pmx_func mdio_grp[] = { + FUNC("gpio", 2), + FUNC("refclk", 1), + FUNC("mdio", 0), +}; + +static const struct mtmips_pmx_func uartl_grp[] = { + FUNC("gpio", 1), + FUNC("uartl", 0), +}; + +static const struct mtmips_pmx_func uartf_grp[] = { + FUNC("gpio", 7), + FUNC("i2s gpio", 6), + FUNC("uartf gpio", 5), + FUNC("gpio pcm", 4), + FUNC("i2s uartf", 3), + FUNC("i2s pcm", 2), + FUNC("uartf pcm", 1), + FUNC("uartf", 0), +}; + +static const struct mtmips_pmx_func i2c_grp[] = { + FUNC("gpio", 1), + FUNC("i2c", 0), +}; + +static const struct mtmips_pmx_group mt7620_pinmux_data[] = { + GRP("sutif", sutif_grp, 0, SUTIF_SHIFT, GM4_MASK), + GRP("wdt rst", wdt_rst_grp, 0, WDT_RST_SHIFT, GM4_MASK), + GRP("pa", pa_g_grp, 0, PA_G_SHIFT, 1), + GRP("nand", nand_sd_grp, 0, NAND_SD_SHIFT, GM4_MASK), + GRP("perst", perst_grp, 0, PERST_SHIFT, GM4_MASK), + GRP("ephy led", ephy_led_grp, 0, EPHY_LED_SHIFT, 1), + GRP("wled", wled_grp, 0, WLED_SHIFT, 1), + GRP("spi cs1", spi_cs1_grp, 0, SPI_CS1_SHIFT, 1), + GRP("spi", spi_grp, 0, SPI_SHIFT, 1), + GRP("rgmii2", rgmii2_grp, 0, RGMII2_SHIFT, 1), + GRP("rgmii1", rgmii1_grp, 0, RGMII1_SHIFT, 1), + GRP("mdio", mdio_grp, 0, MDIO_SHIFT, GM4_MASK), + GRP("uartl", uartl_grp, 0, UARTL_SHIFT, 1), + GRP("uartf", uartf_grp, 0, UARTF_SHIFT, GM8_MASK), + GRP("i2c", i2c_grp, 0, I2C_SHIFT, 1), +}; + +static int mt7620_get_groups_count(struct udevice *dev) +{ + return ARRAY_SIZE(mt7620_pinmux_data); +} + +static const char *mt7620_get_group_name(struct udevice *dev, + unsigned int selector) +{ + return mt7620_pinmux_data[selector].name; +} +#endif /* CONFIG_IS_ENABLED(PINMUX) */ + +static int mt7620_pinctrl_probe(struct udevice *dev) +{ + struct mtmips_pinctrl_priv *priv = dev_get_priv(dev); + int ret = 0; + +#if CONFIG_IS_ENABLED(PINMUX) + ret = mtmips_pinctrl_probe(priv, ARRAY_SIZE(mt7620_pinmux_data), + mt7620_pinmux_data); +#endif /* CONFIG_IS_ENABLED(PINMUX) */ + + return ret; +} + +static int mt7620_pinctrl_ofdata_to_platdata(struct udevice *dev) +{ + struct mtmips_pinctrl_priv *priv = dev_get_priv(dev); + + priv->base = dev_remap_addr_index(dev, 0); + if (!priv->base) + return -EINVAL; + + return 0; +} + +static const struct pinctrl_ops mt7620_pinctrl_ops = { +#if CONFIG_IS_ENABLED(PINMUX) + .get_groups_count = mt7620_get_groups_count, + .get_group_name = mt7620_get_group_name, + .get_functions_count = mtmips_get_functions_count, + .get_function_name = mtmips_get_function_name, + .pinmux_group_set = mtmips_pinmux_group_set, +#endif /* CONFIG_IS_ENABLED(PINMUX) */ + .set_state = pinctrl_generic_set_state, +}; + +static const struct udevice_id mt7620_pinctrl_ids[] = { + { .compatible = "mediatek,mt7620-pinctrl" }, + { } +}; + +U_BOOT_DRIVER(mt7620_pinctrl) = { + .name = "mt7620-pinctrl", + .id = UCLASS_PINCTRL, + .of_match = mt7620_pinctrl_ids, + .ofdata_to_platdata = mt7620_pinctrl_ofdata_to_platdata, + .ops = &mt7620_pinctrl_ops, + .probe = mt7620_pinctrl_probe, + .priv_auto_alloc_size = sizeof(struct mtmips_pinctrl_priv), +};