Re: [U-Boot] [PATCH v3 13/17] doc: driver-model: pmic and regulator uclass documentation

2015-04-03 Thread Przemyslaw Marczak

Hello Simon,

On 03/29/2015 03:08 PM, Simon Glass wrote:

Hi Przemyslaw,

On 24 March 2015 at 14:30, Przemyslaw Marczak p.marc...@samsung.com wrote:

Signed-off-by: Przemyslaw Marczak p.marc...@samsung.com
---
Changes v2, V3:
- update documentation with the framework api changes
- remove doc file name 'dm' prefix
---
  doc/driver-model/pmic-framework.txt | 350 
  1 file changed, 350 insertions(+)
  create mode 100644 doc/driver-model/pmic-framework.txt

diff --git a/doc/driver-model/pmic-framework.txt 
b/doc/driver-model/pmic-framework.txt
new file mode 100644
index 000..72651dc
--- /dev/null
+++ b/doc/driver-model/pmic-framework.txt
@@ -0,0 +1,350 @@
+#
+# (C) Copyright 2014-2015 Samsung Electronics
+# Przemyslaw Marczak p.marc...@samsung.com
+#
+# SPDX-License-Identifier:  GPL-2.0+
+#
+
+PMIC framework based on Driver Model
+
+TOC:
+1. Introduction
+2. How does it work
+3. Pmic driver api
+4. Pmic driver
+5. Pmic command
+6. Regulator driver api
+7. Regulator driver
+8. Regulator command
+
+1. Introduction
+===
+This is an introduction to driver-model multi uclass PMIC devices support.
+At present it is based on two uclass types:
+
+- UCLASS_PMIC  - basic uclass type for PMIC I/O, which provides common
+ read/write interface.
+- UCLASS_REGULATOR - additional uclass type for specific PMIC features, which
+ are various voltage regulators.
+
+New files:
+UCLASS_PMIC:
+- drivers/power/pmic-uclass.c
+- include/power/pmic.h
+UCLASS_REGULATOR:
+- drivers/power/regulator-uclass.c
+- include/power/regulator.h
+
+Commands:
+- lib/cmd_pmic.c
+- lib/cmd_regulator.c
+
+2. How doees it work
+
+The Power Management Integrated Circuits (PMIC) are used in embedded systems
+to provide stable, precise and specific voltage power source with over-voltage
+and thermal protection circuits.
+
+The single PMIC can provide various functionalities with single or multiple
+interfaces, like in the example below.
+
+-- SoC
+ |
+ |__
+ | BUS 0 |   Multi interface PMIC IC|-- LDO out 1
+ | e.g.I2C0  |  |-- LDO out N
+ |---| PMIC device 0 (READ/WRITE ops)   |
+ | or SPI0   ||_ REGULATOR device (ldo/... ops) |-- BUCK out 1
+ |   ||_ CHARGER device (charger ops)   |-- BUCK out M
+ |   ||_ MUIC device (microUSB con ops) |
+ | BUS 1 ||_ ...|--- BATTERY
+ | e.g.I2C1  |  |
+ |---| PMIC device 1 (READ/WRITE ops)   |--- USB in 1
+ . or SPI1   ||_ RTC device (rtc ops)   |--- USB in 2
+ .   |__|--- USB out
+ .
+
+Since U-Boot provides driver model features for I2C and SPI bus drivers,
+the PMIC devices should also support this. With the new basic uclass types
+for PMIC I/O and regulator features, PMIC drivers can simply provide common
+features, with multiple interface and instance support.
+
+Basic design assumptions:
+
+- Common I/O api - UCLASS_PMIC
+The main assumption is to use UCLASS_PMIC device to provide I/O interface,


an I/O interface


+for devices other uclass types. It is no matter what is the type of device
+physical I/O interface.


devices of other uclass types. It doesn't matter what type of physical
I/O interface is used.


Usually PMIC devices are using SPI or I2C interface,

