diff options
| -rw-r--r-- | Documentation/ABI/testing/sysfs-class-regulator | 136 | ||||
| -rw-r--r-- | drivers/regulator/core.c | 196 |
2 files changed, 208 insertions, 124 deletions
diff --git a/Documentation/ABI/testing/sysfs-class-regulator b/Documentation/ABI/testing/sysfs-class-regulator index 3731f6f29bcb..873ef1fc1569 100644 --- a/Documentation/ABI/testing/sysfs-class-regulator +++ b/Documentation/ABI/testing/sysfs-class-regulator | |||
| @@ -3,8 +3,9 @@ Date: April 2008 | |||
| 3 | KernelVersion: 2.6.26 | 3 | KernelVersion: 2.6.26 |
| 4 | Contact: Liam Girdwood <lrg@slimlogic.co.uk> | 4 | Contact: Liam Girdwood <lrg@slimlogic.co.uk> |
| 5 | Description: | 5 | Description: |
| 6 | Each regulator directory will contain a field called | 6 | Some regulator directories will contain a field called |
| 7 | state. This holds the regulator output state. | 7 | state. This reports the regulator enable status, for |
| 8 | regulators which can report that value. | ||
| 8 | 9 | ||
| 9 | This will be one of the following strings: | 10 | This will be one of the following strings: |
| 10 | 11 | ||
| @@ -18,7 +19,8 @@ Description: | |||
| 18 | 'disabled' means the regulator output is OFF and is not | 19 | 'disabled' means the regulator output is OFF and is not |
| 19 | supplying power to the system.. | 20 | supplying power to the system.. |
| 20 | 21 | ||
| 21 | 'unknown' means software cannot determine the state. | 22 | 'unknown' means software cannot determine the state, or |
| 23 | the reported state is invalid. | ||
| 22 | 24 | ||
| 23 | NOTE: this field can be used in conjunction with microvolts | 25 | NOTE: this field can be used in conjunction with microvolts |
| 24 | and microamps to determine regulator output levels. | 26 | and microamps to determine regulator output levels. |
| @@ -53,9 +55,10 @@ Date: April 2008 | |||
| 53 | KernelVersion: 2.6.26 | 55 | KernelVersion: 2.6.26 |
| 54 | Contact: Liam Girdwood <lrg@slimlogic.co.uk> | 56 | Contact: Liam Girdwood <lrg@slimlogic.co.uk> |
| 55 | Description: | 57 | Description: |
| 56 | Each regulator directory will contain a field called | 58 | Some regulator directories will contain a field called |
| 57 | microvolts. This holds the regulator output voltage setting | 59 | microvolts. This holds the regulator output voltage setting |
| 58 | measured in microvolts (i.e. E-6 Volts). | 60 | measured in microvolts (i.e. E-6 Volts), for regulators |
| 61 | which can report that voltage. | ||
| 59 | 62 | ||
| 60 | NOTE: This value should not be used to determine the regulator | 63 | NOTE: This value should not be used to determine the regulator |
| 61 | output voltage level as this value is the same regardless of | 64 | output voltage level as this value is the same regardless of |
| @@ -67,9 +70,10 @@ Date: April 2008 | |||
| 67 | KernelVersion: 2.6.26 | 70 | KernelVersion: 2.6.26 |
| 68 | Contact: Liam Girdwood <lrg@slimlogic.co.uk> | 71 | Contact: Liam Girdwood <lrg@slimlogic.co.uk> |
| 69 | Description: | 72 | Description: |
| 70 | Each regulator directory will contain a field called | 73 | Some regulator directories will contain a field called |
| 71 | microamps. This holds the regulator output current limit | 74 | microamps. This holds the regulator output current limit |
| 72 | setting measured in microamps (i.e. E-6 Amps). | 75 | setting measured in microamps (i.e. E-6 Amps), for regulators |
| 76 | which can report that current. | ||
| 73 | 77 | ||
| 74 | NOTE: This value should not be used to determine the regulator | 78 | NOTE: This value should not be used to determine the regulator |
| 75 | output current level as this value is the same regardless of | 79 | output current level as this value is the same regardless of |
| @@ -81,8 +85,9 @@ Date: April 2008 | |||
| 81 | KernelVersion: 2.6.26 | 85 | KernelVersion: 2.6.26 |
| 82 | Contact: Liam Girdwood <lrg@slimlogic.co.uk> | 86 | Contact: Liam Girdwood <lrg@slimlogic.co.uk> |
| 83 | Description: | 87 | Description: |
| 84 | Each regulator directory will contain a field called | 88 | Some regulator directories will contain a field called |
| 85 | opmode. This holds the regulator operating mode setting. | 89 | opmode. This holds the current regulator operating mode, |
| 90 | for regulators which can report it. | ||
| 86 | 91 | ||
| 87 | The opmode value can be one of the following strings: | 92 | The opmode value can be one of the following strings: |
| 88 | 93 | ||
| @@ -92,7 +97,7 @@ Description: | |||
| 92 | 'standby' | 97 | 'standby' |
| 93 | 'unknown' | 98 | 'unknown' |
| 94 | 99 | ||
| 95 | The modes are described in include/linux/regulator/regulator.h | 100 | The modes are described in include/linux/regulator/consumer.h |
| 96 | 101 | ||
| 97 | NOTE: This value should not be used to determine the regulator | 102 | NOTE: This value should not be used to determine the regulator |
| 98 | output operating mode as this value is the same regardless of | 103 | output operating mode as this value is the same regardless of |
| @@ -104,9 +109,10 @@ Date: April 2008 | |||
| 104 | KernelVersion: 2.6.26 | 109 | KernelVersion: 2.6.26 |
| 105 | Contact: Liam Girdwood <lrg@slimlogic.co.uk> | 110 | Contact: Liam Girdwood <lrg@slimlogic.co.uk> |
| 106 | Description: | 111 | Description: |
| 107 | Each regulator directory will contain a field called | 112 | Some regulator directories will contain a field called |
| 108 | min_microvolts. This holds the minimum safe working regulator | 113 | min_microvolts. This holds the minimum safe working regulator |
| 109 | output voltage setting for this domain measured in microvolts. | 114 | output voltage setting for this domain measured in microvolts, |
| 115 | for regulators which support voltage constraints. | ||
| 110 | 116 | ||
| 111 | NOTE: this will return the string 'constraint not defined' if | 117 | NOTE: this will return the string 'constraint not defined' if |
| 112 | the power domain has no min microvolts constraint defined by | 118 | the power domain has no min microvolts constraint defined by |
| @@ -118,9 +124,10 @@ Date: April 2008 | |||
| 118 | KernelVersion: 2.6.26 | 124 | KernelVersion: 2.6.26 |
| 119 | Contact: Liam Girdwood <lrg@slimlogic.co.uk> | 125 | Contact: Liam Girdwood <lrg@slimlogic.co.uk> |
| 120 | Description: | 126 | Description: |
| 121 | Each regulator directory will contain a field called | 127 | Some regulator directories will contain a field called |
| 122 | max_microvolts. This holds the maximum safe working regulator | 128 | max_microvolts. This holds the maximum safe working regulator |
| 123 | output voltage setting for this domain measured in microvolts. | 129 | output voltage setting for this domain measured in microvolts, |
| 130 | for regulators which support voltage constraints. | ||
| 124 | 131 | ||
| 125 | NOTE: this will return the string 'constraint not defined' if | 132 | NOTE: this will return the string 'constraint not defined' if |
| 126 | the power domain has no max microvolts constraint defined by | 133 | the power domain has no max microvolts constraint defined by |
| @@ -132,10 +139,10 @@ Date: April 2008 | |||
| 132 | KernelVersion: 2.6.26 | 139 | KernelVersion: 2.6.26 |
| 133 | Contact: Liam Girdwood <lrg@slimlogic.co.uk> | 140 | Contact: Liam Girdwood <lrg@slimlogic.co.uk> |
| 134 | Description: | 141 | Description: |
| 135 | Each regulator directory will contain a field called | 142 | Some regulator directories will contain a field called |
| 136 | min_microamps. This holds the minimum safe working regulator | 143 | min_microamps. This holds the minimum safe working regulator |
| 137 | output current limit setting for this domain measured in | 144 | output current limit setting for this domain measured in |
| 138 | microamps. | 145 | microamps, for regulators which support current constraints. |
| 139 | 146 | ||
| 140 | NOTE: this will return the string 'constraint not defined' if | 147 | NOTE: this will return the string 'constraint not defined' if |
| 141 | the power domain has no min microamps constraint defined by | 148 | the power domain has no min microamps constraint defined by |
| @@ -147,10 +154,10 @@ Date: April 2008 | |||
| 147 | KernelVersion: 2.6.26 | 154 | KernelVersion: 2.6.26 |
| 148 | Contact: Liam Girdwood <lrg@slimlogic.co.uk> | 155 | Contact: Liam Girdwood <lrg@slimlogic.co.uk> |
| 149 | Description: | 156 | Description: |
| 150 | Each regulator directory will contain a field called | 157 | Some regulator directories will contain a field called |
| 151 | max_microamps. This holds the maximum safe working regulator | 158 | max_microamps. This holds the maximum safe working regulator |
| 152 | output current limit setting for this domain measured in | 159 | output current limit setting for this domain measured in |
| 153 | microamps. | 160 | microamps, for regulators which support current constraints. |
| 154 | 161 | ||
| 155 | NOTE: this will return the string 'constraint not defined' if | 162 | NOTE: this will return the string 'constraint not defined' if |
| 156 | the power domain has no max microamps constraint defined by | 163 | the power domain has no max microamps constraint defined by |
| @@ -185,7 +192,7 @@ Date: April 2008 | |||
| 185 | KernelVersion: 2.6.26 | 192 | KernelVersion: 2.6.26 |
| 186 | Contact: Liam Girdwood <lrg@slimlogic.co.uk> | 193 | Contact: Liam Girdwood <lrg@slimlogic.co.uk> |
| 187 | Description: | 194 | Description: |
| 188 | Each regulator directory will contain a field called | 195 | Some regulator directories will contain a field called |
| 189 | requested_microamps. This holds the total requested load | 196 | requested_microamps. This holds the total requested load |
| 190 | current in microamps for this regulator from all its consumer | 197 | current in microamps for this regulator from all its consumer |
| 191 | devices. | 198 | devices. |
| @@ -204,125 +211,102 @@ Date: May 2008 | |||
| 204 | KernelVersion: 2.6.26 | 211 | KernelVersion: 2.6.26 |
| 205 | Contact: Liam Girdwood <lrg@slimlogic.co.uk> | 212 | Contact: Liam Girdwood <lrg@slimlogic.co.uk> |
| 206 | Description: | 213 | Description: |
| 207 | Each regulator directory will contain a field called | 214 | Some regulator directories will contain a field called |
| 208 | suspend_mem_microvolts. This holds the regulator output | 215 | suspend_mem_microvolts. This holds the regulator output |
| 209 | voltage setting for this domain measured in microvolts when | 216 | voltage setting for this domain measured in microvolts when |
| 210 | the system is suspended to memory. | 217 | the system is suspended to memory, for voltage regulators |
| 211 | 218 | implementing suspend voltage configuration constraints. | |
| 212 | NOTE: this will return the string 'not defined' if | ||
| 213 | the power domain has no suspend to memory voltage defined by | ||
| 214 | platform code. | ||
| 215 | 219 | ||
| 216 | What: /sys/class/regulator/.../suspend_disk_microvolts | 220 | What: /sys/class/regulator/.../suspend_disk_microvolts |
| 217 | Date: May 2008 | 221 | Date: May 2008 |
| 218 | KernelVersion: 2.6.26 | 222 | KernelVersion: 2.6.26 |
| 219 | Contact: Liam Girdwood <lrg@slimlogic.co.uk> | 223 | Contact: Liam Girdwood <lrg@slimlogic.co.uk> |
| 220 | Description: | 224 | Description: |
| 221 | Each regulator directory will contain a field called | 225 | Some regulator directories will contain a field called |
| 222 | suspend_disk_microvolts. This holds the regulator output | 226 | suspend_disk_microvolts. This holds the regulator output |
| 223 | voltage setting for this domain measured in microvolts when | 227 | voltage setting for this domain measured in microvolts when |
| 224 | the system is suspended to disk. | 228 | the system is suspended to disk, for voltage regulators |
| 225 | 229 | implementing suspend voltage configuration constraints. | |
| 226 | NOTE: this will return the string 'not defined' if | ||
| 227 | the power domain has no suspend to disk voltage defined by | ||
| 228 | platform code. | ||
| 229 | 230 | ||
| 230 | What: /sys/class/regulator/.../suspend_standby_microvolts | 231 | What: /sys/class/regulator/.../suspend_standby_microvolts |
| 231 | Date: May 2008 | 232 | Date: May 2008 |
| 232 | KernelVersion: 2.6.26 | 233 | KernelVersion: 2.6.26 |
| 233 | Contact: Liam Girdwood <lrg@slimlogic.co.uk> | 234 | Contact: Liam Girdwood <lrg@slimlogic.co.uk> |
| 234 | Description: | 235 | Description: |
| 235 | Each regulator directory will contain a field called | 236 | Some regulator directories will contain a field called |
| 236 | suspend_standby_microvolts. This holds the regulator output | 237 | suspend_standby_microvolts. This holds the regulator output |
| 237 | voltage setting for this domain measured in microvolts when | 238 | voltage setting for this domain measured in microvolts when |
| 238 | the system is suspended to standby. | 239 | the system is suspended to standby, for voltage regulators |
| 239 | 240 | implementing suspend voltage configuration constraints. | |
| 240 | NOTE: this will return the string 'not defined' if | ||
| 241 | the power domain has no suspend to standby voltage defined by | ||
| 242 | platform code. | ||
| 243 | 241 | ||
| 244 | What: /sys/class/regulator/.../suspend_mem_mode | 242 | What: /sys/class/regulator/.../suspend_mem_mode |
| 245 | Date: May 2008 | 243 | Date: May 2008 |
| 246 | KernelVersion: 2.6.26 | 244 | KernelVersion: 2.6.26 |
| 247 | Contact: Liam Girdwood <lrg@slimlogic.co.uk> | 245 | Contact: Liam Girdwood <lrg@slimlogic.co.uk> |
| 248 | Description: | 246 | Description: |
| 249 | Each regulator directory will contain a field called | 247 | Some regulator directories will contain a field called |
| 250 | suspend_mem_mode. This holds the regulator operating mode | 248 | suspend_mem_mode. This holds the regulator operating mode |
| 251 | setting for this domain when the system is suspended to | 249 | setting for this domain when the system is suspended to |
| 252 | memory. | 250 | memory, for regulators implementing suspend mode |
| 253 | 251 | configuration constraints. | |
| 254 | NOTE: this will return the string 'not defined' if | ||
| 255 | the power domain has no suspend to memory mode defined by | ||
| 256 | platform code. | ||
| 257 | 252 | ||
| 258 | What: /sys/class/regulator/.../suspend_disk_mode | 253 | What: /sys/class/regulator/.../suspend_disk_mode |
| 259 | Date: May 2008 | 254 | Date: May 2008 |
| 260 | KernelVersion: 2.6.26 | 255 | KernelVersion: 2.6.26 |
| 261 | Contact: Liam Girdwood <lrg@slimlogic.co.uk> | 256 | Contact: Liam Girdwood <lrg@slimlogic.co.uk> |
| 262 | Description: | 257 | Description: |
| 263 | Each regulator directory will contain a field called | 258 | Some regulator directories will contain a field called |
| 264 | suspend_disk_mode. This holds the regulator operating mode | 259 | suspend_disk_mode. This holds the regulator operating mode |
| 265 | setting for this domain when the system is suspended to disk. | 260 | setting for this domain when the system is suspended to disk, |
| 266 | 261 | for regulators implementing suspend mode configuration | |
| 267 | NOTE: this will return the string 'not defined' if | 262 | constraints. |
| 268 | the power domain has no suspend to disk mode defined by | ||
| 269 | platform code. | ||
| 270 | 263 | ||
| 271 | What: /sys/class/regulator/.../suspend_standby_mode | 264 | What: /sys/class/regulator/.../suspend_standby_mode |
| 272 | Date: May 2008 | 265 | Date: May 2008 |
| 273 | KernelVersion: 2.6.26 | 266 | KernelVersion: 2.6.26 |
| 274 | Contact: Liam Girdwood <lrg@slimlogic.co.uk> | 267 | Contact: Liam Girdwood <lrg@slimlogic.co.uk> |
| 275 | Description: | 268 | Description: |
| 276 | Each regulator directory will contain a field called | 269 | Some regulator directories will contain a field called |
| 277 | suspend_standby_mode. This holds the regulator operating mode | 270 | suspend_standby_mode. This holds the regulator operating mode |
| 278 | setting for this domain when the system is suspended to | 271 | setting for this domain when the system is suspended to |
| 279 | standby. | 272 | standby, for regulators implementing suspend mode |
| 280 | 273 | configuration constraints. | |
| 281 | NOTE: this will return the string 'not defined' if | ||
| 282 | the power domain has no suspend to standby mode defined by | ||
| 283 | platform code. | ||
| 284 | 274 | ||
| 285 | What: /sys/class/regulator/.../suspend_mem_state | 275 | What: /sys/class/regulator/.../suspend_mem_state |
| 286 | Date: May 2008 | 276 | Date: May 2008 |
| 287 | KernelVersion: 2.6.26 | 277 | KernelVersion: 2.6.26 |
| 288 | Contact: Liam Girdwood <lrg@slimlogic.co.uk> | 278 | Contact: Liam Girdwood <lrg@slimlogic.co.uk> |
| 289 | Description: | 279 | Description: |
| 290 | Each regulator directory will contain a field called | 280 | Some regulator directories will contain a field called |
| 291 | suspend_mem_state. This holds the regulator operating state | 281 | suspend_mem_state. This holds the regulator operating state |
| 292 | when suspended to memory. | 282 | when suspended to memory, for regulators implementing suspend |
| 293 | 283 | configuration constraints. | |
| 294 | This will be one of the following strings: | ||
| 295 | 284 | ||
| 296 | 'enabled' | 285 | This will be one of the same strings reported by |
| 297 | 'disabled' | 286 | the "state" attribute. |
| 298 | 'not defined' | ||
| 299 | 287 | ||
| 300 | What: /sys/class/regulator/.../suspend_disk_state | 288 | What: /sys/class/regulator/.../suspend_disk_state |
| 301 | Date: May 2008 | 289 | Date: May 2008 |
| 302 | KernelVersion: 2.6.26 | 290 | KernelVersion: 2.6.26 |
| 303 | Contact: Liam Girdwood <lrg@slimlogic.co.uk> | 291 | Contact: Liam Girdwood <lrg@slimlogic.co.uk> |
| 304 | Description: | 292 | Description: |
| 305 | Each regulator directory will contain a field called | 293 | Some regulator directories will contain a field called |
| 306 | suspend_disk_state. This holds the regulator operating state | 294 | suspend_disk_state. This holds the regulator operating state |
| 307 | when suspended to disk. | 295 | when suspended to disk, for regulators implementing |
| 308 | 296 | suspend configuration constraints. | |
| 309 | This will be one of the following strings: | ||
| 310 | 297 | ||
| 311 | 'enabled' | 298 | This will be one of the same strings reported by |
| 312 | 'disabled' | 299 | the "state" attribute. |
| 313 | 'not defined' | ||
| 314 | 300 | ||
| 315 | What: /sys/class/regulator/.../suspend_standby_state | 301 | What: /sys/class/regulator/.../suspend_standby_state |
| 316 | Date: May 2008 | 302 | Date: May 2008 |
| 317 | KernelVersion: 2.6.26 | 303 | KernelVersion: 2.6.26 |
| 318 | Contact: Liam Girdwood <lrg@slimlogic.co.uk> | 304 | Contact: Liam Girdwood <lrg@slimlogic.co.uk> |
| 319 | Description: | 305 | Description: |
| 320 | Each regulator directory will contain a field called | 306 | Some regulator directories will contain a field called |
| 321 | suspend_standby_state. This holds the regulator operating | 307 | suspend_standby_state. This holds the regulator operating |
| 322 | state when suspended to standby. | 308 | state when suspended to standby, for regulators implementing |
| 323 | 309 | suspend configuration constraints. | |
| 324 | This will be one of the following strings: | ||
| 325 | 310 | ||
| 326 | 'enabled' | 311 | This will be one of the same strings reported by |
| 327 | 'disabled' | 312 | the "state" attribute. |
| 328 | 'not defined' | ||
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 5109f7d4809a..9a5ff97d158d 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c | |||
| @@ -242,6 +242,7 @@ static ssize_t regulator_uV_show(struct device *dev, | |||
| 242 | 242 | ||
| 243 | return ret; | 243 | return ret; |
| 244 | } | 244 | } |
| 245 | static DEVICE_ATTR(microvolts, 0444, regulator_uV_show, NULL); | ||
| 245 | 246 | ||
| 246 | static ssize_t regulator_uA_show(struct device *dev, | 247 | static ssize_t regulator_uA_show(struct device *dev, |
| 247 | struct device_attribute *attr, char *buf) | 248 | struct device_attribute *attr, char *buf) |
| @@ -250,6 +251,7 @@ static ssize_t regulator_uA_show(struct device *dev, | |||
| 250 | 251 | ||
| 251 | return sprintf(buf, "%d\n", _regulator_get_current_limit(rdev)); | 252 | return sprintf(buf, "%d\n", _regulator_get_current_limit(rdev)); |
| 252 | } | 253 | } |
| 254 | static DEVICE_ATTR(microamps, 0444, regulator_uA_show, NULL); | ||
| 253 | 255 | ||
| 254 | static ssize_t regulator_name_show(struct device *dev, | 256 | static ssize_t regulator_name_show(struct device *dev, |
| 255 | struct device_attribute *attr, char *buf) | 257 | struct device_attribute *attr, char *buf) |
| @@ -289,6 +291,7 @@ static ssize_t regulator_opmode_show(struct device *dev, | |||
| 289 | 291 | ||
| 290 | return regulator_print_opmode(buf, _regulator_get_mode(rdev)); | 292 | return regulator_print_opmode(buf, _regulator_get_mode(rdev)); |
| 291 | } | 293 | } |
| 294 | static DEVICE_ATTR(opmode, 0444, regulator_opmode_show, NULL); | ||
| 292 | 295 | ||
| 293 | static ssize_t regulator_print_state(char *buf, int state) | 296 | static ssize_t regulator_print_state(char *buf, int state) |
| 294 | { | 297 | { |
| @@ -307,6 +310,7 @@ static ssize_t regulator_state_show(struct device *dev, | |||
| 307 | 310 | ||
| 308 | return regulator_print_state(buf, _regulator_is_enabled(rdev)); | 311 | return regulator_print_state(buf, _regulator_is_enabled(rdev)); |
| 309 | } | 312 | } |
| 313 | static DEVICE_ATTR(state, 0444, regulator_state_show, NULL); | ||
| 310 | 314 | ||
| 311 | static ssize_t regulator_min_uA_show(struct device *dev, | 315 | static ssize_t regulator_min_uA_show(struct device *dev, |
| 312 | struct device_attribute *attr, char *buf) | 316 | struct device_attribute *attr, char *buf) |
| @@ -318,6 +322,7 @@ static ssize_t regulator_min_uA_show(struct device *dev, | |||
| 318 | 322 | ||
| 319 | return sprintf(buf, "%d\n", rdev->constraints->min_uA); | 323 | return sprintf(buf, "%d\n", rdev->constraints->min_uA); |
| 320 | } | 324 | } |
| 325 | static DEVICE_ATTR(min_microamps, 0444, regulator_min_uA_show, NULL); | ||
| 321 | 326 | ||
| 322 | static ssize_t regulator_max_uA_show(struct device *dev, | 327 | static ssize_t regulator_max_uA_show(struct device *dev, |
| 323 | struct device_attribute *attr, char *buf) | 328 | struct device_attribute *attr, char *buf) |
| @@ -329,6 +334,7 @@ static ssize_t regulator_max_uA_show(struct device *dev, | |||
| 329 | 334 | ||
| 330 | return sprintf(buf, "%d\n", rdev->constraints->max_uA); | 335 | return sprintf(buf, "%d\n", rdev->constraints->max_uA); |
| 331 | } | 336 | } |
| 337 | static DEVICE_ATTR(max_microamps, 0444, regulator_max_uA_show, NULL); | ||
| 332 | 338 | ||
| 333 | static ssize_t regulator_min_uV_show(struct device *dev, | 339 | static ssize_t regulator_min_uV_show(struct device *dev, |
| 334 | struct device_attribute *attr, char *buf) | 340 | struct device_attribute *attr, char *buf) |
| @@ -340,6 +346,7 @@ static ssize_t regulator_min_uV_show(struct device *dev, | |||
| 340 | 346 | ||
| 341 | return sprintf(buf, "%d\n", rdev->constraints->min_uV); | 347 | return sprintf(buf, "%d\n", rdev->constraints->min_uV); |
| 342 | } | 348 | } |
| 349 | static DEVICE_ATTR(min_microvolts, 0444, regulator_min_uV_show, NULL); | ||
| 343 | 350 | ||
| 344 | static ssize_t regulator_max_uV_show(struct device *dev, | 351 | static ssize_t regulator_max_uV_show(struct device *dev, |
| 345 | struct device_attribute *attr, char *buf) | 352 | struct device_attribute *attr, char *buf) |
| @@ -351,6 +358,7 @@ static ssize_t regulator_max_uV_show(struct device *dev, | |||
| 351 | 358 | ||
| 352 | return sprintf(buf, "%d\n", rdev->constraints->max_uV); | 359 | return sprintf(buf, "%d\n", rdev->constraints->max_uV); |
| 353 | } | 360 | } |
| 361 | static DEVICE_ATTR(max_microvolts, 0444, regulator_max_uV_show, NULL); | ||
| 354 | 362 | ||
| 355 | static ssize_t regulator_total_uA_show(struct device *dev, | 363 | static ssize_t regulator_total_uA_show(struct device *dev, |
| 356 | struct device_attribute *attr, char *buf) | 364 | struct device_attribute *attr, char *buf) |
| @@ -365,6 +373,7 @@ static ssize_t regulator_total_uA_show(struct device *dev, | |||
| 365 | mutex_unlock(&rdev->mutex); | 373 | mutex_unlock(&rdev->mutex); |
| 366 | return sprintf(buf, "%d\n", uA); | 374 | return sprintf(buf, "%d\n", uA); |
| 367 | } | 375 | } |
| 376 | static DEVICE_ATTR(requested_microamps, 0444, regulator_total_uA_show, NULL); | ||
| 368 | 377 | ||
| 369 | static ssize_t regulator_num_users_show(struct device *dev, | 378 | static ssize_t regulator_num_users_show(struct device *dev, |
| 370 | struct device_attribute *attr, char *buf) | 379 | struct device_attribute *attr, char *buf) |
| @@ -392,131 +401,106 @@ static ssize_t regulator_suspend_mem_uV_show(struct device *dev, | |||
| 392 | { | 401 | { |
| 393 | struct regulator_dev *rdev = dev_get_drvdata(dev); | 402 | struct regulator_dev *rdev = dev_get_drvdata(dev); |
| 394 | 403 | ||
| 395 | if (!rdev->constraints) | ||
| 396 | return sprintf(buf, "not defined\n"); | ||
| 397 | return sprintf(buf, "%d\n", rdev->constraints->state_mem.uV); | 404 | return sprintf(buf, "%d\n", rdev->constraints->state_mem.uV); |
| 398 | } | 405 | } |
| 406 | static DEVICE_ATTR(suspend_mem_microvolts, 0444, | ||
| 407 | regulator_suspend_mem_uV_show, NULL); | ||
| 399 | 408 | ||
| 400 | static ssize_t regulator_suspend_disk_uV_show(struct device *dev, | 409 | static ssize_t regulator_suspend_disk_uV_show(struct device *dev, |
| 401 | struct device_attribute *attr, char *buf) | 410 | struct device_attribute *attr, char *buf) |
| 402 | { | 411 | { |
| 403 | struct regulator_dev *rdev = dev_get_drvdata(dev); | 412 | struct regulator_dev *rdev = dev_get_drvdata(dev); |
| 404 | 413 | ||
| 405 | if (!rdev->constraints) | ||
| 406 | return sprintf(buf, "not defined\n"); | ||
| 407 | return sprintf(buf, "%d\n", rdev->constraints->state_disk.uV); | 414 | return sprintf(buf, "%d\n", rdev->constraints->state_disk.uV); |
| 408 | } | 415 | } |
| 416 | static DEVICE_ATTR(suspend_disk_microvolts, 0444, | ||
| 417 | regulator_suspend_disk_uV_show, NULL); | ||
| 409 | 418 | ||
| 410 | static ssize_t regulator_suspend_standby_uV_show(struct device *dev, | 419 | static ssize_t regulator_suspend_standby_uV_show(struct device *dev, |
| 411 | struct device_attribute *attr, char *buf) | 420 | struct device_attribute *attr, char *buf) |
| 412 | { | 421 | { |
| 413 | struct regulator_dev *rdev = dev_get_drvdata(dev); | 422 | struct regulator_dev *rdev = dev_get_drvdata(dev); |
| 414 | 423 | ||
| 415 | if (!rdev->constraints) | ||
| 416 | return sprintf(buf, "not defined\n"); | ||
| 417 | return sprintf(buf, "%d\n", rdev->constraints->state_standby.uV); | 424 | return sprintf(buf, "%d\n", rdev->constraints->state_standby.uV); |
| 418 | } | 425 | } |
| 426 | static DEVICE_ATTR(suspend_standby_microvolts, 0444, | ||
| 427 | regulator_suspend_standby_uV_show, NULL); | ||
| 419 | 428 | ||
| 420 | static ssize_t regulator_suspend_mem_mode_show(struct device *dev, | 429 | static ssize_t regulator_suspend_mem_mode_show(struct device *dev, |
| 421 | struct device_attribute *attr, char *buf) | 430 | struct device_attribute *attr, char *buf) |
| 422 | { | 431 | { |
| 423 | struct regulator_dev *rdev = dev_get_drvdata(dev); | 432 | struct regulator_dev *rdev = dev_get_drvdata(dev); |
| 424 | 433 | ||
| 425 | if (!rdev->constraints) | ||
| 426 | return sprintf(buf, "not defined\n"); | ||
| 427 | return regulator_print_opmode(buf, | 434 | return regulator_print_opmode(buf, |
| 428 | rdev->constraints->state_mem.mode); | 435 | rdev->constraints->state_mem.mode); |
| 429 | } | 436 | } |
| 437 | static DEVICE_ATTR(suspend_mem_mode, 0444, | ||
| 438 | regulator_suspend_mem_mode_show, NULL); | ||
| 430 | 439 | ||
| 431 | static ssize_t regulator_suspend_disk_mode_show(struct device *dev, | 440 | static ssize_t regulator_suspend_disk_mode_show(struct device *dev, |
| 432 | struct device_attribute *attr, char *buf) | 441 | struct device_attribute *attr, char *buf) |
| 433 | { | 442 | { |
| 434 | struct regulator_dev *rdev = dev_get_drvdata(dev); | 443 | struct regulator_dev *rdev = dev_get_drvdata(dev); |
| 435 | 444 | ||
| 436 | if (!rdev->constraints) | ||
| 437 | return sprintf(buf, "not defined\n"); | ||
| 438 | return regulator_print_opmode(buf, | 445 | return regulator_print_opmode(buf, |
| 439 | rdev->constraints->state_disk.mode); | 446 | rdev->constraints->state_disk.mode); |
| 440 | } | 447 | } |
| 448 | static DEVICE_ATTR(suspend_disk_mode, 0444, | ||
| 449 | regulator_suspend_disk_mode_show, NULL); | ||
| 441 | 450 | ||
| 442 | static ssize_t regulator_suspend_standby_mode_show(struct device *dev, | 451 | static ssize_t regulator_suspend_standby_mode_show(struct device *dev, |
| 443 | struct device_attribute *attr, char *buf) | 452 | struct device_attribute *attr, char *buf) |
| 444 | { | 453 | { |
| 445 | struct regulator_dev *rdev = dev_get_drvdata(dev); | 454 | struct regulator_dev *rdev = dev_get_drvdata(dev); |
| 446 | 455 | ||
| 447 | if (!rdev->constraints) | ||
| 448 | return sprintf(buf, "not defined\n"); | ||
| 449 | return regulator_print_opmode(buf, | 456 | return regulator_print_opmode(buf, |
| 450 | rdev->constraints->state_standby.mode); | 457 | rdev->constraints->state_standby.mode); |
| 451 | } | 458 | } |
| 459 | static DEVICE_ATTR(suspend_standby_mode, 0444, | ||
| 460 | regulator_suspend_standby_mode_show, NULL); | ||
| 452 | 461 | ||
| 453 | static ssize_t regulator_suspend_mem_state_show(struct device *dev, | 462 | static ssize_t regulator_suspend_mem_state_show(struct device *dev, |
| 454 | struct device_attribute *attr, char *buf) | 463 | struct device_attribute *attr, char *buf) |
| 455 | { | 464 | { |
| 456 | struct regulator_dev *rdev = dev_get_drvdata(dev); | 465 | struct regulator_dev *rdev = dev_get_drvdata(dev); |
| 457 | 466 | ||
| 458 | if (!rdev->constraints) | ||
| 459 | return sprintf(buf, "not defined\n"); | ||
| 460 | |||
| 461 | return regulator_print_state(buf, | 467 | return regulator_print_state(buf, |
| 462 | rdev->constraints->state_mem.enabled); | 468 | rdev->constraints->state_mem.enabled); |
| 463 | } | 469 | } |
| 470 | static DEVICE_ATTR(suspend_mem_state, 0444, | ||
| 471 | regulator_suspend_mem_state_show, NULL); | ||
| 464 | 472 | ||
| 465 | static ssize_t regulator_suspend_disk_state_show(struct device *dev, | 473 | static ssize_t regulator_suspend_disk_state_show(struct device *dev, |
| 466 | struct device_attribute *attr, char *buf) | 474 | struct device_attribute *attr, char *buf) |
| 467 | { | 475 | { |
| 468 | struct regulator_dev *rdev = dev_get_drvdata(dev); | 476 | struct regulator_dev *rdev = dev_get_drvdata(dev); |
| 469 | 477 | ||
| 470 | if (!rdev->constraints) | ||
| 471 | return sprintf(buf, "not defined\n"); | ||
| 472 | |||
| 473 | return regulator_print_state(buf, | 478 | return regulator_print_state(buf, |
| 474 | rdev->constraints->state_disk.enabled); | 479 | rdev->constraints->state_disk.enabled); |
| 475 | } | 480 | } |
| 481 | static DEVICE_ATTR(suspend_disk_state, 0444, | ||
| 482 | regulator_suspend_disk_state_show, NULL); | ||
| 476 | 483 | ||
| 477 | static ssize_t regulator_suspend_standby_state_show(struct device *dev, | 484 | static ssize_t regulator_suspend_standby_state_show(struct device *dev, |
| 478 | struct device_attribute *attr, char *buf) | 485 | struct device_attribute *attr, char *buf) |
| 479 | { | 486 | { |
| 480 | struct regulator_dev *rdev = dev_get_drvdata(dev); | 487 | struct regulator_dev *rdev = dev_get_drvdata(dev); |
| 481 | 488 | ||
| 482 | if (!rdev->constraints) | ||
| 483 | return sprintf(buf, "not defined\n"); | ||
| 484 | |||
| 485 | return regulator_print_state(buf, | 489 | return regulator_print_state(buf, |
| 486 | rdev->constraints->state_standby.enabled); | 490 | rdev->constraints->state_standby.enabled); |
| 487 | } | 491 | } |
| 492 | static DEVICE_ATTR(suspend_standby_state, 0444, | ||
| 493 | regulator_suspend_standby_state_show, NULL); | ||
| 494 | |||
| 488 | 495 | ||
| 496 | /* | ||
| 497 | * These are the only attributes are present for all regulators. | ||
| 498 | * Other attributes are a function of regulator functionality. | ||
| 499 | */ | ||
| 489 | static struct device_attribute regulator_dev_attrs[] = { | 500 | static struct device_attribute regulator_dev_attrs[] = { |
| 490 | __ATTR(name, 0444, regulator_name_show, NULL), | 501 | __ATTR(name, 0444, regulator_name_show, NULL), |
| 491 | __ATTR(microvolts, 0444, regulator_uV_show, NULL), | ||
| 492 | __ATTR(microamps, 0444, regulator_uA_show, NULL), | ||
| 493 | __ATTR(opmode, 0444, regulator_opmode_show, NULL), | ||
| 494 | __ATTR(state, 0444, regulator_state_show, NULL), | ||
| 495 | __ATTR(min_microvolts, 0444, regulator_min_uV_show, NULL), | ||
| 496 | __ATTR(min_microamps, 0444, regulator_min_uA_show, NULL), | ||
| 497 | __ATTR(max_microvolts, 0444, regulator_max_uV_show, NULL), | ||
| 498 | __ATTR(max_microamps, 0444, regulator_max_uA_show, NULL), | ||
| 499 | __ATTR(requested_microamps, 0444, regulator_total_uA_show, NULL), | ||
| 500 | __ATTR(num_users, 0444, regulator_num_users_show, NULL), | 502 | __ATTR(num_users, 0444, regulator_num_users_show, NULL), |
| 501 | __ATTR(type, 0444, regulator_type_show, NULL), | 503 | __ATTR(type, 0444, regulator_type_show, NULL), |
| 502 | __ATTR(suspend_mem_microvolts, 0444, | ||
| 503 | regulator_suspend_mem_uV_show, NULL), | ||
| 504 | __ATTR(suspend_disk_microvolts, 0444, | ||
| 505 | regulator_suspend_disk_uV_show, NULL), | ||
| 506 | __ATTR(suspend_standby_microvolts, 0444, | ||
| 507 | regulator_suspend_standby_uV_show, NULL), | ||
| 508 | __ATTR(suspend_mem_mode, 0444, | ||
| 509 | regulator_suspend_mem_mode_show, NULL), | ||
| 510 | __ATTR(suspend_disk_mode, 0444, | ||
| 511 | regulator_suspend_disk_mode_show, NULL), | ||
| 512 | __ATTR(suspend_standby_mode, 0444, | ||
| 513 | regulator_suspend_standby_mode_show, NULL), | ||
| 514 | __ATTR(suspend_mem_state, 0444, | ||
| 515 | regulator_suspend_mem_state_show, NULL), | ||
| 516 | __ATTR(suspend_disk_state, 0444, | ||
| 517 | regulator_suspend_disk_state_show, NULL), | ||
| 518 | __ATTR(suspend_standby_state, 0444, | ||
| 519 | regulator_suspend_standby_state_show, NULL), | ||
| 520 | __ATTR_NULL, | 504 | __ATTR_NULL, |
| 521 | }; | 505 | }; |
| 522 | 506 | ||
| @@ -1711,6 +1695,117 @@ int regulator_notifier_call_chain(struct regulator_dev *rdev, | |||
| 1711 | } | 1695 | } |
| 1712 | EXPORT_SYMBOL_GPL(regulator_notifier_call_chain); | 1696 | EXPORT_SYMBOL_GPL(regulator_notifier_call_chain); |
| 1713 | 1697 | ||
| 1698 | /* | ||
| 1699 | * To avoid cluttering sysfs (and memory) with useless state, only | ||
| 1700 | * create attributes that can be meaningfully displayed. | ||
| 1701 | */ | ||
| 1702 | static int add_regulator_attributes(struct regulator_dev *rdev) | ||
| 1703 | { | ||
| 1704 | struct device *dev = &rdev->dev; | ||
| 1705 | struct regulator_ops *ops = rdev->desc->ops; | ||
| 1706 | int status = 0; | ||
| 1707 | |||
| 1708 | /* some attributes need specific methods to be displayed */ | ||
| 1709 | if (ops->get_voltage) { | ||
| 1710 | status = device_create_file(dev, &dev_attr_microvolts); | ||
| 1711 | if (status < 0) | ||
| 1712 | return status; | ||
| 1713 | } | ||
| 1714 | if (ops->get_current_limit) { | ||
| 1715 | status = device_create_file(dev, &dev_attr_microamps); | ||
| 1716 | if (status < 0) | ||
| 1717 | return status; | ||
| 1718 | } | ||
| 1719 | if (ops->get_mode) { | ||
| 1720 | status = device_create_file(dev, &dev_attr_opmode); | ||
| 1721 | if (status < 0) | ||
| 1722 | return status; | ||
| 1723 | } | ||
| 1724 | if (ops->is_enabled) { | ||
| 1725 | status = device_create_file(dev, &dev_attr_state); | ||
| 1726 | if (status < 0) | ||
| 1727 | return status; | ||
| 1728 | } | ||
| 1729 | |||
| 1730 | /* some attributes are type-specific */ | ||
| 1731 | if (rdev->desc->type == REGULATOR_CURRENT) { | ||
| 1732 | status = device_create_file(dev, &dev_attr_requested_microamps); | ||
| 1733 | if (status < 0) | ||
| 1734 | return status; | ||
| 1735 | } | ||
| 1736 | |||
| 1737 | /* all the other attributes exist to support constraints; | ||
| 1738 | * don't show them if there are no constraints, or if the | ||
| 1739 | * relevant supporting methods are missing. | ||
| 1740 | */ | ||
| 1741 | if (!rdev->constraints) | ||
| 1742 | return status; | ||
| 1743 | |||
| 1744 | /* constraints need specific supporting methods */ | ||
| 1745 | if (ops->set_voltage) { | ||
| 1746 | status = device_create_file(dev, &dev_attr_min_microvolts); | ||
| 1747 | if (status < 0) | ||
| 1748 | return status; | ||
| 1749 | status = device_create_file(dev, &dev_attr_max_microvolts); | ||
| 1750 | if (status < 0) | ||
| 1751 | return status; | ||
| 1752 | } | ||
| 1753 | if (ops->set_current_limit) { | ||
| 1754 | status = device_create_file(dev, &dev_attr_min_microamps); | ||
| 1755 | if (status < 0) | ||
| 1756 | return status; | ||
| 1757 | status = device_create_file(dev, &dev_attr_max_microamps); | ||
| 1758 | if (status < 0) | ||
| 1759 | return status; | ||
| 1760 | } | ||
| 1761 | |||
| 1762 | /* suspend mode constraints need multiple supporting methods */ | ||
| 1763 | if (!(ops->set_suspend_enable && ops->set_suspend_disable)) | ||
| 1764 | return status; | ||
| 1765 | |||
| 1766 | status = device_create_file(dev, &dev_attr_suspend_standby_state); | ||
| 1767 | if (status < 0) | ||
| 1768 | return status; | ||
| 1769 | status = device_create_file(dev, &dev_attr_suspend_mem_state); | ||
| 1770 | if (status < 0) | ||
| 1771 | return status; | ||
| 1772 | status = device_create_file(dev, &dev_attr_suspend_disk_state); | ||
| 1773 | if (status < 0) | ||
| 1774 | return status; | ||
| 1775 | |||
| 1776 | if (ops->set_suspend_voltage) { | ||
| 1777 | status = device_create_file(dev, | ||
| 1778 | &dev_attr_suspend_standby_microvolts); | ||
| 1779 | if (status < 0) | ||
| 1780 | return status; | ||
| 1781 | status = device_create_file(dev, | ||
| 1782 | &dev_attr_suspend_mem_microvolts); | ||
| 1783 | if (status < 0) | ||
| 1784 | return status; | ||
| 1785 | status = device_create_file(dev, | ||
| 1786 | &dev_attr_suspend_disk_microvolts); | ||
| 1787 | if (status < 0) | ||
| 1788 | return status; | ||
| 1789 | } | ||
| 1790 | |||
| 1791 | if (ops->set_suspend_mode) { | ||
| 1792 | status = device_create_file(dev, | ||
| 1793 | &dev_attr_suspend_standby_mode); | ||
| 1794 | if (status < 0) | ||
| 1795 | return status; | ||
| 1796 | status = device_create_file(dev, | ||
| 1797 | &dev_attr_suspend_mem_mode); | ||
| 1798 | if (status < 0) | ||
| 1799 | return status; | ||
| 1800 | status = device_create_file(dev, | ||
| 1801 | &dev_attr_suspend_disk_mode); | ||
| 1802 | if (status < 0) | ||
| 1803 | return status; | ||
| 1804 | } | ||
| 1805 | |||
| 1806 | return status; | ||
| 1807 | } | ||
| 1808 | |||
| 1714 | /** | 1809 | /** |
| 1715 | * regulator_register - register regulator | 1810 | * regulator_register - register regulator |
| 1716 | * @regulator: regulator source | 1811 | * @regulator: regulator source |
| @@ -1779,6 +1874,11 @@ struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc, | |||
| 1779 | 1874 | ||
| 1780 | dev_set_drvdata(&rdev->dev, rdev); | 1875 | dev_set_drvdata(&rdev->dev, rdev); |
| 1781 | 1876 | ||
| 1877 | /* add attributes supported by this regulator */ | ||
| 1878 | ret = add_regulator_attributes(rdev); | ||
| 1879 | if (ret < 0) | ||
| 1880 | goto scrub; | ||
| 1881 | |||
| 1782 | /* set supply regulator if it exists */ | 1882 | /* set supply regulator if it exists */ |
| 1783 | if (init_data->supply_regulator_dev) { | 1883 | if (init_data->supply_regulator_dev) { |
| 1784 | ret = set_supply(rdev, | 1884 | ret = set_supply(rdev, |
