max16064.c 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * Hardware monitoring driver for Maxim MAX16064
  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. #include <linux/kernel.h>
  21. #include <linux/module.h>
  22. #include <linux/init.h>
  23. #include <linux/err.h>
  24. #include <linux/i2c.h>
  25. #include "pmbus.h"
  26. static struct pmbus_driver_info max16064_info = {
  27. .pages = 4,
  28. .direct[PSC_VOLTAGE_IN] = true,
  29. .direct[PSC_VOLTAGE_OUT] = true,
  30. .direct[PSC_TEMPERATURE] = true,
  31. .m[PSC_VOLTAGE_IN] = 19995,
  32. .b[PSC_VOLTAGE_IN] = 0,
  33. .R[PSC_VOLTAGE_IN] = -1,
  34. .m[PSC_VOLTAGE_OUT] = 19995,
  35. .b[PSC_VOLTAGE_OUT] = 0,
  36. .R[PSC_VOLTAGE_OUT] = -1,
  37. .m[PSC_TEMPERATURE] = -7612,
  38. .b[PSC_TEMPERATURE] = 335,
  39. .R[PSC_TEMPERATURE] = -3,
  40. .func[0] = PMBUS_HAVE_VOUT | PMBUS_HAVE_TEMP
  41. | PMBUS_HAVE_STATUS_VOUT | PMBUS_HAVE_STATUS_TEMP,
  42. .func[1] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT,
  43. .func[2] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT,
  44. .func[3] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT,
  45. };
  46. static int max16064_probe(struct i2c_client *client,
  47. const struct i2c_device_id *id)
  48. {
  49. return pmbus_do_probe(client, id, &max16064_info);
  50. }
  51. static int max16064_remove(struct i2c_client *client)
  52. {
  53. return pmbus_do_remove(client);
  54. }
  55. static const struct i2c_device_id max16064_id[] = {
  56. {"max16064", 0},
  57. {}
  58. };
  59. MODULE_DEVICE_TABLE(i2c, max16064_id);
  60. /* This is the driver that will be inserted */
  61. static struct i2c_driver max16064_driver = {
  62. .driver = {
  63. .name = "max16064",
  64. },
  65. .probe = max16064_probe,
  66. .remove = max16064_remove,
  67. .id_table = max16064_id,
  68. };
  69. static int __init max16064_init(void)
  70. {
  71. return i2c_add_driver(&max16064_driver);
  72. }
  73. static void __exit max16064_exit(void)
  74. {
  75. i2c_del_driver(&max16064_driver);
  76. }
  77. MODULE_AUTHOR("Guenter Roeck");
  78. MODULE_DESCRIPTION("PMBus driver for Maxim MAX16064");
  79. MODULE_LICENSE("GPL");
  80. module_init(max16064_init);
  81. module_exit(max16064_exit);