s/are using/use/


+but use of any other interface (e.g. when PMIC is not directly connected
+to the SoC) - is now possible. Drivers can use the same read/write api.
+
+- Common regulator api - UCLASS_REGULATOR
+For setting the attributes of verious types of regulators with common api,


various

with a common


+this uclass can be implemented. This allows to drive the each regulator output


allows driving each regulator's output


+value, on/off state and custom defined operation modes. It also provides the


custom-defined

or perhaps just 'particular'


+user interface for all operations.
+For the very simple implementation, the regulator drivers are not required,


For simple implementations, regulator drivers are not required, so the
code can use pmic read/write directly.


+so the code could base on pmic read/write only.
+
+When board device-tree file includes pmic subnode and the U_Boot compatible
+driver exists, then the pmic device bind should looks like this:
+
+|_ root - will bind the device for I2C/SPI bus node
+  |_ i2c/spi - should bind a device for pmic node
+|_ pmic (parent) - should bind child devices for its features
+  |_ regulator (child)
+  |_ charger   (child)
+  |_ other (child)
+
+Usually PMIC design provides:
+ - single I/O interface (single UCLASS_PMIC driver)
+   Then UCLASS_PMIC device should be a parent of all pmic devices, where each
+   is usually different uclass type, but 

Re: [U-Boot] [PATCH v3 13/17] doc: driver-model: pmic and regulator uclass documentation

2015-03-29 Thread Simon Glass
Hi Przemyslaw,

On 24 March 2015 at 14:30, Przemyslaw Marczak p.marc...@samsung.com wrote:
 Signed-off-by: Przemyslaw Marczak p.marc...@samsung.com
 ---
 Changes v2, V3:
 - update documentation with the framework api changes
 - remove doc file name 'dm' prefix
 ---
  doc/driver-model/pmic-framework.txt | 350 
 
  1 file changed, 350 insertions(+)
  create mode 100644 doc/driver-model/pmic-framework.txt

 diff --git a/doc/driver-model/pmic-framework.txt 
 b/doc/driver-model/pmic-framework.txt
 new file mode 100644
 index 000..72651dc
 --- /dev/null
 +++ b/doc/driver-model/pmic-framework.txt
 @@ -0,0 +1,350 @@
 +#
 +# (C) Copyright 2014-2015 Samsung Electronics
 +# Przemyslaw Marczak p.marc...@samsung.com
 +#
 +# SPDX-License-Identifier:  GPL-2.0+
 +#
 +
 +PMIC framework based on Driver Model
 +
 +TOC:
 +1. Introduction
 +2. How does it work
 +3. Pmic driver api
 +4. Pmic driver
 +5. Pmic command
 +6. Regulator driver api
 +7. Regulator driver
 +8. Regulator command
 +
 +1. Introduction
 +===
 +This is an introduction to driver-model multi uclass PMIC devices support.
 +At present it is based on two uclass types:
 +
 +- UCLASS_PMIC  - basic uclass type for PMIC I/O, which provides common
 + read/write interface.
 +- UCLASS_REGULATOR - additional uclass type for specific PMIC features, which
 + are various voltage regulators.
 +
 +New files:
 +UCLASS_PMIC:
 +- drivers/power/pmic-uclass.c
 +- include/power/pmic.h
 +UCLASS_REGULATOR:
 +- drivers/power/regulator-uclass.c
 +- include/power/regulator.h
 +
 +Commands:
 +- lib/cmd_pmic.c
 +- lib/cmd_regulator.c
 +
 +2. How doees it work
 +
 +The Power Management Integrated Circuits (PMIC) are used in embedded systems
 +to provide stable, precise and specific voltage power source with 
 over-voltage
 +and thermal protection circuits.
 +
 +The single PMIC can provide various functionalities with single or multiple
 +interfaces, like in the example below.
 +
 +-- SoC
 + |
 + |__
 + | BUS 0 |   Multi interface PMIC IC|-- LDO out 1
 + | e.g.I2C0  |  |-- LDO out N
 + |---| PMIC device 0 (READ/WRITE ops)   |
 + | or SPI0   ||_ REGULATOR device (ldo/... ops) |-- BUCK out 1
 + |   ||_ CHARGER device (charger ops)   |-- BUCK out M
 + |   ||_ MUIC device (microUSB con ops) |
 + | BUS 1 ||_ ...|--- BATTERY
 + | e.g.I2C1  |  |
 + |---| PMIC device 1 (READ/WRITE ops)   |--- USB in 1
 + . or SPI1   ||_ RTC device (rtc ops)   |--- USB in 2
 + .   |__|--- USB out
 + .
 +
 +Since U-Boot provides driver model features for I2C and SPI bus drivers,
 +the PMIC devices should also support this. With the new basic uclass types
 +for PMIC I/O and regulator features, PMIC drivers can simply provide common
 +features, with multiple interface and instance support.
 +
 +Basic design assumptions:
 +
 +- Common I/O api - UCLASS_PMIC
 +The main assumption is to use UCLASS_PMIC device to provide I/O interface,

