drivers/leds/leds-sc27xx-bltc.c
Source file repositories/reference/linux-study-clean/drivers/leds/leds-sc27xx-bltc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/leds/leds-sc27xx-bltc.c- Extension
.c- Size
- 9008 bytes
- Lines
- 356
- 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/leds.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/regmap.h
Detected Declarations
struct sc27xx_ledstruct sc27xx_led_privfunction sc27xx_led_initfunction sc27xx_led_get_offsetfunction sc27xx_led_enablefunction sc27xx_led_disablefunction sc27xx_led_setfunction sc27xx_led_clamp_align_delta_tfunction sc27xx_led_pattern_clearfunction sc27xx_led_pattern_setfunction sc27xx_led_registerfunction sc27xx_led_probefunction for_each_available_child_of_node_scopedfunction sc27xx_led_remove
Annotated Snippet
struct sc27xx_led {
struct fwnode_handle *fwnode;
struct led_classdev ldev;
struct sc27xx_led_priv *priv;
u8 line;
bool active;
};
struct sc27xx_led_priv {
struct sc27xx_led leds[SC27XX_LEDS_MAX];
struct regmap *regmap;
struct mutex lock;
u32 base;
};
#define to_sc27xx_led(ldev) \
container_of(ldev, struct sc27xx_led, ldev)
static int sc27xx_led_init(struct regmap *regmap)
{
int err;
err = regmap_update_bits(regmap, SC27XX_MODULE_EN0, SC27XX_BLTC_EN,
SC27XX_BLTC_EN);
if (err)
return err;
err = regmap_update_bits(regmap, SC27XX_CLK_EN0, SC27XX_RTC_EN,
SC27XX_RTC_EN);
if (err)
return err;
return regmap_update_bits(regmap, SC27XX_RGB_CTRL, SC27XX_RGB_PD, 0);
}
static u32 sc27xx_led_get_offset(struct sc27xx_led *leds)
{
return leds->priv->base + SC27XX_LEDS_OFFSET * leds->line;
}
static int sc27xx_led_enable(struct sc27xx_led *leds, enum led_brightness value)
{
u32 base = sc27xx_led_get_offset(leds);
u32 ctrl_base = leds->priv->base + SC27XX_LEDS_CTRL;
u8 ctrl_shift = SC27XX_CTRL_SHIFT * leds->line;
struct regmap *regmap = leds->priv->regmap;
int err;
err = regmap_update_bits(regmap, base + SC27XX_LEDS_DUTY,
SC27XX_DUTY_MASK,
(value << SC27XX_DUTY_SHIFT) |
SC27XX_MOD_MASK);
if (err)
return err;
return regmap_update_bits(regmap, ctrl_base,
(SC27XX_LED_RUN | SC27XX_LED_TYPE) << ctrl_shift,
(SC27XX_LED_RUN | SC27XX_LED_TYPE) << ctrl_shift);
}
static int sc27xx_led_disable(struct sc27xx_led *leds)
{
struct regmap *regmap = leds->priv->regmap;
u32 ctrl_base = leds->priv->base + SC27XX_LEDS_CTRL;
u8 ctrl_shift = SC27XX_CTRL_SHIFT * leds->line;
return regmap_update_bits(regmap, ctrl_base,
(SC27XX_LED_RUN | SC27XX_LED_TYPE) << ctrl_shift, 0);
}
static int sc27xx_led_set(struct led_classdev *ldev, enum led_brightness value)
{
struct sc27xx_led *leds = to_sc27xx_led(ldev);
int err;
mutex_lock(&leds->priv->lock);
if (value == LED_OFF)
err = sc27xx_led_disable(leds);
else
err = sc27xx_led_enable(leds, value);
mutex_unlock(&leds->priv->lock);
return err;
}
static void sc27xx_led_clamp_align_delta_t(u32 *delta_t)
{
u32 v, offset, t = *delta_t;
Annotation
- Immediate include surface: `linux/leds.h`, `linux/module.h`, `linux/of.h`, `linux/platform_device.h`, `linux/regmap.h`.
- Detected declarations: `struct sc27xx_led`, `struct sc27xx_led_priv`, `function sc27xx_led_init`, `function sc27xx_led_get_offset`, `function sc27xx_led_enable`, `function sc27xx_led_disable`, `function sc27xx_led_set`, `function sc27xx_led_clamp_align_delta_t`, `function sc27xx_led_pattern_clear`, `function sc27xx_led_pattern_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.