Received: by 2002:a05:6500:1b41:b0:1fb:d597:ff75 with SMTP id cz1csp133683lqb; Tue, 4 Jun 2024 07:12:53 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWTVTcS0WLoLzrRmeH3k44wOFOVjMJlWgo21QWyPI8FFF3pzlyRWn9ePSHLbXKPGLfVwdJYcYYbj4cQQndOx1MB35F08aiZOUYMdoZWcw== X-Google-Smtp-Source: AGHT+IFRz6DX9iWYvLvImRYiOt9kuLb87bmCvVwr1+0+ZK8ANqERsTq6GsG9xJigyeyAQPch0S6+ X-Received: by 2002:a05:6a20:a11d:b0:1a9:7afc:591c with SMTP id adf61e73a8af0-1b26f0ec401mr15408187637.10.1717510373563; Tue, 04 Jun 2024 07:12:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717510373; cv=pass; d=google.com; s=arc-20160816; b=iHr6wPvsUPqntOqX42XYEQxgfBUpLZiLR7lx9J+gj9rVNG0+2uNBtBjackFw4rLTCK XibE77uwaiBuTC6z6EnUM2WB84ExU3yUt7g3mAKC6GtgbQT5CkF8cKmPgyFfZmdXgscE T5mSZvNmTOHKD5cKyp44YrTPQVhxNf5kuTwCBkV3QjBNgYVgc6e593VREvdL5gmBXFE3 WbGNUNAv0hDnNzzzYn9fXXShtkFv1bMEdRzTj4K1OfsiBOzQFFZs1qQqmqXEKCE7atUX swGrxGkQSW440vh+3YdtKjWcpusw+LyNr+OIJkuNZfS5mGrXnmz9wlcvj3mUcTAr1QEi YoAQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=h8WNzr1RkvpmpYoWNWRKn7+aS0Q1oOONVOvQh0ksva8=; fh=5wOAuKLZJtYT8h+4PiYukhUuQJEuXg0t3c5Bz2sXQ4Y=; b=0bty4QG3A+zU2zvN9chowbYgtRPaYPeci0rAFgC9BRlEPIVSLJcN0ddbWYoSjpWA0h HRDPBZpxKWDI+6/qc13y/w8byhFxSEJmMQywi/Da1Y3uRK69X6djblLJh92/wvOmr7X1 WQ/z6Yt27kT9v1mmvYbQD+8psBa74gn4TmuGj2Lhs92UCZuLqG7fpOz+l2seM8tZl7KQ eGijErc0c0K/8aVlplAr1oih3bddS5DY5lkDtNubqracThlzUWh/wKVec81/FUOy69zp NXNlfVMqiOcsJfYDXpxYRUcOcNXbdAtokz2yMq0aGO3dJqA4uZSWv3zgkIV0gy4ud2cC tzfw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=N6q+Ann8; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-200784-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200784-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-6c3542e3acesi302359a12.151.2024.06.04.07.12.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 07:12:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-200784-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=N6q+Ann8; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-200784-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200784-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id C4514283249 for ; Tue, 4 Jun 2024 14:12:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 270E1179AF; Tue, 4 Jun 2024 14:12:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="N6q+Ann8" Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EBA3A84E1C; Tue, 4 Jun 2024 14:12:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717510338; cv=none; b=ej7bHOvbXC0+oYwB61jdGRiCwi/7+44ZwqFAUULkOAGOdwcbUuRUIHe6kdMBbhfXf/bgaSsZVza/uTU5stziuNCcp9YZGlCS7zF6WFGftndmvCajIo82YpQ6Yac5qCjKLXBVRCcH1XiYURdYtlmyVzNpZWcwcFgNZxR2iPIwcic= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717510338; c=relaxed/simple; bh=OknlLD0OY9K/fjYR7dXwC/HBhNlOqADdpjkjqw4kzDQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=G2T7cGK1EbPxRcsgy1JYTqVD2MLkwMeH5oTv5WC7iNo2CkS+0qWal70IJNJBbB5j77KmhvpG4F8NIFMSr7bqY+Hd04Fl+HgjQXKEHHfP+kr+zEyQcWPMp62JB0ieBZsvY3vuEt50MCVGm+/bpv3hQUyO6QDv/YhQxWpIVEBrtso= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=N6q+Ann8; arc=none smtp.client-ip=209.85.167.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lf1-f50.google.com with SMTP id 2adb3069b0e04-52b7c82e39eso5609583e87.1; Tue, 04 Jun 2024 07:12:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717510335; x=1718115135; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=h8WNzr1RkvpmpYoWNWRKn7+aS0Q1oOONVOvQh0ksva8=; b=N6q+Ann8J/NPRtBmzwvw1FKPVfiYmNIDwFrsuTaLHlmwkI4WVnYK8hywWfsJQD22YS wUbQpeSu0ZVKUxhOofKiQf597U1rLGPhCAYrp55beqYrW35Vn40Idz2zOr9H7EjWP/ZS u6K+0gzzaW5KVTu1R/S4G6+ticC3lSz8FPY1ppAT0/uje6rDhvpUO3oDcDSI+LK9YYCP llb6iX4kAUnJis68KMvBBhLXGY+inOMZJnkXtTOobKK2mT/sPjd+sXzgAyWJ/UqjSZHy c3e6AfBuYFpHB+eFJ1fuI9WK8KDYB4bDogscnshDwKM9Re3hWJpPVPz6atHgdhdYLRbp SsBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717510335; x=1718115135; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=h8WNzr1RkvpmpYoWNWRKn7+aS0Q1oOONVOvQh0ksva8=; b=Ul5hmIgFWwdLA5V2SW0ICdjcNmd1igR8XH4ZoDmK5R92HtPHGeE7LfbucJXiqn9K0v sUwtS9bNKhd1o/hS0SCvi6nX0YtSUeo6o026vZ/j4gz2Ud1CCC/34xQMJsBqAl5k9oG0 srtVQ74frbLxrpPMDpZBALnnz1ZQ4kqLLZXy8pJrbpwgt6CCHNdmeUhyqcMusnqfVJEd +ZYxapUw/b645X0HTgsj5/IDxyfMGSp0CSOsqrDUlwQTJ2Dx+8iWkWpwIE7A2C/E1J9h 8Ek1uA/8sD02LIAbVgDTlj00Y7xAMaAkguNKWqumT/ZSBPbkIaAe13ywvEwiOQjchFJO BB5A== X-Forwarded-Encrypted: i=1; AJvYcCWzllc7L08kcyzeKJ0D/vO/5MItM3H0xNccui+iM+H8Ng9LRSoVN4MAtxrR7+sWioh7O8rFXu88VEWtZN7u7MJ+RUcje7IkOfKg/cUv+j/5EMsL2lxarepeZ7zYnAjIAv5vv/MdGC8IpevC4iKLp+AVify7p6qAbFTEzAHmY7fg4PJuH/4= X-Gm-Message-State: AOJu0YwoLPdKeXlwlyVqllsFrLdsNTeSTGLLvg1MoRSbdgfOSkUteUlv 7uT919q6QClHFz+KSPdS5JdrfEOBVfoYApCjwl89c+rCwm9saamGj8s8Qg== X-Received: by 2002:a19:384d:0:b0:51b:539f:d1c2 with SMTP id 2adb3069b0e04-52b8958868emr9389994e87.33.1717510334830; Tue, 04 Jun 2024 07:12:14 -0700 (PDT) Received: from yoga-710.tas.nnz-ipc.net ([178.218.200.115]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-52b982d3de7sm742743e87.2.2024.06.04.07.12.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 07:12:14 -0700 (PDT) From: Dmitry Yashin To: Linus Walleij , Heiko Stuebner Cc: Luca Ceresoli , Jianqun Xu , Jonas Karlman , devicetree@vger.kernel.org, linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, Dmitry Yashin Subject: [PATCH v3 2/2] pinctrl: rockchip: add rk3308b SoC support Date: Tue, 4 Jun 2024 19:10:20 +0500 Message-ID: <20240604141020.21725-3-dmt.yashin@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240604141020.21725-1-dmt.yashin@gmail.com> References: <20240604141020.21725-1-dmt.yashin@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Add pinctrl support for rk3308b. This pin controller much the same as rk3308's, but with additional iomux routes and 3bit iomuxes selected via gpio##_sel_src_ctrl registers. Set them up in the function rk3308b_soc_sel_src_init to use new 3bit iomuxes over some 2bit old ones and update iomux_recalced and iomux_routes for the new SoC's. Fixes: 1f3e25a06883 ("pinctrl: rockchip: fix RK3308 pinmux bits") Signed-off-by: Dmitry Yashin Reviewed-by: Luca Ceresoli --- drivers/pinctrl/pinctrl-rockchip.c | 234 +++++++++++++++++++++++++++++ drivers/pinctrl/pinctrl-rockchip.h | 1 + 2 files changed, 235 insertions(+) diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c index b252d1454ce0..b6a0eadfeed2 100644 --- a/drivers/pinctrl/pinctrl-rockchip.c +++ b/drivers/pinctrl/pinctrl-rockchip.c @@ -632,6 +632,115 @@ static struct rockchip_mux_recalced_data rk3308_mux_recalced_data[] = { }, }; +static struct rockchip_mux_recalced_data rk3308b_mux_recalced_data[] = { + { + /* gpio1b6_sel */ + .num = 1, + .pin = 14, + .reg = 0x28, + .bit = 12, + .mask = 0xf + }, { + /* gpio1b7_sel */ + .num = 1, + .pin = 15, + .reg = 0x2c, + .bit = 0, + .mask = 0x3 + }, { + /* gpio1c2_sel */ + .num = 1, + .pin = 18, + .reg = 0x30, + .bit = 4, + .mask = 0xf + }, { + /* gpio1c3_sel */ + .num = 1, + .pin = 19, + .reg = 0x30, + .bit = 8, + .mask = 0xf + }, { + /* gpio1c4_sel */ + .num = 1, + .pin = 20, + .reg = 0x30, + .bit = 12, + .mask = 0xf + }, { + /* gpio1c5_sel */ + .num = 1, + .pin = 21, + .reg = 0x34, + .bit = 0, + .mask = 0xf + }, { + /* gpio1c6_sel */ + .num = 1, + .pin = 22, + .reg = 0x34, + .bit = 4, + .mask = 0xf + }, { + /* gpio1c7_sel */ + .num = 1, + .pin = 23, + .reg = 0x34, + .bit = 8, + .mask = 0xf + }, { + /* gpio2a2_sel_plus */ + .num = 2, + .pin = 2, + .reg = 0x608, + .bit = 0, + .mask = 0x7 + }, { + /* gpio2a3_sel_plus */ + .num = 2, + .pin = 3, + .reg = 0x608, + .bit = 4, + .mask = 0x7 + }, { + /* gpio2c0_sel_plus */ + .num = 2, + .pin = 16, + .reg = 0x610, + .bit = 8, + .mask = 0x7 + }, { + /* gpio3b2_sel_plus */ + .num = 3, + .pin = 10, + .reg = 0x610, + .bit = 0, + .mask = 0x7 + }, { + /* gpio3b3_sel_plus */ + .num = 3, + .pin = 11, + .reg = 0x610, + .bit = 4, + .mask = 0x7 + }, { + /* gpio3b4_sel */ + .num = 3, + .pin = 12, + .reg = 0x68, + .bit = 8, + .mask = 0xf + }, { + /* gpio3b5_sel */ + .num = 3, + .pin = 13, + .reg = 0x68, + .bit = 12, + .mask = 0xf + }, +}; + static struct rockchip_mux_recalced_data rk3328_mux_recalced_data[] = { { .num = 2, @@ -882,6 +991,35 @@ static struct rockchip_mux_route_data rk3308_mux_route_data[] = { RK_MUXROUTE_SAME(2, RK_PA4, 3, 0x600, BIT(16 + 2) | BIT(2)), /* pdm-clkm-m2 */ }; +static struct rockchip_mux_route_data rk3308b_mux_route_data[] = { + RK_MUXROUTE_SAME(0, RK_PC3, 1, 0x314, BIT(16 + 0) | BIT(0)), /* rtc_clk */ + RK_MUXROUTE_SAME(1, RK_PC6, 2, 0x314, BIT(16 + 2) | BIT(16 + 3)), /* uart2_rxm0 */ + RK_MUXROUTE_SAME(4, RK_PD2, 2, 0x314, BIT(16 + 2) | BIT(16 + 3) | BIT(2)), /* uart2_rxm1 */ + RK_MUXROUTE_SAME(0, RK_PB7, 2, 0x608, BIT(16 + 8) | BIT(16 + 9)), /* i2c3_sdam0 */ + RK_MUXROUTE_SAME(3, RK_PB4, 2, 0x608, BIT(16 + 8) | BIT(16 + 9) | BIT(8)), /* i2c3_sdam1 */ + RK_MUXROUTE_SAME(2, RK_PA0, 3, 0x608, BIT(16 + 8) | BIT(16 + 9) | BIT(9)), /* i2c3_sdam2 */ + RK_MUXROUTE_SAME(1, RK_PA3, 2, 0x308, BIT(16 + 3)), /* i2s-8ch-1-sclktxm0 */ + RK_MUXROUTE_SAME(1, RK_PA4, 2, 0x308, BIT(16 + 3)), /* i2s-8ch-1-sclkrxm0 */ + RK_MUXROUTE_SAME(1, RK_PB5, 2, 0x308, BIT(16 + 3) | BIT(3)), /* i2s-8ch-1-sclktxm1 */ + RK_MUXROUTE_SAME(1, RK_PB6, 2, 0x308, BIT(16 + 3) | BIT(3)), /* i2s-8ch-1-sclkrxm1 */ + RK_MUXROUTE_SAME(1, RK_PA4, 3, 0x308, BIT(16 + 12) | BIT(16 + 13)), /* pdm-clkm0 */ + RK_MUXROUTE_SAME(1, RK_PB6, 4, 0x308, BIT(16 + 12) | BIT(16 + 13) | BIT(12)), /* pdm-clkm1 */ + RK_MUXROUTE_SAME(2, RK_PA6, 2, 0x308, BIT(16 + 12) | BIT(16 + 13) | BIT(13)), /* pdm-clkm2 */ + RK_MUXROUTE_SAME(2, RK_PA4, 3, 0x600, BIT(16 + 2) | BIT(2)), /* pdm-clkm-m2 */ + RK_MUXROUTE_SAME(3, RK_PB2, 3, 0x314, BIT(16 + 9)), /* spi1_miso */ + RK_MUXROUTE_SAME(2, RK_PA4, 2, 0x314, BIT(16 + 9) | BIT(9)), /* spi1_miso_m1 */ + RK_MUXROUTE_SAME(0, RK_PB3, 3, 0x314, BIT(16 + 10) | BIT(16 + 11)), /* owire_m0 */ + RK_MUXROUTE_SAME(1, RK_PC6, 7, 0x314, BIT(16 + 10) | BIT(16 + 11) | BIT(10)), /* owire_m1 */ + RK_MUXROUTE_SAME(2, RK_PA2, 5, 0x314, BIT(16 + 10) | BIT(16 + 11) | BIT(11)), /* owire_m2 */ + RK_MUXROUTE_SAME(0, RK_PB3, 2, 0x314, BIT(16 + 12) | BIT(16 + 13)), /* can_rxd_m0 */ + RK_MUXROUTE_SAME(1, RK_PC6, 5, 0x314, BIT(16 + 12) | BIT(16 + 13) | BIT(12)), /* can_rxd_m1 */ + RK_MUXROUTE_SAME(2, RK_PA2, 4, 0x314, BIT(16 + 12) | BIT(16 + 13) | BIT(13)), /* can_rxd_m2 */ + RK_MUXROUTE_SAME(1, RK_PC4, 3, 0x314, BIT(16 + 14)), /* mac_rxd0_m0 */ + RK_MUXROUTE_SAME(4, RK_PA2, 2, 0x314, BIT(16 + 14) | BIT(14)), /* mac_rxd0_m1 */ + RK_MUXROUTE_SAME(3, RK_PB4, 4, 0x314, BIT(16 + 15)), /* uart3_rx */ + RK_MUXROUTE_SAME(0, RK_PC1, 3, 0x314, BIT(16 + 15) | BIT(15)), /* uart3_rx_m1 */ +}; + static struct rockchip_mux_route_data rk3328_mux_route_data[] = { RK_MUXROUTE_SAME(1, RK_PA1, 2, 0x50, BIT(16) | BIT(16 + 1)), /* uart2dbg_rxm0 */ RK_MUXROUTE_SAME(2, RK_PA1, 1, 0x50, BIT(16) | BIT(16 + 1) | BIT(0)), /* uart2dbg_rxm1 */ @@ -2420,6 +2558,7 @@ static int rockchip_get_pull(struct rockchip_pin_bank *bank, int pin_num) case RK3188: case RK3288: case RK3308: + case RK3308B: case RK3368: case RK3399: case RK3568: @@ -2478,6 +2617,7 @@ static int rockchip_set_pull(struct rockchip_pin_bank *bank, case RK3188: case RK3288: case RK3308: + case RK3308B: case RK3368: case RK3399: case RK3568: @@ -2740,6 +2880,7 @@ static bool rockchip_pinconf_pull_valid(struct rockchip_pin_ctrl *ctrl, case RK3188: case RK3288: case RK3308: + case RK3308B: case RK3368: case RK3399: case RK3568: @@ -3348,6 +3489,93 @@ static int __maybe_unused rockchip_pinctrl_resume(struct device *dev) static SIMPLE_DEV_PM_OPS(rockchip_pinctrl_dev_pm_ops, rockchip_pinctrl_suspend, rockchip_pinctrl_resume); +#define RK3308B_GRF_SOC_CON13 0x608 +#define RK3308B_GRF_SOC_CON15 0x610 + +/* RK3308B_GRF_SOC_CON13 */ +#define RK3308B_GRF_I2C3_IOFUNC_SRC_CTRL (BIT(16 + 10) | BIT(10)) +#define RK3308B_GRF_GPIO2A3_SEL_SRC_CTRL (BIT(16 + 7) | BIT(7)) +#define RK3308B_GRF_GPIO2A2_SEL_SRC_CTRL (BIT(16 + 3) | BIT(3)) + +/* RK3308B_GRF_SOC_CON15 */ +#define RK3308B_GRF_GPIO2C0_SEL_SRC_CTRL (BIT(16 + 11) | BIT(11)) +#define RK3308B_GRF_GPIO3B3_SEL_SRC_CTRL (BIT(16 + 7) | BIT(7)) +#define RK3308B_GRF_GPIO3B2_SEL_SRC_CTRL (BIT(16 + 3) | BIT(3)) + +/* + * RK3308B has 3bit gpio##_sel_plus iomuxes over some 2bit old ones. + * Put them in use by initializing gpio##_sel_src_ctrl registers. + */ +static int rk3308b_soc_sel_src_init(struct rockchip_pinctrl *info) +{ + int ret; + + ret = regmap_write(info->regmap_base, RK3308B_GRF_SOC_CON13, + RK3308B_GRF_I2C3_IOFUNC_SRC_CTRL | + RK3308B_GRF_GPIO2A3_SEL_SRC_CTRL | + RK3308B_GRF_GPIO2A2_SEL_SRC_CTRL); + if (ret) + return ret; + + ret = regmap_write(info->regmap_base, RK3308B_GRF_SOC_CON15, + RK3308B_GRF_GPIO2C0_SEL_SRC_CTRL | + RK3308B_GRF_GPIO3B3_SEL_SRC_CTRL | + RK3308B_GRF_GPIO3B2_SEL_SRC_CTRL); + + return ret; +}; + +#define RK3308_GRF_CHIP_ID 0x800 + +static int rk3308_soc_update_type(struct rockchip_pinctrl *info) +{ + struct rockchip_pin_ctrl *ctrl = info->ctrl; + unsigned int chip_id; + int ret; + + ret = regmap_read(info->regmap_base, RK3308_GRF_CHIP_ID, &chip_id); + if (ret) + return ret; + + switch (chip_id) { + /* From RK3308 TRM: "Errata: The read only chip id value is 32'h0cea(32'd3306)" */ + case 0xcea: + break; + case 0x3308: + case 0x3308c: + ctrl->type = RK3308B; + break; + default: + return dev_err_probe(info->dev, -EINVAL, "Unknown chip_id: 0x%x\n", chip_id); + } + + return 0; +} + +static int rk3308_soc_data_update(struct rockchip_pinctrl *info) +{ + struct rockchip_pin_ctrl *ctrl = info->ctrl; + int ret; + + ret = rk3308_soc_update_type(info); + if (ret) + return ret; + + if (ctrl->type == RK3308B) { + /* Replace iomux data for RK3308B and RK3308BS */ + ctrl->iomux_recalced = rk3308b_mux_recalced_data; + ctrl->niomux_recalced = ARRAY_SIZE(rk3308b_mux_recalced_data); + ctrl->iomux_routes = rk3308b_mux_route_data; + ctrl->niomux_routes = ARRAY_SIZE(rk3308b_mux_route_data); + + ret = rk3308b_soc_sel_src_init(info); + if (ret) + return ret; + } + + return 0; +} + static int rockchip_pinctrl_probe(struct platform_device *pdev) { struct rockchip_pinctrl *info; @@ -3413,6 +3641,12 @@ static int rockchip_pinctrl_probe(struct platform_device *pdev) return PTR_ERR(info->regmap_pmu); } + if (ctrl->type == RK3308) { + ret = rk3308_soc_data_update(info); + if (ret) + return ret; + } + iomux_recalced_routes_init(info); ret = rockchip_pinctrl_register(pdev, info); diff --git a/drivers/pinctrl/pinctrl-rockchip.h b/drivers/pinctrl/pinctrl-rockchip.h index 4759f336941e..3af5b1bd626b 100644 --- a/drivers/pinctrl/pinctrl-rockchip.h +++ b/drivers/pinctrl/pinctrl-rockchip.h @@ -193,6 +193,7 @@ enum rockchip_pinctrl_type { RK3188, RK3288, RK3308, + RK3308B, RK3368, RK3399, RK3568, -- 2.39.2