drivers/mfd/ene-kb3930.c
Source file repositories/reference/linux-study-clean/drivers/mfd/ene-kb3930.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mfd/ene-kb3930.c- Extension
.c- Size
- 4888 bytes
- Lines
- 211
- Domain
- Driver Families
- Bucket
- drivers/mfd
- 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.
- 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/delay.hlinux/gpio/consumer.hlinux/i2c.hlinux/mfd/core.hlinux/module.hlinux/reboot.hlinux/regmap.h
Detected Declarations
struct kb3930function kb3930_offfunction kb3930_restartfunction kb3930_pm_power_offfunction kb3930_ec_ram_reg_writefunction kb3930_ec_ram_reg_readfunction kb3930_probefunction kb3930_remove
Annotated Snippet
struct kb3930 {
struct i2c_client *client;
struct regmap *ram_regmap;
struct gpio_descs *off_gpios;
};
static struct kb3930 *kb3930_power_off;
#define EC_GPIO_WAVE 0
#define EC_GPIO_OFF_MODE 1
#define EC_OFF_MODE_REBOOT 0
#define EC_OFF_MODE_POWER 1
static void kb3930_off(struct kb3930 *ddata, int off_mode)
{
gpiod_direction_output(ddata->off_gpios->desc[EC_GPIO_OFF_MODE],
off_mode);
/*
* This creates a 10 Hz wave on EC_GPIO_WAVE that signals a
* shutdown request to the EC. Once the EC detects it, it will
* proceed to turn the power off or reset the board depending on
* the value of EC_GPIO_OFF_MODE.
*/
while (1) {
mdelay(50);
gpiod_direction_output(ddata->off_gpios->desc[EC_GPIO_WAVE], 0);
mdelay(50);
gpiod_direction_output(ddata->off_gpios->desc[EC_GPIO_WAVE], 1);
}
}
static int kb3930_restart(struct notifier_block *this,
unsigned long mode, void *cmd)
{
kb3930_off(kb3930_power_off, EC_OFF_MODE_REBOOT);
return NOTIFY_DONE;
}
static void kb3930_pm_power_off(void)
{
kb3930_off(kb3930_power_off, EC_OFF_MODE_POWER);
}
static struct notifier_block kb3930_restart_nb = {
.notifier_call = kb3930_restart,
};
static const struct mfd_cell ariel_ec_cells[] = {
{ .name = "dell-wyse-ariel-led", },
{ .name = "dell-wyse-ariel-power", },
};
static int kb3930_ec_ram_reg_write(void *context, unsigned int reg,
unsigned int val)
{
struct kb3930 *ddata = context;
return i2c_smbus_write_word_data(ddata->client, EC_RAM_OUT,
(val << 8) | reg);
}
static int kb3930_ec_ram_reg_read(void *context, unsigned int reg,
unsigned int *val)
{
struct kb3930 *ddata = context;
int ret;
ret = i2c_smbus_write_word_data(ddata->client, EC_RAM_IN, reg);
if (ret < 0)
return ret;
ret = i2c_smbus_read_word_data(ddata->client, EC_DATA_IN);
if (ret < 0)
return ret;
*val = ret >> 8;
return 0;
}
static const struct regmap_config kb3930_ram_regmap_config = {
.name = "ec_ram",
.reg_bits = 8,
.val_bits = 8,
.reg_stride = 1,
.max_register = 0xff,
.reg_write = kb3930_ec_ram_reg_write,
.reg_read = kb3930_ec_ram_reg_read,
.fast_io = false,
Annotation
- Immediate include surface: `linux/delay.h`, `linux/gpio/consumer.h`, `linux/i2c.h`, `linux/mfd/core.h`, `linux/module.h`, `linux/reboot.h`, `linux/regmap.h`.
- Detected declarations: `struct kb3930`, `function kb3930_off`, `function kb3930_restart`, `function kb3930_pm_power_off`, `function kb3930_ec_ram_reg_write`, `function kb3930_ec_ram_reg_read`, `function kb3930_probe`, `function kb3930_remove`.
- Atlas domain: Driver Families / drivers/mfd.
- Implementation status: source 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.