ir38064.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Hardware monitoring driver for Infineon IR38064
  4. *
  5. * Copyright (c) 2017 Google Inc
  6. *
  7. * VOUT_MODE is not supported by the device. The driver fakes VOUT linear16
  8. * mode with exponent value -8 as direct mode with m=256/b=0/R=0.
  9. *
  10. * The device supports VOUT_PEAK, IOUT_PEAK, and TEMPERATURE_PEAK, however
  11. * this driver does not currently support them.
  12. */
  13. #include <linux/err.h>
  14. #include <linux/i2c.h>
  15. #include <linux/init.h>
  16. #include <linux/kernel.h>
  17. #include <linux/module.h>
  18. #include <linux/of_device.h>
  19. #include <linux/regulator/driver.h>
  20. #include "pmbus.h"
  21. #if IS_ENABLED(CONFIG_SENSORS_IR38064_REGULATOR)
  22. static const struct regulator_desc ir38064_reg_desc[] = {
  23. PMBUS_REGULATOR("vout", 0),
  24. };
  25. #endif /* CONFIG_SENSORS_IR38064_REGULATOR */
  26. static struct pmbus_driver_info ir38064_info = {
  27. .pages = 1,
  28. .format[PSC_VOLTAGE_IN] = linear,
  29. .format[PSC_VOLTAGE_OUT] = direct,
  30. .format[PSC_CURRENT_OUT] = linear,
  31. .format[PSC_POWER] = linear,
  32. .format[PSC_TEMPERATURE] = linear,
  33. .m[PSC_VOLTAGE_OUT] = 256,
  34. .b[PSC_VOLTAGE_OUT] = 0,
  35. .R[PSC_VOLTAGE_OUT] = 0,
  36. .func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_STATUS_INPUT
  37. | PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP
  38. | PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
  39. | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT
  40. | PMBUS_HAVE_POUT,
  41. #if IS_ENABLED(CONFIG_SENSORS_IR38064_REGULATOR)
  42. .num_regulators = 1,
  43. .reg_desc = ir38064_reg_desc,
  44. #endif
  45. };
  46. static int ir38064_probe(struct i2c_client *client)
  47. {
  48. return pmbus_do_probe(client, &ir38064_info);
  49. }
  50. static const struct i2c_device_id ir38064_id[] = {
  51. {"ir38060", 0},
  52. {"ir38064", 0},
  53. {"ir38164", 0},
  54. {"ir38263", 0},
  55. {}
  56. };
  57. MODULE_DEVICE_TABLE(i2c, ir38064_id);
  58. static const struct of_device_id __maybe_unused ir38064_of_match[] = {
  59. { .compatible = "infineon,ir38060" },
  60. { .compatible = "infineon,ir38064" },
  61. { .compatible = "infineon,ir38164" },
  62. { .compatible = "infineon,ir38263" },
  63. {}
  64. };
  65. MODULE_DEVICE_TABLE(of, ir38064_of_match);
  66. /* This is the driver that will be inserted */
  67. static struct i2c_driver ir38064_driver = {
  68. .driver = {
  69. .name = "ir38064",
  70. .of_match_table = of_match_ptr(ir38064_of_match),
  71. },
  72. .probe_new = ir38064_probe,
  73. .id_table = ir38064_id,
  74. };
  75. module_i2c_driver(ir38064_driver);
  76. MODULE_AUTHOR("Maxim Sloyko <[email protected]>");
  77. MODULE_DESCRIPTION("PMBus driver for Infineon IR38064 and compatible chips");
  78. MODULE_LICENSE("GPL");
  79. MODULE_IMPORT_NS(PMBUS);