public inbox for linux-mips@vger.kernel.org
 help / color / mirror / Atom feed
From: "Théo Lebrun" <theo.lebrun@bootlin.com>
To: "Vinod Koul" <vkoul@kernel.org>, "Théo Lebrun" <theo.lebrun@bootlin.com>
Cc: "Vladimir Kondratiev" <vladimir.kondratiev@mobileye.com>,
	"Grégory Clement" <gregory.clement@bootlin.com>,
	"Rob Herring" <robh@kernel.org>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Conor Dooley" <conor+dt@kernel.org>,
	"Kishon Vijay Abraham I" <kishon@kernel.org>,
	"Michael Turquette" <mturquette@baylibre.com>,
	"Stephen Boyd" <sboyd@kernel.org>,
	"Philipp Zabel" <p.zabel@pengutronix.de>,
	"Thomas Bogendoerfer" <tsbogend@alpha.franken.de>,
	"Neil Armstrong" <neil.armstrong@linaro.org>,
	linux-mips@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org,
	linux-clk@vger.kernel.org,
	"Benoît Monin" <benoit.monin@bootlin.com>,
	"Tawfik Bayouk" <tawfik.bayouk@mobileye.com>,
	"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
	"Luca Ceresoli" <luca.ceresoli@bootlin.com>
Subject: Re: [PATCH v5 2/7] phy: Add driver for EyeQ5 Ethernet PHY wrapper
Date: Mon, 05 Jan 2026 17:24:11 +0100	[thread overview]
Message-ID: <DFGSMN8268O0.33TYCQDBVHUHZ@bootlin.com> (raw)
In-Reply-To: <aUq7E4yh0OgTfdxF@vaman>

Hello Vinod,

On Tue Dec 23, 2025 at 4:53 PM CET, Vinod Koul wrote:
> On 15-12-25, 17:26, Théo Lebrun wrote:
>> EyeQ5 embeds a system-controller called OLB. It features many unrelated
>> registers, and some of those are registers used to configure the
>> integration of the RGMII/SGMII Cadence PHY used by MACB/GEM instances.
>> 
>> Wrap in a neat generic PHY provider, exposing two PHYs with standard
>> phy_init() / phy_set_mode() / phy_power_on() operations.
>> 
>> Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
>> Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
>> ---
>>  MAINTAINERS                 |   1 +
>>  drivers/phy/Kconfig         |  13 +++
>>  drivers/phy/Makefile        |   1 +
>>  drivers/phy/phy-eyeq5-eth.c | 249 ++++++++++++++++++++++++++++++++++++++++++++
>>  4 files changed, 264 insertions(+)
>> 
>> diff --git a/MAINTAINERS b/MAINTAINERS
>> index 5b11839cba9d..2f67ec9fad57 100644
>> --- a/MAINTAINERS
>> +++ b/MAINTAINERS
>> @@ -17605,6 +17605,7 @@ F:	arch/mips/boot/dts/mobileye/
>>  F:	arch/mips/configs/eyeq5_defconfig
>>  F:	arch/mips/mobileye/board-epm5.its.S
>>  F:	drivers/clk/clk-eyeq.c
>> +F:	drivers/phy/phy-eyeq5-eth.c
>>  F:	drivers/pinctrl/pinctrl-eyeq5.c
>>  F:	drivers/reset/reset-eyeq.c
>>  F:	include/dt-bindings/clock/mobileye,eyeq5-clk.h
>> diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
>> index 678dd0452f0a..1aa6eff12dbc 100644
>> --- a/drivers/phy/Kconfig
>> +++ b/drivers/phy/Kconfig
>> @@ -101,6 +101,19 @@ config PHY_NXP_PTN3222
>>  	  schemes. It supports all three USB 2.0 data rates: Low Speed, Full
>>  	  Speed and High Speed.
>>  
>> +config PHY_EYEQ5_ETH
>
> sorted please

I wouldn't mind, but entries are currently (v6.19-rc4) not sorted:

$ diff -U100 <(grep ^config drivers/phy/Kconfig) \
             <(grep ^config drivers/phy/Kconfig | sort)
--- /dev/fd/63 2026-01-05 15:55:53.891922890 +0100
+++ /dev/fd/62 2026-01-05 15:55:53.891922890 +0100
@@ -1,11 +1,11 @@
 config GENERIC_PHY
 config GENERIC_PHY_MIPI_DPHY
+config PHY_AIROHA_PCIE
+config PHY_CAN_TRANSCEIVER
+config PHY_EYEQ5_ETH
 config PHY_LPC18XX_USB_OTG
+config PHY_NXP_PTN3222
 config PHY_PISTACHIO_USB
 config PHY_SNPS_EUSB2
 config PHY_XGENE
 config USB_LGM_PHY
