drivers/net/phy/nxp-cbtx.c
Source file repositories/reference/linux-study-clean/drivers/net/phy/nxp-cbtx.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/phy/nxp-cbtx.c- Extension
.c- Size
- 4911 bytes
- Lines
- 228
- 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/mii.hlinux/module.hlinux/phy.h
Detected Declarations
function cbtx_soft_resetfunction cbtx_config_initfunction cbtx_mdix_statusfunction cbtx_read_statusfunction cbtx_mdix_configfunction cbtx_config_anegfunction cbtx_ack_interruptsfunction cbtx_config_intrfunction cbtx_handle_interruptfunction cbtx_get_sset_countfunction cbtx_get_stringsfunction cbtx_get_stats
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/* Driver for 100BASE-TX PHY embedded into NXP SJA1110 switch
*
* Copyright 2022-2023 NXP
*/
#include <linux/kernel.h>
#include <linux/mii.h>
#include <linux/module.h>
#include <linux/phy.h>
#define PHY_ID_CBTX_SJA1110 0x001bb020
/* Registers */
#define CBTX_MODE_CTRL_STAT 0x11
#define CBTX_PDOWN_CTRL 0x18
#define CBTX_RX_ERR_COUNTER 0x1a
#define CBTX_IRQ_STAT 0x1d
#define CBTX_IRQ_ENABLE 0x1e
/* Fields */
#define CBTX_MODE_CTRL_STAT_AUTO_MDIX_EN BIT(7)
#define CBTX_MODE_CTRL_STAT_MDIX_MODE BIT(6)
#define CBTX_PDOWN_CTL_TRUE_PDOWN BIT(0)
#define CBTX_IRQ_ENERGYON BIT(7)
#define CBTX_IRQ_AN_COMPLETE BIT(6)
#define CBTX_IRQ_REM_FAULT BIT(5)
#define CBTX_IRQ_LINK_DOWN BIT(4)
#define CBTX_IRQ_AN_LP_ACK BIT(3)
#define CBTX_IRQ_PARALLEL_DETECT_FAULT BIT(2)
#define CBTX_IRQ_AN_PAGE_RECV BIT(1)
static int cbtx_soft_reset(struct phy_device *phydev)
{
int ret;
/* Can't soft reset unless we remove PHY from true power down mode */
ret = phy_clear_bits(phydev, CBTX_PDOWN_CTRL,
CBTX_PDOWN_CTL_TRUE_PDOWN);
if (ret)
return ret;
return genphy_soft_reset(phydev);
}
static int cbtx_config_init(struct phy_device *phydev)
{
/* Wait for cbtx_config_aneg() to kick in and apply this */
phydev->mdix_ctrl = ETH_TP_MDI_AUTO;
return 0;
}
static int cbtx_mdix_status(struct phy_device *phydev)
{
int ret;
ret = phy_read(phydev, CBTX_MODE_CTRL_STAT);
if (ret < 0)
return ret;
if (ret & CBTX_MODE_CTRL_STAT_MDIX_MODE)
phydev->mdix = ETH_TP_MDI_X;
else
phydev->mdix = ETH_TP_MDI;
return 0;
}
static int cbtx_read_status(struct phy_device *phydev)
{
int ret;
ret = cbtx_mdix_status(phydev);
if (ret)
return ret;
return genphy_read_status(phydev);
}
static int cbtx_mdix_config(struct phy_device *phydev)
{
int ret;
switch (phydev->mdix_ctrl) {
case ETH_TP_MDI_AUTO:
return phy_set_bits(phydev, CBTX_MODE_CTRL_STAT,
CBTX_MODE_CTRL_STAT_AUTO_MDIX_EN);
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/mii.h`, `linux/module.h`, `linux/phy.h`.
- Detected declarations: `function cbtx_soft_reset`, `function cbtx_config_init`, `function cbtx_mdix_status`, `function cbtx_read_status`, `function cbtx_mdix_config`, `function cbtx_config_aneg`, `function cbtx_ack_interrupts`, `function cbtx_config_intr`, `function cbtx_handle_interrupt`, `function cbtx_get_sset_count`.
- 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.