// SPDX-License-Identifier: GPL-2.0-or-later /* * Hardware monitoring driver for ucd9200 series Digital PWM System Controllers * * Copyright (C) 2011 Ericsson AB.
*/
info = devm_kzalloc(&client->dev, sizeof(struct pmbus_driver_info),
GFP_KERNEL); if (!info) return -ENOMEM;
ret = i2c_smbus_read_block_data(client, UCD9200_PHASE_INFO,
block_buffer); if (ret < 0) {
dev_err(&client->dev, "Failed to read phase information\n"); return ret;
}
/* * Calculate number of configured pages (rails) from PHASE_INFO * register. * Rails have to be sequential, so we can abort after finding * the first unconfigured rail.
*/
info->pages = 0; for (i = 0; i < ret; i++) { if (!block_buffer[i]) break;
info->pages++;
} if (!info->pages) {
dev_err(&client->dev, "No rails configured\n"); return -ENODEV;
}
dev_info(&client->dev, "%d rails configured\n", info->pages);
/* * Set PHASE registers on all pages to 0xff to ensure that phase * specific commands will apply to all phases of a given page (rail). * This only affects the READ_IOUT and READ_TEMPERATURE2 registers. * READ_IOUT will return the sum of currents of all phases of a rail, * and READ_TEMPERATURE2 will return the maximum temperature detected * for the phases of the rail.
*/ for (i = 0; i < info->pages; i++) { /* * Setting PAGE & PHASE fails once in a while for no obvious * reason, so we need to retry a couple of times.
*/ for (j = 0; j < 3; j++) {
ret = i2c_smbus_write_byte_data(client, PMBUS_PAGE, i); if (ret < 0) continue;
ret = i2c_smbus_write_byte_data(client, PMBUS_PHASE,
0xff); if (ret < 0) continue; break;
} if (ret < 0) {
dev_err(&client->dev, "Failed to initialize PHASE registers\n"); return ret;
}
} if (info->pages > 1)
i2c_smbus_write_byte_data(client, PMBUS_PAGE, 0);
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.