Mark Brown | 0cdfcc0 | 2013-09-11 13:15:40 +0100 | [diff] [blame] | 1 | /* |
| 2 | * internal.h -- Voltage/Current Regulator framework internal code |
| 3 | * |
| 4 | * Copyright 2007, 2008 Wolfson Microelectronics PLC. |
| 5 | * Copyright 2008 SlimLogic Ltd. |
| 6 | * |
| 7 | * Author: Liam Girdwood <lrg@slimlogic.co.uk> |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify it |
| 10 | * under the terms of the GNU General Public License as published by the |
| 11 | * Free Software Foundation; either version 2 of the License, or (at your |
| 12 | * option) any later version. |
| 13 | * |
| 14 | */ |
| 15 | |
| 16 | #ifndef __REGULATOR_INTERNAL_H |
| 17 | #define __REGULATOR_INTERNAL_H |
| 18 | |
Chunyan Zhang | c360a6d | 2018-01-26 21:08:44 +0800 | [diff] [blame] | 19 | #include <linux/suspend.h> |
| 20 | |
| 21 | #define REGULATOR_STATES_NUM (PM_SUSPEND_MAX + 1) |
| 22 | |
| 23 | struct regulator_voltage { |
| 24 | int min_uV; |
| 25 | int max_uV; |
| 26 | }; |
| 27 | |
Mark Brown | 0cdfcc0 | 2013-09-11 13:15:40 +0100 | [diff] [blame] | 28 | /* |
| 29 | * struct regulator |
| 30 | * |
| 31 | * One for each consumer device. |
Chunyan Zhang | c360a6d | 2018-01-26 21:08:44 +0800 | [diff] [blame] | 32 | * @voltage - a voltage array for each state of runtime, i.e.: |
| 33 | * PM_SUSPEND_ON |
| 34 | * PM_SUSPEND_TO_IDLE |
| 35 | * PM_SUSPEND_STANDBY |
| 36 | * PM_SUSPEND_MEM |
| 37 | * PM_SUSPEND_MAX |
Mark Brown | 0cdfcc0 | 2013-09-11 13:15:40 +0100 | [diff] [blame] | 38 | */ |
| 39 | struct regulator { |
| 40 | struct device *dev; |
| 41 | struct list_head list; |
| 42 | unsigned int always_on:1; |
| 43 | unsigned int bypass:1; |
| 44 | int uA_load; |
Chunyan Zhang | c360a6d | 2018-01-26 21:08:44 +0800 | [diff] [blame] | 45 | struct regulator_voltage voltage[REGULATOR_STATES_NUM]; |
Stephen Boyd | 0630b61 | 2017-03-16 18:07:14 -0700 | [diff] [blame] | 46 | const char *supply_name; |
Mark Brown | 0cdfcc0 | 2013-09-11 13:15:40 +0100 | [diff] [blame] | 47 | struct device_attribute dev_attr; |
| 48 | struct regulator_dev *rdev; |
| 49 | struct dentry *debugfs; |
| 50 | }; |
| 51 | |
Maciej Purski | 148096a | 2018-01-22 15:30:06 +0100 | [diff] [blame] | 52 | extern struct class regulator_class; |
| 53 | |
| 54 | static inline struct regulator_dev *dev_to_rdev(struct device *dev) |
| 55 | { |
| 56 | return container_of(dev, struct regulator_dev, dev); |
| 57 | } |
| 58 | |
Mark Brown | ef126a4 | 2014-09-10 15:17:01 +0100 | [diff] [blame] | 59 | #ifdef CONFIG_OF |
Changbin Du | 08813e0 | 2018-05-02 21:44:57 +0800 | [diff] [blame] | 60 | struct regulator_dev *of_find_regulator_by_node(struct device_node *np); |
Mark Brown | a0c7b16 | 2014-09-09 23:13:57 +0100 | [diff] [blame] | 61 | struct regulator_init_data *regulator_of_get_init_data(struct device *dev, |
| 62 | const struct regulator_desc *desc, |
Krzysztof Kozlowski | bfa21a0 | 2015-01-05 12:48:42 +0100 | [diff] [blame] | 63 | struct regulator_config *config, |
Mark Brown | a0c7b16 | 2014-09-09 23:13:57 +0100 | [diff] [blame] | 64 | struct device_node **node); |
Maciej Purski | a085a31 | 2018-04-23 16:33:39 +0200 | [diff] [blame^] | 65 | |
| 66 | struct regulator_dev *of_parse_coupled_regulator(struct regulator_dev *rdev, |
| 67 | int index); |
| 68 | |
| 69 | int of_get_n_coupled(struct regulator_dev *rdev); |
| 70 | |
| 71 | bool of_check_coupling_data(struct regulator_dev *rdev); |
| 72 | |
Mark Brown | ef126a4 | 2014-09-10 15:17:01 +0100 | [diff] [blame] | 73 | #else |
Changbin Du | 08813e0 | 2018-05-02 21:44:57 +0800 | [diff] [blame] | 74 | static inline struct regulator_dev * |
| 75 | of_find_regulator_by_node(struct device_node *np) |
| 76 | { |
| 77 | return NULL; |
| 78 | } |
| 79 | |
Mark Brown | ef126a4 | 2014-09-10 15:17:01 +0100 | [diff] [blame] | 80 | static inline struct regulator_init_data * |
| 81 | regulator_of_get_init_data(struct device *dev, |
| 82 | const struct regulator_desc *desc, |
Krzysztof Kozlowski | bfa21a0 | 2015-01-05 12:48:42 +0100 | [diff] [blame] | 83 | struct regulator_config *config, |
Mark Brown | ef126a4 | 2014-09-10 15:17:01 +0100 | [diff] [blame] | 84 | struct device_node **node) |
| 85 | { |
| 86 | return NULL; |
| 87 | } |
Mark Brown | a0c7b16 | 2014-09-09 23:13:57 +0100 | [diff] [blame] | 88 | |
Maciej Purski | a085a31 | 2018-04-23 16:33:39 +0200 | [diff] [blame^] | 89 | static inline struct regulator_dev * |
| 90 | of_parse_coupled_regulator(struct regulator_dev *rdev, |
| 91 | int index) |
| 92 | { |
| 93 | return NULL; |
| 94 | } |
| 95 | |
| 96 | static inline int of_get_n_coupled(struct regulator_dev *rdev) |
| 97 | { |
| 98 | return 0; |
| 99 | } |
| 100 | |
| 101 | static inline bool of_check_coupling_data(struct regulator_dev *rdev) |
| 102 | { |
| 103 | return false; |
| 104 | } |
| 105 | |
| 106 | #endif |
Dmitry Torokhov | a8bd42a | 2017-02-03 13:56:02 -0800 | [diff] [blame] | 107 | enum regulator_get_type { |
| 108 | NORMAL_GET, |
| 109 | EXCLUSIVE_GET, |
| 110 | OPTIONAL_GET, |
| 111 | MAX_GET_TYPE |
| 112 | }; |
| 113 | |
| 114 | struct regulator *_regulator_get(struct device *dev, const char *id, |
| 115 | enum regulator_get_type get_type); |
Mark Brown | 0cdfcc0 | 2013-09-11 13:15:40 +0100 | [diff] [blame] | 116 | #endif |