drivers/phy/mediatek/phy-mtk-tphy.c
Source file repositories/reference/linux-study-clean/drivers/phy/mediatek/phy-mtk-tphy.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/phy/mediatek/phy-mtk-tphy.c- Extension
.c- Size
- 46878 bytes
- Lines
- 1680
- Domain
- Driver Families
- Bucket
- drivers/phy
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- 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
dt-bindings/phy/phy.hlinux/clk.hlinux/debugfs.hlinux/delay.hlinux/iopoll.hlinux/mfd/syscon.hlinux/module.hlinux/nvmem-consumer.hlinux/of.hlinux/of_address.hlinux/phy/phy.hlinux/platform_device.hlinux/regmap.hphy-mtk-io.h
Detected Declarations
struct mtk_phy_pdatastruct u2phy_banksstruct u3phy_banksstruct mtk_phy_instancestruct mtk_tphyenum mtk_phy_versionenum u2_phy_paramsenum u3_phy_paramsfunction u2_phy_params_showfunction u2_phy_params_openfunction u2_phy_params_writefunction u2_phy_dbgfs_files_createfunction u3_phy_params_showfunction u3_phy_params_openfunction u3_phy_params_writefunction u3_phy_dbgfs_files_createfunction phy_type_showfunction phy_debugfs_initfunction phy_debugfs_initfunction u3_phy_instance_initfunction u2_phy_pll_26m_setfunction u2_phy_instance_initfunction u2_phy_instance_power_onfunction u2_phy_instance_power_offfunction u2_phy_instance_exitfunction u2_phy_instance_set_modefunction pcie_phy_instance_initfunction pcie_phy_instance_power_onfunction pcie_phy_instance_power_offfunction sata_phy_instance_initfunction phy_v1_banks_initfunction phy_v2_banks_initfunction phy_parse_propertyfunction u2_phy_props_setfunction phy_type_syscon_getfunction phy_type_setfunction phy_efuse_getfunction phy_efuse_setfunction mtk_phy_initfunction mtk_phy_power_onfunction mtk_phy_power_offfunction mtk_phy_exitfunction mtk_phy_set_modefunction mtk_tphy_probe
Annotated Snippet
static const struct file_operations u2_phy_fops = {
.open = u2_phy_params_open,
.write = u2_phy_params_write,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static void u2_phy_dbgfs_files_create(struct mtk_phy_instance *inst)
{
u32 count = ARRAY_SIZE(u2_phy_files);
int i;
for (i = 0; i < count; i++)
debugfs_create_file_aux_num(u2_phy_files[i], 0644, inst->phy->debugfs,
inst, i, &u2_phy_fops);
}
static int u3_phy_params_show(struct seq_file *sf, void *unused)
{
struct mtk_phy_instance *inst = sf->private;
struct u3phy_banks *u3_banks = &inst->u3_banks;
u32 val = 0;
u32 max = 0;
u32 tmp;
int ret = debugfs_get_aux_num(sf->file);
switch (ret) {
case U3P_EFUSE_EN:
tmp = readl(u3_banks->phyd + U3P_U3_PHYD_RSV);
val = !!(tmp & P3D_RG_EFUSE_AUTO_LOAD_DIS);
max = 1;
break;
case U3P_EFUSE_INTR:
tmp = readl(u3_banks->phya + U3P_U3_PHYA_REG0);
val = FIELD_GET(P3A_RG_IEXT_INTR, tmp);
max = FIELD_MAX(P3A_RG_IEXT_INTR);
break;
case U3P_EFUSE_TX_IMP:
tmp = readl(u3_banks->phyd + U3P_U3_PHYD_IMPCAL0);
val = FIELD_GET(P3D_RG_TX_IMPEL, tmp);
max = FIELD_MAX(P3D_RG_TX_IMPEL);
break;
case U3P_EFUSE_RX_IMP:
tmp = readl(u3_banks->phyd + U3P_U3_PHYD_IMPCAL1);
val = FIELD_GET(P3D_RG_RX_IMPEL, tmp);
max = FIELD_MAX(P3D_RG_RX_IMPEL);
break;
default:
seq_printf(sf, "invalid, %d\n", ret);
break;
}
seq_printf(sf, "%s : %d [0, %d]\n", u3_phy_files[ret], val, max);
return 0;
}
static int u3_phy_params_open(struct inode *inode, struct file *file)
{
return single_open(file, u3_phy_params_show, inode->i_private);
}
static ssize_t u3_phy_params_write(struct file *file, const char __user *ubuf,
size_t count, loff_t *ppos)
{
struct seq_file *sf = file->private_data;
struct mtk_phy_instance *inst = sf->private;
struct u3phy_banks *u3_banks = &inst->u3_banks;
void __iomem *phyd = u3_banks->phyd;
ssize_t rc;
u32 val;
int ret = debugfs_get_aux_num(sf->file);
rc = kstrtouint_from_user(ubuf, USER_BUF_LEN(count), 0, &val);
if (rc)
return rc;
switch (ret) {
case U3P_EFUSE_EN:
mtk_phy_update_field(phyd + U3P_U3_PHYD_RSV,
P3D_RG_EFUSE_AUTO_LOAD_DIS, !!val);
break;
case U3P_EFUSE_INTR:
mtk_phy_update_field(u3_banks->phya + U3P_U3_PHYA_REG0,
Annotation
- Immediate include surface: `dt-bindings/phy/phy.h`, `linux/clk.h`, `linux/debugfs.h`, `linux/delay.h`, `linux/iopoll.h`, `linux/mfd/syscon.h`, `linux/module.h`, `linux/nvmem-consumer.h`.
- Detected declarations: `struct mtk_phy_pdata`, `struct u2phy_banks`, `struct u3phy_banks`, `struct mtk_phy_instance`, `struct mtk_tphy`, `enum mtk_phy_version`, `enum u2_phy_params`, `enum u3_phy_params`, `function u2_phy_params_show`, `function u2_phy_params_open`.
- Atlas domain: Driver Families / drivers/phy.
- Implementation status: pattern 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.