Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E4880C7EE29 for ; Sun, 4 Jun 2023 22:30:18 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9F0C185746; Mon, 5 Jun 2023 00:30:15 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=tinet.cat Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 96AC78573F; Mon, 5 Jun 2023 00:30:13 +0200 (CEST) Received: from mx1.tinet.cat (mx1.tinet.org [195.77.216.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id A3A0F85746 for ; Mon, 5 Jun 2023 00:30:10 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=tinet.cat Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=xdrudis@tinet.cat X-ASG-Debug-ID: 1685917809-163e7b5c071cd410001-4l7tJC Received: from smtp01.tinet.cat (smtp.tinet.org [195.77.216.131]) by mx1.tinet.cat with ESMTP id aF664WWx2aCkIrA7; Mon, 05 Jun 2023 00:30:09 +0200 (CEST) X-Barracuda-Envelope-From: xdrudis@tinet.cat X-Barracuda-Effective-Source-IP: smtp.tinet.org[195.77.216.131] X-Barracuda-Apparent-Source-IP: 195.77.216.131 Received: from xdrudis.tinet.cat (180.red-79-152-181.dynamicip.rima-tde.net [79.152.181.180]) by smtp01.tinet.cat (Postfix) with ESMTPSA id 392B5605D0AC; Mon, 5 Jun 2023 00:30:09 +0200 (CEST) Date: Mon, 5 Jun 2023 00:30:08 +0200 From: Xavier Drudis Ferran To: Marek Vasut Cc: Xavier Drudis Ferran , u-boot@lists.denx.de, Simon Glass , Philipp Tomsich , Kever Yang , Lukasz Majewski , Sean Anderson , Christoph Fritz , Jagan Teki Subject: Re: [PATCH v6 2/2] arm: rk3399: usb2phy: phy-rockchip-inno-usb2.c: Implement operations for the 480MHz usb2phy clock in rk3399. Message-ID: X-ASG-Orig-Subj: Re: [PATCH v6 2/2] arm: rk3399: usb2phy: phy-rockchip-inno-usb2.c: Implement operations for the 480MHz usb2phy clock in rk3399. References: <471c7040-fb44-135e-774b-793f8796ad0d@denx.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <471c7040-fb44-135e-774b-793f8796ad0d@denx.de> X-Barracuda-Connect: smtp.tinet.org[195.77.216.131] X-Barracuda-Start-Time: 1685917809 X-Barracuda-URL: https://webmail.tinet.cat:443/cgi-mod/mark.cgi X-Barracuda-Scan-Msg-Size: 1801 X-Barracuda-BRTS-Status: 1 X-Barracuda-Bayes: INNOCENT GLOBAL 0.5239 1.0000 0.7500 X-Barracuda-Spam-Score: 0.75 X-Barracuda-Spam-Status: No, SCORE=0.75 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=6.0 KILL_LEVEL=8.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.109610 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Thanks for looking at this. El Sun, Jun 04, 2023 at 11:33:21AM +0200, Marek Vasut deia: > > diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c > > index 2f31350134..451841b025 100644 > > --- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c > > +++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c > > @@ -55,6 +55,7 @@ struct rockchip_usb2phy_port_cfg { > > struct rockchip_usb2phy_cfg { > > unsigned int reg; > > + struct usb2phy_reg clkout_ctl; > > const struct rockchip_usb2phy_port_cfg port_cfgs[USB2PHY_NUM_PORTS]; > > }; > > @@ -76,6 +77,18 @@ static inline int property_enable(void *reg_base, > > return writel(val, reg_base + reg->offset); > > } > > +static inline bool property_enabled(void *reg_base, > > + const struct usb2phy_reg *reg) > > +{ > > + unsigned int tmp, orig; > > + unsigned int mask = GENMASK(reg->bitend, reg->bitstart); > > + > > + orig = readl(reg_base + reg->offset); > > + > > + tmp = (orig & mask) >> reg->bitstart; > > Use FIELD_GET() macro if possible. > It would be possible, but it seems to require a constant mask. Now the mask is read from a cfg struct, so it's not constant. Currently the mask bitend and bitstart are really always the same value (4 and 4) for all (2) SOCs, so I could change the code to make it a constant and use FIELD_GET(), but I'd see two drawbacks: - It makes code more different than needed from linux drivers/phy/rockchip/phy-rockchip-inno-usb2.c - It will stop working if we ever support rk3366 here, the mask there is bit 15. So I'd rather leave it as it is. But you made me realise I was missing the clkout_ctl struct for rk3568, so I'll copy from linux in v7. I can't test it, though. Thank you.