driver core: remove drivers/base/sys.c and include/linux/sysdev.h
[zen-stable.git] / drivers / hwmon / pmbus / max16064.c
blob1d77cf4d2d442158a95ed7801ed9cd392f99fb2f
1 /*
2 * Hardware monitoring driver for Maxim MAX16064
4 * Copyright (c) 2011 Ericsson AB.
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.
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.
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.
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"
28 #define MAX16064_MFR_VOUT_PEAK 0xd4
29 #define MAX16064_MFR_TEMPERATURE_PEAK 0xd6
31 static int max16064_read_word_data(struct i2c_client *client, int page, int reg)
33 int ret;
35 switch (reg) {
36 case PMBUS_VIRT_READ_VOUT_MAX:
37 ret = pmbus_read_word_data(client, page,
38 MAX16064_MFR_VOUT_PEAK);
39 break;
40 case PMBUS_VIRT_READ_TEMP_MAX:
41 ret = pmbus_read_word_data(client, page,
42 MAX16064_MFR_TEMPERATURE_PEAK);
43 break;
44 case PMBUS_VIRT_RESET_VOUT_HISTORY:
45 case PMBUS_VIRT_RESET_TEMP_HISTORY:
46 ret = 0;
47 break;
48 default:
49 ret = -ENODATA;
50 break;
52 return ret;
55 static int max16064_write_word_data(struct i2c_client *client, int page,
56 int reg, u16 word)
58 int ret;
60 switch (reg) {
61 case PMBUS_VIRT_RESET_VOUT_HISTORY:
62 ret = pmbus_write_word_data(client, page,
63 MAX16064_MFR_VOUT_PEAK, 0);
64 break;
65 case PMBUS_VIRT_RESET_TEMP_HISTORY:
66 ret = pmbus_write_word_data(client, page,
67 MAX16064_MFR_TEMPERATURE_PEAK,
68 0xffff);
69 break;
70 default:
71 ret = -ENODATA;
72 break;
74 return ret;
77 static struct pmbus_driver_info max16064_info = {
78 .pages = 4,
79 .format[PSC_VOLTAGE_IN] = direct,
80 .format[PSC_VOLTAGE_OUT] = direct,
81 .format[PSC_TEMPERATURE] = direct,
82 .m[PSC_VOLTAGE_IN] = 19995,
83 .b[PSC_VOLTAGE_IN] = 0,
84 .R[PSC_VOLTAGE_IN] = -1,
85 .m[PSC_VOLTAGE_OUT] = 19995,
86 .b[PSC_VOLTAGE_OUT] = 0,
87 .R[PSC_VOLTAGE_OUT] = -1,
88 .m[PSC_TEMPERATURE] = -7612,
89 .b[PSC_TEMPERATURE] = 335,
90 .R[PSC_TEMPERATURE] = -3,
91 .func[0] = PMBUS_HAVE_VOUT | PMBUS_HAVE_TEMP
92 | PMBUS_HAVE_STATUS_VOUT | PMBUS_HAVE_STATUS_TEMP,
93 .func[1] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT,
94 .func[2] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT,
95 .func[3] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT,
96 .read_word_data = max16064_read_word_data,
97 .write_word_data = max16064_write_word_data,
100 static int max16064_probe(struct i2c_client *client,
101 const struct i2c_device_id *id)
103 return pmbus_do_probe(client, id, &max16064_info);
106 static int max16064_remove(struct i2c_client *client)
108 pmbus_do_remove(client);
109 return 0;
112 static const struct i2c_device_id max16064_id[] = {
113 {"max16064", 0},
117 MODULE_DEVICE_TABLE(i2c, max16064_id);
119 /* This is the driver that will be inserted */
120 static struct i2c_driver max16064_driver = {
121 .driver = {
122 .name = "max16064",
124 .probe = max16064_probe,
125 .remove = max16064_remove,
126 .id_table = max16064_id,
129 static int __init max16064_init(void)
131 return i2c_add_driver(&max16064_driver);
134 static void __exit max16064_exit(void)
136 i2c_del_driver(&max16064_driver);
139 MODULE_AUTHOR("Guenter Roeck");
140 MODULE_DESCRIPTION("PMBus driver for Maxim MAX16064");
141 MODULE_LICENSE("GPL");
142 module_init(max16064_init);
143 module_exit(max16064_exit);