drivers/phy/realtek/phy-rtk-usb2.c
Source file repositories/reference/linux-study-clean/drivers/phy/realtek/phy-rtk-usb2.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/phy/realtek/phy-rtk-usb2.c- Extension
.c- Size
- 35607 bytes
- Lines
- 1315
- 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 page_addr_to_array_indexfunction array_index_to_page_addrfunction utmi_wait_registerfunction rtk_phy_readfunction rtk_phy_writefunction rtk_phy_set_pagefunction __updated_dc_disconnect_level_page0_0xe4function update_dc_disconnect_level_at_page0function __updated_dc_disconnect_level_page1_0xe2function update_dc_disconnect_level_at_page1function update_dc_disconnect_levelfunction __update_dc_driving_page0_0xe4function update_dc_driving_levelfunction update_hs_clk_selectfunction do_rtk_phy_togglefunction do_rtk_phy_initfunction rtk_phy_initfunction rtk_phy_exitfunction rtk_phy_togglefunction rtk_phy_connectfunction rtk_phy_disconnectfunction rtk_usb2_parameter_showfunction create_debug_filesfunction remove_debug_filesfunction create_debug_filesfunction parse_phy_datafunction rtk_usb2phy_probefunction rtk_usb2phy_remove
Annotated Snippet
struct phy_reg {
void __iomem *reg_wrap_vstatus;
void __iomem *reg_gusb2phyacc0;
int vstatus_index;
};
struct phy_data {
u8 addr;
u8 data;
};
struct phy_cfg {
int page0_size;
struct phy_data page0[MAX_USB_PHY_PAGE0_DATA_SIZE];
int page1_size;
struct phy_data page1[MAX_USB_PHY_PAGE1_DATA_SIZE];
int page2_size;
struct phy_data page2[MAX_USB_PHY_PAGE2_DATA_SIZE];
int num_phy;
bool check_efuse;
int check_efuse_version;
#define CHECK_EFUSE_V1 1
#define CHECK_EFUSE_V2 2
int efuse_dc_driving_rate;
int efuse_dc_disconnect_rate;
int dc_driving_mask;
int dc_disconnect_mask;
bool usb_dc_disconnect_at_page0;
int driving_updated_for_dev_dis;
bool do_toggle;
bool do_toggle_driving;
bool use_default_parameter;
bool is_double_sensitivity_mode;
};
struct phy_parameter {
struct phy_reg phy_reg;
/* Get from efuse */
s8 efuse_usb_dc_cal;
s8 efuse_usb_dc_dis;
/* Get from dts */
bool inverse_hstx_sync_clock;
u32 driving_level;
s32 driving_level_compensate;
s32 disconnection_compensate;
};
struct rtk_phy {
struct device *dev;
struct phy_cfg *phy_cfg;
int num_phy;
struct phy_parameter *phy_parameter;
struct dentry *debug_dir;
};
/* mapping 0xE0 to 0 ... 0xE7 to 7, 0xF0 to 8 ,,, 0xF7 to 15 */
static inline int page_addr_to_array_index(u8 addr)
{
return (int)((((addr) - PAGE_START) & 0x7) +
((((addr) - PAGE_START) & 0x10) >> 1));
}
static inline u8 array_index_to_page_addr(int index)
{
return ((((index) + PAGE_START) & 0x7) +
((((index) & 0x8) << 1) + PAGE_START));
}
#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;
}
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 page_addr_to_array_index`, `function array_index_to_page_addr`, `function utmi_wait_register`, `function rtk_phy_read`, `function rtk_phy_write`.
- 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.