drivers/phy/amlogic/phy-meson-g12a-usb3-pcie.c
Source file repositories/reference/linux-study-clean/drivers/phy/amlogic/phy-meson-g12a-usb3-pcie.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/phy/amlogic/phy-meson-g12a-usb3-pcie.c- Extension
.c- Size
- 11231 bytes
- Lines
- 448
- 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/bitops.hlinux/clk.hlinux/module.hlinux/of.hlinux/phy/phy.hlinux/regmap.hlinux/reset.hlinux/platform_device.hdt-bindings/phy/phy.h
Detected Declarations
struct phy_g12a_usb3_pcie_privfunction phy_g12a_usb3_pcie_cr_bus_addrfunction phy_g12a_usb3_pcie_cr_bus_readfunction phy_g12a_usb3_pcie_cr_bus_writefunction phy_g12a_usb3_initfunction phy_g12a_usb3_pcie_power_onfunction phy_g12a_usb3_pcie_power_offfunction phy_g12a_usb3_pcie_resetfunction phy_g12a_usb3_pcie_initfunction phy_g12a_usb3_pcie_exitfunction phy_g12a_usb3_pcie_probe
Annotated Snippet
struct phy_g12a_usb3_pcie_priv {
struct regmap *regmap;
struct regmap *regmap_cr;
struct clk *clk_ref;
struct reset_control *reset;
struct phy *phy;
unsigned int mode;
};
static const struct regmap_config phy_g12a_usb3_pcie_regmap_conf = {
.reg_bits = 8,
.val_bits = 32,
.reg_stride = 4,
.max_register = PHY_R5,
};
static int phy_g12a_usb3_pcie_cr_bus_addr(struct phy_g12a_usb3_pcie_priv *priv,
unsigned int addr)
{
unsigned int val, reg;
int ret;
reg = FIELD_PREP(PHY_R4_PHY_CR_DATA_IN, addr);
regmap_write(priv->regmap, PHY_R4, reg);
regmap_write(priv->regmap, PHY_R4, reg);
regmap_write(priv->regmap, PHY_R4, reg | PHY_R4_PHY_CR_CAP_ADDR);
ret = regmap_read_poll_timeout(priv->regmap, PHY_R5, val,
(val & PHY_R5_PHY_CR_ACK),
5, 1000);
if (ret)
return ret;
regmap_write(priv->regmap, PHY_R4, reg);
ret = regmap_read_poll_timeout(priv->regmap, PHY_R5, val,
!(val & PHY_R5_PHY_CR_ACK),
5, 1000);
if (ret)
return ret;
return 0;
}
static int phy_g12a_usb3_pcie_cr_bus_read(void *context, unsigned int addr,
unsigned int *data)
{
struct phy_g12a_usb3_pcie_priv *priv = context;
unsigned int val;
int ret;
ret = phy_g12a_usb3_pcie_cr_bus_addr(priv, addr);
if (ret)
return ret;
regmap_write(priv->regmap, PHY_R4, 0);
regmap_write(priv->regmap, PHY_R4, PHY_R4_PHY_CR_READ);
ret = regmap_read_poll_timeout(priv->regmap, PHY_R5, val,
(val & PHY_R5_PHY_CR_ACK),
5, 1000);
if (ret)
return ret;
*data = FIELD_GET(PHY_R5_PHY_CR_DATA_OUT, val);
regmap_write(priv->regmap, PHY_R4, 0);
ret = regmap_read_poll_timeout(priv->regmap, PHY_R5, val,
!(val & PHY_R5_PHY_CR_ACK),
5, 1000);
if (ret)
return ret;
return 0;
}
static int phy_g12a_usb3_pcie_cr_bus_write(void *context, unsigned int addr,
unsigned int data)
{
struct phy_g12a_usb3_pcie_priv *priv = context;
unsigned int val, reg;
int ret;
ret = phy_g12a_usb3_pcie_cr_bus_addr(priv, addr);
if (ret)
return ret;
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/bitops.h`, `linux/clk.h`, `linux/module.h`, `linux/of.h`, `linux/phy/phy.h`, `linux/regmap.h`, `linux/reset.h`.
- Detected declarations: `struct phy_g12a_usb3_pcie_priv`, `function phy_g12a_usb3_pcie_cr_bus_addr`, `function phy_g12a_usb3_pcie_cr_bus_read`, `function phy_g12a_usb3_pcie_cr_bus_write`, `function phy_g12a_usb3_init`, `function phy_g12a_usb3_pcie_power_on`, `function phy_g12a_usb3_pcie_power_off`, `function phy_g12a_usb3_pcie_reset`, `function phy_g12a_usb3_pcie_init`, `function phy_g12a_usb3_pcie_exit`.
- 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.