From patchwork Tue Mar 3 16:24:35 2015
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Przemyslaw Marczak
X-Patchwork-Id: 445786
X-Patchwork-Delegate: sjg@chromium.org
Return-Path:
X-Original-To: incoming@patchwork.ozlabs.org
Delivered-To: patchwork-incoming@bilbo.ozlabs.org
Received: from theia.denx.de (theia.denx.de [85.214.87.163])
by ozlabs.org (Postfix) with ESMTP id CE6F8140082
for ;
Wed, 4 Mar 2015 03:26:44 +1100 (AEDT)
Received: from localhost (localhost [127.0.0.1])
by theia.denx.de (Postfix) with ESMTP id E2AEC4B61D;
Tue, 3 Mar 2015 17:26:24 +0100 (CET)
Received: from theia.denx.de ([127.0.0.1])
by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id XuTWDd0CWWHj; Tue, 3 Mar 2015 17:26:24 +0100 (CET)
Received: from theia.denx.de (localhost [127.0.0.1])
by theia.denx.de (Postfix) with ESMTP id 8115E4B66F;
Tue, 3 Mar 2015 17:26:11 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
by theia.denx.de (Postfix) with ESMTP id 8F4214B5A8
for ; Tue, 3 Mar 2015 17:25:56 +0100 (CET)
Received: from theia.denx.de ([127.0.0.1])
by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id DtIBduinmMk3 for ;
Tue, 3 Mar 2015 17:25:56 +0100 (CET)
X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5
NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested)
Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com
[210.118.77.12]) by theia.denx.de (Postfix) with ESMTPS id 3768D4B58F
for ; Tue, 3 Mar 2015 17:25:54 +0100 (CET)
Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245])
by mailout2.w1.samsung.com
(Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit
(built Nov
17 2011)) with ESMTP id <0NKN00J7W9TRAJ40@mailout2.w1.samsung.com>
for u-boot@lists.denx.de; Tue, 03 Mar 2015 16:29:51 +0000 (GMT)
X-AuditID: cbfec7f5-b7fc86d0000066b7-c0-54f5dff9d730
Received: from eusync2.samsung.com ( [203.254.199.212])
by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id D7.43.26295.9FFD5F45;
Tue, 03 Mar 2015 16:23:21 +0000 (GMT)
Received: from AMDC1186.digital.local ([106.116.147.185])
by eusync2.samsung.com
(Oracle Communications Messaging Server 7u4-23.01(7.0.4.23.0) 64bit
(built Aug
10 2011)) with ESMTPA id <0NKN007TI9MW8FA0@eusync2.samsung.com>; Tue,
03 Mar 2015 16:25:51 +0000 (GMT)
From: Przemyslaw Marczak
To: u-boot@lists.denx.de
Date: Tue, 03 Mar 2015 17:24:35 +0100
Message-id: <1425399883-14053-5-git-send-email-p.marczak@samsung.com>
X-Mailer: git-send-email 1.9.1
In-reply-to: <1425399883-14053-1-git-send-email-p.marczak@samsung.com>
References: <1412801335-1591-1-git-send-email-p.marczak@samsung.com>
<1425399883-14053-1-git-send-email-p.marczak@samsung.com>
X-Brightmail-Tracker:
H4sIAAAAAAAAA+NgFprILMWRmVeSWpSXmKPExsVy+t/xK7o/738NMVj32dLizfHpTBZvHm5m
tOg40sJosePyDRaLB4d3slt827KN0eLA0WyLyYvnM1u83dvJbnH0yzU2By6P2Q0XWTx2zrrL
7jFt4kdmj7N3djB6vN93lc2jb8sqRo/jN7YzBbBHcdmkpOZklqUW6dslcGUc6PnAXvB8IWPF
/FvvmRoYd9d1MXJySAiYSCx6eYYVwhaTuHBvPVsXIxeHkMBSRolTZ14zQjh9TBJbl55iAqli
EzCQ2HPpDDOILSIgIfGr/ypYEbPAGSaJD7saGEESwgKREvt+dQDZHBwsAqoSi+cIgIR5BVwl
nrb8ZYTYJidx8thksM2cAm4SHduXMEEsa2CUmN2wnGUCI+8CRoZVjKKppckFxUnpuUZ6xYm5
xaV56XrJ+bmbGCHB+HUH49JjVocYBTgYlXh4G259DRFiTSwrrsw9xCjBwawkwisAEuJNSays
Si3Kjy8qzUktPsTIxMEp1cAonGeh2OjnVHbsYUlMW+n85N3Mf+pPlaf8Xqqy8QmbQtckvTUd
0Uu9Vvp1tXzu/X1uR61RzeGHrb/sV9efXpTeyLBBYmOJNffmFYsedDz6ph7Nf+Gypm3Iq8KV
k5wu/rVabvg0pnZd37lNN+svF3VdEKs5pJjJHTcx0G4/s4TVko6NhvnrO+YosRRnJBpqMRcV
JwIA1ZMN0SQCAAA=
Cc: Masahiro Yamada ,
Przemyslaw Marczak , Tom Rini
Subject: [U-Boot] [PATCH v2 04/12] dm: pmic: add implementation of driver
model regulator uclass
X-BeenThere: u-boot@lists.denx.de
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: U-Boot discussion
List-Unsubscribe: ,
List-Archive:
List-Post:
List-Help:
List-Subscribe: ,
MIME-Version: 1.0
Errors-To: u-boot-bounces@lists.denx.de
Sender: "U-Boot"
This is the implementation of driver model regulator uclass api.
To use it, the CONFIG_DM_PMIC is required with driver implementation,
since it provides pmic devices basic I/O API.
The regulator framework is based on a 'struct dm_regulator_ops'.
It provides a common function calls, for it's basic features:
- regulator_get_cnt() - number of outputs each type
- regulator_get_value_desc() - describe output value limits
- regulator_get_mode_desc() - describe output operation modes
- regulator_get/set_value() - output value (uV)
- regulator_get/set_state() - output on/off state
- regulator_get/set_mode() - output operation mode
To get the regulator device:
- regulator_get() - by name only
- regulator_i2c_get() - by i2c bus address (of pmic parent)
- regulator_spi_get() - by spi bus address (of pmic parent)
An optional and useful regulator framework features are two descriptors:
- struct regulator_desc - describes the regulator name and output value limits
should be defined by device driver for each regulator output.
- struct regulator_mode_desc - (array) describes a number of operation modes
supported by each regulator output.
The regulator framework features are described in file:
- include/power/regulator.h
Main files:
- drivers/power/regulator-uclass.c - provides regulator common functions api
- include/power/regulator.h - define all structures required by the regulator
Changes:
- new uclass-id: UCLASS_PMIC_REGULATOR
- new config: CONFIG_DM_REGULATOR
Signed-off-by: Przemyslaw Marczak
---
Changes V2:
- new operations for regulator uclass:
-- get/set output state - for output on/off setting
--- add enum: REGULATOR_OFF, REGULATOR_ON
- regulator uclass code rework and cleanup:
-- change name of:
--- enum 'regulator_desc_type' to 'regulator_type'
--- add type DVS
--- struct 'regulator_desc' to 'regulator_value_desc'
-- regulator ops function calls:
--- remove 'ldo/buck' from naming
--- add new argument 'type' for define regulator type
-- regulator.h - update comments
---
drivers/power/Makefile | 1 +
drivers/power/regulator-uclass.c | 227 ++++++++++++++++++++++++++++
include/dm/uclass-id.h | 1 +
include/power/regulator.h | 310 +++++++++++++++++++++++++++++++++++++++
4 files changed, 539 insertions(+)
create mode 100644 drivers/power/regulator-uclass.c
create mode 100644 include/power/regulator.h
diff --git a/drivers/power/Makefile b/drivers/power/Makefile
index 5c9a189..a6b7012 100644
--- a/drivers/power/Makefile
+++ b/drivers/power/Makefile
@@ -22,3 +22,4 @@ obj-$(CONFIG_POWER_FSL) += power_fsl.o
obj-$(CONFIG_POWER_I2C) += power_i2c.o
obj-$(CONFIG_POWER_SPI) += power_spi.o
obj-$(CONFIG_DM_PMIC) += pmic-uclass.o
+obj-$(CONFIG_DM_REGULATOR) += regulator-uclass.o
diff --git a/drivers/power/regulator-uclass.c b/drivers/power/regulator-uclass.c
new file mode 100644
index 0000000..6b5c678
--- /dev/null
+++ b/drivers/power/regulator-uclass.c
@@ -0,0 +1,227 @@
+/*
+ * Copyright (C) 2014-2015 Samsung Electronics
+ * Przemyslaw Marczak
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+DECLARE_GLOBAL_DATA_PTR;
+
+int regulator_get_cnt(struct udevice *dev, int type, int *cnt)
+{
+ const struct dm_regulator_ops *ops;
+
+ ops = pmic_get_uclass_ops(dev, UCLASS_PMIC_REGULATOR);
+ if (!ops)
+ return -ENODEV;
+
+ if (!ops->get_cnt)
+ return -EPERM;
+
+ return ops->get_cnt(dev, type, cnt);
+}
+
+int regulator_get_value_desc(struct udevice *dev, int type, int number,
+ struct regulator_value_desc **desc)
+{
+ const struct dm_regulator_ops *ops;
+
+ ops = pmic_get_uclass_ops(dev, UCLASS_PMIC_REGULATOR);
+ if (!ops)
+ return -ENXIO;
+
+ if (!ops->get_value_desc)
+ return -EPERM;
+
+ return ops->get_value_desc(dev, type, number, desc);
+}
+
+int regulator_get_mode_desc(struct udevice *dev, int type, int number,
+ int *mode_cnt, struct regulator_mode_desc **desc)
+{
+ const struct dm_regulator_ops *ops;
+
+ ops = pmic_get_uclass_ops(dev, UCLASS_PMIC_REGULATOR);
+ if (!ops)
+ return -ENXIO;
+
+ if (!ops->get_mode_desc_array)
+ return -EPERM;
+
+ return ops->get_mode_desc_array(dev, type, number, mode_cnt, desc);
+}
+
+int regulator_get_value(struct udevice *dev, int type, int number, int *value)
+{
+ const struct dm_regulator_ops *ops;
+
+ ops = pmic_get_uclass_ops(dev, UCLASS_PMIC_REGULATOR);
+ if (!ops)
+ return -ENODEV;
+
+ if (!ops->get_value)
+ return -EPERM;
+
+ return ops->get_value(dev, type, number, value);
+}
+
+int regulator_set_value(struct udevice *dev, int type, int number, int value)
+{
+ const struct dm_regulator_ops *ops;
+
+ ops = pmic_get_uclass_ops(dev, UCLASS_PMIC_REGULATOR);
+ if (!ops)
+ return -ENODEV;
+
+ if (!ops->set_value)
+ return -EPERM;
+
+ return ops->set_value(dev, type, number, value);
+}
+
+int regulator_get_state(struct udevice *dev, int type, int number, int *state)
+{
+ const struct dm_regulator_ops *ops;
+
+ ops = pmic_get_uclass_ops(dev, UCLASS_PMIC_REGULATOR);
+ if (!ops)
+ return -ENODEV;
+
+ if (!ops->get_state)
+ return -EPERM;
+
+ return ops->get_state(dev, type, number, state);
+}
+
+int regulator_set_state(struct udevice *dev, int type, int number, int state)
+{
+ const struct dm_regulator_ops *ops;
+
+ ops = pmic_get_uclass_ops(dev, UCLASS_PMIC_REGULATOR);
+ if (!ops)
+ return -ENODEV;
+
+ if (!ops->set_state)
+ return -EPERM;
+
+ return ops->set_state(dev, type, number, state);
+}
+
+int regulator_get_mode(struct udevice *dev, int type, int number, int *mode)
+{
+ const struct dm_regulator_ops *ops;
+
+ ops = pmic_get_uclass_ops(dev, UCLASS_PMIC_REGULATOR);
+ if (!ops)
+ return -ENODEV;
+
+ if (!ops->get_mode)
+ return -EPERM;
+
+ return ops->get_mode(dev, type, number, mode);
+}
+
+int regulator_set_mode(struct udevice *dev, int type, int number, int mode)
+{
+ const struct dm_regulator_ops *ops;
+
+ ops = pmic_get_uclass_ops(dev, UCLASS_PMIC_REGULATOR);
+ if (!ops)
+ return -ENODEV;
+
+ if (!ops->set_mode)
+ return -EPERM;
+
+ return ops->set_mode(dev, type, number, mode);
+}
+
+int regulator_get(char *name, struct udevice **regulator)
+{
+ struct udevice *dev;
+ struct uclass *uc;
+ int ret;
+
+ ret = uclass_get(UCLASS_PMIC_REGULATOR, &uc);
+ if (ret) {
+ error("Regulator uclass not initialized!");
+ return ret;
+ }
+
+ uclass_foreach_dev(dev, uc) {
+ if (!dev)
+ continue;
+
+ if (!strncmp(name, dev->name, strlen(name))) {
+ ret = device_probe(dev);
+ if (ret)
+ error("Dev: %s probe failed", dev->name);
+ *regulator = dev;
+ return ret;
+ }
+ }
+
+ *regulator = NULL;
+ return -EINVAL;
+}
+
+int regulator_i2c_get(int bus, int addr, struct udevice **regulator)
+{
+ struct udevice *pmic;
+ int ret;
+
+ /* First get parent pmic device */
+ ret = pmic_i2c_get(bus, addr, &pmic);
+ if (ret) {
+ error("Chip: %d on bus %d not found!", addr, bus);
+ return ret;
+ }
+
+ /* Get the first regulator child of pmic device */
+ if (device_get_first_child_by_uclass_id(pmic, UCLASS_PMIC_REGULATOR,
+ regulator)) {
+ error("PMIC: %s regulator child not found!", pmic->name);
+ *regulator = NULL;
+ return ret;
+ }
+
+ return 0;
+}
+
+int regulator_spi_get(int bus, int cs, struct udevice **regulator)
+{
+ struct udevice *pmic;
+ int ret;
+
+ /* First get parent pmic device */
+ ret = pmic_spi_get(bus, cs, &pmic);
+ if (ret) {
+ error("Chip: %d on bus %d not found!", cs, bus);
+ return ret;
+ }
+
+ /* Get the first regulator child of pmic device */
+ if (device_get_first_child_by_uclass_id(pmic, UCLASS_PMIC_REGULATOR,
+ regulator)) {
+ error("PMIC: %s regulator child not found!", pmic->name);
+ *regulator = NULL;
+ return ret;
+ }
+
+ return 0;
+}
+
+UCLASS_DRIVER(regulator) = {
+ .id = UCLASS_PMIC_REGULATOR,
+ .name = "regulator",
+};
diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h
index ff360ac..0a1e664 100644
--- a/include/dm/uclass-id.h
+++ b/include/dm/uclass-id.h
@@ -37,6 +37,7 @@ enum uclass_id {
/* PMIC uclass and PMIC related uclasses */
UCLASS_PMIC,
+ UCLASS_PMIC_REGULATOR,
UCLASS_COUNT,
UCLASS_INVALID = -1,
diff --git a/include/power/regulator.h b/include/power/regulator.h
new file mode 100644
index 0000000..ee8a280
--- /dev/null
+++ b/include/power/regulator.h
@@ -0,0 +1,310 @@
+/*
+ * Copyright (C) 2014-2015 Samsung Electronics
+ * Przemyslaw Marczak
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#ifndef _INCLUDE_REGULATOR_H_
+#define _INCLUDE_REGULATOR_H_
+
+#define DESC_NAME_LEN 20
+
+/* enum regulator_type - used for regulator_*() variant calls */
+enum regulator_type {
+ REGULATOR_TYPE_LDO = 0,
+ REGULATOR_TYPE_BUCK,
+ REGULATOR_TYPE_DVS,
+};
+
+/* enum regulator_out_state - used for ldo/buck output state setting */
+enum regulator_out_state {
+ REGULATOR_OFF = 0,
+ REGULATOR_ON,
+};
+
+/**
+ * struct regulator_value_desc - this structure holds an information about
+ * each regulator voltage limits. There is no "step" voltage value - so driver
+ * should take care of this. This is rather platform specific so can be
+ * taken from the device-tree.
+ *
+ * @type - one of: DESC_TYPE_LDO, DESC_TYPE_BUCK or DESC_TYPE_DVS
+ * @number - hardware internal regulator number
+ * @min_uV - minimum voltage (micro Volts)
+ * @max_uV - maximum voltage (micro Volts)
+ * @name - name of regulator - usually will be taken from device tree and
+ * can describe regulator output connected hardware, e.g. "eMMC"
+*/
+struct regulator_value_desc {
+ int type;
+ int number;
+ int min_uV;
+ int max_uV;
+ char name[DESC_NAME_LEN];
+};
+
+/**
+ * struct regulator_mode_desc - this structure holds an information about
+ * each regulator operation modes. Probably in most cases - an array.
+ * This will be probably a driver static data since it's device specific.
+ *
+ * @mode - a driver specific mode number - used for regulator command
+ * @register_value - a driver specific value for this mode
+ * @name - the name of mode - used for regulator command
+ */
+struct regulator_mode_desc {
+ int mode;
+ int register_value;
+ char *name;
+};
+
+/* PMIC regulator device operations */
+struct dm_regulator_ops {
+ /**
+ * get_cnt - get the number of a given regulator 'type' outputs
+ *
+ * @dev - regulator device
+ * @type - regulator type, one of enum regulator_type
+ * Gets:
+ * @cnt - regulator count
+ * Returns: 0 on success or negative value of errno.
+ */
+ int (*get_cnt)(struct udevice *dev, int type, int *cnt);
+
+ /**
+ * Regulator output value descriptor is specific for each output.
+ * It's usually driver static data, but output value limits are
+ * often defined in the device-tree, so those are platform dependent
+ * attributes.
+ *
+ * get_value_desc - get value descriptor of the given regulator output
+ * @dev - regulator device
+ * @type - regulator type, one of enum regulator_type
+ * @number - regulator number
+ * Gets:
+ * @desc - pointer to the descriptor
+ * Returns: 0 on success or negative value of errno.
+ */
+ int (*get_value_desc)(struct udevice *dev, int type, int number,
+ struct regulator_value_desc **desc);
+
+ /**
+ * Regulator output mode descriptors are device specific.
+ * It's usually driver static data.
+ * Each regulator output can support different mode types,
+ * so usually will return an array with a number 'mode_desc_cnt'
+ * of mode descriptors.
+ *
+ * get_mode_desc_array - get mode descriptor array of the given
+ * regulator output number
+ * @dev - regulator device
+ * @type - regulator type, one of 'enum regulator_type'
+ * @number - regulator number
+ * Gets:
+ * @mode_desc_cnt - descriptor array entry count
+ * @desc - pointer to the descriptor array
+ * Returns: 0 on success or negative value of errno.
+ */
+ int (*get_mode_desc_array)(struct udevice *dev, int type,
+ int number, int *mode_desc_cnt,
+ struct regulator_mode_desc **desc);
+
+ /**
+ * The regulator output value function calls operates on a micro Volts,
+ * however the regulator commands operates on a mili Volt unit.
+ *
+ * get/set_value - get/set output value of the given output number
+ * @dev - regulator device
+ * @type - regulator type, one of 'enum regulator_type'
+ * @number - regulator number
+ * Sets/Gets:
+ * @value - set or get output value
+ * Returns: 0 on success or negative value of errno.
+ */
+ int (*get_value)(struct udevice *dev, int type, int number, int *value);
+ int (*set_value)(struct udevice *dev, int type, int number, int value);
+
+ /**
+ * The most basic feature of the regulator output is it's on/off state.
+ *
+ * get/set_state - get/set on/off state of the given output number
+ * @dev - regulator device
+ * @type - regulator type, one of 'enum regulator_type'
+ * @number - regulator number
+ * Sets/Gets:
+ * @state - set or get one of 'enum regulator_out_state'
+ * Returns: 0 on success or negative value of errno.
+ */
+ int (*get_state)(struct udevice *dev, int type, int number, int *state);
+ int (*set_state)(struct udevice *dev, int type, int number, int state);
+
+ /**
+ * The 'get/set_mode()' function calls should operate on a driver
+ * specific mode definitions, which should be found in:
+ * field 'mode' of struct regulator_mode_desc.
+ *
+ * get/set_mode - get/set operation mode of the given output number
+ * @dev - regulator device
+ * @type - regulator type, one of 'enum regulator_type'
+ * @number - regulator number
+ * Sets/Gets:
+ * @mode - set or get output mode
+ * Returns: 0 on success or negative value of errno.
+ */
+ int (*get_mode)(struct udevice *dev, int type, int number, int *mode);
+ int (*set_mode)(struct udevice *dev, int type, int number, int mode);
+};
+
+/**
+ * regulator_get_cnt: returns the number of driver registered regulators.
+ * This is used for pmic regulator command purposes.
+ *
+ * @dev - pointer to the regulator device
+ * @type - regulator type: device specific
+ * Gets:
+ * @cnt - regulator count
+ * Returns: 0 on success or negative value of errno.
+ */
+int regulator_get_cnt(struct udevice *dev, int type, int *cnt);
+
+/**
+ * regulator_get_value_desc: returns a pointer to the regulator value
+ * descriptor of a given device regulator output number.
+ *
+ * @dev - pointer to the regulator device
+ * @type - regulator descriptor type
+ * @number - descriptor number (regulator output number)
+ * Gets:
+ * @desc - pointer to the descriptor
+ * Returns: 0 on success or negative value of errno.
+ */
+int regulator_get_value_desc(struct udevice *dev, int type, int number,
+ struct regulator_value_desc **desc);
+
+/**
+ * regulator_get_mode_desc: returns a pointer to the array of regulator mode
+ * descriptors of a given device regulator type and number.
+ *
+ * @dev - pointer to the regulator device
+ * @type - regulator type: device specific
+ * @number - output number: device specific
+ * Gets:
+ * @mode_cnt - descriptor array entry count
+ * @desc - pointer to the descriptor array
+ * Returns: 0 on success or negative value of errno.
+ */
+int regulator_get_mode_desc(struct udevice *dev, int type, int number,
+ int *mode_cnt, struct regulator_mode_desc **desc);
+
+/**
+ * regulator_get_value: returns voltage value of a given device
+ * regulator type number.
+ *
+ * @dev - pointer to the regulator device
+ * @type - regulator type: device specific
+ * @number - output number: device specific
+ * Gets:
+ * @val - returned voltage - unit: uV (micro Volts)
+ * Returns: 0 on success or negative value of errno.
+ */
+int regulator_get_value(struct udevice *dev, int type, int number, int *val);
+
+/**
+ * regulator_set_value: set the voltage value of a given device regulator type
+ * number to the given one passed by the argument: @val
+ *
+ * @dev - pointer to the regulator device
+ * @type - regulator type: device specific
+ * @number - output number: device specific
+ * @val - voltage value to set - unit: uV (micro Volts)
+ * Returns - 0 on success or -errno val if fails
+ */
+int regulator_set_value(struct udevice *dev, int type, int number, int val);
+
+/**
+ * regulator_get_state: returns output state of a given device
+ * regulator type number.
+ *
+ * @dev - pointer to the regulator device
+ * @type - regulator type, device specific
+ * @number - regulator number, device specific
+ * Gets:
+ * @state - returned regulator number output state:
+ * - REGULATOR_OFF (0) - disable
+ * - REGULATOR_ON (1) - enable
+ * Returns: - 0 on success or -errno val if fails
+ */
+int regulator_get_state(struct udevice *dev, int type, int number, int *state);
+
+/**
+ * regulator_set_state: set output state of a given device regulator type
+ * number to the given one passed by the argument: @state
+ *
+ * @dev - pointer to the regulator device
+ * @type - regulator type: device specific
+ * @number - output number: device specific
+ * @state - output state to set
+ * - enum REGULATOR_OFF == 0 - disable
+ * - enum REGULATOR_ON == 1 - enable
+ * Returns - 0 on success or -errno val if fails
+ */
+int regulator_set_state(struct udevice *dev, int type, int number, int state);
+
+/**
+ * regulator_get_mode: get mode number of a given device regulator type number
+ *
+ * @dev - pointer to the regulator device
+ * @type - output number: device specific
+ * @number - output number: device specific
+ * Gets:
+ * @mode - returned mode number
+ * Returns - 0 on success or -errno val if fails
+ * Note:
+ * The regulator driver should return one of defined, mode number rather
+ * than the raw register value. The struct type 'regulator_mode_desc' has
+ * a mode field for this purpose and register_value for a raw register value.
+ */
+int regulator_get_mode(struct udevice *dev, int type, int number, int *mode);
+
+/**
+ * regulator_set_mode: set given regulator type and number mode to the given
+ * one passed by the argument: @mode
+ *
+ * @dev - pointer to the regulator device
+ * @type - output number: device specific
+ * @number - output number: device specific
+ * @mode - mode type (struct regulator_mode_desc.mode)
+ * Returns - 0 on success or -errno value if fails
+ * Note:
+ * The regulator driver should take one of defined, mode number rather
+ * than a raw register value. The struct type 'regulator_mode_desc' has
+ * a mode field for this purpose and register_value for a raw register value.
+ */
+int regulator_set_mode(struct udevice *dev, int type, int number, int mode);
+
+/**
+ * regulator_..._get: returns the pointer to the pmic regulator device
+ * by specified arguments:
+ *
+ * NAME:
+ * @name - device name (useful for specific names)
+ * or SPI/I2C interface:
+ * @bus - device I2C/SPI bus number
+ * @addr_cs - device specific address for I2C or chip select for SPI,
+ * on the given bus number
+ * Gets:
+ * @regulator - pointer to the pmic device
+ * Returns: 0 on success or negative value of errno.
+ *
+ * The returned 'regulator' device can be used with:
+ * - regulator_get/set_*
+ * and if pmic_platdata is given, then also with:
+ * - pmic_if_* calls
+ * The last one is used for the pmic command purposes.
+ */
+int regulator_get(char *name, struct udevice **regulator);
+int regulator_i2c_get(int bus, int addr, struct udevice **regulator);
+int regulator_spi_get(int bus, int cs, struct udevice **regulator);
+
+#endif /* _INCLUDE_REGULATOR_H_ */