.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright 2017 IBM Corp. |
---|
3 | | - * |
---|
4 | | - * This program is free software; you can redistribute it and/or modify |
---|
5 | | - * it under the terms of the GNU General Public License as published by |
---|
6 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
7 | | - * (at your option) any later version. |
---|
8 | 4 | */ |
---|
9 | 5 | |
---|
| 6 | +#include <linux/bitfield.h> |
---|
10 | 7 | #include <linux/bitops.h> |
---|
11 | 8 | #include <linux/debugfs.h> |
---|
12 | 9 | #include <linux/device.h> |
---|
.. | .. |
---|
16 | 13 | #include <linux/leds.h> |
---|
17 | 14 | #include <linux/module.h> |
---|
18 | 15 | #include <linux/mutex.h> |
---|
| 16 | +#include <linux/of_device.h> |
---|
19 | 17 | #include <linux/pmbus.h> |
---|
20 | 18 | |
---|
21 | 19 | #include "pmbus.h" |
---|
22 | 20 | |
---|
23 | 21 | #define CFFPS_FRU_CMD 0x9A |
---|
24 | 22 | #define CFFPS_PN_CMD 0x9B |
---|
| 23 | +#define CFFPS_HEADER_CMD 0x9C |
---|
25 | 24 | #define CFFPS_SN_CMD 0x9E |
---|
| 25 | +#define CFFPS_MAX_POWER_OUT_CMD 0xA7 |
---|
26 | 26 | #define CFFPS_CCIN_CMD 0xBD |
---|
27 | | -#define CFFPS_FW_CMD_START 0xFA |
---|
28 | | -#define CFFPS_FW_NUM_BYTES 4 |
---|
| 27 | +#define CFFPS_FW_CMD 0xFA |
---|
| 28 | +#define CFFPS1_FW_NUM_BYTES 4 |
---|
| 29 | +#define CFFPS2_FW_NUM_WORDS 3 |
---|
29 | 30 | #define CFFPS_SYS_CONFIG_CMD 0xDA |
---|
| 31 | +#define CFFPS_12VCS_VOUT_CMD 0xDE |
---|
30 | 32 | |
---|
31 | 33 | #define CFFPS_INPUT_HISTORY_CMD 0xD6 |
---|
32 | 34 | #define CFFPS_INPUT_HISTORY_SIZE 100 |
---|
| 35 | + |
---|
| 36 | +#define CFFPS_CCIN_REVISION GENMASK(7, 0) |
---|
| 37 | +#define CFFPS_CCIN_REVISION_LEGACY 0xde |
---|
| 38 | +#define CFFPS_CCIN_VERSION GENMASK(15, 8) |
---|
| 39 | +#define CFFPS_CCIN_VERSION_1 0x2b |
---|
| 40 | +#define CFFPS_CCIN_VERSION_2 0x2e |
---|
| 41 | +#define CFFPS_CCIN_VERSION_3 0x51 |
---|
33 | 42 | |
---|
34 | 43 | /* STATUS_MFR_SPECIFIC bits */ |
---|
35 | 44 | #define CFFPS_MFR_FAN_FAULT BIT(0) |
---|
.. | .. |
---|
41 | 50 | #define CFFPS_MFR_VAUX_FAULT BIT(6) |
---|
42 | 51 | #define CFFPS_MFR_CURRENT_SHARE_WARNING BIT(7) |
---|
43 | 52 | |
---|
44 | | -#define CFFPS_LED_BLINK BIT(0) |
---|
45 | | -#define CFFPS_LED_ON BIT(1) |
---|
46 | | -#define CFFPS_LED_OFF BIT(2) |
---|
| 53 | +#define CFFPS_LED_BLINK (BIT(0) | BIT(6)) |
---|
| 54 | +#define CFFPS_LED_ON (BIT(1) | BIT(6)) |
---|
| 55 | +#define CFFPS_LED_OFF (BIT(2) | BIT(6)) |
---|
47 | 56 | #define CFFPS_BLINK_RATE_MS 250 |
---|
48 | 57 | |
---|
49 | 58 | enum { |
---|
50 | 59 | CFFPS_DEBUGFS_INPUT_HISTORY = 0, |
---|
51 | 60 | CFFPS_DEBUGFS_FRU, |
---|
52 | 61 | CFFPS_DEBUGFS_PN, |
---|
| 62 | + CFFPS_DEBUGFS_HEADER, |
---|
53 | 63 | CFFPS_DEBUGFS_SN, |
---|
| 64 | + CFFPS_DEBUGFS_MAX_POWER_OUT, |
---|
54 | 65 | CFFPS_DEBUGFS_CCIN, |
---|
55 | 66 | CFFPS_DEBUGFS_FW, |
---|
| 67 | + CFFPS_DEBUGFS_ON_OFF_CONFIG, |
---|
56 | 68 | CFFPS_DEBUGFS_NUM_ENTRIES |
---|
57 | 69 | }; |
---|
| 70 | + |
---|
| 71 | +enum versions { cffps1, cffps2, cffps_unknown }; |
---|
58 | 72 | |
---|
59 | 73 | struct ibm_cffps_input_history { |
---|
60 | 74 | struct mutex update_lock; |
---|
.. | .. |
---|
65 | 79 | }; |
---|
66 | 80 | |
---|
67 | 81 | struct ibm_cffps { |
---|
| 82 | + enum versions version; |
---|
68 | 83 | struct i2c_client *client; |
---|
69 | 84 | |
---|
70 | 85 | struct ibm_cffps_input_history input_history; |
---|
.. | .. |
---|
75 | 90 | u8 led_state; |
---|
76 | 91 | struct led_classdev led; |
---|
77 | 92 | }; |
---|
| 93 | + |
---|
| 94 | +static const struct i2c_device_id ibm_cffps_id[]; |
---|
78 | 95 | |
---|
79 | 96 | #define to_psu(x, y) container_of((x), struct ibm_cffps, debugfs_entries[(y)]) |
---|
80 | 97 | |
---|
.. | .. |
---|
126 | 143 | psu->input_history.byte_count); |
---|
127 | 144 | } |
---|
128 | 145 | |
---|
129 | | -static ssize_t ibm_cffps_debugfs_op(struct file *file, char __user *buf, |
---|
130 | | - size_t count, loff_t *ppos) |
---|
| 146 | +static ssize_t ibm_cffps_debugfs_read(struct file *file, char __user *buf, |
---|
| 147 | + size_t count, loff_t *ppos) |
---|
131 | 148 | { |
---|
132 | 149 | u8 cmd; |
---|
133 | 150 | int i, rc; |
---|
134 | 151 | int *idxp = file->private_data; |
---|
135 | 152 | int idx = *idxp; |
---|
136 | 153 | struct ibm_cffps *psu = to_psu(idxp, idx); |
---|
137 | | - char data[I2C_SMBUS_BLOCK_MAX] = { 0 }; |
---|
| 154 | + char data[I2C_SMBUS_BLOCK_MAX + 2] = { 0 }; |
---|
| 155 | + |
---|
| 156 | + pmbus_set_page(psu->client, 0, 0xff); |
---|
138 | 157 | |
---|
139 | 158 | switch (idx) { |
---|
140 | 159 | case CFFPS_DEBUGFS_INPUT_HISTORY: |
---|
.. | .. |
---|
145 | 164 | case CFFPS_DEBUGFS_PN: |
---|
146 | 165 | cmd = CFFPS_PN_CMD; |
---|
147 | 166 | break; |
---|
| 167 | + case CFFPS_DEBUGFS_HEADER: |
---|
| 168 | + cmd = CFFPS_HEADER_CMD; |
---|
| 169 | + break; |
---|
148 | 170 | case CFFPS_DEBUGFS_SN: |
---|
149 | 171 | cmd = CFFPS_SN_CMD; |
---|
150 | 172 | break; |
---|
| 173 | + case CFFPS_DEBUGFS_MAX_POWER_OUT: |
---|
| 174 | + if (psu->version == cffps1) { |
---|
| 175 | + rc = i2c_smbus_read_word_swapped(psu->client, |
---|
| 176 | + CFFPS_MAX_POWER_OUT_CMD); |
---|
| 177 | + } else { |
---|
| 178 | + rc = i2c_smbus_read_word_data(psu->client, |
---|
| 179 | + CFFPS_MAX_POWER_OUT_CMD); |
---|
| 180 | + } |
---|
| 181 | + |
---|
| 182 | + if (rc < 0) |
---|
| 183 | + return rc; |
---|
| 184 | + |
---|
| 185 | + rc = snprintf(data, I2C_SMBUS_BLOCK_MAX, "%d", rc); |
---|
| 186 | + goto done; |
---|
151 | 187 | case CFFPS_DEBUGFS_CCIN: |
---|
152 | 188 | rc = i2c_smbus_read_word_swapped(psu->client, CFFPS_CCIN_CMD); |
---|
153 | 189 | if (rc < 0) |
---|
.. | .. |
---|
156 | 192 | rc = snprintf(data, 5, "%04X", rc); |
---|
157 | 193 | goto done; |
---|
158 | 194 | case CFFPS_DEBUGFS_FW: |
---|
159 | | - for (i = 0; i < CFFPS_FW_NUM_BYTES; ++i) { |
---|
160 | | - rc = i2c_smbus_read_byte_data(psu->client, |
---|
161 | | - CFFPS_FW_CMD_START + i); |
---|
162 | | - if (rc < 0) |
---|
163 | | - return rc; |
---|
| 195 | + switch (psu->version) { |
---|
| 196 | + case cffps1: |
---|
| 197 | + for (i = 0; i < CFFPS1_FW_NUM_BYTES; ++i) { |
---|
| 198 | + rc = i2c_smbus_read_byte_data(psu->client, |
---|
| 199 | + CFFPS_FW_CMD + |
---|
| 200 | + i); |
---|
| 201 | + if (rc < 0) |
---|
| 202 | + return rc; |
---|
164 | 203 | |
---|
165 | | - snprintf(&data[i * 2], 3, "%02X", rc); |
---|
| 204 | + snprintf(&data[i * 2], 3, "%02X", rc); |
---|
| 205 | + } |
---|
| 206 | + |
---|
| 207 | + rc = i * 2; |
---|
| 208 | + break; |
---|
| 209 | + case cffps2: |
---|
| 210 | + for (i = 0; i < CFFPS2_FW_NUM_WORDS; ++i) { |
---|
| 211 | + rc = i2c_smbus_read_word_data(psu->client, |
---|
| 212 | + CFFPS_FW_CMD + |
---|
| 213 | + i); |
---|
| 214 | + if (rc < 0) |
---|
| 215 | + return rc; |
---|
| 216 | + |
---|
| 217 | + snprintf(&data[i * 4], 5, "%04X", rc); |
---|
| 218 | + } |
---|
| 219 | + |
---|
| 220 | + rc = i * 4; |
---|
| 221 | + break; |
---|
| 222 | + default: |
---|
| 223 | + return -EOPNOTSUPP; |
---|
166 | 224 | } |
---|
| 225 | + goto done; |
---|
| 226 | + case CFFPS_DEBUGFS_ON_OFF_CONFIG: |
---|
| 227 | + rc = i2c_smbus_read_byte_data(psu->client, |
---|
| 228 | + PMBUS_ON_OFF_CONFIG); |
---|
| 229 | + if (rc < 0) |
---|
| 230 | + return rc; |
---|
167 | 231 | |
---|
168 | | - rc = i * 2; |
---|
| 232 | + rc = snprintf(data, 3, "%02x", rc); |
---|
169 | 233 | goto done; |
---|
170 | 234 | default: |
---|
171 | 235 | return -EINVAL; |
---|
.. | .. |
---|
182 | 246 | return simple_read_from_buffer(buf, count, ppos, data, rc); |
---|
183 | 247 | } |
---|
184 | 248 | |
---|
| 249 | +static ssize_t ibm_cffps_debugfs_write(struct file *file, |
---|
| 250 | + const char __user *buf, size_t count, |
---|
| 251 | + loff_t *ppos) |
---|
| 252 | +{ |
---|
| 253 | + u8 data; |
---|
| 254 | + ssize_t rc; |
---|
| 255 | + int *idxp = file->private_data; |
---|
| 256 | + int idx = *idxp; |
---|
| 257 | + struct ibm_cffps *psu = to_psu(idxp, idx); |
---|
| 258 | + |
---|
| 259 | + switch (idx) { |
---|
| 260 | + case CFFPS_DEBUGFS_ON_OFF_CONFIG: |
---|
| 261 | + pmbus_set_page(psu->client, 0, 0xff); |
---|
| 262 | + |
---|
| 263 | + rc = simple_write_to_buffer(&data, 1, ppos, buf, count); |
---|
| 264 | + if (rc <= 0) |
---|
| 265 | + return rc; |
---|
| 266 | + |
---|
| 267 | + rc = i2c_smbus_write_byte_data(psu->client, |
---|
| 268 | + PMBUS_ON_OFF_CONFIG, data); |
---|
| 269 | + if (rc) |
---|
| 270 | + return rc; |
---|
| 271 | + |
---|
| 272 | + rc = 1; |
---|
| 273 | + break; |
---|
| 274 | + default: |
---|
| 275 | + return -EINVAL; |
---|
| 276 | + } |
---|
| 277 | + |
---|
| 278 | + return rc; |
---|
| 279 | +} |
---|
| 280 | + |
---|
185 | 281 | static const struct file_operations ibm_cffps_fops = { |
---|
186 | 282 | .llseek = noop_llseek, |
---|
187 | | - .read = ibm_cffps_debugfs_op, |
---|
| 283 | + .read = ibm_cffps_debugfs_read, |
---|
| 284 | + .write = ibm_cffps_debugfs_write, |
---|
188 | 285 | .open = simple_open, |
---|
189 | 286 | }; |
---|
190 | 287 | |
---|
.. | .. |
---|
239 | 336 | } |
---|
240 | 337 | |
---|
241 | 338 | static int ibm_cffps_read_word_data(struct i2c_client *client, int page, |
---|
242 | | - int reg) |
---|
| 339 | + int phase, int reg) |
---|
243 | 340 | { |
---|
244 | 341 | int rc, mfr; |
---|
245 | 342 | |
---|
246 | 343 | switch (reg) { |
---|
247 | 344 | case PMBUS_STATUS_WORD: |
---|
248 | | - rc = pmbus_read_word_data(client, page, reg); |
---|
| 345 | + rc = pmbus_read_word_data(client, page, phase, reg); |
---|
249 | 346 | if (rc < 0) |
---|
250 | 347 | return rc; |
---|
251 | 348 | |
---|
.. | .. |
---|
261 | 358 | if (mfr & CFFPS_MFR_PS_KILL) |
---|
262 | 359 | rc |= PB_STATUS_OFF; |
---|
263 | 360 | break; |
---|
| 361 | + case PMBUS_VIRT_READ_VMON: |
---|
| 362 | + rc = pmbus_read_word_data(client, page, phase, |
---|
| 363 | + CFFPS_12VCS_VOUT_CMD); |
---|
| 364 | + break; |
---|
264 | 365 | default: |
---|
265 | 366 | rc = -ENODATA; |
---|
266 | 367 | break; |
---|
.. | .. |
---|
273 | 374 | enum led_brightness brightness) |
---|
274 | 375 | { |
---|
275 | 376 | int rc; |
---|
| 377 | + u8 next_led_state; |
---|
276 | 378 | struct ibm_cffps *psu = container_of(led_cdev, struct ibm_cffps, led); |
---|
277 | 379 | |
---|
278 | 380 | if (brightness == LED_OFF) { |
---|
279 | | - psu->led_state = CFFPS_LED_OFF; |
---|
| 381 | + next_led_state = CFFPS_LED_OFF; |
---|
280 | 382 | } else { |
---|
281 | 383 | brightness = LED_FULL; |
---|
| 384 | + |
---|
282 | 385 | if (psu->led_state != CFFPS_LED_BLINK) |
---|
283 | | - psu->led_state = CFFPS_LED_ON; |
---|
| 386 | + next_led_state = CFFPS_LED_ON; |
---|
| 387 | + else |
---|
| 388 | + next_led_state = CFFPS_LED_BLINK; |
---|
284 | 389 | } |
---|
285 | 390 | |
---|
| 391 | + dev_dbg(&psu->client->dev, "LED brightness set: %d. Command: %d.\n", |
---|
| 392 | + brightness, next_led_state); |
---|
| 393 | + |
---|
| 394 | + pmbus_set_page(psu->client, 0, 0xff); |
---|
| 395 | + |
---|
286 | 396 | rc = i2c_smbus_write_byte_data(psu->client, CFFPS_SYS_CONFIG_CMD, |
---|
287 | | - psu->led_state); |
---|
| 397 | + next_led_state); |
---|
288 | 398 | if (rc < 0) |
---|
289 | 399 | return rc; |
---|
290 | 400 | |
---|
| 401 | + psu->led_state = next_led_state; |
---|
291 | 402 | led_cdev->brightness = brightness; |
---|
292 | 403 | |
---|
293 | 404 | return 0; |
---|
.. | .. |
---|
300 | 411 | int rc; |
---|
301 | 412 | struct ibm_cffps *psu = container_of(led_cdev, struct ibm_cffps, led); |
---|
302 | 413 | |
---|
303 | | - psu->led_state = CFFPS_LED_BLINK; |
---|
| 414 | + dev_dbg(&psu->client->dev, "LED blink set.\n"); |
---|
304 | 415 | |
---|
305 | | - if (led_cdev->brightness == LED_OFF) |
---|
306 | | - return 0; |
---|
| 416 | + pmbus_set_page(psu->client, 0, 0xff); |
---|
307 | 417 | |
---|
308 | 418 | rc = i2c_smbus_write_byte_data(psu->client, CFFPS_SYS_CONFIG_CMD, |
---|
309 | 419 | CFFPS_LED_BLINK); |
---|
310 | 420 | if (rc < 0) |
---|
311 | 421 | return rc; |
---|
312 | 422 | |
---|
| 423 | + psu->led_state = CFFPS_LED_BLINK; |
---|
| 424 | + led_cdev->brightness = LED_FULL; |
---|
313 | 425 | *delay_on = CFFPS_BLINK_RATE_MS; |
---|
314 | 426 | *delay_off = CFFPS_BLINK_RATE_MS; |
---|
315 | 427 | |
---|
.. | .. |
---|
332 | 444 | rc = devm_led_classdev_register(dev, &psu->led); |
---|
333 | 445 | if (rc) |
---|
334 | 446 | dev_warn(dev, "failed to register led class: %d\n", rc); |
---|
| 447 | + else |
---|
| 448 | + i2c_smbus_write_byte_data(client, CFFPS_SYS_CONFIG_CMD, |
---|
| 449 | + CFFPS_LED_OFF); |
---|
335 | 450 | } |
---|
336 | 451 | |
---|
337 | | -static struct pmbus_driver_info ibm_cffps_info = { |
---|
338 | | - .pages = 1, |
---|
339 | | - .func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | PMBUS_HAVE_IOUT | |
---|
340 | | - PMBUS_HAVE_PIN | PMBUS_HAVE_FAN12 | PMBUS_HAVE_TEMP | |
---|
341 | | - PMBUS_HAVE_TEMP2 | PMBUS_HAVE_TEMP3 | PMBUS_HAVE_STATUS_VOUT | |
---|
342 | | - PMBUS_HAVE_STATUS_IOUT | PMBUS_HAVE_STATUS_INPUT | |
---|
343 | | - PMBUS_HAVE_STATUS_TEMP | PMBUS_HAVE_STATUS_FAN12, |
---|
344 | | - .read_byte_data = ibm_cffps_read_byte_data, |
---|
345 | | - .read_word_data = ibm_cffps_read_word_data, |
---|
| 452 | +static struct pmbus_driver_info ibm_cffps_info[] = { |
---|
| 453 | + [cffps1] = { |
---|
| 454 | + .pages = 1, |
---|
| 455 | + .func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | PMBUS_HAVE_IOUT | |
---|
| 456 | + PMBUS_HAVE_PIN | PMBUS_HAVE_FAN12 | PMBUS_HAVE_TEMP | |
---|
| 457 | + PMBUS_HAVE_TEMP2 | PMBUS_HAVE_TEMP3 | |
---|
| 458 | + PMBUS_HAVE_STATUS_VOUT | PMBUS_HAVE_STATUS_IOUT | |
---|
| 459 | + PMBUS_HAVE_STATUS_INPUT | PMBUS_HAVE_STATUS_TEMP | |
---|
| 460 | + PMBUS_HAVE_STATUS_FAN12, |
---|
| 461 | + .read_byte_data = ibm_cffps_read_byte_data, |
---|
| 462 | + .read_word_data = ibm_cffps_read_word_data, |
---|
| 463 | + }, |
---|
| 464 | + [cffps2] = { |
---|
| 465 | + .pages = 2, |
---|
| 466 | + .func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | PMBUS_HAVE_IOUT | |
---|
| 467 | + PMBUS_HAVE_PIN | PMBUS_HAVE_FAN12 | PMBUS_HAVE_TEMP | |
---|
| 468 | + PMBUS_HAVE_TEMP2 | PMBUS_HAVE_TEMP3 | |
---|
| 469 | + PMBUS_HAVE_STATUS_VOUT | PMBUS_HAVE_STATUS_IOUT | |
---|
| 470 | + PMBUS_HAVE_STATUS_INPUT | PMBUS_HAVE_STATUS_TEMP | |
---|
| 471 | + PMBUS_HAVE_STATUS_FAN12 | PMBUS_HAVE_VMON, |
---|
| 472 | + .func[1] = PMBUS_HAVE_VOUT | PMBUS_HAVE_IOUT | |
---|
| 473 | + PMBUS_HAVE_TEMP | PMBUS_HAVE_TEMP2 | PMBUS_HAVE_TEMP3 | |
---|
| 474 | + PMBUS_HAVE_STATUS_VOUT | PMBUS_HAVE_STATUS_IOUT, |
---|
| 475 | + .read_byte_data = ibm_cffps_read_byte_data, |
---|
| 476 | + .read_word_data = ibm_cffps_read_word_data, |
---|
| 477 | + }, |
---|
346 | 478 | }; |
---|
347 | 479 | |
---|
348 | 480 | static struct pmbus_platform_data ibm_cffps_pdata = { |
---|
349 | 481 | .flags = PMBUS_SKIP_STATUS_CHECK, |
---|
350 | 482 | }; |
---|
351 | 483 | |
---|
352 | | -static int ibm_cffps_probe(struct i2c_client *client, |
---|
353 | | - const struct i2c_device_id *id) |
---|
| 484 | +static int ibm_cffps_probe(struct i2c_client *client) |
---|
354 | 485 | { |
---|
355 | 486 | int i, rc; |
---|
| 487 | + enum versions vs = cffps_unknown; |
---|
356 | 488 | struct dentry *debugfs; |
---|
357 | 489 | struct dentry *ibm_cffps_dir; |
---|
358 | 490 | struct ibm_cffps *psu; |
---|
| 491 | + const void *md = of_device_get_match_data(&client->dev); |
---|
| 492 | + const struct i2c_device_id *id; |
---|
| 493 | + |
---|
| 494 | + if (md) { |
---|
| 495 | + vs = (enum versions)md; |
---|
| 496 | + } else { |
---|
| 497 | + id = i2c_match_id(ibm_cffps_id, client); |
---|
| 498 | + if (id) |
---|
| 499 | + vs = (enum versions)id->driver_data; |
---|
| 500 | + } |
---|
| 501 | + |
---|
| 502 | + if (vs == cffps_unknown) { |
---|
| 503 | + u16 ccin_revision = 0; |
---|
| 504 | + u16 ccin_version = CFFPS_CCIN_VERSION_1; |
---|
| 505 | + int ccin = i2c_smbus_read_word_swapped(client, CFFPS_CCIN_CMD); |
---|
| 506 | + |
---|
| 507 | + if (ccin > 0) { |
---|
| 508 | + ccin_revision = FIELD_GET(CFFPS_CCIN_REVISION, ccin); |
---|
| 509 | + ccin_version = FIELD_GET(CFFPS_CCIN_VERSION, ccin); |
---|
| 510 | + } |
---|
| 511 | + |
---|
| 512 | + switch (ccin_version) { |
---|
| 513 | + default: |
---|
| 514 | + case CFFPS_CCIN_VERSION_1: |
---|
| 515 | + vs = cffps1; |
---|
| 516 | + break; |
---|
| 517 | + case CFFPS_CCIN_VERSION_2: |
---|
| 518 | + vs = cffps2; |
---|
| 519 | + break; |
---|
| 520 | + case CFFPS_CCIN_VERSION_3: |
---|
| 521 | + if (ccin_revision == CFFPS_CCIN_REVISION_LEGACY) |
---|
| 522 | + vs = cffps1; |
---|
| 523 | + else |
---|
| 524 | + vs = cffps2; |
---|
| 525 | + break; |
---|
| 526 | + } |
---|
| 527 | + |
---|
| 528 | + /* Set the client name to include the version number. */ |
---|
| 529 | + snprintf(client->name, I2C_NAME_SIZE, "cffps%d", vs + 1); |
---|
| 530 | + } |
---|
359 | 531 | |
---|
360 | 532 | client->dev.platform_data = &ibm_cffps_pdata; |
---|
361 | | - rc = pmbus_do_probe(client, id, &ibm_cffps_info); |
---|
| 533 | + rc = pmbus_do_probe(client, &ibm_cffps_info[vs]); |
---|
362 | 534 | if (rc) |
---|
363 | 535 | return rc; |
---|
364 | 536 | |
---|
.. | .. |
---|
370 | 542 | if (!psu) |
---|
371 | 543 | return 0; |
---|
372 | 544 | |
---|
| 545 | + psu->version = vs; |
---|
373 | 546 | psu->client = client; |
---|
374 | 547 | mutex_init(&psu->input_history.update_lock); |
---|
375 | 548 | psu->input_history.last_update = jiffies - HZ; |
---|
.. | .. |
---|
397 | 570 | debugfs_create_file("part_number", 0444, ibm_cffps_dir, |
---|
398 | 571 | &psu->debugfs_entries[CFFPS_DEBUGFS_PN], |
---|
399 | 572 | &ibm_cffps_fops); |
---|
| 573 | + debugfs_create_file("header", 0444, ibm_cffps_dir, |
---|
| 574 | + &psu->debugfs_entries[CFFPS_DEBUGFS_HEADER], |
---|
| 575 | + &ibm_cffps_fops); |
---|
400 | 576 | debugfs_create_file("serial_number", 0444, ibm_cffps_dir, |
---|
401 | 577 | &psu->debugfs_entries[CFFPS_DEBUGFS_SN], |
---|
| 578 | + &ibm_cffps_fops); |
---|
| 579 | + debugfs_create_file("max_power_out", 0444, ibm_cffps_dir, |
---|
| 580 | + &psu->debugfs_entries[CFFPS_DEBUGFS_MAX_POWER_OUT], |
---|
402 | 581 | &ibm_cffps_fops); |
---|
403 | 582 | debugfs_create_file("ccin", 0444, ibm_cffps_dir, |
---|
404 | 583 | &psu->debugfs_entries[CFFPS_DEBUGFS_CCIN], |
---|
.. | .. |
---|
406 | 585 | debugfs_create_file("fw_version", 0444, ibm_cffps_dir, |
---|
407 | 586 | &psu->debugfs_entries[CFFPS_DEBUGFS_FW], |
---|
408 | 587 | &ibm_cffps_fops); |
---|
| 588 | + debugfs_create_file("on_off_config", 0644, ibm_cffps_dir, |
---|
| 589 | + &psu->debugfs_entries[CFFPS_DEBUGFS_ON_OFF_CONFIG], |
---|
| 590 | + &ibm_cffps_fops); |
---|
409 | 591 | |
---|
410 | 592 | return 0; |
---|
411 | 593 | } |
---|
412 | 594 | |
---|
413 | 595 | static const struct i2c_device_id ibm_cffps_id[] = { |
---|
414 | | - { "ibm_cffps1", 1 }, |
---|
| 596 | + { "ibm_cffps1", cffps1 }, |
---|
| 597 | + { "ibm_cffps2", cffps2 }, |
---|
| 598 | + { "ibm_cffps", cffps_unknown }, |
---|
415 | 599 | {} |
---|
416 | 600 | }; |
---|
417 | 601 | MODULE_DEVICE_TABLE(i2c, ibm_cffps_id); |
---|
418 | 602 | |
---|
419 | 603 | static const struct of_device_id ibm_cffps_of_match[] = { |
---|
420 | | - { .compatible = "ibm,cffps1" }, |
---|
| 604 | + { |
---|
| 605 | + .compatible = "ibm,cffps1", |
---|
| 606 | + .data = (void *)cffps1 |
---|
| 607 | + }, |
---|
| 608 | + { |
---|
| 609 | + .compatible = "ibm,cffps2", |
---|
| 610 | + .data = (void *)cffps2 |
---|
| 611 | + }, |
---|
| 612 | + { |
---|
| 613 | + .compatible = "ibm,cffps", |
---|
| 614 | + .data = (void *)cffps_unknown |
---|
| 615 | + }, |
---|
421 | 616 | {} |
---|
422 | 617 | }; |
---|
423 | 618 | MODULE_DEVICE_TABLE(of, ibm_cffps_of_match); |
---|
.. | .. |
---|
427 | 622 | .name = "ibm-cffps", |
---|
428 | 623 | .of_match_table = ibm_cffps_of_match, |
---|
429 | 624 | }, |
---|
430 | | - .probe = ibm_cffps_probe, |
---|
| 625 | + .probe_new = ibm_cffps_probe, |
---|
431 | 626 | .remove = pmbus_do_remove, |
---|
432 | 627 | .id_table = ibm_cffps_id, |
---|
433 | 628 | }; |
---|