From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6B28E606A325 for ; Mon, 30 Nov 2026 23:02:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=sqPH/0H3; dkim=fail reason="signature verification failed" (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=M8oUjilX DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=tRsVNKMwwwq379mAtHAWW0DIUBErSAqilEP467p6pes=; b=sqPH/0H34RNt7vaiGR3IyulkXd rQ28szBTipZYx0jipgKIF1/wBgOGfBe4KO7eF/b4h0+j/H2vsGhpfAfVYINoAoio8xCm1SCwSRlt2 sBAy+lRohm27Vu/X0Fdg9+qUauWbrk+JOOYZUZtsJ7k1UmSYN/3yH0fFAte4aXvzFXGaPg/3nLPRW 664au5X+6lQhk3KxZr73EodgJgK+U+wLtPo9zC1NLPSh2Bx8NfzJk1psMaqEUkUU/XW+6sI9T4Xhf cy7njI4LRvQFAvooaLMB2tbkd5qdr4LyQRSlAHYAfBDrp1nF8qxYuU4bdOWdtQZINtSmdGzh6cfgA tIonR5EQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYAO7-0000000620U-1JYk; Mon, 30 Nov 2026 23:02:25 +0000 Received: from mout-p-101.mailbox.org ([2001:67c:2050:0:465::101]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYAO0-000000061z8-3BEb for linux-phy@lists.infradead.org; Mon, 30 Nov 2026 23:02:19 +0000 Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:b231:465::202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519MLKEM768 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-101.mailbox.org (Postfix) with ESMTPS id 4jdffq2x6zz8vbp; Tue, 01 Dec 2026 00:02:11 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1796079731; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=51Fu7bb4JaykEZBRIqWIjBGhzvQuyD1n4m3STTrbVPA=; b=M8oUjilX+5qzXvArNYT9do1y11pzWRFPic+oR/46LhoIz2MoW3LTz1oqz1TxqVpk3VZlOl ScWw9duTQigvTvgqqMUc4l2zbebYWxS+Egv9DY3Q7dNRd3GyoNdR0okaccFPTytMMTLS9R pz3/+S0KKorO3Fi8aXbVstwik/XsfO2G4iQMltOJvuRZNra0BoBidR+ttpzCJrd+7s0fHe afXXqGbRQBBUA+TlYozX51IBAevBIgBNtZBZi2nOT9AiIcTt8n2T2lnjc9UGMka2eAXuaC QxGlIVx9VmVKU0gOraqlpYvxmjG6MnpXYR8C3ae4b+f7P3YatlHbwU5htSAhVw== Message-ID: <76cc2ebc-9e5c-48eb-8219-4577045f01ac@mailbox.org> Date: Tue, 1 Dec 2026 00:01:40 +0100 X-Archived-By: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 2/3] phy: renesas: Add Renesas Multi-Protocol PHY driver for R-Car X5H To: Geert Uytterhoeven Cc: Thanh Quan , Phong Hoang , Hai Pham , Yoshihiro Shimoda , Arnd Bergmann , Biju Das , Conor Dooley , Krzysztof Kozlowski , Magnus Damm , Manivannan Sadhasivam , Neil Armstrong , Rob Herring , Tam Nguyen , Tommaso Merciai , Vinh Nguyen , Vinod Koul , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-phy@lists.infradead.org References: <20261129173739.282027-1-marek.vasut+renesas@mailbox.org> <20261129173739.282027-2-marek.vasut+renesas@mailbox.org> <8e77b7aa-b5cb-4e60-9a01-a37bd6791b22@app.fastmail.com> Content-Language: en-US From: Marek Vasut In-Reply-To: <8e77b7aa-b5cb-4e60-9a01-a37bd6791b22@app.fastmail.com> X-MBO-RS-ID: 55076f5fe042fec51f1 X-MBO-RS-META: sfijdxa6b565n4czofcdk4hs39xy1n9i X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261130_150217_120463_0C7233CE X-CRM114-Status: GOOD ( 25.22 ) X-Spam-Score: -2.8 (--) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-phy" X-Spam-Status: No, score=-5.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On 11/30/26 5:42 PM, Geert Uytterhoeven wrote: Hello Geert, >> +static void mp_phy_init_pcie4_ch_req(struct mp_phy_priv *priv, const int chs, const int chd, > > unsigned int first, unsigned int last > >> + const u32 cntxt2, const u32 txreq) > > No need for all the consts > >> +{ >> + int ch; >> + >> + for (ch = chs; ch <= chd; ch++) { > > unsigned int ch = ... > > Or perhaps drop ch and just increase first? Can you please clarify this "Or perhaps ..." part ? >> + regmap_set_bits(priv->map, MPPHY_PXCNTXT1(ch), 0x2010002); >> + regmap_set_bits(priv->map, MPPHY_PXCNTXT2(ch), cntxt2); >> + regmap_set_bits(priv->map, MPPHY_PXTXREQ(ch), txreq); >> + } >> +} [...] >> +static int mp_phy_init_pcie4(struct phy *phy) >> +{ >> + struct mp_phy_priv *priv = phy_get_drvdata(phy); >> + >> + if (priv->num_lanes[phy->id] == 2) { > > switch ()? > > However, I am wondering if the below can be refactored / simplified. > The loops seem to run from 0 to num_lanes / 2 - 1, with a.o. some > special handling for the first iteration? This is the refactored outcome already. Yes, channel 0 is special. In case of x2/x4 mode, channels 0 or 2 / 0+1 or 2+3 are used for PCIe0 or PCIe1 respectively ; in case of x8 mode, all four channels are used for PCIe0. But there are exceptions regarding the reset pulses and clock settings, please see comments in the code below. >> + if (phy->id == 0) { >> + mp_phy_init_pcie4_ch_req(priv, 0, 0, 0x2020201, 0x80004); >> + mp_phy_init_pcie4_ch_clk(priv, 0, 0); >> + mp_phy_init_pcie4_ch_rst(priv, 0, 0); >> + } else if (phy->id == 1) { >> + mp_phy_init_pcie4_ch_req(priv, 2, 2, 0x2020202, 0x8); >> + mp_phy_init_pcie4_ch_clk(priv, 2, 2); >> + mp_phy_init_pcie4_ch_rst(priv, 2, 2); >> + } >> + } else if (priv->num_lanes[phy->id] == 4) { >> + if (phy->id == 0) { >> + mp_phy_init_pcie4_ch_req(priv, 0, 1, 0x2020201, 0x80008); >> + mp_phy_init_pcie4_ch_clk(priv, 0, 1); >> + /* No reset pulse here. */ >> + } else if (phy->id == 1) { >> + mp_phy_init_pcie4_ch_req(priv, 2, 3, 0x2020202, 0x8); >> + mp_phy_init_pcie4_ch_clk(priv, 2, 3); >> + mp_phy_init_pcie4_ch_rst(priv, 2, 3); >> + } >> + } else if (priv->num_lanes[phy->id] == 8) { >> + mp_phy_init_pcie4_ch_req(priv, 0, 0, 0x2020201, 0x8); >> + mp_phy_init_pcie4_ch_req(priv, 1, 3, 0x2020202, 0x8); >> + /* No clk settings here. */ >> + mp_phy_init_pcie4_ch_rst(priv, 0, 3); >> + } >> + >> + return 0; >> +} > >> +static int mp_phy_init(struct phy *phy) >> +{ >> + struct mp_phy_priv *priv = phy_get_drvdata(phy); >> + struct mp_phy_chan_priv *chan = &priv->chan[phy->id]; >> + int ret; >> + >> + if (chan->initialized) >> + return 0; >> + >> + /* >> + * Note: Current source code support for Ethernet, PCIe initialization >> + * is based on the bare metal code shared by the board team. >> + */ >> + ret = pm_runtime_get_sync(priv->pd_list->pd_devs[phy->id]); >> + if (ret < 0) { >> + dev_err(priv->dev, >> + "Failed to power on domain for channel %d: %d\n", >> + phy->id, ret); > > %pe and ERR_PTR(ret)? pm_runtime_get_sync() does not return error pointer ? [...] >> +static int mp_phy_parse_dt(struct platform_device *pdev, struct mp_phy_priv *priv) >> +{ >> + u32 phy_type[2 * MPPHY_NUM_CHANNELS]; >> + u32 ext_ref_clk[MPPHY_NUM_CHANNELS]; >> + u32 out_ref_clk[MPPHY_NUM_CHANNELS]; >> + struct device *dev = &pdev->dev; >> + int i, ret; > > unsigned int i > >> + >> + ret = device_property_read_u32_array(dev, "renesas,phy-type", phy_type, 8); >> + if (ret < 0) >> + return dev_err_probe(dev, -EINVAL, "Failed to read PHY configuration\n"); >> + >> + ret = device_property_read_u32_array(dev, "renesas,external-ref-clock", >> + ext_ref_clk, 4); >> + if (ret < 0) >> + return dev_err_probe(dev, -EINVAL, "Failed to read PHY clock configuration\n"); >> + >> + ret = device_property_read_u32_array(dev, "renesas,output-repeat-ref-clock", >> + out_ref_clk, 4); >> + if (ret < 0) >> + return dev_err_probe(dev, -EINVAL, "Failed to read PHY clock out configuration\n"); >> + >> + /* Test whether the supplied configuration is valid. */ >> + for (i = 0; i < ARRAY_SIZE(mp_phy_valid_configs); i++) { >> + if (phy_type[0] == mp_phy_valid_configs[i].phy_type[0] && >> + phy_type[1] == mp_phy_valid_configs[i].phy_type[1] && >> + phy_type[2] == mp_phy_valid_configs[i].phy_type[2] && >> + phy_type[3] == mp_phy_valid_configs[i].phy_type[3] && >> + phy_type[4] == mp_phy_valid_configs[i].phy_type[4] && >> + phy_type[5] == mp_phy_valid_configs[i].phy_type[5] && >> + phy_type[6] == mp_phy_valid_configs[i].phy_type[6] && >> + phy_type[7] == mp_phy_valid_configs[i].phy_type[7]) > > memcmp() The phy_type[] array on the left is u32[], but the mp_phy_valid_configs[i].phy_type array on the right is u8[] to conserve space, so memcmp() won't work here. I could convert the former into u8[] but I'm not convinced doing it only for the sake of using memcmp() is good. Then again, this conditional also does not look great. [...] -- Best regards, Marek Vasut -- linux-phy mailing list linux-phy@lists.infradead.org https://lists.infradead.org/mailman/listinfo/linux-phy