-config PHY_CAN_TRANSCEIVER
-config PHY_AIROHA_PCIE
-config PHY_NXP_PTN3222
-config PHY_EYEQ5_ETH

This is why I appended. In V2, I'll send a first patch to reorder
entries to then be able to add PHY_EYEQ5_ETH in the correct location.

>> +	tristate "Ethernet PHY Driver on EyeQ5"
>> +	depends on OF
>> +	depends on MACH_EYEQ5 || COMPILE_TEST
>> +	select AUXILIARY_BUS
>> +	select GENERIC_PHY
>> +	default MACH_EYEQ5
>
> hmmm why should it be default? Maybe add this is respective defconfig for
> platform instead..?

We have been doing this for other parts of OLB. If you are doing a
config for EyeQ5, most probably you want this enabled.

One example usecase this default field makes config easier: when you
migrate an eyeq* config to eyeq5 without resetting the full config by
applying eyeq5_defconfig. With default field you get this driver
enabled, otherwise you don't and Ethernet doesn't work.

I'd prefer keeping this default but we can drop it if you lean strongly
against it.

>> +	help
>> +	  Enable this to support the Ethernet PHY integrated on EyeQ5.
>> +	  It supports both RGMII and SGMII. Registers are located in a
>> +	  shared register region called OLB. If M is selected, the
>> +	  module will be called phy-eyeq5-eth.
>> +
>>  source "drivers/phy/allwinner/Kconfig"
>>  source "drivers/phy/amlogic/Kconfig"
>>  source "drivers/phy/broadcom/Kconfig"
>> diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
>> index bfb27fb5a494..8289497ece55 100644
>> --- a/drivers/phy/Makefile
>> +++ b/drivers/phy/Makefile
>> @@ -13,6 +13,7 @@ obj-$(CONFIG_PHY_SNPS_EUSB2)		+= phy-snps-eusb2.o
>>  obj-$(CONFIG_USB_LGM_PHY)		+= phy-lgm-usb.o
>>  obj-$(CONFIG_PHY_AIROHA_PCIE)		+= phy-airoha-pcie.o
>>  obj-$(CONFIG_PHY_NXP_PTN3222)		+= phy-nxp-ptn3222.o
>> +obj-$(CONFIG_PHY_EYEQ5_ETH)		+= phy-eyeq5-eth.o
>
> sorted please

Same as for Kconfig. Will do it in two steps: first sort, then add the
CONFIG_PHY_EYEQ5_ETH line.

$ diff -U100 <(grep ^obj-\\$ drivers/phy/Makefile) \
             <(grep ^obj-\\$ drivers/phy/Makefile | sort)
--- /dev/fd/63 2026-01-05 16:11:10.977537425 +0100
+++ /dev/fd/62 2026-01-05 16:11:10.978537396 +0100
@@ -1,11 +1,11 @@
-obj-$(CONFIG_GENERIC_PHY)              += phy-core.o
 obj-$(CONFIG_GENERIC_PHY_MIPI_DPHY)    += phy-core-mipi-dphy.o
+obj-$(CONFIG_GENERIC_PHY)              += phy-core.o
+obj-$(CONFIG_PHY_AIROHA_PCIE)          += phy-airoha-pcie.o
 obj-$(CONFIG_PHY_CAN_TRANSCEIVER)      += phy-can-transceiver.o
+obj-$(CONFIG_PHY_EYEQ5_ETH)            += phy-eyeq5-eth.o
 obj-$(CONFIG_PHY_LPC18XX_USB_OTG)      += phy-lpc18xx-usb-otg.o
-obj-$(CONFIG_PHY_XGENE)                += phy-xgene.o
+obj-$(CONFIG_PHY_NXP_PTN3222)          += phy-nxp-ptn3222.o
 obj-$(CONFIG_PHY_PISTACHIO_USB)        += phy-pistachio-usb.o
 obj-$(CONFIG_PHY_SNPS_EUSB2)           += phy-snps-eusb2.o
+obj-$(CONFIG_PHY_XGENE)                += phy-xgene.o
 obj-$(CONFIG_USB_LGM_PHY)              += phy-lgm-usb.o
-obj-$(CONFIG_PHY_AIROHA_PCIE)          += phy-airoha-pcie.o
-obj-$(CONFIG_PHY_NXP_PTN3222)          += phy-nxp-ptn3222.o
-obj-$(CONFIG_PHY_EYEQ5_ETH)            += phy-eyeq5-eth.o

[...]

