drivers/net/phy/bcm54140.c
Source file repositories/reference/linux-study-clean/drivers/net/phy/bcm54140.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/phy/bcm54140.c- Extension
.c- Size
- 23486 bytes
- Lines
- 896
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitfield.hlinux/brcmphy.hlinux/hwmon.hlinux/module.hlinux/phy.hphylib.hbcm-phy-lib.h
Detected Declarations
struct bcm54140_privenum bcm54140_global_phyfunction bcm54140_hwmon_is_visiblefunction bcm54140_hwmon_read_alarmfunction bcm54140_hwmon_read_tempfunction bcm54140_hwmon_read_infunction bcm54140_hwmon_readfunction bcm54140_hwmon_read_stringfunction bcm54140_hwmon_write_tempfunction bcm54140_hwmon_write_infunction bcm54140_hwmon_writefunction bcm54140_enable_monitoringfunction bcm54140_probe_oncefunction bcm54140_base_read_rdbfunction bcm54140_base_write_rdbfunction bcm54140_b0_workaroundfunction bcm54140_get_base_addr_and_portfunction bcm54140_probefunction bcm54140_config_initfunction bcm54140_handle_interruptfunction bcm54140_ack_intrfunction bcm54140_config_intrfunction bcm54140_get_downshiftfunction bcm54140_set_downshiftfunction bcm54140_get_edpdfunction bcm54140_set_edpdfunction bcm54140_get_tunablefunction bcm54140_set_tunable
Annotated Snippet
struct bcm54140_priv {
int port;
int base_addr;
#if IS_ENABLED(CONFIG_HWMON)
/* protect the alarm bits */
struct mutex alarm_lock;
u16 alarm;
#endif
};
#if IS_ENABLED(CONFIG_HWMON)
static umode_t bcm54140_hwmon_is_visible(const void *data,
enum hwmon_sensor_types type,
u32 attr, int channel)
{
switch (type) {
case hwmon_in:
switch (attr) {
case hwmon_in_min:
case hwmon_in_max:
return 0644;
case hwmon_in_label:
case hwmon_in_input:
case hwmon_in_alarm:
return 0444;
default:
return 0;
}
case hwmon_temp:
switch (attr) {
case hwmon_temp_min:
case hwmon_temp_max:
return 0644;
case hwmon_temp_input:
case hwmon_temp_alarm:
return 0444;
default:
return 0;
}
default:
return 0;
}
}
static int bcm54140_hwmon_read_alarm(struct device *dev, unsigned int bit,
long *val)
{
struct phy_device *phydev = dev_get_drvdata(dev);
struct bcm54140_priv *priv = phydev->priv;
int tmp, ret = 0;
mutex_lock(&priv->alarm_lock);
/* latch any alarm bits */
tmp = bcm_phy_read_rdb(phydev, BCM54140_RDB_MON_ISR);
if (tmp < 0) {
ret = tmp;
goto out;
}
priv->alarm |= tmp;
*val = !!(priv->alarm & bit);
priv->alarm &= ~bit;
out:
mutex_unlock(&priv->alarm_lock);
return ret;
}
static int bcm54140_hwmon_read_temp(struct device *dev, u32 attr, long *val)
{
struct phy_device *phydev = dev_get_drvdata(dev);
u16 reg;
int tmp;
switch (attr) {
case hwmon_temp_input:
reg = BCM54140_RDB_MON_TEMP_VAL;
break;
case hwmon_temp_min:
reg = BCM54140_RDB_MON_TEMP_MIN;
break;
case hwmon_temp_max:
reg = BCM54140_RDB_MON_TEMP_MAX;
break;
case hwmon_temp_alarm:
return bcm54140_hwmon_read_alarm(dev,
BCM54140_RDB_MON_ISR_TEMP,
val);
default:
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/brcmphy.h`, `linux/hwmon.h`, `linux/module.h`, `linux/phy.h`, `phylib.h`, `bcm-phy-lib.h`.
- Detected declarations: `struct bcm54140_priv`, `enum bcm54140_global_phy`, `function bcm54140_hwmon_is_visible`, `function bcm54140_hwmon_read_alarm`, `function bcm54140_hwmon_read_temp`, `function bcm54140_hwmon_read_in`, `function bcm54140_hwmon_read`, `function bcm54140_hwmon_read_string`, `function bcm54140_hwmon_write_temp`, `function bcm54140_hwmon_write_in`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- 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.