diff options
author | Guenter Roeck <linux@roeck-us.net> | 2013-02-06 12:55:37 -0500 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2013-04-08 00:16:41 -0400 |
commit | a7c69118bdc8647db0e15defa9e399df21a48890 (patch) | |
tree | d0838283520993eee5a014b6a54bab8e79169d63 /drivers/hwmon/pmbus | |
parent | 6bf44cedab5918bee8e8fea8c7ad187996c8c874 (diff) |
hwmon: (pmbus/lm25066) Report VAUX as vmon
So far the driver reported the voltage on VAUX as "vout2". This was not
entirely appropriate as it is not an output voltage, and complicates
the code. Use the new virtual "VMON" register set and report the voltage
as "vmon" instead.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/pmbus')
-rw-r--r-- | drivers/hwmon/pmbus/lm25066.c | 73 |
1 files changed, 21 insertions, 52 deletions
diff --git a/drivers/hwmon/pmbus/lm25066.c b/drivers/hwmon/pmbus/lm25066.c index c299392716af..5489d70015c2 100644 --- a/drivers/hwmon/pmbus/lm25066.c +++ b/drivers/hwmon/pmbus/lm25066.c | |||
@@ -2,6 +2,7 @@ | |||
2 | * Hardware monitoring driver for LM25066 / LM5064 / LM5066 | 2 | * Hardware monitoring driver for LM25066 / LM5064 / LM5066 |
3 | * | 3 | * |
4 | * Copyright (c) 2011 Ericsson AB. | 4 | * Copyright (c) 2011 Ericsson AB. |
5 | * Copyright (c) 2013 Guenter Roeck | ||
5 | * | 6 | * |
6 | * This program is free software; you can redistribute it and/or modify | 7 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License as published by | 8 | * it under the terms of the GNU General Public License as published by |
@@ -56,42 +57,27 @@ static int lm25066_read_word_data(struct i2c_client *client, int page, int reg) | |||
56 | const struct lm25066_data *data = to_lm25066_data(info); | 57 | const struct lm25066_data *data = to_lm25066_data(info); |
57 | int ret; | 58 | int ret; |
58 | 59 | ||
59 | if (page > 1) | 60 | switch (reg) { |
60 | return -ENXIO; | 61 | case PMBUS_VIRT_READ_VMON: |
61 | 62 | ret = pmbus_read_word_data(client, 0, LM25066_READ_VAUX); | |
62 | /* Map READ_VAUX into READ_VOUT register on page 1 */ | 63 | if (ret < 0) |
63 | if (page == 1) { | 64 | break; |
64 | switch (reg) { | 65 | /* Adjust returned value to match VIN coefficients */ |
65 | case PMBUS_READ_VOUT: | 66 | switch (data->id) { |
66 | ret = pmbus_read_word_data(client, 0, | 67 | case lm25066: |
67 | LM25066_READ_VAUX); | 68 | /* VIN: 4.54 mV VAUX: 283.2 uV LSB */ |
68 | if (ret < 0) | 69 | ret = DIV_ROUND_CLOSEST(ret * 2832, 45400); |
69 | break; | 70 | break; |
70 | /* Adjust returned value to match VOUT coefficients */ | 71 | case lm5064: |
71 | switch (data->id) { | 72 | /* VIN: 4.53 mV VAUX: 700 uV LSB */ |
72 | case lm25066: | 73 | ret = DIV_ROUND_CLOSEST(ret * 70, 453); |
73 | /* VOUT: 4.54 mV VAUX: 283.2 uV LSB */ | ||
74 | ret = DIV_ROUND_CLOSEST(ret * 2832, 45400); | ||
75 | break; | ||
76 | case lm5064: | ||
77 | /* VOUT: 4.53 mV VAUX: 700 uV LSB */ | ||
78 | ret = DIV_ROUND_CLOSEST(ret * 70, 453); | ||
79 | break; | ||
80 | case lm5066: | ||
81 | /* VOUT: 2.18 mV VAUX: 725 uV LSB */ | ||
82 | ret = DIV_ROUND_CLOSEST(ret * 725, 2180); | ||
83 | break; | ||
84 | } | ||
85 | break; | 74 | break; |
86 | default: | 75 | case lm5066: |
87 | /* No other valid registers on page 1 */ | 76 | /* VIN: 2.18 mV VAUX: 725 uV LSB */ |
88 | ret = -ENXIO; | 77 | ret = DIV_ROUND_CLOSEST(ret * 725, 2180); |
89 | break; | 78 | break; |
90 | } | 79 | } |
91 | goto done; | 80 | break; |
92 | } | ||
93 | |||
94 | switch (reg) { | ||
95 | case PMBUS_READ_IIN: | 81 | case PMBUS_READ_IIN: |
96 | ret = pmbus_read_word_data(client, 0, LM25066_MFR_READ_IIN); | 82 | ret = pmbus_read_word_data(client, 0, LM25066_MFR_READ_IIN); |
97 | break; | 83 | break; |
@@ -128,7 +114,6 @@ static int lm25066_read_word_data(struct i2c_client *client, int page, int reg) | |||
128 | ret = -ENODATA; | 114 | ret = -ENODATA; |
129 | break; | 115 | break; |
130 | } | 116 | } |
131 | done: | ||
132 | return ret; | 117 | return ret; |
133 | } | 118 | } |
134 | 119 | ||
@@ -137,9 +122,6 @@ static int lm25066_write_word_data(struct i2c_client *client, int page, int reg, | |||
137 | { | 122 | { |
138 | int ret; | 123 | int ret; |
139 | 124 | ||
140 | if (page > 1) | ||
141 | return -ENXIO; | ||
142 | |||
143 | switch (reg) { | 125 | switch (reg) { |
144 | case PMBUS_IIN_OC_WARN_LIMIT: | 126 | case PMBUS_IIN_OC_WARN_LIMIT: |
145 | ret = pmbus_write_word_data(client, 0, | 127 | ret = pmbus_write_word_data(client, 0, |
@@ -161,17 +143,6 @@ static int lm25066_write_word_data(struct i2c_client *client, int page, int reg, | |||
161 | return ret; | 143 | return ret; |
162 | } | 144 | } |
163 | 145 | ||
164 | static int lm25066_write_byte(struct i2c_client *client, int page, u8 value) | ||
165 | { | ||
166 | if (page > 1) | ||
167 | return -ENXIO; | ||
168 | |||
169 | if (page <= 0) | ||
170 | return pmbus_write_byte(client, page, value); | ||
171 | |||
172 | return 0; | ||
173 | } | ||
174 | |||
175 | static int lm25066_probe(struct i2c_client *client, | 146 | static int lm25066_probe(struct i2c_client *client, |
176 | const struct i2c_device_id *id) | 147 | const struct i2c_device_id *id) |
177 | { | 148 | { |
@@ -195,7 +166,7 @@ static int lm25066_probe(struct i2c_client *client, | |||
195 | data->id = id->driver_data; | 166 | data->id = id->driver_data; |
196 | info = &data->info; | 167 | info = &data->info; |
197 | 168 | ||
198 | info->pages = 2; | 169 | info->pages = 1; |
199 | info->format[PSC_VOLTAGE_IN] = direct; | 170 | info->format[PSC_VOLTAGE_IN] = direct; |
200 | info->format[PSC_VOLTAGE_OUT] = direct; | 171 | info->format[PSC_VOLTAGE_OUT] = direct; |
201 | info->format[PSC_CURRENT_IN] = direct; | 172 | info->format[PSC_CURRENT_IN] = direct; |
@@ -206,14 +177,12 @@ static int lm25066_probe(struct i2c_client *client, | |||
206 | info->b[PSC_TEMPERATURE] = 0; | 177 | info->b[PSC_TEMPERATURE] = 0; |
207 | info->R[PSC_TEMPERATURE] = 0; | 178 | info->R[PSC_TEMPERATURE] = 0; |
208 | 179 | ||
209 | info->func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | 180 | info->func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_VMON | PMBUS_HAVE_VOUT |
210 | | PMBUS_HAVE_STATUS_VOUT | PMBUS_HAVE_PIN | PMBUS_HAVE_IIN | 181 | | PMBUS_HAVE_STATUS_VOUT | PMBUS_HAVE_PIN | PMBUS_HAVE_IIN |
211 | | PMBUS_HAVE_STATUS_INPUT | PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP; | 182 | | PMBUS_HAVE_STATUS_INPUT | PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP; |
212 | info->func[1] = PMBUS_HAVE_VOUT; | ||
213 | 183 | ||
214 | info->read_word_data = lm25066_read_word_data; | 184 | info->read_word_data = lm25066_read_word_data; |
215 | info->write_word_data = lm25066_write_word_data; | 185 | info->write_word_data = lm25066_write_word_data; |
216 | info->write_byte = lm25066_write_byte; | ||
217 | 186 | ||
218 | switch (id->driver_data) { | 187 | switch (id->driver_data) { |
219 | case lm25066: | 188 | case lm25066: |