PMIC/REGULATOR cleanup and Sandbox tests
Subsystems (4)
cover PMIC/REGULATOR cleanup and Sandbox tests
Hello!
This patchset cleanups the POWER framework V4, which is applied into u-boot-dm/next tree.
The main changes:
- pmic/regulator uclasses cleanup - each commit message describes the changes in details.
- added sandbox PMIC emulated device support, which consists of three
drivers: pmic I2C emul, pmic I/O and regulator.
- PMIC/REGULATOR tests for sandbox in: tests/dm/power.c
I tried to add the implementation of all pmic/regulator operations for the sandbox PMIC device - I hope that the drivers are not too complicated.
The tests for sandbox includes every pmic/regulator function call, so for now the tests should well cover the framework features.
The patchset is rebased on the top of u-boot-dm/next, and can be fetched from
here: https://github.com/bobenstein/u-boot.git
branch: dm-pmic-v4-sandbox
Best regards,
Przemyslaw Marczak
Przemyslaw Marczak (12):
dm: pmic: code cleanup of PMIC uclass driver
dm: pmic: max77686: update driver code
dm: regulator: uclass driver code cleanup
odroid u3: cleanup the regulator calls
common: cmd pmic: command cleanup
common: cmd regulator: command cleanup
doc: driver-model: pmic-framework.txt - cleanup
sandbox: i2c: search child emul dev and check its uclass id
sandbox: add: sandbox PMIC device drivers: I2C emul, pmic, regulator
test: dm: dts: add sandbox pmic i2c node
sandbox: defconfig: enable support of sandbox PMIC drivers
test: dm: add sandbox PMIC framework tests
board/samsung/odroid/odroid.c | 9 +- common/cmd_pmic.c | 131 ++++----- common/cmd_regulator.c | 239 ++++++++-------- configs/sandbox_defconfig | 7 + doc/device-tree-bindings/pmic/sandbox.txt | 35 +++ doc/device-tree-bindings/regulator/sandbox.txt | 45 +++ doc/driver-model/pmic-framework.txt | 20 +- drivers/i2c/sandbox_i2c.c | 20 +- drivers/power/pmic/Kconfig | 27 +- drivers/power/pmic/Makefile | 3 +- drivers/power/pmic/i2c_pmic_emul.c | 145 ++++++++++ drivers/power/pmic/max77686.c | 15 +- drivers/power/pmic/pmic-uclass.c | 25 +- drivers/power/pmic/sandbox.c | 79 ++++++ drivers/power/regulator/Kconfig | 32 ++- drivers/power/regulator/Makefile | 1 + drivers/power/regulator/regulator-uclass.c | 104 ++++--- drivers/power/regulator/sandbox.c | 355 +++++++++++++++++++++++ include/power/pmic.h | 39 +-- include/power/regulator.h | 116 ++++---- include/power/sandbox_pmic.h | 222 +++++++++++++++ test/dm/Makefile | 2 + test/dm/power.c | 371 +++++++++++++++++++++++++ test/dm/test.dts | 38 +++ 24 files changed, 1732 insertions(+), 348 deletions(-) create mode 100644 doc/device-tree-bindings/pmic/sandbox.txt create mode 100644 doc/device-tree-bindings/regulator/sandbox.txt create mode 100644 drivers/power/pmic/i2c_pmic_emul.c create mode 100644 drivers/power/pmic/sandbox.c create mode 100644 drivers/power/regulator/sandbox.c create mode 100644 include/power/sandbox_pmic.h create mode 100644 test/dm/power.c
Signature · 1 line
1.9.1
PATCH 1/12 dm: pmic: code cleanup of PMIC uclass driver
The cleanup includes:
- pmic.h - fix mistakes in a few comments
- pmic operations: value 'reg_count' - redefine as function call
- fix function name: pmic_bind_childs() -> pmic_bind_children()
- pmic_bind_children: increment child_info pointer if operation in loop fail
--- drivers/power/pmic/pmic-uclass.c | 25 +++++++++---------------- include/power/pmic.h | 39 ++++++++++++++++++++------------------- 2 files changed, 29 insertions(+), 35 deletions(-)
drivers/power/pmic/pmic-uclass.c +9 -16
@@ -27,8 +27,8 @@ static ulong str_get_num(const char *ptr, const char *maxptr)return simple_strtoul (ptr,NULL ,0 ); } -int pmic_bind_childs (struct udevice *pmic,int offset, -const struct pmic_child_info *child_info) +int pmic_bind_children (struct udevice *pmic,int offset, +const struct pmic_child_info *child_info) {const struct pmic_child_info *info;const void *blob = gd->fdt_blob;
@@ -68,6 +68,7 @@ int pmic_bind_childs(struct udevice *pmic, int offset,if (!drv) {debug (" - driver: '%s' not found!\n" , info->driver); + info++;continue ; }
@@ -77,6 +78,7 @@ int pmic_bind_childs(struct udevice *pmic, int offset, node, &child);if (ret) {debug (" - child binding error: %d\n" , ret); + info++;continue ; }
@@ -110,16 +112,16 @@ int pmic_get(const char *name, struct udevice **devp)int pmic_reg_count (struct udevice *dev) {const struct dm_pmic_ops *ops =dev_get_driver_ops (dev); -if (!ops) + +if (!ops || !ops->reg_count)return -ENOSYS ; -return ops->reg_count; +return ops->reg_count (dev); }int pmic_read (struct udevice *dev,uint reg,uint8_t *buffer,int len) {const struct dm_pmic_ops *ops =dev_get_driver_ops (dev); -int ret;if (!buffer)return -EFAULT ;
@@ -127,17 +129,12 @@ int pmic_read(struct udevice *dev, uint reg, uint8_t *buffer, int len)if (!ops || !ops->read)return -ENOSYS ; - ret = ops->read (dev, reg, buffer, len); -if (ret) -return ret; - -return 0 ; +return ops->read (dev, reg, buffer, len); }int pmic_write (struct udevice *dev,uint reg,const uint8_t *buffer,int len) {const struct dm_pmic_ops *ops =dev_get_driver_ops (dev); -int ret;if (!buffer)return -EFAULT ;
@@ -145,11 +142,7 @@ int pmic_write(struct udevice *dev, uint reg, const uint8_t *buffer, int len)if (!ops || !ops->write)return -ENOSYS ; - ret = ops->write (dev, reg, buffer, len); -if (ret) -return ret; - -return 0 ; +return ops->write (dev, reg, buffer, len); }UCLASS_DRIVER (pmic) = {
include/power/pmic.h +20 -19
@@ -11,9 +11,9 @@#ifndef __CORE_PMIC_H_#define __CORE_PMIC_H_ -#include <linux/list.h> -#include <spi.h> #include <i2c.h> +#include <spi.h> +#include <linux/list.h> #include <power/power_chrg.h> enum {PMIC_I2C ,PMIC_SPI ,PMIC_NONE };
@@ -90,10 +90,10 @@ struct pmic {* U-Boot PMIC Framework * ===================== * -* UCLASS_PMIC - The is designed to provide an I/O interface for PMIC devices. +* UCLASS_PMIC - This is designed to provide an I/O interface for PMIC devices. * * For the multi-function PMIC devices, this can be used as parent I/O device -* for each IC's interface. Then, each children uses its parent for read/write. +* for each IC's interface. Then, each child uses its parent for read/write. * * The driver model tree could look like this: *
@@ -112,8 +112,8 @@ struct pmic {* We can find two PMIC cases in boards design: * - single I/O interface * - multiple I/O interfaces -* We bind single PMIC device for each interface, to provide an I/O as a parent, -* of proper child devices. Each child usually implements a different function, +* We bind a single PMIC device for each interface, to provide an I/O for +* its child devices. And each child usually implements a different function, * controlled by the same interface. * * The binding should be done automatically. If device tree nodes/subnodes are
@@ -131,7 +131,7 @@ struct pmic {* Note: * Each PMIC interface driver should use a different compatible string. * -* If each pmic child device driver need access the PMIC-specific registers, +* If a PMIC child device driver needs access the PMIC-specific registers, * it need know only the register address and the access can be done through * the parent pmic driver. Like in the example: *
@@ -141,10 +141,10 @@ struct pmic {* | |_ dev: my_regulator (set value/etc..) (is child) - UCLASS_REGULATOR * * To ensure such device relationship, the pmic device driver should also bind -* all its child devices, like in the example below. It should be done by call -* the 'pmic_bind_childs()' - please refer to the description of this function -* in this header file. This function, should be called in the driver's '.bind' -* method. +* all its child devices, like in the example below. It can be done by calling +* the 'pmic_bind_children()' - please refer to the function description, which +* can be found in this header file. This function, should be called inside the +* driver's bind() method. * * For the example driver, please refer the MAX77686 driver: * - 'drivers/power/pmic/max77686.c'
@@ -156,18 +156,19 @@ struct pmic {* Should be implemented by UCLASS_PMIC device drivers. The standard * device operations provides the I/O interface for it's childs. * -* @reg_count: devices register count +* @reg_count: device's register count * @read: read 'len' bytes at "reg" and store it into the 'buffer' * @write: write 'len' bytes from the 'buffer' to the register at 'reg' address */ struct dm_pmic_ops { -int reg_count; +int (*reg_count)(struct udevice *dev);int (*read)(struct udevice *dev,uint reg,uint8_t *buffer,int len);int (*write)(struct udevice *dev,uint reg,const uint8_t *buffer,int len); }; -/* enum pmic_op_type - used for various pmic devices operation calls, +/** +* enum pmic_op_type - used for various pmic devices operation calls, * for reduce a number of lines with the same code for read/write or get/set. * * @PMIC_OP_GET - get operation
@@ -181,7 +182,7 @@ enum pmic_op_type {/** * struct pmic_child_info - basic device's child info for bind child nodes with * the driver by the node name prefix and driver name. This is a helper struct -* for function: pmic_bind_childs(). +* for function: pmic_bind_children(). * * @prefix - child node name prefix (or its name if is unique or single) * @driver - driver name for the sub-node with prefix
@@ -194,7 +195,7 @@ struct pmic_child_info {/* drivers/power/pmic-uclass.c */ /** -* pmic_bind_childs() - bind drivers for given parent pmic, using child info +* pmic_bind_children() - bind drivers for given parent pmic, using child info * found in 'child_info' array. * * @pmic - pmic device - the parent of found child's
@@ -216,7 +217,7 @@ struct pmic_child_info {* (pmic - bind automatically by compatible) * compatible = "my_pmic"; * ... -* (pmic's childs - bind by pmic_bind_childs()) +* (pmic's childs - bind by pmic_bind_children()) * (nodes prefix: "ldo", driver: "my_regulator_ldo") * ldo1 { ... }; * ldo2 { ... };
@@ -226,8 +227,8 @@ struct pmic_child_info {* buck2 { ... }; * }; */ -int pmic_bind_childs (struct udevice *pmic,int offset, -const struct pmic_child_info *child_info); +int pmic_bind_children (struct udevice *pmic,int offset, +const struct pmic_child_info *child_info);/** * pmic_get: get the pmic device using its name
Signature · 1 line
1.9.1
PATCH 1/12 dm: pmic: code cleanup of PMIC uclass driver
Hi Przemyslaw,
Quoted 6 lines · Przemyslaw Marczak
The cleanup includes:
-pmic.h- fix mistakes in a few comments
- pmic operations: value 'reg_count' - redefine as function call
- fix function name:pmic_bind_childs()->pmic_bind_children()
-pmic_bind_children: incrementchild_infopointer if operation in loop fail
Quoted 6 lines
Signed-off-by Przemyslaw Marczak <[email protected]>--- drivers/power/pmic/pmic-uclass.c | 25 +++++++++---------------- include/power/pmic.h | 39 ++++++++++++++++++++------------------- 2 files changed, 29 insertions(+), 35 deletions(-)
Tested on sandbox:
BTW in pmic_bind_children() you have something like this:
info = child_info;
while (info->prefix) {
...
if (ret) {
debug(" - child binding error: %d\n", ret);
info++;
continue;}
I think this would be better:
for (info = child_info; info->prefix, info++)
and remove the three info++ expressions inside the loop.
Quoted 211 lines
drivers/power/pmic/pmic-uclass.c +9
-16@@ -27,8 +27,8 @@ static ulong str_get_num(const char *ptr, const char *maxptr)return simple_strtoul (ptr,NULL ,0 ); } -int pmic_bind_childs (struct udevice *pmic,int offset, -const struct pmic_child_info *child_info) +int pmic_bind_children (struct udevice *pmic,int offset, +const struct pmic_child_info *child_info) {const struct pmic_child_info *info;const void *blob = gd->fdt_blob;@@ -68,6 +68,7 @@ int pmic_bind_childs(struct udevice *pmic, int offset,if (!drv) {debug (" - driver: '%s' not found!\n" , info->driver); + info++;continue ; }@@ -77,6 +78,7 @@ int pmic_bind_childs(struct udevice *pmic, int offset, node, &child);if (ret) {debug (" - child binding error: %d\n" , ret); + info++;continue ; }@@ -110,16 +112,16 @@ int pmic_get(const char *name, struct udevice **devp)int pmic_reg_count (struct udevice *dev) {const struct dm_pmic_ops *ops =dev_get_driver_ops (dev); -if (!ops) + +if (!ops || !ops->reg_count)return -ENOSYS ; -return ops->reg_count; +return ops->reg_count (dev); }int pmic_read (struct udevice *dev,uint reg,uint8_t *buffer,int len) {const struct dm_pmic_ops *ops =dev_get_driver_ops (dev); -int ret;if (!buffer)return -EFAULT ;@@ -127,17 +129,12 @@ int pmic_read(struct udevice *dev, uint reg, uint8_t *buffer, int len)if (!ops || !ops->read)return -ENOSYS ; - ret = ops->read (dev, reg, buffer, len); -if (ret) -return ret; - -return 0 ; +return ops->read (dev, reg, buffer, len); }int pmic_write (struct udevice *dev,uint reg,const uint8_t *buffer,int len) {const struct dm_pmic_ops *ops =dev_get_driver_ops (dev); -int ret;if (!buffer)return -EFAULT ;@@ -145,11 +142,7 @@ int pmic_write(struct udevice *dev, uint reg, const uint8_t *buffer, int len)if (!ops || !ops->write)return -ENOSYS ; - ret = ops->write (dev, reg, buffer, len); -if (ret) -return ret; - -return 0 ; +return ops->write (dev, reg, buffer, len); }UCLASS_DRIVER (pmic) = {include/power/pmic.h +20
-20@@ -11,9 +11,9 @@#ifndef __CORE_PMIC_H_#define __CORE_PMIC_H_ -#include <linux/list.h> -#include <spi.h> #include <i2c.h> +#include <spi.h> +#include <linux/list.h> #include <power/power_chrg.h> enum {PMIC_I2C ,PMIC_SPI ,PMIC_NONE };@@ -90,10 +90,10 @@ struct pmic {* U-Boot PMIC Framework * ===================== * -* UCLASS_PMIC - The is designed to provide an I/O interface for PMIC devices. +* UCLASS_PMIC - This is designed to provide an I/O interface for PMIC devices. * * For the multi-function PMIC devices, this can be used as parent I/O device -* for each IC's interface. Then, each children uses its parent for read/write. +* for each IC's interface. Then, each child uses its parent for read/write. * * The driver model tree could look like this: * @@ -112,8 +112,8 @@ struct pmic {* We can find two PMIC cases in boards design: * - single I/O interface * - multiple I/O interfaces -* We bind single PMIC device for each interface, to provide an I/O as a parent, -* of proper child devices. Each child usually implements a different function, +* We bind a single PMIC device for each interface, to provide an I/O for +* its child devices. And each child usually implements a different function, * controlled by the same interface. * * The binding should be done automatically. If device tree nodes/subnodes are @@ -131,7 +131,7 @@ struct pmic {* Note: * Each PMIC interface driver should use a different compatible string. * -* If each pmic child device driver need access the PMIC-specific registers, +* If a PMIC child device driver needs access the PMIC-specific registers, * it need know only the register address and the access can be done through * the parent pmic driver. Like in the example: * @@ -141,10 +141,10 @@ struct pmic {* | |_ dev: my_regulator (set value/etc..) (is child) - UCLASS_REGULATOR * * To ensure such device relationship, the pmic device driver should also bind -* all its child devices, like in the example below. It should be done by call -* the 'pmic_bind_childs()' - please refer to the description of this function -* in this header file. This function, should be called in the driver's '.bind' -* method. +* all its child devices, like in the example below. It can be done by calling +* the 'pmic_bind_children()' - please refer to the function description, which +* can be found in this header file. This function, should be called inside the +* driver's bind() method. * * For the example driver, please refer the MAX77686 driver: * - 'drivers/power/pmic/max77686.c' @@ -156,18 +156,19 @@ struct pmic {* Should be implemented by UCLASS_PMIC device drivers. The standard * device operations provides the I/O interface for it's childs. * -* @reg_count: devices register count +* @reg_count: device's register count * @read: read 'len' bytes at "reg" and store it into the 'buffer' * @write: write 'len' bytes from the 'buffer' to the register at 'reg' address */ struct dm_pmic_ops { -int reg_count; +int (*reg_count)(struct udevice *dev);int (*read)(struct udevice *dev,uint reg,uint8_t *buffer,int len);int (*write)(struct udevice *dev,uint reg,const uint8_t *buffer,int len); }; -/* enum pmic_op_type - used for various pmic devices operation calls, +/** +* enum pmic_op_type - used for various pmic devices operation calls, * for reduce a number of lines with the same code for read/write or get/set. * * @PMIC_OP_GET - get operation @@ -181,7 +182,7 @@ enum pmic_op_type {/** * struct pmic_child_info - basic device's child info for bind child nodes with * the driver by the node name prefix and driver name. This is a helper struct -* for function: pmic_bind_childs(). +* for function: pmic_bind_children(). * * @prefix - child node name prefix (or its name if is unique or single) * @driver - driver name for the sub-node with prefix @@ -194,7 +195,7 @@ struct pmic_child_info {/* drivers/power/pmic-uclass.c */ /** -* pmic_bind_childs() - bind drivers for given parent pmic, using child info +* pmic_bind_children() - bind drivers for given parent pmic, using child info * found in 'child_info' array. * * @pmic - pmic device - the parent of found child's @@ -216,7 +217,7 @@ struct pmic_child_info {* (pmic - bind automatically by compatible) * compatible = "my_pmic"; * ... -* (pmic's childs - bind by pmic_bind_childs()) +* (pmic's childs - bind by pmic_bind_children()) * (nodes prefix: "ldo", driver: "my_regulator_ldo") * ldo1 { ... }; * ldo2 { ... }; @@ -226,8 +227,8 @@ struct pmic_child_info {* buck2 { ... }; * }; */ -int pmic_bind_childs (struct udevice *pmic,int offset, -const struct pmic_child_info *child_info); +int pmic_bind_children (struct udevice *pmic,int offset, +const struct pmic_child_info *child_info);/** * pmic_get: get the pmic device using its name -- 1.9.1
PATCH 1/12 dm: pmic: code cleanup of PMIC uclass driver
Hello Simon,
Quoted 16 lines · Simon Glass
Hi Przemyslaw,
Quoted 6 lines · Przemyslaw Marczak
The cleanup includes:
-pmic.h- fix mistakes in a few comments
- pmic operations: value 'reg_count' - redefine as function call
- fix function name:pmic_bind_childs()->pmic_bind_children()
-pmic_bind_children: incrementchild_infopointer if operation in loop failQuoted 6 lines
Signed-off-by Przemyslaw Marczak <[email protected]>--- drivers/power/pmic/pmic-uclass.c | 25 +++++++++---------------- include/power/pmic.h | 39 ++++++++++++++++++++------------------- 2 files changed, 29 insertions(+), 35 deletions(-)
Quoted 4 lines
Acked-by Simon Glass <[email protected]>Tested on sandbox:
Tested-by Simon Glass <[email protected]>
Thank you for review and testing!
Quoted 11 lines
BTW in
pmic_bind_children()you have something like this:info =
child_info;while (info->prefix) { ... if (ret) { debug(" - child binding error: %d\n", ret); info++; continue; }
Quoted 7 lines
I think this would be better:
for (info =
child_info;info->prefix, info++)and remove the three info++ expressions inside the loop.
Ah, that's right, I will fix that.
Quoted 206 lines
Quoted 206 lines
drivers/power/pmic/pmic-uclass.c +9
-16@@ -27,8 +27,8 @@ static ulong str_get_num(const char *ptr, const char *maxptr)return simple_strtoul (ptr,NULL ,0 ); } -int pmic_bind_childs (struct udevice *pmic,int offset, -const struct pmic_child_info *child_info) +int pmic_bind_children (struct udevice *pmic,int offset, +const struct pmic_child_info *child_info) {const struct pmic_child_info *info;const void *blob = gd->fdt_blob;@@ -68,6 +68,7 @@ int pmic_bind_childs(struct udevice *pmic, int offset,if (!drv) {debug (" - driver: '%s' not found!\n" , info->driver); + info++;continue ; }@@ -77,6 +78,7 @@ int pmic_bind_childs(struct udevice *pmic, int offset, node, &child);if (ret) {debug (" - child binding error: %d\n" , ret); + info++;continue ; }@@ -110,16 +112,16 @@ int pmic_get(const char *name, struct udevice **devp)int pmic_reg_count (struct udevice *dev) {const struct dm_pmic_ops *ops =dev_get_driver_ops (dev); -if (!ops) + +if (!ops || !ops->reg_count)return -ENOSYS ; -return ops->reg_count; +return ops->reg_count (dev); }int pmic_read (struct udevice *dev,uint reg,uint8_t *buffer,int len) {const struct dm_pmic_ops *ops =dev_get_driver_ops (dev); -int ret;if (!buffer)return -EFAULT ;@@ -127,17 +129,12 @@ int pmic_read(struct udevice *dev, uint reg, uint8_t *buffer, int len)if (!ops || !ops->read)return -ENOSYS ; - ret = ops->read (dev, reg, buffer, len); -if (ret) -return ret; - -return 0 ; +return ops->read (dev, reg, buffer, len); }int pmic_write (struct udevice *dev,uint reg,const uint8_t *buffer,int len) {const struct dm_pmic_ops *ops =dev_get_driver_ops (dev); -int ret;if (!buffer)return -EFAULT ;@@ -145,11 +142,7 @@ int pmic_write(struct udevice *dev, uint reg, const uint8_t *buffer, int len)if (!ops || !ops->write)return -ENOSYS ; - ret = ops->write (dev, reg, buffer, len); -if (ret) -return ret; - -return 0 ; +return ops->write (dev, reg, buffer, len); }UCLASS_DRIVER (pmic) = {include/power/pmic.h +20
-19@@ -11,9 +11,9 @@#ifndef __CORE_PMIC_H_#define __CORE_PMIC_H_ -#include <linux/list.h> -#include <spi.h> #include <i2c.h> +#include <spi.h> +#include <linux/list.h> #include <power/power_chrg.h> enum {PMIC_I2C ,PMIC_SPI ,PMIC_NONE };@@ -90,10 +90,10 @@ struct pmic {* U-Boot PMIC Framework * ===================== * -* UCLASS_PMIC - The is designed to provide an I/O interface for PMIC devices. +* UCLASS_PMIC - This is designed to provide an I/O interface for PMIC devices. * * For the multi-function PMIC devices, this can be used as parent I/O device -* for each IC's interface. Then, each children uses its parent for read/write. +* for each IC's interface. Then, each child uses its parent for read/write. * * The driver model tree could look like this: * @@ -112,8 +112,8 @@ struct pmic {* We can find two PMIC cases in boards design: * - single I/O interface * - multiple I/O interfaces -* We bind single PMIC device for each interface, to provide an I/O as a parent, -* of proper child devices. Each child usually implements a different function, +* We bind a single PMIC device for each interface, to provide an I/O for +* its child devices. And each child usually implements a different function, * controlled by the same interface. * * The binding should be done automatically. If device tree nodes/subnodes are @@ -131,7 +131,7 @@ struct pmic {* Note: * Each PMIC interface driver should use a different compatible string. * -* If each pmic child device driver need access the PMIC-specific registers, +* If a PMIC child device driver needs access the PMIC-specific registers, * it need know only the register address and the access can be done through * the parent pmic driver. Like in the example: * @@ -141,10 +141,10 @@ struct pmic {* | |_ dev: my_regulator (set value/etc..) (is child) - UCLASS_REGULATOR * * To ensure such device relationship, the pmic device driver should also bind -* all its child devices, like in the example below. It should be done by call -* the 'pmic_bind_childs()' - please refer to the description of this function -* in this header file. This function, should be called in the driver's '.bind' -* method. +* all its child devices, like in the example below. It can be done by calling +* the 'pmic_bind_children()' - please refer to the function description, which +* can be found in this header file. This function, should be called inside the +* driver's bind() method. * * For the example driver, please refer the MAX77686 driver: * - 'drivers/power/pmic/max77686.c' @@ -156,18 +156,19 @@ struct pmic {* Should be implemented by UCLASS_PMIC device drivers. The standard * device operations provides the I/O interface for it's childs. * -* @reg_count: devices register count +* @reg_count: device's register count * @read: read 'len' bytes at "reg" and store it into the 'buffer' * @write: write 'len' bytes from the 'buffer' to the register at 'reg' address */ struct dm_pmic_ops { -int reg_count; +int (*reg_count)(struct udevice *dev);int (*read)(struct udevice *dev,uint reg,uint8_t *buffer,int len);int (*write)(struct udevice *dev,uint reg,const uint8_t *buffer,int len); }; -/* enum pmic_op_type - used for various pmic devices operation calls, +/** +* enum pmic_op_type - used for various pmic devices operation calls, * for reduce a number of lines with the same code for read/write or get/set. * * @PMIC_OP_GET - get operation @@ -181,7 +182,7 @@ enum pmic_op_type {/** * struct pmic_child_info - basic device's child info for bind child nodes with * the driver by the node name prefix and driver name. This is a helper struct -* for function: pmic_bind_childs(). +* for function: pmic_bind_children(). * * @prefix - child node name prefix (or its name if is unique or single) * @driver - driver name for the sub-node with prefix @@ -194,7 +195,7 @@ struct pmic_child_info {/* drivers/power/pmic-uclass.c */ /** -* pmic_bind_childs() - bind drivers for given parent pmic, using child info +* pmic_bind_children() - bind drivers for given parent pmic, using child info * found in 'child_info' array. * * @pmic - pmic device - the parent of found child's @@ -216,7 +217,7 @@ struct pmic_child_info {* (pmic - bind automatically by compatible) * compatible = "my_pmic"; * ... -* (pmic's childs - bind by pmic_bind_childs()) +* (pmic's childs - bind by pmic_bind_children()) * (nodes prefix: "ldo", driver: "my_regulator_ldo") * ldo1 { ... }; * ldo2 { ... }; @@ -226,8 +227,8 @@ struct pmic_child_info {* buck2 { ... }; * }; */ -int pmic_bind_childs (struct udevice *pmic,int offset, -const struct pmic_child_info *child_info); +int pmic_bind_children (struct udevice *pmic,int offset, +const struct pmic_child_info *child_info);
Quoted 6 lines
Quoted 5 lines
include/power/pmic.h +0
-1/** * pmic_get: get the pmic device using its name -- 1.9.1
Best regards,
Signature · 4 lines
Przemyslaw Marczak Samsung R&D Institute Poland Samsung Electronics p.marczak at samsung.com
PATCH 2/12 dm: pmic: max77686: update driver code
In reply to Przemyslaw MarczakThis update includes:
- add implementation of pmic_reg_count() method
- pmic_bind_children() - update function call name
- Kconfig: add new line at the end of file
--- drivers/power/pmic/Kconfig | 2 +- drivers/power/pmic/max77686.c | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-)
drivers/power/pmic/Kconfig +1 -1
@@ -15,4 +15,4 @@ config DM_PMIC_MAX77686 depends on DM_PMIC ---help--- This config enables implementation of driver-model pmic uclass features - for PMIC MAX77686. The driver implements read/write operations. + for PMIC MAX77686. The driver implements read/write operations.
drivers/power/pmic/max77686.c +10 -5
@@ -16,12 +16,17 @@DECLARE_GLOBAL_DATA_PTR ; -static const struct pmic_child_info pmic_childs_info[] = { +static const struct pmic_child_info pmic_children_info[] = { { .prefix ="ldo" , .driver =MAX77686_LDO_DRIVER }, { .prefix ="buck" , .driver =MAX77686_BUCK_DRIVER }, { }, }; +static int max77686_reg_count (struct udevice *dev) +{ +return MAX77686_NUM_OF_REGS ; +} +static int max77686_write (struct udevice *dev,uint reg,const uint8_t *buff,int len) {
@@ -47,7 +52,7 @@ static int max77686_bind(struct udevice *dev) {int regulators_node;const void *blob = gd->fdt_blob; -int childs; +int children; regulators_node =fdt_subnode_offset (blob, dev->of_offset,"voltage-regulators" );
@@ -59,8 +64,8 @@ static int max77686_bind(struct udevice *dev)debug ("%s: '%s' - found regulators subnode\n" , __func__, dev->name); - childs =pmic_bind_childs (dev, regulators_node, pmic_childs_info); -if (!childs) + children =pmic_bind_children (dev, regulators_node, pmic_children_info); +if (!children)debug ("%s: %s - no child found\n" , __func__, dev->name);/* Always return success for this device */
@@ -68,7 +73,7 @@ static int max77686_bind(struct udevice *dev) }static struct dm_pmic_ops max77686_ops = { - .reg_count =MAX77686_NUM_OF_REGS , + .reg_count = max77686_reg_count, .read = max77686_read, .write = max77686_write, };
Signature · 1 line
1.9.1
PATCH 2/12 dm: pmic: max77686: update driver code
Quoted 10 lines · Przemyslaw Marczak
This update includes:
- add implementation ofpmic_reg_count()method
-pmic_bind_children()- update function call name
-Kconfig: add new line at the end of fileSigned-off-by Przemyslaw Marczak <[email protected]>--- drivers/power/pmic/Kconfig | 2 +- drivers/power/pmic/max77686.c | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-)
Tested on sandbox:
PATCH 3/12 dm: regulator: uclass driver code cleanup
In reply to Przemyslaw MarczakThis cleanup includes:
- remove of the preprocessor macros which pointed to long name functions
- update of the names of some regulator uclass driver functions
- cleanup of the function regulator_autoset()
- reword of some comments of regulator uclass header file
- regulator_get_by_platname: check error for uclass_find_* function calls
- add function: regulator_name_is_unique
- regulator post_bind(): check regulator name uniqueness
- fix mistakes in: regulator/Kconfig
- regulator.h: update comments
--- drivers/power/regulator/Kconfig | 2 +- drivers/power/regulator/regulator-uclass.c | 104 +++++++++++++++++--------- include/power/regulator.h | 116 +++++++++++++++-------------- 3 files changed, 128 insertions(+), 94 deletions(-)
drivers/power/regulator/Kconfig +1 -1
@@ -14,7 +14,7 @@ config DM_REGULATOR It's important to call the device_bind() with the proper node offset, when binding the regulator devices. The pmic_bind_childs() can be used for this purpose if PMIC I/O driver is implemented or dm_scan_fdt_node() - otherwise. Detailed informations can be found in the header file. + otherwise. Detailed information can be found in the header file. config DM_REGULATOR_MAX77686 bool "Enable Driver Model for REGULATOR MAX77686"
drivers/power/regulator/regulator-uclass.c +68 -36
198 lines not on this page · raw message
include/power/regulator.h +59 -57
207 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH 3/12 dm: regulator: uclass driver code cleanup
Quoted 11 lines · Przemyslaw Marczak
This cleanup includes:
- remove of the preprocessor macros which pointed to long name functions
- update of the names of some regulator uclass driver functions
- cleanup of the functionregulator_autoset()
- reword of some comments of regulator uclass header file
-regulator_get_by_platname: check error for uclass_find_* function calls
- add function:regulator_name_is_unique
- regulatorpost_bind(): check regulator name uniqueness
- fix mistakes in: regulator/Kconfig
-regulator.h: update comments
Quoted 6 lines
Signed-off-by Przemyslaw Marczak <[email protected]>--- drivers/power/regulator/Kconfig | 2 +- drivers/power/regulator/regulator-uclass.c | 104 +++++++++++++++++--------- include/power/regulator.h | 116 +++++++++++++++-------------- 3 files changed, 128 insertions(+), 94 deletions(-)
Tested on sandbox:
PATCH 4/12 odroid u3: cleanup the regulator calls
In reply to Przemyslaw Marczak--- board/samsung/odroid/odroid.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
board/samsung/odroid/odroid.c +4 -5
@@ -37,6 +37,7 @@ static const char *mmc_regulators[] = {"VDDQ_EMMC_1.8V" ,"VDDQ_EMMC_2.8V" ,"TFLASH_2.8V" , + NULL, };void set_board_type (void )
@@ -427,9 +428,7 @@ int exynos_init(void)int exynos_power_init (void ) { -int list_count =ARRAY_SIZE (mmc_regulators); - -if (regulator_list_autoset (mmc_regulators, list_count,NULL , true)) +if (regulator_list_autoset (mmc_regulators,NULL , true))error ("Unable to init all mmc regulators" );return 0 ;
@@ -441,7 +440,7 @@ static int s5pc210_phy_control(int on)struct udevice *dev;int ret; - ret =regulator_by_platname ("VDD_UOTG_3.0V" , &dev); + ret =regulator_get_by_platname ("VDD_UOTG_3.0V" , &dev);if (ret) {error ("Regulator get error: %d" , ret);return ret;
@@ -487,7 +486,7 @@ int board_usb_init(int index, enum usb_init_type init)/* Power off and on BUCK8 for LAN9730 */ debug ("LAN9730 - Turning power buck 8 OFF and ON.\n" ); - ret =regulator_by_platname ("VCC_P3V3_2.85V" , &dev); + ret =regulator_get_by_platname ("VCC_P3V3_2.85V" , &dev);if (ret) {error ("Regulator get error: %d" , ret);return ret;
Signature · 1 line
1.9.1
PATCH 4/12 odroid u3: cleanup the regulator calls
Hi Przemyslaw,
Quoted 47 lines · Przemyslaw Marczak
Signed-off-by Przemyslaw Marczak <[email protected]>--- board/samsung/odroid/odroid.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)board/samsung/odroid/odroid.c +4
-6@@ -37,6 +37,7 @@ static const char *mmc_regulators[] = {"VDDQ_EMMC_1.8V" ,"VDDQ_EMMC_2.8V" ,"TFLASH_2.8V" , + NULL, };void set_board_type (void )@@ -427,9 +428,7 @@ int exynos_init(void)int exynos_power_init (void ) { -int list_count =ARRAY_SIZE (mmc_regulators); - -if (regulator_list_autoset (mmc_regulators, list_count,NULL , true)) +if (regulator_list_autoset (mmc_regulators,NULL , true))error ("Unable to init all mmc regulators" );return 0 ;@@ -441,7 +440,7 @@ static int s5pc210_phy_control(int on)struct udevice *dev;int ret; - ret =regulator_by_platname ("VDD_UOTG_3.0V" , &dev); + ret =regulator_get_by_platname ("VDD_UOTG_3.0V" , &dev);if (ret) {error ("Regulator get error: %d" , ret);return ret;@@ -487,7 +486,7 @@ int board_usb_init(int index, enum usb_init_type init)/* Power off and on BUCK8 for LAN9730 */ debug ("LAN9730 - Turning power buck 8 OFF and ON.\n" ); - ret =regulator_by_platname ("VCC_P3V3_2.85V" , &dev); + ret =regulator_get_by_platname ("VCC_P3V3_2.85V" , &dev);if (ret) {error ("Regulator get error: %d" , ret);return ret; --
Quoted 2 lines
1.9.1
This patch might need to be merged with the one that changes the function signature, to avoid build errors. Or you could move the CONFIG enable patch later in the stack perhaps?
Regards,
Simon
PATCH 5/12 common: cmd pmic: command cleanup
In reply to Przemyslaw MarczakThis commit cleanups the use of function: failed(). The new function name is: failure(), and it is used for print errno and the errno-related message only.
The second change is choosing PMIC device by it's name, instead of seq number. Thanks to this change, for set the current device, call of pmic_get() is enough.
--- common/cmd_pmic.c | 131 +++++++++++++++++++++++------------------------------- 1 file changed, 55 insertions(+), 76 deletions(-)
common/cmd_pmic.c +55 -76
@@ -10,75 +10,41 @@#include <dm/uclass-internal.h> #include <power/pmic.h> -#define LIMIT_SEQ 3 -#define LIMIT_DEVNAME 20 +#define LIMIT_DEV 32 +#define LIMIT_PARENT 20static struct udevice *currdev; -static int failed (const char *getset,const char *thing, -const char *for_dev,int ret) +static int failure (int ret) { -printf ("Can't %s %s %s.\nError: %d (%s)\n" , getset, thing, for_dev, - ret,errno_str (ret)); -return CMD_RET_FAILURE ; -} - -static int pmic_dev_get (bool list_only,int get_seq,struct udevice **devp) -{ -struct udevice *dev; -int ret; - -if (devp) - *devp =NULL ; - -for (ret =uclass_first_device (UCLASS_PMIC , &dev); dev; - ret =uclass_next_device (&dev)) { -if (list_only) { -printf ("|%*d | %-*.*s| %-*.*s| %s @ %d\n" , -LIMIT_SEQ , dev->seq, -LIMIT_DEVNAME ,LIMIT_DEVNAME , dev->name, -LIMIT_DEVNAME ,LIMIT_DEVNAME , dev->parent->name, -dev_get_uclass_name (dev->parent), - dev->parent->seq); -continue ; - } +printf ("Error: %d (%s)\n" , ret,errno_str (ret)); -if (dev->seq == get_seq) { -if (devp) - *devp = dev; -else -return -EINVAL ; - -return 0 ; - } - } - -if (list_only) -return ret; - -return -ENODEV ; +return CMD_RET_FAILURE ; }static int do_dev (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) { -int seq, ret = -ENODEV ; +char *name; +int ret = -ENODEV ;switch (argc) {case 2 : - seq =simple_strtoul (argv[1 ],NULL ,0 ); - ret =uclass_get_device_by_seq (UCLASS_PMIC , seq, &currdev); -if (ret && (ret =pmic_dev_get (false, seq, &currdev))) - goto failed; + name = argv[1 ]; + ret =pmic_get (name, &currdev); +if (ret) { +printf ("Can't get PMIC: %s!\n" , name); +return failure (ret); + }case 1 : -if (!currdev) - goto failed; +if (!currdev) { +printf ("PMIC device is not set!\n\n" ); +return CMD_RET_USAGE ; + }printf ("dev: %d @ %s\n" , currdev->seq, currdev->name); }return CMD_RET_SUCCESS ; -failed: -return failed ("get" ,"the" ,"device" , ret); }static int do_list (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[])
@@ -86,18 +52,19 @@ static int do_list(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])struct udevice *dev;int ret; -printf ("|%*s | %-*.*s| %-*.*s| %s @ %s\n" , -LIMIT_SEQ ,"Seq" , -LIMIT_DEVNAME ,LIMIT_DEVNAME ,"Name" , -LIMIT_DEVNAME ,LIMIT_DEVNAME ,"Parent name" , +printf ("| %-*.*s| %-*.*s| %s @ %s\n" , +LIMIT_DEV ,LIMIT_DEV ,"Name" , +LIMIT_PARENT ,LIMIT_PARENT ,"Parent name" ,"Parent uclass" ,"seq" );for (ret =uclass_first_device (UCLASS_PMIC , &dev); dev; ret =uclass_next_device (&dev)) { -printf ("|%*d | %-*.*s| %-*.*s| %s @ %d\n" , -LIMIT_SEQ , dev->seq, -LIMIT_DEVNAME ,LIMIT_DEVNAME , dev->name, -LIMIT_DEVNAME ,LIMIT_DEVNAME , dev->parent->name, +if (ret) +continue ; + +printf ("| %-*.*s| %-*.*s| %s @ %d\n" , +LIMIT_DEV ,LIMIT_DEV , dev->name, +LIMIT_PARENT ,LIMIT_PARENT , dev->parent->name,dev_get_uclass_name (dev->parent), dev->parent->seq); }
@@ -114,8 +81,10 @@ static int do_dump(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])uint reg;int ret; -if (!currdev) -return failed ("get" ,"current" ,"device" , -ENODEV ); +if (!currdev) { +printf ("First, set the PMIC device!\n" ); +return CMD_RET_USAGE ; + } dev = currdev;
@@ -123,8 +92,10 @@ static int do_dump(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])for (reg =0 ; reg <pmic_reg_count (dev); reg++) { ret =pmic_read (dev, reg, &value,1 ); -if (ret) -return failed ("read" , dev->name,"register" , ret); +if (ret) { +printf ("Can't read register: %d\n" , reg); +return failure (ret); + }if (!(reg %16 ))printf ("\n0x%02x: " , reg);
@@ -143,8 +114,10 @@ static int do_read(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])uint8_t value;uint reg; -if (!currdev) -return failed ("get" ,"current" ,"device" , -ENODEV ); +if (!currdev) { +printf ("First, set the PMIC device!\n" ); +return CMD_RET_USAGE ; + } dev = currdev;
@@ -154,13 +127,15 @@ static int do_read(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) reg =simple_strtoul (argv[1 ],NULL ,0 ); regs =pmic_reg_count (dev);if (reg > regs) { -printf ("Pmic max reg: %d\n" , regs); -return failed ("read" ,"given" ,"address" , -EFAULT ); +printf ("PMIC max reg: %d\n" , regs); +return failure (-EFAULT ); } ret =pmic_read (dev, reg, &value,1 ); -if (ret) -return failed ("read" , dev->name,"register" , ret); +if (ret) { +printf ("Can't read PMIC register: %d!\n" , reg); +return failure (ret); + }printf ("0x%02x: 0x%2.2x\n" , reg, value);
@@ -174,8 +149,10 @@ static int do_write(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])uint8_t value;uint reg; -if (!currdev) -return failed ("get" ,"current" ,"device" , -ENODEV ); +if (!currdev) { +printf ("First, set the PMIC device!\n" ); +return CMD_RET_USAGE ; + } dev = currdev;
@@ -185,15 +162,17 @@ static int do_write(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) reg =simple_strtoul (argv[1 ],NULL ,0 ); regs =pmic_reg_count (dev);if (reg > regs) { -printf ("Pmic max reg: %d\n" , regs); -return failed ("write" ,"given" ,"address" , -EFAULT ); +printf ("PMIC max reg: %d\n" , regs); +return failure (-EFAULT ); } value =simple_strtoul (argv[2 ],NULL ,0 ); ret =pmic_write (dev, reg, &value,1 ); -if (ret) -return failed ("write" , dev->name,"register" , ret); +if (ret) { +printf ("Can't write PMIC register: %d!\n" , reg); +return failure (ret); + }return CMD_RET_SUCCESS ; }
@@ -224,7 +203,7 @@ static int do_pmic(cmd_tbl_t *cmdtp, int flag, int argc,U_BOOT_CMD (pmic,CONFIG_SYS_MAXARGS ,1 , do_pmic," operations" ,"list - list pmic devices\n" -"pmic dev [id] - show or [set] operating pmic device\n" +"pmic dev [name] - show or [set] operating PMIC device\n" "pmic dump - dump registers\n" "pmic read address - read byte of register at address\n" "pmic write address - write byte to register at address\n"
Signature · 1 line
1.9.1
PATCH 5/12 common: cmd pmic: command cleanup
Quoted 4 lines · Przemyslaw Marczak
This commit cleanups the use of function:
failed(). The new function name is:failure(), and it is used for print errno and the errno-related message only.
Quoted 9 lines
The second change is choosing PMIC device by it's name, instead of seq number. Thanks to this change, for set the current device, call of
pmic_get()is enough.Signed-off-by Przemyslaw Marczak <[email protected]>--- common/cmd_pmic.c | 131 +++++++++++++++++++++++------------------------------- 1 file changed, 55 insertions(+), 76 deletions(-)
Tested on sandbox:
PATCH 6/12 common: cmd regulator: command cleanup
In reply to Przemyslaw MarczakThis commit cleanups the regulator command.
The first change, is adjusting "regulator dev" command to use "regulator-name" constraint, for setting the operating device. Thanks to this, the regulator_get() function is removed.
This also updates do_list() function, with loop over uclass_find_* function calls, to prevent probe of all listed regulators.
This also cleanups the printing in command.
--- common/cmd_regulator.c | 239 +++++++++++++++++++++++++------------------------ 1 file changed, 122 insertions(+), 117 deletions(-)
common/cmd_regulator.c +122 -117
@@ -10,98 +10,70 @@#include <dm/uclass-internal.h> #include <power/regulator.h> -#define LIMIT_SEQ 3#define LIMIT_DEVNAME 20 -#define LIMIT_OFNAME 20 -#define LIMIT_INFO 16 +#define LIMIT_OFNAME 32 +#define LIMIT_INFO 18static struct udevice *currdev; -static int failed (const char *getset,const char *thing, -const char *for_dev,int ret) +static int failure (int ret) { -printf ("Can't %s %s %s.\nError: %d (%s)\n" , getset, thing, for_dev, - ret,errno_str (ret)); -return CMD_RET_FAILURE ; -} - -static int regulator_get (bool list_only,int get_seq,struct udevice **devp) -{ -struct dm_regulator_uclass_platdata *uc_pdata; -struct udevice *dev; -int ret; - -if (devp) - *devp =NULL ; - -for (ret =uclass_first_device (UCLASS_REGULATOR , &dev); dev; - ret =uclass_next_device (&dev)) { -if (list_only) { - uc_pdata =dev_get_uclass_platdata (dev); -printf ("|%*d | %*.*s @ %-*.*s| %s @ %s\n" , -LIMIT_SEQ , dev->seq, -LIMIT_DEVNAME ,LIMIT_DEVNAME , dev->name, -LIMIT_OFNAME ,LIMIT_OFNAME , uc_pdata->name, - dev->parent->name, -dev_get_uclass_name (dev->parent)); -continue ; - } - -if (dev->seq == get_seq) { -if (devp) - *devp = dev; -else -return -EINVAL ; - -return 0 ; - } - } - -if (list_only) -return ret; +printf ("Error: %d (%s)\n" , ret,errno_str (ret)); -return -ENODEV ; +return CMD_RET_FAILURE ; }static int do_dev (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) {struct dm_regulator_uclass_platdata *uc_pdata; -int seq, ret = -ENXIO ; +const char *name; +int ret = -ENXIO ;switch (argc) {case 2 : - seq =simple_strtoul (argv[1 ],NULL ,0 ); - ret =uclass_get_device_by_seq (UCLASS_REGULATOR , seq, &currdev); -if (ret && (ret =regulator_get (false, seq, &currdev))) - goto failed; + name = argv[1 ]; + ret =regulator_get_by_platname (name, &currdev); +if (ret) { +printf ("Can't get the regulator: %s!\n" , name); +return failure (ret); + }case 1 : +if (!currdev) { +printf ("Regulator device is not set!\n\n" ); +return CMD_RET_USAGE ; + } + uc_pdata =dev_get_uclass_platdata (currdev); -if (!uc_pdata) - goto failed; +if (!uc_pdata) { +printf ("%s: no regulator platform data!\n" , currdev->name); +return failure (ret); + } -printf ("dev: %d @ %s\n" , currdev->seq, uc_pdata->name); +printf ("dev: %s @ %s\n" , uc_pdata->name, currdev->name); }return CMD_RET_SUCCESS ; -failed: -return failed ("get" ,"the" ,"device" , ret); } -static int get_curr_dev_and_pl (struct udevice **devp, -struct dm_regulator_uclass_platdata **uc_pdata, -bool allow_type_fixed) +static int curr_dev_and_platdata (struct udevice **devp, +struct dm_regulator_uclass_platdata **uc_pdata, +bool allow_type_fixed) { *devp =NULL ; *uc_pdata =NULL ; -if (!currdev) -return failed ("get" ,"current" ,"device" , -ENODEV ); +if (!currdev) { +printf ("First, set the regulator device!\n" ); +return CMD_RET_FAILURE ; + } *devp = currdev; *uc_pdata =dev_get_uclass_platdata (*devp); -if (!*uc_pdata) -return failed ("get" ,"regulator" ,"platdata" , -ENXIO ); +if (!*uc_pdata) { +error ("Regulator: %s - missing platform data!" , currdev->name); +return CMD_RET_FAILURE ; + }if (!allow_type_fixed && (*uc_pdata)->type ==REGULATOR_TYPE_FIXED ) {printf ("Operation not allowed for fixed regulator!\n" );
@@ -113,19 +85,28 @@ static int get_curr_dev_and_pl(struct udevice **devp,static int do_list (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) { +struct dm_regulator_uclass_platdata *uc_pdata; +struct udevice *dev;int ret; -printf ("|%*s | %*.*s @ %-*.*s| %s @ %s\n" , -LIMIT_SEQ ,"Seq" , -LIMIT_DEVNAME ,LIMIT_DEVNAME ,"Name" , -LIMIT_OFNAME ,LIMIT_OFNAME ,"fdtname" , -"Parent" ,"uclass" ); +printf ("| %-*.*s| %-*.*s| %s\n" , +LIMIT_DEVNAME ,LIMIT_DEVNAME ,"Device" , +LIMIT_OFNAME ,LIMIT_OFNAME ,"regulator-name" , +"Parent" ); - ret =regulator_get (true,0 ,NULL ); -if (ret) -return CMD_RET_FAILURE ; +for (ret =uclass_find_first_device (UCLASS_REGULATOR , &dev); dev; + ret =uclass_find_next_device (&dev)) { +if (ret) +continue ; -return CMD_RET_SUCCESS ; + uc_pdata =dev_get_uclass_platdata (dev); +printf ("| %-*.*s| %-*.*s| %s\n" , +LIMIT_DEVNAME ,LIMIT_DEVNAME , dev->name, +LIMIT_OFNAME ,LIMIT_OFNAME , uc_pdata->name, + dev->parent->name); + } + +return ret; }static int constraint (const char *name,int val,const char *val_name)
@@ -167,17 +148,18 @@ static int do_info(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])int ret;int i; - ret =get_curr_dev_and_pl (&dev, &uc_pdata, true); + ret =curr_dev_and_platdata (&dev, &uc_pdata, true);if (ret)return ret; parent_uc =dev_get_uclass_name (dev->parent); -printf ("Uclass regulator dev %d info:\n" , dev->seq); -printf ("%-*s %s @ %s\n%-*s %s\n%-*s %s\n%-*s\n" , -LIMIT_INFO ,"* parent:" , dev->parent->name, parent_uc, -LIMIT_INFO ,"* dev name:" , dev->name, -LIMIT_INFO ,"* fdt name:" , uc_pdata->name, +printf ("%s\n%-*s %s\n%-*s %s\n%-*s %s\n%-*s %s\n%-*s\n" , +"Regulator info:" , +LIMIT_INFO ,"* regulator-name:" , uc_pdata->name, +LIMIT_INFO ,"* device name:" , dev->name, +LIMIT_INFO ,"* parent name:" , dev->parent->name, +LIMIT_INFO ,"* parent uclass:" , parent_uc,LIMIT_INFO ,"* constraints:" );constraint (" - min uV:" , uc_pdata->min_uV,NULL );
@@ -206,10 +188,12 @@ static int do_status(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])struct udevice *dev;bool enabled; - ret =get_curr_dev_and_pl (&dev, &uc_pdata, true); + ret =curr_dev_and_platdata (&dev, &uc_pdata, true);if (ret)return ret; +printf ("Regulator %s status:\n" , uc_pdata->name); + enabled =regulator_get_enable (dev);constraint (" * enable:" , enabled, enabled ?"true" :"false" );
@@ -234,16 +218,19 @@ static int do_value(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])int force;int ret; - ret =get_curr_dev_and_pl (&dev, &uc_pdata, argc ==1 ); + ret =curr_dev_and_platdata (&dev, &uc_pdata, argc ==1 );if (ret)return ret;if (argc ==1 ) { - value =regulator_get_value (dev); -if (value <0 ) -return failed ("get" , uc_pdata->name,"voltage" , value); + ret =regulator_get_value (dev); +if (ret <0 ) { +printf ("Regulator: %s - can't get the Voltage!\n" , + uc_pdata->name); +return failure (ret); + } -printf ("%d uV\n" , value); +printf ("%d uV\n" , ret);return CMD_RET_SUCCESS ; }
@@ -259,8 +246,11 @@ static int do_value(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } ret =regulator_set_value (dev, value); -if (ret) -return failed ("set" , uc_pdata->name,"voltage value" , ret); +if (ret) { +printf ("Regulator: %s - can't set the Voltage!\n" , + uc_pdata->name); +return failure (ret); + }return CMD_RET_SUCCESS ; }
@@ -272,16 +262,19 @@ static int do_current(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])int current;int ret; - ret =get_curr_dev_and_pl (&dev, &uc_pdata, argc ==1 ); + ret =curr_dev_and_platdata (&dev, &uc_pdata, argc ==1 );if (ret)return ret;if (argc ==1 ) { - current =regulator_get_current (dev); -if (current <0 ) -return failed ("get" , uc_pdata->name,"current" , current); + ret =regulator_get_current (dev); +if (ret <0 ) { +printf ("Regulator: %s - can't get the Current!\n" , + uc_pdata->name); +return failure (ret); + } -printf ("%d uA\n" , current); +printf ("%d uA\n" , ret);return CMD_RET_SUCCESS ; }
@@ -292,8 +285,11 @@ static int do_current(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } ret =regulator_set_current (dev, current); -if (ret) -return failed ("set" , uc_pdata->name,"current value" , ret); +if (ret) { +printf ("Regulator: %s - can't set the Current!\n" , + uc_pdata->name); +return failure (ret); + }return CMD_RET_SUCCESS ; }
@@ -302,28 +298,33 @@ static int do_mode(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) {struct udevice *dev;struct dm_regulator_uclass_platdata *uc_pdata; -int new_mode;int mode;int ret; - ret =get_curr_dev_and_pl (&dev, &uc_pdata, false); + ret =curr_dev_and_platdata (&dev, &uc_pdata, false);if (ret)return ret;if (argc ==1 ) { - mode =regulator_get_mode (dev); -if (mode <0 ) -return failed ("get" , uc_pdata->name,"mode" , mode); + ret =regulator_get_mode (dev); +if (ret <0 ) { +printf ("Regulator: %s - can't get the operation mode!\n" , + uc_pdata->name); +return failure (ret); + } -printf ("mode id: %d\n" , mode); +printf ("mode id: %d\n" , ret);return CMD_RET_SUCCESS ; } - new_mode =simple_strtoul (argv[1 ],NULL ,0 ); + mode =simple_strtoul (argv[1 ],NULL ,0 ); - ret =regulator_set_mode (dev, new_mode); -if (ret) -return failed ("set" , uc_pdata->name,"mode" , ret); + ret =regulator_set_mode (dev, mode); +if (ret) { +printf ("Regulator: %s - can't set the operation mode!\n" , + uc_pdata->name); +return failure (ret); + }return CMD_RET_SUCCESS ; }
@@ -334,13 +335,15 @@ static int do_enable(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])struct dm_regulator_uclass_platdata *uc_pdata;int ret; - ret =get_curr_dev_and_pl (&dev, &uc_pdata, true); + ret =curr_dev_and_platdata (&dev, &uc_pdata, true);if (ret)return ret; ret =regulator_set_enable (dev, true); -if (ret) -return failed ("enable" ,"regulator" , uc_pdata->name, ret); +if (ret) { +printf ("Regulator: %s - can't enable!\n" , uc_pdata->name); +return failure (ret); + }return CMD_RET_SUCCESS ; }
@@ -351,13 +354,15 @@ static int do_disable(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])struct dm_regulator_uclass_platdata *uc_pdata;int ret; - ret =get_curr_dev_and_pl (&dev, &uc_pdata, true); + ret =curr_dev_and_platdata (&dev, &uc_pdata, true);if (ret)return ret; ret =regulator_set_enable (dev, false); -if (ret) -return failed ("disable" ,"regulator" , uc_pdata->name, ret); +if (ret) { +printf ("Regulator: %s - can't disable!\n" , uc_pdata->name); +return failure (ret); + }return CMD_RET_SUCCESS ; }
@@ -391,13 +396,13 @@ static int do_regulator(cmd_tbl_t *cmdtp, int flag, int argc,U_BOOT_CMD (regulator,CONFIG_SYS_MAXARGS ,1 , do_regulator,"uclass operations" , -"list - list UCLASS regulator devices\n" -"regulator dev [id] - show or [set] operating regulator device\n" -"regulator [info] - print constraints info\n" -"regulator [status] - print operating status\n" -"regulator [value] [-f] - print/[set] voltage value [uV] (force)\n" -"regulator [current] - print/[set] current value [uA]\n" -"regulator [mode_id] - print/[set] operating mode id\n" -"regulator [enable] - enable the regulator output\n" -"regulator [disable] - disable the regulator output\n" +"list - list UCLASS regulator devices\n" +"regulator dev [regulator-name] - show/[set] operating regulator device\n" +"regulator info - print constraints info\n" +"regulator status - print operating status\n" +"regulator value [val] [-f] - print/[set] voltage value [uV] (force)\n" +"regulator current [val] - print/[set] current value [uA]\n" +"regulator mode [id] - print/[set] operating mode id\n" +"regulator enable - enable the regulator output\n" +"regulator disable - disable the regulator output\n" );
Signature · 1 line
1.9.1
PATCH 6/12 common: cmd regulator: command cleanup
Quoted 8 lines · Przemyslaw Marczak
This commit cleanups the regulator command.
The first change, is adjusting "regulator dev" command to use "regulator-name" constraint, for setting the operating device. Thanks to this, theregulator_get()function is removed.This also updates
do_list()function, with loop over uclass_find_* function calls, to prevent probe of all listed regulators.
Quoted 6 lines
This also cleanups the printing in command.
Signed-off-by Przemyslaw Marczak <[email protected]>--- common/cmd_regulator.c | 239 +++++++++++++++++++++++++------------------------ 1 file changed, 122 insertions(+), 117 deletions(-)
Tested on sandbox:
PATCH 7/12 doc: driver-model: pmic-framework.txt - cleanup
In reply to Przemyslaw MarczakThis commit cleanups the PMIC framework documentation.
--- doc/driver-model/pmic-framework.txt | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-)
doc/driver-model/pmic-framework.txt +9 -11
@@ -79,7 +79,7 @@ use pmic read/write directly. 3. Pmic uclass ============== -The basic informations: +The basic information: * Uclass: 'UCLASS_PMIC' * Header: 'include/power/pmic.h' * Core: 'drivers/power/pmic/pmic-uclass.c'
@@ -88,14 +88,13 @@ The basic informations: config: 'CONFIG_CMD_PMIC' * Example: 'drivers/power/pmic/max77686.c' -This is still under the construction. So for the API description, please refer -to the header file. +For detailed API description, please refer to the header file. As an example of the pmic driver, please refer to the MAX77686 driver. -Please pay attention for the driver's '.bind' method. Exactly the function call: -'pmic_bind_childs()', which is used to bind the regulators by using the array of -regulator's node, compatible prefixes. +Please pay attention for the driver's bind() method. Exactly the function call: +'pmic_bind_children()', which is used to bind the regulators by using the array +of regulator's node, compatible prefixes. The 'pmic; command also supports the new API. So the pmic command can be enabled by adding CONFIG_CMD_PMIC.
@@ -108,11 +107,11 @@ The new pmic command allows to: This command can use only UCLASS_PMIC devices, since this uclass is designed for pmic I/O operations only. -For more informations, please refer to the file: 'common/cmd_pmic.c'. +For more information, please refer to the core file. 4. Regulator uclass =================== -The basic informations: +The basic information: * Uclass: 'UCLASS_REGULATOR' * Header: 'include/power/regulator.h' * Core: 'drivers/power/regulator/regulator-uclass.c'
@@ -125,8 +124,7 @@ The basic informations: * Example: 'drivers/power/regulator/fixed.c' config" 'CONFIG_DM_REGULATOR_FIXED' -This is still under the construction. So for the API description, please refer -to the header file. +For detailed API description, please refer to the header file. For the example regulator driver, please refer to the MAX77686 regulator driver, but this driver can't operate without pmic's example driver, which provides an
@@ -139,4 +137,4 @@ The 'regulator' command also supports the new API. The command allow: - choose the current device (like the mmc command) - do all regulator-specific operations -For more informations, please refer to the file: 'common/cmd_regulator.c' +For more information, please refer to the command file.
Signature · 1 line
1.9.1
PATCH 7/12 doc: driver-model: pmic-framework.txt - cleanup
Quoted 6 lines · Przemyslaw Marczak
This commit cleanups the PMIC framework documentation.
Signed-off-by Przemyslaw Marczak <[email protected]>--- doc/driver-model/pmic-framework.txt | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-)
PATCH 8/12 sandbox: i2c: search child emul dev and check its uclass id
In reply to Przemyslaw MarczakThe function get_emul() in sandbox i2c bus driver, always returns first child as i2c emul device. This may only work for i2c devices with a single child, which is an only i2c emul device.
In case when i2c device has more than one child (e.g. PMIC), and one is i2c emul, then the function should search it by check uclass id for each child. This patch add this change to the get_emul().
--- drivers/i2c/sandbox_i2c.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)
drivers/i2c/sandbox_i2c.c +17 -3
@@ -26,6 +26,7 @@ static int get_emul(struct udevice *dev, struct udevice **devp, struct dm_i2c_ops **opsp) {struct dm_i2c_chip *plat; +struct udevice *child;int ret; *devp =NULL ;
@@ -37,9 +38,22 @@ static int get_emul(struct udevice *dev, struct udevice **devp,if (ret)return ret; - ret =device_get_child (dev,0 , &plat->emul); -if (ret) -return ret; +for (device_find_first_child (dev, &child); child; +device_find_next_child (&child)) { +if (device_get_uclass_id (child) !=UCLASS_I2C_EMUL ) +continue ; + + ret =device_probe (child); +if (ret) +return ret; + +break ; + } + +if (child) + plat->emul = child; +else +return -ENODEV ; } *devp = plat->emul; *opsp =i2c_get_ops (plat->emul);
Signature · 1 line
1.9.1
PATCH 8/12 sandbox: i2c: search child emul dev and check its uclass id
Quoted 8 lines · Przemyslaw Marczak
The function
get_emul()in sandbox i2c bus driver, always returns first child as i2c emul device. This may only work for i2c devices with a single child, which is an only i2c emul device.In case when i2c device has more than one child (e.g. PMIC), and one is i2c emul, then the function should search it by check uclass id for each child. This patch add this change to the
get_emul().
Quoted 5 lines
Signed-off-by Przemyslaw Marczak <[email protected]>Cc Simon Glass <[email protected]>--- drivers/i2c/sandbox_i2c.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)
Tested on sandbox:
PATCH 9/12 sandbox: add: sandbox PMIC device drivers: I2C emul, pmic, regulator
In reply to Przemyslaw MarczakThis commit adds emulation of sandbox PMIC device, which includes:
- PMIC I2C emulation driver
- PMIC I/O driver (UCLASS_PMIC)
- PMIC regulator driver (UCLASS_REGULATOR)
The sandbox PMIC has 12 significant registers and 4 as padding to 16 bytes, which allows using 'i2c md' command with the default count (16).
The sandbox PMIC provides regulators:
- 2x BUCK
- 2x LDO
Each, with adjustable output:
- Enable state
- Voltage
- Current limit (LDO1/BUCK1 only)
- Operation mode (different for BUCK and LDO)
Each attribute has it's own register, beside the enable state, which depends on operation mode.
The header file: sandbox_pmic.h includes PMIC's default register values, which are set on i2c pmic emul driver's probe() method.
--- doc/device-tree-bindings/pmic/sandbox.txt | 35 +++ doc/device-tree-bindings/regulator/sandbox.txt | 45 ++++ drivers/power/pmic/Kconfig | 25 ++ drivers/power/pmic/Makefile | 3 +- drivers/power/pmic/i2c_pmic_emul.c | 145 ++++++++++ drivers/power/pmic/sandbox.c | 79 ++++++ drivers/power/regulator/Kconfig | 30 +++ drivers/power/regulator/Makefile | 1 + drivers/power/regulator/sandbox.c | 355 +++++++++++++++++++++++++ include/power/sandbox_pmic.h | 189 +++++++++++++ 10 files changed, 906 insertions(+), 1 deletion(-) create mode 100644 doc/device-tree-bindings/pmic/sandbox.txt create mode 100644 doc/device-tree-bindings/regulator/sandbox.txt create mode 100644 drivers/power/pmic/i2c_pmic_emul.c create mode 100644 drivers/power/pmic/sandbox.c create mode 100644 drivers/power/regulator/sandbox.c create mode 100644 include/power/sandbox_pmic.h
doc/device-tree-bindings/pmic/sandbox.txt new file +35 -0
@@ -0,0 +1,35 @@ +Sandbox pmic + +This device uses two drivers: +- drivers/power/pmic/sandbox.c (for parent device) +- drivers/power/regulator/sandbox.c (for child regulators) + +This file describes the binding info for the PMIC driver. + +To bind the regulators, please read the regulator binding info: +- doc/device-tree-bindings/regulator/sandbox.txt + +Required PMIC node properties: +- compatible: "sandbox,pmic" +- reg = 0x40 + +Required PMIC's "emul" subnode, with property: +- compatible: "sandbox,i2c-pmic" + +With the above properties, the pmic device can be used for read/write only. +To bind each regulator, the optional regulator subnodes should exists. + +Optional subnodes: +- ldo/buck subnodes of each device's regulator (see regulator binding info) + +Example: + +sandbox_pmic { + compatible = "sandbox,pmic"; + reg = <0x40>; + + /* Mandatory for I/O */ + emul { + compatible = "sandbox,i2c-pmic"; + }; +};
doc/device-tree-bindings/regulator/sandbox.txt new file +45 -0
45 lines not on this page · raw message
drivers/power/pmic/Kconfig +25 -0
@@ -16,3 +16,28 @@ config DM_PMIC_MAX77686 ---help--- This config enables implementation of driver-model pmic uclass features for PMIC MAX77686. The driver implements read/write operations. + +config DM_PMIC_SANDBOX + bool "Enable Driver Model for emulated Sandbox PMIC " + depends on DM_PMIC + ---help--- + Enable the driver for Sandbox PMIC emulation. The emulated PMIC device + depends on two drivers: + - sandbox PMIC I/O driver - implements dm pmic operations + - sandbox PMIC i2c emul driver - emulates the PMIC's I2C transmission + + A detailed information can be found in header: '<power/sandbox_pmic.h>' + + The Sandbox PMIC info: + * I/O interface: + - I2C chip address: 0x40 + - first register address: 0x0 + - register count: 0x10 + * Adjustable outputs: + - 2x LDO + - 2x BUCK + - Each, with a different operating conditions (header). + * Reset values: + - set by i2c emul driver's probe() (defaults in header) + + Driver binding info: doc/device-tree-bindings/pmic/sandbox.txt
drivers/power/pmic/Makefile +2 -1
@@ -6,12 +6,13 @@ # obj-$(CONFIG_DM_PMIC) += pmic-uclass.o +obj-$(CONFIG_DM_PMIC_MAX77686) += max77686.o +obj-$(CONFIG_DM_PMIC_SANDBOX) += sandbox.o i2c_pmic_emul.o obj-$(CONFIG_POWER_LTC3676) += pmic_ltc3676.o obj-$(CONFIG_POWER_MAX8998) += pmic_max8998.o obj-$(CONFIG_POWER_MAX8997) += pmic_max8997.o obj-$(CONFIG_POWER_MUIC_MAX8997) += muic_max8997.o obj-$(CONFIG_POWER_MAX77686) += pmic_max77686.o -obj-$(CONFIG_DM_PMIC_MAX77686) += max77686.o obj-$(CONFIG_POWER_PFUZE100) += pmic_pfuze100.o obj-$(CONFIG_POWER_TPS65090_I2C) += pmic_tps65090.o obj-$(CONFIG_POWER_TPS65090_EC) += pmic_tps65090_ec.o
drivers/power/pmic/i2c_pmic_emul.c new file +145 -0
145 lines not on this page · raw message
drivers/power/pmic/sandbox.c new file +79 -0
79 lines not on this page · raw message
drivers/power/regulator/Kconfig +30 -0
@@ -31,3 +31,33 @@ config DM_REGULATOR_FIXED This config enables implementation of driver-model regulator uclass features for fixed value regulators. The driver implements get/set api for enable and get only for voltage value. + +config DM_REGULATOR_SANDBOX + bool "Enable Driver Model for Sandbox PMIC regulator" + depends on DM_REGULATOR && DM_PMIC_SANDBOX + ---help--- + Enable the regulator driver for emulated Sandbox PMIC. + The emulated PMIC device depends on two drivers: + - sandbox PMIC I/O driver - implements dm pmic operations + - sandbox PMIC regulator driver - implements dm regulator operations + - sandbox PMIC i2c emul driver - emulates the PMIC's I2C transmission + + The regulator driver provides uclass operations for sandbox PMIC's + regulators. The driver implements get/set api for: voltage, current, + operation mode and enable state. + The driver supports LDO and BUCK regulators. + + The Sandbox PMIC info: + * I/O interface: + - I2C chip address: 0x40 + - first register address: 0x0 + - register count: 0x10 + * Adjustable outputs: + - 2x LDO + - 2x BUCK + - Each, with a different operating conditions (header). + * Reset values: + - set by i2c emul driver's probe() (defaults in header) + + A detailed information can be found in header: '<power/sandbox_pmic.h>' + Binding info: 'doc/device-tree-bindings/pmic/max77686.txt'
drivers/power/regulator/Makefile +1 -0
@@ -8,3 +8,4 @@ obj-$(CONFIG_DM_REGULATOR) += regulator-uclass.o obj-$(CONFIG_DM_REGULATOR_MAX77686) += max77686.o obj-$(CONFIG_DM_REGULATOR_FIXED) += fixed.o +obj-$(CONFIG_DM_REGULATOR_SANDBOX) += sandbox.o
drivers/power/regulator/sandbox.c new file +355 -0
355 lines not on this page · raw message
include/power/sandbox_pmic.h new file +189 -0
189 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH 9/12 sandbox: add: sandbox PMIC device drivers: I2C emul, pmic, regulator
Hi Przemyslaw,
Quoted 35 lines · Przemyslaw Marczak
This commit adds emulation of sandbox PMIC device, which includes:
- PMIC I2C emulation driver
- PMIC I/O driver (UCLASS_PMIC)
- PMIC regulator driver (UCLASS_REGULATOR)The sandbox PMIC has 12 significant registers and 4 as padding to 16 bytes, which allows using 'i2c md' command with the default count (16).
The sandbox PMIC provides regulators:
- 2x BUCK
- 2x LDOEach, with adjustable output:
- Enable state
- Voltage
- Current limit (LDO1/BUCK1 only)
- Operation mode (different for BUCK and LDO)Each attribute has it's own register, beside the enable state, which depends on operation mode.
The header file:
sandbox_pmic.hincludes PMIC's default register values, which are set on i2c pmic emul driver'sprobe()method.Signed-off-by Przemyslaw Marczak <[email protected]>--- doc/device-tree-bindings/pmic/sandbox.txt | 35 +++ doc/device-tree-bindings/regulator/sandbox.txt | 45 ++++ drivers/power/pmic/Kconfig | 25 ++ drivers/power/pmic/Makefile | 3 +- drivers/power/pmic/i2c_pmic_emul.c | 145 ++++++++++ drivers/power/pmic/sandbox.c | 79 ++++++ drivers/power/regulator/Kconfig | 30 +++ drivers/power/regulator/Makefile | 1 + drivers/power/regulator/sandbox.c | 355 +++++++++++++++++++++++++
Quoted 8 lines
include/power/sandbox_pmic.h | 189 +++++++++++++ 10 files changed, 906 insertions(+), 1 deletion(-) create mode 100644 doc/device-tree-bindings/pmic/sandbox.txt create mode 100644 doc/device-tree-bindings/regulator/sandbox.txt create mode 100644 drivers/power/pmic/i2c_pmic_emul.c create mode 100644 drivers/power/pmic/sandbox.c create mode 100644 drivers/power/regulator/sandbox.c create mode 100644 include/power/sandbox_pmic.h
Tested on sandbox:
I expected i2c_pmic_emul to get its settings from the device tree too
- is that not possible for some reason?
Regards,
Simon
PATCH 9/12 sandbox: add: sandbox PMIC device drivers: I2C emul, pmic, regulator
Hello Simon,
Quoted 48 lines · Simon Glass
Hi Przemyslaw,
Quoted 37 lines · Przemyslaw Marczak
This commit adds emulation of sandbox PMIC device, which includes:
- PMIC I2C emulation driver
- PMIC I/O driver (UCLASS_PMIC)
- PMIC regulator driver (UCLASS_REGULATOR)The sandbox PMIC has 12 significant registers and 4 as padding to 16 bytes, which allows using 'i2c md' command with the default count (16).
The sandbox PMIC provides regulators:
- 2x BUCK
- 2x LDOEach, with adjustable output:
- Enable state
- Voltage
- Current limit (LDO1/BUCK1 only)
- Operation mode (different for BUCK and LDO)Each attribute has it's own register, beside the enable state, which depends on operation mode.
The header file:
sandbox_pmic.hincludes PMIC's default register values, which are set on i2c pmic emul driver'sprobe()method.Signed-off-by Przemyslaw Marczak <[email protected]>--- doc/device-tree-bindings/pmic/sandbox.txt | 35 +++ doc/device-tree-bindings/regulator/sandbox.txt | 45 ++++ drivers/power/pmic/Kconfig | 25 ++ drivers/power/pmic/Makefile | 3 +- drivers/power/pmic/i2c_pmic_emul.c | 145 ++++++++++ drivers/power/pmic/sandbox.c | 79 ++++++ drivers/power/regulator/Kconfig | 30 +++ drivers/power/regulator/Makefile | 1 + drivers/power/regulator/sandbox.c | 355 +++++++++++++++++++++++++ include/power/sandbox_pmic.h | 189 +++++++++++++ 10 files changed, 906 insertions(+), 1 deletion(-)Quoted 6 lines
create mode 100644
doc/device-tree-bindings/pmic/sandbox.txtcreate mode 100644doc/device-tree-bindings/regulator/sandbox.txtcreate mode 100644drivers/power/pmic/i2c_pmic_emul.ccreate mode 100644drivers/power/pmic/sandbox.c
create mode 100644drivers/power/regulator/sandbox.ccreate mode 100644include/power/sandbox_pmic.hAcked-by Simon Glass <[email protected]>
Quoted 9 lines
Tested on sandbox:
Tested-by Simon Glass <[email protected]>I expected
i2c_pmic_emulto get its settings from the device tree too
- is that not possible for some reason?Regards,
Simon
Hmm, I could add some reg default array to the emul node, will check it.
Best regards,
Signature · 4 lines
Przemyslaw Marczak Samsung R&D Institute Poland Samsung Electronics p.marczak at samsung.com
PATCH 9/12 sandbox: add: sandbox PMIC device drivers: I2C emul, pmic, regulator
In reply to Simon GlassHello Simon,
Quoted 48 lines · Simon Glass
Hi Przemyslaw,
Quoted 37 lines · Przemyslaw Marczak
This commit adds emulation of sandbox PMIC device, which includes:
- PMIC I2C emulation driver
- PMIC I/O driver (UCLASS_PMIC)
- PMIC regulator driver (UCLASS_REGULATOR)The sandbox PMIC has 12 significant registers and 4 as padding to 16 bytes, which allows using 'i2c md' command with the default count (16).
The sandbox PMIC provides regulators:
- 2x BUCK
- 2x LDOEach, with adjustable output:
- Enable state
- Voltage
- Current limit (LDO1/BUCK1 only)
- Operation mode (different for BUCK and LDO)Each attribute has it's own register, beside the enable state, which depends on operation mode.
The header file:
sandbox_pmic.hincludes PMIC's default register values, which are set on i2c pmic emul driver'sprobe()method.Signed-off-by Przemyslaw Marczak <[email protected]>--- doc/device-tree-bindings/pmic/sandbox.txt | 35 +++ doc/device-tree-bindings/regulator/sandbox.txt | 45 ++++ drivers/power/pmic/Kconfig | 25 ++ drivers/power/pmic/Makefile | 3 +- drivers/power/pmic/i2c_pmic_emul.c | 145 ++++++++++ drivers/power/pmic/sandbox.c | 79 ++++++ drivers/power/regulator/Kconfig | 30 +++ drivers/power/regulator/Makefile | 1 + drivers/power/regulator/sandbox.c | 355 +++++++++++++++++++++++++ include/power/sandbox_pmic.h | 189 +++++++++++++ 10 files changed, 906 insertions(+), 1 deletion(-)Quoted 6 lines
create mode 100644
doc/device-tree-bindings/pmic/sandbox.txtcreate mode 100644doc/device-tree-bindings/regulator/sandbox.txtcreate mode 100644drivers/power/pmic/i2c_pmic_emul.ccreate mode 100644drivers/power/pmic/sandbox.c
create mode 100644drivers/power/regulator/sandbox.ccreate mode 100644include/power/sandbox_pmic.hAcked-by Simon Glass <[email protected]>
Quoted 9 lines
Tested on sandbox:
Tested-by Simon Glass <[email protected]>I expected
i2c_pmic_emulto get its settings from the device tree too
- is that not possible for some reason?Regards,
Simon
To put the default PMIC register settings into device tree, I would like add some changes:
- add arch/sandbox/dts/include/dt-bindings/pmic/sandbox_pmic.h - to define "VAL2REG(min, step, val)" macro and operation mode IDs
- add arch/sandbox/dts/sandbox_pmic.dtsi
- include the sandbox_pmic.dtsi in sandbox.dts
- include the sandbox_pmic.dtsi in test.dts
And the last one is a problem, because it's compiled without the U-Boot build system - but by dtc command. I could extend the dtc by arg '-i' - to include the sandbox_pmic.dtsi, but then, still I can't use the preprocessor macro.
I think, that move the "test.dts" into "arch/sandbox/dts" directory is a good idea in this case.
Is that acceptable for you?
Actually I didn't used the script "test-dm.sh" before, since I just compile the U-Boot by my own script with the "dtc" routine.
Best regards,
Signature · 4 lines
Przemyslaw Marczak Samsung R&D Institute Poland Samsung Electronics p.marczak at samsung.com
PATCH 9/12 sandbox: add: sandbox PMIC device drivers: I2C emul, pmic, regulator
Hi Przemyslaw,
Quoted 80 lines · Przemyslaw Marczak
Hello Simon,
Quoted 54 lines · Simon Glass
Hi Przemyslaw,
Quoted 41 lines · Przemyslaw Marczak
This commit adds emulation of sandbox PMIC device, which includes:
- PMIC I2C emulation driver
- PMIC I/O driver (UCLASS_PMIC)
- PMIC regulator driver (UCLASS_REGULATOR)The sandbox PMIC has 12 significant registers and 4 as padding to 16 bytes,
which allows using 'i2c md' command with the default count (16).The sandbox PMIC provides regulators:
- 2x BUCK
- 2x LDOEach, with adjustable output:
- Enable state
- Voltage
- Current limit (LDO1/BUCK1 only)
- Operation mode (different for BUCK and LDO)Each attribute has it's own register, beside the enable state, which depends
on operation mode.The header file:
sandbox_pmic.hincludes PMIC's default register values, which are set on i2c pmic emul driver'sprobe()method.Signed-off-by Przemyslaw Marczak <[email protected]>--- doc/device-tree-bindings/pmic/sandbox.txt | 35 +++ doc/device-tree-bindings/regulator/sandbox.txt | 45 ++++ drivers/power/pmic/Kconfig | 25 ++ drivers/power/pmic/Makefile | 3 +- drivers/power/pmic/i2c_pmic_emul.c | 145 ++++++++++ drivers/power/pmic/sandbox.c | 79 ++++++ drivers/power/regulator/Kconfig | 30 +++ drivers/power/regulator/Makefile | 1 + drivers/power/regulator/sandbox.c | 355 +++++++++++++++++++++++++ include/power/sandbox_pmic.h | 189 +++++++++++++ 10 files changed, 906 insertions(+), 1 deletion(-)Quoted 6 lines
create mode 100644
doc/device-tree-bindings/pmic/sandbox.txtcreate mode 100644doc/device-tree-bindings/regulator/sandbox.txtcreate mode 100644drivers/power/pmic/i2c_pmic_emul.ccreate mode 100644drivers/power/pmic/sandbox.c
create mode 100644drivers/power/regulator/sandbox.ccreate mode 100644include/power/sandbox_pmic.hAcked-by Simon Glass <[email protected]>Quoted 9 lines
Tested on sandbox:
Tested-by Simon Glass <[email protected]>I expected
i2c_pmic_emulto get its settings from the device tree too
- is that not possible for some reason?Regards,
SimonTo put the default PMIC register settings into device tree,
I would like add some changes:
- addarch/sandbox/dts/include/dt-bindings/pmic/sandbox_pmic.h- to define "VAL2REG(min, step, val)" macro and operation mode IDs
- addarch/sandbox/dts/sandbox_pmic.dtsi
- include thesandbox_pmic.dtsiinsandbox.dts
- include thesandbox_pmic.dtsiintest.dtsAnd the last one is a problem, because it's compiled without the U-Boot build system - but by dtc command. I could extend the dtc by arg '-i' - to include the
sandbox_pmic.dtsi, but then, still I can't use the preprocessor macro.
Quoted 4 lines
I think, that move the "
test.dts" into "arch/sandbox/dts" directory is a good idea in this case.Is that acceptable for you?
Yes I think that is OK. Another option may be to add a -I option to include $(ARCH)/dts.
Quoted 3 lines
Actually I didn't used the script "
test-dm.sh" before, since I just compile the U-Boot by my own script with the "dtc" routine.
Regards,
Simon
PATCH 10/12 test: dm: dts: add sandbox pmic i2c node
In reply to Przemyslaw MarczakThis commit adds sandbox PMIC subnode to sandbox i2c bus 0.
The PMIC's node includes:
- 2x BUCK
- 2x LDO
Each regulator node include proper constraints:
- min, max micro Volts
- min, max micro Amps (only first of each type)
- always on (BUCK1)
- boot on (LDO1)
--- test/dm/test.dts | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+)
test/dm/test.dts +38 -0
@@ -139,6 +139,44 @@ sandbox,size = <256>; }; }; + + sandbox_pmic { + reg = <0x40>; + compatible = "sandbox,pmic"; + emul { + compatible = "sandbox,i2c-pmic"; + }; + + buck1 { + regulator-name = "SUPPLY_1.2V"; + regulator-min-microvolt = <1200000>; + regulator-max-microvolt = <1200000>; + regulator-min-microamp = <200000>; + regulator-max-microamp = <200000>; + regulator-always-on; + }; + + buck2 { + regulator-name = "SUPPLY_3.3V"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + }; + + ldo1 { + regulator-name = "VDD_EMMC_1.8V"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-min-microamp = <100000>; + regulator-max-microamp = <100000>; + regulator-boot-on; + }; + + ldo2 { + regulator-name = "VDD_LCD_3.3V"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + }; + }; }; pci: pci-controller {
Signature · 1 line
1.9.1
PATCH 10/12 test: dm: dts: add sandbox pmic i2c node
Quoted 12 lines · Przemyslaw Marczak
This commit adds sandbox PMIC subnode to sandbox i2c bus 0.
The PMIC's node includes:
- 2x BUCK
- 2x LDOEach regulator node include proper constraints:
- min, max micro Volts
- min, max micro Amps (only first of each type)
- always on (BUCK1)
- boot on (LDO1)
Quoted 4 lines
Signed-off-by Przemyslaw Marczak <[email protected]>--- test/dm/test.dts | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+)
Tested on sandbox:
PATCH 11/12 sandbox: defconfig: enable support of sandbox PMIC drivers
In reply to Przemyslaw MarczakThis commit enables:
- emulated i2c PMIC driver
- sandbox PMIC I/O driver
- sandbox PMIC's regulator driver
--- configs/sandbox_defconfig | 7 +++++++ 1 file changed, 7 insertions(+)
configs/sandbox_defconfig +7 -0
@@ -26,3 +26,10 @@ CONFIG_TPM_TIS_SANDBOX=y CONFIG_SOUND=y CONFIG_CMD_SOUND=y CONFIG_SOUND_SANDBOX=y +CONFIG_ERRNO_STR=y +CONFIG_DM_PMIC=y +CONFIG_DM_PMIC_SANDBOX=y +CONFIG_CMD_PMIC=y +CONFIG_DM_REGULATOR=y +CONFIG_DM_REGULATOR_SANDBOX=y +CONFIG_CMD_REGULATOR=y
Signature · 1 line
1.9.1
PATCH 11/12 sandbox: defconfig: enable support of sandbox PMIC drivers
Quoted 9 lines · Przemyslaw Marczak
This commit enables:
- emulated i2c PMIC driver
- sandbox PMIC I/O driver
- sandbox PMIC's regulator driverSigned-off-by Przemyslaw Marczak <[email protected]>--- configs/sandbox_defconfig | 7 +++++++ 1 file changed, 7 insertions(+)
Tested on sandbox:
PATCH 12/12 test: dm: add sandbox PMIC framework tests
In reply to Przemyslaw MarczakThis change adds new file to sandbox driver model test environment. The file is: test/dm/power.c, and it includes tests for PMIC framework, which includes PMIC uclass and REGULATOR uclass.
All tests are based od Sandbox PMIC emulated device. Some test constants for this device are defined in the header: include/power/sandbox_pmic.h
PMIC tests includes:
- pmic get - tests, that pmic_get() returns the requested device
- pmic I/O - tests I/O by writing and reading some values to PMIC's registers and then compares, that the write/read values are equal.
The regulator tests includes:
- Regulator get by devname/platname
- Voltage set/get
- Current set/get
- Enable set/get
- Mode set/get
- Autoset
- List autoset
For the regulator 'get' test, the returned device pointers are compared, and their names are also compared to the requested one. Every other test, first sets the given attribute and next try to get it. The test pass, when the set/get values are equal.
--- include/power/sandbox_pmic.h | 33 ++++ test/dm/Makefile | 2 + test/dm/power.c | 371 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 406 insertions(+) create mode 100644 test/dm/power.c
include/power/sandbox_pmic.h +33 -0
@@ -186,4 +186,37 @@ enum {#define LDO2_UV_REG_DEFAULT LDO2_UV_TO_REG(OUT_LDO2_UV_DEFAULT)#define LDO2_OM_REG_DEFAULT OUT_OM_SET(OUT_LDO2_OM_DEFAULT) +/* Test data for: test/dm/power.c */ + +/* BUCK names */ +#define SANDBOX_BUCK1_DEVNAME "buck1" +#define SANDBOX_BUCK1_PLATNAME "SUPPLY_1.2V" +#define SANDBOX_BUCK2_DEVNAME "buck2" +#define SANDBOX_BUCK2_PLATNAME "SUPPLY_3.3V" +/* LDO names */ +#define SANDBOX_LDO1_DEVNAME "ldo1" +#define SANDBOX_LDO1_PLATNAME "VDD_EMMC_1.8V" +#define SANDBOX_LDO2_DEVNAME "ldo2" +#define SANDBOX_LDO2_PLATNAME "VDD_LCD_3.3V" + +/* +* Expected regulators setup after call of: +* - regulator_autoset() +* - regulator_list_autoset() +*/ + +/* BUCK1: for testing regulator_autoset() */ +#define SANDBOX_BUCK1_AUTOSET_EXPECTED_UV 1200000 +#define SANDBOX_BUCK1_AUTOSET_EXPECTED_UA 200000 +#define SANDBOX_BUCK1_AUTOSET_EXPECTED_ENABLE true + +/* LDO1/2 for testing regulator_list_autoset() */ +#define SANDBOX_LDO1_AUTOSET_EXPECTED_UV 1800000 +#define SANDBOX_LDO1_AUTOSET_EXPECTED_UA 100000 +#define SANDBOX_LDO1_AUTOSET_EXPECTED_ENABLE true + +#define SANDBOX_LDO2_AUTOSET_EXPECTED_UV OUT_LDO2_UV_DEFAULT +#define SANDBOX_LDO2_AUTOSET_EXPECTED_UA -ENOSYS +#define SANDBOX_LDO2_AUTOSET_EXPECTED_ENABLE false +#endif
test/dm/Makefile +2 -0
@@ -24,4 +24,6 @@ obj-$(CONFIG_DM_PCI) += pci.o obj-$(CONFIG_DM_SPI_FLASH) += sf.o obj-$(CONFIG_DM_SPI) += spi.o obj-$(CONFIG_DM_USB) += usb.o +obj-$(CONFIG_DM_PMIC) += power.o +obj-$(CONFIG_DM_REGULATOR) += power.o endif
test/dm/power.c new file +371 -0
371 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH 12/12 test: dm: add sandbox PMIC framework tests
Hi Przemyslaw,
Quoted 26 lines · Przemyslaw Marczak
This change adds new file to sandbox driver model test environment. The file is:
test/dm/power.c, and it includes tests for PMIC framework, which includes PMIC uclass and REGULATOR uclass.All tests are based od Sandbox PMIC emulated device. Some test constants for this device are defined in the header:
include/power/sandbox_pmic.hPMIC tests includes:
- pmic get - tests, thatpmic_get()returns the requested device
- pmic I/O - tests I/O by writing and reading some values to PMIC's registers and then compares, that the write/read values are equal.The regulator tests includes:
- Regulator get by devname/platname
- Voltage set/get
- Current set/get
- Enable set/get
- Mode set/get
- Autoset
- List autosetFor the regulator 'get' test, the returned device pointers are compared, and their names are also compared to the requested one. Every other test, first sets the given attribute and next try to get it. The test pass, when the set/get values are equal.
Quoted 7 lines
Signed-off-by Przemyslaw Marczak <[email protected]>--- include/power/sandbox_pmic.h | 33 ++++ test/dm/Makefile | 2 + test/dm/power.c | 371 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 406 insertions(+) create mode 100644 test/dm/power.c
This looks great. I just have some minor nits below.
Quoted 77 lines
include/power/sandbox_pmic.h +33
-0@@ -186,4 +186,37 @@ enum {#define LDO2_UV_REG_DEFAULT LDO2_UV_TO_REG(OUT_LDO2_UV_DEFAULT)#define LDO2_OM_REG_DEFAULT OUT_OM_SET(OUT_LDO2_OM_DEFAULT) +/* Test data for: test/dm/power.c */ + +/* BUCK names */ +#define SANDBOX_BUCK1_DEVNAME "buck1" +#define SANDBOX_BUCK1_PLATNAME "SUPPLY_1.2V" +#define SANDBOX_BUCK2_DEVNAME "buck2" +#define SANDBOX_BUCK2_PLATNAME "SUPPLY_3.3V" +/* LDO names */ +#define SANDBOX_LDO1_DEVNAME "ldo1" +#define SANDBOX_LDO1_PLATNAME "VDD_EMMC_1.8V" +#define SANDBOX_LDO2_DEVNAME "ldo2" +#define SANDBOX_LDO2_PLATNAME "VDD_LCD_3.3V" + +/* +* Expected regulators setup after call of: +* - regulator_autoset() +* - regulator_list_autoset() +*/ + +/* BUCK1: for testing regulator_autoset() */ +#define SANDBOX_BUCK1_AUTOSET_EXPECTED_UV 1200000 +#define SANDBOX_BUCK1_AUTOSET_EXPECTED_UA 200000 +#define SANDBOX_BUCK1_AUTOSET_EXPECTED_ENABLE true + +/* LDO1/2 for testing regulator_list_autoset() */ +#define SANDBOX_LDO1_AUTOSET_EXPECTED_UV 1800000 +#define SANDBOX_LDO1_AUTOSET_EXPECTED_UA 100000 +#define SANDBOX_LDO1_AUTOSET_EXPECTED_ENABLE true + +#define SANDBOX_LDO2_AUTOSET_EXPECTED_UV OUT_LDO2_UV_DEFAULT +#define SANDBOX_LDO2_AUTOSET_EXPECTED_UA -ENOSYS +#define SANDBOX_LDO2_AUTOSET_EXPECTED_ENABLE false +#endif test/dm/Makefile +2
-0@@ -24,4 +24,6 @@ obj-$(CONFIG_DM_PCI) += pci.o obj-$(CONFIG_DM_SPI_FLASH) += sf.o obj-$(CONFIG_DM_SPI) += spi.o obj-$(CONFIG_DM_USB) += usb.o +obj-$(CONFIG_DM_PMIC) += power.o +obj-$(CONFIG_DM_REGULATOR) += power.o endiftest/dm/power.c new file +17
-0@@ -0,0 +1,371 @@ +/* +* Tests for the driver model pmic and regulator code +* +* Copyright (c) 2015 Samsung Electronics +* Przemyslaw Marczak <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#include <common.h> +#include <errno.h> +#include <dm.h> +#include <fdtdec.h> +#include <malloc.h> +#include <dm/device-internal.h> +#include <dm/root.h> +#include <dm/ut.h>
test/dm/power.c line 27
Quoted 10 lines
test/dm/power.c new file +10
-0+#include <dm/util.h> +#include <dm/test.h> +#include <dm/uclass-internal.h> +#include <power/pmic.h> +#include <power/regulator.h> +#include <power/sandbox_pmic.h> + +DECLARE_GLOBAL_DATA_PTR ; + +#ifdef CONFIG_DM_PMIC
How about creating pmic.c and then you can move the ifdef to the Makefile?
Quoted 37 lines
test/dm/power.c new file +37
-0+/* Test PMIC get method */ +static int dm_test_power_pmic_get (struct dm_test_state *dms) +{ +const char *name ="sandbox_pmic" ; +struct udevice *dev; + +ut_assertok (pmic_get (name, &dev)); +ut_assertnonnull (dev); + +/* Check PMIC's name */ +ut_asserteq_str (name, dev->name); + +return 0 ; +} +DM_TEST (dm_test_power_pmic_get,DM_TESTF_SCAN_FDT ); + +/* Test PMIC I/O */ +static int dm_test_power_pmic_io (struct dm_test_state *dms) +{ +const char *name ="sandbox_pmic" ; +uint8_t out_buffer, in_buffer; +struct udevice *dev; +int reg_count, i; + +ut_assertok (pmic_get (name, &dev)); + + reg_count =pmic_reg_count (dev); +ut_asserteq (reg_count,SANDBOX_PMIC_REG_COUNT ); + +/* +* Test PMIC I/O - write and read a loop counter. +* usually we can't write to all PMIC's registers in the real hardware, +* but we can to the sandbox pmic. +*/ +for (i =0 ; i < reg_count; i++) { + out_buffer = i; +ut_assertok (pmic_write (dev, i, &out_buffer,1 ));
test/dm/power.c line 74
Quoted 10 lines
test/dm/power.c new file +10
-0+ut_assertok (pmic_read (dev, i, &in_buffer,1 )); + ut_asserteq(out_buffer, in_buffer); + } + +return 0 ; +} +DM_TEST (dm_test_power_pmic_io,DM_TESTF_SCAN_FDT ); +#endif /* CONFIG_DM_PMIC */ + +#ifdef CONFIG_DM_REGULATOR
This could go in regulator.c
Quoted 69 lines
test/dm/power.c new file +69
-0+enum { +BUCK1 , +BUCK2 , +LDO1 , +LDO2 , +OUTPUT_COUNT , +}; + +enum { +DEVNAME =0 , +PLATNAME , +OUTPUT_NAME_COUNT , +}; + +static const char *regulator_names[OUTPUT_COUNT ][OUTPUT_NAME_COUNT ] = { +/* devname, platname */ + {SANDBOX_BUCK1_DEVNAME ,SANDBOX_BUCK1_PLATNAME }, + {SANDBOX_BUCK2_DEVNAME ,SANDBOX_BUCK2_PLATNAME }, + {SANDBOX_LDO1_DEVNAME ,SANDBOX_LDO1_PLATNAME }, + {SANDBOX_LDO2_DEVNAME ,SANDBOX_LDO2_PLATNAME }, +}; + +/* Test regulator get method */ +static int dm_test_power_regulator_get (struct dm_test_state *dms) +{ +struct dm_regulator_uclass_platdata *uc_pdata; +struct udevice *dev_by_devname; +struct udevice *dev_by_platname; +const char *devname; +const char *platname; +int i; + +for (i =0 ; i <OUTPUT_COUNT ; i++) { +/* +* Do the test for each regulator's devname and platname, +* which are related to a single device. +*/ + devname = regulator_names[i][DEVNAME ]; + platname = regulator_names[i][PLATNAME ]; + +/* +* Check, that regulator_get_by_devname() function, returns +* a device with the name equal to the requested one. +*/ +ut_assertok (regulator_get_by_devname (devname, &dev_by_devname)); +ut_asserteq_str (devname, dev_by_devname->name); + +/* +* Check, that regulator_get_by_platname() function, returns +* a device with the name equal to the requested one. +*/ +ut_assertok (regulator_get_by_platname (platname, &dev_by_platname)); +ut_assert (uc_pdata =dev_get_uclass_platdata (dev_by_platname)); +ut_asserteq_str (platname, uc_pdata->name); + +/* +* Check, that the pointers returned by both get functions, +* points to the same regulator device. +*/ +ut_asserteq_ptr (dev_by_devname, dev_by_platname); + } + +return 0 ; +} +DM_TEST (dm_test_power_regulator_get,DM_TESTF_SCAN_FDT ); + +/* Test regulator set and get Voltage method */ +static int dm_test_power_regulator_set_get_voltage (struct dm_test_state *dms) +{
test/dm/power.c line 153
Quoted 10 lines
test/dm/power.c new file +10
-0+struct dm_regulator_uclass_platdata *uc_pdata; +struct udevice *dev; +const char *platname; +int val_set, val_get; + +/* Set and get Voltage of BUCK1 - set to 'min' constraint */ + platname = regulator_names[BUCK1 ][PLATNAME ]; +ut_assertok (regulator_get_by_platname (platname, &dev)); + +ut_assert (uc_pdata =dev_get_uclass_platdata (dev));
uc_pdata = dev_get_uclass_platdata(dev)ut_assert(uc_pdata)
and below
Quoted 31 lines
test/dm/power.c new file +31
-0+ + val_set = uc_pdata->min_uV; +ut_assertok (regulator_set_value (dev, val_set)); + + val_get =regulator_get_value (dev); +ut_assert (val_get >=0 ); + +ut_asserteq (val_set, val_get); + +return 0 ; +} +DM_TEST (dm_test_power_regulator_set_get_voltage,DM_TESTF_SCAN_FDT ); + +/* Test regulator set and get Current method */ +static int dm_test_power_regulator_set_get_current (struct dm_test_state *dms) +{ +struct dm_regulator_uclass_platdata *uc_pdata; +struct udevice *dev; +const char *platname; +int val_set, val_get; + +/* Set and get the Current of LDO1 - set to 'min' constraint */ + platname = regulator_names[LDO1 ][PLATNAME ]; +ut_assertok (regulator_get_by_platname (platname, &dev)); + +ut_assert (uc_pdata =dev_get_uclass_platdata (dev)); + + val_set = uc_pdata->min_uA; +ut_assertok (regulator_set_current (dev, val_set)); + + val_get =regulator_get_current (dev);
test/dm/power.c line 194
Quoted 10 lines
test/dm/power.c new file +10
-0+ut_assert (val_get >=0 ); + +ut_asserteq (val_set, val_get); + +/* Check LDO2 current limit constraints - should be -ENODATA */ + platname = regulator_names[LDO2 ][PLATNAME ]; +ut_assertok (regulator_get_by_platname (platname, &dev)); + +ut_assert (uc_pdata =dev_get_uclass_platdata (dev)); +ut_asserteq (uc_pdata->min_uA, -ENODATA );
Expected value should come first.
test/dm/power.c line 198
Quoted 4 lines
test/dm/power.c new file +4
-0+ut_asserteq (uc_pdata->max_uA, -ENODATA ); + +/* Try set the Current of LDO2 - should return -ENOSYS */ +ut_asserteq (regulator_set_current (dev,0 ), -ENOSYS );
Nice test
Quoted 57 lines
test/dm/power.c new file +57
-0+ +return 0 ; +} +DM_TEST (dm_test_power_regulator_set_get_current,DM_TESTF_SCAN_FDT ); + +/* Test regulator set and get Enable method */ +static int dm_test_power_regulator_set_get_enable (struct dm_test_state *dms) +{ +const char *platname; +struct udevice *dev; +bool val_set = true; + +/* Set the Enable of LDO1 - default is disabled */ + platname = regulator_names[LDO1 ][PLATNAME ]; +ut_assertok (regulator_get_by_platname (platname, &dev)); +ut_assertok (regulator_set_enable (dev, val_set)); + +/* Get the Enable state of LDO1 and compare it with the requested one */ +ut_asserteq (regulator_get_enable (dev), val_set); + +return 0 ; +} +DM_TEST (dm_test_power_regulator_set_get_enable,DM_TESTF_SCAN_FDT ); + +/* Test regulator set and get mode method */ +static int dm_test_power_regulator_set_get_mode (struct dm_test_state *dms) +{ +const char *platname; +struct udevice *dev; +int val_set =LDO_OM_SLEEP ; + +/* Set the mode id to LDO_OM_SLEEP of LDO1 - default is LDO_OM_OFF */ + platname = regulator_names[LDO1 ][PLATNAME ]; +ut_assertok (regulator_get_by_platname (platname, &dev)); +ut_assertok (regulator_set_mode (dev, val_set)); + +/* Get the mode id of LDO1 and compare it with the requested one */ +ut_asserteq (regulator_get_mode (dev), val_set); + +return 0 ; +} +DM_TEST (dm_test_power_regulator_set_get_mode,DM_TESTF_SCAN_FDT ); + +/* Test regulator autoset method */ +static int dm_test_power_regulator_autoset (struct dm_test_state *dms) +{ +const char *platname; +struct udevice *dev, *dev_autoset; + +/* +* Test the BUCK1 with fdt properties +* - min-microvolt = max-microvolt = 1200000 +* - min-microamp = max-microamp = 200000 +* - always-on = set +* - boot-on = not set +* Expected output state: uV=1200000; uA=200000; output enabled +*/
test/dm/power.c line 265
Quoted 10 lines
test/dm/power.c new file +10
-0+ platname = regulator_names[BUCK1 ][PLATNAME ]; +ut_assertok (regulator_autoset (platname, &dev_autoset, false)); + +/* Check, that the returned device is proper */ +ut_assertok (regulator_get_by_platname (platname, &dev)); +ut_asserteq_ptr (dev, dev_autoset); + +/* Check the setup after autoset */ +ut_asserteq (regulator_get_value (dev), +SANDBOX_BUCK1_AUTOSET_EXPECTED_UV );
Expected value should come first.
Quoted 81 lines
test/dm/power.c new file +81
-0+ut_asserteq (regulator_get_current (dev), +SANDBOX_BUCK1_AUTOSET_EXPECTED_UA ); +ut_asserteq (regulator_get_enable (dev), +SANDBOX_BUCK1_AUTOSET_EXPECTED_ENABLE ); + +return 0 ; +} +DM_TEST (dm_test_power_regulator_autoset,DM_TESTF_SCAN_FDT ); + +/* +* Struct setting: to keep the expected output settings. +* @voltage: Voltage value [uV] +* @current: Current value [uA] +* @enable: output enable state: true/false +*/ +struct setting { +int voltage; +int current; +bool enable; +}; + +/* +* platname_list: an array of regulator platform names. +* For testing regulator_list_autoset() for outputs: +* - LDO1 +* - LDO2 +*/ +static const char *platname_list[] = { +SANDBOX_LDO1_PLATNAME , +SANDBOX_LDO2_PLATNAME , +NULL , +}; + +/* +* expected_setting_list: an array of regulator output setting, expected after +* call of the regulator_list_autoset() for the "platname_list" array. +* For testing results of regulator_list_autoset() for outputs: +* - LDO1 +* - LDO2 +* The settings are defined in: include/power/sandbox_pmic.h +*/ +static const struct setting expected_setting_list[] = { + [0 ] = {/* LDO1 */ + .voltage =SANDBOX_LDO1_AUTOSET_EXPECTED_UV , + .current =SANDBOX_LDO1_AUTOSET_EXPECTED_UA , + .enable =SANDBOX_LDO1_AUTOSET_EXPECTED_ENABLE , + }, + [1 ] = {/* LDO2 */ + .voltage =SANDBOX_LDO2_AUTOSET_EXPECTED_UV , + .current =SANDBOX_LDO2_AUTOSET_EXPECTED_UA , + .enable =SANDBOX_LDO2_AUTOSET_EXPECTED_ENABLE , + }, +}; + +static int list_count =ARRAY_SIZE (expected_setting_list); + +/* Test regulator list autoset method */ +static int dm_test_power_regulator_autoset_list (struct dm_test_state *dms) +{ +struct udevice *dev_list[2 ], *dev; +int i; + +/* +* Test the settings of the regulator list: +* LDO1 with fdt properties: +* - min-microvolt = max-microvolt = 1800000 +* - min-microamp = max-microamp = 100000 +* - always-on = not set +* - boot-on = set +* Expected output state: uV=1800000; uA=100000; output enabled +* +* LDO2 with fdt properties: +* - min-microvolt = max-microvolt = 3300000 +* - always-on = not set +* - boot-on = not set +* Expected output state: uV=300000(default); output disabled(default) +* The expected settings are defined in: include/power/sandbox_pmic.h. +*/ +ut_assertok (regulator_list_autoset (platname_list, dev_list, false)); + +for (i =0 ; i < list_count; i++) {
test/dm/power.c line 356
Quoted 10 lines
test/dm/power.c new file +10
-0+/* Check, that the returned device is non-NULL */ +ut_assert (dev_list[i]); + +/* Check, that the returned device is proper */ +ut_assertok (regulator_get_by_platname (platname_list[i], &dev)); +ut_asserteq_ptr (dev_list[i], dev); + +/* Check, that regulator output Voltage value is as expected */ +ut_asserteq (regulator_get_value (dev_list[i]), + expected_setting_list[i].voltage);
Expected value should come first.
Quoted 16 lines
test/dm/power.c new file +15
-1+ +/* Check, that regulator output Current value is as expected */ +ut_asserteq (regulator_get_current (dev_list[i]), + expected_setting_list[i].current); + +/* Check, that regulator output Enable state is as expected */ +ut_asserteq (regulator_get_enable (dev_list[i]), + expected_setting_list[i].enable); + } + +return 0 ; +} +DM_TEST (dm_test_power_regulator_autoset_list,DM_TESTF_SCAN_FDT ); + +#endif /* CONFIG_DM_REGULATOR */ --
Quoted 2 lines
1.9.1
Regards,
Simon
PATCH 12/12 test: dm: add sandbox PMIC framework tests
Hello Simon,
Quoted 37 lines · Simon Glass
Hi Przemyslaw,
Quoted 26 lines · Przemyslaw Marczak
This change adds new file to sandbox driver model test environment. The file is:
test/dm/power.c, and it includes tests for PMIC framework, which includes PMIC uclass and REGULATOR uclass.All tests are based od Sandbox PMIC emulated device. Some test constants for this device are defined in the header:
include/power/sandbox_pmic.hPMIC tests includes:
- pmic get - tests, thatpmic_get()returns the requested device
- pmic I/O - tests I/O by writing and reading some values to PMIC's registers and then compares, that the write/read values are equal.The regulator tests includes:
- Regulator get by devname/platname
- Voltage set/get
- Current set/get
- Enable set/get
- Mode set/get
- Autoset
- List autosetFor the regulator 'get' test, the returned device pointers are compared, and their names are also compared to the requested one. Every other test, first sets the given attribute and next try to get it. The test pass, when the set/get values are equal.
Quoted 7 lines
Signed-off-by Przemyslaw Marczak <[email protected]>--- include/power/sandbox_pmic.h | 33 ++++ test/dm/Makefile | 2 + test/dm/power.c | 371 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 406 insertions(+)create mode 100644
test/dm/power.c
Quoted 2 lines
This looks great. I just have some minor nits below.
Thanks, that's a good information.
Quoted 81 lines
Quoted 81 lines
include/power/sandbox_pmic.h +33
-0@@ -186,4 +186,37 @@ enum {#define LDO2_UV_REG_DEFAULT LDO2_UV_TO_REG(OUT_LDO2_UV_DEFAULT)#define LDO2_OM_REG_DEFAULT OUT_OM_SET(OUT_LDO2_OM_DEFAULT) +/* Test data for: test/dm/power.c */ + +/* BUCK names */ +#define SANDBOX_BUCK1_DEVNAME "buck1" +#define SANDBOX_BUCK1_PLATNAME "SUPPLY_1.2V" +#define SANDBOX_BUCK2_DEVNAME "buck2" +#define SANDBOX_BUCK2_PLATNAME "SUPPLY_3.3V" +/* LDO names */ +#define SANDBOX_LDO1_DEVNAME "ldo1" +#define SANDBOX_LDO1_PLATNAME "VDD_EMMC_1.8V" +#define SANDBOX_LDO2_DEVNAME "ldo2" +#define SANDBOX_LDO2_PLATNAME "VDD_LCD_3.3V" + +/* +* Expected regulators setup after call of: +* - regulator_autoset() +* - regulator_list_autoset() +*/ + +/* BUCK1: for testing regulator_autoset() */ +#define SANDBOX_BUCK1_AUTOSET_EXPECTED_UV 1200000 +#define SANDBOX_BUCK1_AUTOSET_EXPECTED_UA 200000 +#define SANDBOX_BUCK1_AUTOSET_EXPECTED_ENABLE true + +/* LDO1/2 for testing regulator_list_autoset() */ +#define SANDBOX_LDO1_AUTOSET_EXPECTED_UV 1800000 +#define SANDBOX_LDO1_AUTOSET_EXPECTED_UA 100000 +#define SANDBOX_LDO1_AUTOSET_EXPECTED_ENABLE true + +#define SANDBOX_LDO2_AUTOSET_EXPECTED_UV OUT_LDO2_UV_DEFAULT +#define SANDBOX_LDO2_AUTOSET_EXPECTED_UA -ENOSYS +#define SANDBOX_LDO2_AUTOSET_EXPECTED_ENABLE false +#endif test/dm/Makefile +2
-0@@ -24,4 +24,6 @@ obj-$(CONFIG_DM_PCI) += pci.o obj-$(CONFIG_DM_SPI_FLASH) += sf.o obj-$(CONFIG_DM_SPI) += spi.o obj-$(CONFIG_DM_USB) += usb.o +obj-$(CONFIG_DM_PMIC) += power.o +obj-$(CONFIG_DM_REGULATOR) += power.o endiftest/dm/power.c new file +21
-0@@ -0,0 +1,371 @@ +/* +* Tests for the driver model pmic and regulator code +* +* Copyright (c) 2015 Samsung Electronics +* Przemyslaw Marczak <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#include <common.h> +#include <errno.h> +#include <dm.h> +#include <fdtdec.h> +#include <malloc.h> +#include <dm/device-internal.h> +#include <dm/root.h> +#include <dm/ut.h> +#include <dm/util.h> +#include <dm/test.h> +#include <dm/uclass-internal.h> +#include <power/pmic.h>
Quoted 9 lines
test/dm/power.c line 27
Quoted 6 lines
test/dm/power.c new file +6
-0+#include <power/regulator.h> +#include <power/sandbox_pmic.h> + +DECLARE_GLOBAL_DATA_PTR ; + +#ifdef CONFIG_DM_PMIC How about creating
pmic.cand then you can move the ifdef to theMakefile?
Ok, I can add this.
Quoted 41 lines
Quoted 41 lines
test/dm/power.c new file +41
-0+/* Test PMIC get method */ +static int dm_test_power_pmic_get (struct dm_test_state *dms) +{ +const char *name ="sandbox_pmic" ; +struct udevice *dev; + +ut_assertok (pmic_get (name, &dev)); +ut_assertnonnull (dev); + +/* Check PMIC's name */ +ut_asserteq_str (name, dev->name); + +return 0 ; +} +DM_TEST (dm_test_power_pmic_get,DM_TESTF_SCAN_FDT ); + +/* Test PMIC I/O */ +static int dm_test_power_pmic_io (struct dm_test_state *dms) +{ +const char *name ="sandbox_pmic" ; +uint8_t out_buffer, in_buffer; +struct udevice *dev; +int reg_count, i; + +ut_assertok (pmic_get (name, &dev)); + + reg_count =pmic_reg_count (dev); +ut_asserteq (reg_count,SANDBOX_PMIC_REG_COUNT ); + +/* +* Test PMIC I/O - write and read a loop counter. +* usually we can't write to all PMIC's registers in the real hardware, +* but we can to the sandbox pmic. +*/ +for (i =0 ; i < reg_count; i++) { + out_buffer = i; +ut_assertok (pmic_write (dev, i, &out_buffer,1 )); +ut_assertok (pmic_read (dev, i, &in_buffer,1 )); +ut_asserteq (out_buffer, in_buffer); + } +
Quoted 9 lines
test/dm/power.c line 74
Quoted 6 lines
test/dm/power.c new file +6
-0+ return 0; +} +DM_TEST (dm_test_power_pmic_io,DM_TESTF_SCAN_FDT ); +#endif /* CONFIG_DM_PMIC */ + +#ifdef CONFIG_DM_REGULATOR This could go in
regulator.c
Yes.
Quoted 83 lines
Quoted 69 lines
test/dm/power.c new file +69
-0+enum { +BUCK1 , +BUCK2 , +LDO1 , +LDO2 , +OUTPUT_COUNT , +}; + +enum { +DEVNAME =0 , +PLATNAME , +OUTPUT_NAME_COUNT , +}; + +static const char *regulator_names[OUTPUT_COUNT ][OUTPUT_NAME_COUNT ] = { +/* devname, platname */ + {SANDBOX_BUCK1_DEVNAME ,SANDBOX_BUCK1_PLATNAME }, + {SANDBOX_BUCK2_DEVNAME ,SANDBOX_BUCK2_PLATNAME }, + {SANDBOX_LDO1_DEVNAME ,SANDBOX_LDO1_PLATNAME }, + {SANDBOX_LDO2_DEVNAME ,SANDBOX_LDO2_PLATNAME }, +}; + +/* Test regulator get method */ +static int dm_test_power_regulator_get (struct dm_test_state *dms) +{ +struct dm_regulator_uclass_platdata *uc_pdata; +struct udevice *dev_by_devname; +struct udevice *dev_by_platname; +const char *devname; +const char *platname; +int i; + +for (i =0 ; i <OUTPUT_COUNT ; i++) { +/* +* Do the test for each regulator's devname and platname, +* which are related to a single device. +*/ + devname = regulator_names[i][DEVNAME ]; + platname = regulator_names[i][PLATNAME ]; + +/* +* Check, that regulator_get_by_devname() function, returns +* a device with the name equal to the requested one. +*/ +ut_assertok (regulator_get_by_devname (devname, &dev_by_devname)); +ut_asserteq_str (devname, dev_by_devname->name); + +/* +* Check, that regulator_get_by_platname() function, returns +* a device with the name equal to the requested one. +*/ +ut_assertok (regulator_get_by_platname (platname, &dev_by_platname)); +ut_assert (uc_pdata =dev_get_uclass_platdata (dev_by_platname)); +ut_asserteq_str (platname, uc_pdata->name); + +/* +* Check, that the pointers returned by both get functions, +* points to the same regulator device. +*/ +ut_asserteq_ptr (dev_by_devname, dev_by_platname); + } + +return 0 ; +} +DM_TEST (dm_test_power_regulator_get,DM_TESTF_SCAN_FDT ); + +/* Test regulator set and get Voltage method */ +static int dm_test_power_regulator_set_get_voltage (struct dm_test_state *dms) +{test/dm/power.c line 153
Quoted 10 lines
test/dm/power.c new file +10
-0+struct dm_regulator_uclass_platdata *uc_pdata; +struct udevice *dev; +const char *platname; +int val_set, val_get; + +/* Set and get Voltage of BUCK1 - set to 'min' constraint */ + platname = regulator_names[BUCK1 ][PLATNAME ]; +ut_assertok (regulator_get_by_platname (platname, &dev)); + +ut_assert (uc_pdata =dev_get_uclass_platdata (dev));
uc_pdata=dev_get_uclass_platdata(dev)ut_assert(uc_pdata)
Quoted 2 lines
and below
Ok.
Quoted 35 lines
Quoted 35 lines
test/dm/power.c new file +35
-0+ + val_set = uc_pdata->min_uV; +ut_assertok (regulator_set_value (dev, val_set)); + + val_get =regulator_get_value (dev); +ut_assert (val_get >=0 ); + +ut_asserteq (val_set, val_get); + +return 0 ; +} +DM_TEST (dm_test_power_regulator_set_get_voltage,DM_TESTF_SCAN_FDT ); + +/* Test regulator set and get Current method */ +static int dm_test_power_regulator_set_get_current (struct dm_test_state *dms) +{ +struct dm_regulator_uclass_platdata *uc_pdata; +struct udevice *dev; +const char *platname; +int val_set, val_get; + +/* Set and get the Current of LDO1 - set to 'min' constraint */ + platname = regulator_names[LDO1 ][PLATNAME ]; +ut_assertok (regulator_get_by_platname (platname, &dev)); + +ut_assert (uc_pdata =dev_get_uclass_platdata (dev)); + + val_set = uc_pdata->min_uA; +ut_assertok (regulator_set_current (dev, val_set)); + + val_get =regulator_get_current (dev); +ut_assert (val_get >=0 ); + +ut_asserteq (val_set, val_get); +
Quoted 9 lines
test/dm/power.c line 194
Quoted 6 lines
test/dm/power.c new file +6
-0+/* Check LDO2 current limit constraints - should be -ENODATA */ + platname = regulator_names[LDO2 ][PLATNAME ]; +ut_assertok (regulator_get_by_platname (platname, &dev)); + +ut_assert (uc_pdata =dev_get_uclass_platdata (dev)); +ut_asserteq (uc_pdata->min_uA, -ENODATA );Expected value should come first.
Ok
Quoted 162 lines
test/dm/power.c line 198
Quoted 4 lines
test/dm/power.c new file +4
-0+ut_asserteq (uc_pdata->max_uA, -ENODATA ); + +/* Try set the Current of LDO2 - should return -ENOSYS */ +ut_asserteq (regulator_set_current (dev,0 ), -ENOSYS );Nice test
Quoted 57 lines
test/dm/power.c new file +57
-0+ +return 0 ; +} +DM_TEST (dm_test_power_regulator_set_get_current,DM_TESTF_SCAN_FDT ); + +/* Test regulator set and get Enable method */ +static int dm_test_power_regulator_set_get_enable (struct dm_test_state *dms) +{ +const char *platname; +struct udevice *dev; +bool val_set = true; + +/* Set the Enable of LDO1 - default is disabled */ + platname = regulator_names[LDO1 ][PLATNAME ]; +ut_assertok (regulator_get_by_platname (platname, &dev)); +ut_assertok (regulator_set_enable (dev, val_set)); + +/* Get the Enable state of LDO1 and compare it with the requested one */ +ut_asserteq (regulator_get_enable (dev), val_set); + +return 0 ; +} +DM_TEST (dm_test_power_regulator_set_get_enable,DM_TESTF_SCAN_FDT ); + +/* Test regulator set and get mode method */ +static int dm_test_power_regulator_set_get_mode (struct dm_test_state *dms) +{ +const char *platname; +struct udevice *dev; +int val_set =LDO_OM_SLEEP ; + +/* Set the mode id to LDO_OM_SLEEP of LDO1 - default is LDO_OM_OFF */ + platname = regulator_names[LDO1 ][PLATNAME ]; +ut_assertok (regulator_get_by_platname (platname, &dev)); +ut_assertok (regulator_set_mode (dev, val_set)); + +/* Get the mode id of LDO1 and compare it with the requested one */ +ut_asserteq (regulator_get_mode (dev), val_set); + +return 0 ; +} +DM_TEST (dm_test_power_regulator_set_get_mode,DM_TESTF_SCAN_FDT ); + +/* Test regulator autoset method */ +static int dm_test_power_regulator_autoset (struct dm_test_state *dms) +{ +const char *platname; +struct udevice *dev, *dev_autoset; + +/* +* Test the BUCK1 with fdt properties +* - min-microvolt = max-microvolt = 1200000 +* - min-microamp = max-microamp = 200000 +* - always-on = set +* - boot-on = not set +* Expected output state: uV=1200000; uA=200000; output enabled +*/ test/dm/power.c line 265
Quoted 10 lines
test/dm/power.c new file +10
-0+ platname = regulator_names[BUCK1 ][PLATNAME ]; +ut_assertok (regulator_autoset (platname, &dev_autoset, false)); + +/* Check, that the returned device is proper */ +ut_assertok (regulator_get_by_platname (platname, &dev)); +ut_asserteq_ptr (dev, dev_autoset); + +/* Check the setup after autoset */ +ut_asserteq (regulator_get_value (dev), +SANDBOX_BUCK1_AUTOSET_EXPECTED_UV );Expected value should come first.
Quoted 85 lines
test/dm/power.c new file +85
-0+ut_asserteq (regulator_get_current (dev), +SANDBOX_BUCK1_AUTOSET_EXPECTED_UA ); +ut_asserteq (regulator_get_enable (dev), +SANDBOX_BUCK1_AUTOSET_EXPECTED_ENABLE ); + +return 0 ; +} +DM_TEST (dm_test_power_regulator_autoset,DM_TESTF_SCAN_FDT ); + +/* +* Struct setting: to keep the expected output settings. +* @voltage: Voltage value [uV] +* @current: Current value [uA] +* @enable: output enable state: true/false +*/ +struct setting { +int voltage; +int current; +bool enable; +}; + +/* +* platname_list: an array of regulator platform names. +* For testing regulator_list_autoset() for outputs: +* - LDO1 +* - LDO2 +*/ +static const char *platname_list[] = { +SANDBOX_LDO1_PLATNAME , +SANDBOX_LDO2_PLATNAME , +NULL , +}; + +/* +* expected_setting_list: an array of regulator output setting, expected after +* call of the regulator_list_autoset() for the "platname_list" array. +* For testing results of regulator_list_autoset() for outputs: +* - LDO1 +* - LDO2 +* The settings are defined in: include/power/sandbox_pmic.h +*/ +static const struct setting expected_setting_list[] = { + [0 ] = {/* LDO1 */ + .voltage =SANDBOX_LDO1_AUTOSET_EXPECTED_UV , + .current =SANDBOX_LDO1_AUTOSET_EXPECTED_UA , + .enable =SANDBOX_LDO1_AUTOSET_EXPECTED_ENABLE , + }, + [1 ] = {/* LDO2 */ + .voltage =SANDBOX_LDO2_AUTOSET_EXPECTED_UV , + .current =SANDBOX_LDO2_AUTOSET_EXPECTED_UA , + .enable =SANDBOX_LDO2_AUTOSET_EXPECTED_ENABLE , + }, +}; + +static int list_count =ARRAY_SIZE (expected_setting_list); + +/* Test regulator list autoset method */ +static int dm_test_power_regulator_autoset_list (struct dm_test_state *dms) +{ +struct udevice *dev_list[2 ], *dev; +int i; + +/* +* Test the settings of the regulator list: +* LDO1 with fdt properties: +* - min-microvolt = max-microvolt = 1800000 +* - min-microamp = max-microamp = 100000 +* - always-on = not set +* - boot-on = set +* Expected output state: uV=1800000; uA=100000; output enabled +* +* LDO2 with fdt properties: +* - min-microvolt = max-microvolt = 3300000 +* - always-on = not set +* - boot-on = not set +* Expected output state: uV=300000(default); output disabled(default) +* The expected settings are defined in: include/power/sandbox_pmic.h. +*/ +ut_assertok (regulator_list_autoset (platname_list, dev_list, false)); + +for (i =0 ; i < list_count; i++) { +/* Check, that the returned device is non-NULL */ +ut_assert (dev_list[i]); + +/* Check, that the returned device is proper */
Quoted 9 lines
test/dm/power.c line 356
Quoted 6 lines
test/dm/power.c new file +6
-0+ut_assertok (regulator_get_by_platname (platname_list[i], &dev)); +ut_asserteq_ptr (dev_list[i], dev); + +/* Check, that regulator output Voltage value is as expected */ +ut_asserteq (regulator_get_value (dev_list[i]), + expected_setting_list[i].voltage);Expected value should come first.
ok
Quoted 13 lines
Quoted 13 lines
test/dm/power.c new file +13
-0+ +/* Check, that regulator output Current value is as expected */ +ut_asserteq (regulator_get_current (dev_list[i]), + expected_setting_list[i].current); + +/* Check, that regulator output Enable state is as expected */ +ut_asserteq (regulator_get_enable (dev_list[i]), + expected_setting_list[i].enable); + } + +return 0 ; +} +DM_TEST (dm_test_power_regulator_autoset_list,DM_TESTF_SCAN_FDT );
Quoted 9 lines
Quoted 5 lines
test/dm/power.c new file +2
-1+ +#endif /* CONFIG_DM_REGULATOR */ --1.9.1
Regards,
Simon
Thank you,
Signature · 4 lines
Przemyslaw Marczak Samsung R&D Institute Poland Samsung Electronics p.marczak at samsung.com
cover PMIC/REGULATOR cleanup and Sandbox tests
In reply to Przemyslaw MarczakHi Przemyslaw,
Quoted 17 lines · Przemyslaw Marczak
Hello!
This patchset cleanups the POWER framework V4, which is applied into u-boot-dm/next tree.The main changes:
- pmic/regulator uclasses cleanup - each commit message describes the changes in details.
- added sandbox PMIC emulated device support, which consists of three
drivers: pmic I2C emul, pmic I/O and regulator.
- PMIC/REGULATOR tests for sandbox in:tests/dm/power.cI tried to add the implementation of all pmic/regulator operations for the sandbox PMIC device - I hope that the drivers are not too complicated.
The tests for sandbox includes every pmic/regulator function call, so for now the tests should well cover the framework features.
Quoted 6 lines
The patchset is rebased on the top of u-boot-dm/next, and can be fetched from
here: https://github.com/bobenstein/u-boot.git
branch: dm-pmic-v4-sandboxBest regards,
Przemyslaw Marczak
This looks great, thank you. I pushed the current state to u-boot-dm/working.
I have a small bisectability problem though:
buildman -b dm-next samsung -se
boards.cfg is up to date. Nothing to do.
Summary of 29 commits for 16 boards (16 threads, 2 jobs per thread)
01: dm: sf: Update default name of spi flash in structure udevice
02: exynos5: fix build break by adding CONFIG_POWER
03: exynos4-common: remove the unsued CONFIG_CMD_PMIC
04: lib: Kconfig: add entry for errno_str() function
05: dm: pmic: add implementation of driver model pmic uclass
06: dm: regulator: add implementation of driver model regulator uclass
07: dm: pmic: add pmic command
08: dm: regulator: add regulator command
09: pmic: max77686 set the same compatible as in the kernel
10: dm: pmic: add max77686 pmic driver
11: dm: regulator: add max77686 regulator driver
12: dm: regulator: add fixed voltage regulator driver
13: doc: driver-model: pmic and regulator uclass documentation
14: dm: board:samsung: power_init_board: add requirement of CONFIG_DM_PMIC
15: odroid: board: add support to dm pmic api
arm: + odroid+board/samsung/odroid/built-in.o: In function `s5pc210_phy_control':+build/../board/samsung/odroid/odroid.c:444: undefined reference to
`regulator_by_platname'+build/../board/samsung/odroid/odroid.c:453: undefined reference to
`regulator_set_mode'+board/samsung/odroid/built-in.o: In function `exynos_power_init':+build/../board/samsung/odroid/odroid.c:432: undefined reference to `regulator_by_platname_list_autoset_and_enable'+board/samsung/odroid/built-in.o: In function `board_usb_init':+build/../board/samsung/odroid/odroid.c:490: undefined reference to
`regulator_by_platname'+build/../board/samsung/odroid/odroid.c:496: undefined reference to
`regulator_set_enable'+build/../board/samsung/odroid/odroid.c:502: undefined reference to
`regulator_set_value'+build/../board/samsung/odroid/odroid.c:508: undefined reference to
`regulator_set_value'
+arm-linux-gnueabihf-ld.bfd: BFD (crosstool-NG
linaro-1.13.1-4.7-2013.04-20130415 - Linaro GCC 2013.04) 2.23.1
assertion fail /cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-linux/.build/src/binutils-2.23.1/bfd/elf32-arm.c:7677 +arm-linux-gnueabihf-ld.bfd: error: required section '.rel.plt' not
found in the linker script
+arm-linux-gnueabihf-ld.bfd: final link failed: Invalid operation
+make[1]: *** [u-boot] Error 1
+make: *** [sub-make] Error 2
16: odroid: dts: add 'voltage-regulators' description to max77686 node
17: odroid: config: enable dm pmic, dm regulator and max77686 driver
arm: odroid-board/samsung/odroid/built-in.o: In function `s5pc210_phy_control':-build/../board/samsung/odroid/odroid.c:444: undefined reference to
`regulator_by_platname'-build/../board/samsung/odroid/odroid.c:453: undefined reference to
`regulator_set_mode'-board/samsung/odroid/built-in.o: In function `exynos_power_init':-build/../board/samsung/odroid/odroid.c:432: undefined reference to `regulator_by_platname_list_autoset_and_enable'-board/samsung/odroid/built-in.o: In function `board_usb_init':-build/../board/samsung/odroid/odroid.c:490: undefined reference to
`regulator_by_platname'-build/../board/samsung/odroid/odroid.c:496: undefined reference to
`regulator_set_enable'-build/../board/samsung/odroid/odroid.c:502: undefined reference to
`regulator_set_value'-build/../board/samsung/odroid/odroid.c:508: undefined reference to
`regulator_set_value'
-arm-linux-gnueabihf-ld.bfd: BFD (crosstool-NG
linaro-1.13.1-4.7-2013.04-20130415 - Linaro GCC 2013.04) 2.23.1
assertion fail /cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-linux/.build/src/binutils-2.23.1/bfd/elf32-arm.c:7677 -arm-linux-gnueabihf-ld.bfd: error: required section '.rel.plt' not
found in the linker script
-arm-linux-gnueabihf-ld.bfd: final link failed: Invalid operation
-make[1]: *** [u-boot] Error 1
-make: *** [sub-make] Error 2
18: dm: pmic: code cleanup of PMIC uclass driver
arm: + odroid+../drivers/power/pmic/max77686.c: At top level:+drivers/power/pmic/built-in.o: In function `max77686_bind':+build/../drivers/power/pmic/max77686.c:62: undefined reference to
`pmic_bind_childs'
+arm-linux-gnueabihf-ld.bfd: BFD (crosstool-NG
linaro-1.13.1-4.7-2013.04-20130415 - Linaro GCC 2013.04) 2.23.1
assertion fail /cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-linux/.build/src/binutils-2.23.1/bfd/elf32-arm.c:7677 +arm-linux-gnueabihf-ld.bfd: error: required section '.rel.plt' not
found in the linker script
+arm-linux-gnueabihf-ld.bfd: final link failed: Invalid operation
+make[1]: *** [u-boot] Error 1
+make: *** [sub-make] Error 2w+../drivers/power/pmic/max77686.c: In function ?max77686_bind?:w+../drivers/power/pmic/max77686.c:62:2: warning: implicit declaration
of function ?pmic_bind_childs? [-Wimplicit-function-declaration]w+../drivers/power/pmic/max77686.c:71:2: warning: initialization makes
pointer from integer without a cast [enabled by default]w+../drivers/power/pmic/max77686.c:71:2: warning: (near initialization
for ?max77686_ops.reg_count?) [enabled by default]
19: dm: pmic: max77686: update driver code
arm: odroid-../drivers/power/pmic/max77686.c: At top level:-drivers/power/pmic/built-in.o: In function `max77686_bind':-build/../drivers/power/pmic/max77686.c:62: undefined reference to
`pmic_bind_childs'
-arm-linux-gnueabihf-ld.bfd: BFD (crosstool-NG
linaro-1.13.1-4.7-2013.04-20130415 - Linaro GCC 2013.04) 2.23.1
assertion fail /cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-linux/.build/src/binutils-2.23.1/bfd/elf32-arm.c:7677 -arm-linux-gnueabihf-ld.bfd: error: required section '.rel.plt' not
found in the linker script
-arm-linux-gnueabihf-ld.bfd: final link failed: Invalid operation
-make[1]: *** [u-boot] Error 1
-make: *** [sub-make] Error 2w-../drivers/power/pmic/max77686.c: In function ?max77686_bind?:w-../drivers/power/pmic/max77686.c:62:2: warning: implicit declaration
of function ?pmic_bind_childs? [-Wimplicit-function-declaration]w-../drivers/power/pmic/max77686.c:71:2: warning: initialization makes
pointer from integer without a cast [enabled by default]w-../drivers/power/pmic/max77686.c:71:2: warning: (near initialization
for ?max77686_ops.reg_count?) [enabled by default]
20: dm: regulator: uclass driver code cleanup
arm: + odroid
+In file included from ../board/samsung/odroid/odroid.c:17:0:+../include/power/regulator.h:356:5: note: expected ?struct udevice
**? but argument is of type ?int?+../board/samsung/odroid/odroid.c:432:2: error: too many arguments to
function ?regulator_list_autoset?+../include/power/regulator.h:356:5: note: declared here
+make[2]: *** [board/samsung/odroid/odroid.o] Error 1
+make[1]: *** [board/samsung/odroid] Error 2
+make: *** [sub-make] Error 2w+../board/samsung/odroid/odroid.c: In function ?exynos_power_init?:w+../board/samsung/odroid/odroid.c:432:2: warning: passing argument 2
of ?regulator_list_autoset? makes pointer from integer without a cast
[enabled by default]w+../board/samsung/odroid/odroid.c: In function ?s5pc210_phy_control?:w+../board/samsung/odroid/odroid.c:444:2: warning: implicit
declaration of function ?regulator_by_platname?
[-Wimplicit-function-declaration]
21: odroid u3: cleanup the regulator calls
arm: odroid
-In file included from ../board/samsung/odroid/odroid.c:17:0:-../include/power/regulator.h:356:5: note: expected ?struct udevice
**? but argument is of type ?int?-../board/samsung/odroid/odroid.c:432:2: error: too many arguments to
function ?regulator_list_autoset?-../include/power/regulator.h:356:5: note: declared here
-make[2]: *** [board/samsung/odroid/odroid.o] Error 1
-make[1]: *** [board/samsung/odroid] Error 2
-make: *** [sub-make] Error 2w-../board/samsung/odroid/odroid.c: In function ?exynos_power_init?:w-../board/samsung/odroid/odroid.c:432:2: warning: passing argument 2
of ?regulator_list_autoset? makes pointer from integer without a cast
[enabled by default]w-../board/samsung/odroid/odroid.c: In function ?s5pc210_phy_control?:w-../board/samsung/odroid/odroid.c:444:2: warning: implicit
declaration of function ?regulator_by_platname?
[-Wimplicit-function-declaration]
22: common: cmd pmic: command cleanup
23: common: cmd regulator: command cleanup
24: doc: driver-model: pmic-framework.txt - cleanup
25: sandbox: i2c: search child emul dev and check its uclass id
26: sandbox: add: sandbox PMIC device drivers: I2C emul, pmic, regulator
27: test: dm: dts: add sandbox pmic i2c node
28: sandbox: defconfig: enable support of sandbox PMIC drivers
29: test: dm: add sandbox PMIC framework tests
Can you please take a look?
Quoted 48 lines
Przemyslaw Marczak (12):
dm: pmic: code cleanup of PMIC uclass driver
dm: pmic: max77686: update driver code
dm: regulator: uclass driver code cleanup
odroid u3: cleanup the regulator calls
common: cmd pmic: command cleanup
common: cmd regulator: command cleanup
doc: driver-model: pmic-framework.txt - cleanup
sandbox: i2c: search child emul dev and check its uclass id
sandbox: add: sandbox PMIC device drivers: I2C emul, pmic, regulator
test: dm: dts: add sandbox pmic i2c node
sandbox: defconfig: enable support of sandbox PMIC drivers
test: dm: add sandbox PMIC framework testsboard/samsung/odroid/odroid.c | 9 +- common/cmd_pmic.c | 131 ++++----- common/cmd_regulator.c | 239 ++++++++-------- configs/sandbox_defconfig | 7 + doc/device-tree-bindings/pmic/sandbox.txt | 35 +++ doc/device-tree-bindings/regulator/sandbox.txt | 45 +++ doc/driver-model/pmic-framework.txt | 20 +- drivers/i2c/sandbox_i2c.c | 20 +- drivers/power/pmic/Kconfig | 27 +- drivers/power/pmic/Makefile | 3 +- drivers/power/pmic/i2c_pmic_emul.c | 145 ++++++++++ drivers/power/pmic/max77686.c | 15 +- drivers/power/pmic/pmic-uclass.c | 25 +- drivers/power/pmic/sandbox.c | 79 ++++++ drivers/power/regulator/Kconfig | 32 ++- drivers/power/regulator/Makefile | 1 + drivers/power/regulator/regulator-uclass.c | 104 ++++--- drivers/power/regulator/sandbox.c | 355 +++++++++++++++++++++++ include/power/pmic.h | 39 +-- include/power/regulator.h | 116 ++++---- include/power/sandbox_pmic.h | 222 +++++++++++++++ test/dm/Makefile | 2 + test/dm/power.c | 371 +++++++++++++++++++++++++ test/dm/test.dts | 38 +++ 24 files changed, 1732 insertions(+), 348 deletions(-) create mode 100644 doc/device-tree-bindings/pmic/sandbox.txt create mode 100644 doc/device-tree-bindings/regulator/sandbox.txt create mode 100644 drivers/power/pmic/i2c_pmic_emul.c create mode 100644 drivers/power/pmic/sandbox.c create mode 100644 drivers/power/regulator/sandbox.c create mode 100644 include/power/sandbox_pmic.h create mode 100644 test/dm/power.c
Quoted 3 lines
--
1.9.1
Regards,
Simon
cover PMIC/REGULATOR cleanup and Sandbox tests
Hello Simon,
Quoted 193 lines · Simon Glass
Hi Przemyslaw,
Quoted 17 lines · Przemyslaw Marczak
Hello!
This patchset cleanups the POWER framework V4, which is applied into u-boot-dm/next tree.The main changes:
- pmic/regulator uclasses cleanup - each commit message describes the changes in details.
- added sandbox PMIC emulated device support, which consists of three
drivers: pmic I2C emul, pmic I/O and regulator.
- PMIC/REGULATOR tests for sandbox in:tests/dm/power.cI tried to add the implementation of all pmic/regulator operations for the sandbox PMIC device - I hope that the drivers are not too complicated.
The tests for sandbox includes every pmic/regulator function call, so for now the tests should well cover the framework features.
Quoted 6 lines
The patchset is rebased on the top of u-boot-dm/next, and can be fetched from
here: https://github.com/bobenstein/u-boot.git
branch: dm-pmic-v4-sandboxBest regards,
Przemyslaw MarczakThis looks great, thank you. I pushed the current state to u-boot-dm/working.
I have a small bisectability problem though:
buildman -b dm-next samsung -se
boards.cfg is up to date. Nothing to do.
Summary of 29 commits for 16 boards (16 threads, 2 jobs per thread) 01: dm: sf: Update default name of spi flash in structure udevice 02: exynos5: fix build break by addingCONFIG_POWER
03: exynos4-common: remove the unsuedCONFIG_CMD_PMIC
04: lib:Kconfig: add entry forerrno_str()function
05: dm: pmic: add implementation of driver model pmic uclass 06: dm: regulator: add implementation of driver model regulator uclass 07: dm: pmic: add pmic command
08: dm: regulator: add regulator command
09: pmic: max77686 set the same compatible as in the kernel 10: dm: pmic: add max77686 pmic driver
11: dm: regulator: add max77686 regulator driver
12: dm: regulator: add fixed voltage regulator driver
13: doc: driver-model: pmic and regulator uclass documentation 14: dm: board:samsung:power_init_board: add requirement ofCONFIG_DM_PMIC15: odroid: board: add support to dm pmic api
arm: + odroid(quoted diff) +2
-0+board/samsung/odroid/built-in.o: In function `s5pc210_phy_control': +build/../board/samsung/odroid/odroid.c:444: undefined reference to
regulator_by_platname' +build/../board/samsung/odroid/odroid.c:453: undefined reference toregulator_set_mode'(quoted diff) +2
-0+board/samsung/odroid/built-in.o: In function `exynos_power_init': +build/../board/samsung/odroid/odroid.c:432: undefined reference to`regulator_by_platname_list_autoset_and_enable'
(quoted diff) +2
-0+board/samsung/odroid/built-in.o: In function `board_usb_init': +build/../board/samsung/odroid/odroid.c:490: undefined reference to`regulator_by_platname'
+build/../board/samsung/odroid/odroid.c:496: undefined reference to
`regulator_set_enable'+build/../board/samsung/odroid/odroid.c:502: undefined reference to
`regulator_set_value'+build/../board/samsung/odroid/odroid.c:508: undefined reference to
`regulator_set_value'
+arm-linux-gnueabihf-ld.bfd: BFD (crosstool-NG
linaro-1.13.1-4.7-2013.04-20130415 - Linaro GCC 2013.04) 2.23.1
assertion fail /cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-linux/.build/src/binutils-2.23.1/bfd/elf32-arm.c:7677 +arm-linux-gnueabihf-ld.bfd: error: required section '.rel.plt' not
found in the linker script(quoted diff) +3
-0+arm-linux-gnueabihf-ld.bfd: final link failed: Invalid operation +make[1]: *** [u-boot] Error 1 +make: *** [sub-make] Error 216: odroid: dts: add 'voltage-regulators' description to max77686 node 17: odroid: config: enable dm pmic, dm regulator and max77686 driver
arm: odroid(quoted diff) +0
-2-board/samsung/odroid/built-in.o: In function `s5pc210_phy_control': -build/../board/samsung/odroid/odroid.c:444: undefined reference to
regulator_by_platname' -build/../board/samsung/odroid/odroid.c:453: undefined reference toregulator_set_mode'(quoted diff) +0
-2-board/samsung/odroid/built-in.o: In function `exynos_power_init': -build/../board/samsung/odroid/odroid.c:432: undefined reference to`regulator_by_platname_list_autoset_and_enable'
(quoted diff) +0
-2-board/samsung/odroid/built-in.o: In function `board_usb_init': -build/../board/samsung/odroid/odroid.c:490: undefined reference to`regulator_by_platname'
-build/../board/samsung/odroid/odroid.c:496: undefined reference to
`regulator_set_enable'-build/../board/samsung/odroid/odroid.c:502: undefined reference to
`regulator_set_value'-build/../board/samsung/odroid/odroid.c:508: undefined reference to
`regulator_set_value'
-arm-linux-gnueabihf-ld.bfd: BFD (crosstool-NG
linaro-1.13.1-4.7-2013.04-20130415 - Linaro GCC 2013.04) 2.23.1
assertion fail /cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-linux/.build/src/binutils-2.23.1/bfd/elf32-arm.c:7677 -arm-linux-gnueabihf-ld.bfd: error: required section '.rel.plt' not
found in the linker script(quoted diff) +0
-3-arm-linux-gnueabihf-ld.bfd: final link failed: Invalid operation -make[1]: *** [u-boot] Error 1 -make: *** [sub-make] Error 218: dm: pmic: code cleanup of PMIC uclass driver
arm: + odroid+../drivers/power/pmic/max77686.c: At top level:(quoted diff) +2
-0+drivers/power/pmic/built-in.o: In function `max77686_bind': +build/../drivers/power/pmic/max77686.c:62: undefined reference to`pmic_bind_childs'
+arm-linux-gnueabihf-ld.bfd: BFD (crosstool-NG
linaro-1.13.1-4.7-2013.04-20130415 - Linaro GCC 2013.04) 2.23.1
assertion fail /cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-linux/.build/src/binutils-2.23.1/bfd/elf32-arm.c:7677 +arm-linux-gnueabihf-ld.bfd: error: required section '.rel.plt' not
found in the linker script(quoted diff) +3
-0+arm-linux-gnueabihf-ld.bfd: final link failed: Invalid operation +make[1]: *** [u-boot] Error 1 +make: *** [sub-make] Error 2
w+../drivers/power/pmic/max77686.c: In function ?max77686_bind?:w+../drivers/power/pmic/max77686.c:62:2: warning: implicit declaration of function ?pmic_bind_childs? [-Wimplicit-function-declaration]w+../drivers/power/pmic/max77686.c:71:2: warning: initialization makes pointer from integer without a cast [enabled by default]w+../drivers/power/pmic/max77686.c:71:2: warning: (near initialization for ?max77686_ops.reg_count?) [enabled by default]
19: dm: pmic: max77686: update driver code
arm: odroid-../drivers/power/pmic/max77686.c: At top level:(quoted diff) +0
-2-drivers/power/pmic/built-in.o: In function `max77686_bind': -build/../drivers/power/pmic/max77686.c:62: undefined reference to`pmic_bind_childs'
-arm-linux-gnueabihf-ld.bfd: BFD (crosstool-NG
linaro-1.13.1-4.7-2013.04-20130415 - Linaro GCC 2013.04) 2.23.1
assertion fail /cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-linux/.build/src/binutils-2.23.1/bfd/elf32-arm.c:7677 -arm-linux-gnueabihf-ld.bfd: error: required section '.rel.plt' not
found in the linker script(quoted diff) +0
-3-arm-linux-gnueabihf-ld.bfd: final link failed: Invalid operation -make[1]: *** [u-boot] Error 1 -make: *** [sub-make] Error 2
w-../drivers/power/pmic/max77686.c: In function ?max77686_bind?:w-../drivers/power/pmic/max77686.c:62:2: warning: implicit declaration of function ?pmic_bind_childs? [-Wimplicit-function-declaration]w-../drivers/power/pmic/max77686.c:71:2: warning: initialization makes pointer from integer without a cast [enabled by default]w-../drivers/power/pmic/max77686.c:71:2: warning: (near initialization for ?max77686_ops.reg_count?) [enabled by default]
20: dm: regulator: uclass driver code cleanup
arm: + odroid
+In file included from../board/samsung/odroid/odroid.c:17:0:+../include/power/regulator.h:356:5: note: expected ?struct udevice **? but argument is of type ?int?+../board/samsung/odroid/odroid.c:432:2: error: too many arguments to function ?regulator_list_autoset?+../include/power/regulator.h:356:5: note: declared here(quoted diff) +3
-0+make[2]: *** [board/samsung/odroid/odroid.o] Error 1 +make[1]: *** [board/samsung/odroid] Error 2 +make: *** [sub-make] Error 2
w+../board/samsung/odroid/odroid.c: In function ?exynos_power_init?:w+../board/samsung/odroid/odroid.c:432:2: warning: passing argument 2 of ?regulator_list_autoset? makes pointer from integer without a cast [enabled by default]w+../board/samsung/odroid/odroid.c: In function ?s5pc210_phy_control?:w+../board/samsung/odroid/odroid.c:444:2: warning: implicit declaration of function ?regulator_by_platname? [-Wimplicit-function-declaration]
21: odroid u3: cleanup the regulator calls
arm: odroid
-In file included from../board/samsung/odroid/odroid.c:17:0:-../include/power/regulator.h:356:5: note: expected ?struct udevice **? but argument is of type ?int?-../board/samsung/odroid/odroid.c:432:2: error: too many arguments to function ?regulator_list_autoset?-../include/power/regulator.h:356:5: note: declared here(quoted diff) +0
-3-make[2]: *** [board/samsung/odroid/odroid.o] Error 1 -make[1]: *** [board/samsung/odroid] Error 2 -make: *** [sub-make] Error 2
w-../board/samsung/odroid/odroid.c: In function ?exynos_power_init?:w-../board/samsung/odroid/odroid.c:432:2: warning: passing argument 2 of ?regulator_list_autoset? makes pointer from integer without a cast [enabled by default]w-../board/samsung/odroid/odroid.c: In function ?s5pc210_phy_control?:w-../board/samsung/odroid/odroid.c:444:2: warning: implicit declaration of function ?regulator_by_platname? [-Wimplicit-function-declaration]
22: common: cmd pmic: command cleanup
23: common: cmd regulator: command cleanup
24: doc: driver-model: pmic-framework.txt - cleanup
25: sandbox: i2c: search child emul dev and check its uclass id 26: sandbox: add: sandbox PMIC device drivers: I2C emul, pmic, regulator 27: test: dm: dts: add sandbox pmic i2c node
28: sandbox: defconfig: enable support of sandbox PMIC drivers 29: test: dm: add sandbox PMIC framework tests
Quoted 2 lines
Can you please take a look?
Ok, will check this.
Quoted 48 lines
Quoted 48 lines
Przemyslaw Marczak (12):
dm: pmic: code cleanup of PMIC uclass driver
dm: pmic: max77686: update driver code
dm: regulator: uclass driver code cleanup
odroid u3: cleanup the regulator calls
common: cmd pmic: command cleanup
common: cmd regulator: command cleanup
doc: driver-model: pmic-framework.txt - cleanup
sandbox: i2c: search child emul dev and check its uclass id
sandbox: add: sandbox PMIC device drivers: I2C emul, pmic, regulator
test: dm: dts: add sandbox pmic i2c node
sandbox: defconfig: enable support of sandbox PMIC drivers
test: dm: add sandbox PMIC framework testsboard/samsung/odroid/odroid.c | 9 +- common/cmd_pmic.c | 131 ++++----- common/cmd_regulator.c | 239 ++++++++-------- configs/sandbox_defconfig | 7 + doc/device-tree-bindings/pmic/sandbox.txt | 35 +++ doc/device-tree-bindings/regulator/sandbox.txt | 45 +++ doc/driver-model/pmic-framework.txt | 20 +- drivers/i2c/sandbox_i2c.c | 20 +- drivers/power/pmic/Kconfig | 27 +- drivers/power/pmic/Makefile | 3 +- drivers/power/pmic/i2c_pmic_emul.c | 145 ++++++++++ drivers/power/pmic/max77686.c | 15 +- drivers/power/pmic/pmic-uclass.c | 25 +- drivers/power/pmic/sandbox.c | 79 ++++++ drivers/power/regulator/Kconfig | 32 ++- drivers/power/regulator/Makefile | 1 + drivers/power/regulator/regulator-uclass.c | 104 ++++--- drivers/power/regulator/sandbox.c | 355 +++++++++++++++++++++++ include/power/pmic.h | 39 +-- include/power/regulator.h | 116 ++++---- include/power/sandbox_pmic.h | 222 +++++++++++++++ test/dm/Makefile | 2 + test/dm/power.c | 371 +++++++++++++++++++++++++ test/dm/test.dts | 38 +++ 24 files changed, 1732 insertions(+), 348 deletions(-)create mode 100644
doc/device-tree-bindings/pmic/sandbox.txtcreate mode 100644doc/device-tree-bindings/regulator/sandbox.txtcreate mode 100644drivers/power/pmic/i2c_pmic_emul.ccreate mode 100644drivers/power/pmic/sandbox.c
create mode 100644drivers/power/regulator/sandbox.ccreate mode 100644include/power/sandbox_pmic.h
create mode 100644test/dm/power.c
Quoted 7 lines
Quoted 3 lines
--
1.9.1Regards,
Simon
Best regards,
Signature · 4 lines
Przemyslaw Marczak Samsung R&D Institute Poland Samsung Electronics p.marczak at samsung.com
v2 cover PMIC/REGULATOR cleanup and Sandbox tests
In reply to Przemyslaw MarczakHello Simon,
This patchset fixes the build issues. It changes the last three top commits of u-boot-dm/next. So it is rebased onto:
4e9a6eb dm: board:samsung: power_init_board: add requirement of CONFIG_DM_PMIC
The rebased version, can be fetched from:
https://github.com/bobenstein/u-boot.git
branch: dm-pmic-v5-sandbox
Best regards,
Przemyslaw Marczak
Przemyslaw Marczak (13):
odroid: dts: add 'voltage-regulators' description to max77686 node
odroid: enable driver model pmic/regulator API and MAX77686 drivers
dm: pmic: code cleanup of PMIC uclass driver
dm: regulator: uclass driver code cleanup
common: cmd pmic: command cleanup
common: cmd regulator: command cleanup
doc: driver-model: pmic-framework.txt - cleanup
sandbox: i2c: search child emul dev and check its uclass id
sandbox: add: sandbox PMIC device drivers: I2C emul, pmic, regulator
test: dm: add sandbox PMIC framework tests
test: dm: test.dts - move to sandbox dts directory
sandbox: dts: add sandbox_pmic.dtsi and include it to sandbox.dts and
test.dts
sandbox: defconfig: enable support of sandbox PMIC drivers
arch/arm/dts/exynos4412-odroid.dts | 253 ++++++++++++++++++ arch/sandbox/dts/Makefile | 1 + arch/sandbox/dts/sandbox.dts | 4 + arch/sandbox/dts/sandbox_pmic.dtsi | 78 ++++++ arch/sandbox/dts/test.dts | 236 ++++++++++++++++ board/samsung/common/misc.c | 1 + board/samsung/odroid/odroid.c | 76 +++--- common/cmd_pmic.c | 131 ++++----- common/cmd_regulator.c | 239 +++++++++-------- configs/odroid_defconfig | 8 +- configs/sandbox_defconfig | 7 + doc/device-tree-bindings/pmic/sandbox.txt | 35 +++ doc/device-tree-bindings/regulator/sandbox.txt | 45 ++++ doc/driver-model/pmic-framework.txt | 20 +- drivers/i2c/sandbox_i2c.c | 20 +- drivers/power/pmic/Kconfig | 27 +- drivers/power/pmic/Makefile | 3 +- drivers/power/pmic/i2c_pmic_emul.c | 142 ++++++++++ drivers/power/pmic/max77686.c | 15 +- drivers/power/pmic/pmic-uclass.c | 31 +-- drivers/power/pmic/sandbox.c | 79 ++++++ drivers/power/regulator/Kconfig | 32 ++- drivers/power/regulator/Makefile | 1 + drivers/power/regulator/regulator-uclass.c | 104 +++++--- drivers/power/regulator/sandbox.c | 355 +++++++++++++++++++++++++ include/configs/odroid.h | 5 - include/dt-bindings/pmic/sandbox_pmic.h | 35 +++ include/power/pmic.h | 39 +-- include/power/regulator.h | 116 ++++---- include/power/sandbox_pmic.h | 138 ++++++++++ test/dm/.gitignore | 1 - test/dm/Makefile | 2 + test/dm/pmic.c | 69 +++++ test/dm/regulator.c | 325 ++++++++++++++++++++++ test/dm/test-dm.sh | 3 +- test/dm/test-main.c | 3 +- test/dm/test.dts | 230 ---------------- 37 files changed, 2287 insertions(+), 622 deletions(-) create mode 100644 arch/sandbox/dts/sandbox_pmic.dtsi create mode 100644 arch/sandbox/dts/test.dts create mode 100644 doc/device-tree-bindings/pmic/sandbox.txt create mode 100644 doc/device-tree-bindings/regulator/sandbox.txt create mode 100644 drivers/power/pmic/i2c_pmic_emul.c create mode 100644 drivers/power/pmic/sandbox.c create mode 100644 drivers/power/regulator/sandbox.c create mode 100644 include/dt-bindings/pmic/sandbox_pmic.h create mode 100644 include/power/sandbox_pmic.h delete mode 100644 test/dm/.gitignore create mode 100644 test/dm/pmic.c create mode 100644 test/dm/regulator.c delete mode 100644 test/dm/test.dts
Signature · 1 line
1.9.1
PATCH v2 1/13 odroid: dts: add 'voltage-regulators' description to max77686 node
Adding regulators subnode to fdt max77686 node, allows properly init regulators by the max77686 regulator driver. This enables the complete functionality of the regulator command.
--- arch/arm/dts/exynos4412-odroid.dts | 253 +++++++++++++++++++++++++++++++++++++ 1 file changed, 253 insertions(+)
arch/arm/dts/exynos4412-odroid.dts +253 -0
@@ -40,6 +40,259 @@ interrupts = <7 0>; reg = <0x09 0 0>; #clock-cells = <1>; + + voltage-regulators { + ldo1_reg: ldo1 { + regulator-compatible = "LDO1"; + regulator-name = "VDD_ALIVE_1.0V"; + regulator-min-microvolt = <1000000>; + regulator-max-microvolt = <1000000>; + }; + + ldo2_reg: ldo2 { + regulator-compatible = "LDO2"; + regulator-name = "VDDQ_VM1M2_1.2V"; + regulator-min-microvolt = <1200000>; + regulator-max-microvolt = <1200000>; + }; + + ldo3_reg: ldo3 { + regulator-compatible = "LDO3"; + regulator-name = "VCC_1.8V_AP"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + }; + + ldo4_reg: ldo4 { + regulator-compatible = "LDO4"; + regulator-name = "VDDQ_MMC2_2.8V"; + regulator-min-microvolt = <2800000>; + regulator-max-microvolt = <2800000>; + }; + + ldo5_reg: ldo5 { + regulator-compatible = "LDO5"; + regulator-name = "VDDQ_MMC0/1/3_1.8V"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + }; + + ldo6_reg: ldo6 { + regulator-compatible = "LDO6"; + regulator-name = "VMPLL_1.0V"; + regulator-min-microvolt = <1100000>; + regulator-max-microvolt = <1100000>; + }; + + ldo7_reg: ldo7 { + regulator-compatible = "LDO7"; + regulator-name = "VPLL_1.1V"; + regulator-min-microvolt = <1100000>; + regulator-max-microvolt = <1100000>; + }; + + ldo8_reg: ldo8 { + regulator-compatible = "LDO8"; + regulator-name = "VDD_MIPI/HDMI_1.0V"; + regulator-min-microvolt = <1000000>; + regulator-max-microvolt = <1000000>; + }; + + ldo9_reg: ldo9 { + regulator-compatible = "LDO9"; + regulator-name = "nc"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + }; + + ldo10_reg: ldo10 { + regulator-compatible = "LDO10"; + regulator-name = "VDD_MIPI/HDMI_1.8V"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + }; + + ldo11_reg: ldo11 { + regulator-compatible = "LDO11"; + regulator-name = "VDD_ABB1_1.8V"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + }; + + ldo12_reg: ldo12 { + regulator-compatible = "LDO12"; + regulator-name = "VDD_UOTG_3.0V"; + regulator-min-microvolt = <3000000>; + regulator-max-microvolt = <3000000>; + }; + + ldo13_reg: ldo13 { + regulator-compatible = "LDO13"; + regulator-name = "VDD_C2C_1.8V"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + }; + + ldo14_reg: ldo14 { + regulator-compatible = "LDO14"; + regulator-name = "VDD_ABB02_1.8V"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + }; + + ldo15_reg: ldo15 { + regulator-compatible = "LDO15"; + regulator-name = "VDD_HSIC/OTG_1.0V"; + regulator-min-microvolt = <1000000>; + regulator-max-microvolt = <1000000>; + }; + + ldo16_reg: ldo16 { + regulator-compatible = "LDO16"; + regulator-name = "VDD_HSIC_1.8V"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + }; + + ldo17_reg: ldo17 { + regulator-compatible = "LDO17"; + regulator-name = "VDDQ_CAM_1.2V"; + regulator-min-microvolt = <1200000>; + regulator-max-microvolt = <1200000>; + }; + + ldo18_reg: ldo18 { + regulator-compatible = "LDO18"; + regulator-name = "nc"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + }; + + ldo19_reg: ldo19 { + regulator-compatible = "LDO19"; + regulator-name = "nc"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + }; + + ldo20_reg: ldo20 { + regulator-compatible = "LDO20"; + regulator-name = "VDDQ_EMMC_1.8V"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-always-on; + regulator-boot-on; + }; + + ldo21_reg: ldo21 { + regulator-compatible = "LDO21"; + regulator-name = "TFLASH_2.8V"; + regulator-min-microvolt = <2800000>; + regulator-max-microvolt = <2800000>; + regulator-always-on; + regulator-boot-on; + }; + + ldo22_reg: ldo22 { + regulator-compatible = "LDO22"; + regulator-name = "VDDQ_EMMC_2.8V"; + regulator-min-microvolt = <2800000>; + regulator-max-microvolt = <2800000>; + regulator-always-on; + regulator-boot-on; + }; + + ldo23_reg: ldo23 { + regulator-compatible = "LDO23"; + regulator-name = "nc"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + }; + + ldo24_reg: ldo24 { + regulator-compatible = "LDO24"; + regulator-name = "nc"; + regulator-min-microvolt = <3000000>; + regulator-max-microvolt = <3000000>; + }; + + ldo25_reg: ldo25 { + regulator-compatible = "LDO25"; + regulator-name = "VDDQ_LCD_3.0V"; + regulator-min-microvolt = <3000000>; + regulator-max-microvolt = <3000000>; + }; + + ldo26_reg: ldo26 { + regulator-compatible = "LDO26"; + regulator-name = "nc"; + regulator-min-microvolt = <3000000>; + regulator-max-microvolt = <3000000>; + }; + + buck1_reg: buck at 1 { + regulator-compatible = "BUCK1"; + regulator-name = "VDD_MIF_1.0V"; + regulator-min-microvolt = <8500000>; + regulator-max-microvolt = <1100000>; + }; + + buck2_reg: buck at 2 { + regulator-compatible = "BUCK2"; + regulator-name = "VDD_ARM_1.0V"; + regulator-min-microvolt = <850000>; + regulator-max-microvolt = <1500000>; + }; + + buck3_reg: buck3 { + regulator-compatible = "BUCK3"; + regulator-name = "VDD_INT_1.1V"; + regulator-min-microvolt = <850000>; + regulator-max-microvolt = <1150000>; + }; + + buck4_reg: buck4 { + regulator-compatible = "BUCK4"; + regulator-name = "VDD_G3D_1.0V"; + regulator-min-microvolt = <850000>; + regulator-max-microvolt = <1150000>; + }; + + buck5_reg: buck5 { + regulator-compatible = "BUCK5"; + regulator-name = "VDDQ_AP_1.2V"; + regulator-min-microvolt = <1200000>; + regulator-max-microvolt = <1200000>; + }; + + buck6_reg: buck6 { + regulator-compatible = "BUCK6"; + regulator-name = "VCC_INL1/7_1.35V"; + regulator-min-microvolt = <1350000>; + regulator-max-microvolt = <1350000>; + }; + + buck7_reg: buck7 { + regulator-compatible = "BUCK7"; + regulator-name = "VCC_INL2/3/5_2.0V"; + regulator-min-microvolt = <2000000>; + regulator-max-microvolt = <2000000>; + }; + + buck8_reg: buck8 { + regulator-compatible = "BUCK8"; + regulator-name = "VCC_P3V3_2.85V"; + regulator-min-microvolt = <2850000>; + regulator-max-microvolt = <3300000>; + }; + + buck9_reg: buck9 { + regulator-compatible = "BUCK9"; + regulator-name = "nc"; + regulator-min-microvolt = <1200000>; + regulator-max-microvolt = <1200000>; + }; + }; }; };
Signature · 1 line
1.9.1
PATCH v2 1/13 odroid: dts: add 'voltage-regulators' description to max77686 node
Quoted 9 lines · Przemyslaw Marczak
Adding regulators subnode to fdt max77686 node, allows properly init regulators by the max77686 regulator driver. This enables the complete functionality of the regulator command.
Signed-off-by Przemyslaw Marczak <[email protected]>Acked-by Simon Glass <[email protected]>--- arch/arm/dts/exynos4412-odroid.dts | 253 +++++++++++++++++++++++++++++++++++++ 1 file changed, 253 insertions(+)
Applied to u-boot-dm, thanks!
PATCH v2 2/13 odroid: enable driver model pmic/regulator API and MAX77686 drivers
In reply to Przemyslaw MarczakThis change enables the configs required to init and setup max77686 regulator driver, using the new driver model pmic and regulator API. And also changes the old pmic framework calls to the new ones.
This commits enables:
- CONFIG_ERRNO_STR
- CONFIG_DM_PMIC
- CONFIG_DM_PMIC_CMD
- CONFIG_DM_PMIC_MAX77686
- CONFIG_DM_REGULATOR
- CONFIG_DM_REGULATOR_CMD
- CONFIG_DM_REGULATOR_MAX77686
And removes the unused:
- CONFIG_DM_I2C_COMPAT
- CONFIG_POWER
- CONFIG_POWER_I2C
- CONFIG_POWER_MAX77686
---
Change V2:
- split two commits for odroid into one
--- board/samsung/common/misc.c | 1 + board/samsung/odroid/odroid.c | 77 +++++++++++++++++++++++++------------------ configs/odroid_defconfig | 8 ++++- include/configs/odroid.h | 5 --- 4 files changed, 53 insertions(+), 38 deletions(-)
board/samsung/common/misc.c +1 -0
@@ -16,6 +16,7 @@#include <asm/arch/cpu.h> #include <asm/gpio.h> #include <linux/input.h> +#include <dm.h> #include <power/pmic.h> #include <mmc.h>
board/samsung/odroid/odroid.c +45 -32
127 lines not on this page · raw message
configs/odroid_defconfig +7 -1
@@ -4,5 +4,11 @@ CONFIG_TARGET_ODROID=y CONFIG_OF_CONTROL=y CONFIG_DEFAULT_DEVICE_TREE="exynos4412-odroid" CONFIG_DM_I2C=y -CONFIG_DM_I2C_COMPAT=y # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set +CONFIG_ERRNO_STR=y +CONFIG_DM_PMIC=y +CONFIG_CMD_PMIC=y +CONFIG_DM_PMIC_MAX77686=y +CONFIG_DM_REGULATOR=y +CONFIG_CMD_REGULATOR=y +CONFIG_DM_REGULATOR_MAX77686=y
include/configs/odroid.h +0 -5
@@ -182,11 +182,6 @@#define CONFIG_SYS_I2C_S3C24X0_SPEED 100000#define CONFIG_SYS_I2C_S3C24X0_SLAVE 0 -/* POWER */ -#define CONFIG_POWER -#define CONFIG_POWER_I2C -#define CONFIG_POWER_MAX77686 -/* GPT */ #define CONFIG_RANDOM_UUID
Signature · 1 line
1.9.1
PATCH v2 2/13 odroid: enable driver model pmic/regulator API and MAX77686 drivers
Quoted 24 lines · Przemyslaw Marczak
This change enables the configs required to init and setup max77686 regulator driver, using the new driver model pmic and regulator API. And also changes the old pmic framework calls to the new ones.
This commits enables:
-CONFIG_ERRNO_STR
-CONFIG_DM_PMIC
-CONFIG_DM_PMIC_CMD
-CONFIG_DM_PMIC_MAX77686
-CONFIG_DM_REGULATOR
-CONFIG_DM_REGULATOR_CMD
-CONFIG_DM_REGULATOR_MAX77686And removes the unused:
-CONFIG_DM_I2C_COMPAT
-CONFIG_POWER
-CONFIG_POWER_I2C
-CONFIG_POWER_MAX77686Signed-off-by Przemyslaw Marczak <[email protected]>Acked-by Simon Glass <[email protected]>---
Change V2:
- split two commits for odroid into one
Quoted 6 lines
--- board/samsung/common/misc.c | 1 + board/samsung/odroid/odroid.c | 77 +++++++++++++++++++++++++------------------ configs/odroid_defconfig | 8 ++++- include/configs/odroid.h | 5 --- 4 files changed, 53 insertions(+), 38 deletions(-)
Applied to u-boot-dm, thanks!
PATCH v2 3/13 dm: pmic: code cleanup of PMIC uclass driver
In reply to Przemyslaw MarczakThe cleanup includes:
- pmic.h - fix mistakes in a few comments
- pmic operations: value 'reg_count' - redefine as function call
- fix function name: pmic_bind_childs() -> pmic_bind_children()
- pmic_bind_children: change the 'while' loop with the 'for'
- add implementation of pmic_reg_count() method
- pmic_bind_children() - update function call name
- Kconfig: add new line at the end of file
- Update MAX77686 driver code
Tested on sandbox:
---
Changes V2:
- cleanup of the pmic_bind_children() loop
- split with: dm: pmic: max77686: update driver code
--- drivers/power/pmic/Kconfig | 2 +- drivers/power/pmic/max77686.c | 15 ++++++++++----- drivers/power/pmic/pmic-uclass.c | 31 +++++++++---------------------- include/power/pmic.h | 39 ++++++++++++++++++++------------------- 4 files changed, 40 insertions(+), 47 deletions(-)
drivers/power/pmic/Kconfig +1 -1
@@ -15,4 +15,4 @@ config DM_PMIC_MAX77686 depends on DM_PMIC ---help--- This config enables implementation of driver-model pmic uclass features - for PMIC MAX77686. The driver implements read/write operations. + for PMIC MAX77686. The driver implements read/write operations.
drivers/power/pmic/max77686.c +10 -5
@@ -16,12 +16,17 @@DECLARE_GLOBAL_DATA_PTR ; -static const struct pmic_child_info pmic_childs_info[] = { +static const struct pmic_child_info pmic_children_info[] = { { .prefix ="ldo" , .driver =MAX77686_LDO_DRIVER }, { .prefix ="buck" , .driver =MAX77686_BUCK_DRIVER }, { }, }; +static int max77686_reg_count (struct udevice *dev) +{ +return MAX77686_NUM_OF_REGS ; +} +static int max77686_write (struct udevice *dev,uint reg,const uint8_t *buff,int len) {
@@ -47,7 +52,7 @@ static int max77686_bind(struct udevice *dev) {int regulators_node;const void *blob = gd->fdt_blob; -int childs; +int children; regulators_node =fdt_subnode_offset (blob, dev->of_offset,"voltage-regulators" );
@@ -59,8 +64,8 @@ static int max77686_bind(struct udevice *dev)debug ("%s: '%s' - found regulators subnode\n" , __func__, dev->name); - childs =pmic_bind_childs (dev, regulators_node, pmic_childs_info); -if (!childs) + children =pmic_bind_children (dev, regulators_node, pmic_children_info); +if (!children)debug ("%s: %s - no child found\n" , __func__, dev->name);/* Always return success for this device */
@@ -68,7 +73,7 @@ static int max77686_bind(struct udevice *dev) }static struct dm_pmic_ops max77686_ops = { - .reg_count =MAX77686_NUM_OF_REGS , + .reg_count = max77686_reg_count, .read = max77686_read, .write = max77686_write, };
drivers/power/pmic/pmic-uclass.c +9 -22
@@ -27,8 +27,8 @@ static ulong str_get_num(const char *ptr, const char *maxptr)return simple_strtoul (ptr,NULL ,0 ); } -int pmic_bind_childs (struct udevice *pmic,int offset, -const struct pmic_child_info *child_info) +int pmic_bind_children (struct udevice *pmic,int offset, +const struct pmic_child_info *child_info) {const struct pmic_child_info *info;const void *blob = gd->fdt_blob;
@@ -53,14 +53,10 @@ int pmic_bind_childs(struct udevice *pmic, int offset, node); child =NULL ; - info = child_info; -while (info->prefix) { +for (info = child_info; info->prefix && info->driver; info++) { prefix_len =strlen (info->prefix); -if (strncasecmp (info->prefix, node_name, prefix_len) || - !info->driver) { - info++; +if (strncasecmp (info->prefix, node_name, prefix_len))continue ; - }debug (" - compatible prefix: '%s'\n" , info->prefix);
@@ -110,16 +106,16 @@ int pmic_get(const char *name, struct udevice **devp)int pmic_reg_count (struct udevice *dev) {const struct dm_pmic_ops *ops =dev_get_driver_ops (dev); -if (!ops) + +if (!ops || !ops->reg_count)return -ENOSYS ; -return ops->reg_count; +return ops->reg_count (dev); }int pmic_read (struct udevice *dev,uint reg,uint8_t *buffer,int len) {const struct dm_pmic_ops *ops =dev_get_driver_ops (dev); -int ret;if (!buffer)return -EFAULT ;
@@ -127,17 +123,12 @@ int pmic_read(struct udevice *dev, uint reg, uint8_t *buffer, int len)if (!ops || !ops->read)return -ENOSYS ; - ret = ops->read (dev, reg, buffer, len); -if (ret) -return ret; - -return 0 ; +return ops->read (dev, reg, buffer, len); }int pmic_write (struct udevice *dev,uint reg,const uint8_t *buffer,int len) {const struct dm_pmic_ops *ops =dev_get_driver_ops (dev); -int ret;if (!buffer)return -EFAULT ;
@@ -145,11 +136,7 @@ int pmic_write(struct udevice *dev, uint reg, const uint8_t *buffer, int len)if (!ops || !ops->write)return -ENOSYS ; - ret = ops->write (dev, reg, buffer, len); -if (ret) -return ret; - -return 0 ; +return ops->write (dev, reg, buffer, len); }UCLASS_DRIVER (pmic) = {
include/power/pmic.h +20 -19
@@ -11,9 +11,9 @@#ifndef __CORE_PMIC_H_#define __CORE_PMIC_H_ -#include <linux/list.h> -#include <spi.h> #include <i2c.h> +#include <spi.h> +#include <linux/list.h> #include <power/power_chrg.h> enum {PMIC_I2C ,PMIC_SPI ,PMIC_NONE };
@@ -90,10 +90,10 @@ struct pmic {* U-Boot PMIC Framework * ===================== * -* UCLASS_PMIC - The is designed to provide an I/O interface for PMIC devices. +* UCLASS_PMIC - This is designed to provide an I/O interface for PMIC devices. * * For the multi-function PMIC devices, this can be used as parent I/O device -* for each IC's interface. Then, each children uses its parent for read/write. +* for each IC's interface. Then, each child uses its parent for read/write. * * The driver model tree could look like this: *
@@ -112,8 +112,8 @@ struct pmic {* We can find two PMIC cases in boards design: * - single I/O interface * - multiple I/O interfaces -* We bind single PMIC device for each interface, to provide an I/O as a parent, -* of proper child devices. Each child usually implements a different function, +* We bind a single PMIC device for each interface, to provide an I/O for +* its child devices. And each child usually implements a different function, * controlled by the same interface. * * The binding should be done automatically. If device tree nodes/subnodes are
@@ -131,7 +131,7 @@ struct pmic {* Note: * Each PMIC interface driver should use a different compatible string. * -* If each pmic child device driver need access the PMIC-specific registers, +* If a PMIC child device driver needs access the PMIC-specific registers, * it need know only the register address and the access can be done through * the parent pmic driver. Like in the example: *
@@ -141,10 +141,10 @@ struct pmic {* | |_ dev: my_regulator (set value/etc..) (is child) - UCLASS_REGULATOR * * To ensure such device relationship, the pmic device driver should also bind -* all its child devices, like in the example below. It should be done by call -* the 'pmic_bind_childs()' - please refer to the description of this function -* in this header file. This function, should be called in the driver's '.bind' -* method. +* all its child devices, like in the example below. It can be done by calling +* the 'pmic_bind_children()' - please refer to the function description, which +* can be found in this header file. This function, should be called inside the +* driver's bind() method. * * For the example driver, please refer the MAX77686 driver: * - 'drivers/power/pmic/max77686.c'
@@ -156,18 +156,19 @@ struct pmic {* Should be implemented by UCLASS_PMIC device drivers. The standard * device operations provides the I/O interface for it's childs. * -* @reg_count: devices register count +* @reg_count: device's register count * @read: read 'len' bytes at "reg" and store it into the 'buffer' * @write: write 'len' bytes from the 'buffer' to the register at 'reg' address */ struct dm_pmic_ops { -int reg_count; +int (*reg_count)(struct udevice *dev);int (*read)(struct udevice *dev,uint reg,uint8_t *buffer,int len);int (*write)(struct udevice *dev,uint reg,const uint8_t *buffer,int len); }; -/* enum pmic_op_type - used for various pmic devices operation calls, +/** +* enum pmic_op_type - used for various pmic devices operation calls, * for reduce a number of lines with the same code for read/write or get/set. * * @PMIC_OP_GET - get operation
@@ -181,7 +182,7 @@ enum pmic_op_type {/** * struct pmic_child_info - basic device's child info for bind child nodes with * the driver by the node name prefix and driver name. This is a helper struct -* for function: pmic_bind_childs(). +* for function: pmic_bind_children(). * * @prefix - child node name prefix (or its name if is unique or single) * @driver - driver name for the sub-node with prefix
@@ -194,7 +195,7 @@ struct pmic_child_info {/* drivers/power/pmic-uclass.c */ /** -* pmic_bind_childs() - bind drivers for given parent pmic, using child info +* pmic_bind_children() - bind drivers for given parent pmic, using child info * found in 'child_info' array. * * @pmic - pmic device - the parent of found child's
@@ -216,7 +217,7 @@ struct pmic_child_info {* (pmic - bind automatically by compatible) * compatible = "my_pmic"; * ... -* (pmic's childs - bind by pmic_bind_childs()) +* (pmic's childs - bind by pmic_bind_children()) * (nodes prefix: "ldo", driver: "my_regulator_ldo") * ldo1 { ... }; * ldo2 { ... };
@@ -226,8 +227,8 @@ struct pmic_child_info {* buck2 { ... }; * }; */ -int pmic_bind_childs (struct udevice *pmic,int offset, -const struct pmic_child_info *child_info); +int pmic_bind_children (struct udevice *pmic,int offset, +const struct pmic_child_info *child_info);/** * pmic_get: get the pmic device using its name
Signature · 1 line
1.9.1
PATCH v2 3/13 dm: pmic: code cleanup of PMIC uclass driver
Quoted 18 lines · Przemyslaw Marczak
The cleanup includes:
-pmic.h- fix mistakes in a few comments
- pmic operations: value 'reg_count' - redefine as function call
- fix function name:pmic_bind_childs()->pmic_bind_children()
-pmic_bind_children: change the 'while' loop with the 'for'
- add implementation ofpmic_reg_count()method
-pmic_bind_children()- update function call name
-Kconfig: add new line at the end of file
- Update MAX77686 driver codeSigned-off-by Przemyslaw Marczak <[email protected]>Acked-by Simon Glass <[email protected]>Tested on sandbox:
Tested-by Simon Glass <[email protected]>---
Changes V2:
- cleanup of thepmic_bind_children()loop
- split with: dm: pmic: max77686: update driver code
Quoted 6 lines
--- drivers/power/pmic/Kconfig | 2 +- drivers/power/pmic/max77686.c | 15 ++++++++++----- drivers/power/pmic/pmic-uclass.c | 31 +++++++++---------------------- include/power/pmic.h | 39 ++++++++++++++++++++------------------- 4 files changed, 40 insertions(+), 47 deletions(-)
Applied to u-boot-dm, thanks!
PATCH v2 4/13 dm: regulator: uclass driver code cleanup
In reply to Przemyslaw MarczakThis cleanup includes:
- remove of the preprocessor macros which pointed to long name functions
- update of the names of some regulator uclass driver functions
- cleanup of the function regulator_autoset()
- reword of some comments of regulator uclass header file
- regulator_get_by_platname: check error for uclass_find_* function calls
- add function: regulator_name_is_unique
- regulator post_bind(): check regulator name uniqueness
- fix mistakes in: regulator/Kconfig
- regulator.h: update comments
- odroid u3: cleanup the regulator calls
Tested on sandbox:
---
Changes V2:
- odroid u3: cleanup the regulator calls
--- board/samsung/odroid/odroid.c | 9 +-- drivers/power/regulator/Kconfig | 2 +- drivers/power/regulator/regulator-uclass.c | 104 +++++++++++++++++--------- include/power/regulator.h | 116 +++++++++++++++-------------- 4 files changed, 132 insertions(+), 99 deletions(-)
board/samsung/odroid/odroid.c +4 -5
@@ -37,6 +37,7 @@ static const char *mmc_regulators[] = {"VDDQ_EMMC_1.8V" ,"VDDQ_EMMC_2.8V" ,"TFLASH_2.8V" , + NULL, };void set_board_type (void )
@@ -427,9 +428,7 @@ int exynos_init(void)int exynos_power_init (void ) { -int list_count =ARRAY_SIZE (mmc_regulators); - -if (regulator_list_autoset (mmc_regulators, list_count,NULL , true)) +if (regulator_list_autoset (mmc_regulators,NULL , true))error ("Unable to init all mmc regulators" );return 0 ;
@@ -441,7 +440,7 @@ static int s5pc210_phy_control(int on)struct udevice *dev;int ret; - ret =regulator_by_platname ("VDD_UOTG_3.0V" , &dev); + ret =regulator_get_by_platname ("VDD_UOTG_3.0V" , &dev);if (ret) {error ("Regulator get error: %d" , ret);return ret;
@@ -487,7 +486,7 @@ int board_usb_init(int index, enum usb_init_type init)/* Power off and on BUCK8 for LAN9730 */ debug ("LAN9730 - Turning power buck 8 OFF and ON.\n" ); - ret =regulator_by_platname ("VCC_P3V3_2.85V" , &dev); + ret =regulator_get_by_platname ("VCC_P3V3_2.85V" , &dev);if (ret) {error ("Regulator get error: %d" , ret);return ret;
drivers/power/regulator/Kconfig +1 -1
@@ -14,7 +14,7 @@ config DM_REGULATOR It's important to call the device_bind() with the proper node offset, when binding the regulator devices. The pmic_bind_childs() can be used for this purpose if PMIC I/O driver is implemented or dm_scan_fdt_node() - otherwise. Detailed informations can be found in the header file. + otherwise. Detailed information can be found in the header file. config DM_REGULATOR_MAX77686 bool "Enable Driver Model for REGULATOR MAX77686"
drivers/power/regulator/regulator-uclass.c +68 -36
198 lines not on this page · raw message
include/power/regulator.h +59 -57
207 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v2 4/13 dm: regulator: uclass driver code cleanup
Quoted 19 lines · Przemyslaw Marczak
This cleanup includes:
- remove of the preprocessor macros which pointed to long name functions
- update of the names of some regulator uclass driver functions
- cleanup of the functionregulator_autoset()
- reword of some comments of regulator uclass header file
-regulator_get_by_platname: check error for uclass_find_* function calls
- add function:regulator_name_is_unique
- regulatorpost_bind(): check regulator name uniqueness
- fix mistakes in: regulator/Kconfig
-regulator.h: update comments
- odroid u3: cleanup the regulator callsSigned-off-by Przemyslaw Marczak <[email protected]>Acked-by Simon Glass <[email protected]>Tested on sandbox:
Tested-by Simon Glass <[email protected]>---
Changes V2:
- odroid u3: cleanup the regulator calls
Quoted 6 lines
--- board/samsung/odroid/odroid.c | 9 +-- drivers/power/regulator/Kconfig | 2 +- drivers/power/regulator/regulator-uclass.c | 104 +++++++++++++++++--------- include/power/regulator.h | 116 +++++++++++++++-------------- 4 files changed, 132 insertions(+), 99 deletions(-)
Applied to u-boot-dm, thanks!
PATCH v2 5/13 common: cmd pmic: command cleanup
In reply to Przemyslaw MarczakThis commit cleanups the use of function: failed(). The new function name is: failure(), and it is used for print errno and the errno-related message only.
The second change is choosing PMIC device by it's name, instead of seq number. Thanks to this change, for set the current device, call of pmic_get() is enough.
Tested on sandbox:
---
Changes V2:
- none
--- common/cmd_pmic.c | 131 +++++++++++++++++++++++------------------------------- 1 file changed, 55 insertions(+), 76 deletions(-)
common/cmd_pmic.c +55 -76
@@ -10,75 +10,41 @@#include <dm/uclass-internal.h> #include <power/pmic.h> -#define LIMIT_SEQ 3 -#define LIMIT_DEVNAME 20 +#define LIMIT_DEV 32 +#define LIMIT_PARENT 20static struct udevice *currdev; -static int failed (const char *getset,const char *thing, -const char *for_dev,int ret) +static int failure (int ret) { -printf ("Can't %s %s %s.\nError: %d (%s)\n" , getset, thing, for_dev, - ret,errno_str (ret)); -return CMD_RET_FAILURE ; -} - -static int pmic_dev_get (bool list_only,int get_seq,struct udevice **devp) -{ -struct udevice *dev; -int ret; - -if (devp) - *devp =NULL ; - -for (ret =uclass_first_device (UCLASS_PMIC , &dev); dev; - ret =uclass_next_device (&dev)) { -if (list_only) { -printf ("|%*d | %-*.*s| %-*.*s| %s @ %d\n" , -LIMIT_SEQ , dev->seq, -LIMIT_DEVNAME ,LIMIT_DEVNAME , dev->name, -LIMIT_DEVNAME ,LIMIT_DEVNAME , dev->parent->name, -dev_get_uclass_name (dev->parent), - dev->parent->seq); -continue ; - } +printf ("Error: %d (%s)\n" , ret,errno_str (ret)); -if (dev->seq == get_seq) { -if (devp) - *devp = dev; -else -return -EINVAL ; - -return 0 ; - } - } - -if (list_only) -return ret; - -return -ENODEV ; +return CMD_RET_FAILURE ; }static int do_dev (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) { -int seq, ret = -ENODEV ; +char *name; +int ret = -ENODEV ;switch (argc) {case 2 : - seq =simple_strtoul (argv[1 ],NULL ,0 ); - ret =uclass_get_device_by_seq (UCLASS_PMIC , seq, &currdev); -if (ret && (ret =pmic_dev_get (false, seq, &currdev))) - goto failed; + name = argv[1 ]; + ret =pmic_get (name, &currdev); +if (ret) { +printf ("Can't get PMIC: %s!\n" , name); +return failure (ret); + }case 1 : -if (!currdev) - goto failed; +if (!currdev) { +printf ("PMIC device is not set!\n\n" ); +return CMD_RET_USAGE ; + }printf ("dev: %d @ %s\n" , currdev->seq, currdev->name); }return CMD_RET_SUCCESS ; -failed: -return failed ("get" ,"the" ,"device" , ret); }static int do_list (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[])
@@ -86,18 +52,19 @@ static int do_list(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])struct udevice *dev;int ret; -printf ("|%*s | %-*.*s| %-*.*s| %s @ %s\n" , -LIMIT_SEQ ,"Seq" , -LIMIT_DEVNAME ,LIMIT_DEVNAME ,"Name" , -LIMIT_DEVNAME ,LIMIT_DEVNAME ,"Parent name" , +printf ("| %-*.*s| %-*.*s| %s @ %s\n" , +LIMIT_DEV ,LIMIT_DEV ,"Name" , +LIMIT_PARENT ,LIMIT_PARENT ,"Parent name" ,"Parent uclass" ,"seq" );for (ret =uclass_first_device (UCLASS_PMIC , &dev); dev; ret =uclass_next_device (&dev)) { -printf ("|%*d | %-*.*s| %-*.*s| %s @ %d\n" , -LIMIT_SEQ , dev->seq, -LIMIT_DEVNAME ,LIMIT_DEVNAME , dev->name, -LIMIT_DEVNAME ,LIMIT_DEVNAME , dev->parent->name, +if (ret) +continue ; + +printf ("| %-*.*s| %-*.*s| %s @ %d\n" , +LIMIT_DEV ,LIMIT_DEV , dev->name, +LIMIT_PARENT ,LIMIT_PARENT , dev->parent->name,dev_get_uclass_name (dev->parent), dev->parent->seq); }
@@ -114,8 +81,10 @@ static int do_dump(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])uint reg;int ret; -if (!currdev) -return failed ("get" ,"current" ,"device" , -ENODEV ); +if (!currdev) { +printf ("First, set the PMIC device!\n" ); +return CMD_RET_USAGE ; + } dev = currdev;
@@ -123,8 +92,10 @@ static int do_dump(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])for (reg =0 ; reg <pmic_reg_count (dev); reg++) { ret =pmic_read (dev, reg, &value,1 ); -if (ret) -return failed ("read" , dev->name,"register" , ret); +if (ret) { +printf ("Can't read register: %d\n" , reg); +return failure (ret); + }if (!(reg %16 ))printf ("\n0x%02x: " , reg);
@@ -143,8 +114,10 @@ static int do_read(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])uint8_t value;uint reg; -if (!currdev) -return failed ("get" ,"current" ,"device" , -ENODEV ); +if (!currdev) { +printf ("First, set the PMIC device!\n" ); +return CMD_RET_USAGE ; + } dev = currdev;
@@ -154,13 +127,15 @@ static int do_read(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) reg =simple_strtoul (argv[1 ],NULL ,0 ); regs =pmic_reg_count (dev);if (reg > regs) { -printf ("Pmic max reg: %d\n" , regs); -return failed ("read" ,"given" ,"address" , -EFAULT ); +printf ("PMIC max reg: %d\n" , regs); +return failure (-EFAULT ); } ret =pmic_read (dev, reg, &value,1 ); -if (ret) -return failed ("read" , dev->name,"register" , ret); +if (ret) { +printf ("Can't read PMIC register: %d!\n" , reg); +return failure (ret); + }printf ("0x%02x: 0x%2.2x\n" , reg, value);
@@ -174,8 +149,10 @@ static int do_write(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])uint8_t value;uint reg; -if (!currdev) -return failed ("get" ,"current" ,"device" , -ENODEV ); +if (!currdev) { +printf ("First, set the PMIC device!\n" ); +return CMD_RET_USAGE ; + } dev = currdev;
@@ -185,15 +162,17 @@ static int do_write(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) reg =simple_strtoul (argv[1 ],NULL ,0 ); regs =pmic_reg_count (dev);if (reg > regs) { -printf ("Pmic max reg: %d\n" , regs); -return failed ("write" ,"given" ,"address" , -EFAULT ); +printf ("PMIC max reg: %d\n" , regs); +return failure (-EFAULT ); } value =simple_strtoul (argv[2 ],NULL ,0 ); ret =pmic_write (dev, reg, &value,1 ); -if (ret) -return failed ("write" , dev->name,"register" , ret); +if (ret) { +printf ("Can't write PMIC register: %d!\n" , reg); +return failure (ret); + }return CMD_RET_SUCCESS ; }
@@ -224,7 +203,7 @@ static int do_pmic(cmd_tbl_t *cmdtp, int flag, int argc,U_BOOT_CMD (pmic,CONFIG_SYS_MAXARGS ,1 , do_pmic," operations" ,"list - list pmic devices\n" -"pmic dev [id] - show or [set] operating pmic device\n" +"pmic dev [name] - show or [set] operating PMIC device\n" "pmic dump - dump registers\n" "pmic read address - read byte of register at address\n" "pmic write address - write byte to register at address\n"
Signature · 1 line
1.9.1
PATCH v2 5/13 common: cmd pmic: command cleanup
Quoted 11 lines · Przemyslaw Marczak
This commit cleanups the use of function:
failed(). The new function name is:failure(), and it is used for print errno and the errno-related message only.The second change is choosing PMIC device by it's name, instead of seq number. Thanks to this change, for set the current device, call of
pmic_get()is enough.Signed-off-by Przemyslaw Marczak <[email protected]>Acked-by Simon Glass <[email protected]>Tested on sandbox:
Quoted 8 lines
Tested-by Simon Glass <[email protected]>---
Changes V2:
- none--- common/cmd_pmic.c | 131 +++++++++++++++++++++++------------------------------- 1 file changed, 55 insertions(+), 76 deletions(-)
Applied to u-boot-dm, thanks!
PATCH v2 6/13 common: cmd regulator: command cleanup
In reply to Przemyslaw MarczakThis commit cleanups the regulator command.
The first change, is adjusting "regulator dev" command to use "regulator-name" constraint, for setting the operating device. Thanks to this, the regulator_get() function is removed.
This also updates do_list() function, with loop over uclass_find_* function calls, to prevent probe of all listed regulators.
This also cleanups the printing in command.
Tested on sandbox:
---
Changes V2:
- none
--- common/cmd_regulator.c | 239 +++++++++++++++++++++++++------------------------ 1 file changed, 122 insertions(+), 117 deletions(-)
common/cmd_regulator.c +122 -117
@@ -10,98 +10,70 @@#include <dm/uclass-internal.h> #include <power/regulator.h> -#define LIMIT_SEQ 3#define LIMIT_DEVNAME 20 -#define LIMIT_OFNAME 20 -#define LIMIT_INFO 16 +#define LIMIT_OFNAME 32 +#define LIMIT_INFO 18static struct udevice *currdev; -static int failed (const char *getset,const char *thing, -const char *for_dev,int ret) +static int failure (int ret) { -printf ("Can't %s %s %s.\nError: %d (%s)\n" , getset, thing, for_dev, - ret,errno_str (ret)); -return CMD_RET_FAILURE ; -} - -static int regulator_get (bool list_only,int get_seq,struct udevice **devp) -{ -struct dm_regulator_uclass_platdata *uc_pdata; -struct udevice *dev; -int ret; - -if (devp) - *devp =NULL ; - -for (ret =uclass_first_device (UCLASS_REGULATOR , &dev); dev; - ret =uclass_next_device (&dev)) { -if (list_only) { - uc_pdata =dev_get_uclass_platdata (dev); -printf ("|%*d | %*.*s @ %-*.*s| %s @ %s\n" , -LIMIT_SEQ , dev->seq, -LIMIT_DEVNAME ,LIMIT_DEVNAME , dev->name, -LIMIT_OFNAME ,LIMIT_OFNAME , uc_pdata->name, - dev->parent->name, -dev_get_uclass_name (dev->parent)); -continue ; - } - -if (dev->seq == get_seq) { -if (devp) - *devp = dev; -else -return -EINVAL ; - -return 0 ; - } - } - -if (list_only) -return ret; +printf ("Error: %d (%s)\n" , ret,errno_str (ret)); -return -ENODEV ; +return CMD_RET_FAILURE ; }static int do_dev (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) {struct dm_regulator_uclass_platdata *uc_pdata; -int seq, ret = -ENXIO ; +const char *name; +int ret = -ENXIO ;switch (argc) {case 2 : - seq =simple_strtoul (argv[1 ],NULL ,0 ); - ret =uclass_get_device_by_seq (UCLASS_REGULATOR , seq, &currdev); -if (ret && (ret =regulator_get (false, seq, &currdev))) - goto failed; + name = argv[1 ]; + ret =regulator_get_by_platname (name, &currdev); +if (ret) { +printf ("Can't get the regulator: %s!\n" , name); +return failure (ret); + }case 1 : +if (!currdev) { +printf ("Regulator device is not set!\n\n" ); +return CMD_RET_USAGE ; + } + uc_pdata =dev_get_uclass_platdata (currdev); -if (!uc_pdata) - goto failed; +if (!uc_pdata) { +printf ("%s: no regulator platform data!\n" , currdev->name); +return failure (ret); + } -printf ("dev: %d @ %s\n" , currdev->seq, uc_pdata->name); +printf ("dev: %s @ %s\n" , uc_pdata->name, currdev->name); }return CMD_RET_SUCCESS ; -failed: -return failed ("get" ,"the" ,"device" , ret); } -static int get_curr_dev_and_pl (struct udevice **devp, -struct dm_regulator_uclass_platdata **uc_pdata, -bool allow_type_fixed) +static int curr_dev_and_platdata (struct udevice **devp, +struct dm_regulator_uclass_platdata **uc_pdata, +bool allow_type_fixed) { *devp =NULL ; *uc_pdata =NULL ; -if (!currdev) -return failed ("get" ,"current" ,"device" , -ENODEV ); +if (!currdev) { +printf ("First, set the regulator device!\n" ); +return CMD_RET_FAILURE ; + } *devp = currdev; *uc_pdata =dev_get_uclass_platdata (*devp); -if (!*uc_pdata) -return failed ("get" ,"regulator" ,"platdata" , -ENXIO ); +if (!*uc_pdata) { +error ("Regulator: %s - missing platform data!" , currdev->name); +return CMD_RET_FAILURE ; + }if (!allow_type_fixed && (*uc_pdata)->type ==REGULATOR_TYPE_FIXED ) {printf ("Operation not allowed for fixed regulator!\n" );
@@ -113,19 +85,28 @@ static int get_curr_dev_and_pl(struct udevice **devp,static int do_list (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) { +struct dm_regulator_uclass_platdata *uc_pdata; +struct udevice *dev;int ret; -printf ("|%*s | %*.*s @ %-*.*s| %s @ %s\n" , -LIMIT_SEQ ,"Seq" , -LIMIT_DEVNAME ,LIMIT_DEVNAME ,"Name" , -LIMIT_OFNAME ,LIMIT_OFNAME ,"fdtname" , -"Parent" ,"uclass" ); +printf ("| %-*.*s| %-*.*s| %s\n" , +LIMIT_DEVNAME ,LIMIT_DEVNAME ,"Device" , +LIMIT_OFNAME ,LIMIT_OFNAME ,"regulator-name" , +"Parent" ); - ret =regulator_get (true,0 ,NULL ); -if (ret) -return CMD_RET_FAILURE ; +for (ret =uclass_find_first_device (UCLASS_REGULATOR , &dev); dev; + ret =uclass_find_next_device (&dev)) { +if (ret) +continue ; -return CMD_RET_SUCCESS ; + uc_pdata =dev_get_uclass_platdata (dev); +printf ("| %-*.*s| %-*.*s| %s\n" , +LIMIT_DEVNAME ,LIMIT_DEVNAME , dev->name, +LIMIT_OFNAME ,LIMIT_OFNAME , uc_pdata->name, + dev->parent->name); + } + +return ret; }static int constraint (const char *name,int val,const char *val_name)
@@ -167,17 +148,18 @@ static int do_info(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])int ret;int i; - ret =get_curr_dev_and_pl (&dev, &uc_pdata, true); + ret =curr_dev_and_platdata (&dev, &uc_pdata, true);if (ret)return ret; parent_uc =dev_get_uclass_name (dev->parent); -printf ("Uclass regulator dev %d info:\n" , dev->seq); -printf ("%-*s %s @ %s\n%-*s %s\n%-*s %s\n%-*s\n" , -LIMIT_INFO ,"* parent:" , dev->parent->name, parent_uc, -LIMIT_INFO ,"* dev name:" , dev->name, -LIMIT_INFO ,"* fdt name:" , uc_pdata->name, +printf ("%s\n%-*s %s\n%-*s %s\n%-*s %s\n%-*s %s\n%-*s\n" , +"Regulator info:" , +LIMIT_INFO ,"* regulator-name:" , uc_pdata->name, +LIMIT_INFO ,"* device name:" , dev->name, +LIMIT_INFO ,"* parent name:" , dev->parent->name, +LIMIT_INFO ,"* parent uclass:" , parent_uc,LIMIT_INFO ,"* constraints:" );constraint (" - min uV:" , uc_pdata->min_uV,NULL );
@@ -206,10 +188,12 @@ static int do_status(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])struct udevice *dev;bool enabled; - ret =get_curr_dev_and_pl (&dev, &uc_pdata, true); + ret =curr_dev_and_platdata (&dev, &uc_pdata, true);if (ret)return ret; +printf ("Regulator %s status:\n" , uc_pdata->name); + enabled =regulator_get_enable (dev);constraint (" * enable:" , enabled, enabled ?"true" :"false" );
@@ -234,16 +218,19 @@ static int do_value(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])int force;int ret; - ret =get_curr_dev_and_pl (&dev, &uc_pdata, argc ==1 ); + ret =curr_dev_and_platdata (&dev, &uc_pdata, argc ==1 );if (ret)return ret;if (argc ==1 ) { - value =regulator_get_value (dev); -if (value <0 ) -return failed ("get" , uc_pdata->name,"voltage" , value); + ret =regulator_get_value (dev); +if (ret <0 ) { +printf ("Regulator: %s - can't get the Voltage!\n" , + uc_pdata->name); +return failure (ret); + } -printf ("%d uV\n" , value); +printf ("%d uV\n" , ret);return CMD_RET_SUCCESS ; }
@@ -259,8 +246,11 @@ static int do_value(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } ret =regulator_set_value (dev, value); -if (ret) -return failed ("set" , uc_pdata->name,"voltage value" , ret); +if (ret) { +printf ("Regulator: %s - can't set the Voltage!\n" , + uc_pdata->name); +return failure (ret); + }return CMD_RET_SUCCESS ; }
@@ -272,16 +262,19 @@ static int do_current(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])int current;int ret; - ret =get_curr_dev_and_pl (&dev, &uc_pdata, argc ==1 ); + ret =curr_dev_and_platdata (&dev, &uc_pdata, argc ==1 );if (ret)return ret;if (argc ==1 ) { - current =regulator_get_current (dev); -if (current <0 ) -return failed ("get" , uc_pdata->name,"current" , current); + ret =regulator_get_current (dev); +if (ret <0 ) { +printf ("Regulator: %s - can't get the Current!\n" , + uc_pdata->name); +return failure (ret); + } -printf ("%d uA\n" , current); +printf ("%d uA\n" , ret);return CMD_RET_SUCCESS ; }
@@ -292,8 +285,11 @@ static int do_current(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } ret =regulator_set_current (dev, current); -if (ret) -return failed ("set" , uc_pdata->name,"current value" , ret); +if (ret) { +printf ("Regulator: %s - can't set the Current!\n" , + uc_pdata->name); +return failure (ret); + }return CMD_RET_SUCCESS ; }
@@ -302,28 +298,33 @@ static int do_mode(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) {struct udevice *dev;struct dm_regulator_uclass_platdata *uc_pdata; -int new_mode;int mode;int ret; - ret =get_curr_dev_and_pl (&dev, &uc_pdata, false); + ret =curr_dev_and_platdata (&dev, &uc_pdata, false);if (ret)return ret;if (argc ==1 ) { - mode =regulator_get_mode (dev); -if (mode <0 ) -return failed ("get" , uc_pdata->name,"mode" , mode); + ret =regulator_get_mode (dev); +if (ret <0 ) { +printf ("Regulator: %s - can't get the operation mode!\n" , + uc_pdata->name); +return failure (ret); + } -printf ("mode id: %d\n" , mode); +printf ("mode id: %d\n" , ret);return CMD_RET_SUCCESS ; } - new_mode =simple_strtoul (argv[1 ],NULL ,0 ); + mode =simple_strtoul (argv[1 ],NULL ,0 ); - ret =regulator_set_mode (dev, new_mode); -if (ret) -return failed ("set" , uc_pdata->name,"mode" , ret); + ret =regulator_set_mode (dev, mode); +if (ret) { +printf ("Regulator: %s - can't set the operation mode!\n" , + uc_pdata->name); +return failure (ret); + }return CMD_RET_SUCCESS ; }
@@ -334,13 +335,15 @@ static int do_enable(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])struct dm_regulator_uclass_platdata *uc_pdata;int ret; - ret =get_curr_dev_and_pl (&dev, &uc_pdata, true); + ret =curr_dev_and_platdata (&dev, &uc_pdata, true);if (ret)return ret; ret =regulator_set_enable (dev, true); -if (ret) -return failed ("enable" ,"regulator" , uc_pdata->name, ret); +if (ret) { +printf ("Regulator: %s - can't enable!\n" , uc_pdata->name); +return failure (ret); + }return CMD_RET_SUCCESS ; }
@@ -351,13 +354,15 @@ static int do_disable(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])struct dm_regulator_uclass_platdata *uc_pdata;int ret; - ret =get_curr_dev_and_pl (&dev, &uc_pdata, true); + ret =curr_dev_and_platdata (&dev, &uc_pdata, true);if (ret)return ret; ret =regulator_set_enable (dev, false); -if (ret) -return failed ("disable" ,"regulator" , uc_pdata->name, ret); +if (ret) { +printf ("Regulator: %s - can't disable!\n" , uc_pdata->name); +return failure (ret); + }return CMD_RET_SUCCESS ; }
@@ -391,13 +396,13 @@ static int do_regulator(cmd_tbl_t *cmdtp, int flag, int argc,U_BOOT_CMD (regulator,CONFIG_SYS_MAXARGS ,1 , do_regulator,"uclass operations" , -"list - list UCLASS regulator devices\n" -"regulator dev [id] - show or [set] operating regulator device\n" -"regulator [info] - print constraints info\n" -"regulator [status] - print operating status\n" -"regulator [value] [-f] - print/[set] voltage value [uV] (force)\n" -"regulator [current] - print/[set] current value [uA]\n" -"regulator [mode_id] - print/[set] operating mode id\n" -"regulator [enable] - enable the regulator output\n" -"regulator [disable] - disable the regulator output\n" +"list - list UCLASS regulator devices\n" +"regulator dev [regulator-name] - show/[set] operating regulator device\n" +"regulator info - print constraints info\n" +"regulator status - print operating status\n" +"regulator value [val] [-f] - print/[set] voltage value [uV] (force)\n" +"regulator current [val] - print/[set] current value [uA]\n" +"regulator mode [id] - print/[set] operating mode id\n" +"regulator enable - enable the regulator output\n" +"regulator disable - disable the regulator output\n" );
Signature · 1 line
1.9.1
PATCH v2 6/13 common: cmd regulator: command cleanup
Quoted 13 lines · Przemyslaw Marczak
This commit cleanups the regulator command.
The first change, is adjusting "regulator dev" command to use "regulator-name" constraint, for setting the operating device. Thanks to this, theregulator_get()function is removed.This also updates
do_list()function, with loop over uclass_find_* function calls, to prevent probe of all listed regulators.This also cleanups the printing in command.
Signed-off-by Przemyslaw Marczak <[email protected]>Acked-by Simon Glass <[email protected]>Tested on sandbox:
Quoted 8 lines
Tested-by Simon Glass <[email protected]>---
Changes V2:
- none--- common/cmd_regulator.c | 239 +++++++++++++++++++++++++------------------------ 1 file changed, 122 insertions(+), 117 deletions(-)
Applied to u-boot-dm, thanks!
PATCH v2 7/13 doc: driver-model: pmic-framework.txt - cleanup
In reply to Przemyslaw MarczakThis commit cleanups the PMIC framework documentation.
Tested on sandbox:
---
Changes V2:
- none
--- doc/driver-model/pmic-framework.txt | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-)
doc/driver-model/pmic-framework.txt +9 -11
@@ -79,7 +79,7 @@ use pmic read/write directly. 3. Pmic uclass ============== -The basic informations: +The basic information: * Uclass: 'UCLASS_PMIC' * Header: 'include/power/pmic.h' * Core: 'drivers/power/pmic/pmic-uclass.c'
@@ -88,14 +88,13 @@ The basic informations: config: 'CONFIG_CMD_PMIC' * Example: 'drivers/power/pmic/max77686.c' -This is still under the construction. So for the API description, please refer -to the header file. +For detailed API description, please refer to the header file. As an example of the pmic driver, please refer to the MAX77686 driver. -Please pay attention for the driver's '.bind' method. Exactly the function call: -'pmic_bind_childs()', which is used to bind the regulators by using the array of -regulator's node, compatible prefixes. +Please pay attention for the driver's bind() method. Exactly the function call: +'pmic_bind_children()', which is used to bind the regulators by using the array +of regulator's node, compatible prefixes. The 'pmic; command also supports the new API. So the pmic command can be enabled by adding CONFIG_CMD_PMIC.
@@ -108,11 +107,11 @@ The new pmic command allows to: This command can use only UCLASS_PMIC devices, since this uclass is designed for pmic I/O operations only. -For more informations, please refer to the file: 'common/cmd_pmic.c'. +For more information, please refer to the core file. 4. Regulator uclass =================== -The basic informations: +The basic information: * Uclass: 'UCLASS_REGULATOR' * Header: 'include/power/regulator.h' * Core: 'drivers/power/regulator/regulator-uclass.c'
@@ -125,8 +124,7 @@ The basic informations: * Example: 'drivers/power/regulator/fixed.c' config" 'CONFIG_DM_REGULATOR_FIXED' -This is still under the construction. So for the API description, please refer -to the header file. +For detailed API description, please refer to the header file. For the example regulator driver, please refer to the MAX77686 regulator driver, but this driver can't operate without pmic's example driver, which provides an
@@ -139,4 +137,4 @@ The 'regulator' command also supports the new API. The command allow: - choose the current device (like the mmc command) - do all regulator-specific operations -For more informations, please refer to the file: 'common/cmd_regulator.c' +For more information, please refer to the command file.
Signature · 1 line
1.9.1
PATCH v2 7/13 doc: driver-model: pmic-framework.txt - cleanup
Quoted 9 lines · Przemyslaw Marczak
This commit cleanups the PMIC framework documentation.
Signed-off-by Przemyslaw Marczak <[email protected]>Acked-by Simon Glass <[email protected]>Tested on sandbox:
Tested-by Simon Glass <[email protected]>---
Changes V2:
- none
Applied to u-boot-dm, thanks!
PATCH v2 8/13 sandbox: i2c: search child emul dev and check its uclass id
In reply to Przemyslaw MarczakThe function get_emul() in sandbox i2c bus driver, always returns first child as i2c emul device. This may only work for i2c devices with a single child, which is an only i2c emul device.
In case when i2c device has more than one child (e.g. PMIC), and one is i2c emul, then the function should search it by check uclass id for each child. This patch add this change to the get_emul().
Tested on sandbox:
---
Changes V2:
- none
--- drivers/i2c/sandbox_i2c.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)
drivers/i2c/sandbox_i2c.c +17 -3
@@ -26,6 +26,7 @@ static int get_emul(struct udevice *dev, struct udevice **devp, struct dm_i2c_ops **opsp) {struct dm_i2c_chip *plat; +struct udevice *child;int ret; *devp =NULL ;
@@ -37,9 +38,22 @@ static int get_emul(struct udevice *dev, struct udevice **devp,if (ret)return ret; - ret =device_get_child (dev,0 , &plat->emul); -if (ret) -return ret; +for (device_find_first_child (dev, &child); child; +device_find_next_child (&child)) { +if (device_get_uclass_id (child) !=UCLASS_I2C_EMUL ) +continue ; + + ret =device_probe (child); +if (ret) +return ret; + +break ; + } + +if (child) + plat->emul = child; +else +return -ENODEV ; } *devp = plat->emul; *opsp =i2c_get_ops (plat->emul);
Signature · 1 line
1.9.1
PATCH v2 8/13 sandbox: i2c: search child emul dev and check its uclass id
Quoted 12 lines · Przemyslaw Marczak
The function
get_emul()in sandbox i2c bus driver, always returns first child as i2c emul device. This may only work for i2c devices with a single child, which is an only i2c emul device.In case when i2c device has more than one child (e.g. PMIC), and one is i2c emul, then the function should search it by check uclass id for each child. This patch add this change to the
get_emul().Signed-off-by Przemyslaw Marczak <[email protected]>Cc Simon Glass <[email protected]>Acked-by Simon Glass <[email protected]>Tested on sandbox:
Quoted 8 lines
Tested-by Simon Glass <[email protected]>---
Changes V2:
- none--- drivers/i2c/sandbox_i2c.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)
Applied to u-boot-dm, thanks!
PATCH v2 9/13 sandbox: add: sandbox PMIC device drivers: I2C emul, pmic, regulator
In reply to Przemyslaw MarczakThis commit adds emulation of sandbox PMIC device, which includes:
- PMIC I2C emulation driver
- PMIC I/O driver (UCLASS_PMIC)
- PMIC regulator driver (UCLASS_REGULATOR)
The sandbox PMIC has 12 significant registers and 4 as padding to 16 bytes, which allows using 'i2c md' command with the default count (16).
The sandbox PMIC provides regulators:
- 2x BUCK
- 2x LDO
Each, with adjustable output:
- Enable state
- Voltage
- Current limit (LDO1/BUCK1 only)
- Operation mode (different for BUCK and LDO)
Each attribute has it's own register, beside the enable state, which depends on operation mode.
The header file: sandbox_pmic.h includes PMIC's default register values, which are set on i2c pmic emul driver's probe() method.
Tested on sandbox:
---
Changes V2:
- pmic emul driver: get the default register settings from fdt
- cleanup of sandbox_pmic.h
--- doc/device-tree-bindings/pmic/sandbox.txt | 35 +++ doc/device-tree-bindings/regulator/sandbox.txt | 45 ++++ drivers/power/pmic/Kconfig | 25 ++ drivers/power/pmic/Makefile | 3 +- drivers/power/pmic/i2c_pmic_emul.c | 142 ++++++++++ drivers/power/pmic/sandbox.c | 79 ++++++ drivers/power/regulator/Kconfig | 30 +++ drivers/power/regulator/Makefile | 1 + drivers/power/regulator/sandbox.c | 355 +++++++++++++++++++++++++ include/power/sandbox_pmic.h | 105 ++++++++ 10 files changed, 819 insertions(+), 1 deletion(-) create mode 100644 doc/device-tree-bindings/pmic/sandbox.txt create mode 100644 doc/device-tree-bindings/regulator/sandbox.txt create mode 100644 drivers/power/pmic/i2c_pmic_emul.c create mode 100644 drivers/power/pmic/sandbox.c create mode 100644 drivers/power/regulator/sandbox.c create mode 100644 include/power/sandbox_pmic.h
doc/device-tree-bindings/pmic/sandbox.txt new file +35 -0
@@ -0,0 +1,35 @@ +Sandbox pmic + +This device uses two drivers: +- drivers/power/pmic/sandbox.c (for parent device) +- drivers/power/regulator/sandbox.c (for child regulators) + +This file describes the binding info for the PMIC driver. + +To bind the regulators, please read the regulator binding info: +- doc/device-tree-bindings/regulator/sandbox.txt + +Required PMIC node properties: +- compatible: "sandbox,pmic" +- reg = 0x40 + +Required PMIC's "emul" subnode, with property: +- compatible: "sandbox,i2c-pmic" + +With the above properties, the pmic device can be used for read/write only. +To bind each regulator, the optional regulator subnodes should exists. + +Optional subnodes: +- ldo/buck subnodes of each device's regulator (see regulator binding info) + +Example: + +sandbox_pmic { + compatible = "sandbox,pmic"; + reg = <0x40>; + + /* Mandatory for I/O */ + emul { + compatible = "sandbox,i2c-pmic"; + }; +};
doc/device-tree-bindings/regulator/sandbox.txt new file +45 -0
45 lines not on this page · raw message
drivers/power/pmic/Kconfig +25 -0
@@ -16,3 +16,28 @@ config DM_PMIC_MAX77686 ---help--- This config enables implementation of driver-model pmic uclass features for PMIC MAX77686. The driver implements read/write operations. + +config DM_PMIC_SANDBOX + bool "Enable Driver Model for emulated Sandbox PMIC " + depends on DM_PMIC + ---help--- + Enable the driver for Sandbox PMIC emulation. The emulated PMIC device + depends on two drivers: + - sandbox PMIC I/O driver - implements dm pmic operations + - sandbox PMIC i2c emul driver - emulates the PMIC's I2C transmission + + A detailed information can be found in header: '<power/sandbox_pmic.h>' + + The Sandbox PMIC info: + * I/O interface: + - I2C chip address: 0x40 + - first register address: 0x0 + - register count: 0x10 + * Adjustable outputs: + - 2x LDO + - 2x BUCK + - Each, with a different operating conditions (header). + * Reset values: + - set by i2c emul driver's probe() (defaults in header) + + Driver binding info: doc/device-tree-bindings/pmic/sandbox.txt
drivers/power/pmic/Makefile +2 -1
@@ -6,12 +6,13 @@ # obj-$(CONFIG_DM_PMIC) += pmic-uclass.o +obj-$(CONFIG_DM_PMIC_MAX77686) += max77686.o +obj-$(CONFIG_DM_PMIC_SANDBOX) += sandbox.o i2c_pmic_emul.o obj-$(CONFIG_POWER_LTC3676) += pmic_ltc3676.o obj-$(CONFIG_POWER_MAX8998) += pmic_max8998.o obj-$(CONFIG_POWER_MAX8997) += pmic_max8997.o obj-$(CONFIG_POWER_MUIC_MAX8997) += muic_max8997.o obj-$(CONFIG_POWER_MAX77686) += pmic_max77686.o -obj-$(CONFIG_DM_PMIC_MAX77686) += max77686.o obj-$(CONFIG_POWER_PFUZE100) += pmic_pfuze100.o obj-$(CONFIG_POWER_TPS65090_I2C) += pmic_tps65090.o obj-$(CONFIG_POWER_TPS65090_EC) += pmic_tps65090_ec.o
drivers/power/pmic/i2c_pmic_emul.c new file +142 -0
142 lines not on this page · raw message
drivers/power/pmic/sandbox.c new file +79 -0
79 lines not on this page · raw message
drivers/power/regulator/Kconfig +30 -0
@@ -31,3 +31,33 @@ config DM_REGULATOR_FIXED This config enables implementation of driver-model regulator uclass features for fixed value regulators. The driver implements get/set api for enable and get only for voltage value. + +config DM_REGULATOR_SANDBOX + bool "Enable Driver Model for Sandbox PMIC regulator" + depends on DM_REGULATOR && DM_PMIC_SANDBOX + ---help--- + Enable the regulator driver for emulated Sandbox PMIC. + The emulated PMIC device depends on two drivers: + - sandbox PMIC I/O driver - implements dm pmic operations + - sandbox PMIC regulator driver - implements dm regulator operations + - sandbox PMIC i2c emul driver - emulates the PMIC's I2C transmission + + The regulator driver provides uclass operations for sandbox PMIC's + regulators. The driver implements get/set api for: voltage, current, + operation mode and enable state. + The driver supports LDO and BUCK regulators. + + The Sandbox PMIC info: + * I/O interface: + - I2C chip address: 0x40 + - first register address: 0x0 + - register count: 0x10 + * Adjustable outputs: + - 2x LDO + - 2x BUCK + - Each, with a different operating conditions (header). + * Reset values: + - set by i2c emul driver's probe() (defaults in header) + + A detailed information can be found in header: '<power/sandbox_pmic.h>' + Binding info: 'doc/device-tree-bindings/pmic/max77686.txt'
drivers/power/regulator/Makefile +1 -0
@@ -8,3 +8,4 @@ obj-$(CONFIG_DM_REGULATOR) += regulator-uclass.o obj-$(CONFIG_DM_REGULATOR_MAX77686) += max77686.o obj-$(CONFIG_DM_REGULATOR_FIXED) += fixed.o +obj-$(CONFIG_DM_REGULATOR_SANDBOX) += sandbox.o
drivers/power/regulator/sandbox.c new file +355 -0
355 lines not on this page · raw message
include/power/sandbox_pmic.h new file +105 -0
105 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v2 9/13 sandbox: add: sandbox PMIC device drivers: I2C emul, pmic, regulator
Quoted 42 lines · Przemyslaw Marczak
This commit adds emulation of sandbox PMIC device, which includes:
- PMIC I2C emulation driver
- PMIC I/O driver (UCLASS_PMIC)
- PMIC regulator driver (UCLASS_REGULATOR)The sandbox PMIC has 12 significant registers and 4 as padding to 16 bytes, which allows using 'i2c md' command with the default count (16).
The sandbox PMIC provides regulators:
- 2x BUCK
- 2x LDOEach, with adjustable output:
- Enable state
- Voltage
- Current limit (LDO1/BUCK1 only)
- Operation mode (different for BUCK and LDO)Each attribute has it's own register, beside the enable state, which depends on operation mode.
The header file:
sandbox_pmic.hincludes PMIC's default register values, which are set on i2c pmic emul driver'sprobe()method.Signed-off-by Przemyslaw Marczak <[email protected]>Acked-by Simon Glass <[email protected]>Tested on sandbox:
Tested-by Simon Glass <[email protected]>---
Changes V2:
- pmic emul driver: get the default register settings from fdt
- cleanup ofsandbox_pmic.h--- doc/device-tree-bindings/pmic/sandbox.txt | 35 +++ doc/device-tree-bindings/regulator/sandbox.txt | 45 ++++ drivers/power/pmic/Kconfig | 25 ++ drivers/power/pmic/Makefile | 3 +- drivers/power/pmic/i2c_pmic_emul.c | 142 ++++++++++ drivers/power/pmic/sandbox.c | 79 ++++++ drivers/power/regulator/Kconfig | 30 +++ drivers/power/regulator/Makefile | 1 + drivers/power/regulator/sandbox.c | 355 +++++++++++++++++++++++++
Quoted 8 lines
include/power/sandbox_pmic.h | 105 ++++++++ 10 files changed, 819 insertions(+), 1 deletion(-) create mode 100644 doc/device-tree-bindings/pmic/sandbox.txt create mode 100644 doc/device-tree-bindings/regulator/sandbox.txt create mode 100644 drivers/power/pmic/i2c_pmic_emul.c create mode 100644 drivers/power/pmic/sandbox.c create mode 100644 drivers/power/regulator/sandbox.c create mode 100644 include/power/sandbox_pmic.h
Applied to u-boot-dm, thanks!
PATCH v2 10/13 test: dm: add sandbox PMIC framework tests
In reply to Przemyslaw MarczakThis change adds new file to sandbox driver model test environment. The file is: test/dm/power.c, and it includes tests for PMIC framework, which includes PMIC uclass and REGULATOR uclass.
All tests are based od Sandbox PMIC emulated device. Some test constants for this device are defined in the header: include/power/sandbox_pmic.h
PMIC tests includes:
- pmic get - tests, that pmic_get() returns the requested device
- pmic I/O - tests I/O by writing and reading some values to PMIC's registers and then compares, that the write/read values are equal.
The regulator tests includes:
- Regulator get by devname/platname
- Voltage set/get
- Current set/get
- Enable set/get
- Mode set/get
- Autoset
- List autoset
For the regulator 'get' test, the returned device pointers are compared, and their names are also compared to the requested one. Every other test, first sets the given attribute and next try to get it. The test pass, when the set/get values are equal.
Tested on sandbox:
---
Changes V2:
- test: dm: split power.c into pmic.c and regulator.c
- regulator tests: cleanup
--- include/power/sandbox_pmic.h | 33 +++++ test/dm/Makefile | 2 + test/dm/pmic.c | 69 +++++++++ test/dm/regulator.c | 325 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 429 insertions(+) create mode 100644 test/dm/pmic.c create mode 100644 test/dm/regulator.c
include/power/sandbox_pmic.h +33 -0
@@ -102,4 +102,37 @@ enum {/* Operation mode id -> register value conversion */ #define OM2REG (x) (x) +/* Test data for: test/dm/power.c */ + +/* BUCK names */ +#define SANDBOX_BUCK1_DEVNAME "buck1" +#define SANDBOX_BUCK1_PLATNAME "SUPPLY_1.2V" +#define SANDBOX_BUCK2_DEVNAME "buck2" +#define SANDBOX_BUCK2_PLATNAME "SUPPLY_3.3V" +/* LDO names */ +#define SANDBOX_LDO1_DEVNAME "ldo1" +#define SANDBOX_LDO1_PLATNAME "VDD_EMMC_1.8V" +#define SANDBOX_LDO2_DEVNAME "ldo2" +#define SANDBOX_LDO2_PLATNAME "VDD_LCD_3.3V" + +/* +* Expected regulators setup after call of: +* - regulator_autoset() +* - regulator_list_autoset() +*/ + +/* BUCK1: for testing regulator_autoset() */ +#define SANDBOX_BUCK1_AUTOSET_EXPECTED_UV 1200000 +#define SANDBOX_BUCK1_AUTOSET_EXPECTED_UA 200000 +#define SANDBOX_BUCK1_AUTOSET_EXPECTED_ENABLE true + +/* LDO1/2 for testing regulator_list_autoset() */ +#define SANDBOX_LDO1_AUTOSET_EXPECTED_UV 1800000 +#define SANDBOX_LDO1_AUTOSET_EXPECTED_UA 100000 +#define SANDBOX_LDO1_AUTOSET_EXPECTED_ENABLE true + +#define SANDBOX_LDO2_AUTOSET_EXPECTED_UV 3000000 +#define SANDBOX_LDO2_AUTOSET_EXPECTED_UA -ENOSYS +#define SANDBOX_LDO2_AUTOSET_EXPECTED_ENABLE false +#endif
test/dm/Makefile +2 -0
@@ -24,4 +24,6 @@ obj-$(CONFIG_DM_PCI) += pci.o obj-$(CONFIG_DM_SPI_FLASH) += sf.o obj-$(CONFIG_DM_SPI) += spi.o obj-$(CONFIG_DM_USB) += usb.o +obj-$(CONFIG_DM_PMIC) += pmic.o +obj-$(CONFIG_DM_REGULATOR) += regulator.o endif
test/dm/pmic.c new file +69 -0
69 lines not on this page · raw message
test/dm/regulator.c new file +325 -0
325 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v2 10/13 test: dm: add sandbox PMIC framework tests
Quoted 34 lines · Przemyslaw Marczak
This change adds new file to sandbox driver model test environment. The file is:
test/dm/power.c, and it includes tests for PMIC framework, which includes PMIC uclass and REGULATOR uclass.All tests are based od Sandbox PMIC emulated device. Some test constants for this device are defined in the header:
include/power/sandbox_pmic.hPMIC tests includes:
- pmic get - tests, thatpmic_get()returns the requested device
- pmic I/O - tests I/O by writing and reading some values to PMIC's registers and then compares, that the write/read values are equal.The regulator tests includes:
- Regulator get by devname/platname
- Voltage set/get
- Current set/get
- Enable set/get
- Mode set/get
- Autoset
- List autosetFor the regulator 'get' test, the returned device pointers are compared, and their names are also compared to the requested one. Every other test, first sets the given attribute and next try to get it. The test pass, when the set/get values are equal.
Signed-off-by Przemyslaw Marczak <[email protected]>Acked-by Simon Glass <[email protected]>Tested on sandbox:
Tested-by Simon Glass <[email protected]>---
Changes V2:
- test: dm: splitpower.cintopmic.candregulator.c
- regulator tests: cleanup
Quoted 8 lines
--- include/power/sandbox_pmic.h | 33 +++++ test/dm/Makefile | 2 + test/dm/pmic.c | 69 +++++++++ test/dm/regulator.c | 325 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 429 insertions(+) create mode 100644 test/dm/pmic.c create mode 100644 test/dm/regulator.c
Applied to u-boot-dm, thanks!
PATCH v2 11/13 test: dm: test.dts - move to sandbox dts directory
In reply to Przemyslaw MarczakThe file test.dts from driver model test directory, was compiled by call dtc in script: test/dm/test-dm.sh.
This doesn't allow for including of dtsi files and using of C preprocessor routines in this dts file.
Since the mentioned script builds U-Boot before tests, then moving the test.dts file into sandbox dts directory is reasonable.
Tested on sandbox:
---
Changes V2:
- new commit
--- arch/sandbox/dts/Makefile | 1 + arch/sandbox/dts/test.dts | 230 ++++++++++++++++++++++++++++++++++++++++++++++ test/dm/.gitignore | 1 - test/dm/test-dm.sh | 3 +- test/dm/test-main.c | 3 +- test/dm/test.dts | 230 ---------------------------------------------- 6 files changed, 233 insertions(+), 235 deletions(-) create mode 100644 arch/sandbox/dts/test.dts delete mode 100644 test/dm/.gitignore delete mode 100644 test/dm/test.dts
arch/sandbox/dts/Makefile +1 -0
@@ -1,4 +1,5 @@ dtb-$(CONFIG_SANDBOX) += sandbox.dtb +dtb-$(CONFIG_DM_TEST) += test.dtb targets += $(dtb-y)
arch/sandbox/dts/test.dts new file +230 -0
230 lines not on this page · raw message
test/dm/.gitignore deleted +0 -1
@@ -1 +0,0 @@ -/test.dtb
test/dm/test-dm.sh +1 -2
@@ -6,12 +6,11 @@ die() { } NUM_CPUS=$(cat /proc/cpuinfo |grep -c processor) -dtc -I dts -O dtb test/dm/test.dts -o test/dm/test.dtb make O=sandbox sandbox_config || die "Cannot configure U-Boot" make O=sandbox -s -j${NUM_CPUS} || die "Cannot build U-Boot" dd if=/dev/zero of=spi.bin bs=1M count=2 echo -n "this is a test" > testflash.bin dd if=/dev/zero bs=1M count=4 >>testflash.bin -./sandbox/u-boot -d test/dm/test.dtb -c "dm test" +./sandbox/u-boot -d ./sandbox/arch/sandbox/dts/test.dtb -c "dm test" rm spi.bin rm testflash.bin
test/dm/test-main.c +1 -2
@@ -78,8 +78,7 @@ int dm_test_main(const char *test_name)*/ if (!gd->fdt_blob ||fdt_next_node (gd->fdt_blob,0 ,NULL ) <0 ) {puts ("Please run with test device tree:\n" -" dtc -I dts -O dtb test/dm/test.dts -o test/dm/test.dtb\n" -" ./u-boot -d test/dm/test.dtb\n" ); +" ./u-boot -d arch/sandbox/dts/test.dtb\n" );ut_assert (gd->fdt_blob); }
test/dm/test.dts deleted +0 -230
230 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v2 11/13 test: dm: test.dts - move to sandbox dts directory
Quoted 17 lines · Przemyslaw Marczak
The file
test.dtsfrom driver model test directory, was compiled by call dtc in script:test/dm/test-dm.sh.This doesn't allow for including of dtsi files and using of C preprocessor routines in this dts file.
Since the mentioned script builds U-Boot before tests, then moving the
test.dtsfile into sandbox dts directory is reasonable.Signed-off-by Przemyslaw Marczak <[email protected]>Acked-by Simon Glass <[email protected]>Tested on sandbox:
Tested-by Simon Glass <[email protected]>---
Changes V2:
- new commit
Quoted 11 lines
--- arch/sandbox/dts/Makefile | 1 + arch/sandbox/dts/test.dts | 230 ++++++++++++++++++++++++++++++++++++++++++++++ test/dm/.gitignore | 1 - test/dm/test-dm.sh | 3 +- test/dm/test-main.c | 3 +- test/dm/test.dts | 230 ---------------------------------------------- 6 files changed, 233 insertions(+), 235 deletions(-) create mode 100644 arch/sandbox/dts/test.dts delete mode 100644 test/dm/.gitignore delete mode 100644 test/dm/test.dts
Applied to u-boot-dm, thanks!
PATCH v2 11/13 test: dm: test.dts - move to sandbox dts directory
Hi Simon,
Quoted 30 lines · Simon Glass
Quoted 17 lines · Przemyslaw Marczak
The file
test.dtsfrom driver model test directory, was compiled by call dtc in script:test/dm/test-dm.sh.This doesn't allow for including of dtsi files and using of C preprocessor routines in this dts file.
Since the mentioned script builds U-Boot before tests, then moving the
test.dtsfile into sandbox dts directory is reasonable.Signed-off-by Przemyslaw Marczak <[email protected]>Acked-by Simon Glass <[email protected]>Tested on sandbox:
Tested-by Simon Glass <[email protected]>---
Changes V2:
- new commitQuoted 11 lines
--- arch/sandbox/dts/Makefile | 1 + arch/sandbox/dts/test.dts | 230 ++++++++++++++++++++++++++++++++++++++++++++++ test/dm/.gitignore | 1 - test/dm/test-dm.sh | 3 +- test/dm/test-main.c | 3 +- test/dm/test.dts | 230 ---------------------------------------------- 6 files changed, 233 insertions(+), 235 deletions(-) create mode 100644 arch/sandbox/dts/test.dts delete mode 100644 test/dm/.gitignore delete mode 100644 test/dm/test.dts
Quoted 1 line
Applied to u-boot-dm, thanks!
This patch effectively reverted fbe07ba0f: dm: test: dts: Sort the aliases in the test device tree file
It seems this file was moved before other patches went in and never updated. Maybe there are other merge-conflict resolution errors?
Cheers,
-Joe
PATCH v2 11/13 test: dm: test.dts - move to sandbox dts directory
Hi Simon,
Quoted 33 lines · Joe Hershberger
Hi Simon,
Quoted 30 lines · Simon Glass
Quoted 28 lines · Przemyslaw Marczak
The file
test.dtsfrom driver model test directory, was compiled by call dtc in script:test/dm/test-dm.sh.This doesn't allow for including of dtsi files and using of C preprocessor routines in this dts file.
Since the mentioned script builds U-Boot before tests, then moving the
test.dtsfile into sandbox dts directory is reasonable.Signed-off-by Przemyslaw Marczak <[email protected]>Acked-by Simon Glass <[email protected]>Tested on sandbox:
Tested-by Simon Glass <[email protected]>---
Changes V2:
- new commit--- arch/sandbox/dts/Makefile | 1 + arch/sandbox/dts/test.dts | 230 ++++++++++++++++++++++++++++++++++++++++++++++ test/dm/.gitignore | 1 - test/dm/test-dm.sh | 3 +- test/dm/test-main.c | 3 +- test/dm/test.dts | 230 ---------------------------------------------- 6 files changed, 233 insertions(+), 235 deletions(-) create mode 100644 arch/sandbox/dts/test.dts delete mode 100644 test/dm/.gitignore delete mode 100644 test/dm/test.dts
Quoted 7 lines
Quoted 1 line
Applied to u-boot-dm, thanks!
This patch effectively reverted
fbe07ba0f: dm: test: dts: Sort the aliases in the test device tree fileIt seems this file was moved before other patches went in and never updated. Maybe there are other merge-conflict resolution errors?
Ah yes... it also reverted 4772511: dm: rtc: Add tests for real-time clocks
Cheers,
-Joe
PATCH v2 11/13 test: dm: test.dts - move to sandbox dts directory
Hi Joe,
Quoted 40 lines · Joe Hershberger
Hi Simon,
Quoted 35 lines · Joe Hershberger
Hi Simon,
Quoted 31 lines · Simon Glass
Quoted 17 lines · Przemyslaw Marczak
The file
test.dtsfrom driver model test directory, was compiled by call dtc in script:test/dm/test-dm.sh.This doesn't allow for including of dtsi files and using of C preprocessor routines in this dts file.
Since the mentioned script builds U-Boot before tests, then moving the
test.dtsfile into sandbox dts directory is reasonable.Signed-off-by Przemyslaw Marczak <[email protected]>Acked-by Simon Glass <[email protected]>Tested on sandbox:
Tested-by Simon Glass <[email protected]>---
Changes V2:
- new commitQuoted 11 lines
--- arch/sandbox/dts/Makefile | 1 + arch/sandbox/dts/test.dts | 230 ++++++++++++++++++++++++++++++++++++++++++++++ test/dm/.gitignore | 1 - test/dm/test-dm.sh | 3 +- test/dm/test-main.c | 3 +- test/dm/test.dts | 230 ---------------------------------------------- 6 files changed, 233 insertions(+), 235 deletions(-) create mode 100644 arch/sandbox/dts/test.dts delete mode 100644 test/dm/.gitignore delete mode 100644 test/dm/test.dtsApplied to u-boot-dm, thanks!
Quoted 7 lines
Quoted 5 lines
This patch effectively reverted
fbe07ba0f: dm: test: dts: Sort the aliases in the test device tree fileIt seems this file was moved before other patches went in and never updated. Maybe there are other merge-conflict resolution errors?
Ah yes... it also reverted 4772511: dm: rtc: Add tests for real-time clocks
Thanks for spotting that.
There was another one in uclass-ids.h for which I have a patch sitting behind various other work. But I'll see if I can get something out sooner.
Regards,
Simon
PATCH v2 11/13 test: dm: test.dts - move to sandbox dts directory
Hi Joe, Simon,
Quoted 51 lines · Simon Glass
Hi Joe,
Quoted 40 lines · Joe Hershberger
Hi Simon,
Quoted 35 lines · Joe Hershberger
Hi Simon,
Quoted 31 lines · Simon Glass
Quoted 25 lines · Przemyslaw Marczak
The file
test.dtsfrom driver model test directory, was compiled by call dtc in script:test/dm/test-dm.sh.This doesn't allow for including of dtsi files and using of C preprocessor routines in this dts file.
Since the mentioned script builds U-Boot before tests, then moving the
test.dtsfile into sandbox dts directory is reasonable.Signed-off-by Przemyslaw Marczak <[email protected]>Acked-by Simon Glass <[email protected]>Tested on sandbox:
Tested-by Simon Glass <[email protected]>---
Changes V2:
- new commit--- arch/sandbox/dts/Makefile | 1 + arch/sandbox/dts/test.dts | 230 ++++++++++++++++++++++++++++++++++++++++++++++ test/dm/.gitignore | 1 - test/dm/test-dm.sh | 3 +- test/dm/test-main.c | 3 +- test/dm/test.dts | 230 ---------------------------------------------- 6 files changed, 233 insertions(+), 235 deletions(-)Quoted 3 lines
create mode 100644
arch/sandbox/dts/test.dtsdelete mode 100644 test/dm/.gitignore
delete mode 100644test/dm/test.dtsApplied to u-boot-dm, thanks!
Quoted 7 lines
Quoted 5 lines
This patch effectively reverted
fbe07ba0f: dm: test: dts: Sort the aliases in the test device tree fileIt seems this file was moved before other patches went in and never updated. Maybe there are other merge-conflict resolution errors?
Ah yes... it also reverted 4772511: dm: rtc: Add tests for real-time clocks
Quoted 9 lines
Thanks for spotting that.
There was another one in
uclass-ids.hfor which I have a patch sitting behind various other work. But I'll see if I can get something out sooner.Regards,
Simon
Ooops...
I thought, that I should use the 'next' branch, when I made a rebase of those patches, but I mentioned about this in the cover letter message.
Will check such things better for the future.
Thanks for checking that!
Best regards,
Signature · 4 lines
Przemyslaw Marczak Samsung R&D Institute Poland Samsung Electronics p.marczak at samsung.com
PATCH v2 11/13 test: dm: test.dts - move to sandbox dts directory
Quoted 79 lines · Przemyslaw Marczak
Hi Joe, Simon,
Quoted 65 lines · Simon Glass
Hi Joe,
Quoted 52 lines · Joe Hershberger
Hi Simon,
Quoted 46 lines · Joe Hershberger
Hi Simon,
Quoted 36 lines · Simon Glass
Quoted 28 lines · Przemyslaw Marczak
The file
test.dtsfrom driver model test directory, was compiled by call dtc in script:test/dm/test-dm.sh.This doesn't allow for including of dtsi files and using of C preprocessor routines in this dts file.
Since the mentioned script builds U-Boot before tests, then moving the
test.dtsfile into sandbox dts directory is reasonable.Signed-off-by Przemyslaw Marczak <[email protected]>Acked-by Simon Glass <[email protected]>Tested on sandbox:
Tested-by Simon Glass <[email protected]>---
Changes V2:
- new commit--- arch/sandbox/dts/Makefile | 1 + arch/sandbox/dts/test.dts | 230 ++++++++++++++++++++++++++++++++++++++++++++++ test/dm/.gitignore | 1 - test/dm/test-dm.sh | 3 +- test/dm/test-main.c | 3 +- test/dm/test.dts | 230 ---------------------------------------------- 6 files changed, 233 insertions(+), 235 deletions(-)Quoted 3 lines
create mode 100644
arch/sandbox/dts/test.dtsdelete mode 100644 test/dm/.gitignore
delete mode 100644test/dm/test.dtsQuoted 1 line
Applied to u-boot-dm, thanks!
This patch effectively reverted
fbe07ba0f: dm: test: dts: Sort the aliases in the test device tree fileQuoted 6 lines
Quoted 2 lines
It seems this file was moved before other patches went in and never updated. Maybe there are other merge-conflict resolution errors?
Ah yes... it also reverted 4772511: dm: rtc: Add tests for real-time clocks
Quoted 9 lines
Thanks for spotting that.
There was another one in
uclass-ids.hfor which I have a patch sitting behind various other work. But I'll see if I can get something out sooner.Regards,
Simon
Quoted 7 lines
Ooops...
I thought, that I should use the 'next' branch, when I made a rebase of those patches, but I mentioned about this in the cover letter message.Will check such things better for the future.
Thanks for checking that!
That was my fault. I did several rebases of the /next branch but did not do one right at the end. I've sent a few patches to tidy it up.
Regards,
Simon
PATCH v2 12/13 sandbox: dts: add sandbox_pmic.dtsi and include it to sandbox.dts and test.dts
In reply to Przemyslaw MarczakThis commit adds dtsi file for Sandbox PMIC.
It fully describes the PMIC by:
- i2c emul node - with a default settings of 16 registers
- 2x buck regulator nodes
- 2x ldo regulator nodes
The default register settings are set with preprocessor macros:
- VAL2REG(min[uV/uA], step[uV/uA], val[uV/uA])
- VAL2OMREG(mode id)
Both defined in file:
- include/dt-bindings/pmic/sandbox_pmic.h
The Voltage ranges of each regulator can be found in:
- include/power/sandbox_pmic.h
The new file is included into:
- sandbox.dts
- test.dts
Tested on sandbox:
---
Changes V2:
- move sandbox PMIC node into sandbox_pmic.dtsi
- add sandbox_pmic.h into dt-bindings directory
- add pmic node to: sandbox.dts and test.dts
--- arch/sandbox/dts/sandbox.dts | 4 ++ arch/sandbox/dts/sandbox_pmic.dtsi | 78 +++++++++++++++++++++++++++++++++ arch/sandbox/dts/test.dts | 6 +++ include/dt-bindings/pmic/sandbox_pmic.h | 35 +++++++++++++++ 4 files changed, 123 insertions(+) create mode 100644 arch/sandbox/dts/sandbox_pmic.dtsi create mode 100644 include/dt-bindings/pmic/sandbox_pmic.h
arch/sandbox/dts/sandbox.dts +4 -0
@@ -105,6 +105,9 @@ sandbox,size = <128>; }; }; + sandbox_pmic: sandbox_pmic { + reg = <0x40>; + }; }; spi at 0 {
@@ -195,3 +198,4 @@ }; #include "cros-ec-keyboard.dtsi" +#include "sandbox_pmic.dtsi"
arch/sandbox/dts/sandbox_pmic.dtsi new file +78 -0
78 lines not on this page · raw message
arch/sandbox/dts/test.dts +6 -0
@@ -139,6 +139,10 @@ sandbox,size = <256>; }; }; + + sandbox_pmic: sandbox_pmic { + reg = <0x40>; + }; }; pci: pci-controller {
@@ -228,3 +232,5 @@ }; }; + +#include "sandbox_pmic.dtsi"
include/dt-bindings/pmic/sandbox_pmic.h new file +35 -0
@@ -0,0 +1,35 @@ +/* +* Copyright (C) 2015 Samsung Electronics +* Przemyslaw Marczak <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#ifndef _DT_BINDINGS_SANDBOX_PMIC_H_ +#define _DT_BINDINGS_SANDBOX_PMIC_H_ + +/* +* Sandbox PMIC - prepare reset values +* To provide the default (reset) values as in the real hardware, +* the registers are set in i2c pmic emul driver's probe() method. +* The default values are defined as below. +*/ + +/* Buck operation mode IDs */ +#define BUCK_OM_OFF 0 +#define BUCK_OM_ON 1 +#define BUCK_OM_PWM 2 +#define BUCK_OM_COUNT 3 + +/* Ldo operation mode IDs */ +#define LDO_OM_OFF 0 +#define LDO_OM_ON 1 +#define LDO_OM_SLEEP 2 +#define LDO_OM_STANDBY 3 +#define LDO_OM_COUNT 4 + +/* [Value uV/uA]/[Mode ID] to register */ +#define VAL2REG (min, step, val) (((val) - (min)) / (step)) +#define VAL2OMREG (x) (x) + +#endif
Signature · 1 line
1.9.1
PATCH v2 12/13 sandbox: dts: add sandbox_pmic.dtsi and include it to sandbox.dts and test.dts
Quoted 28 lines · Przemyslaw Marczak
This commit adds dtsi file for Sandbox PMIC.
It fully describes the PMIC by:
- i2c emul node - with a default settings of 16 registers
- 2x buck regulator nodes
- 2x ldo regulator nodesThe default register settings are set with preprocessor macros:
-VAL2REG(min[uV/uA], step[uV/uA], val[uV/uA])
- VAL2OMREG(mode id)
Both defined in file:
-include/dt-bindings/pmic/sandbox_pmic.hThe Voltage ranges of each regulator can be found in:
-include/power/sandbox_pmic.hThe new file is included into:
-sandbox.dts
-test.dtsSigned-off-by Przemyslaw Marczak <[email protected]>Acked-by Simon Glass <[email protected]>Tested on sandbox:
Tested-by Simon Glass <[email protected]>---
Changes V2:
- move sandbox PMIC node intosandbox_pmic.dtsi
- addsandbox_pmic.hinto dt-bindings directory
- add pmic node to:sandbox.dtsandtest.dts
Quoted 8 lines
--- arch/sandbox/dts/sandbox.dts | 4 ++ arch/sandbox/dts/sandbox_pmic.dtsi | 78 +++++++++++++++++++++++++++++++++ arch/sandbox/dts/test.dts | 6 +++ include/dt-bindings/pmic/sandbox_pmic.h | 35 +++++++++++++++ 4 files changed, 123 insertions(+) create mode 100644 arch/sandbox/dts/sandbox_pmic.dtsi create mode 100644 include/dt-bindings/pmic/sandbox_pmic.h
Applied to u-boot-dm, thanks!
PATCH v2 13/13 sandbox: defconfig: enable support of sandbox PMIC drivers
In reply to Przemyslaw MarczakThis commit enables:
- emulated i2c PMIC driver
- sandbox PMIC I/O driver
- sandbox PMIC's regulator driver
Tested on sandbox:
---
Changes V2:
- none
--- configs/sandbox_defconfig | 7 +++++++ 1 file changed, 7 insertions(+)
configs/sandbox_defconfig +7 -0
@@ -26,3 +26,10 @@ CONFIG_TPM_TIS_SANDBOX=y CONFIG_SOUND=y CONFIG_CMD_SOUND=y CONFIG_SOUND_SANDBOX=y +CONFIG_ERRNO_STR=y +CONFIG_DM_PMIC=y +CONFIG_DM_PMIC_SANDBOX=y +CONFIG_CMD_PMIC=y +CONFIG_DM_REGULATOR=y +CONFIG_DM_REGULATOR_SANDBOX=y +CONFIG_CMD_REGULATOR=y
Signature · 1 line
1.9.1
PATCH v2 13/13 sandbox: defconfig: enable support of sandbox PMIC drivers
Quoted 8 lines · Przemyslaw Marczak
This commit enables:
- emulated i2c PMIC driver
- sandbox PMIC I/O driver
- sandbox PMIC's regulator driverSigned-off-by Przemyslaw Marczak <[email protected]>Acked-by Simon Glass <[email protected]>Tested on sandbox:
Quoted 8 lines
Tested-by Simon Glass <[email protected]>---
Changes V2:
- none--- configs/sandbox_defconfig | 7 +++++++ 1 file changed, 7 insertions(+)
Applied to u-boot-dm, thanks!
v2 cover PMIC/REGULATOR cleanup and Sandbox tests
In reply to Przemyslaw MarczakQuoted 81 lines · Przemyslaw Marczak
Hello Simon,
This patchset fixes the build issues. It changes the last three top commits of u-boot-dm/next. So it is rebased onto:
4e9a6eb dm: board:samsung:power_init_board: add requirement ofCONFIG_DM_PMICThe rebased version, can be fetched from:
https://github.com/bobenstein/u-boot.git
branch: dm-pmic-v5-sandboxBest regards,
Przemyslaw MarczakPrzemyslaw Marczak (13):
odroid: dts: add 'voltage-regulators' description to max77686 node
odroid: enable driver model pmic/regulator API and MAX77686 drivers
dm: pmic: code cleanup of PMIC uclass driver
dm: regulator: uclass driver code cleanup
common: cmd pmic: command cleanup
common: cmd regulator: command cleanup
doc: driver-model: pmic-framework.txt - cleanup
sandbox: i2c: search child emul dev and check its uclass id
sandbox: add: sandbox PMIC device drivers: I2C emul, pmic, regulator
test: dm: add sandbox PMIC framework tests
test: dm:test.dts- move to sandbox dts directory
sandbox: dts: addsandbox_pmic.dtsiand include it tosandbox.dtsand
test.dts
sandbox: defconfig: enable support of sandbox PMIC driversarch/arm/dts/exynos4412-odroid.dts | 253 ++++++++++++++++++ arch/sandbox/dts/Makefile | 1 + arch/sandbox/dts/sandbox.dts | 4 + arch/sandbox/dts/sandbox_pmic.dtsi | 78 ++++++ arch/sandbox/dts/test.dts | 236 ++++++++++++++++ board/samsung/common/misc.c | 1 + board/samsung/odroid/odroid.c | 76 +++--- common/cmd_pmic.c | 131 ++++----- common/cmd_regulator.c | 239 +++++++++-------- configs/odroid_defconfig | 8 +- configs/sandbox_defconfig | 7 + doc/device-tree-bindings/pmic/sandbox.txt | 35 +++ doc/device-tree-bindings/regulator/sandbox.txt | 45 ++++ doc/driver-model/pmic-framework.txt | 20 +- drivers/i2c/sandbox_i2c.c | 20 +- drivers/power/pmic/Kconfig | 27 +- drivers/power/pmic/Makefile | 3 +- drivers/power/pmic/i2c_pmic_emul.c | 142 ++++++++++ drivers/power/pmic/max77686.c | 15 +- drivers/power/pmic/pmic-uclass.c | 31 +-- drivers/power/pmic/sandbox.c | 79 ++++++ drivers/power/regulator/Kconfig | 32 ++- drivers/power/regulator/Makefile | 1 + drivers/power/regulator/regulator-uclass.c | 104 +++++--- drivers/power/regulator/sandbox.c | 355 +++++++++++++++++++++++++ include/configs/odroid.h | 5 - include/dt-bindings/pmic/sandbox_pmic.h | 35 +++ include/power/pmic.h | 39 +-- include/power/regulator.h | 116 ++++---- include/power/sandbox_pmic.h | 138 ++++++++++ test/dm/.gitignore | 1 - test/dm/Makefile | 2 + test/dm/pmic.c | 69 +++++ test/dm/regulator.c | 325 ++++++++++++++++++++++ test/dm/test-dm.sh | 3 +- test/dm/test-main.c | 3 +- test/dm/test.dts | 230 ---------------- 37 files changed, 2287 insertions(+), 622 deletions(-) create mode 100644 arch/sandbox/dts/sandbox_pmic.dtsi create mode 100644 arch/sandbox/dts/test.dts create mode 100644 doc/device-tree-bindings/pmic/sandbox.txt create mode 100644 doc/device-tree-bindings/regulator/sandbox.txt create mode 100644 drivers/power/pmic/i2c_pmic_emul.c create mode 100644 drivers/power/pmic/sandbox.c create mode 100644 drivers/power/regulator/sandbox.c create mode 100644 include/dt-bindings/pmic/sandbox_pmic.h create mode 100644 include/power/sandbox_pmic.h delete mode 100644 test/dm/.gitignore create mode 100644 test/dm/pmic.c create mode 100644 test/dm/regulator.c delete mode 100644 test/dm/test.dts
Quoted 3 lines
--
1.9.1
I've pulled this in from u-boot-dm/next to master.
- Simon
v2 cover PMIC/REGULATOR cleanup and Sandbox tests
Hello Simon,
Quoted 82 lines · Simon Glass
Quoted 81 lines · Przemyslaw Marczak
Hello Simon,
This patchset fixes the build issues. It changes the last three top commits of u-boot-dm/next. So it is rebased onto:
4e9a6eb dm: board:samsung:power_init_board: add requirement ofCONFIG_DM_PMICThe rebased version, can be fetched from:
https://github.com/bobenstein/u-boot.git
branch: dm-pmic-v5-sandboxBest regards,
Przemyslaw MarczakPrzemyslaw Marczak (13):
odroid: dts: add 'voltage-regulators' description to max77686 node
odroid: enable driver model pmic/regulator API and MAX77686 drivers
dm: pmic: code cleanup of PMIC uclass driver
dm: regulator: uclass driver code cleanup
common: cmd pmic: command cleanup
common: cmd regulator: command cleanup
doc: driver-model: pmic-framework.txt - cleanup
sandbox: i2c: search child emul dev and check its uclass id
sandbox: add: sandbox PMIC device drivers: I2C emul, pmic, regulator
test: dm: add sandbox PMIC framework tests
test: dm:test.dts- move to sandbox dts directory
sandbox: dts: addsandbox_pmic.dtsiand include it tosandbox.dtsand
test.dts
sandbox: defconfig: enable support of sandbox PMIC driversarch/arm/dts/exynos4412-odroid.dts | 253 ++++++++++++++++++ arch/sandbox/dts/Makefile | 1 + arch/sandbox/dts/sandbox.dts | 4 + arch/sandbox/dts/sandbox_pmic.dtsi | 78 ++++++ arch/sandbox/dts/test.dts | 236 ++++++++++++++++ board/samsung/common/misc.c | 1 + board/samsung/odroid/odroid.c | 76 +++--- common/cmd_pmic.c | 131 ++++----- common/cmd_regulator.c | 239 +++++++++-------- configs/odroid_defconfig | 8 +- configs/sandbox_defconfig | 7 + doc/device-tree-bindings/pmic/sandbox.txt | 35 +++ doc/device-tree-bindings/regulator/sandbox.txt | 45 ++++ doc/driver-model/pmic-framework.txt | 20 +- drivers/i2c/sandbox_i2c.c | 20 +- drivers/power/pmic/Kconfig | 27 +- drivers/power/pmic/Makefile | 3 +- drivers/power/pmic/i2c_pmic_emul.c | 142 ++++++++++ drivers/power/pmic/max77686.c | 15 +- drivers/power/pmic/pmic-uclass.c | 31 +-- drivers/power/pmic/sandbox.c | 79 ++++++ drivers/power/regulator/Kconfig | 32 ++- drivers/power/regulator/Makefile | 1 + drivers/power/regulator/regulator-uclass.c | 104 +++++--- drivers/power/regulator/sandbox.c | 355 +++++++++++++++++++++++++ include/configs/odroid.h | 5 - include/dt-bindings/pmic/sandbox_pmic.h | 35 +++ include/power/pmic.h | 39 +-- include/power/regulator.h | 116 ++++---- include/power/sandbox_pmic.h | 138 ++++++++++ test/dm/.gitignore | 1 - test/dm/Makefile | 2 + test/dm/pmic.c | 69 +++++ test/dm/regulator.c | 325 ++++++++++++++++++++++ test/dm/test-dm.sh | 3 +- test/dm/test-main.c | 3 +- test/dm/test.dts | 230 ---------------- 37 files changed, 2287 insertions(+), 622 deletions(-)create mode 100644
arch/sandbox/dts/sandbox_pmic.dtsicreate mode 100644arch/sandbox/dts/test.dts
create mode 100644doc/device-tree-bindings/pmic/sandbox.txtcreate mode 100644doc/device-tree-bindings/regulator/sandbox.txtcreate mode 100644drivers/power/pmic/i2c_pmic_emul.ccreate mode 100644drivers/power/pmic/sandbox.c
create mode 100644drivers/power/regulator/sandbox.ccreate mode 100644include/dt-bindings/pmic/sandbox_pmic.hcreate mode 100644include/power/sandbox_pmic.h
delete mode 100644 test/dm/.gitignore
create mode 100644test/dm/pmic.c
create mode 100644test/dm/regulator.c
delete mode 100644test/dm/test.dts
Quoted 8 lines
Quoted 3 lines
--
1.9.1I've pulled this in from u-boot-dm/next to master.
- Simon
Thank you, this is great information!
And also thank you for the review of all the versions.
Best regards,
Signature · 4 lines
Przemyslaw Marczak Samsung R&D Institute Poland Samsung Electronics p.marczak at samsung.com
v2 cover PMIC/REGULATOR cleanup and Sandbox tests
Hi Przemyslaw,
Quoted 95 lines · Przemyslaw Marczak
Hello Simon,
Quoted 91 lines · Simon Glass
Quoted 88 lines · Przemyslaw Marczak
Hello Simon,
This patchset fixes the build issues. It changes the last three top commits of u-boot-dm/next. So it is rebased onto:
4e9a6eb dm: board:samsung:power_init_board: add requirement ofCONFIG_DM_PMICThe rebased version, can be fetched from:
https://github.com/bobenstein/u-boot.git
branch: dm-pmic-v5-sandboxBest regards,
Przemyslaw MarczakPrzemyslaw Marczak (13):
odroid: dts: add 'voltage-regulators' description to max77686 node
odroid: enable driver model pmic/regulator API and MAX77686 drivers
dm: pmic: code cleanup of PMIC uclass driver
dm: regulator: uclass driver code cleanup
common: cmd pmic: command cleanup
common: cmd regulator: command cleanup
doc: driver-model: pmic-framework.txt - cleanup
sandbox: i2c: search child emul dev and check its uclass id
sandbox: add: sandbox PMIC device drivers: I2C emul, pmic, regulator
test: dm: add sandbox PMIC framework tests
test: dm:test.dts- move to sandbox dts directory
sandbox: dts: addsandbox_pmic.dtsiand include it tosandbox.dtsand
test.dts
sandbox: defconfig: enable support of sandbox PMIC driversarch/arm/dts/exynos4412-odroid.dts | 253 ++++++++++++++++++ arch/sandbox/dts/Makefile | 1 + arch/sandbox/dts/sandbox.dts | 4 + arch/sandbox/dts/sandbox_pmic.dtsi | 78 ++++++ arch/sandbox/dts/test.dts | 236 ++++++++++++++++ board/samsung/common/misc.c | 1 + board/samsung/odroid/odroid.c | 76 +++--- common/cmd_pmic.c | 131 ++++----- common/cmd_regulator.c | 239 +++++++++-------- configs/odroid_defconfig | 8 +- configs/sandbox_defconfig | 7 + doc/device-tree-bindings/pmic/sandbox.txt | 35 +++ doc/device-tree-bindings/regulator/sandbox.txt | 45 ++++ doc/driver-model/pmic-framework.txt | 20 +- drivers/i2c/sandbox_i2c.c | 20 +- drivers/power/pmic/Kconfig | 27 +- drivers/power/pmic/Makefile | 3 +- drivers/power/pmic/i2c_pmic_emul.c | 142 ++++++++++ drivers/power/pmic/max77686.c | 15 +- drivers/power/pmic/pmic-uclass.c | 31 +-- drivers/power/pmic/sandbox.c | 79 ++++++ drivers/power/regulator/Kconfig | 32 ++- drivers/power/regulator/Makefile | 1 + drivers/power/regulator/regulator-uclass.c | 104 +++++--- drivers/power/regulator/sandbox.c | 355 +++++++++++++++++++++++++ include/configs/odroid.h | 5 - include/dt-bindings/pmic/sandbox_pmic.h | 35 +++ include/power/pmic.h | 39 +-- include/power/regulator.h | 116 ++++---- include/power/sandbox_pmic.h | 138 ++++++++++ test/dm/.gitignore | 1 - test/dm/Makefile | 2 + test/dm/pmic.c | 69 +++++ test/dm/regulator.c | 325 ++++++++++++++++++++++ test/dm/test-dm.sh | 3 +- test/dm/test-main.c | 3 +- test/dm/test.dts | 230 ---------------- 37 files changed, 2287 insertions(+), 622 deletions(-)create mode 100644
arch/sandbox/dts/sandbox_pmic.dtsicreate mode 100644arch/sandbox/dts/test.dts
create mode 100644doc/device-tree-bindings/pmic/sandbox.txtcreate mode 100644doc/device-tree-bindings/regulator/sandbox.txtcreate mode 100644drivers/power/pmic/i2c_pmic_emul.ccreate mode 100644drivers/power/pmic/sandbox.c
create mode 100644drivers/power/regulator/sandbox.ccreate mode 100644include/dt-bindings/pmic/sandbox_pmic.hcreate mode 100644include/power/sandbox_pmic.h
delete mode 100644 test/dm/.gitignore
create mode 100644test/dm/pmic.c
create mode 100644test/dm/regulator.c
delete mode 100644test/dm/test.dts--
1.9.1
Quoted 7 lines
Quoted 4 lines
I've pulled this in from u-boot-dm/next to master.
- Simon
Thank you, this is great information!
And also thank you for the review of all the versions.
No problem - congratulations on getting this major piece of work into mainline. I'll see if I can try it out for another SOC.
Regards,
Simon