| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Hardware monitoring driver for LTC3815 |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (c) 2015 Linear Technology |
|---|
| 5 | 6 | * Copyright (c) 2015 Guenter Roeck |
|---|
| 6 | | - * |
|---|
| 7 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 8 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 9 | | - * the Free Software Foundation; either version 2 of the License, or |
|---|
| 10 | | - * (at your option) any later version. |
|---|
| 11 | | - * |
|---|
| 12 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 13 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 14 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 15 | | - * GNU General Public License for more details. |
|---|
| 16 | 7 | */ |
|---|
| 17 | 8 | |
|---|
| 18 | 9 | #include <linux/err.h> |
|---|
| .. | .. |
|---|
| 64 | 55 | * LTC3815 does not support the CLEAR_FAULTS command. |
|---|
| 65 | 56 | * Emulate it by clearing the status register. |
|---|
| 66 | 57 | */ |
|---|
| 67 | | - ret = pmbus_read_word_data(client, 0, PMBUS_STATUS_WORD); |
|---|
| 58 | + ret = pmbus_read_word_data(client, 0, 0xff, PMBUS_STATUS_WORD); |
|---|
| 68 | 59 | if (ret > 0) { |
|---|
| 69 | 60 | pmbus_write_word_data(client, 0, PMBUS_STATUS_WORD, |
|---|
| 70 | 61 | ret); |
|---|
| .. | .. |
|---|
| 78 | 69 | return ret; |
|---|
| 79 | 70 | } |
|---|
| 80 | 71 | |
|---|
| 81 | | -static int ltc3815_read_word_data(struct i2c_client *client, int page, int reg) |
|---|
| 72 | +static int ltc3815_read_word_data(struct i2c_client *client, int page, |
|---|
| 73 | + int phase, int reg) |
|---|
| 82 | 74 | { |
|---|
| 83 | 75 | int ret; |
|---|
| 84 | 76 | |
|---|
| 85 | 77 | switch (reg) { |
|---|
| 86 | 78 | case PMBUS_VIRT_READ_VIN_MAX: |
|---|
| 87 | | - ret = pmbus_read_word_data(client, page, LTC3815_MFR_VIN_PEAK); |
|---|
| 79 | + ret = pmbus_read_word_data(client, page, phase, |
|---|
| 80 | + LTC3815_MFR_VIN_PEAK); |
|---|
| 88 | 81 | break; |
|---|
| 89 | 82 | case PMBUS_VIRT_READ_VOUT_MAX: |
|---|
| 90 | | - ret = pmbus_read_word_data(client, page, LTC3815_MFR_VOUT_PEAK); |
|---|
| 83 | + ret = pmbus_read_word_data(client, page, phase, |
|---|
| 84 | + LTC3815_MFR_VOUT_PEAK); |
|---|
| 91 | 85 | break; |
|---|
| 92 | 86 | case PMBUS_VIRT_READ_TEMP_MAX: |
|---|
| 93 | | - ret = pmbus_read_word_data(client, page, LTC3815_MFR_TEMP_PEAK); |
|---|
| 87 | + ret = pmbus_read_word_data(client, page, phase, |
|---|
| 88 | + LTC3815_MFR_TEMP_PEAK); |
|---|
| 94 | 89 | break; |
|---|
| 95 | 90 | case PMBUS_VIRT_READ_IOUT_MAX: |
|---|
| 96 | | - ret = pmbus_read_word_data(client, page, LTC3815_MFR_IOUT_PEAK); |
|---|
| 91 | + ret = pmbus_read_word_data(client, page, phase, |
|---|
| 92 | + LTC3815_MFR_IOUT_PEAK); |
|---|
| 97 | 93 | break; |
|---|
| 98 | 94 | case PMBUS_VIRT_READ_IIN_MAX: |
|---|
| 99 | | - ret = pmbus_read_word_data(client, page, LTC3815_MFR_IIN_PEAK); |
|---|
| 95 | + ret = pmbus_read_word_data(client, page, phase, |
|---|
| 96 | + LTC3815_MFR_IIN_PEAK); |
|---|
| 100 | 97 | break; |
|---|
| 101 | 98 | case PMBUS_VIRT_RESET_VOUT_HISTORY: |
|---|
| 102 | 99 | case PMBUS_VIRT_RESET_VIN_HISTORY: |
|---|
| .. | .. |
|---|
| 181 | 178 | .write_word_data = ltc3815_write_word_data, |
|---|
| 182 | 179 | }; |
|---|
| 183 | 180 | |
|---|
| 184 | | -static int ltc3815_probe(struct i2c_client *client, |
|---|
| 185 | | - const struct i2c_device_id *id) |
|---|
| 181 | +static int ltc3815_probe(struct i2c_client *client) |
|---|
| 186 | 182 | { |
|---|
| 187 | 183 | int chip_id; |
|---|
| 188 | 184 | |
|---|
| .. | .. |
|---|
| 196 | 192 | if ((chip_id & LTC3815_ID_MASK) != LTC3815_ID) |
|---|
| 197 | 193 | return -ENODEV; |
|---|
| 198 | 194 | |
|---|
| 199 | | - return pmbus_do_probe(client, id, <c3815_info); |
|---|
| 195 | + return pmbus_do_probe(client, <c3815_info); |
|---|
| 200 | 196 | } |
|---|
| 201 | 197 | |
|---|
| 202 | 198 | static struct i2c_driver ltc3815_driver = { |
|---|
| 203 | 199 | .driver = { |
|---|
| 204 | 200 | .name = "ltc3815", |
|---|
| 205 | 201 | }, |
|---|
| 206 | | - .probe = ltc3815_probe, |
|---|
| 202 | + .probe_new = ltc3815_probe, |
|---|
| 207 | 203 | .remove = pmbus_do_remove, |
|---|
| 208 | 204 | .id_table = ltc3815_id, |
|---|
| 209 | 205 | }; |
|---|