drivers/leds/leds-ti-lmu-common.c
Source file repositories/reference/linux-study-clean/drivers/leds/leds-ti-lmu-common.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/leds/leds-ti-lmu-common.c- Extension
.c- Size
- 3859 bytes
- Lines
- 154
- Domain
- Driver Families
- Bucket
- drivers/leds
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitops.hlinux/err.hlinux/property.hlinux/leds-ti-lmu-common.h
Detected Declarations
function ti_lmu_common_update_brightnessfunction ti_lmu_common_set_brightnessfunction ti_lmu_common_convert_ramp_to_indexfunction ti_lmu_common_set_rampfunction ti_lmu_common_get_ramp_paramsfunction ti_lmu_common_get_brt_resexport ti_lmu_common_set_brightnessexport ti_lmu_common_set_rampexport ti_lmu_common_get_ramp_paramsexport ti_lmu_common_get_brt_res
Annotated Snippet
if (usec > ramp_table[i - 1] && usec < ramp_table[i]) {
if (usec - ramp_table[i - 1] < ramp_table[i] - usec)
return i - 1;
else
return i;
}
}
return 0;
}
int ti_lmu_common_set_ramp(struct ti_lmu_bank *lmu_bank)
{
struct regmap *regmap = lmu_bank->regmap;
u8 ramp, ramp_up, ramp_down;
if (lmu_bank->ramp_up_usec == 0 && lmu_bank->ramp_down_usec == 0) {
ramp_up = 0;
ramp_down = 0;
} else {
ramp_up = ti_lmu_common_convert_ramp_to_index(lmu_bank->ramp_up_usec);
ramp_down = ti_lmu_common_convert_ramp_to_index(lmu_bank->ramp_down_usec);
}
ramp = (ramp_up << 4) | ramp_down;
return regmap_write(regmap, lmu_bank->runtime_ramp_reg, ramp);
}
EXPORT_SYMBOL(ti_lmu_common_set_ramp);
int ti_lmu_common_get_ramp_params(struct device *dev,
struct fwnode_handle *child,
struct ti_lmu_bank *lmu_data)
{
int ret;
ret = fwnode_property_read_u32(child, "ramp-up-us",
&lmu_data->ramp_up_usec);
if (ret)
dev_warn(dev, "ramp-up-us property missing\n");
ret = fwnode_property_read_u32(child, "ramp-down-us",
&lmu_data->ramp_down_usec);
if (ret)
dev_warn(dev, "ramp-down-us property missing\n");
return 0;
}
EXPORT_SYMBOL(ti_lmu_common_get_ramp_params);
int ti_lmu_common_get_brt_res(struct device *dev, struct fwnode_handle *child,
struct ti_lmu_bank *lmu_data)
{
int ret;
ret = device_property_read_u32(dev, "ti,brightness-resolution",
&lmu_data->max_brightness);
if (ret)
ret = fwnode_property_read_u32(child,
"ti,brightness-resolution",
&lmu_data->max_brightness);
if (lmu_data->max_brightness <= 0) {
lmu_data->max_brightness = MAX_BRIGHTNESS_8BIT;
return ret;
}
if (lmu_data->max_brightness > MAX_BRIGHTNESS_11BIT)
lmu_data->max_brightness = MAX_BRIGHTNESS_11BIT;
return 0;
}
EXPORT_SYMBOL(ti_lmu_common_get_brt_res);
MODULE_DESCRIPTION("TI LMU common LED framework");
MODULE_AUTHOR("Sebastian Reichel");
MODULE_AUTHOR("Dan Murphy <dmurphy@ti.com>");
MODULE_LICENSE("GPL v2");
MODULE_ALIAS("ti-lmu-led-common");
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/err.h`, `linux/property.h`, `linux/leds-ti-lmu-common.h`.
- Detected declarations: `function ti_lmu_common_update_brightness`, `function ti_lmu_common_set_brightness`, `function ti_lmu_common_convert_ramp_to_index`, `function ti_lmu_common_set_ramp`, `function ti_lmu_common_get_ramp_params`, `function ti_lmu_common_get_brt_res`, `export ti_lmu_common_set_brightness`, `export ti_lmu_common_set_ramp`, `export ti_lmu_common_get_ramp_params`, `export ti_lmu_common_get_brt_res`.
- Atlas domain: Driver Families / drivers/leds.
- Implementation status: integration 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.