From nobody Sat Jul 09 13:12:13 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 346771D02754; Sat, 9 Jul 2022 13:12:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Lg9Xs6Dvpz3F5b; Sat, 9 Jul 2022 13:12:13 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1657372333; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=lirbzQSsf939P3xUzFv4vMTfWWa3iRV04Cw8QyL8h0M=; b=ayI27Ncfh8HQ1Nhw/zlXz+vLQxP5m5JAq8lQohorQkYbFsUAO7zZK1fpCDEhq7TN/V/iKH RTV5Psb3xCBhvloBafI2QvHlZ2vYdePUyt/Z0KxKCwWaVrIQlMT2tKJv8Dg9dwNpnb3b/i +SioVRPq8i2UeQh9li2ulLkgVr+RhiETtLrbUa2QqszKObRXOiOaKv2YL6Y+aDaPN18eOe VCJ/wKgYqsGu/Uj0qAxuxFkzGJgwO/pBNTQTMFAVn1UZh3KP0WsemTFR1OjxaxgRrFRqr/ Vo+JoB3Fjpt/Lv0qhGeYFUFdC9S0PPfUkHmqvX5k8RQKZcxzZcOo1sC7uodqoA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Lg9Xs5Kplzmnt; Sat, 9 Jul 2022 13:12:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 269DCD2m060782; Sat, 9 Jul 2022 13:12:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 269DCD2A060781; Sat, 9 Jul 2022 13:12:13 GMT (envelope-from git) Date: Sat, 9 Jul 2022 13:12:13 GMT Message-Id: <202207091312.269DCD2A060781@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ganbold Tsagaankhuu Subject: git: eec3290266bc - main - Add RK3568 SoC support to pinctrl driver. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: ganbold X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: eec3290266bc09b4c4b4d875d2269d611adc0016 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1657372333; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=lirbzQSsf939P3xUzFv4vMTfWWa3iRV04Cw8QyL8h0M=; b=Zw11GX7fXs6Q5VvK//UbbiQUuw+4GezQfbwV9AFHL0UXPaTChi+I5TRPfUjwVEBU090q2B n7st7Dg3kDl8IRpIHCgQJRL+KSjkiYBVM8Xz4/j7Qz0MJeObyD2fhPi+6OiDc/5ac9V6qG 26vZuuweabNWWooFzQquel9CPeMZtWB/4g++ZH3afPx43Q4dZj0Bndx7LsXbDDVhA1Tv5B aWL39eyJcY7grJZL9OvpIErIUr+9V2pidobLTUzkBmgRr7Wj/9X0VaCiFzo+ngmsWJoslw hjOTdGR/ku+PvFAChK9ObPihI+rFsq7M5+f2oY60pfwbJH5BQQLwAaD/7/wUiw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1657372333; a=rsa-sha256; cv=none; b=yj0rn5m0lIm33vvHxEGMlsfhcocwiFEGHNg/WeCOZf69q87pN/ZzYsL3d758YTt2hEjqe2 wkMvQWfW0sR3UaTozEgiH0xv8ehwM1UtEuXIyGvGHJPuqmXWJqfeqpCpjkWAo1i4JalYmu sMkRDNGiNqaYTui8ZjwcfY1Pzn3w0POv3TgGYJX+tJPxk+dXyeZqUj4ItmlG9ZPdsi1mvB 0yoILuGxT0bFFb6PjEBk+9eNqxgaEc7ucV7GBtITTsYpTvb3XuE6gDPxMc655ZOuyNs/iw 0yWSAJVcBWC7c6V4RAzsohwYYstuPp06wAUkJyyQMOv3mvWJiZWCp6Edd9f24w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by ganbold: URL: https://cgit.FreeBSD.org/src/commit/?id=eec3290266bc09b4c4b4d875d2269d611adc0016 commit eec3290266bc09b4c4b4d875d2269d611adc0016 Author: Ganbold Tsagaankhuu AuthorDate: 2022-07-09 13:06:52 +0000 Commit: Ganbold Tsagaankhuu CommitDate: 2022-07-09 13:06:52 +0000 Add RK3568 SoC support to pinctrl driver. Submitted by: sos Reviewed by: manu Differential Revision: https://reviews.freebsd.org/D31330 --- sys/arm64/rockchip/rk_pinctrl.c | 232 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 230 insertions(+), 2 deletions(-) diff --git a/sys/arm64/rockchip/rk_pinctrl.c b/sys/arm64/rockchip/rk_pinctrl.c index a6561658ba92..ae633f052a21 100644 --- a/sys/arm64/rockchip/rk_pinctrl.c +++ b/sys/arm64/rockchip/rk_pinctrl.c @@ -767,10 +767,237 @@ struct rk_pinctrl_conf rk3399_conf = { .get_bias_value = rk3399_get_bias_value, }; +static struct rk_pinctrl_gpio rk3568_gpio_bank[] = { + RK_GPIO(0, "gpio0"), + RK_GPIO(1, "gpio1"), + RK_GPIO(2, "gpio2"), + RK_GPIO(3, "gpio3"), + RK_GPIO(4, "gpio4"), +}; + +static struct rk_pinctrl_bank rk3568_iomux_bank[] = { + /* bank sub offs nbits */ + RK_IOMUX(0, 0, 0x0000, 4), /* PMU_GRF */ + RK_IOMUX(0, 1, 0x0008, 4), + RK_IOMUX(0, 2, 0x0010, 4), + RK_IOMUX(0, 3, 0x0018, 4), + + RK_IOMUX(1, 0, 0x0000, 4), /* SYS_GRF */ + RK_IOMUX(1, 1, 0x0008, 4), + RK_IOMUX(1, 2, 0x0010, 4), + RK_IOMUX(1, 3, 0x0018, 4), + RK_IOMUX(2, 0, 0x0020, 4), + RK_IOMUX(2, 1, 0x0028, 4), + RK_IOMUX(2, 2, 0x0030, 4), + RK_IOMUX(2, 3, 0x0038, 4), + RK_IOMUX(3, 0, 0x0040, 4), + RK_IOMUX(3, 1, 0x0048, 4), + RK_IOMUX(3, 2, 0x0050, 4), + RK_IOMUX(3, 3, 0x0058, 4), + RK_IOMUX(4, 0, 0x0060, 4), + RK_IOMUX(4, 1, 0x0068, 4), + RK_IOMUX(4, 2, 0x0070, 4), + RK_IOMUX(4, 3, 0x0078, 4), +}; + +static struct rk_pinctrl_pin_fixup rk3568_pin_fixup[] = {}; + +static struct rk_pinctrl_pin_drive rk3568_pin_drive[] = { + /* bank sub offs val ma */ + /* GPIO0A */ + RK_PINDRIVE(0, 0, 0x0020, 0, 2), + RK_PINDRIVE(0, 0, 0x0020, 1, 4), + RK_PINDRIVE(0, 0, 0x0020, 2, 8), + RK_PINDRIVE(0, 0, 0x0020, 3, 12), + + /* GPIO0B */ + RK_PINDRIVE(0, 1, 0x0024, 0, 2), + RK_PINDRIVE(0, 1, 0x0024, 1, 4), + RK_PINDRIVE(0, 1, 0x0024, 2, 8), + RK_PINDRIVE(0, 1, 0x0024, 3, 12), + + /* GPIO0C */ + RK_PINDRIVE(0, 1, 0x0028, 0, 2), + RK_PINDRIVE(0, 1, 0x0028, 1, 4), + RK_PINDRIVE(0, 1, 0x0028, 2, 8), + RK_PINDRIVE(0, 1, 0x0028, 3, 12), + + /* GPIO0D */ + RK_PINDRIVE(0, 1, 0x002c, 0, 2), + RK_PINDRIVE(0, 1, 0x002c, 1, 4), + RK_PINDRIVE(0, 1, 0x002c, 2, 8), + RK_PINDRIVE(0, 1, 0x002c, 3, 12), + + /* GPIO1A */ + RK_PINDRIVE(1, 0, 0x0080, 0, 2), + RK_PINDRIVE(1, 0, 0x0080, 1, 4), + RK_PINDRIVE(1, 0, 0x0080, 2, 8), + RK_PINDRIVE(1, 0, 0x0080, 3, 12), + + /* GPIO1B */ + RK_PINDRIVE(1, 1, 0x0084, 0, 2), + RK_PINDRIVE(1, 1, 0x0084, 1, 4), + RK_PINDRIVE(1, 1, 0x0084, 2, 8), + RK_PINDRIVE(1, 1, 0x0084, 3, 12), + + /* GPIO1C */ + RK_PINDRIVE(1, 2, 0x0088, 0, 2), + RK_PINDRIVE(1, 2, 0x0088, 1, 4), + RK_PINDRIVE(1, 2, 0x0088, 2, 8), + RK_PINDRIVE(1, 2, 0x0088, 3, 12), + + /* GPIO1D */ + RK_PINDRIVE(1, 3, 0x008c, 0, 2), + RK_PINDRIVE(1, 3, 0x008c, 1, 4), + RK_PINDRIVE(1, 3, 0x008c, 2, 8), + RK_PINDRIVE(1, 3, 0x008c, 3, 12), + + /* GPIO2A */ + RK_PINDRIVE(2, 0, 0x0090, 0, 2), + RK_PINDRIVE(2, 0, 0x0090, 1, 4), + RK_PINDRIVE(2, 0, 0x0090, 2, 8), + RK_PINDRIVE(2, 0, 0x0090, 3, 12), + + /* GPIO2B */ + RK_PINDRIVE(2, 1, 0x0094, 0, 2), + RK_PINDRIVE(2, 1, 0x0094, 1, 4), + RK_PINDRIVE(2, 1, 0x0094, 2, 8), + RK_PINDRIVE(2, 1, 0x0094, 3, 12), + + /* GPIO2C */ + RK_PINDRIVE(2, 2, 0x0098, 0, 2), + RK_PINDRIVE(2, 2, 0x0098, 1, 4), + RK_PINDRIVE(2, 2, 0x0098, 2, 8), + RK_PINDRIVE(2, 2, 0x0098, 3, 12), + + /* GPIO2D */ + RK_PINDRIVE(2, 3, 0x009c, 0, 2), + RK_PINDRIVE(2, 3, 0x009c, 1, 4), + RK_PINDRIVE(2, 3, 0x009c, 2, 8), + RK_PINDRIVE(2, 3, 0x009c, 3, 12), + + /* GPIO3A */ + RK_PINDRIVE(3, 0, 0x00a0, 0, 2), + RK_PINDRIVE(3, 0, 0x00a0, 1, 4), + RK_PINDRIVE(3, 0, 0x00a0, 2, 8), + RK_PINDRIVE(3, 0, 0x00a0, 3, 12), + + /* GPIO3B */ + RK_PINDRIVE(3, 1, 0x00a4, 0, 2), + RK_PINDRIVE(3, 1, 0x00a4, 1, 4), + RK_PINDRIVE(3, 1, 0x00a4, 2, 8), + RK_PINDRIVE(3, 1, 0x00a4, 3, 12), + + /* GPIO3C */ + RK_PINDRIVE(3, 2, 0x00a8, 0, 2), + RK_PINDRIVE(3, 2, 0x00a8, 1, 4), + RK_PINDRIVE(3, 2, 0x00a8, 2, 8), + RK_PINDRIVE(3, 2, 0x00a8, 3, 12), + + /* GPIO3D */ + RK_PINDRIVE(3, 3, 0x00ac, 0, 2), + RK_PINDRIVE(3, 3, 0x00ac, 1, 4), + RK_PINDRIVE(3, 3, 0x00ac, 2, 8), + RK_PINDRIVE(3, 3, 0x00ac, 3, 12), + + /* GPIO4A */ + RK_PINDRIVE(4, 0, 0x00b0, 0, 2), + RK_PINDRIVE(4, 0, 0x00b0, 1, 4), + RK_PINDRIVE(4, 0, 0x00b0, 2, 8), + RK_PINDRIVE(4, 0, 0x00b0, 3, 12), + + /* GPIO4B */ + RK_PINDRIVE(4, 1, 0x00b4, 0, 2), + RK_PINDRIVE(4, 1, 0x00b4, 1, 4), + RK_PINDRIVE(4, 1, 0x00b4, 2, 8), + RK_PINDRIVE(4, 1, 0x00b4, 3, 12), + + /* GPIO4C */ + RK_PINDRIVE(4, 2, 0x00b8, 0, 2), + RK_PINDRIVE(4, 2, 0x00b8, 1, 4), + RK_PINDRIVE(4, 2, 0x00b8, 2, 8), + RK_PINDRIVE(4, 2, 0x00b8, 3, 12), + + /* GPIO4D */ + RK_PINDRIVE(4, 3, 0x00bc, 0, 2), + RK_PINDRIVE(4, 3, 0x00bc, 1, 4), + RK_PINDRIVE(4, 3, 0x00bc, 2, 8), + RK_PINDRIVE(4, 3, 0x00bc, 3, 12), +}; + +static uint32_t +rk3568_get_pd_offset(struct rk_pinctrl_softc *sc, uint32_t bank) +{ + + return (0); +} + +static struct syscon * +rk3568_get_syscon(struct rk_pinctrl_softc *sc, uint32_t bank) +{ + + if (bank) + return (sc->grf); + else + return (sc->pmu); +} + +static int +rk3568_parse_bias(phandle_t node, int bank) +{ + + if (OF_hasprop(node, "bias-disable")) + return (0); + if (OF_hasprop(node, "bias-pull-up")) + return (1); + if (OF_hasprop(node, "bias-pull-down")) + return (2); + return (-1); +} + +static int +rk3568_resolv_bias_value(int bank, int bias) +{ + + if (bias == 1) + return (GPIO_PIN_PULLUP); + if (bias == 2) + return (GPIO_PIN_PULLDOWN); + return (0); +} + +static int +rk3568_get_bias_value(int bank, int bias) +{ + + if (bias & GPIO_PIN_PULLUP) + return (1); + if (bias & GPIO_PIN_PULLDOWN) + return (2); + return (0); +} + +struct rk_pinctrl_conf rk3568_conf = { + .iomux_conf = rk3568_iomux_bank, + .iomux_nbanks = nitems(rk3568_iomux_bank), + .pin_fixup = rk3568_pin_fixup, + .npin_fixup = nitems(rk3568_pin_fixup), + .pin_drive = rk3568_pin_drive, + .npin_drive = nitems(rk3568_pin_drive), + .gpio_bank = rk3568_gpio_bank, + .ngpio_bank = nitems(rk3568_gpio_bank), + .get_pd_offset = rk3568_get_pd_offset, + .get_syscon = rk3568_get_syscon, + .parse_bias = rk3568_parse_bias, + .resolv_bias_value = rk3568_resolv_bias_value, + .get_bias_value = rk3568_get_bias_value, +}; + static struct ofw_compat_data compat_data[] = { {"rockchip,rk3288-pinctrl", (uintptr_t)&rk3288_conf}, {"rockchip,rk3328-pinctrl", (uintptr_t)&rk3328_conf}, {"rockchip,rk3399-pinctrl", (uintptr_t)&rk3399_conf}, + {"rockchip,rk3568-pinctrl", (uintptr_t)&rk3568_conf}, {NULL, 0} }; @@ -1240,8 +1467,9 @@ rk_pinctrl_attach(device_t dev) return (ENXIO); } - /* RK3399,RK3288 has banks in PMU. RK3328 does not have a PMU. */ - if (ofw_bus_node_is_compatible(node, "rockchip,rk3399-pinctrl") || + /* RK3568,RK3399,RK3288 have banks in PMU. RK3328 doesn't have a PMU. */ + if (ofw_bus_node_is_compatible(node, "rockchip,rk3568-pinctrl") || + ofw_bus_node_is_compatible(node, "rockchip,rk3399-pinctrl") || ofw_bus_node_is_compatible(node, "rockchip,rk3288-pinctrl")) { if (OF_hasprop(node, "rockchip,pmu") && syscon_get_by_ofw_property(dev, node,