Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp925939rdb; Thu, 15 Feb 2024 22:47:48 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUr8t2SytINv2ACuo+YhqwsV4t/Qra+EtU7co/o/AGgOwTZcRkLfYB+qBL8sVRiGaY0hPnn/vDsyAN7GAju672804VNx7x/dUJsciE21Q== X-Google-Smtp-Source: AGHT+IHR26y6PkAmiOTEi5ZaxE0LgwUKEIwjHhGoelsJnAyXRXpqai0W2Ajsr+4eH3qPXgYUnEaG X-Received: by 2002:a05:6870:63a1:b0:21a:1b9d:7212 with SMTP id t33-20020a05687063a100b0021a1b9d7212mr4505087oap.17.1708066067748; Thu, 15 Feb 2024 22:47:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708066067; cv=pass; d=google.com; s=arc-20160816; b=bE2xlkK4S1EjW19ffZdr1cjpyVZ11xBbJqg/NPPabF35lAaDen3b2NaBEttQ3QyjHQ 9dMoJim5PIKcVLqsTIRAEqC7rQJdTLwWlABi2ov2Ia54YIWWYx+NhC/maYYWB6v1Jjgu wa0IVf6ClOlCL8jw1X5MsmoCp1QtCt+mtu7FLAW9u6BIqbhCmJZMiNXCyErQZyvGnTX1 VWk/098kMAuo7k1V9JrfbwhEwboPuXWj0BQm6QS6ef6mdFM20NTWj3TUL7n9klOTgjBU DyLz8Y26g+YRquOzECAOZ0pHl/5BsCF79I12SjXEyFn8bopwGZmI1QDTihPLCKb9EV9R nRFg== 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=GqsH3IY/sDMmHTSSKWZUe5tiYSXKqtlC29aIbA6kBHo=; fh=PeIFH1IrsRGwAAFXcFtlWe6Mt3lRNGr6cF8mkEVtkhw=; b=ro75uuhjGxm7T+XQ6Zs0LlsiNA6ennw32W64MrQTwp85IVglwjpytwcFYJE+mM5iy7 6SGmcN5Y2CsH+yM1SiLPH/5l+8J3NeYlYMrbi0BZvqu6nLT2pv3DDl9c2vJWMETKi7Af G1nOSw2w/uliPLmD649gTrhV/V9bbUKKXZ3WG7ONpBP8+O4JuqPKPyLAG3aHljHWdjKz flM0Ntvl4yKfmrs3N/ASdv5H5nKryZ25+LXYOcWjWqjy/gMHw5EX2OL9iBPDFqhT9fmM /PCMVw8eTHcvRJGKwUwiKqa5UfxmnHMQfmdRjmNmBvLbqwfHZouwgyuzZjWRIDUAhnRI yG3Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OFixQkYX; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-68111-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68111-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id h63-20020a638342000000b005dc47b71821si2460024pge.572.2024.02.15.22.47.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 22:47:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-68111-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OFixQkYX; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-68111-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68111-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 69CEC286AC9 for ; Fri, 16 Feb 2024 06:47:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E2EB11429B; Fri, 16 Feb 2024 06:47:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="OFixQkYX" 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 E1D06EEAC; Fri, 16 Feb 2024 06:47:37 +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=1708066058; cv=none; b=amERx59PljaQidHEMd/WWsDq4U8BDFvqJ+KtKhNghlAJxY14ampTc0yu61lnGANrfWqHgbNiGjdEgxxCk3nSJJPSeljL2FfUkO683AgW8UTf6zLPc+qw7e478OjEA18e237FFHBgyF/Dkqd9mth47+H/2+w5338+L2wHmvHn3Uo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708066058; c=relaxed/simple; bh=IaYS5krugxcWWLdlP3aNH0s2GExm1DY2BuiHt8XgCtM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=L1DhMnTHmWQgKfm3HtkDwD8bb/qWCXjAUQG9PuC3e4d9u5MyIPmuRgJjDuEWFhpxtnhTBsaZrJGNgvmf9KQMQtLLbdHRisPv8/YlqTrdoAbtPzbSbFoBAvPxK7ZTXaXo8PrZ6PLcc5rSt9MGWIB/aa2WrIZAHxbq5XYZCqXTIPo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=OFixQkYX; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 28845C433C7; Fri, 16 Feb 2024 06:47:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708066057; bh=IaYS5krugxcWWLdlP3aNH0s2GExm1DY2BuiHt8XgCtM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=OFixQkYX/oFkmeTY9XozPfHlCyyrwGGiRn+t5Qo2SQB/M3BQWiTr6Gmi+2QULbQIP ZXyActqWf41o80jJ/+K/aXx3YrthzC4zot80y4ffZW05ZYxhXuJLS4Xb9d8m+4qWm4 ZITMB1FHWB47wV/xS9bobtFeFdi8szGyjBCxLvwX6VopLmpkmGPqg/gMb4BR97pBwO HOXf7/oYuxZ+TR5Qjqc8l5ef/mmv6O4cZt7vWOFgPIOo42otWumPFAq/7INIlaVp+D lZvsWls0YcMYkkuRYs8lmSvHfHBp3g4mkjYpFRZt/hOfeHmFVZszks349e2vRiV7ZP PJ0kdCoTwZeEQ== Date: Fri, 16 Feb 2024 12:17:32 +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 v2 04/12] phy: rockchip: add usbdp combo phy driver Message-ID: References: <20240213163609.44930-1-sebastian.reichel@collabora.com> <20240213163609.44930-5-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: <20240213163609.44930-5-sebastian.reichel@collabora.com> On 13-02-24, 17:32, 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 > Signed-off-by: Sebastian Reichel > --- > drivers/phy/rockchip/Kconfig | 12 + > drivers/phy/rockchip/Makefile | 1 + > drivers/phy/rockchip/phy-rockchip-usbdp.c | 1639 +++++++++++++++++++++ > 3 files changed, 1652 insertions(+) > create mode 100644 drivers/phy/rockchip/phy-rockchip-usbdp.c > > diff --git a/drivers/phy/rockchip/Kconfig b/drivers/phy/rockchip/Kconfig > index 94360fc96a6f..d21b458c1d18 100644 > --- a/drivers/phy/rockchip/Kconfig > +++ b/drivers/phy/rockchip/Kconfig > @@ -107,3 +107,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 7eab129230d1..25d2e1355db7 100644 > --- a/drivers/phy/rockchip/Makefile > +++ b/drivers/phy/rockchip/Makefile > @@ -11,3 +11,4 @@ obj-$(CONFIG_PHY_ROCKCHIP_PCIE) += phy-rockchip-pcie.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..8b1ace2aaa98 > --- /dev/null > +++ b/drivers/phy/rockchip/phy-rockchip-usbdp.c > @@ -0,0 +1,1639 @@ > +// SPDX-License-Identifier: GPL-2.0-or-later > +/* > + * Rockchip USBDP Combo PHY with Samsung IP block driver > + * > + * Copyright (C) 2021 Rockchip Electronics Co., Ltd > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include Thats a lot of headers, do you need all? > +static inline int rk_udphy_grfreg_write(struct regmap *base, > + const struct rk_udphy_grf_reg *reg, bool en) > +{ > + u32 val, mask, tmp; > + > + tmp = en ? reg->enable : reg->disable; > + mask = GENMASK(reg->bitend, reg->bitstart); > + val = (tmp << reg->bitstart) | (mask << BIT_WRITEABLE_SHIFT); Perhaps FIELD_PREP|GET for these? > +static int rk_udphy_dplane_get(struct rk_udphy *udphy) > +{ > + int dp_lanes; > + > + switch (udphy->mode) { > + case UDPHY_MODE_DP: > + dp_lanes = 4; > + break; empty line after break makes it more readable > + case UDPHY_MODE_DP_USB: > + dp_lanes = 2; > + break; > + case UDPHY_MODE_USB: > + fallthrough; > + default: > + dp_lanes = 0; > + break; > + } > + > + return dp_lanes; > +} > + > +static int rk_udphy_dplane_enable(struct rk_udphy *udphy, int dp_lanes) > +{ > + u32 val = 0; > + int i; > + > + for (i = 0; i < dp_lanes; i++) > + val |= BIT(udphy->dp_lane_sel[i]); > + > + regmap_update_bits(udphy->pma_regmap, CMN_LANE_MUX_AND_EN_OFFSET, CMN_DP_LANE_EN_ALL, > + FIELD_PREP(CMN_DP_LANE_EN_ALL, val)); > + > + if (!dp_lanes) > + regmap_update_bits(udphy->pma_regmap, CMN_DP_RSTN_OFFSET, > + CMN_DP_CMN_RSTN, FIELD_PREP(CMN_DP_CMN_RSTN, 0x0)); > + > + return 0; there is no error generation in the fn, these kind of fn should really be not returning anything > +static int rk_udphy_usb3_phy_init(struct phy *phy) > +{ > + struct rk_udphy *udphy = phy_get_drvdata(phy); > + int ret = 0; > + > + mutex_lock(&udphy->mutex); > + /* DP only or high-speed, disable U3 port */ > + if (!(udphy->mode & UDPHY_MODE_USB) || udphy->hs) { > + rk_udphy_u3_port_disable(udphy, true); > + goto unlock; no power up in that case? > + } > + > + ret = rk_udphy_power_on(udphy, UDPHY_MODE_USB); > + > +unlock: > + mutex_unlock(&udphy->mutex); > + return ret; > +} -- ~Vinod