drivers/leds/leds-is31fl32xx.c
Source file repositories/reference/linux-study-clean/drivers/leds/leds-is31fl32xx.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/leds/leds-is31fl32xx.c- Extension
.c- Size
- 18018 bytes
- Lines
- 647
- 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/device.hlinux/i2c.hlinux/kernel.hlinux/leds.hlinux/module.hlinux/of.h
Detected Declarations
struct is31fl32xx_privstruct is31fl32xx_led_datastruct is31fl32xx_privstruct is31fl32xx_chipdeffunction is31fl32xx_writefunction is31fl3216_resetfunction is31fl3216_software_shutdownfunction is31fl3293_resetfunction is31fl3293_software_shutdownfunction is31fl32xx_brightness_setfunction is31fl32xx_reset_regsfunction is31fl32xx_software_shutdownfunction is31fl32xx_init_regsfunction is31fl32xx_parse_child_dtfunction is31fl32xx_parse_dtfunction for_each_available_child_of_node_scopedfunction is31fl32xx_probefunction is31fl32xx_remove
Annotated Snippet
struct is31fl32xx_led_data {
struct led_classdev cdev;
u8 channel; /* 1-based, max priv->cdef->channels */
u32 max_microamp;
struct is31fl32xx_priv *priv;
};
struct is31fl32xx_priv {
const struct is31fl32xx_chipdef *cdef;
struct i2c_client *client;
unsigned int num_leds;
struct is31fl32xx_led_data leds[];
};
/**
* struct is31fl32xx_chipdef - chip-specific attributes
* @channels : Number of LED channels
* @shutdown_reg : address of Shutdown register (optional)
* @pwm_update_reg : address of PWM Update register
* @pwm_update_value : value to write to PWM Update register
* @global_control_reg : address of Global Control register (optional)
* @reset_reg : address of Reset register (optional)
* @output_frequency_setting_reg: address of output frequency register (optional)
* @pwm_register_base : address of first PWM register
* @pwm_registers_reversed: : true if PWM registers count down instead of up
* @led_control_register_base : address of first LED control register (optional)
* @enable_bits_per_led_control_register: number of LEDs enable bits in each
* @brightness_steps : number of brightness steps supported by the chip
* @reset_func : pointer to reset function
* @sw_shutdown_func : pointer to software shutdown function
*
* For all optional register addresses, the sentinel value %IS31FL32XX_REG_NONE
* indicates that this chip has no such register.
*
* If non-NULL, @reset_func will be called during probing to set all
* necessary registers to a known initialization state. This is needed
* for chips that do not have a @reset_reg.
*
* @enable_bits_per_led_control_register must be >=1 if
* @led_control_register_base != %IS31FL32XX_REG_NONE.
*/
struct is31fl32xx_chipdef {
u8 channels;
u8 shutdown_reg;
u8 pwm_update_reg;
u8 pwm_update_value;
u8 global_control_reg;
u8 reset_reg;
u8 output_frequency_setting_reg;
u8 pwm_register_base;
bool pwm_registers_reversed;
u8 led_control_register_base;
u8 enable_bits_per_led_control_register;
u16 brightness_steps;
int (*reset_func)(struct is31fl32xx_priv *priv);
int (*sw_shutdown_func)(struct is31fl32xx_priv *priv, bool enable);
};
static int is31fl32xx_write(struct is31fl32xx_priv *priv, u8 reg, u8 val)
{
int ret;
dev_dbg(&priv->client->dev, "writing register 0x%02X=0x%02X", reg, val);
ret = i2c_smbus_write_byte_data(priv->client, reg, val);
if (ret) {
dev_err(&priv->client->dev,
"register write to 0x%02X failed (error %d)",
reg, ret);
}
return ret;
}
/*
* Custom reset function for IS31FL3216 because it does not have a RESET
* register the way that the other IS31FL32xx chips do. We don't bother
* writing the GPIO and animation registers, because the registers we
* do write ensure those will have no effect.
*/
static int is31fl3216_reset(struct is31fl32xx_priv *priv)
{
unsigned int i;
int ret;
ret = is31fl32xx_write(priv, IS31FL3216_CONFIG_REG,
IS31FL3216_CONFIG_SSD_ENABLE);
if (ret)
return ret;
for (i = 0; i < priv->cdef->channels; i++) {
ret = is31fl32xx_write(priv, priv->cdef->pwm_register_base+i,
Annotation
- Immediate include surface: `linux/device.h`, `linux/i2c.h`, `linux/kernel.h`, `linux/leds.h`, `linux/module.h`, `linux/of.h`.
- Detected declarations: `struct is31fl32xx_priv`, `struct is31fl32xx_led_data`, `struct is31fl32xx_priv`, `struct is31fl32xx_chipdef`, `function is31fl32xx_write`, `function is31fl3216_reset`, `function is31fl3216_software_shutdown`, `function is31fl3293_reset`, `function is31fl3293_software_shutdown`, `function is31fl32xx_brightness_set`.
- 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.