qcom-spmi-pmic.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Copyright (c) 2014, The Linux Foundation. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 and
  6. * only version 2 as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. */
  13. #include <linux/kernel.h>
  14. #include <linux/module.h>
  15. #include <linux/spmi.h>
  16. #include <linux/regmap.h>
  17. #include <linux/of_platform.h>
  18. static const struct regmap_config spmi_regmap_config = {
  19. .reg_bits = 16,
  20. .val_bits = 8,
  21. .max_register = 0xffff,
  22. .fast_io = true,
  23. };
  24. static int pmic_spmi_probe(struct spmi_device *sdev)
  25. {
  26. struct device_node *root = sdev->dev.of_node;
  27. struct regmap *regmap;
  28. regmap = devm_regmap_init_spmi_ext(sdev, &spmi_regmap_config);
  29. if (IS_ERR(regmap))
  30. return PTR_ERR(regmap);
  31. return of_platform_populate(root, NULL, NULL, &sdev->dev);
  32. }
  33. static void pmic_spmi_remove(struct spmi_device *sdev)
  34. {
  35. of_platform_depopulate(&sdev->dev);
  36. }
  37. static const struct of_device_id pmic_spmi_id_table[] = {
  38. { .compatible = "qcom,spmi-pmic" },
  39. { .compatible = "qcom,pm8941" },
  40. { .compatible = "qcom,pm8841" },
  41. { .compatible = "qcom,pma8084" },
  42. { }
  43. };
  44. MODULE_DEVICE_TABLE(of, pmic_spmi_id_table);
  45. static struct spmi_driver pmic_spmi_driver = {
  46. .probe = pmic_spmi_probe,
  47. .remove = pmic_spmi_remove,
  48. .driver = {
  49. .name = "pmic-spmi",
  50. .of_match_table = pmic_spmi_id_table,
  51. },
  52. };
  53. module_spmi_driver(pmic_spmi_driver);
  54. MODULE_DESCRIPTION("Qualcomm SPMI PMIC driver");
  55. MODULE_ALIAS("spmi:spmi-pmic");
  56. MODULE_LICENSE("GPL v2");
  57. MODULE_AUTHOR("Josh Cartwright <joshc@codeaurora.org>");
  58. MODULE_AUTHOR("Stanimir Varbanov <svarbanov@mm-sol.com>");