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