drivers/regulator/sy8824x.c
Source file repositories/reference/linux-study-clean/drivers/regulator/sy8824x.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/regulator/sy8824x.c- Extension
.c- Size
- 6092 bytes
- Lines
- 238
- Domain
- Driver Families
- Bucket
- drivers/regulator
- 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/module.hlinux/i2c.hlinux/of.hlinux/regmap.hlinux/regulator/driver.hlinux/regulator/of_regulator.h
Detected Declarations
struct sy8824_configstruct sy8824_device_infofunction sy8824_set_modefunction sy8824_get_modefunction sy8824_regulator_registerfunction sy8824_i2c_probe
Annotated Snippet
struct sy8824_config {
/* registers */
unsigned int vol_reg;
unsigned int mode_reg;
unsigned int enable_reg;
/* Voltage range and step(linear) */
unsigned int vsel_min;
unsigned int vsel_step;
unsigned int vsel_count;
const struct regmap_config *config;
};
struct sy8824_device_info {
struct device *dev;
struct regulator_desc desc;
struct regulator_init_data *regulator;
const struct sy8824_config *cfg;
};
static int sy8824_set_mode(struct regulator_dev *rdev, unsigned int mode)
{
struct sy8824_device_info *di = rdev_get_drvdata(rdev);
const struct sy8824_config *cfg = di->cfg;
switch (mode) {
case REGULATOR_MODE_FAST:
regmap_update_bits(rdev->regmap, cfg->mode_reg,
SY8824C_MODE, SY8824C_MODE);
break;
case REGULATOR_MODE_NORMAL:
regmap_update_bits(rdev->regmap, cfg->mode_reg,
SY8824C_MODE, 0);
break;
default:
return -EINVAL;
}
return 0;
}
static unsigned int sy8824_get_mode(struct regulator_dev *rdev)
{
struct sy8824_device_info *di = rdev_get_drvdata(rdev);
const struct sy8824_config *cfg = di->cfg;
u32 val;
int ret = 0;
ret = regmap_read(rdev->regmap, cfg->mode_reg, &val);
if (ret < 0)
return ret;
if (val & SY8824C_MODE)
return REGULATOR_MODE_FAST;
else
return REGULATOR_MODE_NORMAL;
}
static const struct regulator_ops sy8824_regulator_ops = {
.set_voltage_sel = regulator_set_voltage_sel_regmap,
.get_voltage_sel = regulator_get_voltage_sel_regmap,
.set_voltage_time_sel = regulator_set_voltage_time_sel,
.map_voltage = regulator_map_voltage_linear,
.list_voltage = regulator_list_voltage_linear,
.enable = regulator_enable_regmap,
.disable = regulator_disable_regmap,
.is_enabled = regulator_is_enabled_regmap,
.set_mode = sy8824_set_mode,
.get_mode = sy8824_get_mode,
};
static int sy8824_regulator_register(struct sy8824_device_info *di,
struct regulator_config *config)
{
struct regulator_desc *rdesc = &di->desc;
const struct sy8824_config *cfg = di->cfg;
struct regulator_dev *rdev;
rdesc->name = "sy8824-reg";
rdesc->supply_name = "vin";
rdesc->ops = &sy8824_regulator_ops;
rdesc->type = REGULATOR_VOLTAGE;
rdesc->n_voltages = cfg->vsel_count;
rdesc->enable_reg = cfg->enable_reg;
rdesc->enable_mask = SY8824C_BUCK_EN;
rdesc->min_uV = cfg->vsel_min;
rdesc->uV_step = cfg->vsel_step;
rdesc->vsel_reg = cfg->vol_reg;
rdesc->vsel_mask = cfg->vsel_count - 1;
rdesc->owner = THIS_MODULE;
rdev = devm_regulator_register(di->dev, &di->desc, config);
return PTR_ERR_OR_ZERO(rdev);
Annotation
- Immediate include surface: `linux/module.h`, `linux/i2c.h`, `linux/of.h`, `linux/regmap.h`, `linux/regulator/driver.h`, `linux/regulator/of_regulator.h`.
- Detected declarations: `struct sy8824_config`, `struct sy8824_device_info`, `function sy8824_set_mode`, `function sy8824_get_mode`, `function sy8824_regulator_register`, `function sy8824_i2c_probe`.
- Atlas domain: Driver Families / drivers/regulator.
- 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.