Received: by 2002:ab2:5182:0:b0:1f4:61d5:3ad4 with SMTP id x2csp68492lqi; Fri, 5 Apr 2024 09:57:33 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUUmwtEMWxDbn7c4B3PZSwVU1fuXin+TbK85gI1OqxIorb/jkJEPMyoEoheIqp21ypQLeQ4REsKORBYjxQOYXxU7/pvzPOLHGsdGCS/mg== X-Google-Smtp-Source: AGHT+IGx1Pd1XFnNspsK9zElxFPdayYTSFaXADUQYGi2BgnnW3XUbNJK88a6ooWCvJw6bJ9nIGMK X-Received: by 2002:a17:90a:be04:b0:2a2:6e60:b53c with SMTP id a4-20020a17090abe0400b002a26e60b53cmr2050217pjs.20.1712336252956; Fri, 05 Apr 2024 09:57:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712336252; cv=pass; d=google.com; s=arc-20160816; b=cKEJzcarsjT8TIzc4zR1VaTA8fY785cTJMOrxoyRTbbkg69R6eGe0MNPDb8sxqkM3a w9n0LLYbulIqT3mS2QoXdUzvAs18AhRnjGs7cJz1aV6oPlKtOwhzr6JiFh2BUbv4LpCL z9q6/vBfRW+Tq433DekTdlixDwBi+Q6ZWIfaLq2V4z5vwKh0eT/0JiXzsA7QdOsoh4Z6 qx8/24GJEfaynIeMt/r5cTh4qrpDn11XtbzjhhjlV1kin1+4Oqb2xAGeVaByKmpUNxaM k2isD3EoI952saiTMRP2sah0EGAf1UAh9pnPBsQkz5N4C70v6oJojAiR7I2AI8GO+eHT HumQ== 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=yMLzQA/6BbwYzquQezGQzkGkH5ReAB8CGPKnJth/axk=; fh=lyAesGEiK60cWv13f5SBoQvN28BZIeKKtkWMgSIIU+Y=; b=X/ZwXtPFUlOpwLlGmaPGm00pNiDJ8/NSeNRsTChkrpVQHRifEdHQJkwGCoXcdDnrtx Ai2uhpNm8twXqQTlkloV1iYbFgRSWe298Ww6AMQ/xEq7/ZuNvSXcb1YDqkYyGFS3QkDp OiXh2FwOOY1RvcJ4JYA4c9o667nb8Jhjqrg0idK7AOFgthSu7EYhX3O5Wx/hB3LpyBr9 ONiq5yZR9Fn4lNcREIKYaW/RHkokD1kV0A+/IKstw9BjLO6XL/JWadkkuqAIjt2upct8 oU4w6TG13o7OxLbzaXBFJSY3cYMCkp2+0jaQ0K5MzUnKPZXCgVv4Fj6uicZWXhSsbeu9 bzEQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QaRNhIgM; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-133368-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-133368-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id mg16-20020a17090b371000b002a49220ff83si268389pjb.112.2024.04.05.09.57.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 09:57:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-133368-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QaRNhIgM; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-133368-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-133368-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 35C5BB23D2C for ; Fri, 5 Apr 2024 16:52:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 12A75171659; Fri, 5 Apr 2024 16:52:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="QaRNhIgM" 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 219EE79E3; Fri, 5 Apr 2024 16:52:49 +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=1712335970; cv=none; b=CGAxFyNtujWVVhH+gICjMixTILZU0K7OGDIaq6d76TGjRiv0IV3TgOmIGzPQZzYZnozQyq9ebE1frAnFXvuKnmraXV8UvtWkPFHE3EY1sBtC95Lo46uR8XXfsI0IgeW5SeUQ8+eGrruf7LgNlPRsKKGQElecrdOdAD4r1jYtmSI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712335970; c=relaxed/simple; bh=mt/7m6gE+/mQeYNIuTIpesLMoVgYypS7PcDtGHkbqws=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=rUHTSgVMQLc/ujuOXGMVDYXFJs3nkjWOS+rA/iN5+fGYQ6DofsouQs0RPVzkSRcr8EuJQQdA+qw30xSIMWGp99xg1sH0w1KDIzMD8rb/Q0peMgYeTgGcGJp7P6257Tekrdqei2tvK7T7svyucEu4B+qkt6YStd4gCEnPHrLvXC8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QaRNhIgM; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3367AC433F1; Fri, 5 Apr 2024 16:52:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712335969; bh=mt/7m6gE+/mQeYNIuTIpesLMoVgYypS7PcDtGHkbqws=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=QaRNhIgMnDYWgjPVKq0IlAjsC3Yq2QY7DGainZ5KQiecDDQtNx5qr1eZMbSCf2AW5 oHlWIljCKRo6uCUN/Sn3mTjZbi+JqlZzs5QIbAVshQ/+bI9obXK6dIAybh3d3Yl7Yk mFqfGcaZjr1AIUnFw2q+1Yt/mbrw9+NWx7csLU/Q7QIoDpjd0Kh2yRqSCjJwgM+Itf e2mA9jcY5cw/wYgitaH/t7+3wKljzuXDPPDgzPA61i6VA5KHy4FfXQ0+tKpAHNpqc3 lcRVcr7P/kNK5dVr3Z0pmZMvFRLHbUmowypCXZyq6mSAXJixspO0ayR93tha/UFb05 gNyRa8cYrP2Zw== Date: Fri, 5 Apr 2024 22:22:45 +0530 From: Vinod Koul To: forbidden405@outlook.com Cc: Kishon Vijay Abraham I , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jiancheng Xue , Shawn Guo , Philipp Zabel , linux-phy@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Kishon Vijay Abraham I , David Yang Subject: Re: [PATCH v5 5/5] phy: hisilicon: hisi-inno-phy: add support for Hi3798MV200 INNO PHY Message-ID: References: <20240305-inno-phy-v5-0-dc1cb130ea08@outlook.com> <20240305-inno-phy-v5-5-dc1cb130ea08@outlook.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: <20240305-inno-phy-v5-5-dc1cb130ea08@outlook.com> On 05-03-24, 21:32, Yang Xiwen via B4 Relay wrote: > From: Yang Xiwen That is quite an email id! > > Direct MMIO resgiter access is used by Hi3798MV200. For other models, > of_iomap() returns NULL due to insufficient length. So they are so how is that fixed... Pls describe the change... > unaffected. > > Also Hi3798MV200 INNO PHY has an extra reset required to be deasserted, > switch to reset_control_array_*() APIs for that. That probably should be a different patch > > Signed-off-by: Yang Xiwen > --- > drivers/phy/hisilicon/phy-hisi-inno-usb2.c | 66 ++++++++++++++++++------------ > 1 file changed, 40 insertions(+), 26 deletions(-) > > diff --git a/drivers/phy/hisilicon/phy-hisi-inno-usb2.c b/drivers/phy/hisilicon/phy-hisi-inno-usb2.c > index b7e740eb4752..df154cd99ed8 100644 > --- a/drivers/phy/hisilicon/phy-hisi-inno-usb2.c > +++ b/drivers/phy/hisilicon/phy-hisi-inno-usb2.c > @@ -10,6 +10,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -24,6 +25,7 @@ > > #define PHY_TYPE_0 0 > #define PHY_TYPE_1 1 > +#define PHY_TYPE_MMIO 2 > > #define PHY_TEST_DATA GENMASK(7, 0) > #define PHY_TEST_ADDR_OFFSET 8 > @@ -43,6 +45,7 @@ > #define PHY_CLK_ENABLE BIT(2) > > struct hisi_inno_phy_port { > + void __iomem *base; > struct reset_control *utmi_rst; > struct hisi_inno_phy_priv *priv; > }; > @@ -50,7 +53,7 @@ struct hisi_inno_phy_port { > struct hisi_inno_phy_priv { > void __iomem *mmio; > struct clk *ref_clk; > - struct reset_control *por_rst; > + struct reset_control *rsts; > unsigned int type; > struct hisi_inno_phy_port ports[INNO_PHY_PORT_NUM]; > }; > @@ -62,26 +65,31 @@ static void hisi_inno_phy_write_reg(struct hisi_inno_phy_priv *priv, > u32 val; > u32 value; > > - if (priv->type == PHY_TYPE_0) > - val = (data & PHY_TEST_DATA) | > - ((addr << PHY_TEST_ADDR_OFFSET) & PHY0_TEST_ADDR) | > - ((port << PHY0_TEST_PORT_OFFSET) & PHY0_TEST_PORT) | > - PHY0_TEST_WREN | PHY0_TEST_RST; > - else > - val = (data & PHY_TEST_DATA) | > - ((addr << PHY_TEST_ADDR_OFFSET) & PHY1_TEST_ADDR) | > - ((port << PHY1_TEST_PORT_OFFSET) & PHY1_TEST_PORT) | > - PHY1_TEST_WREN | PHY1_TEST_RST; > - writel(val, reg); > - > - value = val; > - if (priv->type == PHY_TYPE_0) > - value |= PHY0_TEST_CLK; > - else > - value |= PHY1_TEST_CLK; > - writel(value, reg); > - > - writel(val, reg); > + if (priv->ports[port].base) > + /* FIXME: fill stride in priv */ when? > + writel(data, (u32 *)priv->ports[port].base + addr); > + else { > + if (priv->type == PHY_TYPE_0) > + val = (data & PHY_TEST_DATA) | > + ((addr << PHY_TEST_ADDR_OFFSET) & PHY0_TEST_ADDR) | > + ((port << PHY0_TEST_PORT_OFFSET) & PHY0_TEST_PORT) | > + PHY0_TEST_WREN | PHY0_TEST_RST; > + else > + val = (data & PHY_TEST_DATA) | > + ((addr << PHY_TEST_ADDR_OFFSET) & PHY1_TEST_ADDR) | > + ((port << PHY1_TEST_PORT_OFFSET) & PHY1_TEST_PORT) | > + PHY1_TEST_WREN | PHY1_TEST_RST; > + writel(val, reg); > + > + value = val; > + if (priv->type == PHY_TYPE_0) > + value |= PHY0_TEST_CLK; > + else > + value |= PHY1_TEST_CLK; > + writel(value, reg); > + > + writel(val, reg); val and value are very helpful variables, do consider naming them better! > + } > } > > static void hisi_inno_phy_setup(struct hisi_inno_phy_priv *priv) > @@ -104,7 +112,7 @@ static int hisi_inno_phy_init(struct phy *phy) > return ret; > udelay(REF_CLK_STABLE_TIME); > > - reset_control_deassert(priv->por_rst); > + reset_control_deassert(priv->rsts); > udelay(POR_RST_COMPLETE_TIME); > > /* Set up phy registers */ > @@ -122,7 +130,7 @@ static int hisi_inno_phy_exit(struct phy *phy) > struct hisi_inno_phy_priv *priv = port->priv; > > reset_control_assert(port->utmi_rst); > - reset_control_assert(priv->por_rst); > + reset_control_assert(priv->rsts); > clk_disable_unprepare(priv->ref_clk); > > return 0; > @@ -158,15 +166,16 @@ static int hisi_inno_phy_probe(struct platform_device *pdev) > if (IS_ERR(priv->ref_clk)) > return PTR_ERR(priv->ref_clk); > > - priv->por_rst = devm_reset_control_get_exclusive(dev, NULL); > - if (IS_ERR(priv->por_rst)) > - return PTR_ERR(priv->por_rst); > + priv->rsts = devm_reset_control_array_get_exclusive(dev); > + if (IS_ERR(priv->rsts)) > + return PTR_ERR(priv->rsts); > > priv->type = (uintptr_t) of_device_get_match_data(dev); > > for_each_child_of_node(np, child) { > struct reset_control *rst; > struct phy *phy; > + void __iomem *base; > > rst = of_reset_control_get_exclusive(child, NULL); > if (IS_ERR(rst)) { > @@ -174,7 +183,10 @@ static int hisi_inno_phy_probe(struct platform_device *pdev) > return PTR_ERR(rst); > } > > + base = of_iomap(child, 0); > + > priv->ports[i].utmi_rst = rst; > + priv->ports[i].base = base; > priv->ports[i].priv = priv; > > phy = devm_phy_create(dev, child, &hisi_inno_phy_ops); > @@ -205,6 +217,8 @@ static const struct of_device_id hisi_inno_phy_of_match[] = { > .data = (void *) PHY_TYPE_0 }, > { .compatible = "hisilicon,hi3798mv100-usb2-phy", > .data = (void *) PHY_TYPE_1 }, > + { .compatible = "hisilicon,hi3798mv200-usb2-phy", > + .data = (void *) PHY_TYPE_MMIO }, > { }, > }; > MODULE_DEVICE_TABLE(of, hisi_inno_phy_of_match); > > -- > 2.43.0 -- ~Vinod