drivers/video/backlight/lm3630a_bl.c
Source file repositories/reference/linux-study-clean/drivers/video/backlight/lm3630a_bl.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/video/backlight/lm3630a_bl.c- Extension
.c- Size
- 15994 bytes
- Lines
- 628
- Domain
- Driver Families
- Bucket
- drivers/video
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/i2c.hlinux/backlight.hlinux/err.hlinux/delay.hlinux/uaccess.hlinux/interrupt.hlinux/regmap.hlinux/gpio/consumer.hlinux/pwm.hlinux/platform_data/lm3630a_bl.h
Detected Declarations
struct lm3630a_chipfunction lm3630a_readfunction lm3630a_writefunction lm3630a_updatefunction lm3630a_chip_initfunction lm3630a_delayed_funcfunction lm3630a_isr_funcfunction lm3630a_intr_configfunction lm3630a_pwm_ctrlfunction lm3630a_bank_a_update_statusfunction lm3630a_bank_a_get_brightnessfunction lm3630a_bank_b_update_statusfunction lm3630a_bank_b_get_brightnessfunction lm3630a_backlight_registerfunction lm3630a_parse_led_sourcesfunction lm3630a_parse_bankfunction lm3630a_parse_nodefunction device_for_each_child_nodefunction lm3630a_probefunction lm3630a_remove
Annotated Snippet
struct lm3630a_chip {
struct device *dev;
struct delayed_work work;
int irq;
struct workqueue_struct *irqthread;
struct lm3630a_platform_data *pdata;
struct backlight_device *bleda;
struct backlight_device *bledb;
struct gpio_desc *enable_gpio;
struct regmap *regmap;
struct pwm_device *pwmd;
struct pwm_state pwmd_state;
};
/* i2c access */
static int lm3630a_read(struct lm3630a_chip *pchip, unsigned int reg)
{
int rval;
unsigned int reg_val;
rval = regmap_read(pchip->regmap, reg, ®_val);
if (rval < 0)
return rval;
return reg_val & 0xFF;
}
static int lm3630a_write(struct lm3630a_chip *pchip,
unsigned int reg, unsigned int data)
{
return regmap_write(pchip->regmap, reg, data);
}
static int lm3630a_update(struct lm3630a_chip *pchip,
unsigned int reg, unsigned int mask,
unsigned int data)
{
return regmap_update_bits(pchip->regmap, reg, mask, data);
}
/* initialize chip */
static int lm3630a_chip_init(struct lm3630a_chip *pchip)
{
int rval;
struct lm3630a_platform_data *pdata = pchip->pdata;
usleep_range(1000, 2000);
/* set Filter Strength Register */
rval = lm3630a_write(pchip, REG_FILTER_STRENGTH, 0x03);
/* set Cofig. register */
rval |= lm3630a_update(pchip, REG_CONFIG, 0x07, pdata->pwm_ctrl);
/* set boost control */
rval |= lm3630a_write(pchip, REG_BOOST, 0x38);
/* set current A */
rval |= lm3630a_update(pchip, REG_I_A, 0x1F, 0x1F);
/* set current B */
rval |= lm3630a_write(pchip, REG_I_B, 0x1F);
/* set control */
rval |= lm3630a_update(pchip, REG_CTRL, 0x14, pdata->leda_ctrl);
rval |= lm3630a_update(pchip, REG_CTRL, 0x0B, pdata->ledb_ctrl);
usleep_range(1000, 2000);
/* set brightness A and B */
rval |= lm3630a_write(pchip, REG_BRT_A, pdata->leda_init_brt);
rval |= lm3630a_write(pchip, REG_BRT_B, pdata->ledb_init_brt);
if (rval < 0)
dev_err(pchip->dev, "i2c failed to access register\n");
return rval;
}
/* interrupt handling */
static void lm3630a_delayed_func(struct work_struct *work)
{
int rval;
struct lm3630a_chip *pchip;
pchip = container_of(work, struct lm3630a_chip, work.work);
rval = lm3630a_read(pchip, REG_INT_STATUS);
if (rval < 0) {
dev_err(pchip->dev,
"i2c failed to access REG_INT_STATUS Register\n");
return;
}
dev_info(pchip->dev, "REG_INT_STATUS Register is 0x%x\n", rval);
}
static irqreturn_t lm3630a_isr_func(int irq, void *chip)
{
Annotation
- Immediate include surface: `linux/module.h`, `linux/slab.h`, `linux/i2c.h`, `linux/backlight.h`, `linux/err.h`, `linux/delay.h`, `linux/uaccess.h`, `linux/interrupt.h`.
- Detected declarations: `struct lm3630a_chip`, `function lm3630a_read`, `function lm3630a_write`, `function lm3630a_update`, `function lm3630a_chip_init`, `function lm3630a_delayed_func`, `function lm3630a_isr_func`, `function lm3630a_intr_config`, `function lm3630a_pwm_ctrl`, `function lm3630a_bank_a_update_status`.
- Atlas domain: Driver Families / drivers/video.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.