drivers/mfd/lp3943.c
Source file repositories/reference/linux-study-clean/drivers/mfd/lp3943.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mfd/lp3943.c- Extension
.c- Size
- 4054 bytes
- Lines
- 156
- Domain
- Driver Families
- Bucket
- drivers/mfd
- 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.
- 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/err.hlinux/gpio.hlinux/i2c.hlinux/mfd/core.hlinux/mfd/lp3943.hlinux/module.hlinux/of.hlinux/slab.h
Detected Declarations
function lp3943_read_bytefunction lp3943_write_bytefunction lp3943_update_bitsfunction lp3943_probeexport lp3943_read_byteexport lp3943_write_byteexport lp3943_update_bits
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* TI/National Semiconductor LP3943 MFD Core Driver
*
* Copyright 2013 Texas Instruments
*
* Author: Milo Kim <milo.kim@ti.com>
*
* Driver structure:
* LP3943 is an integrated device capable of driving 16 output channels.
* It can be used for a GPIO expander and PWM generators.
*
* LED control General usage for a device
* ___________ ____________________________
*
* LP3943 MFD ---- GPIO expander leds-gpio eg) HW enable pin
* |
* --- PWM generator leds-pwm eg) PWM input
*
* Internal two PWM channels are used for LED dimming effect.
* And each output pin can be used as a GPIO as well.
* The LED functionality can work with GPIOs or PWMs.
* LEDs can be controlled with legacy leds-gpio(static brightness) or
* leds-pwm drivers(dynamic brightness control).
* Alternatively, it can be used for generic GPIO and PWM controller.
* For example, a GPIO is HW enable pin of a device.
* A PWM is input pin of a backlight device.
*/
#include <linux/err.h>
#include <linux/gpio.h>
#include <linux/i2c.h>
#include <linux/mfd/core.h>
#include <linux/mfd/lp3943.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/slab.h>
#define LP3943_MAX_REGISTERS 0x09
/* Register configuration for pin MUX */
static const struct lp3943_reg_cfg lp3943_mux_cfg[] = {
/* address, mask, shift */
{ LP3943_REG_MUX0, 0x03, 0 },
{ LP3943_REG_MUX0, 0x0C, 2 },
{ LP3943_REG_MUX0, 0x30, 4 },
{ LP3943_REG_MUX0, 0xC0, 6 },
{ LP3943_REG_MUX1, 0x03, 0 },
{ LP3943_REG_MUX1, 0x0C, 2 },
{ LP3943_REG_MUX1, 0x30, 4 },
{ LP3943_REG_MUX1, 0xC0, 6 },
{ LP3943_REG_MUX2, 0x03, 0 },
{ LP3943_REG_MUX2, 0x0C, 2 },
{ LP3943_REG_MUX2, 0x30, 4 },
{ LP3943_REG_MUX2, 0xC0, 6 },
{ LP3943_REG_MUX3, 0x03, 0 },
{ LP3943_REG_MUX3, 0x0C, 2 },
{ LP3943_REG_MUX3, 0x30, 4 },
{ LP3943_REG_MUX3, 0xC0, 6 },
};
static const struct mfd_cell lp3943_devs[] = {
{
.name = "lp3943-pwm",
.of_compatible = "ti,lp3943-pwm",
},
{
.name = "lp3943-gpio",
.of_compatible = "ti,lp3943-gpio",
},
};
int lp3943_read_byte(struct lp3943 *lp3943, u8 reg, u8 *read)
{
int ret;
unsigned int val;
ret = regmap_read(lp3943->regmap, reg, &val);
if (ret < 0)
return ret;
*read = (u8)val;
return 0;
}
EXPORT_SYMBOL_GPL(lp3943_read_byte);
int lp3943_write_byte(struct lp3943 *lp3943, u8 reg, u8 data)
{
return regmap_write(lp3943->regmap, reg, data);
}
Annotation
- Immediate include surface: `linux/err.h`, `linux/gpio.h`, `linux/i2c.h`, `linux/mfd/core.h`, `linux/mfd/lp3943.h`, `linux/module.h`, `linux/of.h`, `linux/slab.h`.
- Detected declarations: `function lp3943_read_byte`, `function lp3943_write_byte`, `function lp3943_update_bits`, `function lp3943_probe`, `export lp3943_read_byte`, `export lp3943_write_byte`, `export lp3943_update_bits`.
- Atlas domain: Driver Families / drivers/mfd.
- 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.