tps40422.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * Hardware monitoring driver for TI TPS40422
  3. *
  4. * Copyright (c) 2014 Nokia Solutions and Networks.
  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. #include <linux/kernel.h>
  17. #include <linux/module.h>
  18. #include <linux/init.h>
  19. #include <linux/err.h>
  20. #include <linux/i2c.h>
  21. #include "pmbus.h"
  22. static struct pmbus_driver_info tps40422_info = {
  23. .pages = 2,
  24. .format[PSC_VOLTAGE_IN] = linear,
  25. .format[PSC_VOLTAGE_OUT] = linear,
  26. .format[PSC_TEMPERATURE] = linear,
  27. .func[0] = PMBUS_HAVE_VOUT | PMBUS_HAVE_TEMP2
  28. | PMBUS_HAVE_STATUS_VOUT | PMBUS_HAVE_STATUS_TEMP
  29. | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT,
  30. .func[1] = PMBUS_HAVE_VOUT | PMBUS_HAVE_TEMP2
  31. | PMBUS_HAVE_STATUS_VOUT | PMBUS_HAVE_STATUS_TEMP
  32. | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT,
  33. };
  34. static int tps40422_probe(struct i2c_client *client,
  35. const struct i2c_device_id *id)
  36. {
  37. return pmbus_do_probe(client, id, &tps40422_info);
  38. }
  39. static const struct i2c_device_id tps40422_id[] = {
  40. {"tps40422", 0},
  41. {}
  42. };
  43. MODULE_DEVICE_TABLE(i2c, tps40422_id);
  44. /* This is the driver that will be inserted */
  45. static struct i2c_driver tps40422_driver = {
  46. .driver = {
  47. .name = "tps40422",
  48. },
  49. .probe = tps40422_probe,
  50. .remove = pmbus_do_remove,
  51. .id_table = tps40422_id,
  52. };
  53. module_i2c_driver(tps40422_driver);
  54. MODULE_AUTHOR("Zhu Laiwen <richard.zhu@nsn.com>");
  55. MODULE_DESCRIPTION("PMBus driver for TI TPS40422");
  56. MODULE_LICENSE("GPL");