drivers/hwmon/tc654.c
Source file repositories/reference/linux-study-clean/drivers/hwmon/tc654.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hwmon/tc654.c- Extension
.c- Size
- 14948 bytes
- Lines
- 574
- 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/bitops.hlinux/err.hlinux/hwmon.hlinux/hwmon-sysfs.hlinux/i2c.hlinux/init.hlinux/jiffies.hlinux/module.hlinux/mutex.hlinux/slab.hlinux/thermal.hlinux/util_macros.h
Detected Declarations
struct tc654_dataenum tc654_regsfunction fan_showfunction fan_min_showfunction fan_min_storefunction fan_alarm_showfunction fan_pulses_showfunction fan_pulses_storefunction pwm_mode_showfunction pwm_mode_storefunction pwm_showfunction _set_pwmfunction pwm_storefunction tc654_get_max_statefunction tc654_get_cur_statefunction tc654_set_cur_statefunction tc654_probe
Annotated Snippet
struct tc654_data {
struct i2c_client *client;
/* update mutex */
struct mutex update_lock;
/* tc654 register cache */
bool valid;
unsigned long last_updated; /* in jiffies */
u8 rpm_output[2]; /* The fan RPM data for fans 1 and 2 is then
* written to registers RPM1 and RPM2
*/
u8 fan_fault[2]; /* The Fan Fault Threshold Registers are used to
* set the fan fault threshold levels for fan 1
* and fan 2
*/
u8 config; /* The Configuration Register is an 8-bit read/
* writable multi-function control register
* 7: Fan Fault Clear
* 1 = Clear Fan Fault
* 0 = Normal Operation (default)
* 6: Resolution Selection for RPM Output Registers
* RPM Output Registers (RPM1 and RPM2) will be
* set for
* 1 = 25 RPM (9-bit) resolution
* 0 = 50 RPM (8-bit) resolution (default)
* 5: Duty Cycle Control Method
* The V OUT duty cycle will be controlled via
* 1 = the SMBus interface.
* 0 = via the V IN analog input pin. (default)
* 4,3: Fan 2 Pulses Per Rotation
* 00 = 1
* 01 = 2 (default)
* 10 = 4
* 11 = 8
* 2,1: Fan 1 Pulses Per Rotation
* 00 = 1
* 01 = 2 (default)
* 10 = 4
* 11 = 8
* 0: Shutdown Mode
* 1 = Shutdown mode.
* 0 = Normal operation. (default)
*/
u8 status; /* The Status register provides all the information
* about what is going on within the TC654/TC655
* devices.
* 7,6: Unimplemented, Read as '0'
* 5: Over-Temperature Fault Condition
* 1 = Over-Temperature condition has occurred
* 0 = Normal operation. V IN is less than 2.6V
* 4: RPM2 Counter Overflow
* 1 = Fault condition
* 0 = Normal operation
* 3: RPM1 Counter Overflow
* 1 = Fault condition
* 0 = Normal operation
* 2: V IN Input Status
* 1 = V IN is open
* 0 = Normal operation. voltage present at V IN
* 1: Fan 2 Fault
* 1 = Fault condition
* 0 = Normal operation
* 0: Fan 1 Fault
* 1 = Fault condition
* 0 = Normal operation
*/
u8 duty_cycle; /* The DUTY_CYCLE register is a 4-bit read/
* writable register used to control the duty
* cycle of the V OUT output.
*/
};
/* helper to grab and cache data, at most one time per second */
static struct tc654_data *tc654_update_client(struct device *dev)
{
struct tc654_data *data = dev_get_drvdata(dev);
struct i2c_client *client = data->client;
int ret = 0;
mutex_lock(&data->update_lock);
if (time_before(jiffies, data->last_updated + TC654_UPDATE_INTERVAL) &&
likely(data->valid))
goto out;
ret = i2c_smbus_read_byte_data(client, TC654_REG_RPM(0));
if (ret < 0)
goto out;
data->rpm_output[0] = ret;
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/err.h`, `linux/hwmon.h`, `linux/hwmon-sysfs.h`, `linux/i2c.h`, `linux/init.h`, `linux/jiffies.h`, `linux/module.h`.
- Detected declarations: `struct tc654_data`, `enum tc654_regs`, `function fan_show`, `function fan_min_show`, `function fan_min_store`, `function fan_alarm_show`, `function fan_pulses_show`, `function fan_pulses_store`, `function pwm_mode_show`, `function pwm_mode_store`.
- 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.