drivers/net/phy/ncn26000.c
Source file repositories/reference/linux-study-clean/drivers/net/phy/ncn26000.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/phy/ncn26000.c- Extension
.c- Size
- 4543 bytes
- Lines
- 172
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/bitfield.hlinux/errno.hlinux/init.hlinux/module.hlinux/mii.hlinux/phy.hmdio-open-alliance.h
Detected Declarations
function ncn26000_config_initfunction ncn26000_config_anegfunction ncn26000_read_statusfunction ncn26000_handle_interruptfunction ncn26000_config_intr
Annotated Snippet
// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
/*
* Driver for the onsemi 10BASE-T1S NCN26000 PHYs family.
*
* Copyright 2022 onsemi
*/
#include <linux/kernel.h>
#include <linux/bitfield.h>
#include <linux/errno.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/mii.h>
#include <linux/phy.h>
#include "mdio-open-alliance.h"
#define PHY_ID_NCN26000 0x180FF5A1
#define NCN26000_REG_IRQ_CTL 16
#define NCN26000_REG_IRQ_STATUS 17
// the NCN26000 maps link_ctrl to BMCR_ANENABLE
#define NCN26000_BCMR_LINK_CTRL_BIT BMCR_ANENABLE
// the NCN26000 maps link_status to BMSR_ANEGCOMPLETE
#define NCN26000_BMSR_LINK_STATUS_BIT BMSR_ANEGCOMPLETE
#define NCN26000_IRQ_LINKST_BIT BIT(0)
#define NCN26000_IRQ_PLCAST_BIT BIT(1)
#define NCN26000_IRQ_LJABBER_BIT BIT(2)
#define NCN26000_IRQ_RJABBER_BIT BIT(3)
#define NCN26000_IRQ_PLCAREC_BIT BIT(4)
#define NCN26000_IRQ_PHYSCOL_BIT BIT(5)
#define NCN26000_IRQ_RESET_BIT BIT(15)
#define TO_TMR_DEFAULT 32
static int ncn26000_config_init(struct phy_device *phydev)
{
/* HW bug workaround: the default value of the PLCA TO_TIMER should be
* 32, where the current version of NCN26000 reports 24. This will be
* fixed in future PHY versions. For the time being, we force the
* correct default here.
*/
return phy_write_mmd(phydev, MDIO_MMD_VEND2, MDIO_OATC14_PLCA_TOTMR,
TO_TMR_DEFAULT);
}
static int ncn26000_config_aneg(struct phy_device *phydev)
{
/* Note: the NCN26000 supports only P2MP link mode. Therefore, AN is not
* supported. However, this function is invoked by phylib to enable the
* PHY, regardless of the AN support.
*/
phydev->mdix_ctrl = ETH_TP_MDI_AUTO;
phydev->mdix = ETH_TP_MDI;
// bring up the link
return phy_write(phydev, MII_BMCR, NCN26000_BCMR_LINK_CTRL_BIT);
}
static int ncn26000_read_status(struct phy_device *phydev)
{
/* The NCN26000 reports NCN26000_LINK_STATUS_BIT if the link status of
* the PHY is up. It further reports the logical AND of the link status
* and the PLCA status in the BMSR_LSTATUS bit.
*/
int ret;
/* The link state is latched low so that momentary link
* drops can be detected. Do not double-read the status
* in polling mode to detect such short link drops except
* the link was already down.
*/
if (!phy_polling_mode(phydev) || !phydev->link) {
ret = phy_read(phydev, MII_BMSR);
if (ret < 0)
return ret;
else if (ret & NCN26000_BMSR_LINK_STATUS_BIT)
goto upd_link;
}
ret = phy_read(phydev, MII_BMSR);
if (ret < 0)
return ret;
upd_link:
// update link status
if (ret & NCN26000_BMSR_LINK_STATUS_BIT) {
phydev->link = 1;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/bitfield.h`, `linux/errno.h`, `linux/init.h`, `linux/module.h`, `linux/mii.h`, `linux/phy.h`, `mdio-open-alliance.h`.
- Detected declarations: `function ncn26000_config_init`, `function ncn26000_config_aneg`, `function ncn26000_read_status`, `function ncn26000_handle_interrupt`, `function ncn26000_config_intr`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.