// SPDX-License-Identifier: GPL-2.0-or-later /* * Hardware monitoring driver for FSP 3Y-Power PSUs * * Copyright (c) 2021 Václav Kubernát, CESNET * * This driver is mostly reverse engineered with the help of a tool called pmbus_peek written by * David Brownell (and later adopted by Jan Kundrát). The device has some sort of a timing issue * when switching pages, details are explained in the code. The driver support is limited. It * exposes only the values, that have been tested to work correctly. Unsupported values either * aren't supported by the devices or their encondings are unknown.
*/
staticint page_log_to_page_real(int page_log, enum chips chip)
{ switch (chip) { case ym2151e: switch (page_log) { case YM2151_PAGE_12V_LOG: return YM2151_PAGE_12V_REAL; case YM2151_PAGE_5VSB_LOG: return YM2151_PAGE_5VSB_REAL;
} return -EINVAL; case yh5151e: switch (page_log) { case YH5151E_PAGE_12V_LOG: return YH5151E_PAGE_12V_REAL; case YH5151E_PAGE_5V_LOG: return YH5151E_PAGE_5V_REAL; case YH5151E_PAGE_3V3_LOG: return YH5151E_PAGE_3V3_REAL;
} return -EINVAL;
}
return -EINVAL;
}
staticint set_page(struct i2c_client *client, int page_log)
{ conststruct pmbus_driver_info *info = pmbus_get_driver_info(client); struct fsp3y_data *data = to_fsp3y_data(info); int rv; int page_real;
if (page_log < 0) return 0;
page_real = page_log_to_page_real(page_log, data->chip); if (page_real < 0) return page_real;
if (data->page != page_real) {
rv = i2c_smbus_write_byte_data(client, PMBUS_PAGE, page_real); if (rv < 0) return rv;
data->page = page_real;
/* * Testing showed that the device has a timing issue. After * setting a page, it takes a while, before the device actually * gives the correct values from the correct page. 20 ms was * tested to be enough to not give wrong values (15 ms wasn't * enough).
*/
usleep_range(20000, 30000);
}
return 0;
}
staticint fsp3y_read_byte_data(struct i2c_client *client, int page, int reg)
{ conststruct pmbus_driver_info *info = pmbus_get_driver_info(client); struct fsp3y_data *data = to_fsp3y_data(info); int rv;
/* * Inject an exponent for non-compliant YH5151-E.
*/ if (data->vout_linear_11 && reg == PMBUS_VOUT_MODE) return 0x1A;
rv = set_page(client, page); if (rv < 0) return rv;
return i2c_smbus_read_byte_data(client, reg);
}
staticint fsp3y_read_word_data(struct i2c_client *client, int page, int phase, int reg)
{ conststruct pmbus_driver_info *info = pmbus_get_driver_info(client); struct fsp3y_data *data = to_fsp3y_data(info); int rv;
/* * This masks commands which weren't tested to work correctly. Some of * the masked commands return 0xFFFF. These would probably get tagged as * invalid by pmbus_core. Other ones do return values which might be * useful (that is, they are not 0xFFFF), but their encoding is unknown, * and so they are unsupported.
*/ switch (reg) { case PMBUS_READ_FAN_SPEED_1: case PMBUS_READ_IIN: case PMBUS_READ_IOUT: case PMBUS_READ_PIN: case PMBUS_READ_POUT: case PMBUS_READ_TEMPERATURE_1: case PMBUS_READ_TEMPERATURE_2: case PMBUS_READ_TEMPERATURE_3: case PMBUS_READ_VIN: case PMBUS_READ_VOUT: case PMBUS_STATUS_WORD: break; default: return -ENXIO;
}
rv = set_page(client, page); if (rv < 0) return rv;
rv = i2c_smbus_read_word_data(client, reg); if (rv < 0) return rv;
/* * YH-5151E sometimes reports vout in linear11 and sometimes in * linear16. This depends on the exact individual piece of hardware. One * YH-5151E can use linear16 and another might use linear11 instead. * * The format can be recognized by reading VOUT_MODE - if it doesn't * report a valid exponent, then vout uses linear11. Otherwise, the * device is compliant and uses linear16.
*/
data->vout_linear_11 = false; if (data->chip == yh5151e) {
rv = i2c_smbus_read_byte_data(client, PMBUS_VOUT_MODE); if (rv < 0) return rv;
MODULE_AUTHOR("Václav Kubernát");
MODULE_DESCRIPTION("PMBus driver for FSP/3Y-Power power supplies");
MODULE_LICENSE("GPL");
MODULE_IMPORT_NS("PMBUS");
Messung V0.5
¤ Dauer der Verarbeitung: 0.0 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.