pmic-framework.txt 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. #
  2. # (C) Copyright 2014-2015 Samsung Electronics
  3. # Przemyslaw Marczak <p.marczak@samsung.com>
  4. #
  5. # SPDX-License-Identifier: GPL-2.0+
  6. #
  7. PMIC framework based on Driver Model
  8. ====================================
  9. TOC:
  10. 1. Introduction
  11. 2. How does it work
  12. 3. Pmic uclass
  13. 4. Regulator uclass
  14. 1. Introduction
  15. ===============
  16. This is an introduction to driver-model multi uclass PMIC IC's support.
  17. At present it's based on two uclass types:
  18. - UCLASS_PMIC - basic uclass type for PMIC I/O, which provides common
  19. read/write interface.
  20. - UCLASS_REGULATOR - additional uclass type for specific PMIC features,
  21. which are Voltage/Current regulators.
  22. New files:
  23. UCLASS_PMIC:
  24. - drivers/power/pmic/pmic-uclass.c
  25. - include/power/pmic.h
  26. UCLASS_REGULATOR:
  27. - drivers/power/regulator/regulator-uclass.c
  28. - include/power/regulator.h
  29. Commands:
  30. - common/cmd_pmic.c
  31. - common/cmd_regulator.c
  32. 2. How doees it work
  33. ====================
  34. The Power Management Integrated Circuits (PMIC) are used in embedded systems
  35. to provide stable, precise and specific voltage power source with over-voltage
  36. and thermal protection circuits.
  37. The single PMIC can provide various functions by single or multiple interfaces,
  38. like in the example below.
  39. -- SoC
  40. |
  41. | ______________________________________
  42. | BUS 0 | Multi interface PMIC IC |--> LDO out 1
  43. | e.g.I2C0 | |--> LDO out N
  44. |-----------|---- PMIC device 0 (READ/WRITE ops) |
  45. | or SPI0 | |_ REGULATOR device (ldo/... ops) |--> BUCK out 1
  46. | | |_ CHARGER device (charger ops) |--> BUCK out M
  47. | | |_ MUIC device (microUSB con ops) |
  48. | BUS 1 | |_ ... |---> BATTERY
  49. | e.g.I2C1 | |
  50. |-----------|---- PMIC device 1 (READ/WRITE ops) |---> USB in 1
  51. . or SPI1 | |_ RTC device (rtc ops) |---> USB in 2
  52. . |______________________________________|---> USB out
  53. .
  54. Since U-Boot provides driver model features for I2C and SPI bus drivers,
  55. the PMIC devices should also support this. By the pmic and regulator API's,
  56. PMIC drivers can simply provide a common functions, for multi-interface and
  57. and multi-instance device support.
  58. Basic design assumptions:
  59. - Common I/O API - UCLASS_PMIC
  60. For the multi-function PMIC devices, this can be used as parent I/O device
  61. for each IC's interface. Then, each children uses the same dev for read/write.
  62. - Common regulator API - UCLASS_REGULATOR
  63. For driving the regulator attributes, auto setting function or command line
  64. interface, based on kernel-style regulator device tree constraints.
  65. For simple implementations, regulator drivers are not required, so the code can
  66. use pmic read/write directly.
  67. 3. Pmic uclass
  68. ==============
  69. The basic information:
  70. * Uclass: 'UCLASS_PMIC'
  71. * Header: 'include/power/pmic.h'
  72. * Core: 'drivers/power/pmic/pmic-uclass.c'
  73. config: 'CONFIG_DM_PMIC'
  74. * Command: 'common/cmd_pmic.c'
  75. config: 'CONFIG_CMD_PMIC'
  76. * Example: 'drivers/power/pmic/max77686.c'
  77. For detailed API description, please refer to the header file.
  78. As an example of the pmic driver, please refer to the MAX77686 driver.
  79. Please pay attention for the driver's bind() method. Exactly the function call:
  80. 'pmic_bind_children()', which is used to bind the regulators by using the array
  81. of regulator's node, compatible prefixes.
  82. The 'pmic; command also supports the new API. So the pmic command can be enabled
  83. by adding CONFIG_CMD_PMIC.
  84. The new pmic command allows to:
  85. - list pmic devices
  86. - choose the current device (like the mmc command)
  87. - read or write the pmic register
  88. - dump all pmic registers
  89. This command can use only UCLASS_PMIC devices, since this uclass is designed
  90. for pmic I/O operations only.
  91. For more information, please refer to the core file.
  92. 4. Regulator uclass
  93. ===================
  94. The basic information:
  95. * Uclass: 'UCLASS_REGULATOR'
  96. * Header: 'include/power/regulator.h'
  97. * Core: 'drivers/power/regulator/regulator-uclass.c'
  98. config: 'CONFIG_DM_REGULATOR'
  99. binding: 'doc/device-tree-bindings/regulator/regulator.txt'
  100. * Command: 'common/cmd_regulator.c'
  101. config: 'CONFIG_CMD_REGULATOR'
  102. * Example: 'drivers/power/regulator/max77686.c'
  103. 'drivers/power/pmic/max77686.c' (required I/O driver for the above)
  104. * Example: 'drivers/power/regulator/fixed.c'
  105. config" 'CONFIG_DM_REGULATOR_FIXED'
  106. For detailed API description, please refer to the header file.
  107. For the example regulator driver, please refer to the MAX77686 regulator driver,
  108. but this driver can't operate without pmic's example driver, which provides an
  109. I/O interface for MAX77686 regulator.
  110. The second example is a fixed Voltage/Current regulator for a common use.
  111. The 'regulator' command also supports the new API. The command allow:
  112. - list regulator devices
  113. - choose the current device (like the mmc command)
  114. - do all regulator-specific operations
  115. For more information, please refer to the command file.