drivers/phy/realtek/phy-rtk-usb3.c
Source file repositories/reference/linux-study-clean/drivers/phy/realtek/phy-rtk-usb3.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/phy/realtek/phy-rtk-usb3.c- Extension
.c- Size
- 20345 bytes
- Lines
- 751
- Domain
- Driver Families
- Bucket
- drivers/phy
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/of.hlinux/of_address.hlinux/platform_device.hlinux/uaccess.hlinux/debugfs.hlinux/nvmem-consumer.hlinux/regmap.hlinux/sys_soc.hlinux/mfd/syscon.hlinux/phy/phy.hlinux/usb.h
Detected Declarations
struct phy_regstruct phy_datastruct phy_cfgstruct phy_parameterstruct rtk_phyfunction utmi_wait_registerfunction rtk_phy3_wait_vbusyfunction rtk_phy_readfunction rtk_phy_writefunction do_rtk_usb3_phy_togglefunction do_rtk_phy_initfunction rtk_phy_initfunction rtk_phy_exitfunction rtk_phy_togglefunction rtk_phy_connectfunction rtk_phy_disconnectfunction rtk_usb3_parameter_showfunction create_debug_filesfunction remove_debug_filesfunction create_debug_filesfunction update_amplitude_control_valuefunction parse_phy_datafunction rtk_usb3phy_probefunction rtk_usb3phy_remove
Annotated Snippet
struct phy_reg {
void __iomem *reg_mdio_ctl;
};
struct phy_data {
u8 addr;
u16 data;
};
struct phy_cfg {
int param_size;
struct phy_data param[MAX_USB_PHY_DATA_SIZE];
bool check_efuse;
bool do_toggle;
bool do_toggle_once;
bool use_default_parameter;
bool check_rx_front_end_offset;
};
struct phy_parameter {
struct phy_reg phy_reg;
/* Get from efuse */
u8 efuse_usb_u3_tx_lfps_swing_trim;
/* Get from dts */
u32 amplitude_control_coarse;
u32 amplitude_control_fine;
};
struct rtk_phy {
struct device *dev;
struct phy_cfg *phy_cfg;
int num_phy;
struct phy_parameter *phy_parameter;
struct dentry *debug_dir;
};
#define PHY_IO_TIMEOUT_USEC (50000)
#define PHY_IO_DELAY_US (100)
static inline int utmi_wait_register(void __iomem *reg, u32 mask, u32 result)
{
int ret;
unsigned int val;
ret = read_poll_timeout(readl, val, ((val & mask) == result),
PHY_IO_DELAY_US, PHY_IO_TIMEOUT_USEC, false, reg);
if (ret) {
pr_err("%s can't program USB phy\n", __func__);
return -ETIMEDOUT;
}
return 0;
}
static int rtk_phy3_wait_vbusy(struct phy_reg *phy_reg)
{
return utmi_wait_register(phy_reg->reg_mdio_ctl, USB_MDIO_CTRL_PHY_BUSY, 0);
}
static u16 rtk_phy_read(struct phy_reg *phy_reg, char addr)
{
unsigned int tmp;
u32 value;
tmp = (addr << USB_MDIO_CTRL_PHY_ADDR_SHIFT);
writel(tmp, phy_reg->reg_mdio_ctl);
rtk_phy3_wait_vbusy(phy_reg);
value = readl(phy_reg->reg_mdio_ctl);
value = value >> USB_MDIO_CTRL_PHY_DATA_SHIFT;
return (u16)value;
}
static int rtk_phy_write(struct phy_reg *phy_reg, char addr, u16 data)
{
unsigned int val;
val = USB_MDIO_CTRL_PHY_WRITE |
(addr << USB_MDIO_CTRL_PHY_ADDR_SHIFT) |
(data << USB_MDIO_CTRL_PHY_DATA_SHIFT);
writel(val, phy_reg->reg_mdio_ctl);
Annotation
- Immediate include surface: `linux/module.h`, `linux/of.h`, `linux/of_address.h`, `linux/platform_device.h`, `linux/uaccess.h`, `linux/debugfs.h`, `linux/nvmem-consumer.h`, `linux/regmap.h`.
- Detected declarations: `struct phy_reg`, `struct phy_data`, `struct phy_cfg`, `struct phy_parameter`, `struct rtk_phy`, `function utmi_wait_register`, `function rtk_phy3_wait_vbusy`, `function rtk_phy_read`, `function rtk_phy_write`, `function do_rtk_usb3_phy_toggle`.
- Atlas domain: Driver Families / drivers/phy.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.