Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1061d851 authored by Guenter Roeck's avatar Guenter Roeck
Browse files

hwmon: (pmbus) Add support for VID output voltage mode



In VID mode, output voltages are measured and reported as VID values, and
have to be converted to voltages using VID conversion tables or functions.
Support is added for VR11 only at this time.

This patch enables support for PMBus devices supporting VID VR11 based output
voltage selection such as NCP4200 and NCP4208.

Signed-off-by: default avatarGuenter Roeck <guenter.roeck@ericsson.com>
Reviewed-by: default avatarRobert Coulson <robert.coulson@ericsson.com>
parent 9d2ecfb7
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -50,9 +50,9 @@ static int adm1275_probe(struct i2c_client *client,
	}

	info->pages = 1;
	info->direct[PSC_VOLTAGE_IN] = true;
	info->direct[PSC_VOLTAGE_OUT] = true;
	info->direct[PSC_CURRENT_OUT] = true;
	info->format[PSC_VOLTAGE_IN] = direct;
	info->format[PSC_VOLTAGE_OUT] = direct;
	info->format[PSC_CURRENT_OUT] = direct;
	info->m[PSC_CURRENT_OUT] = 807;
	info->b[PSC_CURRENT_OUT] = 20475;
	info->R[PSC_CURRENT_OUT] = -1;
+3 −3
Original line number Diff line number Diff line
@@ -27,9 +27,9 @@

static struct pmbus_driver_info max16064_info = {
	.pages = 4,
	.direct[PSC_VOLTAGE_IN] = true,
	.direct[PSC_VOLTAGE_OUT] = true,
	.direct[PSC_TEMPERATURE] = true,
	.format[PSC_VOLTAGE_IN] = direct,
	.format[PSC_VOLTAGE_OUT] = direct,
	.format[PSC_TEMPERATURE] = direct,
	.m[PSC_VOLTAGE_IN] = 19995,
	.b[PSC_VOLTAGE_IN] = 0,
	.R[PSC_VOLTAGE_IN] = -1,
+9 −9
Original line number Diff line number Diff line
@@ -72,10 +72,10 @@ static int max34440_read_byte_data(struct i2c_client *client, int page, int reg)
static struct pmbus_driver_info max34440_info[] = {
	[max34440] = {
		.pages = 14,
		.direct[PSC_VOLTAGE_IN] = true,
		.direct[PSC_VOLTAGE_OUT] = true,
		.direct[PSC_TEMPERATURE] = true,
		.direct[PSC_CURRENT_OUT] = true,
		.format[PSC_VOLTAGE_IN] = direct,
		.format[PSC_VOLTAGE_OUT] = direct,
		.format[PSC_TEMPERATURE] = direct,
		.format[PSC_CURRENT_OUT] = direct,
		.m[PSC_VOLTAGE_IN] = 1,
		.b[PSC_VOLTAGE_IN] = 0,
		.R[PSC_VOLTAGE_IN] = 3,	    /* R = 0 in datasheet reflects mV */
@@ -112,11 +112,11 @@ static struct pmbus_driver_info max34440_info[] = {
	},
	[max34441] = {
		.pages = 12,
		.direct[PSC_VOLTAGE_IN] = true,
		.direct[PSC_VOLTAGE_OUT] = true,
		.direct[PSC_TEMPERATURE] = true,
		.direct[PSC_CURRENT_OUT] = true,
		.direct[PSC_FAN] = true,
		.format[PSC_VOLTAGE_IN] = direct,
		.format[PSC_VOLTAGE_OUT] = direct,
		.format[PSC_TEMPERATURE] = direct,
		.format[PSC_CURRENT_OUT] = direct,
		.format[PSC_FAN] = direct,
		.m[PSC_VOLTAGE_IN] = 1,
		.b[PSC_VOLTAGE_IN] = 0,
		.R[PSC_VOLTAGE_IN] = 3,
+4 −4
Original line number Diff line number Diff line
@@ -91,10 +91,10 @@ static int max8688_read_byte_data(struct i2c_client *client, int page, int reg)

static struct pmbus_driver_info max8688_info = {
	.pages = 1,
	.direct[PSC_VOLTAGE_IN] = true,
	.direct[PSC_VOLTAGE_OUT] = true,
	.direct[PSC_TEMPERATURE] = true,
	.direct[PSC_CURRENT_OUT] = true,
	.format[PSC_VOLTAGE_IN] = direct,
	.format[PSC_VOLTAGE_OUT] = direct,
	.format[PSC_TEMPERATURE] = direct,
	.format[PSC_CURRENT_OUT] = direct,
	.m[PSC_VOLTAGE_IN] = 19995,
	.b[PSC_VOLTAGE_IN] = 0,
	.R[PSC_VOLTAGE_IN] = -1,
+31 −3
Original line number Diff line number Diff line
@@ -96,6 +96,8 @@ static void pmbus_find_sensor_groups(struct i2c_client *client,
static int pmbus_identify(struct i2c_client *client,
			  struct pmbus_driver_info *info)
{
	int ret = 0;

	if (!info->pages) {
		/*
		 * Check if the PAGE command is supported. If it is,
@@ -117,6 +119,27 @@ static int pmbus_identify(struct i2c_client *client,
		}
	}

	if (pmbus_check_byte_register(client, 0, PMBUS_VOUT_MODE)) {
		int vout_mode;

		vout_mode = pmbus_read_byte_data(client, 0, PMBUS_VOUT_MODE);
		if (vout_mode >= 0 && vout_mode != 0xff) {
			switch (vout_mode >> 5) {
			case 0:
				break;
			case 1:
				info->format[PSC_VOLTAGE_OUT] = vid;
				break;
			case 2:
				info->format[PSC_VOLTAGE_OUT] = direct;
				break;
			default:
				ret = -ENODEV;
				goto abort;
			}
		}
	}

	/*
	 * We should check if the COEFFICIENTS register is supported.
	 * If it is, and the chip is configured for direct mode, we can read
@@ -125,13 +148,18 @@ static int pmbus_identify(struct i2c_client *client,
	 *
	 * To do this, we will need access to a chip which actually supports the
	 * COEFFICIENTS command, since the command is too complex to implement
	 * without testing it.
	 * without testing it. Until then, abort if a chip configured for direct
	 * mode was detected.
	 */
	if (info->format[PSC_VOLTAGE_OUT] == direct) {
		ret = -ENODEV;
		goto abort;
	}

	/* Try to find sensor groups  */
	pmbus_find_sensor_groups(client, info);

	return 0;
abort:
	return ret;
}

static int pmbus_probe(struct i2c_client *client,
Loading