drivers/phy/amlogic/phy-meson8b-usb2.c
Source file repositories/reference/linux-study-clean/drivers/phy/amlogic/phy-meson8b-usb2.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/phy/amlogic/phy-meson8b-usb2.c- Extension
.c- Size
- 10051 bytes
- Lines
- 331
- 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/bitfield.hlinux/clk.hlinux/delay.hlinux/io.hlinux/mod_devicetable.hlinux/module.hlinux/property.hlinux/regmap.hlinux/reset.hlinux/phy/phy.hlinux/platform_device.hlinux/usb/of.h
Detected Declarations
struct phy_meson8b_usb2_match_datastruct phy_meson8b_usb2_privfunction phy_meson8b_usb2_power_onfunction phy_meson8b_usb2_power_offfunction phy_meson8b_usb2_probe
Annotated Snippet
struct phy_meson8b_usb2_match_data {
bool host_enable_aca;
};
struct phy_meson8b_usb2_priv {
struct regmap *regmap;
enum usb_dr_mode dr_mode;
struct clk *clk_usb_general;
struct clk *clk_usb;
struct reset_control *reset;
const struct phy_meson8b_usb2_match_data *match;
};
static const struct regmap_config phy_meson8b_usb2_regmap_conf = {
.reg_bits = 8,
.val_bits = 32,
.reg_stride = 4,
.max_register = REG_TUNE,
};
static int phy_meson8b_usb2_power_on(struct phy *phy)
{
struct phy_meson8b_usb2_priv *priv = phy_get_drvdata(phy);
u32 reg;
int ret;
if (!IS_ERR_OR_NULL(priv->reset)) {
ret = reset_control_reset(priv->reset);
if (ret) {
dev_err(&phy->dev, "Failed to trigger USB reset\n");
return ret;
}
}
ret = clk_prepare_enable(priv->clk_usb_general);
if (ret) {
dev_err(&phy->dev, "Failed to enable USB general clock\n");
reset_control_rearm(priv->reset);
return ret;
}
ret = clk_prepare_enable(priv->clk_usb);
if (ret) {
dev_err(&phy->dev, "Failed to enable USB DDR clock\n");
clk_disable_unprepare(priv->clk_usb_general);
reset_control_rearm(priv->reset);
return ret;
}
regmap_set_bits(priv->regmap, REG_CONFIG, REG_CONFIG_CLK_32k_ALTSEL);
regmap_update_bits(priv->regmap, REG_CTRL, REG_CTRL_REF_CLK_SEL_MASK,
FIELD_PREP(REG_CTRL_REF_CLK_SEL_MASK, 0x2));
regmap_update_bits(priv->regmap, REG_CTRL, REG_CTRL_FSEL_MASK,
FIELD_PREP(REG_CTRL_FSEL_MASK, 0x5));
/* reset the PHY */
regmap_set_bits(priv->regmap, REG_CTRL, REG_CTRL_POWER_ON_RESET);
udelay(RESET_COMPLETE_TIME);
regmap_clear_bits(priv->regmap, REG_CTRL, REG_CTRL_POWER_ON_RESET);
udelay(RESET_COMPLETE_TIME);
regmap_set_bits(priv->regmap, REG_CTRL, REG_CTRL_SOF_TOGGLE_OUT);
if (priv->dr_mode == USB_DR_MODE_HOST) {
regmap_clear_bits(priv->regmap, REG_DBG_UART,
REG_DBG_UART_SET_IDDQ);
if (priv->match->host_enable_aca) {
regmap_set_bits(priv->regmap, REG_ADP_BC,
REG_ADP_BC_ACA_ENABLE);
udelay(ACA_ENABLE_COMPLETE_TIME);
regmap_read(priv->regmap, REG_ADP_BC, ®);
if (reg & REG_ADP_BC_ACA_PIN_FLOAT) {
dev_warn(&phy->dev, "USB ID detect failed!\n");
clk_disable_unprepare(priv->clk_usb);
clk_disable_unprepare(priv->clk_usb_general);
reset_control_rearm(priv->reset);
return -EINVAL;
}
}
}
return 0;
}
static int phy_meson8b_usb2_power_off(struct phy *phy)
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/clk.h`, `linux/delay.h`, `linux/io.h`, `linux/mod_devicetable.h`, `linux/module.h`, `linux/property.h`, `linux/regmap.h`.
- Detected declarations: `struct phy_meson8b_usb2_match_data`, `struct phy_meson8b_usb2_priv`, `function phy_meson8b_usb2_power_on`, `function phy_meson8b_usb2_power_off`, `function phy_meson8b_usb2_probe`.
- 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.