drivers/net/phy/mediatek/mtk-ge-soc.c
Source file repositories/reference/linux-study-clean/drivers/net/phy/mediatek/mtk-ge-soc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/phy/mediatek/mtk-ge-soc.c- Extension
.c- Size
- 47492 bytes
- Lines
- 1551
- Domain
- Driver Families
- Bucket
- drivers/net
- 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/bitfield.hlinux/bitmap.hlinux/mfd/syscon.hlinux/module.hlinux/nvmem-consumer.hlinux/pinctrl/consumer.hlinux/phy.hlinux/regmap.hlinux/of.h../phylib.hmtk.h
Detected Declarations
struct mtk_socphy_sharedenum calibration_modeenum CAL_ITEMenum CAL_MODEfunction cal_cyclefunction rext_fill_resultfunction rext_cal_efusefunction tx_offset_fill_resultfunction tx_offset_cal_efusefunction tx_amp_fill_resultfunction tx_amp_cal_efusefunction tx_r50_fill_resultfunction tx_r50_cal_efusefunction tx_vcm_cal_swfunction mt798x_phy_common_finetunefunction mt7981_phy_finetunefunction mt7988_phy_finetunefunction mt798x_phy_eeefunction cal_swfunction cal_efusefunction start_calfunction mt798x_phy_calibrationfunction mt798x_phy_config_initfunction mt798x_phy_led_blink_setfunction mt798x_phy_led_brightness_setfunction mt798x_phy_led_hw_is_supportedfunction mt798x_phy_led_hw_control_getfunction mt798x_phy_led_hw_control_setfunction mt7988_phy_led_get_polarityfunction mt7988_phy_fix_leds_polaritiesfunction mt7988_phy_probe_sharedfunction mt7988_phy_probefunction mt7981_phy_probefunction an7581_phy_probefunction an7581_phy_led_polarity_setfunction for_each_set_bitfunction an7583_phy_config_init
Annotated Snippet
struct mtk_socphy_shared {
u32 boottrap;
struct mtk_socphy_priv priv[4];
};
/* One calibration cycle consists of:
* 1.Set DA_CALIN_FLAG high to start calibration. Keep it high
* until AD_CAL_COMP is ready to output calibration result.
* 2.Wait until DA_CAL_CLK is available.
* 3.Fetch AD_CAL_COMP_OUT.
*/
static int cal_cycle(struct phy_device *phydev, int devad,
u32 regnum, u16 mask, u16 cal_val)
{
int reg_val;
int ret;
phy_modify_mmd(phydev, devad, regnum,
mask, cal_val);
phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_AD_CALIN,
MTK_PHY_DA_CALIN_FLAG);
ret = phy_read_mmd_poll_timeout(phydev, MDIO_MMD_VEND1,
MTK_PHY_RG_AD_CAL_CLK, reg_val,
reg_val & MTK_PHY_DA_CAL_CLK, 500,
ANALOG_INTERNAL_OPERATION_MAX_US,
false);
if (ret) {
phydev_err(phydev, "Calibration cycle timeout\n");
return ret;
}
phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_AD_CALIN,
MTK_PHY_DA_CALIN_FLAG);
ret = phy_read_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_AD_CAL_COMP);
if (ret < 0)
return ret;
ret = FIELD_GET(MTK_PHY_AD_CAL_COMP_OUT_MASK, ret);
phydev_dbg(phydev, "cal_val: 0x%x, ret: %d\n", cal_val, ret);
return ret;
}
static int rext_fill_result(struct phy_device *phydev, u16 *buf)
{
phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG5,
MTK_PHY_RG_REXT_TRIM_MASK, buf[0] << 8);
phy_modify_mmd(phydev, MDIO_MMD_VEND2, MTK_PHY_RG_BG_RASEL,
MTK_PHY_RG_BG_RASEL_MASK, buf[1]);
return 0;
}
static int rext_cal_efuse(struct phy_device *phydev, u32 *buf)
{
u16 rext_cal_val[2];
rext_cal_val[0] = EFS_RG_REXT_TRIM(buf[3]);
rext_cal_val[1] = EFS_RG_BG_RASEL(buf[3]);
rext_fill_result(phydev, rext_cal_val);
return 0;
}
static int tx_offset_fill_result(struct phy_device *phydev, u16 *buf)
{
phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_CR_TX_AMP_OFFSET_A_B,
MTK_PHY_CR_TX_AMP_OFFSET_A_MASK, buf[0] << 8);
phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_CR_TX_AMP_OFFSET_A_B,
MTK_PHY_CR_TX_AMP_OFFSET_B_MASK, buf[1]);
phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_CR_TX_AMP_OFFSET_C_D,
MTK_PHY_CR_TX_AMP_OFFSET_C_MASK, buf[2] << 8);
phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_CR_TX_AMP_OFFSET_C_D,
MTK_PHY_CR_TX_AMP_OFFSET_D_MASK, buf[3]);
return 0;
}
static int tx_offset_cal_efuse(struct phy_device *phydev, u32 *buf)
{
u16 tx_offset_cal_val[4];
tx_offset_cal_val[0] = EFS_DA_TX_AMP_OFFSET_A(buf[0]);
tx_offset_cal_val[1] = EFS_DA_TX_AMP_OFFSET_B(buf[1]);
tx_offset_cal_val[2] = EFS_DA_TX_AMP_OFFSET_C(buf[1]);
tx_offset_cal_val[3] = EFS_DA_TX_AMP_OFFSET_D(buf[1]);
tx_offset_fill_result(phydev, tx_offset_cal_val);
return 0;
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/bitmap.h`, `linux/mfd/syscon.h`, `linux/module.h`, `linux/nvmem-consumer.h`, `linux/pinctrl/consumer.h`, `linux/phy.h`, `linux/regmap.h`.
- Detected declarations: `struct mtk_socphy_shared`, `enum calibration_mode`, `enum CAL_ITEM`, `enum CAL_MODE`, `function cal_cycle`, `function rext_fill_result`, `function rext_cal_efuse`, `function tx_offset_fill_result`, `function tx_offset_cal_efuse`, `function tx_amp_fill_result`.
- Atlas domain: Driver Families / drivers/net.
- 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.