Re: [U-Boot] [PATCH v3 05/17] dm: pmic: add implementation of driver model pmic uclass

2015-04-05 Thread Simon Glass
Hi Przemyslaw,

On 3 April 2015 at 10:08, Przemyslaw Marczak p.marc...@samsung.com wrote:
 Hello Simon,

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

 Hi Prazemyslaw,

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


 +   UCLASS_PMIC,
 +
  UCLASS_COUNT,
  UCLASS_INVALID = -1,
   };
 diff --git a/include/power/pmic.h b/include/power/pmic.h
 index afbc5aa..b55304f 100644
 --- a/include/power/pmic.h
 +++ b/include/power/pmic.h
 @@ -1,4 +1,7 @@
   /*
 + *  Copyright (C) 2014-2015 Samsung Electronics
 + *  Przemyslaw Marczak p.marc...@samsung.com
 + *
*  Copyright (C) 2011-2012 Samsung Electronics
*  Lukasz Majewski l.majew...@samsung.com
*
 @@ -9,10 +12,13 @@
   #define __CORE_PMIC_H_

   #include linux/list.h
 +#include spi.h
   #include i2c.h
   #include power/power_chrg.h

   enum { PMIC_I2C, PMIC_SPI, PMIC_NONE};
 +
 +#ifdef CONFIG_POWER
   enum { I2C_PMIC, I2C_NUM, };
   enum { PMIC_READ, PMIC_WRITE, };
   enum { PMIC_SENSOR_BYTE_ORDER_LITTLE, PMIC_SENSOR_BYTE_ORDER_BIG, };
 @@ -77,7 +83,210 @@ struct pmic {
  struct pmic *parent;
  struct list_head list;
   };
 +#endif /* CONFIG_POWER */
 +
 +#ifdef CONFIG_DM_PMIC
 +/**
 + * Driver model pmic framework.
 + * The PMIC_UCLASS uclass is designed to provide a common I/O
 + * interface for pmic child devices of various uclass types.


 I worry about having the docs in multiple places. Should you adjust
 this to point to the Kconfig? Or change the Kconfig to point here? Or
 maybe it would be better to drop both and put these in your README? I
 am concerned that if we later change something, we end up with
 inconsistent docs.


 Right, this could be an issue in the future. I suppose that first thing is
 to look at this header file, before anyone starts work with this framework.
 So maybe it's better keep the description only in this file, and add some
 basic info to Kconfig and doc, with the links to here?

Yes that sounds good to me. It's great that you have documented this so well.

Regards,
Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v3 05/17] dm: pmic: add implementation of driver model pmic uclass

2015-04-03 Thread Przemyslaw Marczak

Hello Simon,

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

Hi Prazemyslaw,

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

This is an introduction to driver-model multi uclass PMIC support.
It starts with UCLASS_PMIC - a common PMIC devices uclass type
to provide device read/write operations only.


Your Kconfig docs are a model to others! It describes the function
very nicely without a lot of words.

Please excuse the nits, they are intended to help it read better.



That's ok, it's better to fix if needs.



Beside two basic operations the pmic platform data is introduced,
which provides basic informations about the pmic device I/O interface
and is shared with all childs (and should also for childs new uclass
types in the future).

Usually PMIC devices provides various functionalities with single
or multiple I/O interfaces.
Using this new framework and new uclass types introduced in the future,
it can be handle like this:

_ root device
|
|_ BUS 0 device (e.g. I2C0)- UCLASS_I2C/SPI/...
| |_ PMIC device 1 (read/write ops)- UCLASS_PMIC
|   |_ REGULATOR device (ldo/buck/... ops) - UCLASS_REGULATOR
|   |_ CHARGER device (charger ops)- UCLASS_CHARGER (in the future)
|   |_ MUIC device (microUSB con ops)  - UCLASS_MUIC(in the future)
|   |_ ...
|
|_ BUS 1 device (e.g. I2C1)- UCLASS_I2C/SPI/...
   |_ PMIC device 2 (read/write ops)- UCLASS_PMIC
 |_ RTC device (rtc ops)- UCLASS_MUIC (in the future)

For each PMIC device interface, new UCLASS_PMIC device is bind with proper
pmic driver, and it's child devices provides some specified operations.

All new definitions can be found in file:
- 'include/power/pmic.h'

Uclass file:
- pmic-uclass.c - provides a common code for UCLASS_PMIC device drivers

The old pmic framework is still kept and is independent.

Changes:
- new uclass-id: UCLASS_PMIC
- new config: CONFIG_DM_PMIC

New pmic api is documented in: doc/driver-model/pmic-framework.txt

Signed-off-by: Przemyslaw Marczak p.marc...@samsung.com
---
Changes V2:
- pmic uclass: adjust uclass code to the mainline changes
- pmic uclass: remove pmic_i2c and pmic_spi
- pmic uclass: modify pmic_platdata
- pmic uclass: add pmic_if_* functions
- pmic uclass: remove pmic_init_dm()
- pmic uclass: cleanup
- pmic.h: define pmic ops structure (read/write operations)
- pmic.h: add comments to functions

Changes V3:
- pmic-uclass.c and pmic.h:
   -- remove  pmic_if_* functions
   -- add new function pmic_child_node_scan()
- add Kconfig entry
---
  drivers/power/Kconfig   |  68 ++
  drivers/power/Makefile  |   1 +
  drivers/power/pmic-uclass.c | 130 +++
  include/dm/uclass-id.h  |   3 +
  include/power/pmic.h| 210 
  5 files changed, 412 insertions(+)
  create mode 100644 drivers/power/pmic-uclass.c

diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
index f8f0239..3513b46 100644
--- a/drivers/power/Kconfig
+++ b/drivers/power/Kconfig
@@ -1,3 +1,71 @@
+config DM_PMIC
+   bool Enable Driver Model for PMIC drivers (UCLASS_PMIC)
+   depends on DM
+   ---help---
+   This config enables the driver-model multi uclass PMIC support.
+   Its basic uclass type is: UCLASS_PMIC, which is designed to provide
+   a common I/O interface for pmic child devices of various uclass types.


Should be consistent - and use PMIC instead pmic.


+
+   Usually PMIC IC's provides more than one functionality, which means


s/functionality/function/


+   that we should implement new uclass operations for each one. Usually
+   PMIC's provide those various functionalities by one or more interfaces.


functions


+   And this could looks like this:
+
+   root device
+   |_ BUS 0 device (e.g. I2C0) - UCLASS_I2C/SPI/...
+   | |_ PMIC device (READ/WRITE ops)   - UCLASS_PMIC
+   |   |  (pmic sub-devices)
+   |   |_ REGULATOR device (ldo/buck/... ops)  - UCLASS_REGULATOR
+   |   |_ CHARGER device (charger ops) - UCLASS_CHARGER (future)
+   |   |_ MUIC device (microUSB connector ops) - UCLASS_MUIC(future)
+   |   |_ ...
+   |
+   |_ BUS 1 device (e.g. I2C1) - UCLASS_I2C/SPI/...
+  |_ PMIC device (READ/WRITE ops)  - UCLASS_PMIC
+|  (pmic sub-devices)
+|_ RTC device (rtc ops)- UCLASS_MUIC (future)


Would this be UCLASS_RTC?


+
+   From the I/O interface point of view, there can be found two PMIC types:
+   - single I/O interface - then UCLASS_PMIC device should be a parent of
+ all pmic sub-devices, where each is usually different uclass type, but
+ need to access the same interface
+
+   - multiple I/O interfaces - for each interface the UCLASS_PMIC device
+ should be a parent of only those devices (different uclass types),
+  

Re: [U-Boot] [PATCH v3 05/17] dm: pmic: add implementation of driver model pmic uclass

2015-03-29 Thread Simon Glass
Hi Prazemyslaw,

On 24 March 2015 at 14:30, Przemyslaw Marczak p.marc...@samsung.com wrote:
 This is an introduction to driver-model multi uclass PMIC support.
 It starts with UCLASS_PMIC - a common PMIC devices uclass type
 to provide device read/write operations only.

Your Kconfig docs are a model to others! It describes the function
very nicely without a lot of words.

Please excuse the nits, they are intended to help it read better.


 Beside two basic operations the pmic platform data is introduced,
 which provides basic informations about the pmic device I/O interface
 and is shared with all childs (and should also for childs new uclass
 types in the future).

 Usually PMIC devices provides various functionalities with single
 or multiple I/O interfaces.
 Using this new framework and new uclass types introduced in the future,
 it can be handle like this:

 _ root device
 |
 |_ BUS 0 device (e.g. I2C0)- UCLASS_I2C/SPI/...
 | |_ PMIC device 1 (read/write ops)- UCLASS_PMIC
 |   |_ REGULATOR device (ldo/buck/... ops) - UCLASS_REGULATOR
 |   |_ CHARGER device (charger ops)- UCLASS_CHARGER (in the future)
 |   |_ MUIC device (microUSB con ops)  - UCLASS_MUIC(in the future)
 |   |_ ...
 |
 |_ BUS 1 device (e.g. I2C1)- UCLASS_I2C/SPI/...
   |_ PMIC device 2 (read/write ops)- UCLASS_PMIC
 |_ RTC device (rtc ops)- UCLASS_MUIC (in the future)

 For each PMIC device interface, new UCLASS_PMIC device is bind with proper
 pmic driver, and it's child devices provides some specified operations.

 All new definitions can be found in file:
 - 'include/power/pmic.h'

 Uclass file:
 - pmic-uclass.c - provides a common code for UCLASS_PMIC device drivers

 The old pmic framework is still kept and is independent.

 Changes:
 - new uclass-id: UCLASS_PMIC
 - new config: CONFIG_DM_PMIC

 New pmic api is documented in: doc/driver-model/pmic-framework.txt

 Signed-off-by: Przemyslaw Marczak p.marc...@samsung.com
 ---
 Changes V2:
 - pmic uclass: adjust uclass code to the mainline changes
 - pmic uclass: remove pmic_i2c and pmic_spi
 - pmic uclass: modify pmic_platdata
 - pmic uclass: add pmic_if_* functions
 - pmic uclass: remove pmic_init_dm()
 - pmic uclass: cleanup
 - pmic.h: define pmic ops structure (read/write operations)
 - pmic.h: add comments to functions

 Changes V3:
 - pmic-uclass.c and pmic.h:
   -- remove  pmic_if_* functions
   -- add new function pmic_child_node_scan()
 - add Kconfig entry
 ---
  drivers/power/Kconfig   |  68 ++
  drivers/power/Makefile  |   1 +
  drivers/power/pmic-uclass.c | 130 +++
  include/dm/uclass-id.h  |   3 +
  include/power/pmic.h| 210 
 
  5 files changed, 412 insertions(+)
  create mode 100644 drivers/power/pmic-uclass.c

 diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
 index f8f0239..3513b46 100644
 --- a/drivers/power/Kconfig
 +++ b/drivers/power/Kconfig
 @@ -1,3 +1,71 @@
 +config DM_PMIC
 +   bool Enable Driver Model for PMIC drivers (UCLASS_PMIC)
 +   depends on DM
 +   ---help---
 +   This config enables the driver-model multi uclass PMIC support.
 +   Its basic uclass type is: UCLASS_PMIC, which is designed to provide
 +   a common I/O interface for pmic child devices of various uclass types.

Should be consistent - and use PMIC instead pmic.

 +
 +   Usually PMIC IC's provides more than one functionality, which means

s/functionality/function/

 +   that we should implement new uclass operations for each one. Usually
 +   PMIC's provide those various functionalities by one or more 
 interfaces.

functions

 +   And this could looks like this:
 +
 +   root device
 +   |_ BUS 0 device (e.g. I2C0) - UCLASS_I2C/SPI/...
 +   | |_ PMIC device (READ/WRITE ops)   - UCLASS_PMIC
 +   |   |  (pmic sub-devices)
 +   |   |_ REGULATOR device (ldo/buck/... ops)  - UCLASS_REGULATOR
 +   |   |_ CHARGER device (charger ops) - UCLASS_CHARGER (future)
 +   |   |_ MUIC device (microUSB connector ops) - UCLASS_MUIC(future)
 +   |   |_ ...
 +   |
 +   |_ BUS 1 device (e.g. I2C1) - UCLASS_I2C/SPI/...
 +  |_ PMIC device (READ/WRITE ops)  - UCLASS_PMIC
 +|  (pmic sub-devices)
 +|_ RTC device (rtc ops)- UCLASS_MUIC (future)

Would this be UCLASS_RTC?

 +
 +   From the I/O interface point of view, there can be found two PMIC 
 types:
 +   - single I/O interface - then UCLASS_PMIC device should be a parent of
 + all pmic sub-devices, where each is usually different uclass type, 
 but
 + need to access the same interface
 +
 +   - multiple I/O interfaces - for each interface the UCLASS_PMIC device
 + should be a parent of only those devices (different uclass types),
 + which needs to 

[U-Boot] [PATCH v3 05/17] dm: pmic: add implementation of driver model pmic uclass

2015-03-24 Thread Przemyslaw Marczak
This is an introduction to driver-model multi uclass PMIC support.
It starts with UCLASS_PMIC - a common PMIC devices uclass type
to provide device read/write operations only.

Beside two basic operations the pmic platform data is introduced,
which provides basic informations about the pmic device I/O interface
and is shared with all childs (and should also for childs new uclass
types in the future).

Usually PMIC devices provides various functionalities with single
or multiple I/O interfaces.
Using this new framework and new uclass types introduced in the future,
it can be handle like this:

_ root device
|
|_ BUS 0 device (e.g. I2C0)- UCLASS_I2C/SPI/...
| |_ PMIC device 1 (read/write ops)- UCLASS_PMIC
|   |_ REGULATOR device (ldo/buck/... ops) - UCLASS_REGULATOR
|   |_ CHARGER device (charger ops)- UCLASS_CHARGER (in the future)
|   |_ MUIC device (microUSB con ops)  - UCLASS_MUIC(in the future)
|   |_ ...
|
|_ BUS 1 device (e.g. I2C1)- UCLASS_I2C/SPI/...
  |_ PMIC device 2 (read/write ops)- UCLASS_PMIC
|_ RTC device (rtc ops)- UCLASS_MUIC (in the future)

For each PMIC device interface, new UCLASS_PMIC device is bind with proper
pmic driver, and it's child devices provides some specified operations.

All new definitions can be found in file:
- 'include/power/pmic.h'

Uclass file:
- pmic-uclass.c - provides a common code for UCLASS_PMIC device drivers

The old pmic framework is still kept and is independent.

Changes:
- new uclass-id: UCLASS_PMIC
- new config: CONFIG_DM_PMIC

New pmic api is documented in: doc/driver-model/pmic-framework.txt

Signed-off-by: Przemyslaw Marczak p.marc...@samsung.com
---
Changes V2:
- pmic uclass: adjust uclass code to the mainline changes
- pmic uclass: remove pmic_i2c and pmic_spi
- pmic uclass: modify pmic_platdata
- pmic uclass: add pmic_if_* functions
- pmic uclass: remove pmic_init_dm()
- pmic uclass: cleanup
- pmic.h: define pmic ops structure (read/write operations)
- pmic.h: add comments to functions

Changes V3:
- pmic-uclass.c and pmic.h:
  -- remove  pmic_if_* functions
  -- add new function pmic_child_node_scan()
- add Kconfig entry
---
 drivers/power/Kconfig   |  68 ++
 drivers/power/Makefile  |   1 +
 drivers/power/pmic-uclass.c | 130 +++
 include/dm/uclass-id.h  |   3 +
 include/power/pmic.h| 210 
 5 files changed, 412 insertions(+)
 create mode 100644 drivers/power/pmic-uclass.c

diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
index f8f0239..3513b46 100644
--- a/drivers/power/Kconfig
+++ b/drivers/power/Kconfig
@@ -1,3 +1,71 @@
+config DM_PMIC
+   bool Enable Driver Model for PMIC drivers (UCLASS_PMIC)
+   depends on DM
+   ---help---
+   This config enables the driver-model multi uclass PMIC support.
+   Its basic uclass type is: UCLASS_PMIC, which is designed to provide
+   a common I/O interface for pmic child devices of various uclass types.
+
+   Usually PMIC IC's provides more than one functionality, which means
+   that we should implement new uclass operations for each one. Usually
+   PMIC's provide those various functionalities by one or more interfaces.
+   And this could looks like this:
+
+   root device
+   |_ BUS 0 device (e.g. I2C0) - UCLASS_I2C/SPI/...
+   | |_ PMIC device (READ/WRITE ops)   - UCLASS_PMIC
+   |   |  (pmic sub-devices)
+   |   |_ REGULATOR device (ldo/buck/... ops)  - UCLASS_REGULATOR
+   |   |_ CHARGER device (charger ops) - UCLASS_CHARGER (future)
+   |   |_ MUIC device (microUSB connector ops) - UCLASS_MUIC(future)
+   |   |_ ...
+   |
+   |_ BUS 1 device (e.g. I2C1) - UCLASS_I2C/SPI/...
+  |_ PMIC device (READ/WRITE ops)  - UCLASS_PMIC
+|  (pmic sub-devices)
+|_ RTC device (rtc ops)- UCLASS_MUIC (future)
+
+   From the I/O interface point of view, there can be found two PMIC types:
+   - single I/O interface - then UCLASS_PMIC device should be a parent of
+ all pmic sub-devices, where each is usually different uclass type, but
+ need to access the same interface
+
+   - multiple I/O interfaces - 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.
+
+   For each case, binding should be done automatically. If only device tree
+   nodes/subnodes are proper defined, then:
+   |_ the ROOT driver will bind the device for I2C/SPI node:
+ |_ the I2C/SPI driver should bind a device for pmic node:
+   |_ the PMIC driver should bind devices for its childs:
+ |  (pmic sub-devices)
+ |_ regulator (child)
+ |_ charger   (child)
+ |_