drivers/leds/rgb/leds-lp5812.c
Source file repositories/reference/linux-study-clean/drivers/leds/rgb/leds-lp5812.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/leds/rgb/leds-lp5812.c- Extension
.c- Size
- 16042 bytes
- Lines
- 643
- 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.
- 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/delay.hlinux/i2c.hlinux/init.hlinux/kernel.hlinux/led-class-multicolor.hlinux/leds.hlinux/module.hlinux/mutex.hlinux/sysfs.hlinux/types.hleds-lp5812.h
Detected Declarations
function lp5812_writefunction lp5812_readfunction lp5812_read_tsd_config_statusfunction lp5812_update_regs_configfunction parse_drive_modefunction lp5812_set_drive_mode_scan_orderfunction lp5812_set_led_modefunction lp5812_manual_dc_pwm_controlfunction lp5812_multicolor_brightnessfunction lp5812_led_brightnessfunction lp5812_set_brightnessfunction lp5812_set_mc_brightnessfunction lp5812_init_ledfunction lp5812_register_ledsfunction lp5812_init_devicefunction lp5812_deinit_devicefunction lp5812_parse_led_channelfunction lp5812_parse_ledfunction lp5812_of_probefunction for_each_available_child_of_node_scopedfunction lp5812_probefunction lp5812_remove
Annotated Snippet
switch (chip_mode_map[i].selection_led) {
case LP5812_MODE_MIX_SELECT_LED_0:
chip->drive_mode.bits.mix_sel_led_0 = true;
break;
case LP5812_MODE_MIX_SELECT_LED_1:
chip->drive_mode.bits.mix_sel_led_1 = true;
break;
case LP5812_MODE_MIX_SELECT_LED_2:
chip->drive_mode.bits.mix_sel_led_2 = true;
break;
case LP5812_MODE_MIX_SELECT_LED_3:
chip->drive_mode.bits.mix_sel_led_3 = true;
break;
default:
return -EINVAL;
}
return 0;
}
return -EINVAL;
}
static int lp5812_set_drive_mode_scan_order(struct lp5812_chip *chip)
{
u8 val;
int ret;
val = chip->drive_mode.val;
ret = lp5812_write(chip, LP5812_DEV_CONFIG1, val);
if (ret)
return ret;
val = chip->scan_order.val;
ret = lp5812_write(chip, LP5812_DEV_CONFIG2, val);
return ret;
}
static int lp5812_set_led_mode(struct lp5812_chip *chip, int led_number,
enum control_mode mode)
{
u8 reg_val;
u16 reg;
int ret;
/*
* Select device configuration register.
* Reg3 for LED_0–LED_3, LED_A0–A2, LED_B0
* Reg4 for LED_B1–B2, LED_C0–C2, LED_D0–D2
*/
if (led_number < LP5812_NUMBER_LED_IN_REG)
reg = LP5812_DEV_CONFIG3;
else
reg = LP5812_DEV_CONFIG4;
ret = lp5812_read(chip, reg, ®_val);
if (ret)
return ret;
if (mode == LP5812_MODE_MANUAL)
reg_val &= ~(LP5812_ENABLE << (led_number % LP5812_NUMBER_LED_IN_REG));
else
reg_val |= (LP5812_ENABLE << (led_number % LP5812_NUMBER_LED_IN_REG));
ret = lp5812_write(chip, reg, reg_val);
if (ret)
return ret;
ret = lp5812_update_regs_config(chip);
return ret;
}
static int lp5812_manual_dc_pwm_control(struct lp5812_chip *chip, int led_number,
u8 val, enum dimming_type dimming_type)
{
u16 led_base_reg;
int ret;
if (dimming_type == LP5812_DIMMING_ANALOG)
led_base_reg = LP5812_MANUAL_DC_BASE;
else
led_base_reg = LP5812_MANUAL_PWM_BASE;
ret = lp5812_write(chip, led_base_reg + led_number, val);
return ret;
}
Annotation
- Immediate include surface: `linux/delay.h`, `linux/i2c.h`, `linux/init.h`, `linux/kernel.h`, `linux/led-class-multicolor.h`, `linux/leds.h`, `linux/module.h`, `linux/mutex.h`.
- Detected declarations: `function lp5812_write`, `function lp5812_read`, `function lp5812_read_tsd_config_status`, `function lp5812_update_regs_config`, `function parse_drive_mode`, `function lp5812_set_drive_mode_scan_order`, `function lp5812_set_led_mode`, `function lp5812_manual_dc_pwm_control`, `function lp5812_multicolor_brightness`, `function lp5812_led_brightness`.
- Atlas domain: Driver Families / drivers/leds.
- Implementation status: source implementation candidate.
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.