an I/O interface

 +for devices other uclass types. It is no matter what is the type of device
 +physical I/O interface.

devices of other uclass types. It doesn't matter what type of physical
I/O interface is used.


Usually PMIC devices are using SPI or I2C interface,

s/are using/use/

 +but use of any other interface (e.g. when PMIC is not directly connected
 +to the SoC) - is now possible. Drivers can use the same read/write api.
 +
 +- Common regulator api - UCLASS_REGULATOR
 +For setting the attributes of verious types of regulators with common api,

various

with a common

 +this uclass can be implemented. This allows to drive the each regulator 
 output

allows driving each regulator's output

 +value, on/off state and custom defined operation modes. It also provides the

custom-defined

or perhaps just 'particular'

 +user interface for all operations.
 +For the very simple implementation, the regulator drivers are not required,

For simple implementations, regulator drivers are not required, so the
code can use pmic read/write directly.

 +so the code could base on pmic read/write only.
 +
 +When board device-tree file includes pmic subnode and the U_Boot compatible
 +driver exists, then the pmic device bind should looks like this:
 +
 +|_ root - will bind the device for I2C/SPI bus node
 +  |_ i2c/spi - should bind a device for pmic node
 +|_ pmic (parent) - should bind child devices for its features
 +  |_ regulator (child)
 +  |_ charger   (child)
 +  |_ other (child)
 +
 +Usually PMIC design provides:
 + - single I/O interface (single UCLASS_PMIC driver)
 +   Then UCLASS_PMIC device should be a parent of all pmic devices, where 

[U-Boot] [PATCH v3 13/17] doc: driver-model: pmic and regulator uclass documentation

2015-03-24 Thread Przemyslaw Marczak
Signed-off-by: Przemyslaw Marczak p.marc...@samsung.com
---
Changes v2, V3:
- update documentation with the framework api changes
- remove doc file name 'dm' prefix
---
 doc/driver-model/pmic-framework.txt | 350 
 1 file changed, 350 insertions(+)
 create mode 100644 doc/driver-model/pmic-framework.txt

