X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;ds=sidebyside;f=include%2Fpower%2Fregulator.h;h=74938dd61e49287e378902c5f4a20b2f2306023d;hb=87271ed8ebf0217471ea5f785402488f5fb7a26d;hp=015229027c874eeb860b91000eda11accf604e51;hpb=7a1af7a79bd79ded6a78d0c1afdbc3353669e313;p=oweals%2Fu-boot.git diff --git a/include/power/regulator.h b/include/power/regulator.h index 015229027c..74938dd61e 100644 --- a/include/power/regulator.h +++ b/include/power/regulator.h @@ -1,8 +1,7 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ /* * Copyright (C) 2014-2015 Samsung Electronics * Przemyslaw Marczak - * - * SPDX-License-Identifier: GPL-2.0+ */ #ifndef _INCLUDE_REGULATOR_H_ @@ -46,6 +45,7 @@ * Note: For the proper operation, at least name constraint is needed, since * it can be used when calling regulator_get_by_platname(). And the mandatory * rule for this name is, that it must be globally unique for the single dts. + * If regulator-name property is not provided, node name will be chosen. * * Regulator bind: * For each regulator device, the device_bind() should be called with passed @@ -53,7 +53,7 @@ * which does the scan on the device node, for the 'regulator-name' constraint. * If the parent is not a PMIC device, and the child is not bind by function: * 'pmic_bind_childs()', then it's recommended to bind the device by call to - * dm_scan_fdt_node() - this is usually done automatically for bus devices, + * dm_scan_fdt_dev() - this is usually done automatically for bus devices, * as a post bind method. * * Regulator get: @@ -107,6 +107,7 @@ enum regulator_type { REGULATOR_TYPE_BUCK, REGULATOR_TYPE_DVS, REGULATOR_TYPE_FIXED, + REGULATOR_TYPE_GPIO, REGULATOR_TYPE_OTHER, }; @@ -149,8 +150,11 @@ enum regulator_flag { * @always_on* - bool type, true or false * @boot_on* - bool type, true or false * TODO(sjg@chromium.org): Consider putting the above two into @flags + * @ramp_delay - Time to settle down after voltage change (unit: uV/us) * @flags: - flags value (see REGULATOR_FLAG_...) * @name** - fdt regulator name - should be taken from the device tree + * ctrl_reg: - Control register offset used to enable/disable regulator + * volt_reg: - register offset for writing voltage vsel values * * Note: * * - set automatically on device probe by the uclass's '.pre_probe' method. @@ -164,12 +168,18 @@ struct dm_regulator_uclass_platdata { int mode_count; int min_uV; int max_uV; + int init_uV; int min_uA; int max_uA; + unsigned int ramp_delay; bool always_on; bool boot_on; const char *name; int flags; + u8 ctrl_reg; + u8 volt_reg; + bool suspend_on; + u32 suspend_uV; }; /* Regulator device operations */ @@ -186,6 +196,19 @@ struct dm_regulator_ops { int (*get_value)(struct udevice *dev); int (*set_value)(struct udevice *dev, int uV); + /** + * The regulator suspend output value function calls operates + * on a micro Volts. + * + * get/set_suspen_value - get/set suspend mode output value + * @dev - regulator device + * Sets: + * @uV - set the suspend output value [micro Volts] + * @return output value [uV] on success or negative errno if fail. + */ + int (*set_suspend_value)(struct udevice *dev, int uV); + int (*get_suspend_value)(struct udevice *dev); + /** * The regulator output current function calls operates on a micro Amps. * @@ -205,11 +228,24 @@ struct dm_regulator_ops { * @dev - regulator device * Sets: * @enable - set true - enable or false - disable - * @return true/false for get; or 0 / -errno for set. + * @return true/false for get or -errno if fail; 0 / -errno for set. */ - bool (*get_enable)(struct udevice *dev); + int (*get_enable)(struct udevice *dev); int (*set_enable)(struct udevice *dev, bool enable); + /** + * The most basic feature of the regulator output is its enable state + * in suspend mode. + * + * get/set_suspend_enable - get/set enable state of the suspend output + * @dev - regulator device + * Sets: + * @enable - set true - enable or false - disable + * @return true/false for get or -errno if fail; 0 / -errno for set. + */ + int (*set_suspend_enable)(struct udevice *dev, bool enable); + int (*get_suspend_enable)(struct udevice *dev); + /** * The 'get/set_mode()' function calls should operate on a driver- * specific mode id definitions, which should be found in: @@ -254,6 +290,33 @@ int regulator_get_value(struct udevice *dev); */ int regulator_set_value(struct udevice *dev, int uV); +/** + * regulator_set_suspend_value: set the suspend microvoltage value of a given regulator. + * + * @dev - pointer to the regulator device + * @uV - the output suspend value to set [micro Volts] + * @return - 0 on success or -errno val if fails + */ +int regulator_set_suspend_value(struct udevice *dev, int uV); + +/** + * regulator_get_suspend_value: get the suspend microvoltage value of a given regulator. + * + * @dev - pointer to the regulator device + * @return - positive output value [uV] on success or negative errno if fail. + */ +int regulator_get_suspend_value(struct udevice *dev); + +/** + * regulator_set_value_force: set the microvoltage value of a given regulator + * without any min-,max condition check + * + * @dev - pointer to the regulator device + * @uV - the output value to set [micro Volts] + * @return - 0 on success or -errno val if fails + */ +int regulator_set_value_force(struct udevice *dev, int uV); + /** * regulator_get_current: get microampere value of a given regulator * @@ -275,9 +338,9 @@ int regulator_set_current(struct udevice *dev, int uA); * regulator_get_enable: get regulator device enable state. * * @dev - pointer to the regulator device - * @return - true/false of enable state + * @return - true/false of enable state or -errno val if fails */ -bool regulator_get_enable(struct udevice *dev); +int regulator_get_enable(struct udevice *dev); /** * regulator_set_enable: set regulator enable state @@ -288,6 +351,34 @@ bool regulator_get_enable(struct udevice *dev); */ int regulator_set_enable(struct udevice *dev, bool enable); +/** + * regulator_set_enable_if_allowed: set regulator enable state if allowed by + * regulator + * + * @dev - pointer to the regulator device + * @enable - set true or false + * @return - 0 on success or if enabling is not supported + * -errno val if fails. + */ +int regulator_set_enable_if_allowed(struct udevice *dev, bool enable); + +/** + * regulator_set_suspend_enable: set regulator suspend enable state + * + * @dev - pointer to the regulator device + * @enable - set true or false + * @return - 0 on success or -errno val if fails + */ +int regulator_set_suspend_enable(struct udevice *dev, bool enable); + +/** + * regulator_get_suspend_enable: get regulator suspend enable state + * + * @dev - pointer to the regulator device + * @return - true/false of enable state or -errno val if fails + */ +int regulator_get_suspend_enable(struct udevice *dev); + /** * regulator_get_mode: get active operation mode id of a given regulator * @@ -418,4 +509,20 @@ int regulator_get_by_devname(const char *devname, struct udevice **devp); */ int regulator_get_by_platname(const char *platname, struct udevice **devp); +/** + * device_get_supply_regulator: returns the pointer to the supply regulator. + * Search by phandle, found in device's node. + * + * Note: Please pay attention to proper order of device bind sequence. + * The regulator device searched by the phandle, must be binded before + * this function call. + * + * @dev - device with supply phandle + * @supply_name - phandle name of regulator + * @devp - returned pointer to the supply device + * @return 0 on success or negative value of errno. + */ +int device_get_supply_regulator(struct udevice *dev, const char *supply_name, + struct udevice **devp); + #endif /* _INCLUDE_REGULATOR_H_ */