|
5 | 5 | * Copyright (c) 2022 9elements GmbH
|
6 | 6 | */
|
7 | 7 |
|
| 8 | +#include <linux/delay.h> |
8 | 9 | #include <linux/i2c.h>
|
9 | 10 | #include <linux/module.h>
|
10 | 11 | #include <linux/pmbus.h>
|
@@ -53,6 +54,30 @@ static int pli1209bc_read_word_data(struct i2c_client *client, int page,
|
53 | 54 | }
|
54 | 55 | }
|
55 | 56 |
|
| 57 | +static int pli1209bc_write_byte(struct i2c_client *client, int page, u8 reg) |
| 58 | +{ |
| 59 | + int ret; |
| 60 | + |
| 61 | + switch (reg) { |
| 62 | + case PMBUS_CLEAR_FAULTS: |
| 63 | + ret = pmbus_write_byte(client, page, reg); |
| 64 | + /* |
| 65 | + * PLI1209 takes 230 usec to execute the CLEAR_FAULTS command. |
| 66 | + * During that time it's busy and NACKs all requests on the |
| 67 | + * SMBUS interface. It also NACKs reads on PMBUS_STATUS_BYTE |
| 68 | + * making it impossible to poll the BUSY flag. |
| 69 | + * |
| 70 | + * Just wait for not BUSY unconditionally. |
| 71 | + */ |
| 72 | + usleep_range(250, 300); |
| 73 | + break; |
| 74 | + default: |
| 75 | + ret = -ENODATA; |
| 76 | + break; |
| 77 | + } |
| 78 | + return ret; |
| 79 | +} |
| 80 | + |
56 | 81 | #if IS_ENABLED(CONFIG_SENSORS_PLI1209BC_REGULATOR)
|
57 | 82 | static const struct regulator_desc pli1209bc_reg_desc = {
|
58 | 83 | .name = "vout2",
|
@@ -102,6 +127,7 @@ static struct pmbus_driver_info pli1209bc_info = {
|
102 | 127 | | PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP
|
103 | 128 | | PMBUS_HAVE_STATUS_IOUT | PMBUS_HAVE_STATUS_INPUT,
|
104 | 129 | .read_word_data = pli1209bc_read_word_data,
|
| 130 | + .write_byte = pli1209bc_write_byte, |
105 | 131 | #if IS_ENABLED(CONFIG_SENSORS_PLI1209BC_REGULATOR)
|
106 | 132 | .num_regulators = 1,
|
107 | 133 | .reg_desc = &pli1209bc_reg_desc,
|
|
0 commit comments