aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon
diff options
context:
space:
mode:
authorGuenter Roeck <guenter.roeck@ericsson.com>2011-01-26 23:11:04 -0500
committerGuenter Roeck <guenter.roeck@ericsson.com>2011-03-15 01:39:06 -0400
commit8ea3238ba16fbf06ff20b2979f894dc88383584a (patch)
tree6defaab5e756c6af736540e7894a34f57ae25c92 /drivers/hwmon
parent44f5a408ba0dd873784fbb07815db8edb5e00d20 (diff)
hwmon: (pmbus) Add support for Maxim MAX8688
Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com> Acked-by: Jonathan Cameron <jic23@cam.ac.uk>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/Kconfig10
-rw-r--r--drivers/hwmon/Makefile1
-rw-r--r--drivers/hwmon/max8688.c158
3 files changed, 169 insertions, 0 deletions
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index ac116693e357..521f191fcbe3 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -779,6 +779,16 @@ config SENSORS_PMBUS
779 This driver can also be built as a module. If so, the module will 779 This driver can also be built as a module. If so, the module will
780 be called pmbus. 780 be called pmbus.
781 781
782config SENSORS_MAX8688
783 tristate "Maxim MAX8688"
784 default n
785 help
786 If you say yes here you get hardware monitoring support for Maxim
787 MAX8688.
788
789 This driver can also be built as a module. If so, the module will
790 be called max8688.
791
782endif # PMBUS 792endif # PMBUS
783 793
784config SENSORS_SHT15 794config SENSORS_SHT15
diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile
index 09e67955fd57..0e7cf92d1b56 100644
--- a/drivers/hwmon/Makefile
+++ b/drivers/hwmon/Makefile
@@ -117,6 +117,7 @@ obj-$(CONFIG_SENSORS_WM8350) += wm8350-hwmon.o
117# PMBus drivers 117# PMBus drivers
118obj-$(CONFIG_PMBUS) += pmbus_core.o 118obj-$(CONFIG_PMBUS) += pmbus_core.o
119obj-$(CONFIG_SENSORS_PMBUS) += pmbus.o 119obj-$(CONFIG_SENSORS_PMBUS) += pmbus.o
120obj-$(CONFIG_SENSORS_MAX8688) += max8688.o
120 121
121ifeq ($(CONFIG_HWMON_DEBUG_CHIP),y) 122ifeq ($(CONFIG_HWMON_DEBUG_CHIP),y)
122EXTRA_CFLAGS += -DDEBUG 123EXTRA_CFLAGS += -DDEBUG
diff --git a/drivers/hwmon/max8688.c b/drivers/hwmon/max8688.c
new file mode 100644
index 000000000000..8ebfef2ecf26
--- /dev/null
+++ b/drivers/hwmon/max8688.c
@@ -0,0 +1,158 @@
1/*
2 * Hardware monitoring driver for Maxim MAX8688
3 *
4 * Copyright (c) 2011 Ericsson AB.
5 *
6 * 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 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21#include <linux/kernel.h>
22#include <linux/module.h>
23#include <linux/init.h>
24#include <linux/err.h>
25#include <linux/i2c.h>
26#include "pmbus.h"
27
28#define MAX8688_MFG_STATUS 0xd8
29
30#define MAX8688_STATUS_OC_FAULT (1 << 4)
31#define MAX8688_STATUS_OV_FAULT (1 << 5)
32#define MAX8688_STATUS_OV_WARNING (1 << 8)
33#define MAX8688_STATUS_UV_FAULT (1 << 9)
34#define MAX8688_STATUS_UV_WARNING (1 << 10)
35#define MAX8688_STATUS_UC_FAULT (1 << 11)
36#define MAX8688_STATUS_OC_WARNING (1 << 12)
37#define MAX8688_STATUS_OT_FAULT (1 << 13)
38#define MAX8688_STATUS_OT_WARNING (1 << 14)
39
40static int max8688_get_status(struct i2c_client *client, int page, int reg)
41{
42 int ret = 0;
43 int mfg_status;
44
45 if (page)
46 return -EINVAL;
47
48 switch (reg) {
49 case PMBUS_STATUS_VOUT:
50 mfg_status = pmbus_read_word_data(client, 0,
51 MAX8688_MFG_STATUS);
52 if (mfg_status < 0)
53 return mfg_status;
54 if (mfg_status & MAX8688_STATUS_UV_WARNING)
55 ret |= PB_VOLTAGE_UV_WARNING;
56 if (mfg_status & MAX8688_STATUS_UV_FAULT)
57 ret |= PB_VOLTAGE_UV_FAULT;
58 if (mfg_status & MAX8688_STATUS_OV_WARNING)
59 ret |= PB_VOLTAGE_OV_WARNING;
60 if (mfg_status & MAX8688_STATUS_OV_FAULT)
61 ret |= PB_VOLTAGE_OV_FAULT;
62 break;
63 case PMBUS_STATUS_IOUT:
64 mfg_status = pmbus_read_word_data(client, 0,
65 MAX8688_MFG_STATUS);
66 if (mfg_status < 0)
67 return mfg_status;
68 if (mfg_status & MAX8688_STATUS_UC_FAULT)
69 ret |= PB_IOUT_UC_FAULT;
70 if (mfg_status & MAX8688_STATUS_OC_WARNING)
71 ret |= PB_IOUT_OC_WARNING;
72 if (mfg_status & MAX8688_STATUS_OC_FAULT)
73 ret |= PB_IOUT_OC_FAULT;
74 break;
75 case PMBUS_STATUS_TEMPERATURE:
76 mfg_status = pmbus_read_word_data(client, 0,
77 MAX8688_MFG_STATUS);
78 if (mfg_status < 0)
79 return mfg_status;
80 if (mfg_status & MAX8688_STATUS_OT_WARNING)
81 ret |= PB_TEMP_OT_WARNING;
82 if (mfg_status & MAX8688_STATUS_OT_FAULT)
83 ret |= PB_TEMP_OT_FAULT;
84 break;
85 default:
86 ret = -ENODATA;
87 break;
88 }
89 return ret;
90}
91
92static struct pmbus_driver_info max8688_info = {
93 .pages = 1,
94 .direct[PSC_VOLTAGE_IN] = true,
95 .direct[PSC_VOLTAGE_OUT] = true,
96 .direct[PSC_TEMPERATURE] = true,
97 .direct[PSC_CURRENT_OUT] = true,
98 .m[PSC_VOLTAGE_IN] = 19995,
99 .b[PSC_VOLTAGE_IN] = 0,
100 .R[PSC_VOLTAGE_IN] = -1,
101 .m[PSC_VOLTAGE_OUT] = 19995,
102 .b[PSC_VOLTAGE_OUT] = 0,
103 .R[PSC_VOLTAGE_OUT] = -1,
104 .m[PSC_CURRENT_OUT] = 23109,
105 .b[PSC_CURRENT_OUT] = 0,
106 .R[PSC_CURRENT_OUT] = -2,
107 .m[PSC_TEMPERATURE] = -7612,
108 .b[PSC_TEMPERATURE] = 335,
109 .R[PSC_TEMPERATURE] = -3,
110 .func[0] = PMBUS_HAVE_VOUT | PMBUS_HAVE_IOUT | PMBUS_HAVE_TEMP
111 | PMBUS_HAVE_STATUS_VOUT | PMBUS_HAVE_STATUS_IOUT
112 | PMBUS_HAVE_STATUS_TEMP,
113 .get_status = max8688_get_status,
114};
115
116static int max8688_probe(struct i2c_client *client,
117 const struct i2c_device_id *id)
118{
119 return pmbus_do_probe(client, id, &max8688_info);
120}
121
122static int max8688_remove(struct i2c_client *client)
123{
124 return pmbus_do_remove(client);
125}
126
127static const struct i2c_device_id max8688_id[] = {
128 {"max8688", 0},
129 { }
130};
131
132MODULE_DEVICE_TABLE(i2c, max8688_id);
133
134/* This is the driver that will be inserted */
135static struct i2c_driver max8688_driver = {
136 .driver = {
137 .name = "max8688",
138 },
139 .probe = max8688_probe,
140 .remove = max8688_remove,
141 .id_table = max8688_id,
142};
143
144static int __init max8688_init(void)
145{
146 return i2c_add_driver(&max8688_driver);
147}
148
149static void __exit max8688_exit(void)
150{
151 i2c_del_driver(&max8688_driver);
152}
153
154MODULE_AUTHOR("Guenter Roeck");
155MODULE_DESCRIPTION("PMBus driver for Maxim MAX8688");
156MODULE_LICENSE("GPL");
157module_init(max8688_init);
158module_exit(max8688_exit);