aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2015-08-17 19:17:24 -0400
committerGuenter Roeck <linux@roeck-us.net>2015-08-19 12:08:17 -0400
commit2c052d4280ca48fddc7a9ffd2329ada3628cab86 (patch)
tree7e2e20a28d8c5113e6fb64af40e805097997f109
parent228b687d9e20f367e4d5ea8723e3abbf0892db61 (diff)
hwmon: (pmbus) Use BIT macro
Using the BIT macro makes the code a little easier to read. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
-rw-r--r--drivers/hwmon/pmbus/lm25066.c7
-rw-r--r--drivers/hwmon/pmbus/max34440.c9
-rw-r--r--drivers/hwmon/pmbus/max8688.c19
-rw-r--r--drivers/hwmon/pmbus/pmbus.h163
-rw-r--r--drivers/hwmon/pmbus/zl6100.c11
5 files changed, 107 insertions, 102 deletions
diff --git a/drivers/hwmon/pmbus/lm25066.c b/drivers/hwmon/pmbus/lm25066.c
index a26b1d1d9514..a3d912cd3b8d 100644
--- a/drivers/hwmon/pmbus/lm25066.c
+++ b/drivers/hwmon/pmbus/lm25066.c
@@ -19,6 +19,7 @@
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 20 */
21 21
22#include <linux/bitops.h>
22#include <linux/kernel.h> 23#include <linux/kernel.h>
23#include <linux/module.h> 24#include <linux/module.h>
24#include <linux/init.h> 25#include <linux/init.h>
@@ -42,15 +43,15 @@ enum chips { lm25056, lm25063, lm25066, lm5064, lm5066 };
42#define LM25066_READ_AVG_IIN 0xde 43#define LM25066_READ_AVG_IIN 0xde
43#define LM25066_READ_AVG_PIN 0xdf 44#define LM25066_READ_AVG_PIN 0xdf
44 45
45#define LM25066_DEV_SETUP_CL (1 << 4) /* Current limit */ 46#define LM25066_DEV_SETUP_CL BIT(4) /* Current limit */
46 47
47/* LM25056 only */ 48/* LM25056 only */
48 49
49#define LM25056_VAUX_OV_WARN_LIMIT 0xe3 50#define LM25056_VAUX_OV_WARN_LIMIT 0xe3
50#define LM25056_VAUX_UV_WARN_LIMIT 0xe4 51#define LM25056_VAUX_UV_WARN_LIMIT 0xe4
51 52
52#define LM25056_MFR_STS_VAUX_OV_WARN (1 << 1) 53#define LM25056_MFR_STS_VAUX_OV_WARN BIT(1)
53#define LM25056_MFR_STS_VAUX_UV_WARN (1 << 0) 54#define LM25056_MFR_STS_VAUX_UV_WARN BIT(0)
54 55
55/* LM25063 only */ 56/* LM25063 only */
56 57
diff --git a/drivers/hwmon/pmbus/max34440.c b/drivers/hwmon/pmbus/max34440.c
index 7e930c3ce1ab..74a1f6f68fb3 100644
--- a/drivers/hwmon/pmbus/max34440.c
+++ b/drivers/hwmon/pmbus/max34440.c
@@ -19,6 +19,7 @@
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 20 */
21 21
22#include <linux/bitops.h>
22#include <linux/kernel.h> 23#include <linux/kernel.h>
23#include <linux/module.h> 24#include <linux/module.h>
24#include <linux/init.h> 25#include <linux/init.h>
@@ -38,10 +39,10 @@ enum chips { max34440, max34441, max34446, max34460, max34461 };
38#define MAX34446_MFR_IOUT_AVG 0xe2 39#define MAX34446_MFR_IOUT_AVG 0xe2
39#define MAX34446_MFR_TEMPERATURE_AVG 0xe3 40#define MAX34446_MFR_TEMPERATURE_AVG 0xe3
40 41
41#define MAX34440_STATUS_OC_WARN (1 << 0) 42#define MAX34440_STATUS_OC_WARN BIT(0)
42#define MAX34440_STATUS_OC_FAULT (1 << 1) 43#define MAX34440_STATUS_OC_FAULT BIT(1)
43#define MAX34440_STATUS_OT_FAULT (1 << 5) 44#define MAX34440_STATUS_OT_FAULT BIT(5)
44#define MAX34440_STATUS_OT_WARN (1 << 6) 45#define MAX34440_STATUS_OT_WARN BIT(6)
45 46
46struct max34440_data { 47struct max34440_data {
47 int id; 48 int id;
diff --git a/drivers/hwmon/pmbus/max8688.c b/drivers/hwmon/pmbus/max8688.c
index f04454a42fdd..dd4883a19045 100644
--- a/drivers/hwmon/pmbus/max8688.c
+++ b/drivers/hwmon/pmbus/max8688.c
@@ -18,6 +18,7 @@
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */ 19 */
20 20
21#include <linux/bitops.h>
21#include <linux/kernel.h> 22#include <linux/kernel.h>
22#include <linux/module.h> 23#include <linux/module.h>
23#include <linux/init.h> 24#include <linux/init.h>
@@ -30,15 +31,15 @@
30#define MAX8688_MFR_TEMPERATURE_PEAK 0xd6 31#define MAX8688_MFR_TEMPERATURE_PEAK 0xd6
31#define MAX8688_MFG_STATUS 0xd8 32#define MAX8688_MFG_STATUS 0xd8
32 33
33#define MAX8688_STATUS_OC_FAULT (1 << 4) 34#define MAX8688_STATUS_OC_FAULT BIT(4)
34#define MAX8688_STATUS_OV_FAULT (1 << 5) 35#define MAX8688_STATUS_OV_FAULT BIT(5)
35#define MAX8688_STATUS_OV_WARNING (1 << 8) 36#define MAX8688_STATUS_OV_WARNING BIT(8)
36#define MAX8688_STATUS_UV_FAULT (1 << 9) 37#define MAX8688_STATUS_UV_FAULT BIT(9)
37#define MAX8688_STATUS_UV_WARNING (1 << 10) 38#define MAX8688_STATUS_UV_WARNING BIT(10)
38#define MAX8688_STATUS_UC_FAULT (1 << 11) 39#define MAX8688_STATUS_UC_FAULT BIT(11)
39#define MAX8688_STATUS_OC_WARNING (1 << 12) 40#define MAX8688_STATUS_OC_WARNING BIT(12)
40#define MAX8688_STATUS_OT_FAULT (1 << 13) 41#define MAX8688_STATUS_OT_FAULT BIT(13)
41#define MAX8688_STATUS_OT_WARNING (1 << 14) 42#define MAX8688_STATUS_OT_WARNING BIT(14)
42 43
43static int max8688_read_word_data(struct i2c_client *client, int page, int reg) 44static int max8688_read_word_data(struct i2c_client *client, int page, int reg)
44{ 45{
diff --git a/drivers/hwmon/pmbus/pmbus.h b/drivers/hwmon/pmbus/pmbus.h
index f1cb15cfc1c0..bfcb13bae34b 100644
--- a/drivers/hwmon/pmbus/pmbus.h
+++ b/drivers/hwmon/pmbus/pmbus.h
@@ -19,11 +19,12 @@
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 20 */
21 21
22#include <linux/regulator/driver.h>
23
24#ifndef PMBUS_H 22#ifndef PMBUS_H
25#define PMBUS_H 23#define PMBUS_H
26 24
25#include <linux/bitops.h>
26#include <linux/regulator/driver.h>
27
27/* 28/*
28 * Registers 29 * Registers
29 */ 30 */
@@ -194,13 +195,13 @@ enum pmbus_regs {
194/* 195/*
195 * OPERATION 196 * OPERATION
196 */ 197 */
197#define PB_OPERATION_CONTROL_ON (1<<7) 198#define PB_OPERATION_CONTROL_ON BIT(7)
198 199
199/* 200/*
200 * CAPABILITY 201 * CAPABILITY
201 */ 202 */
202#define PB_CAPABILITY_SMBALERT (1<<4) 203#define PB_CAPABILITY_SMBALERT BIT(4)
203#define PB_CAPABILITY_ERROR_CHECK (1<<7) 204#define PB_CAPABILITY_ERROR_CHECK BIT(7)
204 205
205/* 206/*
206 * VOUT_MODE 207 * VOUT_MODE
@@ -215,94 +216,94 @@ enum pmbus_regs {
215/* 216/*
216 * Fan configuration 217 * Fan configuration
217 */ 218 */
218#define PB_FAN_2_PULSE_MASK ((1 << 0) | (1 << 1)) 219#define PB_FAN_2_PULSE_MASK (BIT(0) | BIT(1))
219#define PB_FAN_2_RPM (1 << 2) 220#define PB_FAN_2_RPM BIT(2)
220#define PB_FAN_2_INSTALLED (1 << 3) 221#define PB_FAN_2_INSTALLED BIT(3)
221#define PB_FAN_1_PULSE_MASK ((1 << 4) | (1 << 5)) 222#define PB_FAN_1_PULSE_MASK (BIT(4) | BIT(5))
222#define PB_FAN_1_RPM (1 << 6) 223#define PB_FAN_1_RPM BIT(6)
223#define PB_FAN_1_INSTALLED (1 << 7) 224#define PB_FAN_1_INSTALLED BIT(7)
224 225
225/* 226/*
226 * STATUS_BYTE, STATUS_WORD (lower) 227 * STATUS_BYTE, STATUS_WORD (lower)
227 */ 228 */
228#define PB_STATUS_NONE_ABOVE (1<<0) 229#define PB_STATUS_NONE_ABOVE BIT(0)
229#define PB_STATUS_CML (1<<1) 230#define PB_STATUS_CML BIT(1)
230#define PB_STATUS_TEMPERATURE (1<<2) 231#define PB_STATUS_TEMPERATURE BIT(2)
231#define PB_STATUS_VIN_UV (1<<3) 232#define PB_STATUS_VIN_UV BIT(3)
232#define PB_STATUS_IOUT_OC (1<<4) 233#define PB_STATUS_IOUT_OC BIT(4)
233#define PB_STATUS_VOUT_OV (1<<5) 234#define PB_STATUS_VOUT_OV BIT(5)
234#define PB_STATUS_OFF (1<<6) 235#define PB_STATUS_OFF BIT(6)
235#define PB_STATUS_BUSY (1<<7) 236#define PB_STATUS_BUSY BIT(7)
236 237
237/* 238/*
238 * STATUS_WORD (upper) 239 * STATUS_WORD (upper)
239 */ 240 */
240#define PB_STATUS_UNKNOWN (1<<8) 241#define PB_STATUS_UNKNOWN BIT(8)
241#define PB_STATUS_OTHER (1<<9) 242#define PB_STATUS_OTHER BIT(9)
242#define PB_STATUS_FANS (1<<10) 243#define PB_STATUS_FANS BIT(10)
243#define PB_STATUS_POWER_GOOD_N (1<<11) 244#define PB_STATUS_POWER_GOOD_N BIT(11)
244#define PB_STATUS_WORD_MFR (1<<12) 245#define PB_STATUS_WORD_MFR BIT(12)
245#define PB_STATUS_INPUT (1<<13) 246#define PB_STATUS_INPUT BIT(13)
246#define PB_STATUS_IOUT_POUT (1<<14) 247#define PB_STATUS_IOUT_POUT BIT(14)
247#define PB_STATUS_VOUT (1<<15) 248#define PB_STATUS_VOUT BIT(15)
248 249
249/* 250/*
250 * STATUS_IOUT 251 * STATUS_IOUT
251 */ 252 */
252#define PB_POUT_OP_WARNING (1<<0) 253#define PB_POUT_OP_WARNING BIT(0)
253#define PB_POUT_OP_FAULT (1<<1) 254#define PB_POUT_OP_FAULT BIT(1)
254#define PB_POWER_LIMITING (1<<2) 255#define PB_POWER_LIMITING BIT(2)
255#define PB_CURRENT_SHARE_FAULT (1<<3) 256#define PB_CURRENT_SHARE_FAULT BIT(3)
256#define PB_IOUT_UC_FAULT (1<<4) 257#define PB_IOUT_UC_FAULT BIT(4)
257#define PB_IOUT_OC_WARNING (1<<5) 258#define PB_IOUT_OC_WARNING BIT(5)
258#define PB_IOUT_OC_LV_FAULT (1<<6) 259#define PB_IOUT_OC_LV_FAULT BIT(6)
259#define PB_IOUT_OC_FAULT (1<<7) 260#define PB_IOUT_OC_FAULT BIT(7)
260 261
261/* 262/*
262 * STATUS_VOUT, STATUS_INPUT 263 * STATUS_VOUT, STATUS_INPUT
263 */ 264 */
264#define PB_VOLTAGE_UV_FAULT (1<<4) 265#define PB_VOLTAGE_UV_FAULT BIT(4)
265#define PB_VOLTAGE_UV_WARNING (1<<5) 266#define PB_VOLTAGE_UV_WARNING BIT(5)
266#define PB_VOLTAGE_OV_WARNING (1<<6) 267#define PB_VOLTAGE_OV_WARNING BIT(6)
267#define PB_VOLTAGE_OV_FAULT (1<<7) 268#define PB_VOLTAGE_OV_FAULT BIT(7)
268 269
269/* 270/*
270 * STATUS_INPUT 271 * STATUS_INPUT
271 */ 272 */
272#define PB_PIN_OP_WARNING (1<<0) 273#define PB_PIN_OP_WARNING BIT(0)
273#define PB_IIN_OC_WARNING (1<<1) 274#define PB_IIN_OC_WARNING BIT(1)
274#define PB_IIN_OC_FAULT (1<<2) 275#define PB_IIN_OC_FAULT BIT(2)
275 276
276/* 277/*
277 * STATUS_TEMPERATURE 278 * STATUS_TEMPERATURE
278 */ 279 */
279#define PB_TEMP_UT_FAULT (1<<4) 280#define PB_TEMP_UT_FAULT BIT(4)
280#define PB_TEMP_UT_WARNING (1<<5) 281#define PB_TEMP_UT_WARNING BIT(5)
281#define PB_TEMP_OT_WARNING (1<<6) 282#define PB_TEMP_OT_WARNING BIT(6)
282#define PB_TEMP_OT_FAULT (1<<7) 283#define PB_TEMP_OT_FAULT BIT(7)
283 284
284/* 285/*
285 * STATUS_FAN 286 * STATUS_FAN
286 */ 287 */
287#define PB_FAN_AIRFLOW_WARNING (1<<0) 288#define PB_FAN_AIRFLOW_WARNING BIT(0)
288#define PB_FAN_AIRFLOW_FAULT (1<<1) 289#define PB_FAN_AIRFLOW_FAULT BIT(1)
289#define PB_FAN_FAN2_SPEED_OVERRIDE (1<<2) 290#define PB_FAN_FAN2_SPEED_OVERRIDE BIT(2)
290#define PB_FAN_FAN1_SPEED_OVERRIDE (1<<3) 291#define PB_FAN_FAN1_SPEED_OVERRIDE BIT(3)
291#define PB_FAN_FAN2_WARNING (1<<4) 292#define PB_FAN_FAN2_WARNING BIT(4)
292#define PB_FAN_FAN1_WARNING (1<<5) 293#define PB_FAN_FAN1_WARNING BIT(5)
293#define PB_FAN_FAN2_FAULT (1<<6) 294#define PB_FAN_FAN2_FAULT BIT(6)
294#define PB_FAN_FAN1_FAULT (1<<7) 295#define PB_FAN_FAN1_FAULT BIT(7)
295 296
296/* 297/*
297 * CML_FAULT_STATUS 298 * CML_FAULT_STATUS
298 */ 299 */
299#define PB_CML_FAULT_OTHER_MEM_LOGIC (1<<0) 300#define PB_CML_FAULT_OTHER_MEM_LOGIC BIT(0)
300#define PB_CML_FAULT_OTHER_COMM (1<<1) 301#define PB_CML_FAULT_OTHER_COMM BIT(1)
301#define PB_CML_FAULT_PROCESSOR (1<<3) 302#define PB_CML_FAULT_PROCESSOR BIT(3)
302#define PB_CML_FAULT_MEMORY (1<<4) 303#define PB_CML_FAULT_MEMORY BIT(4)
303#define PB_CML_FAULT_PACKET_ERROR (1<<5) 304#define PB_CML_FAULT_PACKET_ERROR BIT(5)
304#define PB_CML_FAULT_INVALID_DATA (1<<6) 305#define PB_CML_FAULT_INVALID_DATA BIT(6)
305#define PB_CML_FAULT_INVALID_COMMAND (1<<7) 306#define PB_CML_FAULT_INVALID_COMMAND BIT(7)
306 307
307enum pmbus_sensor_classes { 308enum pmbus_sensor_classes {
308 PSC_VOLTAGE_IN = 0, 309 PSC_VOLTAGE_IN = 0,
@@ -318,26 +319,26 @@ enum pmbus_sensor_classes {
318#define PMBUS_PAGES 32 /* Per PMBus specification */ 319#define PMBUS_PAGES 32 /* Per PMBus specification */
319 320
320/* Functionality bit mask */ 321/* Functionality bit mask */
321#define PMBUS_HAVE_VIN (1 << 0) 322#define PMBUS_HAVE_VIN BIT(0)
322#define PMBUS_HAVE_VCAP (1 << 1) 323#define PMBUS_HAVE_VCAP BIT(1)
323#define PMBUS_HAVE_VOUT (1 << 2) 324#define PMBUS_HAVE_VOUT BIT(2)
324#define PMBUS_HAVE_IIN (1 << 3) 325#define PMBUS_HAVE_IIN BIT(3)
325#define PMBUS_HAVE_IOUT (1 << 4) 326#define PMBUS_HAVE_IOUT BIT(4)
326#define PMBUS_HAVE_PIN (1 << 5) 327#define PMBUS_HAVE_PIN BIT(5)
327#define PMBUS_HAVE_POUT (1 << 6) 328#define PMBUS_HAVE_POUT BIT(6)
328#define PMBUS_HAVE_FAN12 (1 << 7) 329#define PMBUS_HAVE_FAN12 BIT(7)
329#define PMBUS_HAVE_FAN34 (1 << 8) 330#define PMBUS_HAVE_FAN34 BIT(8)
330#define PMBUS_HAVE_TEMP (1 << 9) 331#define PMBUS_HAVE_TEMP BIT(9)
331#define PMBUS_HAVE_TEMP2 (1 << 10) 332#define PMBUS_HAVE_TEMP2 BIT(10)
332#define PMBUS_HAVE_TEMP3 (1 << 11) 333#define PMBUS_HAVE_TEMP3 BIT(11)
333#define PMBUS_HAVE_STATUS_VOUT (1 << 12) 334#define PMBUS_HAVE_STATUS_VOUT BIT(12)
334#define PMBUS_HAVE_STATUS_IOUT (1 << 13) 335#define PMBUS_HAVE_STATUS_IOUT BIT(13)
335#define PMBUS_HAVE_STATUS_INPUT (1 << 14) 336#define PMBUS_HAVE_STATUS_INPUT BIT(14)
336#define PMBUS_HAVE_STATUS_TEMP (1 << 15) 337#define PMBUS_HAVE_STATUS_TEMP BIT(15)
337#define PMBUS_HAVE_STATUS_FAN12 (1 << 16) 338#define PMBUS_HAVE_STATUS_FAN12 BIT(16)
338#define PMBUS_HAVE_STATUS_FAN34 (1 << 17) 339#define PMBUS_HAVE_STATUS_FAN34 BIT(17)
339#define PMBUS_HAVE_VMON (1 << 18) 340#define PMBUS_HAVE_VMON BIT(18)
340#define PMBUS_HAVE_STATUS_VMON (1 << 19) 341#define PMBUS_HAVE_STATUS_VMON BIT(19)
341 342
342enum pmbus_data_format { linear = 0, direct, vid }; 343enum pmbus_data_format { linear = 0, direct, vid };
343enum vrm_version { vr11 = 0, vr12 }; 344enum vrm_version { vr11 = 0, vr12 };
diff --git a/drivers/hwmon/pmbus/zl6100.c b/drivers/hwmon/pmbus/zl6100.c
index 819644121259..771802d7e20d 100644
--- a/drivers/hwmon/pmbus/zl6100.c
+++ b/drivers/hwmon/pmbus/zl6100.c
@@ -19,6 +19,7 @@
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 20 */
21 21
22#include <linux/bitops.h>
22#include <linux/kernel.h> 23#include <linux/kernel.h>
23#include <linux/module.h> 24#include <linux/module.h>
24#include <linux/init.h> 25#include <linux/init.h>
@@ -44,16 +45,16 @@ struct zl6100_data {
44#define ZL6100_MFR_CONFIG 0xd0 45#define ZL6100_MFR_CONFIG 0xd0
45#define ZL6100_DEVICE_ID 0xe4 46#define ZL6100_DEVICE_ID 0xe4
46 47
47#define ZL6100_MFR_XTEMP_ENABLE (1 << 7) 48#define ZL6100_MFR_XTEMP_ENABLE BIT(7)
48 49
49#define MFR_VMON_OV_FAULT_LIMIT 0xf5 50#define MFR_VMON_OV_FAULT_LIMIT 0xf5
50#define MFR_VMON_UV_FAULT_LIMIT 0xf6 51#define MFR_VMON_UV_FAULT_LIMIT 0xf6
51#define MFR_READ_VMON 0xf7 52#define MFR_READ_VMON 0xf7
52 53
53#define VMON_UV_WARNING (1 << 5) 54#define VMON_UV_WARNING BIT(5)
54#define VMON_OV_WARNING (1 << 4) 55#define VMON_OV_WARNING BIT(4)
55#define VMON_UV_FAULT (1 << 1) 56#define VMON_UV_FAULT BIT(1)
56#define VMON_OV_FAULT (1 << 0) 57#define VMON_OV_FAULT BIT(0)
57 58
58#define ZL6100_WAIT_TIME 1000 /* uS */ 59#define ZL6100_WAIT_TIME 1000 /* uS */
59 60