Linux ARM-MSM sub-architecture
 help / color / mirror / Atom feed
From: Wesley Cheng <quic_wcheng@quicinc.com>
To: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>,
	Melody Olvera <quic_molvera@quicinc.com>
Cc: Vinod Koul <vkoul@kernel.org>,
	Kishon Vijay Abraham I <kishon@kernel.org>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	"Catalin Marinas" <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>,
	"Bjorn Andersson" <andersson@kernel.org>,
	Konrad Dybcio <konradybcio@kernel.org>,
	Satya Durga Srinivasu Prabhala <quic_satyap@quicinc.com>,
	Trilok Soni <quic_tsoni@quicinc.com>,
	<linux-arm-msm@vger.kernel.org>, <linux-phy@lists.infradead.org>,
	<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-usb@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH 5/7] phy: qcom: Add M31 based eUSB2 PHY driver
Date: Wed, 26 Feb 2025 12:23:34 -0800	[thread overview]
Message-ID: <92b42216-c409-4e21-a33e-54c29fa5f8a0@quicinc.com> (raw)
In-Reply-To: <rpwm6gimdb4zyvyusovfbfaw4uxrossm6elayebvt2gusb7zwk@67w7672qpcto>



On 1/14/2025 2:34 AM, Dmitry Baryshkov wrote:
> On Mon, Jan 13, 2025 at 01:52:11PM -0800, Melody Olvera wrote:
>> From: Wesley Cheng <quic_wcheng@quicinc.com>
>>
>> On SM8750, the eUSB2 PHY used is M31 based. Add the initialization
>> sequences to bring it out of reset, and to initialize the associated eUSB2
>> repeater as well.
> 
> What does M31 mean? What is the relationship between the eUSB and USB
> M31 PHYs?
> 

M31 is the vendor.  I'll reword this to make it a bit clearer.  There's no
relationship between eUSB2 and USB2 PHY drivers, as the eUSB2 based driver
would require some additional components such as a USB repeater.

