drivers/regulator/sy7636a-regulator.c
Source file repositories/reference/linux-study-clean/drivers/regulator/sy7636a-regulator.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/regulator/sy7636a-regulator.c- Extension
.c- Size
- 4575 bytes
- Lines
- 168
- 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/gpio/consumer.hlinux/i2c.hlinux/mfd/sy7636a.hlinux/module.hlinux/platform_device.hlinux/regulator/consumer.hlinux/regulator/driver.hlinux/regulator/machine.hlinux/regmap.h
Detected Declarations
struct sy7636a_datafunction sy7636a_get_vcom_voltage_opfunction sy7636a_get_statusfunction sy7636a_regulator_probe
Annotated Snippet
struct sy7636a_data {
struct regmap *regmap;
struct gpio_desc *pgood_gpio;
struct gpio_desc *en_gpio;
struct gpio_desc *vcom_en_gpio;
};
static int sy7636a_get_vcom_voltage_op(struct regulator_dev *rdev)
{
int ret;
unsigned int val, val_h;
ret = regmap_read(rdev->regmap, SY7636A_REG_VCOM_ADJUST_CTRL_L, &val);
if (ret)
return ret;
ret = regmap_read(rdev->regmap, SY7636A_REG_VCOM_ADJUST_CTRL_H, &val_h);
if (ret)
return ret;
val |= (val_h << VCOM_ADJUST_CTRL_SHIFT);
return (val & VCOM_ADJUST_CTRL_MASK) * VCOM_ADJUST_CTRL_SCAL;
}
static int sy7636a_get_status(struct regulator_dev *rdev)
{
struct sy7636a_data *data = dev_get_drvdata(rdev->dev.parent);
int ret = 0;
ret = gpiod_get_value_cansleep(data->pgood_gpio);
if (ret < 0)
dev_err(&rdev->dev, "Failed to read pgood gpio: %d\n", ret);
return ret;
}
static const struct regulator_ops sy7636a_vcom_volt_ops = {
.get_voltage = sy7636a_get_vcom_voltage_op,
.enable = regulator_enable_regmap,
.disable = regulator_disable_regmap,
.is_enabled = regulator_is_enabled_regmap,
.get_status = sy7636a_get_status,
};
static const struct regulator_desc desc = {
.name = "vcom",
.id = 0,
.ops = &sy7636a_vcom_volt_ops,
.type = REGULATOR_VOLTAGE,
.owner = THIS_MODULE,
.enable_reg = SY7636A_REG_OPERATION_MODE_CRL,
.enable_mask = SY7636A_OPERATION_MODE_CRL_ONOFF,
.regulators_node = of_match_ptr("regulators"),
.of_match = of_match_ptr("vcom"),
};
static int sy7636a_regulator_probe(struct platform_device *pdev)
{
struct regmap *regmap = dev_get_regmap(pdev->dev.parent, NULL);
struct regulator_config config = { };
struct regulator_dev *rdev;
struct gpio_desc *gdp;
struct sy7636a_data *data;
int ret;
if (!regmap)
return -EPROBE_DEFER;
device_set_of_node_from_dev(&pdev->dev, pdev->dev.parent);
gdp = devm_gpiod_get(&pdev->dev, "epd-pwr-good", GPIOD_IN);
if (IS_ERR(gdp)) {
dev_err(&pdev->dev, "Power good GPIO fault %ld\n", PTR_ERR(gdp));
return PTR_ERR(gdp);
}
data = devm_kzalloc(&pdev->dev, sizeof(struct sy7636a_data), GFP_KERNEL);
if (!data)
return -ENOMEM;
data->regmap = regmap;
data->pgood_gpio = gdp;
ret = devm_regulator_get_enable_optional(&pdev->dev, "vin");
if (ret)
return dev_err_probe(&pdev->dev, ret,
"failed to get vin regulator\n");
data->en_gpio = devm_gpiod_get_optional(&pdev->dev, "enable",
Annotation
- Immediate include surface: `linux/gpio/consumer.h`, `linux/i2c.h`, `linux/mfd/sy7636a.h`, `linux/module.h`, `linux/platform_device.h`, `linux/regulator/consumer.h`, `linux/regulator/driver.h`, `linux/regulator/machine.h`.
- Detected declarations: `struct sy7636a_data`, `function sy7636a_get_vcom_voltage_op`, `function sy7636a_get_status`, `function sy7636a_regulator_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.