drivers/net/phy/rockchip.c
Source file repositories/reference/linux-study-clean/drivers/net/phy/rockchip.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/phy/rockchip.c- Extension
.c- Size
- 4529 bytes
- Lines
- 201
- 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/ethtool.hlinux/kernel.hlinux/module.hlinux/mii.hlinux/netdevice.hlinux/phy.h
Detected Declarations
function Copyrightfunction rockchip_close_tstmodefunction rockchip_integrated_phy_analog_initfunction rockchip_integrated_phy_config_initfunction rockchip_link_change_notifyfunction rockchip_set_polarityfunction rockchip_config_anegfunction rockchip_phy_resume
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0+
/*
* drivers/net/phy/rockchip.c
*
* Driver for ROCKCHIP Ethernet PHYs
*
* Copyright (c) 2017, Fuzhou Rockchip Electronics Co., Ltd
*
* David Wu <david.wu@rock-chips.com>
*/
#include <linux/ethtool.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/mii.h>
#include <linux/netdevice.h>
#include <linux/phy.h>
#define INTERNAL_EPHY_ID 0x1234d400
#define MII_INTERNAL_CTRL_STATUS 17
#define SMI_ADDR_TSTCNTL 20
#define SMI_ADDR_TSTREAD1 21
#define SMI_ADDR_TSTREAD2 22
#define SMI_ADDR_TSTWRITE 23
#define MII_SPECIAL_CONTROL_STATUS 31
#define MII_AUTO_MDIX_EN BIT(7)
#define MII_MDIX_EN BIT(6)
#define MII_SPEED_10 BIT(2)
#define MII_SPEED_100 BIT(3)
#define TSTCNTL_RD (BIT(15) | BIT(10))
#define TSTCNTL_WR (BIT(14) | BIT(10))
#define TSTMODE_ENABLE 0x400
#define TSTMODE_DISABLE 0x0
#define WR_ADDR_A7CFG 0x18
static int rockchip_init_tstmode(struct phy_device *phydev)
{
int ret;
/* Enable access to Analog and DSP register banks */
ret = phy_write(phydev, SMI_ADDR_TSTCNTL, TSTMODE_ENABLE);
if (ret)
return ret;
ret = phy_write(phydev, SMI_ADDR_TSTCNTL, TSTMODE_DISABLE);
if (ret)
return ret;
return phy_write(phydev, SMI_ADDR_TSTCNTL, TSTMODE_ENABLE);
}
static int rockchip_close_tstmode(struct phy_device *phydev)
{
/* Back to basic register bank */
return phy_write(phydev, SMI_ADDR_TSTCNTL, TSTMODE_DISABLE);
}
static int rockchip_integrated_phy_analog_init(struct phy_device *phydev)
{
int ret;
ret = rockchip_init_tstmode(phydev);
if (ret)
return ret;
/*
* Adjust tx amplitude to make sginal better,
* the default value is 0x8.
*/
ret = phy_write(phydev, SMI_ADDR_TSTWRITE, 0xB);
if (ret)
return ret;
ret = phy_write(phydev, SMI_ADDR_TSTCNTL, TSTCNTL_WR | WR_ADDR_A7CFG);
if (ret)
return ret;
return rockchip_close_tstmode(phydev);
}
static int rockchip_integrated_phy_config_init(struct phy_device *phydev)
{
int val, ret;
/*
Annotation
- Immediate include surface: `linux/ethtool.h`, `linux/kernel.h`, `linux/module.h`, `linux/mii.h`, `linux/netdevice.h`, `linux/phy.h`.
- Detected declarations: `function Copyright`, `function rockchip_close_tstmode`, `function rockchip_integrated_phy_analog_init`, `function rockchip_integrated_phy_config_init`, `function rockchip_link_change_notify`, `function rockchip_set_polarity`, `function rockchip_config_aneg`, `function rockchip_phy_resume`.
- 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.