Re: [PATCH v3] phy: fsl-imx8mq-usb: add debugfs to access control register
From: Andrew Lunn <andrew@lunn.ch>
Date: 2026-01-16 15:19:10
Also in:
imx, linux-phy, lkml
On Fri, Jan 16, 2026 at 07:29:39PM +0800, Xu Yang wrote:
On Thu, Jan 08, 2026 at 10:43:01AM -0500, Frank Li wrote:quoted
On Thu, Jan 08, 2026 at 04:36:41PM +0800, Xu Yang wrote:quoted
The CR port is a simple 16-bit data/address parallel port that is provided for on-chip access to the control registers inside the USB 3.0 femtoPHY[1].quoted
While access to these registers is not required for normal PHY operation, this interface enables you to access some of the PHY’s diagnostic features during normal operation or to override some basic PHY control signals.Simple said "Export these registers by debugfs to help PHY’s diagnostic." should be enoughOK.quoted
quoted
3 debugfs files are created to read and write control registers, all use hexadecimal format: ctrl_reg_base: the register offset to write, or the start offset to read. ctrl_reg_count: how many continuous registers to be read. ctrl_reg_value: read to show the continuous registers value from the offset in ctrl_reg_base, to ctrl_reg_base + ctrl_reg_count - 1, one line for one register. when write, override the register at ctrl_reg_base, one time can only change one 16bits register.how many regs? how about create file regNNN,quoted
From 0x0 to 0x201F.
Rather than reinvent the wheel, could you use regmap? https://elixir.bootlin.com/linux/v6.12.1/source/drivers/base/regmap/regmap-debugfs.c#L546 Regmap should be able to provide a debugfs interface for you, no driver code needed. This will also help you with the abstraction between the core generic part of the PHY driver and the SoC integration glue. You pass the regmap to the core driver, and the funny muxing through two registers is hidden away from the core. If the next SoC integrated uses plan MMIO, that SoC glue driver can instantiate an MMIO regmap. Using regmap is a good idea for core generic drivers which can be integrated into SoCs in different ways. It hides the SoC details behind a well known API. Andrew