mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ze Huang <huangze@whut.edu.cn>
To: Vinod Koul <vkoul@kernel.org>
Cc: Kishon Vijay Abraham I <kishon@kernel.org>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>, Yixun Lan <dlan@gentoo.org>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	linux-phy@lists.infradead.org, devicetree@vger.kernel.org,
	linux-riscv@lists.infradead.org, spacemit@lists.linux.dev,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 4/4] phy: spacemit: add USB3 support for K1 PCIe/USB3 combo PHY
Date: Wed, 14 May 2025 20:00:28 +0800	[thread overview]
Message-ID: <95e8f8fd-d7ea-4d78-a794-72f73a3e19f3@whut.edu.cn> (raw)
In-Reply-To: <aCRaAEJSphC7uWY0@vaman>

On 5/14/25 4:53 PM, Vinod Koul wrote:
> On 18-04-25, 21:19, Ze Huang wrote:
>> Add support for USB 3.0 mode on the K1 PCIe/USB3 combo PHY. Currently,
>> only USB mode is supported; PCIe support is not included in this change.
>>
>> Signed-off-by: Ze Huang <huangze@whut.edu.cn>
>> ---
...
>> +#define COMBPHY_USB_LFPS_REG		0x58
>> +#define  COMBPHY_USB_LFPS_MASK		0x700
>> +#define  COMBPHY_USB_LFPS_THRES_DEFAULT	0x03
> Same comment as other patch

>> +
>> +#define COMBPHY_MODE_SEL	BIT(3)
>> +#define COMBPHY_WAIT_TIMEOUT	1000
>> +
>> +struct spacemit_combphy_priv {
>> +	struct device *dev;
>> +	struct phy *phy;
>> +	struct reset_control *phy_rst;
>> +	void __iomem *phy_ctrl;
>> +	void __iomem *phy_sel;
>> +	bool rx_always_on;
>> +	u8 lfps_threshold;
>> +	u8 type;
>> +};
>> +
>> +static void spacemit_reg_update(void __iomem *reg, u32 offset, u32 mask, u32 val)
>> +{
>> +	u32 tmp;
>> +
>> +	tmp = readl(reg + offset);
>> +	tmp = (tmp & ~(mask)) | val;
>> +	writel(tmp, reg + offset);
>> +}
>> +
>> +static int spacemit_combphy_wait_ready(struct spacemit_combphy_priv *priv,
>> +				       u32 offset, u32 mask, u32 val)
>> +{
>> +	u32 reg_val;
>> +	int ret = 0;
> Superfluous init, drop it pls

OK

>
>> +
>> +	ret = read_poll_timeout(readl, reg_val, (reg_val & mask) == val,
>> +				1000, COMBPHY_WAIT_TIMEOUT * 1000, false,
>> +				priv->phy_ctrl + offset);
>> +
>> +	return ret;
> why use local variable?

Will drop it.

>
>> +}
>> +
>> +static int spacemit_combphy_set_mode(struct spacemit_combphy_priv *priv)
>> +{
>> +	int ret = 0;
>> +
>> +	switch (priv->type) {
>> +	case PHY_TYPE_USB3:
>> +		spacemit_reg_update(priv->phy_sel, 0, 0, COMBPHY_MODE_SEL);
>> +		break;
>> +	default:
>> +		dev_err(priv->dev, "PHY type %x not supported\n", priv->type);
>> +		ret = -EINVAL;
>> +		break;
>> +	}
>> +
>> +	return ret;
>> +}
...
>> +static const struct of_device_id spacemit_combphy_of_match[] = {
>> +	{ .compatible = "spacemit,k1-combphy", },
>> +	{ /* sentinel */ }
>> +};
>> +MODULE_DEVICE_TABLE(of, spacemit_combphy_of_match);
>> +
>> +static struct platform_driver spacemit_combphy_driver = {
>> +	.probe	= spacemit_combphy_probe,
>> +	.driver = {
>> +		.name = "spacemit-k1-combphy",
>> +		.of_match_table = spacemit_combphy_of_match,
>> +	},
>> +};
>> +module_platform_driver(spacemit_combphy_driver);
>> +
>> +MODULE_DESCRIPTION("Spacemit PCIE/USB3.0 COMBO PHY driver");
>> +MODULE_LICENSE("GPL");
> Could this be single driver with different init register sequences?

Yes, on K1 SoC, the USB3 and PCIe Port A share the same COMBO PHY hardware.

PHY can be initialized for PCIe as well via a different init sequence.
In the future, we can extend the driver to support both modes based on 
the DT property.


  reply	other threads:[~2025-05-14 12:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-18 13:19 [PATCH v2 0/4] Add USB2.0 PHY and USB3.0 PHY support for SpacemiT K1 Ze Huang
2025-04-18 13:19 ` [PATCH v2 1/4] dt-bindings: phy: spacemit: add K1 USB2 PHY Ze Huang
2025-04-18 13:19 ` [PATCH v2 2/4] dt-bindings: phy: spacemit: add K1 PCIe/USB3 combo PHY Ze Huang
2025-04-23 15:23   ` Rob Herring (Arm)
2025-04-18 13:19 ` [PATCH v2 3/4] phy: spacemit: support K1 USB2.0 PHY controller Ze Huang
2025-05-14  8:51   ` Vinod Koul
2025-05-14 11:54     ` Ze Huang
2025-04-18 13:19 ` [PATCH v2 4/4] phy: spacemit: add USB3 support for K1 PCIe/USB3 combo PHY Ze Huang
2025-05-14  8:53   ` Vinod Koul
2025-05-14 12:00     ` Ze Huang [this message]
2025-05-14 13:06   ` Philipp Zabel

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=95e8f8fd-d7ea-4d78-a794-72f73a3e19f3@whut.edu.cn \
    --to=huangze@whut.edu.cn \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dlan@gentoo.org \
    --cc=kishon@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-phy@lists.infradead.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=p.zabel@pengutronix.de \
    --cc=robh@kernel.org \
    --cc=spacemit@lists.linux.dev \
    --cc=vkoul@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

all inboxes | Powered by JetHome®