>>
>> Signed-off-by: Wesley Cheng <quic_wcheng@quicinc.com>
>> Signed-off-by: Melody Olvera <quic_molvera@quicinc.com>
>> ---
>>  drivers/phy/qualcomm/Kconfig              |  12 +-
>>  drivers/phy/qualcomm/Makefile             |   1 +
>>  drivers/phy/qualcomm/phy-qcom-m31-eusb2.c | 269 ++++++++++++++++++++++++++++++
>>  3 files changed, 281 insertions(+), 1 deletion(-)
> 
> Please run the patch through checkpatch.pl --strict
> 
>>
>> diff --git a/drivers/phy/qualcomm/phy-qcom-m31-eusb2.c b/drivers/phy/qualcomm/phy-qcom-m31-eusb2.c
>> new file mode 100644
>> index 0000000000000000000000000000000000000000..e15529673e358db914936a60fa605c872cd2511a
>> --- /dev/null
>> +++ b/drivers/phy/qualcomm/phy-qcom-m31-eusb2.c
>> @@ -0,0 +1,269 @@
>> +// SPDX-License-Identifier: GPL-2.0+
>> +/*
>> + * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
>> + */
>> +
>> +#include <linux/clk.h>
>> +#include <linux/delay.h>
>> +#include <linux/err.h>
>> +#include <linux/io.h>
>> +#include <linux/kernel.h>
>> +#include <linux/module.h>
>> +#include <linux/of.h>
>> +#include <linux/phy/phy.h>
>> +#include <linux/platform_device.h>
>> +#include <linux/reset.h>
>> +#include <linux/slab.h>
>> +
>> +#define USB_PHY_UTMI_CTRL0		(0x3c)
>> +
>> +#define USB_PHY_UTMI_CTRL5		(0x50)
>> +
>> +#define USB_PHY_HS_PHY_CTRL_COMMON0	(0x54)
>> +#define FSEL				(0x7 << 4)
> 
> GENMASK()
> 
>> +#define FSEL_38_4_MHZ_VAL		(0x6 << 4)
> 
> FIELD_PREP
> 
>> +
>> +#define USB_PHY_HS_PHY_CTRL2		(0x64)
>> +
>> +#define USB_PHY_CFG0			(0x94)
>> +#define USB_PHY_CFG1			(0x154)
>> +
>> +#define USB_PHY_FSEL_SEL		(0xb8)
>> +
>> +#define USB_PHY_XCFGI_39_32		(0x16c)
>> +#define USB_PHY_XCFGI_71_64		(0x17c)
>> +#define USB_PHY_XCFGI_31_24		(0x168)
>> +#define USB_PHY_XCFGI_7_0		(0x15c)
>> +
>> +#define M31_EUSB_PHY_INIT_CFG(o, b, v)	\
>> +{				\
>> +	.off = o,		\
>> +	.mask = b,		\
>> +	.val = v,		\
>> +}
>> +
>> +struct m31_phy_tbl_entry {
>> +	u32 off;
>> +	u32 mask;
>> +	u32 val;
>> +};
>> +
>> +struct m31_eusb2_priv_data {
>> +	const struct m31_phy_tbl_entry	*setup_seq;
>> +	unsigned int			setup_seq_nregs;
>> +	const struct m31_phy_tbl_entry	*override_seq;
>> +	unsigned int			override_seq_nregs;
>> +	const struct m31_phy_tbl_entry	*reset_seq;
>> +	unsigned int			reset_seq_nregs;
>> +	unsigned int			fsel;
>> +};
>> +
>> +static const struct m31_phy_tbl_entry m31_eusb2_setup_tbl[] = {
>> +	M31_EUSB_PHY_INIT_CFG(USB_PHY_CFG0, BIT(1), 1),
>> +	M31_EUSB_PHY_INIT_CFG(USB_PHY_UTMI_CTRL5, BIT(1), 1),
>> +	M31_EUSB_PHY_INIT_CFG(USB_PHY_CFG1, BIT(0), 1),
>> +	M31_EUSB_PHY_INIT_CFG(USB_PHY_FSEL_SEL, BIT(0), 1),
>> +};
>> +
>> +static const struct m31_phy_tbl_entry m31_eusb_phy_override_tbl[] = {
>> +	M31_EUSB_PHY_INIT_CFG(USB_PHY_XCFGI_39_32, GENMASK(3, 2), 0),
>> +	M31_EUSB_PHY_INIT_CFG(USB_PHY_XCFGI_71_64, GENMASK(3, 0), 7),
>> +	M31_EUSB_PHY_INIT_CFG(USB_PHY_XCFGI_31_24, GENMASK(2, 0), 0),
>> +	M31_EUSB_PHY_INIT_CFG(USB_PHY_XCFGI_7_0, GENMASK(1, 0), 0),
>> +};
>> +
>> +static const struct m31_phy_tbl_entry m31_eusb_phy_reset_tbl[] = {
>> +	M31_EUSB_PHY_INIT_CFG(USB_PHY_HS_PHY_CTRL2, BIT(3), 1),
>> +	M31_EUSB_PHY_INIT_CFG(USB_PHY_HS_PHY_CTRL2, BIT(2), 1),
>> +	M31_EUSB_PHY_INIT_CFG(USB_PHY_UTMI_CTRL0, BIT(0), 1),
>> +	M31_EUSB_PHY_INIT_CFG(USB_PHY_HS_PHY_CTRL_COMMON0, BIT(1), 1),
>> +	M31_EUSB_PHY_INIT_CFG(USB_PHY_HS_PHY_CTRL_COMMON0, BIT(2), 0),
>> +	M31_EUSB_PHY_INIT_CFG(USB_PHY_UTMI_CTRL5, BIT(1), 0),
>> +	M31_EUSB_PHY_INIT_CFG(USB_PHY_HS_PHY_CTRL2, BIT(3), 0),
>> +	M31_EUSB_PHY_INIT_CFG(USB_PHY_CFG0, BIT(1), 0),
>> +};
>> +
>> +struct m31eusb2_phy {
>> +	struct phy			*phy;
>> +	void __iomem			*base;
>> +	const struct m31_eusb2_priv_data	*data;
>> +
>> +	struct regulator		*vreg;
>> +	struct clk			*clk;
>> +	struct reset_control		*reset;
>> +
>> +	struct phy *repeater;
>> +};
>> +
>> +static void msm_m31_eusb2_write_readback(void __iomem *base, u32 offset,
>> +					const u32 mask, u32 val)
>> +{
>> +	u32 write_val, tmp = readl_relaxed(base + offset);
>> +
>> +	tmp &= ~mask;
>> +	write_val = tmp | val;
>> +
>> +	writel_relaxed(write_val, base + offset);
>> +
>> +	tmp = readl_relaxed(base + offset);
>> +	tmp &= mask;
>> +
>> +	if (tmp != val)
>> +		pr_err("write: %x to offset: %x FAILED\n", val, offset);
>> +}
>> +
>> +static void m31eusb2_phy_write_sequence(struct m31eusb2_phy *phy,
>> +					const struct m31_phy_tbl_entry *tbl,
>> +					int num)
>> +{
>> +	int i;
>> +
>> +	for (i = 0 ; i < num; i++, tbl++) {
>> +		dev_dbg(&phy->phy->dev, "Offset:%x BitMask:%x Value:%x",
>> +					tbl->off, tbl->mask, tbl->val);
>> +
>> +		msm_m31_eusb2_write_readback(phy->base,
>> +					tbl->off, tbl->mask,
>> +					tbl->val << __ffs(tbl->mask));
> 
> could you please check, what actually gets written? I suspect there
> should be a -1 here.
> 

The __ffs  uses the ctz/ctzl built in, which counts leading zeros, so the
-1 should already be accounted for.  FIELD_PREP uses the ffs builtin
directly, which would require the -1.  Confirmed that the writes are being
done as expected from the programming tables above.

Thanks
Wesley Cheng

  reply	other threads:[~2025-02-26 20:23 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-13 21:52 [PATCH 0/7] phy: qcom: Introduce USB support for SM8750 Melody Olvera
2025-01-13 21:52 ` [PATCH 1/7] dt-bindings: phy: qcom,sc8280xp-qmp-usb43dp-phy: Add SM8750 to QMP PHY Melody Olvera
2025-01-14  7:28   ` Krzysztof Kozlowski
2025-01-13 21:52 ` [PATCH 2/7] dt-bindings: phy: Add the M31 based eUSB2 PHY bindings Melody Olvera
2025-01-13 23:27   ` Rob Herring (Arm)
2025-01-14 10:12   ` Dmitry Baryshkov
2025-02-21  3:16     ` Wesley Cheng
2025-02-21  3:48       ` Dmitry Baryshkov
2025-01-16 19:30   ` Konrad Dybcio
2025-01-13 21:52 ` [PATCH 3/7] dt-bindings: usb: qcom,dwc3: Add SM8750 compatible Melody Olvera
2025-01-13 23:27   ` Rob Herring (Arm)
2025-01-14  7:34   ` Krzysztof Kozlowski
2025-01-13 21:52 ` [PATCH 4/7] phy: qcom: qmp-combo: Add new PHY sequences for SM8750 Melody Olvera
2025-01-14  8:59   ` neil.armstrong
2025-02-04  3:32     ` Wesley Cheng
2025-01-14 10:23   ` Dmitry Baryshkov
2025-02-04  3:31     ` Wesley Cheng
2025-02-04 14:59       ` Dmitry Baryshkov
2025-02-22  2:43         ` Wesley Cheng
2025-02-22  5:14           ` Dmitry Baryshkov
2025-01-13 21:52 ` [PATCH 5/7] phy: qcom: Add M31 based eUSB2 PHY driver Melody Olvera
2025-01-14  8:57   ` neil.armstrong
2025-01-14 10:34   ` Dmitry Baryshkov
2025-02-26 20:23     ` Wesley Cheng [this message]
2025-02-27  1:55       ` Dmitry Baryshkov
2025-01-16  8:45   ` Philipp Zabel
2025-01-13 21:52 ` [PATCH 6/7] arm64: defconfig: Add M31 eUSB2 PHY config Melody Olvera
2025-01-14  7:35   ` Krzysztof Kozlowski
2025-01-13 21:52 ` [PATCH 7/7] arm64: dts: qcom: sm8750: Add USB support to SM8750 platforms Melody Olvera
2025-01-14 10:38   ` Dmitry Baryshkov
2025-02-04  3:21     ` Wesley Cheng
2025-02-04 15:19       ` Dmitry Baryshkov
2025-01-22 11:10   ` Krzysztof Kozlowski
2025-02-27 18:29   ` Dmitry Baryshkov
2025-02-27 19:28     ` Wesley Cheng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=92b42216-c409-4e21-a33e-54c29fa5f8a0@quicinc.com \
    --to=quic_wcheng@quicinc.com \
    --cc=andersson@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.baryshkov@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=kishon@kernel.org \
    --cc=konradybcio@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-phy@lists.infradead.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=quic_molvera@quicinc.com \
    --cc=quic_satyap@quicinc.com \
    --cc=quic_tsoni@quicinc.com \
    --cc=robh@kernel.org \
    --cc=vkoul@kernel.org \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox