drivers/hwmon/pmbus/tps53679.c

Source file repositories/reference/linux-study-clean/drivers/hwmon/pmbus/tps53679.c

File Facts

System
Linux kernel
Corpus path
drivers/hwmon/pmbus/tps53679.c
Extension
.c
Size
9178 bytes
Lines
334
Domain
Driver Families
Bucket
drivers/hwmon
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

switch (vout_params) {
		case TPS53679_PROT_VR13_10MV:
		case TPS53679_PROT_VR12_5_10MV:
			info->vrm_version[i] = vr13;
			break;
		case TPS53679_PROT_VR13_5MV:
		case TPS53679_PROT_VR12_5MV:
		case TPS53679_PROT_IMVP8_5MV:
			info->vrm_version[i] = vr12;
			break;
		default:
			return -EINVAL;
		}
	}

	return 0;
}

static int tps53679_identify_phases(struct i2c_client *client,
				    struct pmbus_driver_info *info)
{
	int ret;

	/* On TPS53681, only channel A provides per-phase output current */
	ret = pmbus_read_byte_data(client, 0, TPS53681_MFR_SPECIFIC_20);
	if (ret < 0)
		return ret;
	info->phases[0] = (ret & 0x07) + 1;

	return 0;
}

static int tps53679_identify_chip(struct i2c_client *client,
				  u8 revision, char *id)
{
	u8 buf[I2C_SMBUS_BLOCK_MAX];
	int ret;
	int buf_len;
	int id_len;

	ret = pmbus_read_byte_data(client, 0, PMBUS_REVISION);
	if (ret < 0)
		return ret;
	if (ret != revision) {
		dev_err(&client->dev, "Unexpected PMBus revision 0x%x\n", ret);
		return -ENODEV;
	}

	ret = i2c_smbus_read_block_data(client, PMBUS_IC_DEVICE_ID, buf);
	if (ret <= 0)
		return ret < 0 ? ret : -EIO;

	/* Adjust length if null terminator is present */
	buf_len = (buf[ret - 1] != '\x00' ? ret : ret - 1);

	id_len = strlen(id);

	if (buf_len != id_len || strncmp(id, buf, id_len)) {
		dev_err(&client->dev, "Unexpected device ID: %*ph\n", ret, buf);
		return -ENODEV;
	}
	return 0;
}

/*
 * Common identification function for chips with multi-phase support.
 * Since those chips have special configuration registers, we want to have
 * some level of reassurance that we are really talking with the chip
 * being probed. Check PMBus revision and chip ID.
 */
static int tps53679_identify_multiphase(struct i2c_client *client,
					struct pmbus_driver_info *info,
					int pmbus_rev, char *device_id)
{
	int ret;

	ret = tps53679_identify_chip(client, pmbus_rev, device_id);
	if (ret < 0)
		return ret;

	ret = tps53679_identify_mode(client, info);
	if (ret < 0)
		return ret;

	return tps53679_identify_phases(client, info);
}

static int tps53679_identify(struct i2c_client *client,
			     struct pmbus_driver_info *info)
{

Annotation

Implementation Notes