drivers/phy/freescale/phy-fsl-imx8mq-usb.c
Source file repositories/reference/linux-study-clean/drivers/phy/freescale/phy-fsl-imx8mq-usb.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/phy/freescale/phy-fsl-imx8mq-usb.c- Extension
.c- Size
- 19119 bytes
- Lines
- 762
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/clk.hlinux/delay.hlinux/io.hlinux/module.hlinux/of.hlinux/phy/phy.hlinux/platform_device.hlinux/regulator/consumer.hlinux/usb/typec_mux.h
Detected Declarations
struct tca_blkstruct imx8mq_usb_phyfunction tca_blk_typec_switch_setfunction tca_blk_put_typec_switchfunction tca_blk_orientation_setfunction tca_blk_initfunction imx95_usb_phy_put_tcafunction phy_tx_vref_tune_from_propertyfunction imx95_phy_tx_vref_tune_from_propertyfunction phy_tx_rise_tune_from_propertyfunction imx95_phy_tx_rise_tune_from_propertyfunction phy_tx_preemp_amp_tune_from_propertyfunction phy_tx_vboost_level_from_propertyfunction phy_pcs_tx_deemph_3p5db_from_propertyfunction phy_comp_dis_tune_from_propertyfunction imx95_phy_comp_dis_tune_from_propertyfunction phy_pcs_tx_swing_full_from_propertyfunction imx8m_get_phy_tuning_datafunction imx8m_phy_tunefunction imx8mq_usb_phy_initfunction imx8mp_usb_phy_initfunction imx8mq_phy_power_onfunction imx8mq_phy_power_offfunction imx8mq_usb_phy_probefunction imx8mq_usb_phy_remove
Annotated Snippet
struct tca_blk {
struct typec_switch_dev *sw;
void __iomem *base;
struct mutex mutex;
enum typec_orientation orientation;
};
struct imx8mq_usb_phy {
struct phy *phy;
struct clk *clk;
struct clk *alt_clk;
void __iomem *base;
struct regulator *vbus;
struct tca_blk *tca;
u32 pcs_tx_swing_full;
u32 pcs_tx_deemph_3p5db;
u32 tx_vref_tune;
u32 tx_rise_tune;
u32 tx_preemp_amp_tune;
u32 tx_vboost_level;
u32 comp_dis_tune;
};
static void tca_blk_orientation_set(struct tca_blk *tca,
enum typec_orientation orientation);
static int tca_blk_typec_switch_set(struct typec_switch_dev *sw,
enum typec_orientation orientation)
{
struct imx8mq_usb_phy *imx_phy = typec_switch_get_drvdata(sw);
struct tca_blk *tca = imx_phy->tca;
int ret;
if (tca->orientation == orientation)
return 0;
ret = clk_prepare_enable(imx_phy->clk);
if (ret)
return ret;
tca_blk_orientation_set(tca, orientation);
clk_disable_unprepare(imx_phy->clk);
return 0;
}
static struct typec_switch_dev *tca_blk_get_typec_switch(struct platform_device *pdev,
struct imx8mq_usb_phy *imx_phy)
{
struct device *dev = &pdev->dev;
struct typec_switch_dev *sw;
struct typec_switch_desc sw_desc = { };
sw_desc.drvdata = imx_phy;
sw_desc.fwnode = dev->fwnode;
sw_desc.set = tca_blk_typec_switch_set;
sw_desc.name = NULL;
sw = typec_switch_register(dev, &sw_desc);
if (IS_ERR(sw)) {
dev_err(dev, "Error register tca orientation switch: %ld",
PTR_ERR(sw));
return NULL;
}
return sw;
}
static void tca_blk_put_typec_switch(struct typec_switch_dev *sw)
{
typec_switch_unregister(sw);
}
static void tca_blk_orientation_set(struct tca_blk *tca,
enum typec_orientation orientation)
{
u32 val;
mutex_lock(&tca->mutex);
if (orientation == TYPEC_ORIENTATION_NONE) {
/*
* use Controller Synced Mode for TCA low power enable and
* put PHY to USB safe state.
*/
val = FIELD_PREP(TCA_GCFG_OP_MODE, TCA_GCFG_OP_MODE_SYNCMODE);
writel(val, tca->base + TCA_GCFG);
val = TCA_TCPC_VALID | TCA_TCPC_LOW_POWER_EN;
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/clk.h`, `linux/delay.h`, `linux/io.h`, `linux/module.h`, `linux/of.h`, `linux/phy/phy.h`, `linux/platform_device.h`.
- Detected declarations: `struct tca_blk`, `struct imx8mq_usb_phy`, `function tca_blk_typec_switch_set`, `function tca_blk_put_typec_switch`, `function tca_blk_orientation_set`, `function tca_blk_init`, `function imx95_usb_phy_put_tca`, `function phy_tx_vref_tune_from_property`, `function imx95_phy_tx_vref_tune_from_property`, `function phy_tx_rise_tune_from_property`.
- Atlas domain: Driver Families / drivers/phy.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.