Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 | /* * consumer.h -- SoC Regulator consumer support. * * Copyright (C) 2007, 2008 Wolfson Microelectronics PLC. * * Author: Liam Girdwood <lg@opensource.wolfsonmicro.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * Regulator Consumer Interface. * * A Power Management Regulator framework for SoC based devices. * Features:- * o Voltage and current level control. * o Operating mode control. * o Regulator status. * o sysfs entries for showing client devices and status * * EXPERIMENTAL FEATURES: * Dynamic Regulator operating Mode Switching (DRMS) - allows regulators * to use most efficient operating mode depending upon voltage and load and * is transparent to client drivers. * * e.g. Devices x,y,z share regulator r. Device x and y draw 20mA each during * IO and 1mA at idle. Device z draws 100mA when under load and 5mA when * idling. Regulator r has > 90% efficiency in NORMAL mode at loads > 100mA * but this drops rapidly to 60% when below 100mA. Regulator r has > 90% * efficiency in IDLE mode at loads < 10mA. Thus regulator r will operate * in normal mode for loads > 10mA and in IDLE mode for load <= 10mA. * */ #ifndef __LINUX_REGULATOR_CONSUMER_H_ #define __LINUX_REGULATOR_CONSUMER_H_ /* * Regulator operating modes. * * Regulators can run in a variety of different operating modes depending on * output load. This allows further system power savings by selecting the * best (and most efficient) regulator mode for a desired load. * * Most drivers will only care about NORMAL. The modes below are generic and * will probably not match the naming convention of your regulator data sheet * but should match the use cases in the datasheet. * * In order of power efficiency (least efficient at top). * * Mode Description * FAST Regulator can handle fast changes in it's load. * e.g. useful in CPU voltage & frequency scaling where * load can quickly increase with CPU frequency increases. * * NORMAL Normal regulator power supply mode. Most drivers will * use this mode. * * IDLE Regulator runs in a more efficient mode for light * loads. Can be used for devices that have a low power * requirement during periods of inactivity. This mode * may be more noisy than NORMAL and may not be able * to handle fast load switching. * * STANDBY Regulator runs in the most efficient mode for very * light loads. Can be used by devices when they are * in a sleep/standby state. This mode is likely to be * the most noisy and may not be able to handle fast load * switching. * * NOTE: Most regulators will only support a subset of these modes. Some * will only just support NORMAL. * * These modes can be OR'ed together to make up a mask of valid register modes. */ #define REGULATOR_MODE_FAST 0x1 #define REGULATOR_MODE_NORMAL 0x2 #define REGULATOR_MODE_IDLE 0x4 #define REGULATOR_MODE_STANDBY 0x8 /* * Regulator notifier events. * * UNDER_VOLTAGE Regulator output is under voltage. * OVER_CURRENT Regulator output current is too high. * REGULATION_OUT Regulator output is out of regulation. * FAIL Regulator output has failed. * OVER_TEMP Regulator over temp. * FORCE_DISABLE Regulator shut down by software. * * NOTE: These events can be OR'ed together when passed into handler. */ #define REGULATOR_EVENT_UNDER_VOLTAGE 0x01 #define REGULATOR_EVENT_OVER_CURRENT 0x02 #define REGULATOR_EVENT_REGULATION_OUT 0x04 #define REGULATOR_EVENT_FAIL 0x08 #define REGULATOR_EVENT_OVER_TEMP 0x10 #define REGULATOR_EVENT_FORCE_DISABLE 0x20 struct regulator; /** * struct regulator_bulk_data - Data used for bulk regulator operations. * * @supply The name of the supply. Initialised by the user before * using the bulk regulator APIs. * @consumer The regulator consumer for the supply. This will be managed * by the bulk API. * * The regulator APIs provide a series of regulator_bulk_() API calls as * a convenience to consumers which require multiple supplies. This * structure is used to manage data for these calls. */ struct regulator_bulk_data { const char *supply; struct regulator *consumer; }; #if defined(CONFIG_REGULATOR) /* regulator get and put */ struct regulator *__must_check regulator_get(struct device *dev, const char *id); void regulator_put(struct regulator *regulator); /* regulator output control and status */ int regulator_enable(struct regulator *regulator); int regulator_disable(struct regulator *regulator); int regulator_force_disable(struct regulator *regulator); int regulator_is_enabled(struct regulator *regulator); int regulator_bulk_get(struct device *dev, int num_consumers, struct regulator_bulk_data *consumers); int regulator_bulk_enable(int num_consumers, struct regulator_bulk_data *consumers); int regulator_bulk_disable(int num_consumers, struct regulator_bulk_data *consumers); void regulator_bulk_free(int num_consumers, struct regulator_bulk_data *consumers); int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV); int regulator_get_voltage(struct regulator *regulator); int regulator_set_current_limit(struct regulator *regulator, int min_uA, int max_uA); int regulator_get_current_limit(struct regulator *regulator); int regulator_set_mode(struct regulator *regulator, unsigned int mode); unsigned int regulator_get_mode(struct regulator *regulator); int regulator_set_optimum_mode(struct regulator *regulator, int load_uA); /* regulator notifier block */ int regulator_register_notifier(struct regulator *regulator, struct notifier_block *nb); int regulator_unregister_notifier(struct regulator *regulator, struct notifier_block *nb); /* driver data - core doesn't touch */ void *regulator_get_drvdata(struct regulator *regulator); void regulator_set_drvdata(struct regulator *regulator, void *data); #else /* * Make sure client drivers will still build on systems with no software * controllable voltage or current regulators. */ static inline struct regulator *__must_check regulator_get(struct device *dev, const char *id) { /* Nothing except the stubbed out regulator API should be * looking at the value except to check if it is an error * value so the actual return value doesn't matter. */ return (struct regulator *)id; } static inline void regulator_put(struct regulator *regulator) { } static inline int regulator_enable(struct regulator *regulator) { return 0; } static inline int regulator_disable(struct regulator *regulator) { return 0; } static inline int regulator_is_enabled(struct regulator *regulator) { return 1; } static inline int regulator_bulk_get(struct device *dev, int num_consumers, struct regulator_bulk_data *consumers) { return 0; } static inline int regulator_bulk_enable(int num_consumers, struct regulator_bulk_data *consumers) { return 0; } static inline int regulator_bulk_disable(int num_consumers, struct regulator_bulk_data *consumers) { return 0; } static inline void regulator_bulk_free(int num_consumers, struct regulator_bulk_data *consumers) { } static inline int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV) { return 0; } static inline int regulator_get_voltage(struct regulator *regulator) { return 0; } static inline int regulator_set_current_limit(struct regulator *regulator, int min_uA, int max_uA) { return 0; } static inline int regulator_get_current_limit(struct regulator *regulator) { return 0; } static inline int regulator_set_mode(struct regulator *regulator, unsigned int mode) { return 0; } static inline unsigned int regulator_get_mode(struct regulator *regulator) { return REGULATOR_MODE_NORMAL; } static inline int regulator_set_optimum_mode(struct regulator *regulator, int load_uA) { return REGULATOR_MODE_NORMAL; } static inline int regulator_register_notifier(struct regulator *regulator, struct notifier_block *nb) { return 0; } static inline int regulator_unregister_notifier(struct regulator *regulator, struct notifier_block *nb) { return 0; } static inline void *regulator_get_drvdata(struct regulator *regulator) { return NULL; } static inline void regulator_set_drvdata(struct regulator *regulator, void *data) { } #endif #endif |