drivers/regulator/max77541-regulator.c
Source file repositories/reference/linux-study-clean/drivers/regulator/max77541-regulator.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/regulator/max77541-regulator.c- Extension
.c- Size
- 4904 bytes
- Lines
- 154
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/mfd/max77541.hlinux/mod_devicetable.hlinux/platform_device.hlinux/regmap.hlinux/regulator/driver.h
Detected Declarations
enum max77541_regulatorsfunction max77541_regulator_probe
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Copyright (c) 2022 Analog Devices, Inc.
* ADI Regulator driver for the MAX77540 and MAX77541
*/
#include <linux/mfd/max77541.h>
#include <linux/mod_devicetable.h>
#include <linux/platform_device.h>
#include <linux/regmap.h>
#include <linux/regulator/driver.h>
static const struct regulator_ops max77541_buck_ops = {
.enable = regulator_enable_regmap,
.disable = regulator_disable_regmap,
.is_enabled = regulator_is_enabled_regmap,
.list_voltage = regulator_list_voltage_pickable_linear_range,
.get_voltage_sel = regulator_get_voltage_sel_pickable_regmap,
.set_voltage_sel = regulator_set_voltage_sel_pickable_regmap,
};
static const struct linear_range max77540_buck_ranges[] = {
/* Ranges when VOLT_SEL bits are 0x00 */
REGULATOR_LINEAR_RANGE(500000, 0x00, 0x8B, 5000),
REGULATOR_LINEAR_RANGE(1200000, 0x8C, 0xFF, 0),
/* Ranges when VOLT_SEL bits are 0x40 */
REGULATOR_LINEAR_RANGE(1200000, 0x00, 0x8B, 10000),
REGULATOR_LINEAR_RANGE(2400000, 0x8C, 0xFF, 0),
/* Ranges when VOLT_SEL bits are 0x80 */
REGULATOR_LINEAR_RANGE(2000000, 0x00, 0x9F, 20000),
REGULATOR_LINEAR_RANGE(5200000, 0xA0, 0xFF, 0),
};
static const struct linear_range max77541_buck_ranges[] = {
/* Ranges when VOLT_SEL bits are 0x00 */
REGULATOR_LINEAR_RANGE(300000, 0x00, 0xB3, 5000),
REGULATOR_LINEAR_RANGE(1200000, 0xB4, 0xFF, 0),
/* Ranges when VOLT_SEL bits are 0x40 */
REGULATOR_LINEAR_RANGE(1200000, 0x00, 0x8B, 10000),
REGULATOR_LINEAR_RANGE(2400000, 0x8C, 0xFF, 0),
/* Ranges when VOLT_SEL bits are 0x80 */
REGULATOR_LINEAR_RANGE(2000000, 0x00, 0x9F, 20000),
REGULATOR_LINEAR_RANGE(5200000, 0xA0, 0xFF, 0),
};
static const unsigned int max77541_buck_volt_range_sel[] = {
0x0, 0x0, 0x1, 0x1, 0x2, 0x2,
};
enum max77541_regulators {
MAX77541_BUCK1 = 1,
MAX77541_BUCK2,
};
#define MAX77540_BUCK(_id, _ops) \
{ .id = MAX77541_BUCK ## _id, \
.name = "buck"#_id, \
.of_match = "buck"#_id, \
.regulators_node = "regulators", \
.enable_reg = MAX77541_REG_EN_CTRL, \
.enable_mask = MAX77541_BIT_M ## _id ## _EN, \
.ops = &(_ops), \
.type = REGULATOR_VOLTAGE, \
.linear_ranges = max77540_buck_ranges, \
.n_linear_ranges = ARRAY_SIZE(max77540_buck_ranges), \
.vsel_reg = MAX77541_REG_M ## _id ## _VOUT, \
.vsel_mask = MAX77541_BITS_MX_VOUT, \
.vsel_range_reg = MAX77541_REG_M ## _id ## _CFG1, \
.vsel_range_mask = MAX77541_BITS_MX_CFG1_RNG, \
.linear_range_selectors_bitfield = max77541_buck_volt_range_sel, \
.owner = THIS_MODULE, \
}
#define MAX77541_BUCK(_id, _ops) \
{ .id = MAX77541_BUCK ## _id, \
.name = "buck"#_id, \
.of_match = "buck"#_id, \
.regulators_node = "regulators", \
.enable_reg = MAX77541_REG_EN_CTRL, \
.enable_mask = MAX77541_BIT_M ## _id ## _EN, \
.ops = &(_ops), \
.type = REGULATOR_VOLTAGE, \
.linear_ranges = max77541_buck_ranges, \
.n_linear_ranges = ARRAY_SIZE(max77541_buck_ranges), \
.vsel_reg = MAX77541_REG_M ## _id ## _VOUT, \
.vsel_mask = MAX77541_BITS_MX_VOUT, \
.vsel_range_reg = MAX77541_REG_M ## _id ## _CFG1, \
.vsel_range_mask = MAX77541_BITS_MX_CFG1_RNG, \
.linear_range_selectors_bitfield = max77541_buck_volt_range_sel, \
.owner = THIS_MODULE, \
Annotation
- Immediate include surface: `linux/mfd/max77541.h`, `linux/mod_devicetable.h`, `linux/platform_device.h`, `linux/regmap.h`, `linux/regulator/driver.h`.
- Detected declarations: `enum max77541_regulators`, `function max77541_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.