Commit 43f33b6e authored by Guenter Roeck's avatar Guenter Roeck

hwmon: (pmbus) Add 'phase' parameter where needed for multi-phase support

In preparation for multi-phase support, add 'phase' parameter to read_word
and set_page functions. Actual multi-phase support will be added in
a subsequent patch.

Cc: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
parent a1dd176c
...@@ -162,9 +162,12 @@ Read byte from page <page>, register <reg>. ...@@ -162,9 +162,12 @@ Read byte from page <page>, register <reg>.
:: ::
int (*read_word_data)(struct i2c_client *client, int page, int reg); int (*read_word_data)(struct i2c_client *client, int page, int phase,
int reg);
Read word from page <page>, register <reg>. Read word from page <page>, phase <pase>, register <reg>. If the chip does not
support multiple phases, the phase parameter can be ignored. If the chip
supports multiple phases, a phase value of 0xff indicates all phases.
:: ::
...@@ -201,16 +204,21 @@ is mandatory. ...@@ -201,16 +204,21 @@ is mandatory.
:: ::
int pmbus_set_page(struct i2c_client *client, u8 page); int pmbus_set_page(struct i2c_client *client, u8 page, u8 phase);
Set PMBus page register to <page> for subsequent commands. Set PMBus page register to <page> and <phase> for subsequent commands.
If the chip does not support multiple phases, the phase parameter is
ignored. Otherwise, a phase value of 0xff selects all phases.
:: ::
int pmbus_read_word_data(struct i2c_client *client, u8 page, u8 reg); int pmbus_read_word_data(struct i2c_client *client, u8 page, u8 phase,
u8 reg);
Read word data from <page>, <reg>. Similar to i2c_smbus_read_word_data(), but Read word data from <page>, <phase>, <reg>. Similar to
selects page first. i2c_smbus_read_word_data(), but selects page and phase first. If the chip does
not support multiple phases, the phase parameter is ignored. Otherwise, a phase
value of 0xff selects all phases.
:: ::
......
...@@ -226,7 +226,8 @@ static int adm1275_write_pmon_config(const struct adm1275_data *data, ...@@ -226,7 +226,8 @@ static int adm1275_write_pmon_config(const struct adm1275_data *data,
return ret; return ret;
} }
static int adm1275_read_word_data(struct i2c_client *client, int page, int reg) static int adm1275_read_word_data(struct i2c_client *client, int page,
int phase, int reg)
{ {
const struct pmbus_driver_info *info = pmbus_get_driver_info(client); const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
const struct adm1275_data *data = to_adm1275_data(info); const struct adm1275_data *data = to_adm1275_data(info);
...@@ -239,58 +240,68 @@ static int adm1275_read_word_data(struct i2c_client *client, int page, int reg) ...@@ -239,58 +240,68 @@ static int adm1275_read_word_data(struct i2c_client *client, int page, int reg)
case PMBUS_IOUT_UC_FAULT_LIMIT: case PMBUS_IOUT_UC_FAULT_LIMIT:
if (!data->have_uc_fault) if (!data->have_uc_fault)
return -ENXIO; return -ENXIO;
ret = pmbus_read_word_data(client, 0, ADM1275_IOUT_WARN2_LIMIT); ret = pmbus_read_word_data(client, 0, 0xff,
ADM1275_IOUT_WARN2_LIMIT);
break; break;
case PMBUS_IOUT_OC_FAULT_LIMIT: case PMBUS_IOUT_OC_FAULT_LIMIT:
if (!data->have_oc_fault) if (!data->have_oc_fault)
return -ENXIO; return -ENXIO;
ret = pmbus_read_word_data(client, 0, ADM1275_IOUT_WARN2_LIMIT); ret = pmbus_read_word_data(client, 0, 0xff,
ADM1275_IOUT_WARN2_LIMIT);
break; break;
case PMBUS_VOUT_OV_WARN_LIMIT: case PMBUS_VOUT_OV_WARN_LIMIT:
if (data->have_vout) if (data->have_vout)
return -ENODATA; return -ENODATA;
ret = pmbus_read_word_data(client, 0, ret = pmbus_read_word_data(client, 0, 0xff,
ADM1075_VAUX_OV_WARN_LIMIT); ADM1075_VAUX_OV_WARN_LIMIT);
break; break;
case PMBUS_VOUT_UV_WARN_LIMIT: case PMBUS_VOUT_UV_WARN_LIMIT:
if (data->have_vout) if (data->have_vout)
return -ENODATA; return -ENODATA;
ret = pmbus_read_word_data(client, 0, ret = pmbus_read_word_data(client, 0, 0xff,
ADM1075_VAUX_UV_WARN_LIMIT); ADM1075_VAUX_UV_WARN_LIMIT);
break; break;
case PMBUS_READ_VOUT: case PMBUS_READ_VOUT:
if (data->have_vout) if (data->have_vout)
return -ENODATA; return -ENODATA;
ret = pmbus_read_word_data(client, 0, ADM1075_READ_VAUX); ret = pmbus_read_word_data(client, 0, 0xff,
ADM1075_READ_VAUX);
break; break;
case PMBUS_VIRT_READ_IOUT_MIN: case PMBUS_VIRT_READ_IOUT_MIN:
if (!data->have_iout_min) if (!data->have_iout_min)
return -ENXIO; return -ENXIO;
ret = pmbus_read_word_data(client, 0, ADM1293_IOUT_MIN); ret = pmbus_read_word_data(client, 0, 0xff,
ADM1293_IOUT_MIN);
break; break;
case PMBUS_VIRT_READ_IOUT_MAX: case PMBUS_VIRT_READ_IOUT_MAX:
ret = pmbus_read_word_data(client, 0, ADM1275_PEAK_IOUT); ret = pmbus_read_word_data(client, 0, 0xff,
ADM1275_PEAK_IOUT);
break; break;
case PMBUS_VIRT_READ_VOUT_MAX: case PMBUS_VIRT_READ_VOUT_MAX:
ret = pmbus_read_word_data(client, 0, ADM1275_PEAK_VOUT); ret = pmbus_read_word_data(client, 0, 0xff,
ADM1275_PEAK_VOUT);
break; break;
case PMBUS_VIRT_READ_VIN_MAX: case PMBUS_VIRT_READ_VIN_MAX:
ret = pmbus_read_word_data(client, 0, ADM1275_PEAK_VIN); ret = pmbus_read_word_data(client, 0, 0xff,
ADM1275_PEAK_VIN);
break; break;
case PMBUS_VIRT_READ_PIN_MIN: case PMBUS_VIRT_READ_PIN_MIN:
if (!data->have_pin_min) if (!data->have_pin_min)
return -ENXIO; return -ENXIO;
ret = pmbus_read_word_data(client, 0, ADM1293_PIN_MIN); ret = pmbus_read_word_data(client, 0, 0xff,
ADM1293_PIN_MIN);
break; break;
case PMBUS_VIRT_READ_PIN_MAX: case PMBUS_VIRT_READ_PIN_MAX:
if (!data->have_pin_max) if (!data->have_pin_max)
return -ENXIO; return -ENXIO;
ret = pmbus_read_word_data(client, 0, ADM1276_PEAK_PIN); ret = pmbus_read_word_data(client, 0, 0xff,
ADM1276_PEAK_PIN);
break; break;
case PMBUS_VIRT_READ_TEMP_MAX: case PMBUS_VIRT_READ_TEMP_MAX:
if (!data->have_temp_max) if (!data->have_temp_max)
return -ENXIO; return -ENXIO;
ret = pmbus_read_word_data(client, 0, ADM1278_PEAK_TEMP); ret = pmbus_read_word_data(client, 0, 0xff,
ADM1278_PEAK_TEMP);
break; break;
case PMBUS_VIRT_RESET_IOUT_HISTORY: case PMBUS_VIRT_RESET_IOUT_HISTORY:
case PMBUS_VIRT_RESET_VOUT_HISTORY: case PMBUS_VIRT_RESET_VOUT_HISTORY:
......
...@@ -148,7 +148,7 @@ static ssize_t ibm_cffps_debugfs_read(struct file *file, char __user *buf, ...@@ -148,7 +148,7 @@ static ssize_t ibm_cffps_debugfs_read(struct file *file, char __user *buf,
struct ibm_cffps *psu = to_psu(idxp, idx); struct ibm_cffps *psu = to_psu(idxp, idx);
char data[I2C_SMBUS_BLOCK_MAX + 2] = { 0 }; char data[I2C_SMBUS_BLOCK_MAX + 2] = { 0 };
pmbus_set_page(psu->client, 0); pmbus_set_page(psu->client, 0, 0xff);
switch (idx) { switch (idx) {
case CFFPS_DEBUGFS_INPUT_HISTORY: case CFFPS_DEBUGFS_INPUT_HISTORY:
...@@ -247,7 +247,7 @@ static ssize_t ibm_cffps_debugfs_write(struct file *file, ...@@ -247,7 +247,7 @@ static ssize_t ibm_cffps_debugfs_write(struct file *file,
switch (idx) { switch (idx) {
case CFFPS_DEBUGFS_ON_OFF_CONFIG: case CFFPS_DEBUGFS_ON_OFF_CONFIG:
pmbus_set_page(psu->client, 0); pmbus_set_page(psu->client, 0, 0xff);
rc = simple_write_to_buffer(&data, 1, ppos, buf, count); rc = simple_write_to_buffer(&data, 1, ppos, buf, count);
if (rc <= 0) if (rc <= 0)
...@@ -325,13 +325,13 @@ static int ibm_cffps_read_byte_data(struct i2c_client *client, int page, ...@@ -325,13 +325,13 @@ static int ibm_cffps_read_byte_data(struct i2c_client *client, int page,
} }
static int ibm_cffps_read_word_data(struct i2c_client *client, int page, static int ibm_cffps_read_word_data(struct i2c_client *client, int page,
int reg) int phase, int reg)
{ {
int rc, mfr; int rc, mfr;
switch (reg) { switch (reg) {
case PMBUS_STATUS_WORD: case PMBUS_STATUS_WORD:
rc = pmbus_read_word_data(client, page, reg); rc = pmbus_read_word_data(client, page, phase, reg);
if (rc < 0) if (rc < 0)
return rc; return rc;
...@@ -348,7 +348,8 @@ static int ibm_cffps_read_word_data(struct i2c_client *client, int page, ...@@ -348,7 +348,8 @@ static int ibm_cffps_read_word_data(struct i2c_client *client, int page,
rc |= PB_STATUS_OFF; rc |= PB_STATUS_OFF;
break; break;
case PMBUS_VIRT_READ_VMON: case PMBUS_VIRT_READ_VMON:
rc = pmbus_read_word_data(client, page, CFFPS_12VCS_VOUT_CMD); rc = pmbus_read_word_data(client, page, phase,
CFFPS_12VCS_VOUT_CMD);
break; break;
default: default:
rc = -ENODATA; rc = -ENODATA;
...@@ -379,7 +380,7 @@ static int ibm_cffps_led_brightness_set(struct led_classdev *led_cdev, ...@@ -379,7 +380,7 @@ static int ibm_cffps_led_brightness_set(struct led_classdev *led_cdev,
dev_dbg(&psu->client->dev, "LED brightness set: %d. Command: %d.\n", dev_dbg(&psu->client->dev, "LED brightness set: %d. Command: %d.\n",
brightness, next_led_state); brightness, next_led_state);
pmbus_set_page(psu->client, 0); pmbus_set_page(psu->client, 0, 0xff);
rc = i2c_smbus_write_byte_data(psu->client, CFFPS_SYS_CONFIG_CMD, rc = i2c_smbus_write_byte_data(psu->client, CFFPS_SYS_CONFIG_CMD,
next_led_state); next_led_state);
...@@ -401,7 +402,7 @@ static int ibm_cffps_led_blink_set(struct led_classdev *led_cdev, ...@@ -401,7 +402,7 @@ static int ibm_cffps_led_blink_set(struct led_classdev *led_cdev,
dev_dbg(&psu->client->dev, "LED blink set.\n"); dev_dbg(&psu->client->dev, "LED blink set.\n");
pmbus_set_page(psu->client, 0); pmbus_set_page(psu->client, 0, 0xff);
rc = i2c_smbus_write_byte_data(psu->client, CFFPS_SYS_CONFIG_CMD, rc = i2c_smbus_write_byte_data(psu->client, CFFPS_SYS_CONFIG_CMD,
CFFPS_LED_BLINK); CFFPS_LED_BLINK);
......
...@@ -21,37 +21,42 @@ ...@@ -21,37 +21,42 @@
#define IR35221_MFR_IOUT_VALLEY 0xcb #define IR35221_MFR_IOUT_VALLEY 0xcb
#define IR35221_MFR_TEMP_VALLEY 0xcc #define IR35221_MFR_TEMP_VALLEY 0xcc
static int ir35221_read_word_data(struct i2c_client *client, int page, int reg) static int ir35221_read_word_data(struct i2c_client *client, int page,
int phase, int reg)
{ {
int ret; int ret;
switch (reg) { switch (reg) {
case PMBUS_VIRT_READ_VIN_MAX: case PMBUS_VIRT_READ_VIN_MAX:
ret = pmbus_read_word_data(client, page, IR35221_MFR_VIN_PEAK); ret = pmbus_read_word_data(client, page, phase,
IR35221_MFR_VIN_PEAK);
break; break;
case PMBUS_VIRT_READ_VOUT_MAX: case PMBUS_VIRT_READ_VOUT_MAX:
ret = pmbus_read_word_data(client, page, IR35221_MFR_VOUT_PEAK); ret = pmbus_read_word_data(client, page, phase,
IR35221_MFR_VOUT_PEAK);
break; break;
case PMBUS_VIRT_READ_IOUT_MAX: case PMBUS_VIRT_READ_IOUT_MAX:
ret = pmbus_read_word_data(client, page, IR35221_MFR_IOUT_PEAK); ret = pmbus_read_word_data(client, page, phase,
IR35221_MFR_IOUT_PEAK);
break; break;
case PMBUS_VIRT_READ_TEMP_MAX: case PMBUS_VIRT_READ_TEMP_MAX:
ret = pmbus_read_word_data(client, page, IR35221_MFR_TEMP_PEAK); ret = pmbus_read_word_data(client, page, phase,
IR35221_MFR_TEMP_PEAK);
break; break;
case PMBUS_VIRT_READ_VIN_MIN: case PMBUS_VIRT_READ_VIN_MIN:
ret = pmbus_read_word_data(client, page, ret = pmbus_read_word_data(client, page, phase,
IR35221_MFR_VIN_VALLEY); IR35221_MFR_VIN_VALLEY);
break; break;
case PMBUS_VIRT_READ_VOUT_MIN: case PMBUS_VIRT_READ_VOUT_MIN:
ret = pmbus_read_word_data(client, page, ret = pmbus_read_word_data(client, page, phase,
IR35221_MFR_VOUT_VALLEY); IR35221_MFR_VOUT_VALLEY);
break; break;
case PMBUS_VIRT_READ_IOUT_MIN: case PMBUS_VIRT_READ_IOUT_MIN:
ret = pmbus_read_word_data(client, page, ret = pmbus_read_word_data(client, page, phase,
IR35221_MFR_IOUT_VALLEY); IR35221_MFR_IOUT_VALLEY);
break; break;
case PMBUS_VIRT_READ_TEMP_MIN: case PMBUS_VIRT_READ_TEMP_MIN:
ret = pmbus_read_word_data(client, page, ret = pmbus_read_word_data(client, page, phase,
IR35221_MFR_TEMP_VALLEY); IR35221_MFR_TEMP_VALLEY);
break; break;
default: default:
......
...@@ -49,7 +49,8 @@ static ssize_t isl68137_avs_enable_store_page(struct i2c_client *client, ...@@ -49,7 +49,8 @@ static ssize_t isl68137_avs_enable_store_page(struct i2c_client *client,
* enabling AVS control is the workaround. * enabling AVS control is the workaround.
*/ */
if (op_val == ISL68137_VOUT_AVS) { if (op_val == ISL68137_VOUT_AVS) {
rc = pmbus_read_word_data(client, page, PMBUS_VOUT_COMMAND); rc = pmbus_read_word_data(client, page, 0xff,
PMBUS_VOUT_COMMAND);
if (rc < 0) if (rc < 0)
return rc; return rc;
......
...@@ -211,7 +211,8 @@ struct lm25066_data { ...@@ -211,7 +211,8 @@ struct lm25066_data {
#define to_lm25066_data(x) container_of(x, struct lm25066_data, info) #define to_lm25066_data(x) container_of(x, struct lm25066_data, info)
static int lm25066_read_word_data(struct i2c_client *client, int page, int reg) static int lm25066_read_word_data(struct i2c_client *client, int page,
int phase, int reg)
{ {
const struct pmbus_driver_info *info = pmbus_get_driver_info(client); const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
const struct lm25066_data *data = to_lm25066_data(info); const struct lm25066_data *data = to_lm25066_data(info);
...@@ -219,7 +220,7 @@ static int lm25066_read_word_data(struct i2c_client *client, int page, int reg) ...@@ -219,7 +220,7 @@ static int lm25066_read_word_data(struct i2c_client *client, int page, int reg)
switch (reg) { switch (reg) {
case PMBUS_VIRT_READ_VMON: case PMBUS_VIRT_READ_VMON:
ret = pmbus_read_word_data(client, 0, LM25066_READ_VAUX); ret = pmbus_read_word_data(client, 0, 0xff, LM25066_READ_VAUX);
if (ret < 0) if (ret < 0)
break; break;
/* Adjust returned value to match VIN coefficients */ /* Adjust returned value to match VIN coefficients */
...@@ -244,33 +245,40 @@ static int lm25066_read_word_data(struct i2c_client *client, int page, int reg) ...@@ -244,33 +245,40 @@ static int lm25066_read_word_data(struct i2c_client *client, int page, int reg)
} }
break; break;
case PMBUS_READ_IIN: case PMBUS_READ_IIN:
ret = pmbus_read_word_data(client, 0, LM25066_MFR_READ_IIN); ret = pmbus_read_word_data(client, 0, 0xff,
LM25066_MFR_READ_IIN);
break; break;
case PMBUS_READ_PIN: case PMBUS_READ_PIN:
ret = pmbus_read_word_data(client, 0, LM25066_MFR_READ_PIN); ret = pmbus_read_word_data(client, 0, 0xff,
LM25066_MFR_READ_PIN);
break; break;
case PMBUS_IIN_OC_WARN_LIMIT: case PMBUS_IIN_OC_WARN_LIMIT:
ret = pmbus_read_word_data(client, 0, ret = pmbus_read_word_data(client, 0, 0xff,
LM25066_MFR_IIN_OC_WARN_LIMIT); LM25066_MFR_IIN_OC_WARN_LIMIT);
break; break;
case PMBUS_PIN_OP_WARN_LIMIT: case PMBUS_PIN_OP_WARN_LIMIT:
ret = pmbus_read_word_data(client, 0, ret = pmbus_read_word_data(client, 0, 0xff,
LM25066_MFR_PIN_OP_WARN_LIMIT); LM25066_MFR_PIN_OP_WARN_LIMIT);
break; break;
case PMBUS_VIRT_READ_VIN_AVG: case PMBUS_VIRT_READ_VIN_AVG:
ret = pmbus_read_word_data(client, 0, LM25066_READ_AVG_VIN); ret = pmbus_read_word_data(client, 0, 0xff,
LM25066_READ_AVG_VIN);
break; break;
case PMBUS_VIRT_READ_VOUT_AVG: case PMBUS_VIRT_READ_VOUT_AVG:
ret = pmbus_read_word_data(client, 0, LM25066_READ_AVG_VOUT); ret = pmbus_read_word_data(client, 0, 0xff,
LM25066_READ_AVG_VOUT);
break; break;
case PMBUS_VIRT_READ_IIN_AVG: case PMBUS_VIRT_READ_IIN_AVG:
ret = pmbus_read_word_data(client, 0, LM25066_READ_AVG_IIN); ret = pmbus_read_word_data(client, 0, 0xff,
LM25066_READ_AVG_IIN);
break; break;
case PMBUS_VIRT_READ_PIN_AVG: case PMBUS_VIRT_READ_PIN_AVG:
ret = pmbus_read_word_data(client, 0, LM25066_READ_AVG_PIN); ret = pmbus_read_word_data(client, 0, 0xff,
LM25066_READ_AVG_PIN);
break; break;
case PMBUS_VIRT_READ_PIN_MAX: case PMBUS_VIRT_READ_PIN_MAX:
ret = pmbus_read_word_data(client, 0, LM25066_READ_PIN_PEAK); ret = pmbus_read_word_data(client, 0, 0xff,
LM25066_READ_PIN_PEAK);
break; break;
case PMBUS_VIRT_RESET_PIN_HISTORY: case PMBUS_VIRT_RESET_PIN_HISTORY:
ret = 0; ret = 0;
...@@ -288,13 +296,14 @@ static int lm25066_read_word_data(struct i2c_client *client, int page, int reg) ...@@ -288,13 +296,14 @@ static int lm25066_read_word_data(struct i2c_client *client, int page, int reg)
return ret; return ret;
} }
static int lm25056_read_word_data(struct i2c_client *client, int page, int reg) static int lm25056_read_word_data(struct i2c_client *client, int page,
int phase, int reg)
{ {
int ret; int ret;
switch (reg) { switch (reg) {
case PMBUS_VIRT_VMON_UV_WARN_LIMIT: case PMBUS_VIRT_VMON_UV_WARN_LIMIT:
ret = pmbus_read_word_data(client, 0, ret = pmbus_read_word_data(client, 0, 0xff,
LM25056_VAUX_UV_WARN_LIMIT); LM25056_VAUX_UV_WARN_LIMIT);
if (ret < 0) if (ret < 0)
break; break;
...@@ -302,7 +311,7 @@ static int lm25056_read_word_data(struct i2c_client *client, int page, int reg) ...@@ -302,7 +311,7 @@ static int lm25056_read_word_data(struct i2c_client *client, int page, int reg)
ret = DIV_ROUND_CLOSEST(ret * 293, 6140); ret = DIV_ROUND_CLOSEST(ret * 293, 6140);
break; break;
case PMBUS_VIRT_VMON_OV_WARN_LIMIT: case PMBUS_VIRT_VMON_OV_WARN_LIMIT:
ret = pmbus_read_word_data(client, 0, ret = pmbus_read_word_data(client, 0, 0xff,
LM25056_VAUX_OV_WARN_LIMIT); LM25056_VAUX_OV_WARN_LIMIT);
if (ret < 0) if (ret < 0)
break; break;
...@@ -310,7 +319,7 @@ static int lm25056_read_word_data(struct i2c_client *client, int page, int reg) ...@@ -310,7 +319,7 @@ static int lm25056_read_word_data(struct i2c_client *client, int page, int reg)
ret = DIV_ROUND_CLOSEST(ret * 293, 6140); ret = DIV_ROUND_CLOSEST(ret * 293, 6140);
break; break;
default: default:
ret = lm25066_read_word_data(client, page, reg); ret = lm25066_read_word_data(client, page, phase, reg);
break; break;
} }
return ret; return ret;
......
...@@ -173,7 +173,8 @@ static int ltc_wait_ready(struct i2c_client *client) ...@@ -173,7 +173,8 @@ static int ltc_wait_ready(struct i2c_client *client)
return -ETIMEDOUT; return -ETIMEDOUT;
} }
static int ltc_read_word_data(struct i2c_client *client, int page, int reg) static int ltc_read_word_data(struct i2c_client *client, int page, int phase,
int reg)
{ {
int ret; int ret;
...@@ -181,7 +182,7 @@ static int ltc_read_word_data(struct i2c_client *client, int page, int reg) ...@@ -181,7 +182,7 @@ static int ltc_read_word_data(struct i2c_client *client, int page, int reg)
if (ret < 0) if (ret < 0)
return ret; return ret;
return pmbus_read_word_data(client, page, reg); return pmbus_read_word_data(client, page, 0xff, reg);
} }
static int ltc_read_byte_data(struct i2c_client *client, int page, int reg) static int ltc_read_byte_data(struct i2c_client *client, int page, int reg)
...@@ -224,7 +225,7 @@ static int ltc_get_max(struct ltc2978_data *data, struct i2c_client *client, ...@@ -224,7 +225,7 @@ static int ltc_get_max(struct ltc2978_data *data, struct i2c_client *client,
{ {
int ret; int ret;
ret = ltc_read_word_data(client, page, reg); ret = ltc_read_word_data(client, page, 0xff, reg);
if (ret >= 0) { if (ret >= 0) {
if (lin11_to_val(ret) > lin11_to_val(*pmax)) if (lin11_to_val(ret) > lin11_to_val(*pmax))
*pmax = ret; *pmax = ret;
...@@ -238,7 +239,7 @@ static int ltc_get_min(struct ltc2978_data *data, struct i2c_client *client, ...@@ -238,7 +239,7 @@ static int ltc_get_min(struct ltc2978_data *data, struct i2c_client *client,
{ {
int ret; int ret;
ret = ltc_read_word_data(client, page, reg); ret = ltc_read_word_data(client, page, 0xff, reg);
if (ret >= 0) { if (ret >= 0) {
if (lin11_to_val(ret) < lin11_to_val(*pmin)) if (lin11_to_val(ret) < lin11_to_val(*pmin))
*pmin = ret; *pmin = ret;
...@@ -260,7 +261,8 @@ static int ltc2978_read_word_data_common(struct i2c_client *client, int page, ...@@ -260,7 +261,8 @@ static int ltc2978_read_word_data_common(struct i2c_client *client, int page,
&data->vin_max); &data->vin_max);
break; break;
case PMBUS_VIRT_READ_VOUT_MAX: case PMBUS_VIRT_READ_VOUT_MAX:
ret = ltc_read_word_data(client, page, LTC2978_MFR_VOUT_PEAK); ret = ltc_read_word_data(client, page, 0xff,
LTC2978_MFR_VOUT_PEAK);
if (ret >= 0) { if (ret >= 0) {
/* /*
* VOUT is 16 bit unsigned with fixed exponent, * VOUT is 16 bit unsigned with fixed exponent,
...@@ -291,7 +293,8 @@ static int ltc2978_read_word_data_common(struct i2c_client *client, int page, ...@@ -291,7 +293,8 @@ static int ltc2978_read_word_data_common(struct i2c_client *client, int page,
return ret; return ret;
} }
static int ltc2978_read_word_data(struct i2c_client *client, int page, int reg) static int ltc2978_read_word_data(struct i2c_client *client, int page,
int phase, int reg)
{ {
const struct pmbus_driver_info *info = pmbus_get_driver_info(client); const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
struct ltc2978_data *data = to_ltc2978_data(info); struct ltc2978_data *data = to_ltc2978_data(info);
...@@ -303,7 +306,8 @@ static int ltc2978_read_word_data(struct i2c_client *client, int page, int reg) ...@@ -303,7 +306,8 @@ static int ltc2978_read_word_data(struct i2c_client *client, int page, int reg)
&data->vin_min); &data->vin_min);
break; break;
case PMBUS_VIRT_READ_VOUT_MIN: case PMBUS_VIRT_READ_VOUT_MIN:
ret = ltc_read_word_data(client, page, LTC2978_MFR_VOUT_MIN); ret = ltc_read_word_data(client, page, phase,
LTC2978_MFR_VOUT_MIN);
if (ret >= 0) { if (ret >= 0) {
/* /*
* VOUT_MIN is known to not be supported on some lots * VOUT_MIN is known to not be supported on some lots
...@@ -336,7 +340,8 @@ static int ltc2978_read_word_data(struct i2c_client *client, int page, int reg) ...@@ -336,7 +340,8 @@ static int ltc2978_read_word_data(struct i2c_client *client, int page, int reg)
return ret; return ret;
} }
static int ltc2974_read_word_data(struct i2c_client *client, int page, int reg) static int ltc2974_read_word_data(struct i2c_client *client, int page,
int phase, int reg)
{ {
const struct pmbus_driver_info *info = pmbus_get_driver_info(client); const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
struct ltc2978_data *data = to_ltc2978_data(info); struct ltc2978_data *data = to_ltc2978_data(info);
...@@ -355,13 +360,14 @@ static int ltc2974_read_word_data(struct i2c_client *client, int page, int reg) ...@@ -355,13 +360,14 @@ static int ltc2974_read_word_data(struct i2c_client *client, int page, int reg)
ret = 0; ret = 0;
break; break;
default: default:
ret = ltc2978_read_word_data(client, page, reg); ret = ltc2978_read_word_data(client, page, phase, reg);
break; break;
} }
return ret; return ret;
} }
static int ltc2975_read_word_data(struct i2c_client *client, int page, int reg) static int ltc2975_read_word_data(struct i2c_client *client, int page,
int phase, int reg)
{ {
const struct pmbus_driver_info *info = pmbus_get_driver_info(client); const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
struct ltc2978_data *data = to_ltc2978_data(info); struct ltc2978_data *data = to_ltc2978_data(info);
...@@ -389,13 +395,14 @@ static int ltc2975_read_word_data(struct i2c_client *client, int page, int reg) ...@@ -389,13 +395,14 @@ static int ltc2975_read_word_data(struct i2c_client *client, int page, int reg)
ret = 0; ret = 0;
break; break;
default: default:
ret = ltc2978_read_word_data(client, page, reg); ret = ltc2978_read_word_data(client, page, phase, reg);
break; break;
} }
return ret; return ret;
} }
static int ltc3880_read_word_data(struct i2c_client *client, int page, int reg) static int ltc3880_read_word_data(struct i2c_client *client, int page,
int phase, int reg)
{ {
const struct pmbus_driver_info *info = pmbus_get_driver_info(client); const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
struct ltc2978_data *data = to_ltc2978_data(info); struct ltc2978_data *data = to_ltc2978_data(info);
...@@ -427,7 +434,8 @@ static int ltc3880_read_word_data(struct i2c_client *client, int page, int reg) ...@@ -427,7 +434,8 @@ static int ltc3880_read_word_data(struct i2c_client *client, int page, int reg)
return ret; return ret;
} }
static int ltc3883_read_word_data(struct i2c_client *client, int page, int reg) static int ltc3883_read_word_data(struct i2c_client *client, int page,
int phase, int reg)
{ {
const struct pmbus_driver_info *info = pmbus_get_driver_info(client); const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
struct ltc2978_data *data = to_ltc2978_data(info); struct ltc2978_data *data = to_ltc2978_data(info);
...@@ -442,7 +450,7 @@ static int ltc3883_read_word_data(struct i2c_client *client, int page, int reg) ...@@ -442,7 +450,7 @@ static int ltc3883_read_word_data(struct i2c_client *client, int page, int reg)
ret = 0; ret = 0;
break; break;
default: default:
ret = ltc3880_read_word_data(client, page, reg); ret = ltc3880_read_word_data(client, page, phase, reg);
break; break;
} }
return ret; return ret;
......
...@@ -55,7 +55,7 @@ static int ltc3815_write_byte(struct i2c_client *client, int page, u8 reg) ...@@ -55,7 +55,7 @@ static int ltc3815_write_byte(struct i2c_client *client, int page, u8 reg)
* LTC3815 does not support the CLEAR_FAULTS command. * LTC3815 does not support the CLEAR_FAULTS command.
* Emulate it by clearing the status register. * Emulate it by clearing the status register.
*/ */
ret = pmbus_read_word_data(client, 0, PMBUS_STATUS_WORD); ret = pmbus_read_word_data(client, 0, 0xff, PMBUS_STATUS_WORD);
if (ret > 0) { if (ret > 0) {
pmbus_write_word_data(client, 0, PMBUS_STATUS_WORD, pmbus_write_word_data(client, 0, PMBUS_STATUS_WORD,
ret); ret);
...@@ -69,25 +69,31 @@ static int ltc3815_write_byte(struct i2c_client *client, int page, u8 reg) ...@@ -69,25 +69,31 @@ static int ltc3815_write_byte(struct i2c_client *client, int page, u8 reg)
return ret; return ret;
} }
static int ltc3815_read_word_data(struct i2c_client *client, int page, int reg) static int ltc3815_read_word_data(struct i2c_client *client, int page,
int phase, int reg)
{ {
int ret; int ret;
switch (reg) { switch (reg) {
case PMBUS_VIRT_READ_VIN_MAX: case PMBUS_VIRT_READ_VIN_MAX:
ret = pmbus_read_word_data(client, page, LTC3815_MFR_VIN_PEAK); ret = pmbus_read_word_data(client, page, phase,
LTC3815_MFR_VIN_PEAK);
break; break;
case PMBUS_VIRT_READ_VOUT_MAX: case PMBUS_VIRT_READ_VOUT_MAX:
ret = pmbus_read_word_data(client, page, LTC3815_MFR_VOUT_PEAK); ret = pmbus_read_word_data(client, page, phase,
LTC3815_MFR_VOUT_PEAK);
break; break;
case PMBUS_VIRT_READ_TEMP_MAX: case PMBUS_VIRT_READ_TEMP_MAX:
ret = pmbus_read_word_data(client, page, LTC3815_MFR_TEMP_PEAK); ret = pmbus_read_word_data(client, page, phase,
LTC3815_MFR_TEMP_PEAK);
break; break;
case PMBUS_VIRT_READ_IOUT_MAX: case PMBUS_VIRT_READ_IOUT_MAX:
ret = pmbus_read_word_data(client, page, LTC3815_MFR_IOUT_PEAK); ret = pmbus_read_word_data(client, page, phase,
LTC3815_MFR_IOUT_PEAK);
break; break;
case PMBUS_VIRT_READ_IIN_MAX: case PMBUS_VIRT_READ_IIN_MAX:
ret = pmbus_read_word_data(client, page, LTC3815_MFR_IIN_PEAK); ret = pmbus_read_word_data(client, page, phase,
LTC3815_MFR_IIN_PEAK);
break; break;
case PMBUS_VIRT_RESET_VOUT_HISTORY: case PMBUS_VIRT_RESET_VOUT_HISTORY:
case PMBUS_VIRT_RESET_VIN_HISTORY: case PMBUS_VIRT_RESET_VIN_HISTORY:
......
...@@ -15,17 +15,18 @@ ...@@ -15,17 +15,18 @@
#define MAX16064_MFR_VOUT_PEAK 0xd4 #define MAX16064_MFR_VOUT_PEAK 0xd4
#define MAX16064_MFR_TEMPERATURE_PEAK 0xd6 #define MAX16064_MFR_TEMPERATURE_PEAK 0xd6
static int max16064_read_word_data(struct i2c_client *client, int page, int reg) static int max16064_read_word_data(struct i2c_client *client, int page,
int phase, int reg)
{ {
int ret; int ret;
switch (reg) { switch (reg) {
case PMBUS_VIRT_READ_VOUT_MAX: case PMBUS_VIRT_READ_VOUT_MAX:
ret = pmbus_read_word_data(client, page, ret = pmbus_read_word_data(client, page, phase,
MAX16064_MFR_VOUT_PEAK); MAX16064_MFR_VOUT_PEAK);
break; break;
case PMBUS_VIRT_READ_TEMP_MAX: case PMBUS_VIRT_READ_TEMP_MAX:
ret = pmbus_read_word_data(client, page, ret = pmbus_read_word_data(client, page, phase,
MAX16064_MFR_TEMPERATURE_PEAK); MAX16064_MFR_TEMPERATURE_PEAK);
break; break;
case PMBUS_VIRT_RESET_VOUT_HISTORY: case PMBUS_VIRT_RESET_VOUT_HISTORY:
......
...@@ -85,7 +85,8 @@ static u32 max_current[][5] = { ...@@ -85,7 +85,8 @@ static u32 max_current[][5] = {
[max20743] = { 18900, 24100, 29200, 34100 }, [max20743] = { 18900, 24100, 29200, 34100 },
}; };
static int max20730_read_word_data(struct i2c_client *client, int page, int reg) static int max20730_read_word_data(struct i2c_client *client, int page,
int phase, int reg)
{ {
const struct pmbus_driver_info *info = pmbus_get_driver_info(client); const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
const struct max20730_data *data = to_max20730_data(info); const struct max20730_data *data = to_max20730_data(info);
......
...@@ -72,7 +72,7 @@ static int max31785_read_long_data(struct i2c_client *client, int page, ...@@ -72,7 +72,7 @@ static int max31785_read_long_data(struct i2c_client *client, int page,
cmdbuf[0] = reg; cmdbuf[0] = reg;
rc = pmbus_set_page(client, page); rc = pmbus_set_page(client, page, 0xff);
if (rc < 0) if (rc < 0)
return rc; return rc;
...@@ -110,7 +110,7 @@ static int max31785_get_pwm_mode(struct i2c_client *client, int page) ...@@ -110,7 +110,7 @@ static int max31785_get_pwm_mode(struct i2c_client *client, int page)
if (config < 0) if (config < 0)
return config; return config;
command = pmbus_read_word_data(client, page, PMBUS_FAN_COMMAND_1); command = pmbus_read_word_data(client, page, 0xff, PMBUS_FAN_COMMAND_1);
if (command < 0) if (command < 0)
return command; return command;
...@@ -126,7 +126,7 @@ static int max31785_get_pwm_mode(struct i2c_client *client, int page) ...@@ -126,7 +126,7 @@ static int max31785_get_pwm_mode(struct i2c_client *client, int page)
} }
static int max31785_read_word_data(struct i2c_client *client, int page, static int max31785_read_word_data(struct i2c_client *client, int page,
int reg) int phase, int reg)
{ {
u32 val; u32 val;
int rv; int rv;
......
...@@ -41,7 +41,8 @@ struct max34440_data { ...@@ -41,7 +41,8 @@ struct max34440_data {
#define to_max34440_data(x) container_of(x, struct max34440_data, info) #define to_max34440_data(x) container_of(x, struct max34440_data, info)
static int max34440_read_word_data(struct i2c_client *client, int page, int reg) static int max34440_read_word_data(struct i2c_client *client, int page,
int phase, int reg)
{ {
int ret; int ret;
const struct pmbus_driver_info *info = pmbus_get_driver_info(client); const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
...@@ -49,44 +50,44 @@ static int max34440_read_word_data(struct i2c_client *client, int page, int reg) ...@@ -49,44 +50,44 @@ static int max34440_read_word_data(struct i2c_client *client, int page, int reg)
switch (reg) { switch (reg) {
case PMBUS_VIRT_READ_VOUT_MIN: case PMBUS_VIRT_READ_VOUT_MIN:
ret = pmbus_read_word_data(client, page, ret = pmbus_read_word_data(client, page, phase,
MAX34440_MFR_VOUT_MIN); MAX34440_MFR_VOUT_MIN);
break; break;
case PMBUS_VIRT_READ_VOUT_MAX: case PMBUS_VIRT_READ_VOUT_MAX:
ret = pmbus_read_word_data(client, page, ret = pmbus_read_word_data(client, page, phase,
MAX34440_MFR_VOUT_PEAK); MAX34440_MFR_VOUT_PEAK);
break; break;
case PMBUS_VIRT_READ_IOUT_AVG: case PMBUS_VIRT_READ_IOUT_AVG:
if (data->id != max34446 && data->id != max34451) if (data->id != max34446 && data->id != max34451)
return -ENXIO; return -ENXIO;
ret = pmbus_read_word_data(client, page, ret = pmbus_read_word_data(client, page, phase,
MAX34446_MFR_IOUT_AVG); MAX34446_MFR_IOUT_AVG);
break; break;
case PMBUS_VIRT_READ_IOUT_MAX: case PMBUS_VIRT_READ_IOUT_MAX:
ret = pmbus_read_word_data(client, page, ret = pmbus_read_word_data(client, page, phase,
MAX34440_MFR_IOUT_PEAK); MAX34440_MFR_IOUT_PEAK);
break; break;
case PMBUS_VIRT_READ_POUT_AVG: case PMBUS_VIRT_READ_POUT_AVG:
if (data->id != max34446) if (data->id != max34446)
return -ENXIO; return -ENXIO;
ret = pmbus_read_word_data(client, page, ret = pmbus_read_word_data(client, page, phase,
MAX34446_MFR_POUT_AVG); MAX34446_MFR_POUT_AVG);
break; break;
case PMBUS_VIRT_READ_POUT_MAX: case PMBUS_VIRT_READ_POUT_MAX:
if (data->id != max34446) if (data->id != max34446)
return -ENXIO; return -ENXIO;
ret = pmbus_read_word_data(client, page, ret = pmbus_read_word_data(client, page, phase,
MAX34446_MFR_POUT_PEAK); MAX34446_MFR_POUT_PEAK);
break; break;
case PMBUS_VIRT_READ_TEMP_AVG: case PMBUS_VIRT_READ_TEMP_AVG:
if (data->id != max34446 && data->id != max34460 && if (data->id != max34446 && data->id != max34460 &&
data->id != max34461) data->id != max34461)
return -ENXIO; return -ENXIO;
ret = pmbus_read_word_data(client, page, ret = pmbus_read_word_data(client, page, phase,
MAX34446_MFR_TEMPERATURE_AVG); MAX34446_MFR_TEMPERATURE_AVG);
break; break;
case PMBUS_VIRT_READ_TEMP_MAX: case PMBUS_VIRT_READ_TEMP_MAX:
ret = pmbus_read_word_data(client, page, ret = pmbus_read_word_data(client, page, phase,
MAX34440_MFR_TEMPERATURE_PEAK); MAX34440_MFR_TEMPERATURE_PEAK);
break; break;
case PMBUS_VIRT_RESET_POUT_HISTORY: case PMBUS_VIRT_RESET_POUT_HISTORY:
...@@ -159,14 +160,14 @@ static int max34440_read_byte_data(struct i2c_client *client, int page, int reg) ...@@ -159,14 +160,14 @@ static int max34440_read_byte_data(struct i2c_client *client, int page, int reg)
int mfg_status; int mfg_status;
if (page >= 0) { if (page >= 0) {
ret = pmbus_set_page(client, page); ret = pmbus_set_page(client, page, 0xff);
if (ret < 0) if (ret < 0)
return ret; return ret;
} }
switch (reg) { switch (reg) {
case PMBUS_STATUS_IOUT: case PMBUS_STATUS_IOUT:
mfg_status = pmbus_read_word_data(client, 0, mfg_status = pmbus_read_word_data(client, 0, 0xff,
PMBUS_STATUS_MFR_SPECIFIC); PMBUS_STATUS_MFR_SPECIFIC);
if (mfg_status < 0) if (mfg_status < 0)
return mfg_status; return mfg_status;
...@@ -176,7 +177,7 @@ static int max34440_read_byte_data(struct i2c_client *client, int page, int reg) ...@@ -176,7 +177,7 @@ static int max34440_read_byte_data(struct i2c_client *client, int page, int reg)
ret |= PB_IOUT_OC_FAULT; ret |= PB_IOUT_OC_FAULT;
break; break;
case PMBUS_STATUS_TEMPERATURE: case PMBUS_STATUS_TEMPERATURE:
mfg_status = pmbus_read_word_data(client, 0, mfg_status = pmbus_read_word_data(client, 0, 0xff,
PMBUS_STATUS_MFR_SPECIFIC); PMBUS_STATUS_MFR_SPECIFIC);
if (mfg_status < 0) if (mfg_status < 0)
return mfg_status; return mfg_status;
......
...@@ -28,7 +28,8 @@ ...@@ -28,7 +28,8 @@
#define MAX8688_STATUS_OT_FAULT BIT(13) #define MAX8688_STATUS_OT_FAULT BIT(13)
#define MAX8688_STATUS_OT_WARNING BIT(14) #define MAX8688_STATUS_OT_WARNING BIT(14)
static int max8688_read_word_data(struct i2c_client *client, int page, int reg) static int max8688_read_word_data(struct i2c_client *client, int page,
int phase, int reg)
{ {
int ret; int ret;
...@@ -37,13 +38,15 @@ static int max8688_read_word_data(struct i2c_client *client, int page, int reg) ...@@ -37,13 +38,15 @@ static int max8688_read_word_data(struct i2c_client *client, int page, int reg)
switch (reg) { switch (reg) {
case PMBUS_VIRT_READ_VOUT_MAX: case PMBUS_VIRT_READ_VOUT_MAX:
ret = pmbus_read_word_data(client, 0, MAX8688_MFR_VOUT_PEAK); ret = pmbus_read_word_data(client, 0, 0xff,
MAX8688_MFR_VOUT_PEAK);
break; break;
case PMBUS_VIRT_READ_IOUT_MAX: case PMBUS_VIRT_READ_IOUT_MAX:
ret = pmbus_read_word_data(client, 0, MAX8688_MFR_IOUT_PEAK); ret = pmbus_read_word_data(client, 0, 0xff,
MAX8688_MFR_IOUT_PEAK);
break; break;
case PMBUS_VIRT_READ_TEMP_MAX: case PMBUS_VIRT_READ_TEMP_MAX:
ret = pmbus_read_word_data(client, 0, ret = pmbus_read_word_data(client, 0, 0xff,
MAX8688_MFR_TEMPERATURE_PEAK); MAX8688_MFR_TEMPERATURE_PEAK);
break; break;
case PMBUS_VIRT_RESET_VOUT_HISTORY: case PMBUS_VIRT_RESET_VOUT_HISTORY:
...@@ -94,7 +97,7 @@ static int max8688_read_byte_data(struct i2c_client *client, int page, int reg) ...@@ -94,7 +97,7 @@ static int max8688_read_byte_data(struct i2c_client *client, int page, int reg)
switch (reg) { switch (reg) {
case PMBUS_STATUS_VOUT: case PMBUS_STATUS_VOUT:
mfg_status = pmbus_read_word_data(client, 0, mfg_status = pmbus_read_word_data(client, 0, 0xff,
MAX8688_MFG_STATUS); MAX8688_MFG_STATUS);
if (mfg_status < 0) if (mfg_status < 0)
return mfg_status; return mfg_status;
...@@ -108,7 +111,7 @@ static int max8688_read_byte_data(struct i2c_client *client, int page, int reg) ...@@ -108,7 +111,7 @@ static int max8688_read_byte_data(struct i2c_client *client, int page, int reg)
ret |= PB_VOLTAGE_OV_FAULT; ret |= PB_VOLTAGE_OV_FAULT;
break; break;
case PMBUS_STATUS_IOUT: case PMBUS_STATUS_IOUT:
mfg_status = pmbus_read_word_data(client, 0, mfg_status = pmbus_read_word_data(client, 0, 0xff,
MAX8688_MFG_STATUS); MAX8688_MFG_STATUS);
if (mfg_status < 0) if (mfg_status < 0)
return mfg_status; return mfg_status;
...@@ -120,7 +123,7 @@ static int max8688_read_byte_data(struct i2c_client *client, int page, int reg) ...@@ -120,7 +123,7 @@ static int max8688_read_byte_data(struct i2c_client *client, int page, int reg)
ret |= PB_IOUT_OC_FAULT; ret |= PB_IOUT_OC_FAULT;
break; break;
case PMBUS_STATUS_TEMPERATURE: case PMBUS_STATUS_TEMPERATURE:
mfg_status = pmbus_read_word_data(client, 0, mfg_status = pmbus_read_word_data(client, 0, 0xff,
MAX8688_MFG_STATUS); MAX8688_MFG_STATUS);
if (mfg_status < 0) if (mfg_status < 0)
return mfg_status; return mfg_status;
......
...@@ -102,10 +102,10 @@ static int pmbus_identify(struct i2c_client *client, ...@@ -102,10 +102,10 @@ static int pmbus_identify(struct i2c_client *client,
int page; int page;
for (page = 1; page < PMBUS_PAGES; page++) { for (page = 1; page < PMBUS_PAGES; page++) {
if (pmbus_set_page(client, page) < 0) if (pmbus_set_page(client, page, 0xff) < 0)
break; break;
} }
pmbus_set_page(client, 0); pmbus_set_page(client, 0, 0xff);
info->pages = page; info->pages = page;
} else { } else {
info->pages = 1; info->pages = 1;
......
...@@ -418,7 +418,8 @@ struct pmbus_driver_info { ...@@ -418,7 +418,8 @@ struct pmbus_driver_info {
* the standard register. * the standard register.
*/ */
int (*read_byte_data)(struct i2c_client *client, int page, int reg); int (*read_byte_data)(struct i2c_client *client, int page, int reg);
int (*read_word_data)(struct i2c_client *client, int page, int reg); int (*read_word_data)(struct i2c_client *client, int page, int phase,
int reg);
int (*write_word_data)(struct i2c_client *client, int page, int reg, int (*write_word_data)(struct i2c_client *client, int page, int reg,
u16 word); u16 word);
int (*write_byte)(struct i2c_client *client, int page, u8 value); int (*write_byte)(struct i2c_client *client, int page, u8 value);
...@@ -457,9 +458,11 @@ extern const struct regulator_ops pmbus_regulator_ops; ...@@ -457,9 +458,11 @@ extern const struct regulator_ops pmbus_regulator_ops;
/* Function declarations */ /* Function declarations */
void pmbus_clear_cache(struct i2c_client *client); void pmbus_clear_cache(struct i2c_client *client);
int pmbus_set_page(struct i2c_client *client, int page); int pmbus_set_page(struct i2c_client *client, int page, int phase);
int pmbus_read_word_data(struct i2c_client *client, int page, u8 reg); int pmbus_read_word_data(struct i2c_client *client, int page, int phase,
int pmbus_write_word_data(struct i2c_client *client, int page, u8 reg, u16 word); u8 reg);
int pmbus_write_word_data(struct i2c_client *client, int page, u8 reg,
u16 word);
int pmbus_read_byte_data(struct i2c_client *client, int page, u8 reg); int pmbus_read_byte_data(struct i2c_client *client, int page, u8 reg);
int pmbus_write_byte(struct i2c_client *client, int page, u8 value); int pmbus_write_byte(struct i2c_client *client, int page, u8 value);
int pmbus_write_byte_data(struct i2c_client *client, int page, u8 reg, int pmbus_write_byte_data(struct i2c_client *client, int page, u8 reg,
......
...@@ -146,7 +146,7 @@ void pmbus_clear_cache(struct i2c_client *client) ...@@ -146,7 +146,7 @@ void pmbus_clear_cache(struct i2c_client *client)
} }
EXPORT_SYMBOL_GPL(pmbus_clear_cache); EXPORT_SYMBOL_GPL(pmbus_clear_cache);
int pmbus_set_page(struct i2c_client *client, int page) int pmbus_set_page(struct i2c_client *client, int page, int phase)
{ {
struct pmbus_data *data = i2c_get_clientdata(client); struct pmbus_data *data = i2c_get_clientdata(client);
int rv; int rv;
...@@ -177,7 +177,7 @@ int pmbus_write_byte(struct i2c_client *client, int page, u8 value) ...@@ -177,7 +177,7 @@ int pmbus_write_byte(struct i2c_client *client, int page, u8 value)
{ {
int rv; int rv;
rv = pmbus_set_page(client, page); rv = pmbus_set_page(client, page, 0xff);
if (rv < 0) if (rv < 0)
return rv; return rv;
...@@ -208,7 +208,7 @@ int pmbus_write_word_data(struct i2c_client *client, int page, u8 reg, ...@@ -208,7 +208,7 @@ int pmbus_write_word_data(struct i2c_client *client, int page, u8 reg,
{ {
int rv; int rv;
rv = pmbus_set_page(client, page); rv = pmbus_set_page(client, page, 0xff);
if (rv < 0) if (rv < 0)
return rv; return rv;
...@@ -286,11 +286,11 @@ int pmbus_update_fan(struct i2c_client *client, int page, int id, ...@@ -286,11 +286,11 @@ int pmbus_update_fan(struct i2c_client *client, int page, int id,
} }
EXPORT_SYMBOL_GPL(pmbus_update_fan); EXPORT_SYMBOL_GPL(pmbus_update_fan);
int pmbus_read_word_data(struct i2c_client *client, int page, u8 reg) int pmbus_read_word_data(struct i2c_client *client, int page, int phase, u8 reg)
{ {
int rv; int rv;
rv = pmbus_set_page(client, page); rv = pmbus_set_page(client, page, phase);
if (rv < 0) if (rv < 0)
return rv; return rv;
...@@ -320,14 +320,15 @@ static int pmbus_read_virt_reg(struct i2c_client *client, int page, int reg) ...@@ -320,14 +320,15 @@ static int pmbus_read_virt_reg(struct i2c_client *client, int page, int reg)
* _pmbus_read_word_data() is similar to pmbus_read_word_data(), but checks if * _pmbus_read_word_data() is similar to pmbus_read_word_data(), but checks if
* a device specific mapping function exists and calls it if necessary. * a device specific mapping function exists and calls it if necessary.
*/ */
static int _pmbus_read_word_data(struct i2c_client *client, int page, int reg) static int _pmbus_read_word_data(struct i2c_client *client, int page,
int phase, int reg)
{ {
struct pmbus_data *data = i2c_get_clientdata(client); struct pmbus_data *data = i2c_get_clientdata(client);
const struct pmbus_driver_info *info = data->info; const struct pmbus_driver_info *info = data->info;
int status; int status;
if (info->read_word_data) { if (info->read_word_data) {
status = info->read_word_data(client, page, reg); status = info->read_word_data(client, page, phase, reg);
if (status != -ENODATA) if (status != -ENODATA)
return status; return status;
} }
...@@ -335,14 +336,20 @@ static int _pmbus_read_word_data(struct i2c_client *client, int page, int reg) ...@@ -335,14 +336,20 @@ static int _pmbus_read_word_data(struct i2c_client *client, int page, int reg)
if (reg >= PMBUS_VIRT_BASE) if (reg >= PMBUS_VIRT_BASE)
return pmbus_read_virt_reg(client, page, reg); return pmbus_read_virt_reg(client, page, reg);
return pmbus_read_word_data(client, page, reg); return pmbus_read_word_data(client, page, phase, reg);
}
/* Same as above, but without phase parameter, for use in check functions */
static int __pmbus_read_word_data(struct i2c_client *client, int page, int reg)
{
return _pmbus_read_word_data(client, page, 0xff, reg);
} }
int pmbus_read_byte_data(struct i2c_client *client, int page, u8 reg) int pmbus_read_byte_data(struct i2c_client *client, int page, u8 reg)
{ {
int rv; int rv;
rv = pmbus_set_page(client, page); rv = pmbus_set_page(client, page, 0xff);
if (rv < 0) if (rv < 0)
return rv; return rv;
...@@ -354,7 +361,7 @@ int pmbus_write_byte_data(struct i2c_client *client, int page, u8 reg, u8 value) ...@@ -354,7 +361,7 @@ int pmbus_write_byte_data(struct i2c_client *client, int page, u8 reg, u8 value)
{ {
int rv; int rv;
rv = pmbus_set_page(client, page); rv = pmbus_set_page(client, page, 0xff);
if (rv < 0) if (rv < 0)
return rv; return rv;
...@@ -440,7 +447,7 @@ static int pmbus_get_fan_rate(struct i2c_client *client, int page, int id, ...@@ -440,7 +447,7 @@ static int pmbus_get_fan_rate(struct i2c_client *client, int page, int id,
have_rpm = !!(config & pmbus_fan_rpm_mask[id]); have_rpm = !!(config & pmbus_fan_rpm_mask[id]);
if (want_rpm == have_rpm) if (want_rpm == have_rpm)
return pmbus_read_word_data(client, page, return pmbus_read_word_data(client, page, 0xff,
pmbus_fan_command_registers[id]); pmbus_fan_command_registers[id]);
/* Can't sensibly map between RPM and PWM, just return zero */ /* Can't sensibly map between RPM and PWM, just return zero */
...@@ -530,7 +537,7 @@ EXPORT_SYMBOL_GPL(pmbus_check_byte_register); ...@@ -530,7 +537,7 @@ EXPORT_SYMBOL_GPL(pmbus_check_byte_register);
bool pmbus_check_word_register(struct i2c_client *client, int page, int reg) bool pmbus_check_word_register(struct i2c_client *client, int page, int reg)
{ {
return pmbus_check_register(client, _pmbus_read_word_data, page, reg); return pmbus_check_register(client, __pmbus_read_word_data, page, reg);
} }
EXPORT_SYMBOL_GPL(pmbus_check_word_register); EXPORT_SYMBOL_GPL(pmbus_check_word_register);
...@@ -595,6 +602,7 @@ static struct pmbus_data *pmbus_update_device(struct device *dev) ...@@ -595,6 +602,7 @@ static struct pmbus_data *pmbus_update_device(struct device *dev)
sensor->data sensor->data
= _pmbus_read_word_data(client, = _pmbus_read_word_data(client,
sensor->page, sensor->page,
0xff,
sensor->reg); sensor->reg);
} }
pmbus_clear_faults(client); pmbus_clear_faults(client);
...@@ -1964,7 +1972,7 @@ static ssize_t pmbus_show_samples(struct device *dev, ...@@ -1964,7 +1972,7 @@ static ssize_t pmbus_show_samples(struct device *dev,
struct i2c_client *client = to_i2c_client(dev->parent); struct i2c_client *client = to_i2c_client(dev->parent);
struct pmbus_samples_reg *reg = to_samples_reg(devattr); struct pmbus_samples_reg *reg = to_samples_reg(devattr);
val = _pmbus_read_word_data(client, reg->page, reg->attr->reg); val = _pmbus_read_word_data(client, reg->page, 0xff, reg->attr->reg);
if (val < 0) if (val < 0)
return val; return val;
...@@ -2120,7 +2128,7 @@ static int pmbus_read_status_byte(struct i2c_client *client, int page) ...@@ -2120,7 +2128,7 @@ static int pmbus_read_status_byte(struct i2c_client *client, int page)
static int pmbus_read_status_word(struct i2c_client *client, int page) static int pmbus_read_status_word(struct i2c_client *client, int page)
{ {
return _pmbus_read_word_data(client, page, PMBUS_STATUS_WORD); return _pmbus_read_word_data(client, page, 0xff, PMBUS_STATUS_WORD);
} }
static int pmbus_init_common(struct i2c_client *client, struct pmbus_data *data, static int pmbus_init_common(struct i2c_client *client, struct pmbus_data *data,
......
...@@ -370,7 +370,7 @@ static void ucd9000_probe_gpio(struct i2c_client *client, ...@@ -370,7 +370,7 @@ static void ucd9000_probe_gpio(struct i2c_client *client,
#ifdef CONFIG_DEBUG_FS #ifdef CONFIG_DEBUG_FS
static int ucd9000_get_mfr_status(struct i2c_client *client, u8 *buffer) static int ucd9000_get_mfr_status(struct i2c_client *client, u8 *buffer)
{ {
int ret = pmbus_set_page(client, 0); int ret = pmbus_set_page(client, 0, 0xff);
if (ret < 0) if (ret < 0)
return ret; return ret;
......
...@@ -18,7 +18,8 @@ ...@@ -18,7 +18,8 @@
#define XDPE122_AMD_625MV 0x10 /* AMD mode 6.25mV */ #define XDPE122_AMD_625MV 0x10 /* AMD mode 6.25mV */
#define XDPE122_PAGE_NUM 2 #define XDPE122_PAGE_NUM 2
static int xdpe122_read_word_data(struct i2c_client *client, int page, int reg) static int xdpe122_read_word_data(struct i2c_client *client, int page,
int phase, int reg)
{ {
const struct pmbus_driver_info *info = pmbus_get_driver_info(client); const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
long val; long val;
...@@ -29,7 +30,7 @@ static int xdpe122_read_word_data(struct i2c_client *client, int page, int reg) ...@@ -29,7 +30,7 @@ static int xdpe122_read_word_data(struct i2c_client *client, int page, int reg)
switch (reg) { switch (reg) {
case PMBUS_VOUT_OV_FAULT_LIMIT: case PMBUS_VOUT_OV_FAULT_LIMIT:
case PMBUS_VOUT_UV_FAULT_LIMIT: case PMBUS_VOUT_UV_FAULT_LIMIT:
ret = pmbus_read_word_data(client, page, reg); ret = pmbus_read_word_data(client, page, phase, reg);
if (ret < 0) if (ret < 0)
return ret; return ret;
......
...@@ -125,7 +125,8 @@ static inline void zl6100_wait(const struct zl6100_data *data) ...@@ -125,7 +125,8 @@ static inline void zl6100_wait(const struct zl6100_data *data)
} }
} }
static int zl6100_read_word_data(struct i2c_client *client, int page, int reg) static int zl6100_read_word_data(struct i2c_client *client, int page,
int phase, int reg)
{ {
const struct pmbus_driver_info *info = pmbus_get_driver_info(client); const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
struct zl6100_data *data = to_zl6100_data(info); struct zl6100_data *data = to_zl6100_data(info);
...@@ -167,7 +168,7 @@ static int zl6100_read_word_data(struct i2c_client *client, int page, int reg) ...@@ -167,7 +168,7 @@ static int zl6100_read_word_data(struct i2c_client *client, int page, int reg)
} }
zl6100_wait(data); zl6100_wait(data);
ret = pmbus_read_word_data(client, page, vreg); ret = pmbus_read_word_data(client, page, phase, vreg);
data->access = ktime_get(); data->access = ktime_get();
if (ret < 0) if (ret < 0)
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment