162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * consumer.h -- SoC Regulator consumer support. 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * Copyright (C) 2007, 2008 Wolfson Microelectronics PLC. 662306a36Sopenharmony_ci * 762306a36Sopenharmony_ci * Author: Liam Girdwood <lrg@slimlogic.co.uk> 862306a36Sopenharmony_ci * 962306a36Sopenharmony_ci * Regulator Consumer Interface. 1062306a36Sopenharmony_ci * 1162306a36Sopenharmony_ci * A Power Management Regulator framework for SoC based devices. 1262306a36Sopenharmony_ci * Features:- 1362306a36Sopenharmony_ci * o Voltage and current level control. 1462306a36Sopenharmony_ci * o Operating mode control. 1562306a36Sopenharmony_ci * o Regulator status. 1662306a36Sopenharmony_ci * o sysfs entries for showing client devices and status 1762306a36Sopenharmony_ci * 1862306a36Sopenharmony_ci * EXPERIMENTAL FEATURES: 1962306a36Sopenharmony_ci * Dynamic Regulator operating Mode Switching (DRMS) - allows regulators 2062306a36Sopenharmony_ci * to use most efficient operating mode depending upon voltage and load and 2162306a36Sopenharmony_ci * is transparent to client drivers. 2262306a36Sopenharmony_ci * 2362306a36Sopenharmony_ci * e.g. Devices x,y,z share regulator r. Device x and y draw 20mA each during 2462306a36Sopenharmony_ci * IO and 1mA at idle. Device z draws 100mA when under load and 5mA when 2562306a36Sopenharmony_ci * idling. Regulator r has > 90% efficiency in NORMAL mode at loads > 100mA 2662306a36Sopenharmony_ci * but this drops rapidly to 60% when below 100mA. Regulator r has > 90% 2762306a36Sopenharmony_ci * efficiency in IDLE mode at loads < 10mA. Thus regulator r will operate 2862306a36Sopenharmony_ci * in normal mode for loads > 10mA and in IDLE mode for load <= 10mA. 2962306a36Sopenharmony_ci */ 3062306a36Sopenharmony_ci 3162306a36Sopenharmony_ci#ifndef __LINUX_REGULATOR_CONSUMER_H_ 3262306a36Sopenharmony_ci#define __LINUX_REGULATOR_CONSUMER_H_ 3362306a36Sopenharmony_ci 3462306a36Sopenharmony_ci#include <linux/err.h> 3562306a36Sopenharmony_ci#include <linux/suspend.h> 3662306a36Sopenharmony_ci 3762306a36Sopenharmony_cistruct device; 3862306a36Sopenharmony_cistruct notifier_block; 3962306a36Sopenharmony_cistruct regmap; 4062306a36Sopenharmony_cistruct regulator_dev; 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_ci/* 4362306a36Sopenharmony_ci * Regulator operating modes. 4462306a36Sopenharmony_ci * 4562306a36Sopenharmony_ci * Regulators can run in a variety of different operating modes depending on 4662306a36Sopenharmony_ci * output load. This allows further system power savings by selecting the 4762306a36Sopenharmony_ci * best (and most efficient) regulator mode for a desired load. 4862306a36Sopenharmony_ci * 4962306a36Sopenharmony_ci * Most drivers will only care about NORMAL. The modes below are generic and 5062306a36Sopenharmony_ci * will probably not match the naming convention of your regulator data sheet 5162306a36Sopenharmony_ci * but should match the use cases in the datasheet. 5262306a36Sopenharmony_ci * 5362306a36Sopenharmony_ci * In order of power efficiency (least efficient at top). 5462306a36Sopenharmony_ci * 5562306a36Sopenharmony_ci * Mode Description 5662306a36Sopenharmony_ci * FAST Regulator can handle fast changes in it's load. 5762306a36Sopenharmony_ci * e.g. useful in CPU voltage & frequency scaling where 5862306a36Sopenharmony_ci * load can quickly increase with CPU frequency increases. 5962306a36Sopenharmony_ci * 6062306a36Sopenharmony_ci * NORMAL Normal regulator power supply mode. Most drivers will 6162306a36Sopenharmony_ci * use this mode. 6262306a36Sopenharmony_ci * 6362306a36Sopenharmony_ci * IDLE Regulator runs in a more efficient mode for light 6462306a36Sopenharmony_ci * loads. Can be used for devices that have a low power 6562306a36Sopenharmony_ci * requirement during periods of inactivity. This mode 6662306a36Sopenharmony_ci * may be more noisy than NORMAL and may not be able 6762306a36Sopenharmony_ci * to handle fast load switching. 6862306a36Sopenharmony_ci * 6962306a36Sopenharmony_ci * STANDBY Regulator runs in the most efficient mode for very 7062306a36Sopenharmony_ci * light loads. Can be used by devices when they are 7162306a36Sopenharmony_ci * in a sleep/standby state. This mode is likely to be 7262306a36Sopenharmony_ci * the most noisy and may not be able to handle fast load 7362306a36Sopenharmony_ci * switching. 7462306a36Sopenharmony_ci * 7562306a36Sopenharmony_ci * NOTE: Most regulators will only support a subset of these modes. Some 7662306a36Sopenharmony_ci * will only just support NORMAL. 7762306a36Sopenharmony_ci * 7862306a36Sopenharmony_ci * These modes can be OR'ed together to make up a mask of valid register modes. 7962306a36Sopenharmony_ci */ 8062306a36Sopenharmony_ci 8162306a36Sopenharmony_ci#define REGULATOR_MODE_INVALID 0x0 8262306a36Sopenharmony_ci#define REGULATOR_MODE_FAST 0x1 8362306a36Sopenharmony_ci#define REGULATOR_MODE_NORMAL 0x2 8462306a36Sopenharmony_ci#define REGULATOR_MODE_IDLE 0x4 8562306a36Sopenharmony_ci#define REGULATOR_MODE_STANDBY 0x8 8662306a36Sopenharmony_ci 8762306a36Sopenharmony_ci/* 8862306a36Sopenharmony_ci * Regulator notifier events. 8962306a36Sopenharmony_ci * 9062306a36Sopenharmony_ci * UNDER_VOLTAGE Regulator output is under voltage. 9162306a36Sopenharmony_ci * OVER_CURRENT Regulator output current is too high. 9262306a36Sopenharmony_ci * REGULATION_OUT Regulator output is out of regulation. 9362306a36Sopenharmony_ci * FAIL Regulator output has failed. 9462306a36Sopenharmony_ci * OVER_TEMP Regulator over temp. 9562306a36Sopenharmony_ci * FORCE_DISABLE Regulator forcibly shut down by software. 9662306a36Sopenharmony_ci * VOLTAGE_CHANGE Regulator voltage changed. 9762306a36Sopenharmony_ci * Data passed is old voltage cast to (void *). 9862306a36Sopenharmony_ci * DISABLE Regulator was disabled. 9962306a36Sopenharmony_ci * PRE_VOLTAGE_CHANGE Regulator is about to have voltage changed. 10062306a36Sopenharmony_ci * Data passed is "struct pre_voltage_change_data" 10162306a36Sopenharmony_ci * ABORT_VOLTAGE_CHANGE Regulator voltage change failed for some reason. 10262306a36Sopenharmony_ci * Data passed is old voltage cast to (void *). 10362306a36Sopenharmony_ci * PRE_DISABLE Regulator is about to be disabled 10462306a36Sopenharmony_ci * ABORT_DISABLE Regulator disable failed for some reason 10562306a36Sopenharmony_ci * 10662306a36Sopenharmony_ci * NOTE: These events can be OR'ed together when passed into handler. 10762306a36Sopenharmony_ci */ 10862306a36Sopenharmony_ci 10962306a36Sopenharmony_ci#define REGULATOR_EVENT_UNDER_VOLTAGE 0x01 11062306a36Sopenharmony_ci#define REGULATOR_EVENT_OVER_CURRENT 0x02 11162306a36Sopenharmony_ci#define REGULATOR_EVENT_REGULATION_OUT 0x04 11262306a36Sopenharmony_ci#define REGULATOR_EVENT_FAIL 0x08 11362306a36Sopenharmony_ci#define REGULATOR_EVENT_OVER_TEMP 0x10 11462306a36Sopenharmony_ci#define REGULATOR_EVENT_FORCE_DISABLE 0x20 11562306a36Sopenharmony_ci#define REGULATOR_EVENT_VOLTAGE_CHANGE 0x40 11662306a36Sopenharmony_ci#define REGULATOR_EVENT_DISABLE 0x80 11762306a36Sopenharmony_ci#define REGULATOR_EVENT_PRE_VOLTAGE_CHANGE 0x100 11862306a36Sopenharmony_ci#define REGULATOR_EVENT_ABORT_VOLTAGE_CHANGE 0x200 11962306a36Sopenharmony_ci#define REGULATOR_EVENT_PRE_DISABLE 0x400 12062306a36Sopenharmony_ci#define REGULATOR_EVENT_ABORT_DISABLE 0x800 12162306a36Sopenharmony_ci#define REGULATOR_EVENT_ENABLE 0x1000 12262306a36Sopenharmony_ci/* 12362306a36Sopenharmony_ci * Following notifications should be emitted only if detected condition 12462306a36Sopenharmony_ci * is such that the HW is likely to still be working but consumers should 12562306a36Sopenharmony_ci * take a recovery action to prevent problems esacalating into errors. 12662306a36Sopenharmony_ci */ 12762306a36Sopenharmony_ci#define REGULATOR_EVENT_UNDER_VOLTAGE_WARN 0x2000 12862306a36Sopenharmony_ci#define REGULATOR_EVENT_OVER_CURRENT_WARN 0x4000 12962306a36Sopenharmony_ci#define REGULATOR_EVENT_OVER_VOLTAGE_WARN 0x8000 13062306a36Sopenharmony_ci#define REGULATOR_EVENT_OVER_TEMP_WARN 0x10000 13162306a36Sopenharmony_ci#define REGULATOR_EVENT_WARN_MASK 0x1E000 13262306a36Sopenharmony_ci 13362306a36Sopenharmony_ci/* 13462306a36Sopenharmony_ci * Regulator errors that can be queried using regulator_get_error_flags 13562306a36Sopenharmony_ci * 13662306a36Sopenharmony_ci * UNDER_VOLTAGE Regulator output is under voltage. 13762306a36Sopenharmony_ci * OVER_CURRENT Regulator output current is too high. 13862306a36Sopenharmony_ci * REGULATION_OUT Regulator output is out of regulation. 13962306a36Sopenharmony_ci * FAIL Regulator output has failed. 14062306a36Sopenharmony_ci * OVER_TEMP Regulator over temp. 14162306a36Sopenharmony_ci * 14262306a36Sopenharmony_ci * NOTE: These errors can be OR'ed together. 14362306a36Sopenharmony_ci */ 14462306a36Sopenharmony_ci 14562306a36Sopenharmony_ci#define REGULATOR_ERROR_UNDER_VOLTAGE BIT(1) 14662306a36Sopenharmony_ci#define REGULATOR_ERROR_OVER_CURRENT BIT(2) 14762306a36Sopenharmony_ci#define REGULATOR_ERROR_REGULATION_OUT BIT(3) 14862306a36Sopenharmony_ci#define REGULATOR_ERROR_FAIL BIT(4) 14962306a36Sopenharmony_ci#define REGULATOR_ERROR_OVER_TEMP BIT(5) 15062306a36Sopenharmony_ci 15162306a36Sopenharmony_ci#define REGULATOR_ERROR_UNDER_VOLTAGE_WARN BIT(6) 15262306a36Sopenharmony_ci#define REGULATOR_ERROR_OVER_CURRENT_WARN BIT(7) 15362306a36Sopenharmony_ci#define REGULATOR_ERROR_OVER_VOLTAGE_WARN BIT(8) 15462306a36Sopenharmony_ci#define REGULATOR_ERROR_OVER_TEMP_WARN BIT(9) 15562306a36Sopenharmony_ci 15662306a36Sopenharmony_ci/** 15762306a36Sopenharmony_ci * struct pre_voltage_change_data - Data sent with PRE_VOLTAGE_CHANGE event 15862306a36Sopenharmony_ci * 15962306a36Sopenharmony_ci * @old_uV: Current voltage before change. 16062306a36Sopenharmony_ci * @min_uV: Min voltage we'll change to. 16162306a36Sopenharmony_ci * @max_uV: Max voltage we'll change to. 16262306a36Sopenharmony_ci */ 16362306a36Sopenharmony_cistruct pre_voltage_change_data { 16462306a36Sopenharmony_ci unsigned long old_uV; 16562306a36Sopenharmony_ci unsigned long min_uV; 16662306a36Sopenharmony_ci unsigned long max_uV; 16762306a36Sopenharmony_ci}; 16862306a36Sopenharmony_ci 16962306a36Sopenharmony_cistruct regulator; 17062306a36Sopenharmony_ci 17162306a36Sopenharmony_ci/** 17262306a36Sopenharmony_ci * struct regulator_bulk_data - Data used for bulk regulator operations. 17362306a36Sopenharmony_ci * 17462306a36Sopenharmony_ci * @supply: The name of the supply. Initialised by the user before 17562306a36Sopenharmony_ci * using the bulk regulator APIs. 17662306a36Sopenharmony_ci * @init_load_uA: After getting the regulator, regulator_set_load() will be 17762306a36Sopenharmony_ci * called with this load. Initialised by the user before 17862306a36Sopenharmony_ci * using the bulk regulator APIs. 17962306a36Sopenharmony_ci * @consumer: The regulator consumer for the supply. This will be managed 18062306a36Sopenharmony_ci * by the bulk API. 18162306a36Sopenharmony_ci * 18262306a36Sopenharmony_ci * The regulator APIs provide a series of regulator_bulk_() API calls as 18362306a36Sopenharmony_ci * a convenience to consumers which require multiple supplies. This 18462306a36Sopenharmony_ci * structure is used to manage data for these calls. 18562306a36Sopenharmony_ci */ 18662306a36Sopenharmony_cistruct regulator_bulk_data { 18762306a36Sopenharmony_ci const char *supply; 18862306a36Sopenharmony_ci int init_load_uA; 18962306a36Sopenharmony_ci struct regulator *consumer; 19062306a36Sopenharmony_ci 19162306a36Sopenharmony_ci /* private: Internal use */ 19262306a36Sopenharmony_ci int ret; 19362306a36Sopenharmony_ci}; 19462306a36Sopenharmony_ci 19562306a36Sopenharmony_ci#if defined(CONFIG_REGULATOR) 19662306a36Sopenharmony_ci 19762306a36Sopenharmony_ci/* regulator get and put */ 19862306a36Sopenharmony_cistruct regulator *__must_check regulator_get(struct device *dev, 19962306a36Sopenharmony_ci const char *id); 20062306a36Sopenharmony_cistruct regulator *__must_check devm_regulator_get(struct device *dev, 20162306a36Sopenharmony_ci const char *id); 20262306a36Sopenharmony_cistruct regulator *__must_check regulator_get_exclusive(struct device *dev, 20362306a36Sopenharmony_ci const char *id); 20462306a36Sopenharmony_cistruct regulator *__must_check devm_regulator_get_exclusive(struct device *dev, 20562306a36Sopenharmony_ci const char *id); 20662306a36Sopenharmony_cistruct regulator *__must_check regulator_get_optional(struct device *dev, 20762306a36Sopenharmony_ci const char *id); 20862306a36Sopenharmony_cistruct regulator *__must_check devm_regulator_get_optional(struct device *dev, 20962306a36Sopenharmony_ci const char *id); 21062306a36Sopenharmony_ciint devm_regulator_get_enable(struct device *dev, const char *id); 21162306a36Sopenharmony_ciint devm_regulator_get_enable_optional(struct device *dev, const char *id); 21262306a36Sopenharmony_civoid regulator_put(struct regulator *regulator); 21362306a36Sopenharmony_civoid devm_regulator_put(struct regulator *regulator); 21462306a36Sopenharmony_ci 21562306a36Sopenharmony_ciint regulator_register_supply_alias(struct device *dev, const char *id, 21662306a36Sopenharmony_ci struct device *alias_dev, 21762306a36Sopenharmony_ci const char *alias_id); 21862306a36Sopenharmony_civoid regulator_unregister_supply_alias(struct device *dev, const char *id); 21962306a36Sopenharmony_ci 22062306a36Sopenharmony_ciint regulator_bulk_register_supply_alias(struct device *dev, 22162306a36Sopenharmony_ci const char *const *id, 22262306a36Sopenharmony_ci struct device *alias_dev, 22362306a36Sopenharmony_ci const char *const *alias_id, 22462306a36Sopenharmony_ci int num_id); 22562306a36Sopenharmony_civoid regulator_bulk_unregister_supply_alias(struct device *dev, 22662306a36Sopenharmony_ci const char * const *id, int num_id); 22762306a36Sopenharmony_ci 22862306a36Sopenharmony_ciint devm_regulator_register_supply_alias(struct device *dev, const char *id, 22962306a36Sopenharmony_ci struct device *alias_dev, 23062306a36Sopenharmony_ci const char *alias_id); 23162306a36Sopenharmony_ci 23262306a36Sopenharmony_ciint devm_regulator_bulk_register_supply_alias(struct device *dev, 23362306a36Sopenharmony_ci const char *const *id, 23462306a36Sopenharmony_ci struct device *alias_dev, 23562306a36Sopenharmony_ci const char *const *alias_id, 23662306a36Sopenharmony_ci int num_id); 23762306a36Sopenharmony_ci 23862306a36Sopenharmony_ci/* regulator output control and status */ 23962306a36Sopenharmony_ciint __must_check regulator_enable(struct regulator *regulator); 24062306a36Sopenharmony_ciint regulator_disable(struct regulator *regulator); 24162306a36Sopenharmony_ciint regulator_force_disable(struct regulator *regulator); 24262306a36Sopenharmony_ciint regulator_is_enabled(struct regulator *regulator); 24362306a36Sopenharmony_ciint regulator_disable_deferred(struct regulator *regulator, int ms); 24462306a36Sopenharmony_ci 24562306a36Sopenharmony_ciint __must_check regulator_bulk_get(struct device *dev, int num_consumers, 24662306a36Sopenharmony_ci struct regulator_bulk_data *consumers); 24762306a36Sopenharmony_ciint __must_check of_regulator_bulk_get_all(struct device *dev, struct device_node *np, 24862306a36Sopenharmony_ci struct regulator_bulk_data **consumers); 24962306a36Sopenharmony_ciint __must_check devm_regulator_bulk_get(struct device *dev, int num_consumers, 25062306a36Sopenharmony_ci struct regulator_bulk_data *consumers); 25162306a36Sopenharmony_civoid devm_regulator_bulk_put(struct regulator_bulk_data *consumers); 25262306a36Sopenharmony_ciint __must_check devm_regulator_bulk_get_exclusive(struct device *dev, int num_consumers, 25362306a36Sopenharmony_ci struct regulator_bulk_data *consumers); 25462306a36Sopenharmony_ciint __must_check devm_regulator_bulk_get_const( 25562306a36Sopenharmony_ci struct device *dev, int num_consumers, 25662306a36Sopenharmony_ci const struct regulator_bulk_data *in_consumers, 25762306a36Sopenharmony_ci struct regulator_bulk_data **out_consumers); 25862306a36Sopenharmony_ciint __must_check regulator_bulk_enable(int num_consumers, 25962306a36Sopenharmony_ci struct regulator_bulk_data *consumers); 26062306a36Sopenharmony_ciint devm_regulator_bulk_get_enable(struct device *dev, int num_consumers, 26162306a36Sopenharmony_ci const char * const *id); 26262306a36Sopenharmony_ciint regulator_bulk_disable(int num_consumers, 26362306a36Sopenharmony_ci struct regulator_bulk_data *consumers); 26462306a36Sopenharmony_ciint regulator_bulk_force_disable(int num_consumers, 26562306a36Sopenharmony_ci struct regulator_bulk_data *consumers); 26662306a36Sopenharmony_civoid regulator_bulk_free(int num_consumers, 26762306a36Sopenharmony_ci struct regulator_bulk_data *consumers); 26862306a36Sopenharmony_ci 26962306a36Sopenharmony_ciint regulator_count_voltages(struct regulator *regulator); 27062306a36Sopenharmony_ciint regulator_list_voltage(struct regulator *regulator, unsigned selector); 27162306a36Sopenharmony_ciint regulator_is_supported_voltage(struct regulator *regulator, 27262306a36Sopenharmony_ci int min_uV, int max_uV); 27362306a36Sopenharmony_ciunsigned int regulator_get_linear_step(struct regulator *regulator); 27462306a36Sopenharmony_ciint regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV); 27562306a36Sopenharmony_ciint regulator_set_voltage_time(struct regulator *regulator, 27662306a36Sopenharmony_ci int old_uV, int new_uV); 27762306a36Sopenharmony_ciint regulator_get_voltage(struct regulator *regulator); 27862306a36Sopenharmony_ciint regulator_sync_voltage(struct regulator *regulator); 27962306a36Sopenharmony_ciint regulator_set_current_limit(struct regulator *regulator, 28062306a36Sopenharmony_ci int min_uA, int max_uA); 28162306a36Sopenharmony_ciint regulator_get_current_limit(struct regulator *regulator); 28262306a36Sopenharmony_ci 28362306a36Sopenharmony_ciint regulator_set_mode(struct regulator *regulator, unsigned int mode); 28462306a36Sopenharmony_ciunsigned int regulator_get_mode(struct regulator *regulator); 28562306a36Sopenharmony_ciint regulator_get_error_flags(struct regulator *regulator, 28662306a36Sopenharmony_ci unsigned int *flags); 28762306a36Sopenharmony_ciint regulator_set_load(struct regulator *regulator, int load_uA); 28862306a36Sopenharmony_ci 28962306a36Sopenharmony_ciint regulator_allow_bypass(struct regulator *regulator, bool allow); 29062306a36Sopenharmony_ci 29162306a36Sopenharmony_cistruct regmap *regulator_get_regmap(struct regulator *regulator); 29262306a36Sopenharmony_ciint regulator_get_hardware_vsel_register(struct regulator *regulator, 29362306a36Sopenharmony_ci unsigned *vsel_reg, 29462306a36Sopenharmony_ci unsigned *vsel_mask); 29562306a36Sopenharmony_ciint regulator_list_hardware_vsel(struct regulator *regulator, 29662306a36Sopenharmony_ci unsigned selector); 29762306a36Sopenharmony_ci 29862306a36Sopenharmony_ci/* regulator notifier block */ 29962306a36Sopenharmony_ciint regulator_register_notifier(struct regulator *regulator, 30062306a36Sopenharmony_ci struct notifier_block *nb); 30162306a36Sopenharmony_ciint devm_regulator_register_notifier(struct regulator *regulator, 30262306a36Sopenharmony_ci struct notifier_block *nb); 30362306a36Sopenharmony_ciint regulator_unregister_notifier(struct regulator *regulator, 30462306a36Sopenharmony_ci struct notifier_block *nb); 30562306a36Sopenharmony_civoid devm_regulator_unregister_notifier(struct regulator *regulator, 30662306a36Sopenharmony_ci struct notifier_block *nb); 30762306a36Sopenharmony_ci 30862306a36Sopenharmony_ci/* regulator suspend */ 30962306a36Sopenharmony_ciint regulator_suspend_enable(struct regulator_dev *rdev, 31062306a36Sopenharmony_ci suspend_state_t state); 31162306a36Sopenharmony_ciint regulator_suspend_disable(struct regulator_dev *rdev, 31262306a36Sopenharmony_ci suspend_state_t state); 31362306a36Sopenharmony_ciint regulator_set_suspend_voltage(struct regulator *regulator, int min_uV, 31462306a36Sopenharmony_ci int max_uV, suspend_state_t state); 31562306a36Sopenharmony_ci 31662306a36Sopenharmony_ci/* driver data - core doesn't touch */ 31762306a36Sopenharmony_civoid *regulator_get_drvdata(struct regulator *regulator); 31862306a36Sopenharmony_civoid regulator_set_drvdata(struct regulator *regulator, void *data); 31962306a36Sopenharmony_ci 32062306a36Sopenharmony_ci/* misc helpers */ 32162306a36Sopenharmony_ci 32262306a36Sopenharmony_civoid regulator_bulk_set_supply_names(struct regulator_bulk_data *consumers, 32362306a36Sopenharmony_ci const char *const *supply_names, 32462306a36Sopenharmony_ci unsigned int num_supplies); 32562306a36Sopenharmony_ci 32662306a36Sopenharmony_cibool regulator_is_equal(struct regulator *reg1, struct regulator *reg2); 32762306a36Sopenharmony_ci 32862306a36Sopenharmony_ci#else 32962306a36Sopenharmony_ci 33062306a36Sopenharmony_ci/* 33162306a36Sopenharmony_ci * Make sure client drivers will still build on systems with no software 33262306a36Sopenharmony_ci * controllable voltage or current regulators. 33362306a36Sopenharmony_ci */ 33462306a36Sopenharmony_cistatic inline struct regulator *__must_check regulator_get(struct device *dev, 33562306a36Sopenharmony_ci const char *id) 33662306a36Sopenharmony_ci{ 33762306a36Sopenharmony_ci /* Nothing except the stubbed out regulator API should be 33862306a36Sopenharmony_ci * looking at the value except to check if it is an error 33962306a36Sopenharmony_ci * value. Drivers are free to handle NULL specifically by 34062306a36Sopenharmony_ci * skipping all regulator API calls, but they don't have to. 34162306a36Sopenharmony_ci * Drivers which don't, should make sure they properly handle 34262306a36Sopenharmony_ci * corner cases of the API, such as regulator_get_voltage() 34362306a36Sopenharmony_ci * returning 0. 34462306a36Sopenharmony_ci */ 34562306a36Sopenharmony_ci return NULL; 34662306a36Sopenharmony_ci} 34762306a36Sopenharmony_ci 34862306a36Sopenharmony_cistatic inline struct regulator *__must_check 34962306a36Sopenharmony_cidevm_regulator_get(struct device *dev, const char *id) 35062306a36Sopenharmony_ci{ 35162306a36Sopenharmony_ci return NULL; 35262306a36Sopenharmony_ci} 35362306a36Sopenharmony_ci 35462306a36Sopenharmony_cistatic inline struct regulator *__must_check 35562306a36Sopenharmony_ciregulator_get_exclusive(struct device *dev, const char *id) 35662306a36Sopenharmony_ci{ 35762306a36Sopenharmony_ci return ERR_PTR(-ENODEV); 35862306a36Sopenharmony_ci} 35962306a36Sopenharmony_ci 36062306a36Sopenharmony_cistatic inline struct regulator *__must_check 36162306a36Sopenharmony_cidevm_regulator_get_exclusive(struct device *dev, const char *id) 36262306a36Sopenharmony_ci{ 36362306a36Sopenharmony_ci return ERR_PTR(-ENODEV); 36462306a36Sopenharmony_ci} 36562306a36Sopenharmony_ci 36662306a36Sopenharmony_cistatic inline int devm_regulator_get_enable(struct device *dev, const char *id) 36762306a36Sopenharmony_ci{ 36862306a36Sopenharmony_ci return -ENODEV; 36962306a36Sopenharmony_ci} 37062306a36Sopenharmony_ci 37162306a36Sopenharmony_cistatic inline int devm_regulator_get_enable_optional(struct device *dev, 37262306a36Sopenharmony_ci const char *id) 37362306a36Sopenharmony_ci{ 37462306a36Sopenharmony_ci return -ENODEV; 37562306a36Sopenharmony_ci} 37662306a36Sopenharmony_ci 37762306a36Sopenharmony_cistatic inline struct regulator *__must_check 37862306a36Sopenharmony_ciregulator_get_optional(struct device *dev, const char *id) 37962306a36Sopenharmony_ci{ 38062306a36Sopenharmony_ci return ERR_PTR(-ENODEV); 38162306a36Sopenharmony_ci} 38262306a36Sopenharmony_ci 38362306a36Sopenharmony_ci 38462306a36Sopenharmony_cistatic inline struct regulator *__must_check 38562306a36Sopenharmony_cidevm_regulator_get_optional(struct device *dev, const char *id) 38662306a36Sopenharmony_ci{ 38762306a36Sopenharmony_ci return ERR_PTR(-ENODEV); 38862306a36Sopenharmony_ci} 38962306a36Sopenharmony_ci 39062306a36Sopenharmony_cistatic inline void regulator_put(struct regulator *regulator) 39162306a36Sopenharmony_ci{ 39262306a36Sopenharmony_ci} 39362306a36Sopenharmony_ci 39462306a36Sopenharmony_cistatic inline void devm_regulator_put(struct regulator *regulator) 39562306a36Sopenharmony_ci{ 39662306a36Sopenharmony_ci} 39762306a36Sopenharmony_ci 39862306a36Sopenharmony_cistatic inline void devm_regulator_bulk_put(struct regulator_bulk_data *consumers) 39962306a36Sopenharmony_ci{ 40062306a36Sopenharmony_ci} 40162306a36Sopenharmony_ci 40262306a36Sopenharmony_cistatic inline int regulator_register_supply_alias(struct device *dev, 40362306a36Sopenharmony_ci const char *id, 40462306a36Sopenharmony_ci struct device *alias_dev, 40562306a36Sopenharmony_ci const char *alias_id) 40662306a36Sopenharmony_ci{ 40762306a36Sopenharmony_ci return 0; 40862306a36Sopenharmony_ci} 40962306a36Sopenharmony_ci 41062306a36Sopenharmony_cistatic inline void regulator_unregister_supply_alias(struct device *dev, 41162306a36Sopenharmony_ci const char *id) 41262306a36Sopenharmony_ci{ 41362306a36Sopenharmony_ci} 41462306a36Sopenharmony_ci 41562306a36Sopenharmony_cistatic inline int regulator_bulk_register_supply_alias(struct device *dev, 41662306a36Sopenharmony_ci const char *const *id, 41762306a36Sopenharmony_ci struct device *alias_dev, 41862306a36Sopenharmony_ci const char * const *alias_id, 41962306a36Sopenharmony_ci int num_id) 42062306a36Sopenharmony_ci{ 42162306a36Sopenharmony_ci return 0; 42262306a36Sopenharmony_ci} 42362306a36Sopenharmony_ci 42462306a36Sopenharmony_cistatic inline void regulator_bulk_unregister_supply_alias(struct device *dev, 42562306a36Sopenharmony_ci const char * const *id, 42662306a36Sopenharmony_ci int num_id) 42762306a36Sopenharmony_ci{ 42862306a36Sopenharmony_ci} 42962306a36Sopenharmony_ci 43062306a36Sopenharmony_cistatic inline int devm_regulator_register_supply_alias(struct device *dev, 43162306a36Sopenharmony_ci const char *id, 43262306a36Sopenharmony_ci struct device *alias_dev, 43362306a36Sopenharmony_ci const char *alias_id) 43462306a36Sopenharmony_ci{ 43562306a36Sopenharmony_ci return 0; 43662306a36Sopenharmony_ci} 43762306a36Sopenharmony_ci 43862306a36Sopenharmony_cistatic inline int devm_regulator_bulk_register_supply_alias(struct device *dev, 43962306a36Sopenharmony_ci const char *const *id, 44062306a36Sopenharmony_ci struct device *alias_dev, 44162306a36Sopenharmony_ci const char *const *alias_id, 44262306a36Sopenharmony_ci int num_id) 44362306a36Sopenharmony_ci{ 44462306a36Sopenharmony_ci return 0; 44562306a36Sopenharmony_ci} 44662306a36Sopenharmony_ci 44762306a36Sopenharmony_cistatic inline int regulator_enable(struct regulator *regulator) 44862306a36Sopenharmony_ci{ 44962306a36Sopenharmony_ci return 0; 45062306a36Sopenharmony_ci} 45162306a36Sopenharmony_ci 45262306a36Sopenharmony_cistatic inline int regulator_disable(struct regulator *regulator) 45362306a36Sopenharmony_ci{ 45462306a36Sopenharmony_ci return 0; 45562306a36Sopenharmony_ci} 45662306a36Sopenharmony_ci 45762306a36Sopenharmony_cistatic inline int regulator_force_disable(struct regulator *regulator) 45862306a36Sopenharmony_ci{ 45962306a36Sopenharmony_ci return 0; 46062306a36Sopenharmony_ci} 46162306a36Sopenharmony_ci 46262306a36Sopenharmony_cistatic inline int regulator_disable_deferred(struct regulator *regulator, 46362306a36Sopenharmony_ci int ms) 46462306a36Sopenharmony_ci{ 46562306a36Sopenharmony_ci return 0; 46662306a36Sopenharmony_ci} 46762306a36Sopenharmony_ci 46862306a36Sopenharmony_cistatic inline int regulator_is_enabled(struct regulator *regulator) 46962306a36Sopenharmony_ci{ 47062306a36Sopenharmony_ci return 1; 47162306a36Sopenharmony_ci} 47262306a36Sopenharmony_ci 47362306a36Sopenharmony_cistatic inline int regulator_bulk_get(struct device *dev, 47462306a36Sopenharmony_ci int num_consumers, 47562306a36Sopenharmony_ci struct regulator_bulk_data *consumers) 47662306a36Sopenharmony_ci{ 47762306a36Sopenharmony_ci return 0; 47862306a36Sopenharmony_ci} 47962306a36Sopenharmony_ci 48062306a36Sopenharmony_cistatic inline int devm_regulator_bulk_get(struct device *dev, int num_consumers, 48162306a36Sopenharmony_ci struct regulator_bulk_data *consumers) 48262306a36Sopenharmony_ci{ 48362306a36Sopenharmony_ci return 0; 48462306a36Sopenharmony_ci} 48562306a36Sopenharmony_ci 48662306a36Sopenharmony_cistatic inline int of_regulator_bulk_get_all(struct device *dev, struct device_node *np, 48762306a36Sopenharmony_ci struct regulator_bulk_data **consumers) 48862306a36Sopenharmony_ci{ 48962306a36Sopenharmony_ci return 0; 49062306a36Sopenharmony_ci} 49162306a36Sopenharmony_ci 49262306a36Sopenharmony_cistatic inline int regulator_bulk_enable(int num_consumers, 49362306a36Sopenharmony_ci struct regulator_bulk_data *consumers) 49462306a36Sopenharmony_ci{ 49562306a36Sopenharmony_ci return 0; 49662306a36Sopenharmony_ci} 49762306a36Sopenharmony_ci 49862306a36Sopenharmony_cistatic inline int devm_regulator_bulk_get_enable(struct device *dev, 49962306a36Sopenharmony_ci int num_consumers, 50062306a36Sopenharmony_ci const char * const *id) 50162306a36Sopenharmony_ci{ 50262306a36Sopenharmony_ci return 0; 50362306a36Sopenharmony_ci} 50462306a36Sopenharmony_ci 50562306a36Sopenharmony_cistatic inline int regulator_bulk_disable(int num_consumers, 50662306a36Sopenharmony_ci struct regulator_bulk_data *consumers) 50762306a36Sopenharmony_ci{ 50862306a36Sopenharmony_ci return 0; 50962306a36Sopenharmony_ci} 51062306a36Sopenharmony_ci 51162306a36Sopenharmony_cistatic inline int regulator_bulk_force_disable(int num_consumers, 51262306a36Sopenharmony_ci struct regulator_bulk_data *consumers) 51362306a36Sopenharmony_ci{ 51462306a36Sopenharmony_ci return 0; 51562306a36Sopenharmony_ci} 51662306a36Sopenharmony_ci 51762306a36Sopenharmony_cistatic inline void regulator_bulk_free(int num_consumers, 51862306a36Sopenharmony_ci struct regulator_bulk_data *consumers) 51962306a36Sopenharmony_ci{ 52062306a36Sopenharmony_ci} 52162306a36Sopenharmony_ci 52262306a36Sopenharmony_cistatic inline int regulator_set_voltage(struct regulator *regulator, 52362306a36Sopenharmony_ci int min_uV, int max_uV) 52462306a36Sopenharmony_ci{ 52562306a36Sopenharmony_ci return 0; 52662306a36Sopenharmony_ci} 52762306a36Sopenharmony_ci 52862306a36Sopenharmony_cistatic inline int regulator_set_voltage_time(struct regulator *regulator, 52962306a36Sopenharmony_ci int old_uV, int new_uV) 53062306a36Sopenharmony_ci{ 53162306a36Sopenharmony_ci return 0; 53262306a36Sopenharmony_ci} 53362306a36Sopenharmony_ci 53462306a36Sopenharmony_cistatic inline int regulator_get_voltage(struct regulator *regulator) 53562306a36Sopenharmony_ci{ 53662306a36Sopenharmony_ci return -EINVAL; 53762306a36Sopenharmony_ci} 53862306a36Sopenharmony_ci 53962306a36Sopenharmony_cistatic inline int regulator_sync_voltage(struct regulator *regulator) 54062306a36Sopenharmony_ci{ 54162306a36Sopenharmony_ci return -EINVAL; 54262306a36Sopenharmony_ci} 54362306a36Sopenharmony_ci 54462306a36Sopenharmony_cistatic inline int regulator_is_supported_voltage(struct regulator *regulator, 54562306a36Sopenharmony_ci int min_uV, int max_uV) 54662306a36Sopenharmony_ci{ 54762306a36Sopenharmony_ci return 0; 54862306a36Sopenharmony_ci} 54962306a36Sopenharmony_ci 55062306a36Sopenharmony_cistatic inline unsigned int regulator_get_linear_step(struct regulator *regulator) 55162306a36Sopenharmony_ci{ 55262306a36Sopenharmony_ci return 0; 55362306a36Sopenharmony_ci} 55462306a36Sopenharmony_ci 55562306a36Sopenharmony_cistatic inline int regulator_set_current_limit(struct regulator *regulator, 55662306a36Sopenharmony_ci int min_uA, int max_uA) 55762306a36Sopenharmony_ci{ 55862306a36Sopenharmony_ci return 0; 55962306a36Sopenharmony_ci} 56062306a36Sopenharmony_ci 56162306a36Sopenharmony_cistatic inline int regulator_get_current_limit(struct regulator *regulator) 56262306a36Sopenharmony_ci{ 56362306a36Sopenharmony_ci return 0; 56462306a36Sopenharmony_ci} 56562306a36Sopenharmony_ci 56662306a36Sopenharmony_cistatic inline int regulator_set_mode(struct regulator *regulator, 56762306a36Sopenharmony_ci unsigned int mode) 56862306a36Sopenharmony_ci{ 56962306a36Sopenharmony_ci return 0; 57062306a36Sopenharmony_ci} 57162306a36Sopenharmony_ci 57262306a36Sopenharmony_cistatic inline unsigned int regulator_get_mode(struct regulator *regulator) 57362306a36Sopenharmony_ci{ 57462306a36Sopenharmony_ci return REGULATOR_MODE_NORMAL; 57562306a36Sopenharmony_ci} 57662306a36Sopenharmony_ci 57762306a36Sopenharmony_cistatic inline int regulator_get_error_flags(struct regulator *regulator, 57862306a36Sopenharmony_ci unsigned int *flags) 57962306a36Sopenharmony_ci{ 58062306a36Sopenharmony_ci return -EINVAL; 58162306a36Sopenharmony_ci} 58262306a36Sopenharmony_ci 58362306a36Sopenharmony_cistatic inline int regulator_set_load(struct regulator *regulator, int load_uA) 58462306a36Sopenharmony_ci{ 58562306a36Sopenharmony_ci return 0; 58662306a36Sopenharmony_ci} 58762306a36Sopenharmony_ci 58862306a36Sopenharmony_cistatic inline int regulator_allow_bypass(struct regulator *regulator, 58962306a36Sopenharmony_ci bool allow) 59062306a36Sopenharmony_ci{ 59162306a36Sopenharmony_ci return 0; 59262306a36Sopenharmony_ci} 59362306a36Sopenharmony_ci 59462306a36Sopenharmony_cistatic inline struct regmap *regulator_get_regmap(struct regulator *regulator) 59562306a36Sopenharmony_ci{ 59662306a36Sopenharmony_ci return ERR_PTR(-EOPNOTSUPP); 59762306a36Sopenharmony_ci} 59862306a36Sopenharmony_ci 59962306a36Sopenharmony_cistatic inline int regulator_get_hardware_vsel_register(struct regulator *regulator, 60062306a36Sopenharmony_ci unsigned *vsel_reg, 60162306a36Sopenharmony_ci unsigned *vsel_mask) 60262306a36Sopenharmony_ci{ 60362306a36Sopenharmony_ci return -EOPNOTSUPP; 60462306a36Sopenharmony_ci} 60562306a36Sopenharmony_ci 60662306a36Sopenharmony_cistatic inline int regulator_list_hardware_vsel(struct regulator *regulator, 60762306a36Sopenharmony_ci unsigned selector) 60862306a36Sopenharmony_ci{ 60962306a36Sopenharmony_ci return -EOPNOTSUPP; 61062306a36Sopenharmony_ci} 61162306a36Sopenharmony_ci 61262306a36Sopenharmony_cistatic inline int regulator_register_notifier(struct regulator *regulator, 61362306a36Sopenharmony_ci struct notifier_block *nb) 61462306a36Sopenharmony_ci{ 61562306a36Sopenharmony_ci return 0; 61662306a36Sopenharmony_ci} 61762306a36Sopenharmony_ci 61862306a36Sopenharmony_cistatic inline int devm_regulator_register_notifier(struct regulator *regulator, 61962306a36Sopenharmony_ci struct notifier_block *nb) 62062306a36Sopenharmony_ci{ 62162306a36Sopenharmony_ci return 0; 62262306a36Sopenharmony_ci} 62362306a36Sopenharmony_ci 62462306a36Sopenharmony_cistatic inline int regulator_unregister_notifier(struct regulator *regulator, 62562306a36Sopenharmony_ci struct notifier_block *nb) 62662306a36Sopenharmony_ci{ 62762306a36Sopenharmony_ci return 0; 62862306a36Sopenharmony_ci} 62962306a36Sopenharmony_ci 63062306a36Sopenharmony_cistatic inline int devm_regulator_unregister_notifier(struct regulator *regulator, 63162306a36Sopenharmony_ci struct notifier_block *nb) 63262306a36Sopenharmony_ci{ 63362306a36Sopenharmony_ci return 0; 63462306a36Sopenharmony_ci} 63562306a36Sopenharmony_ci 63662306a36Sopenharmony_cistatic inline int regulator_suspend_enable(struct regulator_dev *rdev, 63762306a36Sopenharmony_ci suspend_state_t state) 63862306a36Sopenharmony_ci{ 63962306a36Sopenharmony_ci return -EINVAL; 64062306a36Sopenharmony_ci} 64162306a36Sopenharmony_ci 64262306a36Sopenharmony_cistatic inline int regulator_suspend_disable(struct regulator_dev *rdev, 64362306a36Sopenharmony_ci suspend_state_t state) 64462306a36Sopenharmony_ci{ 64562306a36Sopenharmony_ci return -EINVAL; 64662306a36Sopenharmony_ci} 64762306a36Sopenharmony_ci 64862306a36Sopenharmony_cistatic inline int regulator_set_suspend_voltage(struct regulator *regulator, 64962306a36Sopenharmony_ci int min_uV, int max_uV, 65062306a36Sopenharmony_ci suspend_state_t state) 65162306a36Sopenharmony_ci{ 65262306a36Sopenharmony_ci return -EINVAL; 65362306a36Sopenharmony_ci} 65462306a36Sopenharmony_ci 65562306a36Sopenharmony_cistatic inline void *regulator_get_drvdata(struct regulator *regulator) 65662306a36Sopenharmony_ci{ 65762306a36Sopenharmony_ci return NULL; 65862306a36Sopenharmony_ci} 65962306a36Sopenharmony_ci 66062306a36Sopenharmony_cistatic inline void regulator_set_drvdata(struct regulator *regulator, 66162306a36Sopenharmony_ci void *data) 66262306a36Sopenharmony_ci{ 66362306a36Sopenharmony_ci} 66462306a36Sopenharmony_ci 66562306a36Sopenharmony_cistatic inline int regulator_count_voltages(struct regulator *regulator) 66662306a36Sopenharmony_ci{ 66762306a36Sopenharmony_ci return 0; 66862306a36Sopenharmony_ci} 66962306a36Sopenharmony_ci 67062306a36Sopenharmony_cistatic inline int regulator_list_voltage(struct regulator *regulator, unsigned selector) 67162306a36Sopenharmony_ci{ 67262306a36Sopenharmony_ci return -EINVAL; 67362306a36Sopenharmony_ci} 67462306a36Sopenharmony_ci 67562306a36Sopenharmony_cistatic inline void 67662306a36Sopenharmony_ciregulator_bulk_set_supply_names(struct regulator_bulk_data *consumers, 67762306a36Sopenharmony_ci const char *const *supply_names, 67862306a36Sopenharmony_ci unsigned int num_supplies) 67962306a36Sopenharmony_ci{ 68062306a36Sopenharmony_ci} 68162306a36Sopenharmony_ci 68262306a36Sopenharmony_cistatic inline bool 68362306a36Sopenharmony_ciregulator_is_equal(struct regulator *reg1, struct regulator *reg2) 68462306a36Sopenharmony_ci{ 68562306a36Sopenharmony_ci return false; 68662306a36Sopenharmony_ci} 68762306a36Sopenharmony_ci#endif 68862306a36Sopenharmony_ci 68962306a36Sopenharmony_cistatic inline int regulator_set_voltage_triplet(struct regulator *regulator, 69062306a36Sopenharmony_ci int min_uV, int target_uV, 69162306a36Sopenharmony_ci int max_uV) 69262306a36Sopenharmony_ci{ 69362306a36Sopenharmony_ci if (regulator_set_voltage(regulator, target_uV, max_uV) == 0) 69462306a36Sopenharmony_ci return 0; 69562306a36Sopenharmony_ci 69662306a36Sopenharmony_ci return regulator_set_voltage(regulator, min_uV, max_uV); 69762306a36Sopenharmony_ci} 69862306a36Sopenharmony_ci 69962306a36Sopenharmony_cistatic inline int regulator_set_voltage_tol(struct regulator *regulator, 70062306a36Sopenharmony_ci int new_uV, int tol_uV) 70162306a36Sopenharmony_ci{ 70262306a36Sopenharmony_ci if (regulator_set_voltage(regulator, new_uV, new_uV + tol_uV) == 0) 70362306a36Sopenharmony_ci return 0; 70462306a36Sopenharmony_ci else 70562306a36Sopenharmony_ci return regulator_set_voltage(regulator, 70662306a36Sopenharmony_ci new_uV - tol_uV, new_uV + tol_uV); 70762306a36Sopenharmony_ci} 70862306a36Sopenharmony_ci 70962306a36Sopenharmony_cistatic inline int regulator_is_supported_voltage_tol(struct regulator *regulator, 71062306a36Sopenharmony_ci int target_uV, int tol_uV) 71162306a36Sopenharmony_ci{ 71262306a36Sopenharmony_ci return regulator_is_supported_voltage(regulator, 71362306a36Sopenharmony_ci target_uV - tol_uV, 71462306a36Sopenharmony_ci target_uV + tol_uV); 71562306a36Sopenharmony_ci} 71662306a36Sopenharmony_ci 71762306a36Sopenharmony_ci#endif 718