drivers/leds/leds-tca6507.c
Source file repositories/reference/linux-study-clean/drivers/leds/leds-tca6507.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/leds/leds-tca6507.c- Extension
.c- Size
- 20405 bytes
- Lines
- 791
- 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/module.hlinux/slab.hlinux/leds.hlinux/err.hlinux/i2c.hlinux/gpio/driver.hlinux/property.hlinux/workqueue.h
Detected Declarations
struct tca6507_platform_datastruct tca6507_chipstruct bankstruct tca6507_ledfunction TO_LEVELfunction TO_BRIGHTfunction choose_timesfunction set_selectfunction set_codefunction set_levelfunction set_timesfunction tca6507_workfunction led_releasefunction led_preparefunction led_assignfunction tca6507_brightness_setfunction tca6507_blink_setfunction tca6507_gpio_set_valuefunction tca6507_gpio_direction_outputfunction tca6507_probe_gpiosfunction tca6507_probe_gpiosfunction tca6507_led_dt_initfunction device_for_each_child_node_scopedfunction tca6507_probefunction tca6507_remove
Annotated Snippet
struct tca6507_platform_data {
struct led_platform_data leds;
};
#define TCA6507_MAKE_GPIO 1
enum {
BANK0,
BANK1,
MASTER,
};
static int bank_source[3] = {
TCA6507_LS_LED_PWM0,
TCA6507_LS_LED_PWM1,
TCA6507_LS_LED_MIR,
};
static int blink_source[2] = {
TCA6507_LS_BLINK0,
TCA6507_LS_BLINK1,
};
/* PWM registers */
#define TCA6507_REG_CNT 11
/*
* 0x00, 0x01, 0x02 encode the TCA6507_LS_* values, each output
* owns one bit in each register
*/
#define TCA6507_FADE_ON 0x03
#define TCA6507_FULL_ON 0x04
#define TCA6507_FADE_OFF 0x05
#define TCA6507_FIRST_OFF 0x06
#define TCA6507_SECOND_OFF 0x07
#define TCA6507_MAX_INTENSITY 0x08
#define TCA6507_MASTER_INTENSITY 0x09
#define TCA6507_INITIALIZE 0x0A
#define INIT_CODE 0x8
#define TIMECODES 16
static int time_codes[TIMECODES] = {
0, 64, 128, 192, 256, 384, 512, 768,
1024, 1536, 2048, 3072, 4096, 5760, 8128, 16320
};
/* Convert an led.brightness level (0..255) to a TCA6507 level (0..15) */
static inline int TO_LEVEL(int brightness)
{
return brightness >> 4;
}
/* ...and convert back */
static inline int TO_BRIGHT(int level)
{
if (level)
return (level << 4) | 0xf;
return 0;
}
#define NUM_LEDS 7
struct tca6507_chip {
int reg_set; /* One bit per register where
* a '1' means the register
* should be written */
u8 reg_file[TCA6507_REG_CNT];
/* Bank 2 is Master Intensity and doesn't use times */
struct bank {
int level;
int ontime, offtime;
int on_dflt, off_dflt;
int time_use, level_use;
} bank[3];
struct i2c_client *client;
struct work_struct work;
spinlock_t lock;
struct tca6507_led {
struct tca6507_chip *chip;
struct led_classdev led_cdev;
int num;
int ontime, offtime;
int on_dflt, off_dflt;
int bank; /* Bank used, or -1 */
int blink; /* Set if hardware-blinking */
} leds[NUM_LEDS];
#ifdef CONFIG_GPIOLIB
struct gpio_chip gpio;
int gpio_map[NUM_LEDS];
#endif
};
Annotation
- Immediate include surface: `linux/module.h`, `linux/slab.h`, `linux/leds.h`, `linux/err.h`, `linux/i2c.h`, `linux/gpio/driver.h`, `linux/property.h`, `linux/workqueue.h`.
- Detected declarations: `struct tca6507_platform_data`, `struct tca6507_chip`, `struct bank`, `struct tca6507_led`, `function TO_LEVEL`, `function TO_BRIGHT`, `function choose_times`, `function set_select`, `function set_code`, `function set_level`.
- 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.