drivers/regulator/max77675-regulator.c

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

File Facts

System
Linux kernel
Corpus path
drivers/regulator/max77675-regulator.c
Extension
.c
Size
32913 bytes
Lines
1057
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 max77675_regulator_sbb_setting {
	u8   fps_slot;
	bool fixed_slew_rate;
};

struct max77675_config {
	u8   en_mode;
	u8   voltage_change_latency;
	u8   drv_sbb_strength;
	u8   dvs_slew_rate;
	u8   debounce_time;
	u8   manual_reset_time;
	bool en_pullup_disable;
	bool bias_low_power_request;
	bool simo_ldo_always_on;
};

struct max77675_regulator {
	struct device *dev;
	struct regmap *regmap;
	struct max77675_config config;
	struct max77675_regulator_sbb_setting sbb_setting[MAX77675_ID_NUM_MAX];
};

static int max77675_regulator_get_fps_src(struct max77675_regulator *maxreg, int id)
{
	unsigned int reg_addr;
	unsigned int val;
	int ret;

	switch (id) {
	case MAX77675_ID_SBB0:
		reg_addr = MAX77675_REG_CNFG_SBB0_B;
		break;
	case MAX77675_ID_SBB1:
		reg_addr = MAX77675_REG_CNFG_SBB1_B;
		break;
	case MAX77675_ID_SBB2:
		reg_addr = MAX77675_REG_CNFG_SBB2_B;
		break;
	case MAX77675_ID_SBB3:
		reg_addr = MAX77675_REG_CNFG_SBB3_B;
		break;
	default:
		dev_err(maxreg->dev, "Invalid regulator id: %d\n", id);
		return -EINVAL;
	}

	ret = regmap_read(maxreg->regmap, reg_addr, &val);
	if (ret < 0) {
		dev_err(maxreg->dev, "Failed to read FPS source (reg 0x%02x): %d\n",
			reg_addr, ret);
		return ret;
	}

	return FIELD_GET(MAX77675_EN_SBB_MASK, val);
}

static int max77675_regulator_set_fps_src(struct max77675_regulator *maxreg, int id, u8 fps_src)
{
	unsigned int reg_addr;

	switch (id) {
	case MAX77675_ID_SBB0:
		reg_addr = MAX77675_REG_CNFG_SBB0_B;
		break;
	case MAX77675_ID_SBB1:
		reg_addr = MAX77675_REG_CNFG_SBB1_B;
		break;
	case MAX77675_ID_SBB2:
		reg_addr = MAX77675_REG_CNFG_SBB2_B;
		break;
	case MAX77675_ID_SBB3:
		reg_addr = MAX77675_REG_CNFG_SBB3_B;
		break;
	default:
		dev_err(maxreg->dev, "Invalid regulator id: %d\n", id);
		return -EINVAL;
	}

	return regmap_update_bits(maxreg->regmap, reg_addr, MAX77675_EN_SBB_MASK, fps_src);
}

static int max77675_set_sbb_slew_rate_fixed(struct max77675_regulator *maxreg, int id, bool fixed)
{
	u8 mask, value;
	u8 slew_src_ctrl_bit = fixed ? 0 : 1;

	switch (id) {
	case MAX77675_ID_SBB0:

Annotation

Implementation Notes