diff --git a/doc/driver-model/pmic-framework.txt 
b/doc/driver-model/pmic-framework.txt
new file mode 100644
index 000..72651dc
--- /dev/null
+++ b/doc/driver-model/pmic-framework.txt
@@ -0,0 +1,350 @@
+#
+# (C) Copyright 2014-2015 Samsung Electronics
+# Przemyslaw Marczak p.marc...@samsung.com
+#
+# SPDX-License-Identifier:  GPL-2.0+
+#
+
+PMIC framework based on Driver Model
+
+TOC:
+1. Introduction
+2. How does it work
+3. Pmic driver api
+4. Pmic driver
+5. Pmic command
+6. Regulator driver api
+7. Regulator driver
+8. Regulator command
+
+1. Introduction
+===
+This is an introduction to driver-model multi uclass PMIC devices support.
+At present it is based on two uclass types:
+
+- UCLASS_PMIC  - basic uclass type for PMIC I/O, which provides common
+ read/write interface.
+- UCLASS_REGULATOR - additional uclass type for specific PMIC features, which
+ are various voltage regulators.
+
+New files:
+UCLASS_PMIC:
+- drivers/power/pmic-uclass.c
+- include/power/pmic.h
+UCLASS_REGULATOR:
+- drivers/power/regulator-uclass.c
+- include/power/regulator.h
+
+Commands:
+- lib/cmd_pmic.c
+- lib/cmd_regulator.c
+
+2. How doees it work
+
+The Power Management Integrated Circuits (PMIC) are used in embedded systems
+to provide stable, precise and specific voltage power source with over-voltage
+and thermal protection circuits.
+
+The single PMIC can provide various functionalities with single or multiple
+interfaces, like in the example below.
+
+-- SoC
+ |
+ |__
+ | BUS 0 |   Multi interface PMIC IC|-- LDO out 1
+ | e.g.I2C0  |  |-- LDO out N
+ |---| PMIC device 0 (READ/WRITE ops)   |
+ | or SPI0   ||_ REGULATOR device (ldo/... ops) |-- BUCK out 1
+ |   ||_ CHARGER device (charger ops)   |-- BUCK out M
+ |   ||_ MUIC device (microUSB con ops) |
+ | BUS 1 ||_ ...|--- BATTERY
+ | e.g.I2C1  |  |
+ |---| PMIC device 1 (READ/WRITE ops)   |--- USB in 1
+ . or SPI1   ||_ RTC device (rtc ops)   |--- USB in 2
+ .   |__|--- USB out
+ .
+
+Since U-Boot provides driver model features for I2C and SPI bus drivers,
+the PMIC devices should also support this. With the new basic uclass types
+for PMIC I/O and regulator features, PMIC drivers can simply provide common
+features, with multiple interface and instance support.
+
+Basic design assumptions:
+
+- Common I/O api - UCLASS_PMIC
+The main assumption is to use UCLASS_PMIC device to provide I/O interface,
+for devices other uclass types. It is no matter what is the type of device
+physical I/O interface. Usually PMIC devices are using SPI or I2C interface,
+but use of any other interface (e.g. when PMIC is not directly connected
+to the SoC) - is now possible. Drivers can use the same read/write api.
+
+- Common regulator api - UCLASS_REGULATOR
+For setting the attributes of verious types of regulators with common api,
+this uclass can be implemented. This allows to drive the each regulator output
+value, on/off state and custom defined operation modes. It also provides the
+user interface for all operations.
+For the very simple implementation, the regulator drivers are not required,
+so the code could base on pmic read/write only.
+
+When board device-tree file includes pmic subnode and the U_Boot compatible
+driver exists, then the pmic device bind should looks like this:
+
+|_ root - will bind the device for I2C/SPI bus node
+  |_ i2c/spi - should bind a device for pmic node
+|_ pmic (parent) - should bind child devices for its features
+  |_ regulator (child)
+  |_ charger   (child)
+  |_ other (child)
+
+Usually PMIC design provides:
+ - single I/O interface (single UCLASS_PMIC driver)
+   Then UCLASS_PMIC device should be a parent of all pmic devices, where each
+   is usually different uclass type, but need to access the same interface
+
+ - multiple I/O interfaces (UCLASS_PMIC driver for each)
+   For each interface the UCLASS_PMIC device should be a parent of only those
+   devices (different uclass types), which needs to access the specified
+   interface.
+
+3. Pmic driver api
+===
+To use the pmic API, config: CONFIG_DM_PMIC is required.
+The new driver API is very simple and is based on 'struct dm_pmic_ops',
+which define two basic operations: device read and write.
+
+The platform data is