drivers/hwmon/aspeed-pwm-tacho.c
Source file repositories/reference/linux-study-clean/drivers/hwmon/aspeed-pwm-tacho.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hwmon/aspeed-pwm-tacho.c- Extension
.c- Size
- 29764 bytes
- Lines
- 990
- Domain
- Driver Families
- Bucket
- drivers/hwmon
- 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.
- 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/clk.hlinux/delay.hlinux/errno.hlinux/gpio/consumer.hlinux/hwmon.hlinux/hwmon-sysfs.hlinux/io.hlinux/kernel.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/regmap.hlinux/reset.hlinux/sysfs.hlinux/thermal.h
Detected Declarations
struct aspeed_cooling_devicestruct aspeed_pwm_tacho_datastruct type_paramsstruct pwm_port_paramsenum typeenum pwm_portfunction regmap_aspeed_pwm_tacho_reg_writefunction regmap_aspeed_pwm_tacho_reg_readfunction aspeed_set_clock_enablefunction aspeed_set_clock_sourcefunction aspeed_set_pwm_clock_valuesfunction aspeed_set_pwm_port_enablefunction aspeed_set_pwm_port_typefunction aspeed_set_pwm_port_duty_rising_fallingfunction aspeed_set_tacho_type_enablefunction aspeed_set_tacho_type_valuesfunction aspeed_set_fan_tach_ch_enablefunction aspeed_set_fan_tach_ch_sourcefunction aspeed_set_pwm_port_fan_ctrlfunction aspeed_get_fan_tach_ch_measure_periodfunction aspeed_get_fan_tach_ch_rpmfunction pwm_storefunction pwm_showfunction rpm_showfunction pwm_is_visiblefunction fan_dev_is_visiblefunction aspeed_create_typefunction aspeed_create_pwm_portfunction aspeed_create_fan_tach_channelfunction aspeed_pwm_cz_get_max_statefunction aspeed_pwm_cz_get_cur_statefunction aspeed_pwm_cz_set_cur_statefunction aspeed_create_pwm_coolingfunction aspeed_create_fanfunction aspeed_pwm_tacho_removefunction aspeed_pwm_tacho_probefunction for_each_child_of_node_scoped
Annotated Snippet
struct aspeed_cooling_device {
char name[16];
struct aspeed_pwm_tacho_data *priv;
struct thermal_cooling_device *tcdev;
int pwm_port;
u8 *cooling_levels;
u8 max_state;
u8 cur_state;
};
struct aspeed_pwm_tacho_data {
struct regmap *regmap;
struct reset_control *rst;
unsigned long clk_freq;
bool pwm_present[8];
bool fan_tach_present[MAX_ASPEED_FAN_TACH_CHANNELS];
u8 type_pwm_clock_unit[3];
u8 type_pwm_clock_division_h[3];
u8 type_pwm_clock_division_l[3];
u8 type_fan_tach_clock_division[3];
u8 type_fan_tach_mode[3];
u16 type_fan_tach_unit[3];
u8 pwm_port_type[8];
u8 pwm_port_fan_ctrl[8];
u8 fan_tach_ch_source[MAX_ASPEED_FAN_TACH_CHANNELS];
struct aspeed_cooling_device *cdev[8];
const struct attribute_group *groups[3];
/* protects access to shared ASPEED_PTCR_RESULT */
struct mutex tach_lock;
};
enum type { TYPEM, TYPEN, TYPEO };
struct type_params {
u32 l_value;
u32 h_value;
u32 unit_value;
u32 clk_ctrl_mask;
u32 clk_ctrl_reg;
u32 ctrl_reg;
u32 ctrl_reg1;
};
static const struct type_params type_params[] = {
[TYPEM] = {
.l_value = ASPEED_PTCR_CLK_CTRL_TYPEM_L,
.h_value = ASPEED_PTCR_CLK_CTRL_TYPEM_H,
.unit_value = ASPEED_PTCR_CLK_CTRL_TYPEM_UNIT,
.clk_ctrl_mask = ASPEED_PTCR_CLK_CTRL_TYPEM_MASK,
.clk_ctrl_reg = ASPEED_PTCR_CLK_CTRL,
.ctrl_reg = ASPEED_PTCR_TYPEM_CTRL,
.ctrl_reg1 = ASPEED_PTCR_TYPEM_CTRL1,
},
[TYPEN] = {
.l_value = ASPEED_PTCR_CLK_CTRL_TYPEN_L,
.h_value = ASPEED_PTCR_CLK_CTRL_TYPEN_H,
.unit_value = ASPEED_PTCR_CLK_CTRL_TYPEN_UNIT,
.clk_ctrl_mask = ASPEED_PTCR_CLK_CTRL_TYPEN_MASK,
.clk_ctrl_reg = ASPEED_PTCR_CLK_CTRL,
.ctrl_reg = ASPEED_PTCR_TYPEN_CTRL,
.ctrl_reg1 = ASPEED_PTCR_TYPEN_CTRL1,
},
[TYPEO] = {
.l_value = ASPEED_PTCR_CLK_CTRL_TYPEO_L,
.h_value = ASPEED_PTCR_CLK_CTRL_TYPEO_H,
.unit_value = ASPEED_PTCR_CLK_CTRL_TYPEO_UNIT,
.clk_ctrl_mask = ASPEED_PTCR_CLK_CTRL_TYPEO_MASK,
.clk_ctrl_reg = ASPEED_PTCR_CLK_CTRL_EXT,
.ctrl_reg = ASPEED_PTCR_TYPEO_CTRL,
.ctrl_reg1 = ASPEED_PTCR_TYPEO_CTRL1,
}
};
enum pwm_port { PWMA, PWMB, PWMC, PWMD, PWME, PWMF, PWMG, PWMH };
struct pwm_port_params {
u32 pwm_en;
u32 ctrl_reg;
u32 type_part1;
u32 type_part2;
u32 type_mask;
u32 duty_ctrl_rise_point;
u32 duty_ctrl_fall_point;
u32 duty_ctrl_reg;
u32 duty_ctrl_rise_fall_mask;
};
static const struct pwm_port_params pwm_port_params[] = {
[PWMA] = {
.pwm_en = ASPEED_PTCR_CTRL_PWMA_EN,
Annotation
- Immediate include surface: `linux/clk.h`, `linux/delay.h`, `linux/errno.h`, `linux/gpio/consumer.h`, `linux/hwmon.h`, `linux/hwmon-sysfs.h`, `linux/io.h`, `linux/kernel.h`.
- Detected declarations: `struct aspeed_cooling_device`, `struct aspeed_pwm_tacho_data`, `struct type_params`, `struct pwm_port_params`, `enum type`, `enum pwm_port`, `function regmap_aspeed_pwm_tacho_reg_write`, `function regmap_aspeed_pwm_tacho_reg_read`, `function aspeed_set_clock_enable`, `function aspeed_set_clock_source`.
- Atlas domain: Driver Families / drivers/hwmon.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.