aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/core.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2015-02-08Merge remote-tracking branches 'regulator/topic/max8649', 'regulator/topic/mode', 'regulator/topic/mt6397', 'regulator/topic/pfuze100' and 'regulator/topic/qcom-rpm' into regulator-nextMark Brown1-77/+35
2015-02-08Merge remote-tracking branch 'regulator/topic/dt-cb' into regulator-nextMark Brown1-5/+17
2015-02-08Merge remote-tracking branch 'regulator/topic/core' into regulator-nextMark Brown1-130/+111
2015-02-02regulator: Build sysfs entries with static attribute groupsTakashi Iwai1-127/+108
Instead of calling device_create_file() manually after the device registration, put all in attribute groups and filter the unwanted ones via is_visible callback. This not only simplifies the code but also avoids the possible race between the device registration and sysfs registration. Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-01-28regulator: core: Consolidate drms update handlingBjorn Andersson1-77/+35
Refactor drms_uA_update() slightly to allow regulator_set_optimum_mode() to utilize the same logic instead of duplicating it. Signed-off-by: Bjorn Andersson <bjorn.andersson@sonymobile.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-01-14regulator: Update documentation after renaming function argumentKrzysztof Kozlowski1-1/+1
Update documentation for regulator_register() function after renaming its argument. Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Reported-by: kbuild test robot <fengguang.wu@intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-01-09Merge branch 'topic/core' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator into regulator-dt-cbMark Brown1-3/+3
Conflicts: drivers/regulator/core.c
2015-01-08regulator: Allow parsing custom properties when using simplified DT parsingKrzysztof Kozlowski1-1/+1
When drivers use simplified DT parsing method (they provide 'regulator_desc.of_match') they still may want to parse custom properties for some of the regulators. For example some of the regulators support GPIO enable control. Add a driver-supplied callback for such case. This way the regulator core parses common bindings offloading a lot of code from drivers and still custom properties may be used. The callback, called for each parsed regulator, may modify the 'regulator_config' initially passed to regulator_register(). Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-01-08regulator: Copy config passed during registrationKrzysztof Kozlowski1-3/+15
Copy the 'regulator_config' structure passed to regulator_register() function so the driver could safely modify it after parsing init data. The driver may want to change the config as a result of specific init data parsed by regulator core (e.g. when core handled parsing device tree). Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-01-08regulator: core: fix race condition in regulator_put()Ashay Jaiswal1-1/+3
The regulator framework maintains a list of consumer regulators for a regulator device and protects it from concurrent access using the regulator device's mutex lock. In the case of regulator_put() the consumer is removed and regulator device's parameters are updated without holding the regulator device's mutex. This would lead to a race condition between the regulator_put() and any function which traverses the consumer list or modifies regulator device's parameters. Fix this race condition by holding the regulator device's mutex in case of regulator_put. Signed-off-by: Ashay Jaiswal <ashayj@codeaurora.org> Signed-off-by: Mark Brown <broonie@kernel.org> Cc: stable@vger.kernel.org
2014-12-29regulator: core: Fix format specifier warningAniroop Mathur1-1/+1
Signed-off-by: Aniroop Mathur <a.mathur@samsung.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2014-12-29regulator: core: Avoid negative regulator no & initialize it to -1Aniroop Mathur1-3/+3
This patch initializes regulator_no to -1 to avoid extra subtraction operation performed every time we register a regulator and avoid negative regulator no in its name. Signed-off-by: Aniroop Mathur <a.mathur@samsung.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2014-12-05Merge remote-tracking branches 'regulator/topic/anatop', 'regulator/topic/disable', 'regulator/topic/dummy' and 'regulator/topic/gpio' into regulator-nextMark Brown1-1/+18
2014-12-04regulator: core: Fix regualtor_ena_gpio_free not to access pin after freeingSeung-Woo Kim1-0/+2
After freeing pin from regulator_ena_gpio_free, loop can access the pin. So this patch fixes not to access pin after freeing. Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2014-11-24regulator: core: Add PRE_DISABLE notificationRichard Fitzgerald1-0/+16
Add a PRE_DISABLE notification so that consumers can use a notifier to run any steps required to prepare for the regulator being switched off. Since the regulator disable can fail an abort notification is also added. Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2014-10-31regulator: Lower priority of constraint loggingMark Brown1-1/+1
Some systems have very large numbers of regulators so the constraint logging done at startup can end up being a very big part of the boot output which is both verbose and slows things down if the console is a serial console. Lower to dev_dbg() instead, we may want to provide a boot parameter to raise this in future but for now people can edit the source. Signed-off-by: Mark Brown <broonie@kernel.org> Reviewed-by: Guenter Roeck <linux@roeck-us.net>
2014-10-20regulator: Add ena_gpio_initialized to regulator_configMarkus Pargmann1-1/+2
Most drivers do not set the ena_gpio field of struct regulator_config before passing it to the regulator core. This is fine as long as the gpio identifier that is passed is a positive integer. But the gpio identifier 0 is also valid. So we are not able to decide wether we got a real gpio identifier or not based on a 0 in ena_gpio. To be able to decide if it is a valid gpio that got passed, this patch adds a ena_gpio_initialized field that should be set if was initialized with a correct value, either a gpio >= 0 or a negative error number. The core then checks if ena_gpio or ena_gpio_initialized before handling it as a gpio. This way we maintain backwards compatibility and fix the behaviour for gpio number 0. Signed-off-by: Markus Pargmann <mpa@pengutronix.de> Signed-off-by: Mark Brown <broonie@kernel.org>
2014-09-30Merge remote-tracking branches 'regulator/topic/tps65217', 'regulator/topic/tps65910' and 'regulator/topic/voltage-ev' into regulator-nextMark Brown1-7/+56
2014-09-30Merge remote-tracking branches 'regulator/topic/drivers', 'regulator/topic/enable', 'regulator/topic/fan53555', 'regulator/topic/hi6421' and 'regulator/topic/isl9305' into regulator-nextMark Brown1-53/+94
2014-09-10Merge branch 'topic/of' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator into regulator-isl9305Mark Brown1-3/+7
2014-09-10regulator: of: Provide simplified DT parsing methodMark Brown1-3/+7
Currently regulator drivers which support DT all repeat very similar code to supply a list of known regulator identifiers to be matched with DT, convert that to platform data which is then matched up with the regulators as they are registered. This is both fiddly to get right and for devices which can use the standard helpers to provide their operations is the main source of code in the driver. Since this code is essentially identical for most drivers we can factor it out into the core, moving the identifiers in the match table into the regulator descriptors and also allowing drivers to pass in the name of the subnode to search. When a driver provides an of_match string for the regulator the core will attempt to use that to obtain init_data, allowing the driver to remove all explicit code for DT parsing and simply provide data instead. The current code leaks the phandles for the child nodes, this will be addressed incrementally and makes no practical difference for FDT anyway as the DT data structures are never freed. Signed-off-by: Mark Brown <broonie@linaro.org>
2014-08-29regulator: core: Add REGULATOR_EVENT_PRE_VOLTAGE_CHANGE (and ABORT)Heiko Stübner1-7/+56
In some cases we need to know when a regulator is about to be changed. Add a way for clients to be notified. Note that for set_voltage() we don't necessarily know what voltage we'll end up with, so we tell the client what the range will be so they can prepare. Signed-off-by: Heiko Stübner <heiko@sntech.de> Signed-off-by: Doug Anderson <dianders@chromium.org> Signed-off-by: Mark Brown <broonie+linaro@kernel.org>
2014-08-19regulator: core: add const to regulator_ops and fix build error in mc13892Guodong Xu1-4/+4
Commit 272e2315fac3 ("regulator: core: add const qualifier to ops in struct regulator_desc") introduced const qualifier to ops in regulator_desc. This patch adds 'const' to regulator_ops vars in newly added core APIs for v3.17-rc1: - regulator_get_hardware_vsel_register() - regulator_list_hardware_vsel() This patch also fix a build error in mc13892-regulator.c due to const regulator_desc.ops. Modification of regulator_desc.ops' member fields is not allowed. Signed-off-by: Guodong Xu <guodong.xu@linaro.org> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-08-16regulator: core: add guard delay between calling regulator_disable and _enableGuodong Xu1-0/+31
Some regulator require a minimum delay between its disable and next enable. This is to avoid damages when out-of-range frequent disable/enable of a single regulator can bring to the regulator chip. Add @off_on_delay to struct regulator_desc. Device drivers' can use this field to set this guard time. Add @last_off_jiffy to struct regulator_dev. When @off_on_delay is set by driver, regulator core can store its last off (disable) time into this field. Signed-off-by: Guodong Xu <guodong.xu@linaro.org> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-08-16regulator: core: factor out delay function from _regulator_do_enableGuodong Xu1-34/+40
A common delay function can be helpful when implementing new features. Factor it out to maximize code reusability. Signed-off-by: Guodong Xu <guodong.xu@linaro.org> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-08-16regulator: core: add const qualifier to ops in struct regulator_descGuodong Xu1-12/+12
struct regulator_ops *ops is a member in struct regulator_desc, which gets its value from individual regulator driver upon regulator_register() and is used by regulator core APIs. It's not allowed for regulator core to modify any of these callbacks in *ops. Add 'const' qualifier to enforce that. Signed-off-by: Guodong Xu <guodong.xu@linaro.org> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-08-05Merge remote-tracking branches 'regulator/topic/da9211', 'regulator/topic/getreg', 'regulator/topic/gpio' and 'regulator/topic/lp872x' into regulator-nextMark Brown1-9/+84
2014-07-29regulator: core: Allow to get voltage count and list from parentJavier Martinez Canillas1-6/+17
Load switches are modeled as regulators but they just provide the voltage of their parent input supply. So, the drivers for these switches usually neither provide a .list_voltage handler not set a .n_voltages count. But there is code in the kernel that assumes that all regulators should be able to provide this information (e.g: cpufreq and mmc subsystems). If the voltage count and list are not available for a regulator and it has a parent input supply, then use the parent values. Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-07-29regulator: core: Get voltage from parent if not availableJavier Martinez Canillas1-0/+2
Load switches are modeled as regulators but they just provide the voltage of their parent input supply. So the drivers for these switches usually don't provide a .get_voltage function handler but there is code in the kernel that assumes that all regulators should be able to provide its current voltage rail. So, if the output voltage for a regulator is not available and it has a parent supply, then pass the voltage of its parent. Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-07-25regulator: Add helpers for low-level register accessTuomas Tynkkynen1-0/+71
Add helper functions that allow regulator consumers to obtain low-level details about the regulator hardware, like the voltage selector register address and such. These details can be useful when configuring hardware or firmware that want to do low-level access to regulators, with no involvement from the kernel. The use-case for Tegra is a voltage-controlled oscillator clocksource which has control logic to change the supply voltage via I2C to achieve a desired output clock rate. Signed-off-by: Tuomas Tynkkynen <ttynkkynen@nvidia.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-06-30regulator: core: convert to use gpio_desc internallyRussell King1-9/+13
Convert the regulator GPIO handling to use a gpio descriptor rather than numbers. This allows us to revise the interfaces to permit all GPIOs to be used with the regulator core. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-06-05regulator: core: print error value when constraints are not appliedNishanth Menon1-3/+5
With commit 064d5cd110f94ce41ca5681dcda8b77fa63d5b95 (regulator: core: Fix the init of DT defined fixed regulators) We ensure that regulator must be capable of providing it's current voltage when constraints are used, however adding the return value in the print is a little more informative to explain the nature of the failure involved. So, instead of providing message such as: smps9: failed to get the current voltage having error value added to the message such as: smps9: failed to get the current voltage(-22) is a little more informative for debugging the error. Signed-off-by: Nishanth Menon <nm@ti.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-06-02Merge remote-tracking branches 'regulator/topic/fixed', 'regulator/topic/id-const', 'regulator/topic/ltc3589', 'regulator/topic/max8649' and 'regulator/topic/of' into regulator-nextMark Brown1-1/+2
2014-06-02Merge remote-tracking branch 'regulator/topic/core' into regulator-nextMark Brown1-10/+12
2014-06-01regulator: core: Fix the init of DT defined fixed regulatorsAlban Bedel1-7/+16
When a regulator is defined using DT and it has a single voltage the regulator init always tries to apply this voltage. However it fails if the regulator isn't settable because it is using an internal low level function. To overcome this we now first query the regulator and only set it if needed. Signed-off-by: Alban Bedel <alban.bedel@avionic-design.de> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-06-01regulator: core: Disable unused regulators after deferred probing is doneSaravana Kannan1-1/+1
regulator_init_complete does a scan of regulators which dont have always-on or consumers are automatically disabled as being unused. However, with deferred probing, late_initcall() is too soon to declare a regulator as unused as the regulator itself might not have registered due to defferal - Example: A regulator deffered due to i2bus not available which in turn is deffered due to pinctrl availability. Since deferred probing is done in late_initcall(), do the cleanup of unused regulators by regulator_init_complete in late_initcall_sync instead of late_initcall. Cc: Liam Girdwood <lgirdwood@gmail.com> Cc: Mark Brown <broonie@kernel.org> Cc: Markus Pargmann <mpa@pengutronix.de> Signed-off-by: Saravana Kannan <skannan@codeaurora.org> [nm@ti.com: minor rewording] Signed-off-by: Nishanth Menon <nm@ti.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-06-01regulator: Don't disable unused regulators we don't have permission forMark Brown1-2/+6
In the spirit of conservatism that governs our general approach to permissions it is better if we don't touch regulators we weren't explicitly given permissions to control. This avoids the need to explicitly specify unknown regulators in DT as always on, if a regulator is not otherwise involved in software control it can be omitted from the DT. Regulators explicitly given constraints in DT still need to have an always on constraint specified as before. Signed-off-by: Mark Brown <broonie@linaro.org>
2014-05-28regulator: Fix regulator_get_{optional,exclusive}() documentationStephen Boyd1-7/+4
regulator_get_optional() doesn't hold an exclusive reference to the regulator. Fix the documentation and reword the exclusive documentation to fix the grammatical error "this reference is held". Signed-off-by: Stephen Boyd <sboyd@codeaurora.org> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-05-26regulator: core: Use map_voltage_linear_range by default for list_voltage_linear_rangeAxel Lin1-0/+4
Use map_voltage_linear_range() if list_voltage_linear_range() is in use and nothing is set. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-05-23regulator: Constify the pointer to alias name arrayLee Jones1-3/+4
Toughen-up checks for read-only regulator names. Signed-off-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-04-14regulator: core: Get and put regulator of_nodeCharles Keepax1-1/+2
Currently the regulator core does not take an additional reference to the of_node it is passed. This means that the caller must ensure that the of_node is valid for the duration of the regulator's existance. It is reasonable for the framework to assume it is passed a valid of_node but seems onerous for it to assume the caller will keep the node valid for the life-time of the regulator, especially when devm_regulator_register is used and there will likely be no code in the driver called at the point it would be safe to put the of_node. This patch adds an additional of_node_get when the regulator is registered and an of_node_put when it is unregistered in the core. This means individual drivers are free to put their of_node references at the end of probe letting the regulator core handling it from there. This simplifies code on the driver side. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-04-02Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivialLinus Torvalds1-1/+1
Pull trivial tree updates from Jiri Kosina: "Usual rocket science -- mostly documentation and comment updates" * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial: sparse: fix comment doc: fix double words isdn: capi: fix "CAPI_VERSION" comment doc: DocBook: Fix typos in xml and template file Bluetooth: add module name for btwilink driver core: unexport static function create_syslog_header mmc: core: typo fix in printk specifier ARM: spear: clean up editing mistake net-sysfs: fix comment typo 'CONFIG_SYFS' doc: Insert MODULE_ in module-signing macros Documentation: update URL to hfsplus Technote 1150 gpio: update path to documentation ixgbe: Fix format string in ixgbe_fcoe. Kconfig: Remove useless "default N" lines user_namespace.c: Remove duplicated word in comment CREDITS: fix formatting treewide: Fix typo in Documentation/DocBook mm: Fix warning on make htmldocs caused by slab.c ata: ata-samsung_cf: cleanup in header file idr: remove unused prototype of idr_free()
2014-03-26Merge remote-tracking branch 'regulator/topic/core' into regulator-nextMark Brown1-0/+14
2014-03-04Merge tag 'regulator-v3.14-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulatorLinus Torvalds1-28/+20
Pull regulator fixes from Mark Brown: "A couple of fixes here which ensure that regulators using the core support for GPIO enables work in all cases by ensuring that helpers are used consistently rather than open coding in places and hence not having GPIO support in some of them" * tag 'regulator-v3.14-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator: regulator: core: Replace direct ops->disable usage regulator: core: Replace direct ops->enable usage
2014-02-25regulator: core: Replace direct ops->disable usageMarkus Pargmann1-21/+13
There are many places where ops->disable is called directly. Instead we should use _regulator_do_disable() which also handles gpio regulators. To be able to use the wrapper function from _regulator_force_disable(), I moved the _notifier_call_chain() call from _regulator_do_disable() to _regulator_disable(). This way, _regulator_force_disable() can use different flags for _notifier_call_chain() without calling it twice. Cc: <stable@vger.kernel.org> # 3.10+ Signed-off-by: Markus Pargmann <mpa@pengutronix.de> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-02-25regulator: core: Replace direct ops->enable usageMarkus Pargmann1-7/+7
There are some direct ops->enable in the regulator core driver. This is a potential issue as the function _regulator_do_enable() handles gpio regulators and the normal ops->enable calls. These gpio regulators are simply ignored when ops->enable is called directly. One possible bug is that boot-on and always-on gpio regulators are not enabled on registration. This patch replaces all ops->enable calls by _regulator_do_enable. [Handle missing enable operations -- broonie] Cc: <stable@vger.kernel.org> # 3.10+ Signed-off-by: Markus Pargmann <mpa@pengutronix.de> Signed-off-by: Mark Brown <broonie@linaro.org> regulator: Handle invalid enable operation for always/boot on regulators Signed-off-by: Mark Brown <broonie@linaro.org>
2014-02-23Merge remote-tracking branch 'regulator/fix/core' into regulator-linusMark Brown1-1/+1
2014-02-21regulator: core: Change dummy supplies error message to a warningShuah Khan1-1/+1
Change "dummy supplies not allowed" error message to warning instead, as this is a just warning message with no change to the behavior. [Added a CC to stable since some other bug fixes cause this to come up more frequently on PCs which is how it was noticed -- broonie] Signed-off-by: Shuah Khan <shuah.kh@samsung.com> Signed-off-by: Mark Brown <broonie@linaro.org> Cc: stable@vger.kernel.org
2014-02-20Merge branch 'master' into for-nextJiri Kosina1-9/+15
2014-02-19treewide: Fix typo in Documentation/DocBookMasanari Iida1-1/+1
This patch fix spelling typo in Documentation/DocBook. It is because .html and .xml files are generated by make htmldocs, I have to fix a typo within the source files. Signed-off-by: Masanari Iida <standby24x7@gmail.com> Acked-by: Randy Dunlap <rdunlap@infradead.org> Signed-off-by: Jiri Kosina <jkosina@suse.cz>