drivers/net/phy/teranetics.c
Source file repositories/reference/linux-study-clean/drivers/net/phy/teranetics.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/phy/teranetics.c- Extension
.c- Size
- 2404 bytes
- Lines
- 97
- Domain
- Driver Families
- Bucket
- drivers/net
- 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/kernel.hlinux/module.hlinux/mii.hlinux/ethtool.hlinux/mdio.hlinux/phy.h
Detected Declarations
function teranetics_aneg_donefunction teranetics_read_statusfunction teranetics_match_phy_device
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* Driver for Teranetics PHY
*
* Author: Shaohui Xie <Shaohui.Xie@freescale.com>
*
* Copyright 2015 Freescale Semiconductor, Inc.
*/
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/mii.h>
#include <linux/ethtool.h>
#include <linux/mdio.h>
#include <linux/phy.h>
MODULE_DESCRIPTION("Teranetics PHY driver");
MODULE_AUTHOR("Shaohui Xie <Shaohui.Xie@freescale.com>");
MODULE_LICENSE("GPL v2");
#define PHY_ID_TN2020 0x00a19410
#define MDIO_PHYXS_LNSTAT_SYNC0 0x0001
#define MDIO_PHYXS_LNSTAT_SYNC1 0x0002
#define MDIO_PHYXS_LNSTAT_SYNC2 0x0004
#define MDIO_PHYXS_LNSTAT_SYNC3 0x0008
#define MDIO_PHYXS_LNSTAT_ALIGN 0x1000
#define MDIO_PHYXS_LANE_READY (MDIO_PHYXS_LNSTAT_SYNC0 | \
MDIO_PHYXS_LNSTAT_SYNC1 | \
MDIO_PHYXS_LNSTAT_SYNC2 | \
MDIO_PHYXS_LNSTAT_SYNC3 | \
MDIO_PHYXS_LNSTAT_ALIGN)
static int teranetics_aneg_done(struct phy_device *phydev)
{
/* auto negotiation state can only be checked when using copper
* port, if using fiber port, just lie it's done.
*/
if (!phy_read_mmd(phydev, MDIO_MMD_VEND1, 93))
return genphy_c45_aneg_done(phydev);
return 1;
}
static int teranetics_read_status(struct phy_device *phydev)
{
int reg;
phydev->link = 1;
phydev->speed = SPEED_10000;
phydev->duplex = DUPLEX_FULL;
if (!phy_read_mmd(phydev, MDIO_MMD_VEND1, 93)) {
reg = phy_read_mmd(phydev, MDIO_MMD_PHYXS, MDIO_PHYXS_LNSTAT);
if (reg < 0 ||
!((reg & MDIO_PHYXS_LANE_READY) == MDIO_PHYXS_LANE_READY)) {
phydev->link = 0;
return 0;
}
reg = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_STAT1);
if (reg < 0 || !(reg & MDIO_STAT1_LSTATUS))
phydev->link = 0;
}
return 0;
}
static int teranetics_match_phy_device(struct phy_device *phydev,
const struct phy_driver *phydrv)
{
return phydev->c45_ids.device_ids[3] == PHY_ID_TN2020;
}
static struct phy_driver teranetics_driver[] = {
{
.phy_id = PHY_ID_TN2020,
.phy_id_mask = 0xffffffff,
.name = "Teranetics TN2020",
.features = PHY_10GBIT_FEATURES,
.aneg_done = teranetics_aneg_done,
.config_aneg = gen10g_config_aneg,
.read_status = teranetics_read_status,
.match_phy_device = teranetics_match_phy_device,
},
};
module_phy_driver(teranetics_driver);
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/mii.h`, `linux/ethtool.h`, `linux/mdio.h`, `linux/phy.h`.
- Detected declarations: `function teranetics_aneg_done`, `function teranetics_read_status`, `function teranetics_match_phy_device`.
- Atlas domain: Driver Families / drivers/net.
- 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.