Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp274650lqe; Sat, 6 Apr 2024 00:06:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX6Yz8yyDmho1Ce611wWyqVyHkmLP2xsum7KWWhTiffILO8OZR+apJ09nGqFa132mrjPdMJ5KUWxkFQC6rapjteWoAuuST5+U8HcXI6bg== X-Google-Smtp-Source: AGHT+IFUSTAQ0/Xb35sImqtLjshplosKljKEPAdvj6TB0hFXAgZ5ZGcgbm2CKylRkWtiSlE2r6S+ X-Received: by 2002:a05:622a:609:b0:434:5df:f9a9 with SMTP id z9-20020a05622a060900b0043405dff9a9mr6396341qta.16.1712387196795; Sat, 06 Apr 2024 00:06:36 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712387196; cv=pass; d=google.com; s=arc-20160816; b=baa3HGHmNfoylOWRmezC+te3yAZZBn+BerRGTMmIvQW2xKdCPmn2BsHW5oZyy36iJ0 y2qBPGd4s/xsVJ1aSkAdyN/9rw5J1QosJl4phl19iH8pkBuLJmLbJPuvQXiumo3FIMgI SR70PLbqVqfficOKH7P6IqMbggigUAEMoQ5iY7clIsA3miUSEiAs+lxVBMV/0hAs2dLp ymBmQ0yle2QowZ7excT6JVSQl5XVADBYWxp1yOHjQdNRzJGs0AQ+LA1eingGMQ51HrRF BhuyQKvild1geLupYwf1cMeUOdp0K47oxwo6P0BZalaZghEPQpqhKYfrhU2Eng/aD9tO cW4Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=FUVAztfwqMtd069Z28F/GiuGa12JGaOv0/Z4N1yYPIc=; fh=PeIFH1IrsRGwAAFXcFtlWe6Mt3lRNGr6cF8mkEVtkhw=; b=IjDbqwZ/UvAOQLGA7OmJg+39dDPfVnFPWlMH3fziPLzwjQXy5pgoJsSf2HzKPFcNaN vkly2h1uEXSY6vGNZo/GhHEdzhNpj6FYKJr0vHXYotjF9p5iicn92FW5RT+uAQqTx9gc vyJBETD/31nDJ4o+fphyWg9JQ1JJpGIxSuEvnm+/+nRM/kbOsm9n2cGx4NVnkK8n7SQ+ g077XBgwCuGL5BAq/aaJOsIE2q1xjTaNToEsyRi8tDQMKFCCSFn2zM6AkVAy9aBc1F+U 02Y0A6uDJBySHaDO3KPXw/aoVGAoBHDln30nSsiAxOUPnmMJ0tdmrXOx7KJlBIgjMKIy 30ig==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Qo4eSOcj; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-133833-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-133833-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id t13-20020a05622a148d00b00432d3044306si3539013qtx.418.2024.04.06.00.06.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Apr 2024 00:06:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-133833-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Qo4eSOcj; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-133833-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-133833-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 773281C20F8F for ; Sat, 6 Apr 2024 07:06:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6347522F02; Sat, 6 Apr 2024 07:06:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Qo4eSOcj" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 64FD52206E; Sat, 6 Apr 2024 07:06:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712387187; cv=none; b=eLzl4Luby0cW2ZEPifXFTmvaiKjV2P62D9XRPnFYX3gMBNDAIxSslS8wY4keaZ1Q9y6UO3Isg6dS5JksnKPy8ZAmZgGDSkg+5v5EaKWwIAIsADrfkiNAl6JrwSJ57reXyzjn56t0vNe0RWWVc1e7scR5T1XN4UF2INEy8Nrz8yQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712387187; c=relaxed/simple; bh=MCFYeOmRurFOqa2pWXaognBvgbOHLrLLj1a7t+4t00g=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=rtKAAseE+1dPIKNerq/eOSvyd/GbY77sEqmd7s9v+68FOpL5LsMCoD+PTPYXLtxLExlOO6s64TP7ajEuamBOdqmo+nQLbj3t8qyiXP6kvI+CXsbLQJCePAdWQPjInStw9T+hcINYpS+s9s2kOv/1aARBa3sAf03wEsd3hAewxJI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Qo4eSOcj; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0E995C43390; Sat, 6 Apr 2024 07:06:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712387186; bh=MCFYeOmRurFOqa2pWXaognBvgbOHLrLLj1a7t+4t00g=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Qo4eSOcjsN7orGimV+Ldl+ZnKKNN6IZnM6S/e3F+Yum2SMulDYOtIwqkAOE2LrAo0 xfXzoOJ8cwkYKAZ5BzJl6NcsMlGZ6cX8WwH4rvKHfyeInnpLyyayx1a+sxM52MJaUu aiVR+2+AHRKPMGHzMp4MpuRKKAWw2FPdNdpRSu1LMOX2E7CrDQU0woSYzOptZXovMx NL8If4/Qh1IOYMPZWTbdyF0g/7XbVZW+Ji5imyF4tpmwGBu7FTwhsfqFPZPtigzl3H CXShIg1ek8MCpFHFu9wf6SekZVvhxRoDg5GUdW4aJeLZlQwdRJaHtVZh4m+9u7do1v pT4T6vNRucH6A== Date: Sat, 6 Apr 2024 12:36:22 +0530 From: Vinod Koul To: Sebastian Reichel Cc: Heiko Stuebner , Kishon Vijay Abraham I , linux-rockchip@lists.infradead.org, linux-phy@lists.infradead.org, Rob Herring , Krzysztof Kozlowski , Conor Dooley , Frank Wang , Kever Yang , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, kernel@collabora.com, Zhang Yubing Subject: Re: [PATCH v4 02/10] phy: rockchip: add usbdp combo phy driver Message-ID: References: <20240325141653.84910-1-sebastian.reichel@collabora.com> <20240325141653.84910-3-sebastian.reichel@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240325141653.84910-3-sebastian.reichel@collabora.com> On 25-03-24, 15:15, Sebastian Reichel wrote: > This adds a new USBDP combo PHY with Samsung IP block driver. > > The driver get lane mux and mapping info in 2 ways, supporting > DisplayPort alternate mode or parsing from DT. When parsing from DT, > the property "rockchip,dp-lane-mux" provide the DP mux and mapping > info. This is needed when the PHY is not used with TypeC Alt-Mode. > For example if the USB3 interface of the PHY is connected to a USB > Type A connector and the DP interface is connected to a DisplayPort > connector. > > When do DP link training, need to set lane number, link rate, swing, > and pre-emphasis via PHY configure interface. > > Co-developed-by: Heiko Stuebner > Signed-off-by: Heiko Stuebner > Co-developed-by: Zhang Yubing > Signed-off-by: Zhang Yubing > Co-developed-by: Frank Wang > Signed-off-by: Frank Wang > Tested-by: Heiko Stuebner > Signed-off-by: Sebastian Reichel > --- > drivers/phy/rockchip/Kconfig | 12 + > drivers/phy/rockchip/Makefile | 1 + > drivers/phy/rockchip/phy-rockchip-usbdp.c | 1612 +++++++++++++++++++++ > 3 files changed, 1625 insertions(+) > create mode 100644 drivers/phy/rockchip/phy-rockchip-usbdp.c > > diff --git a/drivers/phy/rockchip/Kconfig b/drivers/phy/rockchip/Kconfig > index a34f67bb7e61..c3d62243b474 100644 > --- a/drivers/phy/rockchip/Kconfig > +++ b/drivers/phy/rockchip/Kconfig > @@ -115,3 +115,15 @@ config PHY_ROCKCHIP_USB > select GENERIC_PHY > help > Enable this to support the Rockchip USB 2.0 PHY. > + > +config PHY_ROCKCHIP_USBDP > + tristate "Rockchip USBDP COMBO PHY Driver" > + depends on ARCH_ROCKCHIP && OF > + select GENERIC_PHY > + select TYPEC > + help > + Enable this to support the Rockchip USB3.0/DP combo PHY with > + Samsung IP block. This is required for USB3 support on RK3588. > + > + To compile this driver as a module, choose M here: the module > + will be called phy-rockchip-usbdp > diff --git a/drivers/phy/rockchip/Makefile b/drivers/phy/rockchip/Makefile > index 3d911304e654..010a824e32ce 100644 > --- a/drivers/phy/rockchip/Makefile > +++ b/drivers/phy/rockchip/Makefile > @@ -12,3 +12,4 @@ obj-$(CONFIG_PHY_ROCKCHIP_SAMSUNG_HDPTX) += phy-rockchip-samsung-hdptx.o > obj-$(CONFIG_PHY_ROCKCHIP_SNPS_PCIE3) += phy-rockchip-snps-pcie3.o > obj-$(CONFIG_PHY_ROCKCHIP_TYPEC) += phy-rockchip-typec.o > obj-$(CONFIG_PHY_ROCKCHIP_USB) += phy-rockchip-usb.o > +obj-$(CONFIG_PHY_ROCKCHIP_USBDP) += phy-rockchip-usbdp.o > diff --git a/drivers/phy/rockchip/phy-rockchip-usbdp.c b/drivers/phy/rockchip/phy-rockchip-usbdp.c > new file mode 100644 > index 000000000000..38dc96cfe403 > --- /dev/null > +++ b/drivers/phy/rockchip/phy-rockchip-usbdp.c > @@ -0,0 +1,1612 @@ > +// SPDX-License-Identifier: GPL-2.0-or-later > +/* > + * Rockchip USBDP Combo PHY with Samsung IP block driver > + * > + * Copyright (C) 2021 Rockchip Electronics Co., Ltd we are in 2024! > + */ > + > +#include > +#include > +#include > +#include > +#include Do you need both > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include That seems a bit more of headers, do you need all of them? > +static int rk_udphy_setup(struct rk_udphy *udphy) > +{ > + int ret = 0; Superfluous init > +static int rk_udphy_parse_dt(struct rk_udphy *udphy) > +{ > + struct device *dev = udphy->dev; > + struct device_node *np = dev_of_node(dev); > + enum usb_device_speed maximum_speed; > + int ret; > + > + udphy->u2phygrf = syscon_regmap_lookup_by_phandle(np, "rockchip,u2phy-grf"); > + if (IS_ERR(udphy->u2phygrf)) > + return dev_err_probe(dev, PTR_ERR(udphy->u2phygrf), "failed to get u2phy-grf\n"); > + > + udphy->udphygrf = syscon_regmap_lookup_by_phandle(np, "rockchip,usbdpphy-grf"); > + if (IS_ERR(udphy->udphygrf)) > + return dev_err_probe(dev, PTR_ERR(udphy->udphygrf), "failed to get usbdpphy-grf\n"); > + > + udphy->usbgrf = syscon_regmap_lookup_by_phandle(np, "rockchip,usb-grf"); > + if (IS_ERR(udphy->usbgrf)) > + return dev_err_probe(dev, PTR_ERR(udphy->usbgrf), "failed to get usb-grf\n"); > + > + udphy->vogrf = syscon_regmap_lookup_by_phandle(np, "rockchip,vo-grf"); > + if (IS_ERR(udphy->vogrf)) > + return dev_err_probe(dev, PTR_ERR(udphy->vogrf), "failed to get vo-grf\n"); > + > + ret = rk_udphy_parse_lane_mux_data(udphy); > + if (ret) > + return ret; > + > + udphy->sbu1_dc_gpio = devm_gpiod_get_optional(dev, "sbu1-dc", GPIOD_OUT_LOW); > + if (IS_ERR(udphy->sbu1_dc_gpio)) > + return PTR_ERR(udphy->sbu1_dc_gpio); > + > + udphy->sbu2_dc_gpio = devm_gpiod_get_optional(dev, "sbu2-dc", GPIOD_OUT_LOW); > + if (IS_ERR(udphy->sbu2_dc_gpio)) > + return PTR_ERR(udphy->sbu2_dc_gpio); > + > + if (device_property_present(dev, "maximum-speed")) { > + maximum_speed = usb_get_maximum_speed(dev); > + udphy->hs = maximum_speed <= USB_SPEED_HIGH ? true : false; > + } > + > + ret = rk_udphy_clk_init(udphy, dev); > + if (ret) > + return ret; > + > + ret = rk_udphy_reset_init(udphy, dev); > + if (ret) > + return ret; > + > + return 0; return rk_udphy_reset_init() > +static const struct phy_ops rk_udphy_dp_phy_ops = { > + .init = rk_udphy_dp_phy_init, > + .exit = rk_udphy_dp_phy_exit, > + .power_on = rk_udphy_dp_phy_power_on, > + .power_off = rk_udphy_dp_phy_power_off, > + .configure = rk_udphy_dp_phy_configure, > + .owner = THIS_MODULE, > +}; > + > +static int rk_udphy_usb3_phy_init(struct phy *phy) > +{ > + struct rk_udphy *udphy = phy_get_drvdata(phy); > + int ret = 0; Superfluous init here too -- ~Vinod