drivers/regulator/rt5133-regulator.c

Source file repositories/reference/linux-study-clean/drivers/regulator/rt5133-regulator.c

File Facts

System
Linux kernel
Corpus path
drivers/regulator/rt5133-regulator.c
Extension
.c
Size
17892 bytes
Lines
643
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.

Dependency Surface

Detected Declarations

Annotated Snippet

struct chip_data {
	const struct regulator_desc *regulators;
	const u8 vendor_id;
};

struct rt5133_priv {
	struct device *dev;
	struct regmap *regmap;
	struct gpio_desc *enable_gpio;
	struct regulator_dev *rdev[RT5133_REGULATOR_MAX];
	struct gpio_chip gc;
	const struct chip_data *cdata;
	unsigned int gpio_output_flag;
	u8 crc8_tbls[CRC8_TABLE_SIZE];
};

static const unsigned int vout_type1_tables[] = {
	1800000, 2500000, 2700000, 2800000, 2900000, 3000000, 3100000, 3200000
};

static const unsigned int vout_type2_tables[] = {
	1700000, 1800000, 1900000, 2500000, 2700000, 2800000, 2900000, 3000000
};

static const unsigned int vout_type3_tables[] = {
	900000, 950000, 1000000, 1050000, 1100000, 1150000, 1200000, 1800000
};

static const unsigned int vout_type4_tables[] = {
	855000, 900000, 950000, 1000000, 1040000, 1090000, 1140000, 1710000
};

static const struct regulator_ops rt5133_regulator_ops = {
	.list_voltage = regulator_list_voltage_table,
	.set_voltage_sel = regulator_set_voltage_sel_regmap,
	.get_voltage_sel = regulator_get_voltage_sel_regmap,
	.enable = regulator_enable_regmap,
	.disable = regulator_disable_regmap,
	.is_enabled = regulator_is_enabled_regmap,
	.set_active_discharge = regulator_set_active_discharge_regmap,
};

static const struct regulator_ops rt5133_base_regulator_ops = {
	.enable = regulator_enable_regmap,
	.disable = regulator_disable_regmap,
	.is_enabled = regulator_is_enabled_regmap,
};

#define RT5133_REGULATOR_DESC(_name, _node_name, vtables, _supply) \
{\
	.name = #_name,\
	.id = RT5133_REGULATOR_##_name,\
	.of_match = of_match_ptr(#_node_name),\
	.regulators_node = of_match_ptr("regulators"),\
	.supply_name = _supply,\
	.type = REGULATOR_VOLTAGE,\
	.owner = THIS_MODULE,\
	.ops = &rt5133_regulator_ops,\
	.n_voltages = ARRAY_SIZE(vtables),\
	.volt_table = vtables,\
	.enable_reg = RT5133_REG_##_name##_CTRL1,\
	.enable_mask = RT5133_LDO_ENABLE_MASK,\
	.vsel_reg = RT5133_REG_##_name##_CTRL2,\
	.vsel_mask = RT5133_LDO_VSEL_MASK,\
	.active_discharge_reg = RT5133_REG_##_name##_CTRL3,\
	.active_discharge_mask = RT5133_LDO_AD_MASK,\
}

static const struct regulator_desc rt5133_regulators[] = {
	/* For digital part, base current control */
	{
		.name = "base",
		.id = RT5133_REGULATOR_BASE,
		.of_match = of_match_ptr("base"),
		.regulators_node = of_match_ptr("regulators"),
		.type = REGULATOR_VOLTAGE,
		.owner = THIS_MODULE,
		.ops = &rt5133_base_regulator_ops,
		.enable_reg = RT5133_REG_BASE_CTRL,
		.enable_mask = RT5133_FOFF_BASE_MASK,
		.enable_is_inverted = true,
	},
	RT5133_REGULATOR_DESC(LDO1, ldo1, vout_type1_tables, "base"),
	RT5133_REGULATOR_DESC(LDO2, ldo2, vout_type1_tables, "base"),
	RT5133_REGULATOR_DESC(LDO3, ldo3, vout_type2_tables, "base"),
	RT5133_REGULATOR_DESC(LDO4, ldo4, vout_type2_tables, "base"),
	RT5133_REGULATOR_DESC(LDO5, ldo5, vout_type2_tables, "base"),
	RT5133_REGULATOR_DESC(LDO6, ldo6, vout_type2_tables, "base"),
	RT5133_REGULATOR_DESC(LDO7, ldo7, vout_type3_tables, "vin"),
	RT5133_REGULATOR_DESC(LDO8, ldo8, vout_type3_tables, "vin"),

Annotation

Implementation Notes