xref: /linux/drivers/hwmon/pmbus/max16064.c (revision 1061d8518f8bde548a03a5ff77dbe9a4202ad826)
19d2ecfb7SGuenter Roeck /*
29d2ecfb7SGuenter Roeck  * Hardware monitoring driver for Maxim MAX16064
39d2ecfb7SGuenter Roeck  *
49d2ecfb7SGuenter Roeck  * Copyright (c) 2011 Ericsson AB.
59d2ecfb7SGuenter Roeck  *
69d2ecfb7SGuenter Roeck  * This program is free software; you can redistribute it and/or modify
79d2ecfb7SGuenter Roeck  * it under the terms of the GNU General Public License as published by
89d2ecfb7SGuenter Roeck  * the Free Software Foundation; either version 2 of the License, or
99d2ecfb7SGuenter Roeck  * (at your option) any later version.
109d2ecfb7SGuenter Roeck  *
119d2ecfb7SGuenter Roeck  * This program is distributed in the hope that it will be useful,
129d2ecfb7SGuenter Roeck  * but WITHOUT ANY WARRANTY; without even the implied warranty of
139d2ecfb7SGuenter Roeck  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
149d2ecfb7SGuenter Roeck  * GNU General Public License for more details.
159d2ecfb7SGuenter Roeck  *
169d2ecfb7SGuenter Roeck  * You should have received a copy of the GNU General Public License
179d2ecfb7SGuenter Roeck  * along with this program; if not, write to the Free Software
189d2ecfb7SGuenter Roeck  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
199d2ecfb7SGuenter Roeck  */
209d2ecfb7SGuenter Roeck 
219d2ecfb7SGuenter Roeck #include <linux/kernel.h>
229d2ecfb7SGuenter Roeck #include <linux/module.h>
239d2ecfb7SGuenter Roeck #include <linux/init.h>
249d2ecfb7SGuenter Roeck #include <linux/err.h>
259d2ecfb7SGuenter Roeck #include <linux/i2c.h>
269d2ecfb7SGuenter Roeck #include "pmbus.h"
279d2ecfb7SGuenter Roeck 
289d2ecfb7SGuenter Roeck static struct pmbus_driver_info max16064_info = {
299d2ecfb7SGuenter Roeck 	.pages = 4,
30*1061d851SGuenter Roeck 	.format[PSC_VOLTAGE_IN] = direct,
31*1061d851SGuenter Roeck 	.format[PSC_VOLTAGE_OUT] = direct,
32*1061d851SGuenter Roeck 	.format[PSC_TEMPERATURE] = direct,
339d2ecfb7SGuenter Roeck 	.m[PSC_VOLTAGE_IN] = 19995,
349d2ecfb7SGuenter Roeck 	.b[PSC_VOLTAGE_IN] = 0,
359d2ecfb7SGuenter Roeck 	.R[PSC_VOLTAGE_IN] = -1,
369d2ecfb7SGuenter Roeck 	.m[PSC_VOLTAGE_OUT] = 19995,
379d2ecfb7SGuenter Roeck 	.b[PSC_VOLTAGE_OUT] = 0,
389d2ecfb7SGuenter Roeck 	.R[PSC_VOLTAGE_OUT] = -1,
399d2ecfb7SGuenter Roeck 	.m[PSC_TEMPERATURE] = -7612,
409d2ecfb7SGuenter Roeck 	.b[PSC_TEMPERATURE] = 335,
419d2ecfb7SGuenter Roeck 	.R[PSC_TEMPERATURE] = -3,
429d2ecfb7SGuenter Roeck 	.func[0] = PMBUS_HAVE_VOUT | PMBUS_HAVE_TEMP
439d2ecfb7SGuenter Roeck 		| PMBUS_HAVE_STATUS_VOUT | PMBUS_HAVE_STATUS_TEMP,
449d2ecfb7SGuenter Roeck 	.func[1] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT,
459d2ecfb7SGuenter Roeck 	.func[2] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT,
469d2ecfb7SGuenter Roeck 	.func[3] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT,
479d2ecfb7SGuenter Roeck };
489d2ecfb7SGuenter Roeck 
499d2ecfb7SGuenter Roeck static int max16064_probe(struct i2c_client *client,
509d2ecfb7SGuenter Roeck 			  const struct i2c_device_id *id)
519d2ecfb7SGuenter Roeck {
529d2ecfb7SGuenter Roeck 	return pmbus_do_probe(client, id, &max16064_info);
539d2ecfb7SGuenter Roeck }
549d2ecfb7SGuenter Roeck 
559d2ecfb7SGuenter Roeck static int max16064_remove(struct i2c_client *client)
569d2ecfb7SGuenter Roeck {
579d2ecfb7SGuenter Roeck 	return pmbus_do_remove(client);
589d2ecfb7SGuenter Roeck }
599d2ecfb7SGuenter Roeck 
609d2ecfb7SGuenter Roeck static const struct i2c_device_id max16064_id[] = {
619d2ecfb7SGuenter Roeck 	{"max16064", 0},
629d2ecfb7SGuenter Roeck 	{}
639d2ecfb7SGuenter Roeck };
649d2ecfb7SGuenter Roeck 
659d2ecfb7SGuenter Roeck MODULE_DEVICE_TABLE(i2c, max16064_id);
669d2ecfb7SGuenter Roeck 
679d2ecfb7SGuenter Roeck /* This is the driver that will be inserted */
689d2ecfb7SGuenter Roeck static struct i2c_driver max16064_driver = {
699d2ecfb7SGuenter Roeck 	.driver = {
709d2ecfb7SGuenter Roeck 		   .name = "max16064",
719d2ecfb7SGuenter Roeck 		   },
729d2ecfb7SGuenter Roeck 	.probe = max16064_probe,
739d2ecfb7SGuenter Roeck 	.remove = max16064_remove,
749d2ecfb7SGuenter Roeck 	.id_table = max16064_id,
759d2ecfb7SGuenter Roeck };
769d2ecfb7SGuenter Roeck 
779d2ecfb7SGuenter Roeck static int __init max16064_init(void)
789d2ecfb7SGuenter Roeck {
799d2ecfb7SGuenter Roeck 	return i2c_add_driver(&max16064_driver);
809d2ecfb7SGuenter Roeck }
819d2ecfb7SGuenter Roeck 
829d2ecfb7SGuenter Roeck static void __exit max16064_exit(void)
839d2ecfb7SGuenter Roeck {
849d2ecfb7SGuenter Roeck 	i2c_del_driver(&max16064_driver);
859d2ecfb7SGuenter Roeck }
869d2ecfb7SGuenter Roeck 
879d2ecfb7SGuenter Roeck MODULE_AUTHOR("Guenter Roeck");
889d2ecfb7SGuenter Roeck MODULE_DESCRIPTION("PMBus driver for Maxim MAX16064");
899d2ecfb7SGuenter Roeck MODULE_LICENSE("GPL");
909d2ecfb7SGuenter Roeck module_init(max16064_init);
919d2ecfb7SGuenter Roeck module_exit(max16064_exit);
92