diff options
author | Guenter Roeck <guenter.roeck@ericsson.com> | 2011-03-17 16:16:01 -0400 |
---|---|---|
committer | Guenter Roeck <guenter.roeck@ericsson.com> | 2011-05-19 11:19:41 -0400 |
commit | 83f7649c52871d4b0799c209c364374b682fa4a8 (patch) | |
tree | e39a462b73225034026277767fa45de9832a7975 | |
parent | 0c0a0615163e025eb978547969467012529e01d5 (diff) |
hwmon: (pmbus) Add support for Analog Devices ADM1275
Add support for Analog Devices ADM1275 Hot-Swap Controller and Digital Power
Monitor
Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
Reviewed-by: Tom Grennan <tom.grennan@ericsson.com>
-rw-r--r-- | Documentation/hwmon/adm1275 | 60 | ||||
-rw-r--r-- | drivers/hwmon/Kconfig | 10 | ||||
-rw-r--r-- | drivers/hwmon/Makefile | 1 | ||||
-rw-r--r-- | drivers/hwmon/adm1275.c | 121 |
4 files changed, 192 insertions, 0 deletions
diff --git a/Documentation/hwmon/adm1275 b/Documentation/hwmon/adm1275 new file mode 100644 index 000000000000..6a3a6476cf20 --- /dev/null +++ b/Documentation/hwmon/adm1275 | |||
@@ -0,0 +1,60 @@ | |||
1 | Kernel driver adm1275 | ||
2 | ===================== | ||
3 | |||
4 | Supported chips: | ||
5 | * Analog Devices ADM1275 | ||
6 | Prefix: 'adm1275' | ||
7 | Addresses scanned: - | ||
8 | Datasheet: www.analog.com/static/imported-files/data_sheets/ADM1275.pdf | ||
9 | |||
10 | Author: Guenter Roeck <guenter.roeck@ericsson.com> | ||
11 | |||
12 | |||
13 | Description | ||
14 | ----------- | ||
15 | |||
16 | This driver supports hardware montoring for Analog Devices ADM1275 Hot-Swap | ||
17 | Controller and Digital Power Monitor. | ||
18 | |||
19 | The ADM1275 is a hot-swap controller that allows a circuit board to be removed | ||
20 | from or inserted into a live backplane. It also features current and voltage | ||
21 | readback via an integrated 12-bit analog-to-digital converter (ADC), accessed | ||
22 | using a PMBus. interface. | ||
23 | |||
24 | The driver is a client driver to the core PMBus driver. Please see | ||
25 | Documentation/hwmon/pmbus for details on PMBus client drivers. | ||
26 | |||
27 | |||
28 | Usage Notes | ||
29 | ----------- | ||
30 | |||
31 | This driver does not auto-detect devices. You will have to instantiate the | ||
32 | devices explicitly. Please see Documentation/i2c/instantiating-devices for | ||
33 | details. | ||
34 | |||
35 | |||
36 | Platform data support | ||
37 | --------------------- | ||
38 | |||
39 | The driver supports standard PMBus driver platform data. Please see | ||
40 | Documentation/hwmon/pmbus for details. | ||
41 | |||
42 | |||
43 | Sysfs entries | ||
44 | ------------- | ||
45 | |||
46 | The following attributes are supported. Limits are read-write; all other | ||
47 | attributes are read-only. | ||
48 | |||
49 | in1_label "vin1" or "vout1" depending on chip variant and | ||
50 | configuration. | ||
51 | in1_input Measured voltage. From READ_VOUT register. | ||
52 | in1_min Minumum Voltage. From VOUT_UV_WARN_LIMIT register. | ||
53 | in1_max Maximum voltage. From VOUT_OV_WARN_LIMIT register. | ||
54 | in1_min_alarm Voltage low alarm. From VOLTAGE_UV_WARNING status. | ||
55 | in1_max_alarm Voltage high alarm. From VOLTAGE_OV_WARNING status. | ||
56 | |||
57 | curr1_label "iout1" | ||
58 | curr1_input Measured current. From READ_IOUT register. | ||
59 | curr1_max Maximum current. From IOUT_OC_WARN_LIMIT register. | ||
60 | curr1_max_alarm Current high alarm. From IOUT_OC_WARN_LIMIT register. | ||
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index d00fd39f6ee3..4abd3735a76e 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig | |||
@@ -827,6 +827,16 @@ config SENSORS_PMBUS | |||
827 | This driver can also be built as a module. If so, the module will | 827 | This driver can also be built as a module. If so, the module will |
828 | be called pmbus. | 828 | be called pmbus. |
829 | 829 | ||
830 | config SENSORS_ADM1275 | ||
831 | tristate "Analog Devices ADM1275" | ||
832 | default n | ||
833 | help | ||
834 | If you say yes here you get hardware monitoring support for Analog | ||
835 | Devices ADM1275 Hot-Swap Controller and Digital Power Monitor. | ||
836 | |||
837 | This driver can also be built as a module. If so, the module will | ||
838 | be called adm1275. | ||
839 | |||
830 | config SENSORS_MAX16064 | 840 | config SENSORS_MAX16064 |
831 | tristate "Maxim MAX16064" | 841 | tristate "Maxim MAX16064" |
832 | default n | 842 | default n |
diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile index c4a269b06925..21c9b17abad5 100644 --- a/drivers/hwmon/Makefile +++ b/drivers/hwmon/Makefile | |||
@@ -120,6 +120,7 @@ obj-$(CONFIG_SENSORS_WM8350) += wm8350-hwmon.o | |||
120 | # PMBus drivers | 120 | # PMBus drivers |
121 | obj-$(CONFIG_PMBUS) += pmbus_core.o | 121 | obj-$(CONFIG_PMBUS) += pmbus_core.o |
122 | obj-$(CONFIG_SENSORS_PMBUS) += pmbus.o | 122 | obj-$(CONFIG_SENSORS_PMBUS) += pmbus.o |
123 | obj-$(CONFIG_SENSORS_ADM1275) += adm1275.o | ||
123 | obj-$(CONFIG_SENSORS_MAX16064) += max16064.o | 124 | obj-$(CONFIG_SENSORS_MAX16064) += max16064.o |
124 | obj-$(CONFIG_SENSORS_MAX34440) += max34440.o | 125 | obj-$(CONFIG_SENSORS_MAX34440) += max34440.o |
125 | obj-$(CONFIG_SENSORS_MAX8688) += max8688.o | 126 | obj-$(CONFIG_SENSORS_MAX8688) += max8688.o |
diff --git a/drivers/hwmon/adm1275.c b/drivers/hwmon/adm1275.c new file mode 100644 index 000000000000..c2ee2048ab91 --- /dev/null +++ b/drivers/hwmon/adm1275.c | |||
@@ -0,0 +1,121 @@ | |||
1 | /* | ||
2 | * Hardware monitoring driver for Analog Devices ADM1275 Hot-Swap Controller | ||
3 | * and Digital Power Monitor | ||
4 | * | ||
5 | * Copyright (c) 2011 Ericsson AB. | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | */ | ||
17 | |||
18 | #include <linux/kernel.h> | ||
19 | #include <linux/module.h> | ||
20 | #include <linux/init.h> | ||
21 | #include <linux/err.h> | ||
22 | #include <linux/slab.h> | ||
23 | #include <linux/i2c.h> | ||
24 | #include "pmbus.h" | ||
25 | |||
26 | #define ADM1275_PMON_CONFIG 0xd4 | ||
27 | |||
28 | #define ADM1275_VIN_VOUT_SELECT (1 << 6) | ||
29 | #define ADM1275_VRANGE (1 << 5) | ||
30 | |||
31 | static int adm1275_probe(struct i2c_client *client, | ||
32 | const struct i2c_device_id *id) | ||
33 | { | ||
34 | int config; | ||
35 | struct pmbus_driver_info *info; | ||
36 | |||
37 | if (!i2c_check_functionality(client->adapter, | ||
38 | I2C_FUNC_SMBUS_READ_BYTE_DATA)) | ||
39 | return -ENODEV; | ||
40 | |||
41 | info = kzalloc(sizeof(struct pmbus_driver_info), GFP_KERNEL); | ||
42 | if (!info) | ||
43 | return -ENOMEM; | ||
44 | |||
45 | config = i2c_smbus_read_byte_data(client, ADM1275_PMON_CONFIG); | ||
46 | if (config < 0) | ||
47 | return config; | ||
48 | |||
49 | info->pages = 1; | ||
50 | info->direct[PSC_VOLTAGE_IN] = true; | ||
51 | info->direct[PSC_VOLTAGE_OUT] = true; | ||
52 | info->direct[PSC_CURRENT_OUT] = true; | ||
53 | info->m[PSC_CURRENT_OUT] = 800; | ||
54 | info->b[PSC_CURRENT_OUT] = 20475; | ||
55 | info->R[PSC_CURRENT_OUT] = -1; | ||
56 | info->func[0] = PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT; | ||
57 | |||
58 | if (config & ADM1275_VRANGE) { | ||
59 | info->m[PSC_VOLTAGE_IN] = 19045; | ||
60 | info->b[PSC_VOLTAGE_IN] = 0; | ||
61 | info->R[PSC_VOLTAGE_IN] = -2; | ||
62 | info->m[PSC_VOLTAGE_OUT] = 19045; | ||
63 | info->b[PSC_VOLTAGE_OUT] = 0; | ||
64 | info->R[PSC_VOLTAGE_OUT] = -2; | ||
65 | } else { | ||
66 | info->m[PSC_VOLTAGE_IN] = 6666; | ||
67 | info->b[PSC_VOLTAGE_IN] = 0; | ||
68 | info->R[PSC_VOLTAGE_IN] = -1; | ||
69 | info->m[PSC_VOLTAGE_OUT] = 6666; | ||
70 | info->b[PSC_VOLTAGE_OUT] = 0; | ||
71 | info->R[PSC_VOLTAGE_OUT] = -1; | ||
72 | } | ||
73 | |||
74 | if (config & ADM1275_VIN_VOUT_SELECT) | ||
75 | info->func[0] |= PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT; | ||
76 | else | ||
77 | info->func[0] |= PMBUS_HAVE_VIN | PMBUS_HAVE_STATUS_INPUT; | ||
78 | |||
79 | return pmbus_do_probe(client, id, info); | ||
80 | } | ||
81 | |||
82 | static int adm1275_remove(struct i2c_client *client) | ||
83 | { | ||
84 | const struct pmbus_driver_info *info = pmbus_get_driver_info(client); | ||
85 | int ret; | ||
86 | |||
87 | ret = pmbus_do_remove(client); | ||
88 | kfree(info); | ||
89 | return ret; | ||
90 | } | ||
91 | |||
92 | static const struct i2c_device_id adm1275_id[] = { | ||
93 | {"adm1275", 0}, | ||
94 | { } | ||
95 | }; | ||
96 | MODULE_DEVICE_TABLE(i2c, adm1275_id); | ||
97 | |||
98 | static struct i2c_driver adm1275_driver = { | ||
99 | .driver = { | ||
100 | .name = "adm1275", | ||
101 | }, | ||
102 | .probe = adm1275_probe, | ||
103 | .remove = adm1275_remove, | ||
104 | .id_table = adm1275_id, | ||
105 | }; | ||
106 | |||
107 | static int __init adm1275_init(void) | ||
108 | { | ||
109 | return i2c_add_driver(&adm1275_driver); | ||
110 | } | ||
111 | |||
112 | static void __exit adm1275_exit(void) | ||
113 | { | ||
114 | i2c_del_driver(&adm1275_driver); | ||
115 | } | ||
116 | |||
117 | MODULE_AUTHOR("Guenter Roeck"); | ||
118 | MODULE_DESCRIPTION("PMBus driver for Analog Devices ADM1275"); | ||
119 | MODULE_LICENSE("GPL"); | ||
120 | module_init(adm1275_init); | ||
121 | module_exit(adm1275_exit); | ||