From nobody Wed Dec 28 03:50:08 2022 X-Original-To: dev-commits-src-main@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 4Nhcwx1d26z2kjyZ; Wed, 28 Dec 2022 03:50:09 +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 4Nhcwx0lScz3n1V; Wed, 28 Dec 2022 03:50:09 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1672199409; 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=VuuB3bZIviOFWsaF9PrYtYrXc2AFsN5arHlL7FHk1kQ=; b=VXrNt6b8XcF5bItPyQ05wtN2fxXA8FdQjxIJvYulCb9sSTH8TO8ZwrowKyjzI0s9rm27c0 Q01P1hRW5UwLV5qbD0POyAFiTxvk1SNaiv0N/ph01OwIkoxp4cQPWFYJSZNK/Ctchf6VW+ HNgKa6rQM05QKUvQ7P1PBNGrgBErVXewBXOW9uSn+E4SqObkvbfovQwbLQ4RgxFT7VQpaw PF6nYnS6qxNFN2gq9O035sE87LjdHY6wJCyv8+OtTFtXgnEh8WV5KG9f1jI3PUvEqyArui g82RUoXXCNnE6mCeP5/+Cy8OSojRWEi6XUSRfwlRS1yVHLbju/f9rxkqDhVItw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1672199409; 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=VuuB3bZIviOFWsaF9PrYtYrXc2AFsN5arHlL7FHk1kQ=; b=c+LeaIheKgDPFHl/q81OGUZM1abwjazg3snfzZxDPbmOC2lvawixtDiIVGofqBbPAyWwSs TsPACDsuqptHlO5siKZKlx217CEFtc1XL2SQQ72euoohZNnVxTG7ItqjEaCw5WcsnievXV UUMdorpYv61vWhf+4ZTSRZ3WqaDn7ZWGIXxXIMy0EE49Am+UEV01ogqUE96NbcrYujiZPU BYY44kn+7IRrvcYZ670qAPQA76GcxO8RCdbEImeCk6K1GIr6TkL5B0yk06tzHM9+R6fVRH GYoSCGTxphz6WE0AtKP9dhL5/LjX8PlUNH0CpeWB59Umdj2F3yj0KiZ5IwwFLw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1672199409; a=rsa-sha256; cv=none; b=DqgkyTI7C1U3fdZial0HB/vDgHTrZZTmjO+04gYheXhY4Kab2UwqxN+5wDK17ZZ+HYWQmk kZFPyj5ojJKA/AnMWeqYPhF6twVTEYlYVJVS7j/jkg+dBEJKTiszQI7KbsWJ7fVQAORZYT oAdjhXXebIz6exM2RSF38IrVsovPBpdMlMrwWZlfcuVo/qzJKut7hrhT8yR4ID8fQxwO3g Zuf3xBqSxTBc3IjPor41A3n3y67XJuQpUoG9ncqx2gBEQBx1DLZk4tscmzl2+I4Zuum/IP nYNA10RBske6fIDJlpYfpVovN0KuDszN0X0ac4Ljoil15pHMCVPzl2g89eiB0g== 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 4Nhcww6V8rzbPS; Wed, 28 Dec 2022 03:50:08 +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 2BS3o8Rh004228; Wed, 28 Dec 2022 03:50:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2BS3o8E2004221; Wed, 28 Dec 2022 03:50:08 GMT (envelope-from git) Date: Wed, 28 Dec 2022 03:50:08 GMT Message-Id: <202212280350.2BS3o8E2004221@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: 79c6e0b31f32 - main - Improve and make it more general Rockchip USB2PHY driver. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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: 79c6e0b31f32a2df4bfe682de29e7b7b135fb51d Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by ganbold: URL: https://cgit.FreeBSD.org/src/commit/?id=79c6e0b31f32a2df4bfe682de29e7b7b135fb51d commit 79c6e0b31f32a2df4bfe682de29e7b7b135fb51d Author: Søren Schmidt AuthorDate: 2022-12-28 03:48:48 +0000 Commit: Ganbold Tsagaankhuu CommitDate: 2022-12-28 03:48:48 +0000 Improve and make it more general Rockchip USB2PHY driver. Add support for Rockchip RK3568. --- sys/arm64/rockchip/rk_usb2phy.c | 53 +++++++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 18 deletions(-) diff --git a/sys/arm64/rockchip/rk_usb2phy.c b/sys/arm64/rockchip/rk_usb2phy.c index b7ba19488f85..58072ffc3ee9 100644 --- a/sys/arm64/rockchip/rk_usb2phy.c +++ b/sys/arm64/rockchip/rk_usb2phy.c @@ -54,11 +54,6 @@ __FBSDID("$FreeBSD$"); #include "clkdev_if.h" #include "syscon_if.h" -#define RK3399_GRF_USB20_PHY0_CON0 0x0 -#define RK3399_GRF_USB20_PHY0_CON1 0x4 -#define RK3399_GRF_USB20_PHY0_CON2 0x8 -#define RK3399_GRF_USB20_PHY0_CON3 0xC - struct rk_usb2phy_reg { uint32_t offset; uint32_t enable_mask; @@ -71,14 +66,25 @@ struct rk_usb2phy_regs { struct rk_usb2phy_regs rk3399_regs = { .clk_ctl = { + .offset = 0x0000, /* bit 4 put pll in suspend */ .enable_mask = 0x100000, .disable_mask = 0x100010, } }; +struct rk_usb2phy_regs rk3568_regs = { + .clk_ctl = { + .offset = 0x0008, + .enable_mask = 0x100000, + /* bit 4 put pll in suspend */ + .disable_mask = 0x100010, + } +}; + static struct ofw_compat_data compat_data[] = { { "rockchip,rk3399-usb2phy", (uintptr_t)&rk3399_regs }, + { "rockchip,rk3568-usb2phy", (uintptr_t)&rk3568_regs }, { NULL, 0 } }; @@ -106,9 +112,9 @@ DEFINE_CLASS_1(rk_usb2phy_phynode, rk_usb2phy_phynode_class, rk_usb2phy_phynode_methods, sizeof(struct phynode_usb_sc), phynode_usb_class); -enum RK3399_USBPHY { - RK3399_USBPHY_HOST = 0, - RK3399_USBPHY_OTG, +enum RK_USBPHY { + RK_USBPHY_HOST = 0, + RK_USBPHY_OTG, }; static int @@ -123,7 +129,7 @@ rk_usb2phy_enable(struct phynode *phynode, bool enable) phy = phynode_get_id(phynode); sc = device_get_softc(dev); - if (phy != RK3399_USBPHY_HOST) + if (phy != RK_USBPHY_HOST) return (ERANGE); if (sc->phy_supply) { @@ -154,7 +160,7 @@ rk_usb2phy_get_mode(struct phynode *phynode, int *mode) phy = phynode_get_id(phynode); sc = device_get_softc(dev); - if (phy != RK3399_USBPHY_HOST) + if (phy != RK_USBPHY_HOST) return (ERANGE); *mode = sc->mode; @@ -173,7 +179,7 @@ rk_usb2phy_set_mode(struct phynode *phynode, int mode) phy = phynode_get_id(phynode); sc = device_get_softc(dev); - if (phy != RK3399_USBPHY_HOST) + if (phy != RK_USBPHY_HOST) return (ERANGE); sc->mode = mode; @@ -304,8 +310,10 @@ rk_usb2phy_export_clock(struct rk_usb2phy_softc *devsc) sc->clkdev = device_get_parent(devsc->dev); sc->grf = devsc->grf; sc->regs = (struct rk_usb2phy_regs *)ofw_bus_search_compatible(devsc->dev, compat_data)->ocd_data; - OF_getencprop(node, "reg", regs, sizeof(regs)); - sc->regs->clk_ctl.offset = regs[0]; + if (sc->regs->clk_ctl.offset == 0) { + OF_getencprop(node, "reg", regs, sizeof(regs)); + sc->regs->clk_ctl.offset = regs[0]; + } clknode_register(clkdom, clk); if (clkdom_finit(clkdom) != 0) { @@ -329,7 +337,7 @@ rk_usb2phy_probe(device_t dev) if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) return (ENXIO); - device_set_desc(dev, "Rockchip RK3399 USB2PHY"); + device_set_desc(dev, "Rockchip USB2PHY"); return (BUS_PROBE_DEFAULT); } @@ -346,9 +354,18 @@ rk_usb2phy_attach(device_t dev) sc->dev = dev; node = ofw_bus_get_node(dev); - if (syscon_get_handle_default(dev, &sc->grf) != 0) { - device_printf(dev, "Cannot get syscon handle\n"); - return (ENXIO); + if (OF_hasprop(node, "rockchip,usbgrf")) { + if (syscon_get_by_ofw_property(dev, node, "rockchip,usbgrf", + &sc->grf)) { + device_printf(dev, "Cannot get syscon handle\n"); + return (ENXIO); + } + } + else { + if (syscon_get_handle_default(dev, &sc->grf)) { + device_printf(dev, "Cannot get syscon handle\n"); + return (ENXIO); + } } if (clk_get_by_ofw_name(dev, 0, "phyclk", &sc->clk) != 0) { @@ -380,7 +397,7 @@ rk_usb2phy_attach(device_t dev) } regulator_get_by_ofw_property(dev, host, "phy-supply", &sc->phy_supply); - phy_init.id = RK3399_USBPHY_HOST; + phy_init.id = RK_USBPHY_HOST; phy_init.ofw_node = host; phynode = phynode_create(dev, &rk_usb2phy_phynode_class, &phy_init); if (phynode == NULL) {