>> +static int eq5_phy_exit(struct phy *phy)
>> +{
>> +	struct eq5_phy_inst *inst = phy_get_drvdata(phy);
>> +	struct eq5_phy_private *priv = inst->priv;
>> +	struct device *dev = priv->dev;
>> +
>> +	dev_dbg(dev, "phy_exit(inst=%td)\n", inst - priv->phys);
>> +
>> +	writel(0, inst->gp);
>> +	writel(0, inst->sgmii);
>> +	udelay(5);
>
> this is same patter in init as well...?

Yes! phy_ops::init() must reinit the HW to ensure its config fields
are well taken into account. We might inherit an already initialised
PHY from the bootloader.

We could in theory move those three ops (writel+writel+udelay) into a
helper function but I feel like it would decrease readability without
increasing code quality.

>> +
>> +	return 0;
>> +}
>> +
>> +static int eq5_phy_set_mode(struct phy *phy, enum phy_mode mode, int submode)
>> +{
>> +	struct eq5_phy_inst *inst = phy_get_drvdata(phy);
>> +	struct eq5_phy_private *priv = inst->priv;
>> +	struct device *dev = priv->dev;
>> +
>> +	dev_dbg(dev, "phy_set_mode(inst=%td, mode=%d, submode=%d)\n",
>> +		inst - priv->phys, mode, submode);
>
> these are good for debug but not for upstream, please drop

Ah this is surprising! They helped me debug this driver and fix one bug
or two so I thought I'd leave them in. They get compiled out by
default. And there is no ftrace events equivalent which would make
those dev_dbg() moot.

⟩ git grep -F dev_dbg\( drivers/ | wc -l
25174
⟩ git grep -F dev_dbg\( drivers/phy/ | wc -l
260

[...]

>> +static int eq5_phy_probe(struct auxiliary_device *adev,
>> +			 const struct auxiliary_device_id *id)
>> +{
>> +	struct device *dev = &adev->dev;
>> +	struct phy_provider *provider;
>> +	struct eq5_phy_private *priv;
>> +	void __iomem *base;
>> +	int ret;
>> +
>> +	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
>> +	if (!priv)
>> +		return -ENOMEM;
>> +
>> +	priv->dev = dev;
>> +	dev_set_drvdata(dev, priv);
>> +
>> +	base = (void __iomem *)dev_get_platdata(dev);
>
> no need to cast for void *

Yes! My initial goal was to prevent a sparse warning about the implicit
cast from `void *` as returned by dev_get_platdata() and
`void __iomem *base`.

But it does not matter in our case (and the correct solution for
explicit cast would have implied __force).

--

I'll wait for feedback on `default MACH_EYEQ5` and `dev_dbg()` before
sending the next revision.

Thanks for the review!

--
Théo Lebrun, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com


  reply	other threads:[~2026-01-05 16:24 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-15 16:26 [PATCH v5 0/7] Add generic PHY driver used by MACB/GEM on EyeQ5 Théo Lebrun
2025-12-15 16:26 ` [PATCH v5 1/7] dt-bindings: soc: mobileye: OLB is an Ethernet PHY provider " Théo Lebrun
2025-12-15 16:26 ` [PATCH v5 2/7] phy: Add driver for EyeQ5 Ethernet PHY wrapper Théo Lebrun
2025-12-23 15:53   ` Vinod Koul
2026-01-05 16:24     ` Théo Lebrun [this message]
2025-12-15 16:26 ` [PATCH v5 3/7] clk: eyeq: use the auxiliary device creation helper Théo Lebrun
2025-12-15 16:26 ` [PATCH v5 4/7] clk: eyeq: add EyeQ5 children auxiliary device for generic PHYs Théo Lebrun
2025-12-15 16:26 ` [PATCH v5 5/7] reset: eyeq: drop device_set_of_node_from_dev() done by parent Théo Lebrun
2025-12-15 16:26 ` [PATCH v5 6/7] MIPS: mobileye: eyeq5: add two Cadence GEM Ethernet controllers Théo Lebrun
2025-12-15 16:26 ` [PATCH v5 7/7] MIPS: mobileye: eyeq5-epm: add two Cadence GEM Ethernet PHYs Théo Lebrun

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=DFGSMN8268O0.33TYCQDBVHUHZ@bootlin.com \
    --to=theo.lebrun@bootlin.com \
    --cc=benoit.monin@bootlin.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=gregory.clement@bootlin.com \
    --cc=kishon@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=linux-phy@lists.infradead.org \
    --cc=luca.ceresoli@bootlin.com \
    --cc=mturquette@baylibre.com \
    --cc=neil.armstrong@linaro.org \
    --cc=p.zabel@pengutronix.de \
    --cc=robh@kernel.org \
    --cc=sboyd@kernel.org \
    --cc=tawfik.bayouk@mobileye.com \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=tsbogend@alpha.franken.de \
    --cc=vkoul@kernel.org \
    --cc=vladimir.kondratiev@mobileye.com \
    /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