drivers/leds/leds-mt6323.c
Source file repositories/reference/linux-study-clean/drivers/leds/leds-mt6323.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/leds/leds-mt6323.c- Extension
.c- Size
- 18752 bytes
- Lines
- 728
- 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/kernel.hlinux/leds.hlinux/mfd/mt6323/registers.hlinux/mfd/mt6397/core.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/regmap.h
Detected Declarations
struct mt6323_ledsstruct mt6323_ledstruct mt6323_regsstruct mt6323_hwspecstruct mt6323_datastruct mt6323_ledsfunction mt6323_led_hw_brightnessfunction mt6323_led_hw_offfunction mt6323_get_led_hw_brightnessfunction mt6323_led_hw_onfunction mt6323_led_set_blinkfunction mt6323_led_set_brightnessfunction mtk_wled_hw_onfunction mtk_wled_hw_offfunction mt6323_get_wled_brightnessfunction mt6323_wled_set_brightnessfunction mt6323_led_set_dt_defaultfunction mt6323_led_probefunction for_each_available_child_of_node_scopedfunction mt6323_led_remove
Annotated Snippet
struct mt6323_led {
int id;
struct mt6323_leds *parent;
struct led_classdev cdev;
enum led_brightness current_brightness;
};
/**
* struct mt6323_regs - register spec for the LED device
* @top_ckpdn: Offset to ISINK_CKPDN[0..x] registers
* @num_top_ckpdn: Number of ISINK_CKPDN registers
* @top_ckcon: Offset to ISINK_CKCON[0..x] registers
* @num_top_ckcon: Number of ISINK_CKCON registers
* @isink_con: Offset to ISINKx_CON[0..x] registers
* @num_isink_con: Number of ISINKx_CON registers
* @isink_max_regs: Number of ISINK[0..x] registers
* @isink_en_ctrl: Offset to ISINK_EN_CTRL register
* @iwled_en_ctrl: Offset to IWLED_EN_CTRL register
*/
struct mt6323_regs {
const u16 *top_ckpdn;
u8 num_top_ckpdn;
const u16 *top_ckcon;
u8 num_top_ckcon;
const u16 *isink_con;
u8 num_isink_con;
u8 isink_max_regs;
u16 isink_en_ctrl;
u16 iwled_en_ctrl;
};
/**
* struct mt6323_hwspec - hardware specific parameters
* @max_period: Maximum period for all LEDs
* @max_leds: Maximum number of supported LEDs
* @max_wleds: Maximum number of WLEDs
* @max_brightness: Maximum brightness for all LEDs
* @unit_duty: Steps of duty per period
*/
struct mt6323_hwspec {
u16 max_period;
u8 max_leds;
u8 max_wleds;
u16 max_brightness;
u16 unit_duty;
};
/**
* struct mt6323_data - device specific data
* @regs: Register spec for this device
* @spec: Hardware specific parameters
*/
struct mt6323_data {
const struct mt6323_regs *regs;
const struct mt6323_hwspec *spec;
};
/**
* struct mt6323_leds - state container for holding LED controller
* of the driver
* @dev: the device pointer
* @hw: the underlying hardware providing shared
* bus for the register operations
* @pdata: device specific data
* @lock: the lock among process context
* @led: the array that contains the state of individual
* LED device
*/
struct mt6323_leds {
struct device *dev;
struct mt6397_chip *hw;
const struct mt6323_data *pdata;
/* protect among process context */
struct mutex lock;
struct mt6323_led *led[MAX_SUPPORTED_LEDS];
};
static int mt6323_led_hw_brightness(struct led_classdev *cdev,
enum led_brightness brightness)
{
struct mt6323_led *led = container_of(cdev, struct mt6323_led, cdev);
struct mt6323_leds *leds = led->parent;
const struct mt6323_regs *regs = leds->pdata->regs;
struct regmap *regmap = leds->hw->regmap;
u32 con2_mask = 0, con2_val = 0;
int ret;
/*
* Setup current output for the corresponding
* brightness level.
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/leds.h`, `linux/mfd/mt6323/registers.h`, `linux/mfd/mt6397/core.h`, `linux/module.h`, `linux/of.h`, `linux/platform_device.h`, `linux/regmap.h`.
- Detected declarations: `struct mt6323_leds`, `struct mt6323_led`, `struct mt6323_regs`, `struct mt6323_hwspec`, `struct mt6323_data`, `struct mt6323_leds`, `function mt6323_led_hw_brightness`, `function mt6323_led_hw_off`, `function mt6323_get_led_hw_brightness`, `function mt6323_led_hw_on`.
- 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.