drivers/phy/broadcom/phy-bcm-ns2-pcie.c
Source file repositories/reference/linux-study-clean/drivers/phy/broadcom/phy-bcm-ns2-pcie.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/phy/broadcom/phy-bcm-ns2-pcie.c- Extension
.c- Size
- 2038 bytes
- Lines
- 88
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/device.hlinux/module.hlinux/of_mdio.hlinux/mdio.hlinux/phy.hlinux/phy/phy.h
Detected Declarations
function ns2_pci_phy_initfunction ns2_pci_phy_probe
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
// Copyright (C) 2016 Broadcom
#include <linux/device.h>
#include <linux/module.h>
#include <linux/of_mdio.h>
#include <linux/mdio.h>
#include <linux/phy.h>
#include <linux/phy/phy.h>
#define BLK_ADDR_REG_OFFSET 0x1f
#define PLL_AFE1_100MHZ_BLK 0x2100
#define PLL_CLK_AMP_OFFSET 0x03
#define PLL_CLK_AMP_2P05V 0x2b18
static int ns2_pci_phy_init(struct phy *p)
{
struct mdio_device *mdiodev = phy_get_drvdata(p);
int rc;
/* select the AFE 100MHz block page */
rc = mdiodev_write(mdiodev, BLK_ADDR_REG_OFFSET, PLL_AFE1_100MHZ_BLK);
if (rc)
goto err;
/* set the 100 MHz reference clock amplitude to 2.05 v */
rc = mdiodev_write(mdiodev, PLL_CLK_AMP_OFFSET, PLL_CLK_AMP_2P05V);
if (rc)
goto err;
return 0;
err:
dev_err(&mdiodev->dev, "Error %d writing to phy\n", rc);
return rc;
}
static const struct phy_ops ns2_pci_phy_ops = {
.init = ns2_pci_phy_init,
.owner = THIS_MODULE,
};
static int ns2_pci_phy_probe(struct mdio_device *mdiodev)
{
struct device *dev = &mdiodev->dev;
struct phy_provider *provider;
struct phy *phy;
phy = devm_phy_create(dev, dev->of_node, &ns2_pci_phy_ops);
if (IS_ERR(phy)) {
dev_err(dev, "failed to create Phy\n");
return PTR_ERR(phy);
}
phy_set_drvdata(phy, mdiodev);
provider = devm_of_phy_provider_register(&phy->dev,
of_phy_simple_xlate);
if (IS_ERR(provider)) {
dev_err(dev, "failed to register Phy provider\n");
return PTR_ERR(provider);
}
return 0;
}
static const struct of_device_id ns2_pci_phy_of_match[] = {
{ .compatible = "brcm,ns2-pcie-phy", },
{ /* sentinel */ },
};
MODULE_DEVICE_TABLE(of, ns2_pci_phy_of_match);
static struct mdio_driver ns2_pci_phy_driver = {
.mdiodrv = {
.driver = {
.name = "phy-bcm-ns2-pci",
.of_match_table = ns2_pci_phy_of_match,
},
},
.probe = ns2_pci_phy_probe,
};
mdio_module_driver(ns2_pci_phy_driver);
MODULE_AUTHOR("Broadcom");
MODULE_DESCRIPTION("Broadcom Northstar2 PCI Phy driver");
MODULE_LICENSE("GPL v2");
MODULE_ALIAS("platform:phy-bcm-ns2-pci");
Annotation
- Immediate include surface: `linux/device.h`, `linux/module.h`, `linux/of_mdio.h`, `linux/mdio.h`, `linux/phy.h`, `linux/phy/phy.h`.
- Detected declarations: `function ns2_pci_phy_init`, `function ns2_pci_phy_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.