drivers/net/phy/air_phy_lib.c
Source file repositories/reference/linux-study-clean/drivers/net/phy/air_phy_lib.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/phy/air_phy_lib.c- Extension
.c- Size
- 5112 bytes
- Lines
- 212
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/export.hlinux/module.hlinux/phy.hlinux/wordpart.hair_phy_lib.h
Detected Declarations
function Copyrightfunction __air_buckpbus_reg_writefunction __air_buckpbus_reg_modifyfunction air_phy_buckpbus_reg_readfunction air_phy_buckpbus_reg_writefunction air_phy_buckpbus_reg_modifyfunction air_phy_read_pagefunction air_phy_write_pageexport air_phy_buckpbus_reg_readexport air_phy_buckpbus_reg_writeexport air_phy_buckpbus_reg_modifyexport air_phy_read_pageexport air_phy_write_page
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0+
/*
* Airoha Ethernet PHY common library
*
* Copyright (C) 2026 Airoha Technology Corp.
* Copyright (C) 2026 Collabora Ltd.
* Louis-Alexis Eyraud <louisalexis.eyraud@collabora.com>
*/
#include <linux/export.h>
#include <linux/module.h>
#include <linux/phy.h>
#include <linux/wordpart.h>
#include "air_phy_lib.h"
static int __air_buckpbus_reg_read(struct phy_device *phydev,
u32 pbus_address, u32 *pbus_data)
{
int pbus_data_low, pbus_data_high;
int ret;
ret = __phy_write(phydev, AIR_BPBUS_MODE, AIR_BPBUS_MODE_ADDR_FIXED);
if (ret < 0)
return ret;
ret = __phy_write(phydev, AIR_BPBUS_RD_ADDR_HIGH,
upper_16_bits(pbus_address));
if (ret < 0)
return ret;
ret = __phy_write(phydev, AIR_BPBUS_RD_ADDR_LOW,
lower_16_bits(pbus_address));
if (ret < 0)
return ret;
pbus_data_high = __phy_read(phydev, AIR_BPBUS_RD_DATA_HIGH);
if (pbus_data_high < 0)
return pbus_data_high;
pbus_data_low = __phy_read(phydev, AIR_BPBUS_RD_DATA_LOW);
if (pbus_data_low < 0)
return pbus_data_low;
*pbus_data = pbus_data_low | (pbus_data_high << 16);
return 0;
}
static int __air_buckpbus_reg_write(struct phy_device *phydev,
u32 pbus_address, u32 pbus_data)
{
int ret;
ret = __phy_write(phydev, AIR_BPBUS_MODE, AIR_BPBUS_MODE_ADDR_FIXED);
if (ret < 0)
return ret;
ret = __phy_write(phydev, AIR_BPBUS_WR_ADDR_HIGH,
upper_16_bits(pbus_address));
if (ret < 0)
return ret;
ret = __phy_write(phydev, AIR_BPBUS_WR_ADDR_LOW,
lower_16_bits(pbus_address));
if (ret < 0)
return ret;
ret = __phy_write(phydev, AIR_BPBUS_WR_DATA_HIGH,
upper_16_bits(pbus_data));
if (ret < 0)
return ret;
ret = __phy_write(phydev, AIR_BPBUS_WR_DATA_LOW,
lower_16_bits(pbus_data));
if (ret < 0)
return ret;
return 0;
}
static int __air_buckpbus_reg_modify(struct phy_device *phydev,
u32 pbus_address, u32 mask, u32 set)
{
int pbus_data_low, pbus_data_high;
u32 pbus_data_old, pbus_data_new;
int ret;
ret = __phy_write(phydev, AIR_BPBUS_MODE, AIR_BPBUS_MODE_ADDR_FIXED);
if (ret < 0)
return ret;
Annotation
- Immediate include surface: `linux/export.h`, `linux/module.h`, `linux/phy.h`, `linux/wordpart.h`, `air_phy_lib.h`.
- Detected declarations: `function Copyright`, `function __air_buckpbus_reg_write`, `function __air_buckpbus_reg_modify`, `function air_phy_buckpbus_reg_read`, `function air_phy_buckpbus_reg_write`, `function air_phy_buckpbus_reg_modify`, `function air_phy_read_page`, `function air_phy_write_page`, `export air_phy_buckpbus_reg_read`, `export air_phy_buckpbus_reg_write`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: integration 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.