consumer.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * consumer.h -- SoC Regulator consumer support.
  4. *
  5. * Copyright (C) 2007, 2008 Wolfson Microelectronics PLC.
  6. *
  7. * Author: Liam Girdwood <[email protected]>
  8. *
  9. * Regulator Consumer Interface.
  10. *
  11. * A Power Management Regulator framework for SoC based devices.
  12. * Features:-
  13. * o Voltage and current level control.
  14. * o Operating mode control.
  15. * o Regulator status.
  16. * o sysfs entries for showing client devices and status
  17. *
  18. * EXPERIMENTAL FEATURES:
  19. * Dynamic Regulator operating Mode Switching (DRMS) - allows regulators
  20. * to use most efficient operating mode depending upon voltage and load and
  21. * is transparent to client drivers.
  22. *
  23. * e.g. Devices x,y,z share regulator r. Device x and y draw 20mA each during
  24. * IO and 1mA at idle. Device z draws 100mA when under load and 5mA when
  25. * idling. Regulator r has > 90% efficiency in NORMAL mode at loads > 100mA
  26. * but this drops rapidly to 60% when below 100mA. Regulator r has > 90%
  27. * efficiency in IDLE mode at loads < 10mA. Thus regulator r will operate
  28. * in normal mode for loads > 10mA and in IDLE mode for load <= 10mA.
  29. */
  30. #ifndef __LINUX_REGULATOR_CONSUMER_H_
  31. #define __LINUX_REGULATOR_CONSUMER_H_
  32. #include <linux/err.h>
  33. #include <linux/suspend.h>
  34. struct device;
  35. struct notifier_block;
  36. struct regmap;
  37. struct regulator_dev;
  38. /*
  39. * Regulator operating modes.
  40. *
  41. * Regulators can run in a variety of different operating modes depending on
  42. * output load. This allows further system power savings by selecting the
  43. * best (and most efficient) regulator mode for a desired load.
  44. *
  45. * Most drivers will only care about NORMAL. The modes below are generic and
  46. * will probably not match the naming convention of your regulator data sheet
  47. * but should match the use cases in the datasheet.
  48. *
  49. * In order of power efficiency (least efficient at top).
  50. *
  51. * Mode Description
  52. * FAST Regulator can handle fast changes in it's load.
  53. * e.g. useful in CPU voltage & frequency scaling where
  54. * load can quickly increase with CPU frequency increases.
  55. *
  56. * NORMAL Normal regulator power supply mode. Most drivers will
  57. * use this mode.
  58. *
  59. * IDLE Regulator runs in a more efficient mode for light
  60. * loads. Can be used for devices that have a low power
  61. * requirement during periods of inactivity. This mode
  62. * may be more noisy than NORMAL and may not be able
  63. * to handle fast load switching.
  64. *
  65. * STANDBY Regulator runs in the most efficient mode for very
  66. * light loads. Can be used by devices when they are
  67. * in a sleep/standby state. This mode is likely to be
  68. * the most noisy and may not be able to handle fast load
  69. * switching.
  70. *
  71. * NOTE: Most regulators will only support a subset of these modes. Some
  72. * will only just support NORMAL.
  73. *
  74. * These modes can be OR'ed together to make up a mask of valid register modes.
  75. */
  76. #define REGULATOR_MODE_INVALID 0x0
  77. #define REGULATOR_MODE_FAST 0x1
  78. #define REGULATOR_MODE_NORMAL 0x2
  79. #define REGULATOR_MODE_IDLE 0x4
  80. #define REGULATOR_MODE_STANDBY 0x8
  81. /*
  82. * Regulator notifier events.
  83. *
  84. * UNDER_VOLTAGE Regulator output is under voltage.
  85. * OVER_CURRENT Regulator output current is too high.
  86. * REGULATION_OUT Regulator output is out of regulation.
  87. * FAIL Regulator output has failed.
  88. * OVER_TEMP Regulator over temp.
  89. * FORCE_DISABLE Regulator forcibly shut down by software.
  90. * VOLTAGE_CHANGE Regulator voltage changed.
  91. * Data passed is old voltage cast to (void *).
  92. * DISABLE Regulator was disabled.
  93. * PRE_VOLTAGE_CHANGE Regulator is about to have voltage changed.
  94. * Data passed is "struct pre_voltage_change_data"
  95. * ABORT_VOLTAGE_CHANGE Regulator voltage change failed for some reason.
  96. * Data passed is old voltage cast to (void *).
  97. * PRE_DISABLE Regulator is about to be disabled
  98. * ABORT_DISABLE Regulator disable failed for some reason
  99. *
  100. * NOTE: These events can be OR'ed together when passed into handler.
  101. */
  102. #define REGULATOR_EVENT_UNDER_VOLTAGE 0x01
  103. #define REGULATOR_EVENT_OVER_CURRENT 0x02
  104. #define REGULATOR_EVENT_REGULATION_OUT 0x04
  105. #define REGULATOR_EVENT_FAIL 0x08
  106. #define REGULATOR_EVENT_OVER_TEMP 0x10
  107. #define REGULATOR_EVENT_FORCE_DISABLE 0x20
  108. #define REGULATOR_EVENT_VOLTAGE_CHANGE 0x40
  109. #define REGULATOR_EVENT_DISABLE 0x80
  110. #define REGULATOR_EVENT_PRE_VOLTAGE_CHANGE 0x100
  111. #define REGULATOR_EVENT_ABORT_VOLTAGE_CHANGE 0x200
  112. #define REGULATOR_EVENT_PRE_DISABLE 0x400
  113. #define REGULATOR_EVENT_ABORT_DISABLE 0x800
  114. #define REGULATOR_EVENT_ENABLE 0x1000
  115. /*
  116. * Following notifications should be emitted only if detected condition
  117. * is such that the HW is likely to still be working but consumers should
  118. * take a recovery action to prevent problems esacalating into errors.
  119. */
  120. #define REGULATOR_EVENT_UNDER_VOLTAGE_WARN 0x2000
  121. #define REGULATOR_EVENT_OVER_CURRENT_WARN 0x4000
  122. #define REGULATOR_EVENT_OVER_VOLTAGE_WARN 0x8000
  123. #define REGULATOR_EVENT_OVER_TEMP_WARN 0x10000
  124. #define REGULATOR_EVENT_WARN_MASK 0x1E000
  125. /*
  126. * Regulator errors that can be queried using regulator_get_error_flags
  127. *
  128. * UNDER_VOLTAGE Regulator output is under voltage.
  129. * OVER_CURRENT Regulator output current is too high.
  130. * REGULATION_OUT Regulator output is out of regulation.
  131. * FAIL Regulator output has failed.
  132. * OVER_TEMP Regulator over temp.
  133. *
  134. * NOTE: These errors can be OR'ed together.
  135. */
  136. #define REGULATOR_ERROR_UNDER_VOLTAGE BIT(1)
  137. #define REGULATOR_ERROR_OVER_CURRENT BIT(2)
  138. #define REGULATOR_ERROR_REGULATION_OUT BIT(3)
  139. #define REGULATOR_ERROR_FAIL BIT(4)
  140. #define REGULATOR_ERROR_OVER_TEMP BIT(5)
  141. #define REGULATOR_ERROR_UNDER_VOLTAGE_WARN BIT(6)
  142. #define REGULATOR_ERROR_OVER_CURRENT_WARN BIT(7)
  143. #define REGULATOR_ERROR_OVER_VOLTAGE_WARN BIT(8)
  144. #define REGULATOR_ERROR_OVER_TEMP_WARN BIT(9)
  145. /**
  146. * struct pre_voltage_change_data - Data sent with PRE_VOLTAGE_CHANGE event
  147. *
  148. * @old_uV: Current voltage before change.
  149. * @min_uV: Min voltage we'll change to.
  150. * @max_uV: Max voltage we'll change to.
  151. */
  152. struct pre_voltage_change_data {
  153. unsigned long old_uV;
  154. unsigned long min_uV;
  155. unsigned long max_uV;
  156. };
  157. struct regulator;
  158. /**
  159. * struct regulator_bulk_data - Data used for bulk regulator operations.
  160. *
  161. * @supply: The name of the supply. Initialised by the user before
  162. * using the bulk regulator APIs.
  163. * @init_load_uA: After getting the regulator, regulator_set_load() will be
  164. * called with this load. Initialised by the user before
  165. * using the bulk regulator APIs.
  166. * @consumer: The regulator consumer for the supply. This will be managed
  167. * by the bulk API.
  168. *
  169. * The regulator APIs provide a series of regulator_bulk_() API calls as
  170. * a convenience to consumers which require multiple supplies. This
  171. * structure is used to manage data for these calls.
  172. */
  173. struct regulator_bulk_data {
  174. const char *supply;
  175. int init_load_uA;
  176. struct regulator *consumer;
  177. /* private: Internal use */
  178. int ret;
  179. };
  180. #if defined(CONFIG_REGULATOR)
  181. /* regulator get and put */
  182. struct regulator *__must_check regulator_get(struct device *dev,
  183. const char *id);
  184. struct regulator *__must_check devm_regulator_get(struct device *dev,
  185. const char *id);
  186. struct regulator *__must_check regulator_get_exclusive(struct device *dev,
  187. const char *id);
  188. struct regulator *__must_check devm_regulator_get_exclusive(struct device *dev,
  189. const char *id);
  190. struct regulator *__must_check regulator_get_optional(struct device *dev,
  191. const char *id);
  192. struct regulator *__must_check devm_regulator_get_optional(struct device *dev,
  193. const char *id);
  194. int devm_regulator_get_enable(struct device *dev, const char *id);
  195. int devm_regulator_get_enable_optional(struct device *dev, const char *id);
  196. void regulator_put(struct regulator *regulator);
  197. void devm_regulator_put(struct regulator *regulator);
  198. int regulator_register_supply_alias(struct device *dev, const char *id,
  199. struct device *alias_dev,
  200. const char *alias_id);
  201. void regulator_unregister_supply_alias(struct device *dev, const char *id);
  202. int regulator_bulk_register_supply_alias(struct device *dev,
  203. const char *const *id,
  204. struct device *alias_dev,
  205. const char *const *alias_id,
  206. int num_id);
  207. void regulator_bulk_unregister_supply_alias(struct device *dev,
  208. const char * const *id, int num_id);
  209. int devm_regulator_register_supply_alias(struct device *dev, const char *id,
  210. struct device *alias_dev,
  211. const char *alias_id);
  212. int devm_regulator_bulk_register_supply_alias(struct device *dev,
  213. const char *const *id,
  214. struct device *alias_dev,
  215. const char *const *alias_id,
  216. int num_id);
  217. /* regulator output control and status */
  218. int __must_check regulator_enable(struct regulator *regulator);
  219. int regulator_disable(struct regulator *regulator);
  220. int regulator_force_disable(struct regulator *regulator);
  221. int regulator_is_enabled(struct regulator *regulator);
  222. int regulator_disable_deferred(struct regulator *regulator, int ms);
  223. int __must_check regulator_bulk_get(struct device *dev, int num_consumers,
  224. struct regulator_bulk_data *consumers);
  225. int __must_check devm_regulator_bulk_get(struct device *dev, int num_consumers,
  226. struct regulator_bulk_data *consumers);
  227. void devm_regulator_bulk_put(struct regulator_bulk_data *consumers);
  228. int __must_check devm_regulator_bulk_get_const(
  229. struct device *dev, int num_consumers,
  230. const struct regulator_bulk_data *in_consumers,
  231. struct regulator_bulk_data **out_consumers);
  232. int __must_check regulator_bulk_enable(int num_consumers,
  233. struct regulator_bulk_data *consumers);
  234. int devm_regulator_bulk_get_enable(struct device *dev, int num_consumers,
  235. const char * const *id);
  236. int regulator_bulk_disable(int num_consumers,
  237. struct regulator_bulk_data *consumers);
  238. int regulator_bulk_force_disable(int num_consumers,
  239. struct regulator_bulk_data *consumers);
  240. void regulator_bulk_free(int num_consumers,
  241. struct regulator_bulk_data *consumers);
  242. int regulator_count_voltages(struct regulator *regulator);
  243. int regulator_list_voltage(struct regulator *regulator, unsigned selector);
  244. int regulator_is_supported_voltage(struct regulator *regulator,
  245. int min_uV, int max_uV);
  246. unsigned int regulator_get_linear_step(struct regulator *regulator);
  247. int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV);
  248. int regulator_set_voltage_time(struct regulator *regulator,
  249. int old_uV, int new_uV);
  250. int regulator_get_voltage(struct regulator *regulator);
  251. int regulator_sync_voltage(struct regulator *regulator);
  252. int regulator_set_current_limit(struct regulator *regulator,
  253. int min_uA, int max_uA);
  254. int regulator_get_current_limit(struct regulator *regulator);
  255. int regulator_set_mode(struct regulator *regulator, unsigned int mode);
  256. unsigned int regulator_get_mode(struct regulator *regulator);
  257. int regulator_get_error_flags(struct regulator *regulator,
  258. unsigned int *flags);
  259. int regulator_set_load(struct regulator *regulator, int load_uA);
  260. int regulator_allow_bypass(struct regulator *regulator, bool allow);
  261. struct regmap *regulator_get_regmap(struct regulator *regulator);
  262. int regulator_get_hardware_vsel_register(struct regulator *regulator,
  263. unsigned *vsel_reg,
  264. unsigned *vsel_mask);
  265. int regulator_list_hardware_vsel(struct regulator *regulator,
  266. unsigned selector);
  267. /* regulator notifier block */
  268. int regulator_register_notifier(struct regulator *regulator,
  269. struct notifier_block *nb);
  270. int devm_regulator_register_notifier(struct regulator *regulator,
  271. struct notifier_block *nb);
  272. int regulator_unregister_notifier(struct regulator *regulator,
  273. struct notifier_block *nb);
  274. void devm_regulator_unregister_notifier(struct regulator *regulator,
  275. struct notifier_block *nb);
  276. /* regulator suspend */
  277. int regulator_suspend_enable(struct regulator_dev *rdev,
  278. suspend_state_t state);
  279. int regulator_suspend_disable(struct regulator_dev *rdev,
  280. suspend_state_t state);
  281. int regulator_set_suspend_voltage(struct regulator *regulator, int min_uV,
  282. int max_uV, suspend_state_t state);
  283. /* driver data - core doesn't touch */
  284. void *regulator_get_drvdata(struct regulator *regulator);
  285. void regulator_set_drvdata(struct regulator *regulator, void *data);
  286. /* misc helpers */
  287. void regulator_bulk_set_supply_names(struct regulator_bulk_data *consumers,
  288. const char *const *supply_names,
  289. unsigned int num_supplies);
  290. bool regulator_is_equal(struct regulator *reg1, struct regulator *reg2);
  291. #else
  292. /*
  293. * Make sure client drivers will still build on systems with no software
  294. * controllable voltage or current regulators.
  295. */
  296. static inline struct regulator *__must_check regulator_get(struct device *dev,
  297. const char *id)
  298. {
  299. /* Nothing except the stubbed out regulator API should be
  300. * looking at the value except to check if it is an error
  301. * value. Drivers are free to handle NULL specifically by
  302. * skipping all regulator API calls, but they don't have to.
  303. * Drivers which don't, should make sure they properly handle
  304. * corner cases of the API, such as regulator_get_voltage()
  305. * returning 0.
  306. */
  307. return NULL;
  308. }
  309. static inline struct regulator *__must_check
  310. devm_regulator_get(struct device *dev, const char *id)
  311. {
  312. return NULL;
  313. }
  314. static inline struct regulator *__must_check
  315. regulator_get_exclusive(struct device *dev, const char *id)
  316. {
  317. return ERR_PTR(-ENODEV);
  318. }
  319. static inline struct regulator *__must_check
  320. devm_regulator_get_exclusive(struct device *dev, const char *id)
  321. {
  322. return ERR_PTR(-ENODEV);
  323. }
  324. static inline int devm_regulator_get_enable(struct device *dev, const char *id)
  325. {
  326. return -ENODEV;
  327. }
  328. static inline int devm_regulator_get_enable_optional(struct device *dev,
  329. const char *id)
  330. {
  331. return -ENODEV;
  332. }
  333. static inline struct regulator *__must_check
  334. regulator_get_optional(struct device *dev, const char *id)
  335. {
  336. return ERR_PTR(-ENODEV);
  337. }
  338. static inline struct regulator *__must_check
  339. devm_regulator_get_optional(struct device *dev, const char *id)
  340. {
  341. return ERR_PTR(-ENODEV);
  342. }
  343. static inline void regulator_put(struct regulator *regulator)
  344. {
  345. }
  346. static inline void devm_regulator_put(struct regulator *regulator)
  347. {
  348. }
  349. static inline void devm_regulator_bulk_put(struct regulator_bulk_data *consumers)
  350. {
  351. }
  352. static inline int regulator_register_supply_alias(struct device *dev,
  353. const char *id,
  354. struct device *alias_dev,
  355. const char *alias_id)
  356. {
  357. return 0;
  358. }
  359. static inline void regulator_unregister_supply_alias(struct device *dev,
  360. const char *id)
  361. {
  362. }
  363. static inline int regulator_bulk_register_supply_alias(struct device *dev,
  364. const char *const *id,
  365. struct device *alias_dev,
  366. const char * const *alias_id,
  367. int num_id)
  368. {
  369. return 0;
  370. }
  371. static inline void regulator_bulk_unregister_supply_alias(struct device *dev,
  372. const char * const *id,
  373. int num_id)
  374. {
  375. }
  376. static inline int devm_regulator_register_supply_alias(struct device *dev,
  377. const char *id,
  378. struct device *alias_dev,
  379. const char *alias_id)
  380. {
  381. return 0;
  382. }
  383. static inline int devm_regulator_bulk_register_supply_alias(struct device *dev,
  384. const char *const *id,
  385. struct device *alias_dev,
  386. const char *const *alias_id,
  387. int num_id)
  388. {
  389. return 0;
  390. }
  391. static inline int regulator_enable(struct regulator *regulator)
  392. {
  393. return 0;
  394. }
  395. static inline int regulator_disable(struct regulator *regulator)
  396. {
  397. return 0;
  398. }
  399. static inline int regulator_force_disable(struct regulator *regulator)
  400. {
  401. return 0;
  402. }
  403. static inline int regulator_disable_deferred(struct regulator *regulator,
  404. int ms)
  405. {
  406. return 0;
  407. }
  408. static inline int regulator_is_enabled(struct regulator *regulator)
  409. {
  410. return 1;
  411. }
  412. static inline int regulator_bulk_get(struct device *dev,
  413. int num_consumers,
  414. struct regulator_bulk_data *consumers)
  415. {
  416. return 0;
  417. }
  418. static inline int devm_regulator_bulk_get(struct device *dev, int num_consumers,
  419. struct regulator_bulk_data *consumers)
  420. {
  421. return 0;
  422. }
  423. static inline int regulator_bulk_enable(int num_consumers,
  424. struct regulator_bulk_data *consumers)
  425. {
  426. return 0;
  427. }
  428. static inline int devm_regulator_bulk_get_enable(struct device *dev,
  429. int num_consumers,
  430. const char * const *id)
  431. {
  432. return 0;
  433. }
  434. static inline int regulator_bulk_disable(int num_consumers,
  435. struct regulator_bulk_data *consumers)
  436. {
  437. return 0;
  438. }
  439. static inline int regulator_bulk_force_disable(int num_consumers,
  440. struct regulator_bulk_data *consumers)
  441. {
  442. return 0;
  443. }
  444. static inline void regulator_bulk_free(int num_consumers,
  445. struct regulator_bulk_data *consumers)
  446. {
  447. }
  448. static inline int regulator_set_voltage(struct regulator *regulator,
  449. int min_uV, int max_uV)
  450. {
  451. return 0;
  452. }
  453. static inline int regulator_set_voltage_time(struct regulator *regulator,
  454. int old_uV, int new_uV)
  455. {
  456. return 0;
  457. }
  458. static inline int regulator_get_voltage(struct regulator *regulator)
  459. {
  460. return -EINVAL;
  461. }
  462. static inline int regulator_sync_voltage(struct regulator *regulator)
  463. {
  464. return -EINVAL;
  465. }
  466. static inline int regulator_is_supported_voltage(struct regulator *regulator,
  467. int min_uV, int max_uV)
  468. {
  469. return 0;
  470. }
  471. static inline unsigned int regulator_get_linear_step(struct regulator *regulator)
  472. {
  473. return 0;
  474. }
  475. static inline int regulator_set_current_limit(struct regulator *regulator,
  476. int min_uA, int max_uA)
  477. {
  478. return 0;
  479. }
  480. static inline int regulator_get_current_limit(struct regulator *regulator)
  481. {
  482. return 0;
  483. }
  484. static inline int regulator_set_mode(struct regulator *regulator,
  485. unsigned int mode)
  486. {
  487. return 0;
  488. }
  489. static inline unsigned int regulator_get_mode(struct regulator *regulator)
  490. {
  491. return REGULATOR_MODE_NORMAL;
  492. }
  493. static inline int regulator_get_error_flags(struct regulator *regulator,
  494. unsigned int *flags)
  495. {
  496. return -EINVAL;
  497. }
  498. static inline int regulator_set_load(struct regulator *regulator, int load_uA)
  499. {
  500. return 0;
  501. }
  502. static inline int regulator_allow_bypass(struct regulator *regulator,
  503. bool allow)
  504. {
  505. return 0;
  506. }
  507. static inline struct regmap *regulator_get_regmap(struct regulator *regulator)
  508. {
  509. return ERR_PTR(-EOPNOTSUPP);
  510. }
  511. static inline int regulator_get_hardware_vsel_register(struct regulator *regulator,
  512. unsigned *vsel_reg,
  513. unsigned *vsel_mask)
  514. {
  515. return -EOPNOTSUPP;
  516. }
  517. static inline int regulator_list_hardware_vsel(struct regulator *regulator,
  518. unsigned selector)
  519. {
  520. return -EOPNOTSUPP;
  521. }
  522. static inline int regulator_register_notifier(struct regulator *regulator,
  523. struct notifier_block *nb)
  524. {
  525. return 0;
  526. }
  527. static inline int devm_regulator_register_notifier(struct regulator *regulator,
  528. struct notifier_block *nb)
  529. {
  530. return 0;
  531. }
  532. static inline int regulator_unregister_notifier(struct regulator *regulator,
  533. struct notifier_block *nb)
  534. {
  535. return 0;
  536. }
  537. static inline int devm_regulator_unregister_notifier(struct regulator *regulator,
  538. struct notifier_block *nb)
  539. {
  540. return 0;
  541. }
  542. static inline int regulator_suspend_enable(struct regulator_dev *rdev,
  543. suspend_state_t state)
  544. {
  545. return -EINVAL;
  546. }
  547. static inline int regulator_suspend_disable(struct regulator_dev *rdev,
  548. suspend_state_t state)
  549. {
  550. return -EINVAL;
  551. }
  552. static inline int regulator_set_suspend_voltage(struct regulator *regulator,
  553. int min_uV, int max_uV,
  554. suspend_state_t state)
  555. {
  556. return -EINVAL;
  557. }
  558. static inline void *regulator_get_drvdata(struct regulator *regulator)
  559. {
  560. return NULL;
  561. }
  562. static inline void regulator_set_drvdata(struct regulator *regulator,
  563. void *data)
  564. {
  565. }
  566. static inline int regulator_count_voltages(struct regulator *regulator)
  567. {
  568. return 0;
  569. }
  570. static inline int regulator_list_voltage(struct regulator *regulator, unsigned selector)
  571. {
  572. return -EINVAL;
  573. }
  574. static inline void
  575. regulator_bulk_set_supply_names(struct regulator_bulk_data *consumers,
  576. const char *const *supply_names,
  577. unsigned int num_supplies)
  578. {
  579. }
  580. static inline bool
  581. regulator_is_equal(struct regulator *reg1, struct regulator *reg2)
  582. {
  583. return false;
  584. }
  585. #endif
  586. static inline int regulator_set_voltage_triplet(struct regulator *regulator,
  587. int min_uV, int target_uV,
  588. int max_uV)
  589. {
  590. if (regulator_set_voltage(regulator, target_uV, max_uV) == 0)
  591. return 0;
  592. return regulator_set_voltage(regulator, min_uV, max_uV);
  593. }
  594. static inline int regulator_set_voltage_tol(struct regulator *regulator,
  595. int new_uV, int tol_uV)
  596. {
  597. if (regulator_set_voltage(regulator, new_uV, new_uV + tol_uV) == 0)
  598. return 0;
  599. else
  600. return regulator_set_voltage(regulator,
  601. new_uV - tol_uV, new_uV + tol_uV);
  602. }
  603. static inline int regulator_is_supported_voltage_tol(struct regulator *regulator,
  604. int target_uV, int tol_uV)
  605. {
  606. return regulator_is_supported_voltage(regulator,
  607. target_uV - tol_uV,
  608. target_uV + tol_uV);
  609. }
  610. #endif