hi6421-spmi-pmic.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Device driver for regulators in HISI PMIC IC
  4. *
  5. * Copyright (c) 2013 Linaro Ltd.
  6. * Copyright (c) 2011 Hisilicon.
  7. * Copyright (c) 2020-2021 Huawei Technologies Co., Ltd.
  8. */
  9. #include <linux/mfd/core.h>
  10. #include <linux/module.h>
  11. #include <linux/platform_device.h>
  12. #include <linux/regmap.h>
  13. #include <linux/slab.h>
  14. #include <linux/spmi.h>
  15. static const struct mfd_cell hi6421v600_devs[] = {
  16. { .name = "hi6421v600-irq", },
  17. { .name = "hi6421v600-regulator", },
  18. };
  19. static const struct regmap_config regmap_config = {
  20. .reg_bits = 16,
  21. .val_bits = BITS_PER_BYTE,
  22. .max_register = 0xffff,
  23. .fast_io = true
  24. };
  25. static int hi6421_spmi_pmic_probe(struct spmi_device *sdev)
  26. {
  27. struct device *dev = &sdev->dev;
  28. struct regmap *regmap;
  29. int ret;
  30. regmap = devm_regmap_init_spmi_ext(sdev, &regmap_config);
  31. if (IS_ERR(regmap))
  32. return PTR_ERR(regmap);
  33. dev_set_drvdata(&sdev->dev, regmap);
  34. ret = devm_mfd_add_devices(&sdev->dev, PLATFORM_DEVID_NONE,
  35. hi6421v600_devs, ARRAY_SIZE(hi6421v600_devs),
  36. NULL, 0, NULL);
  37. if (ret < 0)
  38. dev_err(dev, "Failed to add child devices: %d\n", ret);
  39. return ret;
  40. }
  41. static const struct of_device_id pmic_spmi_id_table[] = {
  42. { .compatible = "hisilicon,hi6421-spmi" },
  43. { }
  44. };
  45. MODULE_DEVICE_TABLE(of, pmic_spmi_id_table);
  46. static struct spmi_driver hi6421_spmi_pmic_driver = {
  47. .driver = {
  48. .name = "hi6421-spmi-pmic",
  49. .of_match_table = pmic_spmi_id_table,
  50. },
  51. .probe = hi6421_spmi_pmic_probe,
  52. };
  53. module_spmi_driver(hi6421_spmi_pmic_driver);
  54. MODULE_DESCRIPTION("HiSilicon Hi6421v600 SPMI PMIC driver");
  55. MODULE_LICENSE("GPL v2");