drivers/hwmon/lm75.c
Source file repositories/reference/linux-study-clean/drivers/hwmon/lm75.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hwmon/lm75.c- Extension
.c- Size
- 30459 bytes
- Lines
- 1178
- 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.
- 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/module.hlinux/init.hlinux/interrupt.hlinux/slab.hlinux/jiffies.hlinux/i2c.hlinux/i3c/device.hlinux/hwmon.hlinux/err.hlinux/mod_devicetable.hlinux/property.hlinux/regmap.hlinux/util_macros.hlinux/regulator/consumer.hlm75.h
Detected Declarations
struct lm75_paramsstruct lm75_datastruct lm75_i3c_deviceenum lm75_typefunction lm75_reg_to_mcfunction lm75_write_configfunction lm75_alarm_handlerfunction lm75_read_stringfunction lm75_readfunction lm75_write_tempfunction lm75_update_intervalfunction lm75_write_chipfunction lm75_writefunction lm75_is_visiblefunction lm75_is_writeable_regfunction lm75_is_volatile_regfunction lm75_i2c_reg_readfunction lm75_i2c_reg_writefunction lm75_i3c_reg_readfunction lm75_i3c_reg_writefunction lm75_removefunction lm75_generic_probefunction lm75_i2c_probefunction lm75_i3c_probefunction lm75_detectfunction lm75_suspendfunction lm75_resume
Annotated Snippet
struct lm75_params {
bool config_reg_16bits;
u16 set_mask;
u16 clr_mask;
u8 default_resolution;
u8 resolution_limits;
const u8 *resolutions;
unsigned int default_sample_time;
u8 num_sample_times;
const unsigned int *sample_times;
bool alarm;
};
/* Addresses scanned */
static const unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c,
0x4d, 0x4e, 0x4f, I2C_CLIENT_END };
/* The LM75 registers */
#define LM75_REG_TEMP 0x00
#define LM75_REG_CONF 0x01
#define LM75_REG_HYST 0x02
#define LM75_REG_MAX 0x03
#define PCT2075_REG_IDLE 0x04
struct lm75_data {
const char *label;
struct regmap *regmap;
u16 orig_conf;
u8 resolution; /* In bits, 9 to 16 */
unsigned int sample_time; /* In ms */
enum lm75_type kind;
const struct lm75_params *params;
u8 reg_buf[1];
u8 val_buf[3];
};
/*-----------------------------------------------------------------------*/
static const u8 lm75_sample_set_masks[] = { 0 << 5, 1 << 5, 2 << 5, 3 << 5 };
#define LM75_ALERT_POLARITY_HIGH_8_BIT (BIT(2))
#define LM75_ALERT_POLARITY_HIGH_16_BIT (BIT(2) << 8)
#define LM75_SAMPLE_CLEAR_MASK (3 << 5)
/* The structure below stores the configuration values of the supported devices.
* In case of being supported multiple configurations, the default one must
* always be the first element of the array
*/
static const struct lm75_params device_params[] = {
[adt75] = {
.clr_mask = 1 << 5, /* not one-shot mode */
.default_resolution = 12,
.default_sample_time = MSEC_PER_SEC / 10,
},
[as6200] = {
.config_reg_16bits = true,
.set_mask = 0xC010, /* 8 sample/s, 4 CF */
.default_resolution = 12,
.default_sample_time = 125,
.num_sample_times = 4,
.sample_times = (unsigned int []){ 125, 250, 1000, 4000 },
.alarm = true,
},
[at30ts74] = {
.set_mask = 3 << 5, /* 12-bit mode*/
.default_resolution = 12,
.default_sample_time = 200,
.num_sample_times = 4,
.sample_times = (unsigned int []){ 25, 50, 100, 200 },
.resolutions = (u8 []) {9, 10, 11, 12 },
},
[ds1775] = {
.clr_mask = 3 << 5,
.set_mask = 2 << 5, /* 11-bit mode */
.default_resolution = 11,
.default_sample_time = 500,
.num_sample_times = 4,
.sample_times = (unsigned int []){ 125, 250, 500, 1000 },
.resolutions = (u8 []) {9, 10, 11, 12 },
},
[ds75] = {
.clr_mask = 3 << 5,
.set_mask = 2 << 5, /* 11-bit mode */
.default_resolution = 11,
.default_sample_time = 600,
.num_sample_times = 4,
.sample_times = (unsigned int []){ 150, 300, 600, 1200 },
.resolutions = (u8 []) {9, 10, 11, 12 },
},
[stds75] = {
Annotation
- Immediate include surface: `linux/module.h`, `linux/init.h`, `linux/interrupt.h`, `linux/slab.h`, `linux/jiffies.h`, `linux/i2c.h`, `linux/i3c/device.h`, `linux/hwmon.h`.
- Detected declarations: `struct lm75_params`, `struct lm75_data`, `struct lm75_i3c_device`, `enum lm75_type`, `function lm75_reg_to_mc`, `function lm75_write_config`, `function lm75_alarm_handler`, `function lm75_read_string`, `function lm75_read`, `function lm75_write_temp`.
- Atlas domain: Driver Families / drivers/hwmon.
- Implementation status: source implementation candidate.
- 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.