dect
/
linux-2.6
Archived
13
0
Fork 0
Commit Graph

33 Commits

Author SHA1 Message Date
Diego Liziero cd78dfc6c6 drivers/regulator: fix when type is different from REGULATOR_VOLTAGE or REGULATOR_CURRENT
When regulator_desc->type is something different from REGULATOR_VOLTAGE or REGULATOR_CURRENT
the if should probably return ERR_PTR(-EINVAL)

The semantic patch that makes this change is as follows:
(http://www.emn.fr/x-info/coccinelle/)

@@ expression E; constant C; @@
(
- !E == C
+ E != C
)

Signed-off-by: Diego Liziero <diegoliz@gmail.com>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
2009-04-28 18:58:07 +01:00
Dan Carpenter 036de8efae unreachable code in drms_uA_update()
I removed the extra semi-colon and indented the return statement.

The unreachable code was found by smatch (http://repo.or.cz/w/smatch.git).
The patch was compile tested.

regards,
dan carpenter

Signed-off-by: Dan Carpenter <error27@gmail.com>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
2009-04-28 18:58:06 +01:00
Mark Brown ca7255614e regulator: Support disabling of unused regulators by machines
At present it is not possible for machine constraints to disable
regulators which have been left on when the system starts, for example
as a result of fixed default configurations in hardware. This means that
power may be wasted by these regulators if they are not in use.

Provide intial support for this with a late_initcall which will disable
any unused regulators if the machine has enabled this feature by calling
regulator_has_full_constraints(). If this has not been called then print
a warning to encourage users to fully specify their constraints so that
we can change this to be the default behaviour in future.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
2009-03-31 09:56:29 +01:00
Mark Brown 50f075963f regulator: Don't increment use_count for boot_on regulators
Don't set use_count for regulators that are enabled at boot since this
stops the supply being disabled by well-behaved consumers which do
balanced enables and disabled. Any consumers which don't do disables
which are not matched by enables are unable to share regulators - shared
regulators are the common case so the API should facilitate them.

Consumers that want to disable regulators that are enabled when they
start have two options:

 - Do a regulator_enable() prior to the disable to bring the use count
   in sync with the hardware state; this will ensure that if the
   regulator was enabled by another driver then this consumer will play
   nicely with it.
 - Use regulator_force_disable(); this explicitly bypasses any checks
   done by the core and documents the inability of the driver to share
   the supply.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
2009-03-31 09:56:29 +01:00
David Brownell cd94b50530 regulator: refcount fixes
Fix some refcounting issues in the regulator framework, supporting
regulator_disable() for regulators that were enabled at boot time
via machine constraints:

 - Update those regulators' usecounts after enabling, so they
   can cleanly be disabled at that level.

 - Remove the problematic per-consumer usecount, so there's
   only one level of enable/disable.

Buggy consumers could notice different bug symptoms.  The main
example would be refcounting bugs; also, any (out-of-tree) users
of the experimental regulator_set_optimum_mode() stuff which
don't call it when they're done using a regulator.

This is a net minor codeshrink.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
2009-03-31 09:56:28 +01:00
Mark Brown 1dc60343f8 regulator: Don't warn if we failed to get a regulator
The consumer can print a message if required, some consumers may have
optional regulators and wish to downgrade the logging for them or ignore
their absence.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
2009-03-31 09:56:28 +01:00
Mark Brown cacf90f24e regulator: Allow boot_on regulators to be disabled by clients
Rather than incrementing the reference count for boot_on regulators
(which prevents them being disabled later on) simply force the
regulator to be enabled when applying the constraints. Previously
boot_on was essentially equivalent to always_on.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
2009-03-31 09:56:27 +01:00
Mark Brown 3e2b9abda5 regulator: Don't warn on omitted voltage constraints
Specifying voltage constraints is optional (and only needed if the
consumer is allowed to change the voltage) so don't complain unless
a voltage has been specified.

Also avoid surprises with a dangling else while we're here.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
2009-03-31 09:56:26 +01:00
David Brownell 4367cfdc7c regulator: enumerate voltages (v2)
Add a basic mechanism for regulators to report the discrete
voltages they support:  list_voltage() enumerates them using
selectors numbered from 0 to an upper bound.

Use those methods to force machine-level constraints into bounds.
(Example:  regulator supports 1.8V, 2.4V, 2.6V, 3.3V, and board
constraints for that rail are 2.0V to 3.6V ... so the range of
voltages is then 2.4V to 3.3V on this board.)

Export those voltages to the regulator consumer interface, so for
example regulator hooked up to an MMC/SD/SDIO slot can report the
actual voltage options available to cards connected there.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
2009-03-31 09:56:24 +01:00
Mark Brown a308466c24 regulator: Allow regulators to set the initial operating mode
This is useful when wishing to run in a fixed operating mode that isn't
the default.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
2009-03-31 09:56:24 +01:00
Mark Brown fe203ddfa5 regulator: Suggest use of datasheet supply or pin names for consumers
Update the documentation to suggest the use of datasheet names for
the supplies requested by regulator consumers. Doing this makes it
easier to tie the design for a given platform up with the requirements
of the driver for a consumer.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
2009-03-31 09:56:23 +01:00
Mike Rapoport 0f1d747bfa regulator: add unset_regulator_supplies to fix regulator_unregister
Currently regulator_unregister does not clear regulator <--> consumer
mapping.
This patch introduces unset_regulator_supplies that clear the map.

Signed-off-by: Mike Rapoport <mike@compulab.co.il>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
2009-03-31 09:56:23 +01:00
Mark Brown 1fa9ad52b0 regulator: Hoist struct regulator_dev out of core to fix notifiers
Commit 872ed3fe176833f7d43748eb88010da4bbd2f983 caused regulator drivers
to take the struct regulator_dev lock themselves which requires that the
struct be visible to them. Band aid this by making the struct visible.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
2009-03-31 09:56:22 +01:00
Mark Brown 0527100fd1 regulator: Pass regulator init data as explict argument when registering
Rather than having the regulator init data read from the platform_data
member of the struct device that is registered for the regulator make
the init data an explict argument passed in when registering. This
allows drivers to use the platform data for their own purposes if they
wish.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
2009-03-31 09:56:21 +01:00
Jonathan Cameron b136fb4463 Regulator: Push lock out of _notifier_call_chain + add voltage change event.
Regulator: Push lock out of _notifier_call_chain and into caller functions
(side effect of fixing deadlock in regulator_force_disable)
+ Add a voltage changed event.
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
2009-03-31 09:56:20 +01:00
David Brownell 853116a105 regulator: add get_status()
Based on previous LKML discussions:

 * Update docs for regulator sysfs class attributes to highlight
   the fact that all current attributes are intended to be control
   inputs, including notably "state" and "opmode" which previously
   implied otherwise.

 * Define a new regulator driver get_status() method, which is the
   first method reporting regulator outputs instead of inputs.
   It can report on/off and error status; or instead of simply
   "on", report the actual operating mode.

For the moment, this is a sysfs-only interface, not accessible to
regulator clients.  Such clients can use the current notification
interfaces to detect errors, if the regulator reports them.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
2009-03-31 09:56:20 +01:00
David Brownell 6001e13c5f regulator: catch some registration errors
Prevent registration of duplicate "struct regulator" names.
They'd be unavailable, and clearly indicate something wrong.

[Edited to remove check for NULL consumer device until we have a
solution for things like cpufreq -- broonie]

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
2009-01-08 20:10:34 +00:00
Mark Brown cf7bbcdf4d regulator: Fix some kerneldoc rendering issues
There are some minor textual changes in here as well, mostly to enable()
and disable() but the primary goal of these changes is to fix
misrenderings of the kerneldoc documentation for the regulator API.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
2009-01-08 20:10:33 +00:00
Mark Brown c8e7e4640f regulator: Add missing kerneldoc
This is only the documentation that the kerneldoc system warns about.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
2009-01-08 20:10:33 +00:00
Mark Brown 69279fb9a9 regulator: Clean up kerneldoc warnings
Remove kerneldoc warnings that don't relate to missing documentation,
mostly by renaming parameters in the documentation to match their
actual names.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
2009-01-08 20:10:33 +00:00
Mark Brown 8dc5390d4f regulator: Remove extraneous kerneldoc annotations
Some of the internal structures have no kerneldoc but the ** at the start
of the comment marking them for documentation.  Remove the annotation
until some is added.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
2009-01-08 20:10:32 +00:00
Mike Rapoport 74f544c1fc regulator: move set_machine_constraints after regulator device initialization
Calling set_machine_constraints before regulator device initialization
causes crash when constraints have apply_uV set.

Signed-off-by: Mike Rapoport <mike@compulab.co.il>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
2009-01-08 20:10:31 +00:00
David Brownell 7ad68e2f97 regulator: sysfs attribute reduction (v2)
Clean up the sysfs interface to regulators by only exposing the
attributes that can be properly displayed.  For example: when a
particular regulator method is needed to display the value, only
create that attribute when that method exists.

This cleaned-up interface is much more comprehensible.  Most
regulators only support a subset of the possible methods, so
often more than half the attributes would be meaningless.  Many
"not defined" values are no longer necessary.  (But handling
of out-of-range values still looks a bit iffy.)

Documentation is updated to reflect that few of the attributes
are *always* present, and to briefly explain why a regulator may
not have a given attribute.

This adds object code, about a dozen bytes more than was removed
by the preceding patch, but saves a bunch of per-regulator data
associated with the now-removed attributes.  So there's a net
reduction in memory footprint.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
2009-01-08 20:10:30 +00:00
David Brownell 4fca9545d1 regulator: code shrink (v2)
Shrink regulator core by removing duplication in attribute printing
and probe() cleanup paths.  Saves about 340 bytes (object) on ARM.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
2009-01-08 20:10:30 +00:00
David Brownell e573520b17 regulator: improved mode error checks
Minor bugfixes in handling of regulator modes:

 - have the routine verifying regulator modes check against
   the set of legal modes (!);

 - have regulator_set_optimum_mode() verify the return value
   of regulator_ops.get_optimum_mode(), like drms_uA_update();

 - one call to regulator_ops.set_mode() treated zero as a
   failure code; make this consistent with other callers.

Both regulator_set_mode() and regulator_set_optimum_mode() now
require valid_ops_mask to include REGULATOR_CHANGE_MODE; that
seems like a bugfix too.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
2009-01-08 20:10:30 +00:00
David Brownell 412aec6105 regulator: enable/disable refcounting
Make the <linux/regulator.h> framework treat enable/disable call
pairs like the <linux/clk.h> and <linux/interrupt.h> frameworks do:
they're refcounted, so that different parts of a driver don't need
to put work into coordination that frameworks normally handle.
It's a minor object code shrink.

It also makes the regulator_is_disabled() kerneldoc say what it's
actually returning:  return value is not a refcount, and may report
an error (e.g. I/O error from I2C).

It also fixes some minor regulator_put() goofage:  removing unlocked
access to the enable state.  (But still not making regulator put/get
match the refcounting pattern they invoke.)

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
2009-01-08 20:10:29 +00:00
Kay Sievers 812460a927 regulator: struct device - replace bus_id with dev_name(), dev_set_name()
This patch is part of a larger patch series which will remove
the "char bus_id[20]" name string from struct device. The device
name is managed in the kobject anyway, and without any size
limitation, and just needlessly copied into "struct device".

To set and read the device name dev_name(dev) and dev_set_name(dev)
must be used. If your code uses static kobjects, which it shouldn't
do, "const char *init_name" can be used to statically provide the
name the registered device should have. At registration time, the
init_name field is cleared, to enforce the use of dev_name(dev) to
access the device name at a later time.

We need to get rid of all occurrences of bus_id in the entire tree
to be able to enable the new interface. Please apply this patch,
and possibly convert any remaining remaining occurrences of bus_id.

We want to submit a patch to -next, which will remove bus_id from
"struct device", to find the remaining pieces to convert, and finally
switch over to the new api, which will remove the 20 bytes array
and does no longer have a size limitation.

Thanks,
Kay

From: Kay Sievers <kay.sievers@vrfy.org>
Subject: regulator: struct device - replace bus_id with dev_name(), dev_set_name()

Cc: Liam Girdwood <lrg@slimlogic.co.uk>
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-Off-By: Kay Sievers <kay.sievers@vrfy.org>

Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
2009-01-08 20:10:29 +00:00
Mark Brown bc558a60b5 regulator: Export regulator name via sysfs
Provide a new file 'name' in the regulator sysfs class with a human
readable name for the regulator for use in applications.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
2008-10-13 21:51:53 +01:00
Mark Brown e5fda26c7e regulator: Enable regulators marked as always_on
If the machine constraints mark a regulator as always_on but this was
not done by the bootloader then enable the regulator when applying
constraints.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
2008-10-13 21:51:51 +01:00
Mark Brown e06f5b4fea regulator: Additional diagnostics for machine constraints
Try to find a human readable name for the regulator we're failing on and
print a specific diagnostic when we fail to set the suspend state.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
2008-10-13 21:51:51 +01:00
Mark Brown 46fabe1edd regulator: check for init_data on registration
Since it is now mandatory to supply constraints via init_data on device
registration check for that when registering, saving us from oopsing
later on.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
2008-10-13 21:51:51 +01:00
Liam Girdwood a5766f11cf regulator: core - Rework machine API to remove string based functions.
This improves the machine level API in order to configure
regulator constraints and consumers as platform data and removes the
old string based API that required several calls to set up each regulator.

The intention is to create a struct regulator_init_data, populate
it's fields with constraints, consumers devices, etc and then register
the regulator device from board.c in the standard Linux way.

e.g. regulator LDO2 (supplying codec and sim) platform data.

/* regulator LDO2 consumer devices */
static struct regulator_consumer_supply ldo2_consumers[] = {
{
	.dev	= &platform_audio_device.dev,
	.supply	= "codec_avdd",
},
{
	.dev	= &platform_sim_device.dev,
	.supply	= "sim_vcc",
}
};

/* regulator LDO2 constraints  */
static struct regulator_init_data ldo2_data = {
	.constraints = {
		.min_uV = 3300000,
		.max_uV = 3300000,
		.valid_modes_mask = REGULATOR_MODE_NORMAL,
		.apply_uV = 1,
	},
	.num_consumer_supplies = ARRAY_SIZE(ldo2_consumers),
	.consumer_supplies = ldo2_consumers,
};

/* machine regulator devices with thier consumers and constraints */
static struct platform_device wm8350_regulator_devices[] = {
{
	.name = "wm8350-regulator",
	.id = WM8350_LDO_2,
	.dev = {
		.platform_data = &ldo2_data,
	},
},
};

Changes in detail:-

  o Removed all const char* regulator config functions in machine API.
  o Created new struct regulator_init_data to contain regulator
    machine configuration constraints and consmuers.
  o Changed set_supply(), set_machine_constraints(),
    set_consumer_device_supply() to remove their string identifier
    parameters. Also made them static and moved functions nearer top of
    core.c.
  o Removed no longer used inline func to_rdev()
  o Added regulator_get_init_drvdata() to retrieve init data.
  o Added struct device* as parameter to regulator_register().
  o Changed my email address.

Signed-off-by: Eric Miao <eric.miao@marvell.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
2008-10-13 21:51:50 +01:00
Liam Girdwood 414c70cb91 regulator: regulator framework core
This adds the regulator framework core.

This framework is designed to provide a generic interface to voltage
and current regulators within the Linux kernel. It's intended to
provide voltage and current control to client or consumer drivers and
also provide status information to user space applications through a
sysfs interface.

The intention is to allow systems to dynamically control regulator
output in order to save power and prolong battery life. This applies
to both voltage regulators (where voltage output is controllable) and
current sinks (where current output is controllable).

This framework safely compiles out if not selected so that client
drivers can still be used in systems with no software controllable
regulators.

Signed-off-by: Liam Girdwood <lg@opensource.wolfsonmicro.com>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2008-07-30 10:10:21 +01:00