drivers/regulator/tps65185.c

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

File Facts

System
Linux kernel
Corpus path
drivers/regulator/tps65185.c
Extension
.c
Size
11967 bytes
Lines
458
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 tps65185_data {
	struct device *dev;
	struct regmap *regmap;
	struct gpio_desc *pgood_gpio;
	struct gpio_desc *pwrup_gpio;
	struct gpio_desc *vcom_ctrl_gpio;
	struct gpio_desc *wakeup_gpio;
	struct completion pgood_completion;
	int pgood_irq;
	struct completion tmst_completion;
};

static const struct hwmon_channel_info *tps65185_info[] = {
	HWMON_CHANNEL_INFO(chip, HWMON_C_REGISTER_TZ),
	HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT),
	NULL
};

static int tps65185_hwmon_read(struct device *dev, enum hwmon_sensor_types type,
			       u32 attr, int channel, long *temp)
{
	struct tps65185_data *data = dev_get_drvdata(dev);
	unsigned int val;
	int ret;

	reinit_completion(&data->tmst_completion);
	/* start acquisition */
	regmap_update_bits(data->regmap, TPS65185_REG_TMST1,
			   TPS65185_READ_THERM, TPS65185_READ_THERM);
	wait_for_completion_timeout(&data->tmst_completion,
				    msecs_to_jiffies(PGOOD_TIMEOUT_MSECS));
	ret = regmap_read(data->regmap, TPS65185_REG_TMST1, &val);
	if (!(val & TPS65185_CONV_END))
		return -ETIMEDOUT;

	ret = regmap_read(data->regmap, TPS65185_REG_TMST_VALUE, &val);
	if (ret)
		return ret;

	*temp = (s8)val * 1000;

	return 0;
}

static umode_t tps65185_hwmon_is_visible(const void *data,
					 enum hwmon_sensor_types type,
					 u32 attr, int channel)
{
	return 0444;
}

static const struct hwmon_ops tps65185_hwmon_ops = {
	.is_visible = tps65185_hwmon_is_visible,
	.read = tps65185_hwmon_read,
};

static const struct hwmon_chip_info tps65185_chip_info = {
	.ops = &tps65185_hwmon_ops,
	.info = tps65185_info,
};

static bool tps65185_volatile_reg(struct device *dev, unsigned int reg)
{
	switch (reg) {
	case TPS65185_REG_TMST_VALUE:
	case TPS65185_REG_ENABLE:
	case TPS65185_REG_VCOM2:
	case TPS65185_REG_INT1:
	case TPS65185_REG_INT2:
	case TPS65185_REG_TMST1:
		return true;
	default:
		return false;
	}
}

static const struct regmap_config regmap_config = {
	.reg_bits = 8,
	.val_bits = 8,
	.max_register = 0x10,
	.cache_type = REGCACHE_MAPLE,
	.volatile_reg = tps65185_volatile_reg,
};

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

Annotation

Implementation Notes