drivers/leds/leds-lm3532.c
Source file repositories/reference/linux-study-clean/drivers/leds/leds-lm3532.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/leds/leds-lm3532.c- Extension
.c- Size
- 18847 bytes
- Lines
- 743
- Domain
- Driver Families
- Bucket
- drivers/leds
- 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/i2c.hlinux/leds.hlinux/slab.hlinux/regmap.hlinux/types.hlinux/regulator/consumer.hlinux/module.huapi/linux/uleds.hlinux/gpio/consumer.h
Detected Declarations
struct lm3532_als_datastruct lm3532_ledstruct lm3532_datafunction lm3532_get_als_imp_indexfunction lm3532_get_indexfunction lm3532_get_als_avg_indexfunction lm3532_get_ramp_indexfunction lm3532_led_enablefunction lm3532_led_disablefunction lm3532_brightness_setfunction lm3532_init_registersfunction lm3532_als_configurefunction lm3532_parse_alsfunction gpio_set_low_actionfunction lm3532_parse_nodefunction device_for_each_child_node_scopedfunction lm3532_probe
Annotated Snippet
struct lm3532_als_data {
u8 config;
u8 als1_imp_sel;
u8 als2_imp_sel;
u8 als_avrg_time;
u8 als_input_mode;
u32 als_vmin;
u32 als_vmax;
u8 zones_lo[LM3532_ALS_ZB_MAX];
u8 zones_hi[LM3532_ALS_ZB_MAX];
};
/**
* struct lm3532_led
* @led_dev: led class device
* @priv: Pointer the device data structure
* @control_bank: Control bank the LED is associated to
* @mode: Mode of the LED string
* @ctrl_brt_pointer: Zone target register that controls the sink
* @num_leds: Number of LED strings are supported in this array
* @full_scale_current: The full-scale current setting for the current sink.
* @led_strings: The LED strings supported in this array
* @enabled: Enabled status
*/
struct lm3532_led {
struct led_classdev led_dev;
struct lm3532_data *priv;
int control_bank;
int mode;
int ctrl_brt_pointer;
int num_leds;
int full_scale_current;
unsigned int enabled:1;
u32 led_strings[LM3532_MAX_CONTROL_BANKS];
};
/**
* struct lm3532_data
* @enable_gpio: Hardware enable gpio
* @regulator: regulator
* @client: i2c client
* @regmap: Devices register map
* @dev: Pointer to the devices device struct
* @lock: Lock for reading/writing the device
* @als_data: Pointer to the als data struct
* @runtime_ramp_up: Runtime ramp up setting
* @runtime_ramp_down: Runtime ramp down setting
* @leds: Array of LED strings
*/
struct lm3532_data {
struct gpio_desc *enable_gpio;
struct regulator *regulator;
struct i2c_client *client;
struct regmap *regmap;
struct device *dev;
struct mutex lock;
struct lm3532_als_data *als_data;
u32 runtime_ramp_up;
u32 runtime_ramp_down;
struct lm3532_led leds[];
};
static const struct reg_default lm3532_reg_defs[] = {
{LM3532_REG_OUTPUT_CFG, 0xe4},
{LM3532_REG_STARTSHUT_RAMP, 0xc0},
{LM3532_REG_RT_RAMP, 0xc0},
{LM3532_REG_PWM_A_CFG, 0x82},
{LM3532_REG_PWM_B_CFG, 0x82},
{LM3532_REG_PWM_C_CFG, 0x82},
{LM3532_REG_ZONE_CFG_A, 0xf1},
{LM3532_REG_CTRL_A_FS_CURR, 0xf3},
{LM3532_REG_ZONE_CFG_B, 0xf1},
{LM3532_REG_CTRL_B_FS_CURR, 0xf3},
{LM3532_REG_ZONE_CFG_C, 0xf1},
{LM3532_REG_CTRL_C_FS_CURR, 0xf3},
{LM3532_REG_ENABLE, 0xf8},
{LM3532_ALS_CONFIG, 0x44},
{LM3532_REG_ZN_0_HI, 0x35},
{LM3532_REG_ZN_0_LO, 0x33},
{LM3532_REG_ZN_1_HI, 0x6a},
{LM3532_REG_ZN_1_LO, 0x66},
{LM3532_REG_ZN_2_HI, 0xa1},
{LM3532_REG_ZN_2_LO, 0x99},
{LM3532_REG_ZN_3_HI, 0xdc},
{LM3532_REG_ZN_3_LO, 0xcc},
};
Annotation
- Immediate include surface: `linux/i2c.h`, `linux/leds.h`, `linux/slab.h`, `linux/regmap.h`, `linux/types.h`, `linux/regulator/consumer.h`, `linux/module.h`, `uapi/linux/uleds.h`.
- Detected declarations: `struct lm3532_als_data`, `struct lm3532_led`, `struct lm3532_data`, `function lm3532_get_als_imp_index`, `function lm3532_get_index`, `function lm3532_get_als_avg_index`, `function lm3532_get_ramp_index`, `function lm3532_led_enable`, `function lm3532_led_disable`, `function lm3532_brightness_set`.
- Atlas domain: Driver Families / drivers/leds.
- 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.