drivers/phy/phy-nxp-ptn3222.c
Source file repositories/reference/linux-study-clean/drivers/phy/phy-nxp-ptn3222.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/phy/phy-nxp-ptn3222.c- Extension
.c- Size
- 2750 bytes
- Lines
- 124
- 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/gpio/consumer.hlinux/i2c.hlinux/module.hlinux/of.hlinux/phy/phy.hlinux/regmap.hlinux/regulator/consumer.h
Detected Declarations
struct ptn3222function ptn3222_initfunction ptn3222_exitfunction ptn3222_probe
Annotated Snippet
struct ptn3222 {
struct i2c_client *client;
struct phy *phy;
struct gpio_desc *reset_gpio;
struct regulator_bulk_data *supplies;
};
static int ptn3222_init(struct phy *phy)
{
struct ptn3222 *ptn3222 = phy_get_drvdata(phy);
int ret;
ret = regulator_bulk_enable(NUM_SUPPLIES, ptn3222->supplies);
if (ret)
return ret;
gpiod_set_value_cansleep(ptn3222->reset_gpio, 0);
return 0;
}
static int ptn3222_exit(struct phy *phy)
{
struct ptn3222 *ptn3222 = phy_get_drvdata(phy);
gpiod_set_value_cansleep(ptn3222->reset_gpio, 1);
return regulator_bulk_disable(NUM_SUPPLIES, ptn3222->supplies);
}
static const struct phy_ops ptn3222_ops = {
.init = ptn3222_init,
.exit = ptn3222_exit,
.owner = THIS_MODULE,
};
static const struct regulator_bulk_data ptn3222_supplies[NUM_SUPPLIES] = {
{
.supply = "vdd3v3",
.init_load_uA = 11000,
}, {
.supply = "vdd1v8",
.init_load_uA = 55000,
}
};
static int ptn3222_probe(struct i2c_client *client)
{
struct device *dev = &client->dev;
struct phy_provider *phy_provider;
struct ptn3222 *ptn3222;
int ret;
ptn3222 = devm_kzalloc(dev, sizeof(*ptn3222), GFP_KERNEL);
if (!ptn3222)
return -ENOMEM;
ptn3222->client = client;
ptn3222->reset_gpio = devm_gpiod_get_optional(dev, "reset",
GPIOD_OUT_HIGH);
if (IS_ERR(ptn3222->reset_gpio))
return dev_err_probe(dev, PTR_ERR(ptn3222->reset_gpio),
"unable to acquire reset gpio\n");
ret = devm_regulator_bulk_get_const(dev, NUM_SUPPLIES, ptn3222_supplies,
&ptn3222->supplies);
if (ret)
return ret;
ptn3222->phy = devm_phy_create(dev, dev->of_node, &ptn3222_ops);
if (IS_ERR(ptn3222->phy)) {
dev_err(dev, "failed to create PHY: %d\n", ret);
return PTR_ERR(ptn3222->phy);
}
phy_set_drvdata(ptn3222->phy, ptn3222);
phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
return PTR_ERR_OR_ZERO(phy_provider);
}
static const struct i2c_device_id ptn3222_table[] = {
{ "ptn3222" },
{ }
};
MODULE_DEVICE_TABLE(i2c, ptn3222_table);
static const struct of_device_id ptn3222_of_table[] = {
Annotation
- Immediate include surface: `linux/gpio/consumer.h`, `linux/i2c.h`, `linux/module.h`, `linux/of.h`, `linux/phy/phy.h`, `linux/regmap.h`, `linux/regulator/consumer.h`.
- Detected declarations: `struct ptn3222`, `function ptn3222_init`, `function ptn3222_exit`, `function ptn3222_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.