Commit Graph

786 Commits

Author SHA1 Message Date
Xu Kai f58d0d1b41 leds: leds-qpnp: bug fix for NULL pointer dereference in qpnp_xxx_set()
In previous merged commit: e7bca9b9, there is a bug about NULL
pointer dereference in qpnp_xxx_set functions. When led_mode
is MANUAL_MODE, there will be no PWM config data, so "pwm_cfg"
is a NULL pointer in this situation. Fix this by using it only
when the PWM config data exists.

CRs-Fixed: 622683
Change-Id: Ife218cc352e9620e86e0dda96335b6a43bdb65fb
Signed-off-by: Xu Kai <kaixu@codeaurora.org>
2014-03-10 16:02:14 +08:00
Xu Kai e7bca9b959 leds: leds-qpnp: PWM period granularity auto selection for leds
Some leds use PWM wave to control the brightness. The original
period granularity is using microsecond by default, it's a very
large granularity and will cause some user experience issues on
leds' brightness.

Auto select the PWM period granularity between microsecond and
nanosecond according to the range that hardware can support.

CRs-Fixed: 622683
Change-Id: I0669a0c88ca2ba491f0a53be6070476d61374d72
Signed-off-by: Xu Kai <kaixu@codeaurora.org>
2014-03-03 12:15:19 +08:00
Chun Zhang 5e917f497f leds: leds-qpnp: correct brightness value for MPP based LEDs
MPP ports provide LEDs with current from 5mA to 40mA with a resolution
of 5mA. Due to this PMIC feature, MPP based LED intensity should be
rounded to reflect actual hardware status.

Change-Id: I306f19df0dd455dbaad9a364fb0df5694015d9ea
Signed-off-by: Chun Zhang <chunz@codeaurora.org>
2014-02-25 17:50:14 -08:00
Abinaya P 0e9a6e2532 leds: leds-qpnp: support for single regulator for flash and torch
Add code to handle if there is only one regulator for
both flash and torch.

Change-Id: Ib88867cc56f48d589dcf5346c64964efbd4ad5a5
Signed-off-by: Abinaya P <abinayap@codeaurora.org>
2014-02-20 17:43:39 +05:30
Abinaya P fd18025b12 leds: leds-qpnp: set VREG_OK parameter based on strobe type
If the strobe is from hardware, vreg_ok parameter is set to
0x40 and if the strobe is from software, vreg_ok parameter
is set to 0x80.

Change-Id: Ic692bee1e40c3ee0d69e319bf80cb8b135d6833c
Signed-off-by: Abinaya P <abinayap@codeaurora.org>
2014-02-20 15:15:33 +05:30
Abinaya P 9774f5b4c8 leds: leds-qpnp: avoid truncation in qpnp_led_masked_write function
Since the last parameter of qpnp_led_masked_write function is
of type 'u8', make sure that only value of type 'u8' is passed
to this parameter of function to avoid truncation.

Change-Id: If047f844fc45713b77c4561a88253dade3c4c478
Signed-off-by: Abinaya P <abinayap@codeaurora.org>
2014-02-12 11:58:33 +05:30
Abinaya P 4878d4a1fc leds: leds-qpnp: Set the strobe bit correctly for flash led
The strobe bit is set to 1 when the flash led uses HW strobe and it is
set to 0 when the flash led uses SW strobe.

CRs-Fixed: 585414
Change-Id: Id65e9e70bc6c84ca5c8a9e65fd86e67b513e6745
Signed-off-by: Abinaya P <abinayap@codeaurora.org>
2014-01-23 09:45:05 +05:30
Abinaya P cedc9b5d79 leds: leds-qpnp: Rename WLED OVP Enumeration
The enumerator WLED_OVP_37V is renamed to WLED_OVP_27V in
order to comply with the register documentation.

Change-Id: I78f885268194b53bb7c690a733ba2fe03cc33bfe
CRs-Fixed: 592660
Signed-off-by: Himanshu Aggarwal <haggarwa@codeaurora.org>
2013-12-31 12:49:13 +05:30
Xu Kai 4409c5d5dd pwm: qpnp: modify to use pwm_config_us() for some qcom drivers
Kernel 3.10 defines pwm_config() to use nanosecond parameters, but
now some qcom drivers still use pwm_config() to pass microsecond
parameters. pwm-qpnp driver has already provided a new API called
pwm_config_us() to support microsecond parameters, so we should
modify to use pwm_config_us() instead of pwm_config() for these
drivers.

CRs-Fixed: 587715
Change-Id: I222440bb7636972b9ae35eba175ddffc58095ce8
Signed-off-by: Xu Kai <kaixu@codeaurora.org>
2013-12-17 15:12:43 +08:00
Linux Build Service Account 632ac48e5b Merge "leds: leds-qpnp: Correctly terminate of_device_id array" 2013-12-16 15:02:48 -08:00
Himanshu Aggarwal 4cae635627 leds: leds-qpnp: Set proper flash duration
Flash duration is between 0ms and 1280ms in increments of 10ms and can
be stored in an 8-bit value. The current conversion formula to u8
results in shrinking of this value, which leads to a loss of
most-significant bit in flash duration. This erroneous calcuation
is corrected in the driver.

Change-Id: I43b486743703ed8007e2366e94ce145fdd4dc56e
CRs-Fixed: 582957
Signed-off-by: Himanshu Aggarwal <haggarwa@codeaurora.org>
2013-12-05 12:18:21 +05:30
Himanshu Aggarwal ea7a28ed93 leds: leds-qpnp: Correctly terminate of_device_id array
Add missing NULL terminator for device match table in drivers leds-qpnp.c.
Without this, of_dev_lookup() may run off the end of the array looking
for bogus data.

Change-Id: Ie6c61b4500a5fbe792e3154a761c235573c7e6bf
CRs-Fixed: 582141
Signed-off-by: Himanshu Aggarwal <haggarwa@codeaurora.org>
2013-11-30 21:12:21 +05:30
Sarada Prasanna Garnayak 17a3b9bd83 leds: leds-qpnp: Reset WLED enable register in wled init function
Reset WLED enable register in wled initialization function to avoid
unnecessary power consumption during the device boots up.

CRs-Fixed: 546571
Change-Id: Id8d8ed9d3c20e2209847457c711b7645d5de45b3
Signed-off-by: Sarada Prasanna Garnayak <c_sgarna@codeaurora.org>
2013-11-27 20:42:35 +05:30
Ian Maund f06163e6d0 msm: reap unused kernel files
This change removes source files from the kernel tree that
were not being used during make. The list of used files
was generated using an annotated make log and was then
compared with new files added since the public release of
kernel version 3.10.00. New files which were added but
not used have been removed from the tree.

A diff was also run to determine the list of files that had
been modified since the release of kernel version 3.10.00.
These files were then scrubbed based on the current kernel
configuration, removing invalid and unused conditionals.

Some files which support planned functionality or are
useful in debugging have been excluded from this reap.

Change-Id: Ia44a224d3cea7bc78dd45e8a8279860d35d4b008
Signed-off-by: Ian Maund <imaund@codeaurora.org>
2013-11-21 17:45:28 -08:00
Kumar Gala f629ba6d5b msm: remove include of <asm/mach-types.h> and <asm/system.h>
Upstream has removed <asm/system.h> so remove it from legacy uses.  As all
the platforms we support utilize device tree we no longer need to include
<asm/mach-types.h>.

Change-Id: I8e53b1fd96ad26711fae59f081a8892f8bb184b7
Signed-off-by: Kumar Gala <galak@codeaurora.org>
2013-11-04 13:59:18 -06:00
Linux Build Service Account c5b6680df0 Merge "leds: leds-qpnp: Avoid OVP spike when disabling wled" 2013-10-29 04:29:13 -07:00
Amy Maloche fef9e15072 leds: leds-qpnp: Avoid OVP spike when disabling wled
Implement software workaround to avoid OVP spike when
WLED module is disabled.

Change-Id: I8468c4d2f0f82ab642932ea0a9c1d4687cc3d3db
Signed-off-by: Amy Maloche <amaloche@codeaurora.org>
2013-10-28 12:51:29 -07:00
Linux Build Service Account 705a36a47c Merge "leds: leds-qpnp: Add regulator support for MPP based LEDs" 2013-10-26 01:21:51 -07:00
Linux Build Service Account 071e315f7b Merge "leds: leds-qpnp: Changes for WLED work function called only once." 2013-10-25 20:09:52 -07:00
Sarada Prasanna Garnayak cc76d7dda8 leds: leds-qpnp: Changes for WLED work function called only once.
Remove the redundant and extra schedule_work() call during
wled initialization sequence as __qpnp_led_work() call just
before schedule_work() has already does the wled initialization.

CRs-Fixed: 554413
Change-Id: Ib206cb6b67db0d53ddeb285a28940abca7c9fe6e
Signed-off-by: Sarada Prasanna Garnayak <c_sgarna@codeaurora.org>
2013-10-25 19:52:40 +05:30
Chun Zhang 98868eff8e leds: leds-qpnp: Add regulator support for MPP based LEDs
MPP based LEDs may be powered by regulators. Regulator support is
necessary to properly use MPP based LEDs.

Change-Id: Ib3c328f0d5f35be8b171fdd76c75c4e85539c833
Signed-off-by: Chun Zhang <chunz@codeaurora.org>
2013-10-24 13:14:22 -07:00
Chun Zhang 768738efed leds: leds-qpnp: Added in delay for flash LED operation
Flash LEDs require VIN_CHG to reach 5V to fire stabely. Adding delay
between flash enable and assert strobe when flash LEDs are turned on
and between flash strobe desert and module disable provides an improved
proformance. This also simplifies enable sequence so that the current
module enable sequence 0x00 to 0x80 before going to 0xE0 un-necessary.

CRs-Fixed: 539632, 548259
Change-Id: I26472c9ba445f3a311814ede8a821fa580f460b8
Signed-off-by: Chun Zhang <chunz@codeaurora.org>
2013-10-21 19:33:43 -07:00
Mark Brown d041e861d4 leds: wm831x-status: Request a REG resource
commit 61abeba5222895d6900b13115f5d8eba7988d7d6 upstream.

The wm831x-status driver was not converted to use a REG resource when they
were introduced and the rest of the wm831x drivers converted, causing it
to fail to probe due to requesting the wrong resource type.

Signed-off-by: Mark Brown <broonie@linaro.org>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-09-26 17:18:27 -07:00
Amy Maloche b1a2f61113 leds: leds-qpnp: Avoid OVP spike when disabling wled
Implement software workaround to avoid OVP spike
when wled module is disabled.

Change-Id: I336de47e43dd187da421c7c780ab861147c84c71
Signed-off-by: Amy Maloche <amaloche@codeaurora.org>
2013-09-24 11:32:56 -07:00
Mohan Pallaka a305f87b3c leds: leds-qpnp: Add brightness control for mpp leds
Add brightness control by changing the current supplied
to leds in manual mode.

CRs-fixed: 539440
Change-Id: I3170e0edb2e5a963ee006923cb6d80172290bc88
Signed-off-by: Mohan Pallaka <mpallaka@codeaurora.org>
2013-09-18 00:31:32 -07:00
Himanshu Aggarwal ae734857bc leds: leds-qpnp: fix WLED max current mask
Change WLED_MAX_CURR_MASK to 0x1F as max current value in
LED1_FULL_SCALE_CURRENT register occupies 5 bits

CRs-fixed: 540299
Change-Id: I5297adceae6052e97750fe95aa96a05dd3625b08
Signed-off-by: Himanshu Aggarwal <haggarwa@codeaurora.org>
2013-09-13 11:54:37 +05:30
Prasad Sodagudi ff84eac09c pwm: Update pwm enable sequence in all PWM client drivers
The PWM controller in Qualcomm PMIC chipset needs to re-enabled
if the underlying PWM configuration is changed. With the
introduction of generic PWM framework in 3.10, the framework does not
pass through the PWM enable request if it finds that the PWM is
already enabled and silently discards the request. So add a check
to disable PWM before sending an enable request.

Signed-off-by: Prasad Sodagudi <psodagud@codeaurora.org>
2013-09-04 17:24:27 -07:00
Amy Maloche ead1f716df leds: leds-qpnp: Set WLED string current sinks
Set correct current sink when 1, 2 or 3 strings are in use.
Also, when using debug dumps, print all relevant registers.

Change-Id: Ib9ae9a959c3fcee0dcbb7b2882434cc6bcd126a3
Signed-off-by: Amy Maloche <amaloche@codeaurora.org>
2013-09-04 17:20:37 -07:00
Chun Zhang fb3f90874a leds: leds-qpnp: Enable watchdog timer for flash torch mode
Flash LED raises module temperature when turned on. Current
implementation disables timers in torch mode and this creates
potential risk of module damage due to raised temperature.
When flash LED is used as torch, watchdog timer should be enabled
to allow hardware to turn LEDs off according to predefined
duration.

Change-Id: I3768a04abd59c12f6bd1c355a5e194b1fa5b2bc4
Signed-off-by: Chun Zhang <chunz@codeaurora.org>
2013-09-04 17:19:41 -07:00
Chun Zhang c5370444e2 led: leds-qpnp: Enable individual flash LED control
Existing implementation turns on and off both flash LEDs simultaneously
due to earlier hardware bug. With hardware bug removed, enabling flash
LED individual control allows user to turn on or off one flash LED at a
time.

CRs-Fixed: 498526
Change-Id: I95448e1886dc2aba2da7bb4845c1b5993b3fe0da
Signed-off-by: Chun Zhang <chunz@codeaurora.org>
2013-09-04 17:19:05 -07:00
Chun Zhang 37c7cd344e leds: leds-qpnp: Enable flash torch mode on single LED PMIC
Flash LED torch mode is not supported from hardware perspective
on PMIC with single flash LED module. Enabling torch mode on such
PMIC chips requires detection of PMIC peripheral subtype and
use flash mode with a lower current to implement torch.

Change-Id: I77228068c2c0ec4a0ed5614f4a991a3bce5db013
Signed-off-by: Chun Zhang <chunz@codeaurora.org>
2013-09-04 17:19:04 -07:00
Chun Zhang d4b8ec9dfa leds: leds-qpnp: Enable sync boost for flash LED torch mode
Flash LED uses sync boost as power source in torch mode. Enabling
sync boost when flash LED is used as torch light can make flash
LED working when battery is low.

Change-Id: Iab757de65087ee1a4312a5a9ec4d87c8bf3d5555
Signed-off-by: Chun Zhang <chunz@codeaurora.org>
2013-09-04 17:15:32 -07:00
Amy Maloche e6bfbba5b6 leds: leds-qpnp: Correct switch frequency settings
New hardware has different settings than old hardware, which
is no longer supported.  Update settings as needed.

Change-Id: I91ae32ddb112bf64211bb7212b68152349a0457c
Signed-off-by: Amy Maloche <amaloche@codeaurora.org>
2013-09-04 17:14:28 -07:00
Chun Zhang 8eb29e8d44 leds: qpnp-leds: Modularize regulator operation for LED
Previous implementation does not give a concise logic and is
not easy to operate regulators for LED when other LEDs are in
need. By modularizing regulator operation, it is easy to use the
logic when other LEDs need to use regulators.

Change-Id: I633c7e7d5af804c54adea6d8ac8f6567bdee2cc2
Signed-off-by: Chun Zhang <chunz@codeaurora.org>
2013-09-04 17:13:55 -07:00
Mohan Pallaka ef3b3f6c46 leds: leds-qpnp: Add LUT support for KPDBL
Keypad Backlight module supports LUT mode. Add
support for LUT mode and parse the parameters
from DTS file.

Change-Id: Ie293c46b32f1bb9a09ee4ddaae54632249e17256
Signed-off-by: Mohan Pallaka <mpallaka@codeaurora.org>
2013-09-04 17:12:58 -07:00
Chun Zhang ceb1d9e51a leds: leds-qpnp: Support vin control for MPP LEDs
MPP can support input voltages from vin0 to vin3. Parse
this data from Device Tree and program appropriate MPP
registers. Also add support for minimum brightness that
MPP LED can support.

Change-Id: Ieb4f924321f224b1915539befe33abf3b03f6ac3
Signed-off-by: Chun Zhang <chunz@codeaurora.org>
Signed-off-by: Mohan Pallaka <mpallaka@codeaurora.org>
2013-09-04 17:09:27 -07:00
Tingting Yang f6d9606d20 leds: leds-gpio-flash: add led gpio flash driver
the flash led pins flash_en and flash_now are connected with msm gpios.
add led gpio flash driver for qrd board.

Change-Id: I057958f8756c8fc31ba1a5032cf096d7a7e27e17
Signed-off-by: Tingting Yang <tingting@codeaurora.org>
2013-09-04 17:05:34 -07:00
Chun Zhang ec3a0be582 leds: leds-qpnp: Change max current to 200mA for flash LED
Flash LED requires a max current of 200mA when used as torch light.
Existing implementation 1A for torch light and this might cause
issue for flash usage.

Change-Id: I44f1a9e73f27b6613356f82e20cf123f42172f8d
Signed-off-by: Chun Zhang <chunz@codeaurora.org>
2013-09-04 17:04:08 -07:00
Amy Maloche f68cddf9fe leds: leds-qpnp: Enable PWM and LPG configuration from userspace
Allow user to control properties such as pwm period and
duty cycles at runtime through sysfs.

Change-Id: Icec7f3de25d0f4bc89666639402317ef8446e803
Signed-off-by: Amy Maloche <amaloche@codeaurora.org>
2013-09-04 17:04:05 -07:00
Chun Zhang 9035c3fb7b led: leds-qpnp: Add work queue to LED driver
Regulator operation requires non-atomic context and current driver
does not put LED to sleep. This causes APPs crash. By introducing
work queue, the problem is solved.

Change-Id: Ifbd9f37fee893cb48c06e41a82202b93f3313704
Signed-off-by: Chun Zhang <chunz@codeaurora.org>
2013-09-04 17:03:52 -07:00
Chun Zhang 0bd4a8346a leds: leds-qpnp: Correct VREG_OK value for flash LED
Hardware team suggests another value for VREG_OK register because
current value used may potentially cause flash LED issue.

Change-Id: I8ff8aab409adcd1ca3fa306a0381c083c5bd0bf7
Signed-off-by: Chun Zhang <chunz@codeaurora.org>
2013-09-04 17:00:17 -07:00
Prasad Sodagudi b9878fcc82 leds: pm8xxx: Enable PWM LPG banks based on max current
The current design enables PWM LPG high bank with out
checking the max current. So enable PWM LPG low bank when max
current configured as 4mA and enable PWM LPG high bank when
the max current configured as 8mA. Enabled both PWM LPG low bank
and PWM LPG high bank when max current configure as 12mA.

CRs-Fixed: 486318
Change-Id: Ib7177aafc63c4c33b8c144d665a11d5aaf0ef584
Signed-off-by: Prasad Sodagudi <psodagud@codeaurora.org>
2013-09-04 16:55:35 -07:00
Amy Maloche a526529e5d leds: leds-qpnp: Add blink sysfs entry support
Add support for blink entry.  When blink entry is used,
switch to LPG mode if not already in LPG mode, and switch
back when blink is done.

Change-Id: Id32e50f8484628bbf2ecc15e13cafa0dfee84829
Signed-off-by: Amy Maloche <amaloche@codeaurora.org>
2013-09-04 16:53:59 -07:00
Chun Zhang a86949e10c leds: leds-qpnp: Utilize SMBB Boost Regulator for flash LED
Enable SMBB boost regulator when flash LED is turned on in flash
mode and disable it when flash LED is turned off. This avoids
losing USB when flash is turned on.

Change-Id: I31f22dc0f127bd4765466621e3c0882e15838d22
Signed-off-by: Chun Zhang <chunz@codeaurora.org>
2013-09-04 16:50:07 -07:00
Amy Maloche 9a16bcd641 leds: leds-qpnp: Add support for PWM for all LED types
Create a new LED structure specific for PWM and include
it in necessary structures, RGB, MPP and KPDBL.

Change-Id: I28b3722ffb4b0e711a83d08fb62b0247e8e2b959
Signed-off-by: Amy Maloche <amaloche@codeaurora.org>
2013-09-04 16:42:15 -07:00
Amy Maloche 3cba49a2f6 arm/dt: msm8974-leds: Update flash LED default settings
Update default settings for flash LED to optimize for
camera use, and set current flash LEDs to these values.

CRs-fixed: 474728
Change-Id: I9ad142eedf39ee1c3ba774863ad5571924024a33
Signed-off-by: Amy Maloche <amaloche@codeaurora.org>
Signed-off-by: Chun Zhang <chunz@codeaurora.org>
2013-09-04 16:40:31 -07:00
Chun Zhang 61548004e5 leds: leds-qpnp: Change torch trigger API
Change torch trigger API by adding a separate torch node in DT and
by controlling that torch node to turn on and turn off torch led.
This eliminated sysfs entry to turn on torch mode.

Change-Id: Ia443f4bb21262df2c1d394f05bd72db08a079b7e
Signed-off-by: Chun Zhang <chunz@codeaurora.org>
2013-09-04 16:30:46 -07:00
Amy Maloche 4603bc10d5 leds: leds-qpnp: Add masks for mode ctrl and source
Add masks for mode ctrl and source select, so that
settings must be correctly set in device tree.

Change-Id: Ie6a30e2fb52be2124320d11fc6a7d673fefccccb
Signed-off-by: Amy Maloche <amaloche@codeaurora.org>
2013-09-04 16:30:45 -07:00
Amy Maloche 7895523fa4 leds: leds-qpnp: Add missing break in switch statement
MPP Led call is missing a "break" in qpnp_led_set switch
statment.  Add this in so that functions reserved for
differnet LED types are not called.

Change-Id: I7d8e76927db8cc3bc7d0d7c300bdbf886d0c0714
Signed-off-by: Amy Maloche <amaloche@codeaurora.org>
2013-09-04 16:30:42 -07:00
Mohan Pallaka 9c144fc30b leds: leds-qpnp: Add support for kpdbl
Add support for keypad backlight supported by PMIC.
The supporting parameters are parsed from DTS.

CRs-fixed: 446817
Change-Id: Ied5e1d6d333d1b9543cf7e1466c36a98c2bb7d2b
Signed-off-by: Mohan Pallaka <mpallaka@codeaurora.org>
2013-09-04 16:26:46 -07:00
Amy Maloche b1faf96d18 leds: leds-qpnp: Add support for MPP controlled leds
Add appropriate settings to allow software to control
leds via MPP ports.

Change-Id: I923e31756526b6afa91ec41efc64414f63b8b888
Acked-by: Chun Zhang <chunz@qti.qualcomm.com>
Signed-off-by: Amy Maloche <amaloche@codeaurora.org>
2013-09-04 16:23:35 -07:00
Amy Maloche d12c6ad2ab leds: leds-qpnp: Remove improper casting
Led values for PWM mode are integers, not u8.  Read
in from device tree correctly to not lose any values.

CRs-fixed: 474766
Change-Id: Ibc0850375107c00b64e096e34f87713b863a2ca7
Signed-off-by: Amy Maloche <amaloche@codeaurora.org>
2013-09-04 16:21:50 -07:00
Amy Maloche 90b56b30b0 leds: leds-qpnp: add support for torch mode
"Torch mode" is when the flash led is left on for an
undetermined amount of time.  To accomplish this, secure
PMIC registers must be accessed and programmed.  After
utilizing torch mode, the initial duration timeout
must be re-implemented.

CRs-Fixed: 454787
Change-Id: I061540e6f0a0ccd726dea619a81efda949608cb3
Acked-by: Chun Zhang <chunz@qti.qualcomm.com>
Signed-off-by: Amy Maloche <amaloche@codeaurora.org>
2013-09-04 16:15:13 -07:00
Amy Maloche 29f8c28a75 leds: leds-qpnp: correct wled op_fdbck data type
Change op_fdbck attribute in wled from bool to 8-bit int.
LED datasheet shows this variable should be able to select
LED outputs.

CRs-Fixed: 459520
Change-Id: I41c2408ca8c9e04040ac0d45cd6973f1d221264f
Acked-by: Chun Zhang <chunz@qti.qualcomm.com>
Signed-off-by: Amy Maloche <amaloche@codeaurora.org>
2013-09-04 16:15:12 -07:00
Amy Maloche ea9e3df163 leds: leds-qpnp: Enable lut parameters to be set by user
Settings for pause-hi, pause-lo, ramp step and flags were
previously set by default.  For some patterns, they need to
be set to other values, so add them to device settings.  Also
clarify other settings in documentation.

Change-Id: Ica9b254273ce700e27a84442f6682e3190777b5e
Signed-off-by: Amy Maloche <amaloche@codeaurora.org>
2013-09-04 16:12:37 -07:00
Amy Maloche bd9296a551 leds: leds-qpnp: use 12 bit brightness settings
Brightness can be set with up to 12 bits, so use all 12.
Set this change in both driver and display settings.

CRs-fixed: 457937
Change-Id: I669e031afddc828068758752dbaac3576e34b2dd
Signed-off-by: Amy Maloche <amaloche@codeaurora.org>
2013-09-04 16:06:00 -07:00
Amy Maloche 54c21dca03 leds: leds-pm8xxx: enable setting of max current for individual string
Max current for all wleds will still be used to set
general properties, such as max brightness, but for
each string an individual max can be set.

CRs-Fixed: 377988
Change-Id: I73284176b04e016e315d36d680cef02119dec370
Signed-off-by: Amy Maloche <amaloche@codeaurora.org>
2013-09-04 16:03:24 -07:00
Amy Maloche b04222df08 leds: leds-pm8xxx: Add individual WLED string control
Add ability to choose which WLEDs to turn on, instead of
only 1, 2 or 3 starting from the left side.

Change-Id: I1c2ae88e9150801d98f9f85bbc4d2edf693de658
Signed-off-by: Amy Maloche <amaloche@codeaurora.org>
2013-09-04 16:03:23 -07:00
Amy Maloche 96d097913c leds: leds-qpnp: Correct driver bugs
Flash headroom address should be offset 0x4a, not 0x49.
Additionally, WLED_MOD_SRC_SEL_REG must be set.

CRs-fixed: 452968
Change-Id: I102be8d420126fbe7743b41dcbd01d5f3a34ed95
Signed-off-by: Amy Maloche <amaloche@codeaurora.org>
2013-09-04 15:59:59 -07:00
Amy Maloche 2bedb34a68 leds: leds-qpnp: disable flash enable register when not in use
Disable flash enable registers when the flash LED is not in use
in order to save power.

Also, correctly set FLASH_VREG_OK_FORCE register after each LED
flash so that software retains control of power_ok signal.

Change-Id: I9e2001434a540da521432c53f175f9bab2a4687b
Signed-off-by: Amy Maloche <amaloche@codeaurora.org>
2013-09-04 15:59:54 -07:00
Asaf Penso 7789b387bc leds: leds-qpnp: add support for leds delayed turn off
In case a led is turned on by default, add an option to set the amount of
time in milliseconds before turn off.

Change-Id: I983c7c0e8091e57d512a5656152dc14dd86774bb
Signed-off-by: Asaf Penso <apenso@codeaurora.org>
2013-09-04 15:51:30 -07:00
Amy Maloche 669a031189 leds: leds-qpnp: correct current sink mask for multiple wled strings
An improper number of wleds string current sink registers are written
when the number of wled strings > 1.  This must be corrected by shifting
the register bit over.

CRs-fixed: 434911
Change-Id: I3d729fcaa6ed3052d5ff4cc96719714c19f5072f
Signed-off-by: Amy Maloche <amaloche@codeaurora.org>
2013-09-04 15:49:21 -07:00
Amy Maloche 481444189c leds: leds-pm8xxx: add mask for brightness control
With existing mask in use, one bit of another functionality
of the register is at risk of being overwritten.  Add a new
mask to leave bit <4> untouched.

CRs-fixed: 426193
Change-Id: I04a9d3496ef9ac569523f0d48569b0beee1bb509
Signed-off-by: Amy Maloche <amaloche@codeaurora.org>
2013-09-04 15:42:02 -07:00
Amy Maloche 14fefca84a leds: qpnp-leds: correct bugs in driver probe
There are 4 errors during the probe of leds-qpnp:
1) dev_kzalloc should only be called when num_leds > 0
2) led->num_leds is only set for the first child led node
3) return path does not unregister leds in all cases
4) cleanup for more than 1 led in probe fails

These must be corrected.

CRs-fixed: 422575
Change-Id: Ie0c4f3d8ee12dfabe48c1f78162941aedb5dbb52
Signed-off-by: Amy Maloche <amaloche@codeaurora.org>
2013-09-04 15:40:56 -07:00
Mohan Pallaka 83a8993ab2 leds: leds-pm8xxx: Fix incorrect register macros
Some of the register macros are incorrectly used. Fix
them to be used properly.

CRs-fixed: 421968
Change-Id: I036b6cc0146c6a5d6276f7a48e313d3cd948c8ef
Signed-off-by: Mohan Pallaka <mpallaka@codeaurora.org>
2013-09-04 15:37:57 -07:00
Amy Maloche 9ea86e7328 leds: qpnp-leds: Add support for RGB Leds
Add support to driver for RGB (red/green/blue, tri color)
LEDs.  Support with PWM and LPG modes.

Change-Id: I0e48d4008bf9b1ddeb415e1edd5ea084c321ec36
Signed-off-by: Amy Maloche <amaloche@codeaurora.org>
2013-09-04 15:34:39 -07:00
Amy Maloche a28be5181e leds: leds-qpnp: Add support for flash leds
Read in flash LED info from device tree, initialize then
enable leds when triggered at specified current.

Change-Id: I123af80ea7e6a077a7e291c096a347a7ed9e7569
Signed-off-by: Amy Maloche <amaloche@codeaurora.org>
2013-09-04 15:32:03 -07:00
Amy Maloche b10a1fbac1 leds: leds-qpnp: enable parsing of multiple leds at same address
This requires modifying current dt files for devices compatible
with leds-qpnp to use child nodes for each led.  This is desirable
to support different types of LEDs in the future.

Change-Id: I839cb1e4b7ee4118ffcb69f1c46eadefe682338d
Signed-off-by: Amy Maloche <amaloche@codeaurora.org>
2013-09-04 15:31:38 -07:00
Amy Maloche 16816f442c leds: qpnp-leds: use spinlock instead of mutex
Triggers are called with spinlock and therefore we cannot
use mutex when setting led brightness levels.

Change-Id: I2078108286d40c2892681367988e984216acd4de
Signed-off-by: Amy Maloche <amaloche@codeaurora.org>
2013-09-04 15:23:11 -07:00
Amy Maloche 2087a1e3d4 leds: leds-pm8xxx: Add CABC support for backlight control
Content adaptive backlight control (CABC) support is needed to
control backlight by external PWM.  It can be enabled by setting
"cabc_en = true" in the platform data wled_cfg structure.

CRs-fixed: 379347
Change-Id: If30defd3a3ca61283233c97ab26f255a3a62ad7c
Signed-off-by: Amy Maloche <amaloche@codeaurora.org>
2013-09-04 15:14:14 -07:00
Amy Maloche bbc5db9066 leds: leds-qpnp: Add QPNP PMIC led driver
QPNP (Qualcomm Plug N Play) LEDs driver is used for
controlling LEDs that are part of PMIC on Qualcomm reference
platforms. The PMIC is connected to Host processor via
SPMI bus. This driver supports various LED modules such as
WLED (white LED), RGB LED and flash LED. The first version of
the driver supports WLED and other features are added in the
next versions.

Change-Id: Ib2962c784cf566905f909faa0d46f8ebfee77b2d
Signed-off-by: Amy Maloche <amaloche@codeaurora.org>
2013-09-04 15:12:28 -07:00
Amy Maloche f8f44b9238 drivers: leds-pm8xxx: enable low power mode for RGB LED
Disable RGB module when the LED is turned off and enable the
module when the LED is on.

CRs-fixed: 381623
Change-Id: I0861c6a38fff19c9499d169deaa02d05696bd148
Signed-off-by: Amy Maloche <amaloche@codeaurora.org>
2013-09-04 15:03:33 -07:00
Mohan Pallaka 35c29e2138 leds: msm-tricolor: Add support for tricolor leds
Add support for tricolor leds on Qualcomm's MSM
boards.

Change-Id: Ib05d6129f98cf67e7d208465a13cc6b1300c6277
Signed-off-by: Mohan Pallaka <mpallaka@codeaurora.org>
2013-09-04 15:02:14 -07:00
Mohan Pallaka e82b06e986 leds: led-class: Remove deprecated functions
Replace deprecated function sprintf with its safer
counter part, snprintf.

Change-Id: Iffdbe2647d9b4ca228d8ad66ed85c159aaa027c6
Signed-off-by: Mohan Pallaka <mpallaka@codeaurora.org>
2013-09-04 14:48:23 -07:00
Praveen Chidambaram 079c910536 leds: Add support to limit max_brightness of LCD
Make /sys/class/leds/lcd-brightness/max_brightness writable. This
will help limiting the max brightness and control the heat generated
by the LCD.

Change-Id: Ieb297f72f5fc26c19ca09c542e3a4140d01865d4
Signed-off-by: Praveen Chidambaram <pchidamb@codeaurora.org>
2013-09-04 14:48:23 -07:00
Benson Leung 453816ad19 add backlight driver in st1.5
BUG=NONE
TEST=Built and ran on st1.5
Signed-off-by: Horace Fu <horace.fu@quantatw.com>

CRs-Fixed: 245334
Change-Id: Ifc589ff9f9e41c9a7b5672001637f849eb0fde3c
Signed-off-by: Karthik Parsha <kparsha@codeaurora.org>
2013-09-04 14:48:22 -07:00
Trilok Soni bee06f8516 leds: pmic8058: Add PMIC leds driver
Add PMIC8058 based keyboard backlight and low current leds driver.

keyboard backlight led supports upto 16 levels of backlight intensity,
which is mapped to 0..255 levels of brightness of led subsystem.

Three low current(40mA) led drivers of PMIC are also supported
in this driver.

CRs-Fixed: 211772
Change-Id: Ia65b083f6070666aaad95851c9b843332ce35c82
Signed-off-by: Trilok Soni <tsoni@qualcomm.com>
2013-09-04 14:48:21 -07:00
Mohan Pallaka 8fb0d4dd79 leds: leds-pmic-mpp: Add support for MPP connected LED
Add support for LEDs which are connected to PMIC MPPs.

Change-Id: Ib53510dbcb745e92e2100c1afc6dc2d94938fc85
CRs-fixed: 354967
Signed-off-by: Mohan Pallaka <mpallaka@codeaurora.org>
2013-09-04 14:48:20 -07:00
Trilok Soni c8b587ac84 led: pm8xxx: Add pm8xxx leds driver
Add support for Qualcomm PMIC8XXX keyboard
backlight, flash and low current leds.

Change-Id: I460480e0c7f98da4cb27c76ca7ac65807df74a7f
Signed-off-by: Trilok Soni <tsoni@codeaurora.org>
Signed-off-by: Anirudh Ghayal <aghayal@codeaurora.org>
2013-09-04 14:48:19 -07:00
Stepan Moskovchenko 3209569cc1 led: Bring in PMIC LED driver
Signed-off-by: Stepan Moskovchenko <stepanm@quicinc.com>
2013-09-04 14:48:17 -07:00
Mohan Pallaka ea655b09cc leds: Add pdm based gpio led driver
Configure leds through Pulse Density Modulation
registers in MSM core.

Change-Id: Ia9fae2b8d7fea2b91004f33e5790aa725df7d88f
Signed-off-by: Mohan Pallaka <mpallaka@codeaurora.org>
2013-09-04 14:48:16 -07:00
Thomas Tsai 1e4cdf5f40 leds: Add CPLD driver for LEDS
Signed-off-by: San Mehat <san@android.com>

leds: leds-cpld: Remove unused brightness setting

Signed-off-by: San Mehat <san@android.com>

leds: cpld: Make state change debugging conditional

Signed-off-by: Dima Zavin <dima@android.com>
2013-09-04 14:48:16 -07:00
Christian Gmeiner 4b949b8af1 drivers/leds/leds-ot200.c: fix error caused by shifted mask
During the development of this driver an in-house register documentation
was used.  The last week some integration tests were done and this
problem was found.  It turned out that the released register
documentation is wrong.

The fix is very simple: shift all masks by one.

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Cc: Bryan Wu <cooloney@gmail.com>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-05-24 16:22:51 -07:00
Timo Teräs 803d19d57a leds: leds-gpio: reserve gpio before using it
This reverts commit a99d76f (leds: leds-gpio: use gpio_request_one)
and commit 2d7c22f (leds: leds-gpio: set devm_gpio_request_one()
flags param correctly) which was a fix of the first one.

The conversion to devm_gpio_request in commit e3b1d44c (leds:
leds-gpio: use devm_gpio_request_one) is not reverted.

The problem is that gpio_cansleep() and gpio_get_value_cansleep()
calls can crash if the gpio is not first reserved. Incidentally this
same bug existed earlier and was fixed similarly in commit d95cbe61
(leds: Fix potential leds-gpio oops). But the OOPS is real. It happens
when GPIOs are provided by module which is not yet loaded.

So this fixes the following BUG during my ALIX boot (3.9.2-vanilla):

BUG: unable to handle kernel NULL pointer dereference at 0000004c
IP: [<c11287d6>] __gpio_cansleep+0xe/0x1a
*pde = 00000000
Oops: 0000 [#1] SMP
Modules linked in: leds_gpio(+) via_rhine mii cs5535_mfd mfd_core
geode_rng rng_core geode_aes isofs nls_utf8 nls_cp437 vfat fat
ata_generic pata_amd pata_cs5536 pata_acpi libata ehci_pci ehci_hcd
ohci_hcd usb_storage usbcore usb_common sd_mod scsi_mod squashfs loop
Pid: 881, comm: modprobe Not tainted 3.9.2 #1-Alpine
EIP: 0060:[<c11287d6>] EFLAGS: 00010282 CPU: 0
EIP is at __gpio_cansleep+0xe/0x1a
EAX: 00000000 EBX: cf364018 ECX: c132b8b9 EDX: 00000000
ESI: c13993a4 EDI: c1399370 EBP: cded9dbc ESP: cded9dbc
 DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0068
CR0: 8005003b CR2: 0000004c CR3: 0f0c4000 CR4: 00000090
DR0: 00000000 DR1: 00000000 DR2: 00000000 DR3: 00000000
DR6: ffff0ff0 DR7: 00000400
Process modprobe (pid: 881, ti=cded8000 task=cf094aa0 task.ti=cded8000)
Stack:
 cded9de0 d09471cb 00000000 c1399260 cf364014 00000000 c1399260 c1399254
 d0949014 cded9df4 c118cd59 c1399260 d0949014 d0949014 cded9e08 c118ba47
 c1399260 d0949014 c1399294 cded9e1c c118bb75 cded9e24 d0949014 00000000
Call Trace:
 [<d09471cb>] gpio_led_probe+0xba/0x203 [leds_gpio]
 [<c118cd59>] platform_drv_probe+0x26/0x48
 [<c118ba47>] driver_probe_device+0x75/0x15c
 [<c118bb75>] __driver_attach+0x47/0x63
 [<c118a727>] bus_for_each_dev+0x3c/0x66
 [<c118b6f9>] driver_attach+0x14/0x16
 [<c118bb2e>] ? driver_probe_device+0x15c/0x15c
 [<c118b3d5>] bus_add_driver+0xbd/0x1bc
 [<d08b4000>] ? 0xd08b3fff
 [<d08b4000>] ? 0xd08b3fff
 [<c118bffc>] driver_register+0x74/0xec
 [<d08b4000>] ? 0xd08b3fff
 [<c118c8e8>] platform_driver_register+0x38/0x3a
 [<d08b400d>] gpio_led_driver_init+0xd/0x1000 [leds_gpio]
 [<c100116c>] do_one_initcall+0x6b/0x10f
 [<d08b4000>] ? 0xd08b3fff
 [<c105e918>] load_module+0x1631/0x1907
 [<c10975d6>] ? insert_vmalloc_vmlist+0x14/0x43
 [<c1098d5b>] ? __vmalloc_node_range+0x13e/0x15f
 [<c105ec50>] sys_init_module+0x62/0x77
 [<c1257888>] syscall_call+0x7/0xb
EIP: [<c11287d6>] __gpio_cansleep+0xe/0x1a SS:ESP 0068:cded9dbc
CR2: 000000000000004c
 ---[ end trace 5308fb20d2514822 ]---

Signed-off-by: Timo Teräs <timo.teras@iki.f>
Cc: Sachin Kamat <sachin.kamat@linaro.org>
Cc: Raphael Assenat <raph@8d.com>
Cc: Trent Piepho <tpiepho@freescale.com>
Cc: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
Cc: Arnaud Patard <arnaud.patard@rtp-net.org>
Cc: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
Acked-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-05-21 11:26:53 -07:00
Linus Torvalds 5647ac0ad4 Removal of GENERIC_GPIO for v3.10
GENERIC_GPIO now synonymous with GPIOLIB. There are no longer any valid
 cases for enableing GENERIC_GPIO without GPIOLIB, even though it is
 possible to do so which has been causing confusion and breakage. This
 branch does the work to completely eliminate GENERIC_GPIO.
 
 However, it is not trivial to just create a branch to remove it. Over
 the course of the v3.9 cycle more code referencing GENERIC_GPIO has been
 added to linux-next that conflicts with this branch. The following must
 be done to resolve the conflicts when merging this branch into mainline:
 
 * "git grep CONFIG_GENERIC_GPIO" should return 0 hits. Matches should be
   replaced with CONFIG_GPIOLIB
 * "git grep '\bGENERIC_GPIO\b'" should return 1 hit in the Chinese
   documentation.
 * Selectors of GENERIC_GPIO should be turned into selectors of GPIOLIB
 * definitions of the option in architecture Kconfig code should be deleted.
 
 Stephen has 3 merge fixup patches[1] that do the above. They are currently
 applicable on mainline as of May 2nd.
 
 [1] http://www.mail-archive.com/linux-kernel@vger.kernel.org/msg428056.html
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.12 (GNU/Linux)
 
 iQIcBAABAgAGBQJRifUnAAoJEEFnBt12D9kBs2YP/0U6+ia+xYvkVaJc28PDVIzn
 OReZNcJOYU8D5voxz0voaRD0EdcPwjbMu9Kp9aXMHlk4VxevF+8jCc/us0bIjtO1
 VcB5VmSCIhMhxdnBlum11Mk7Vr5MCweyl9NBsypnPt8cl4obMBZHf2yzoodFktNb
 wtyYlOb6FALtc6iDbOO6dG3w9F7FAOLvskUFzdv89m8mupTsBu9jw9NqFDbJHOex
 rxq0Sdd+kWF/nkJVcV5Y6jIdletRlhpipefMJ9diexreHvwqh+c4kJEYZaXgB5+m
 ha95cPbReK1d+RqzM3A8d4irzSVSmq4k7ijI6QkFOr48+AH7XsgKv5so885LKzMN
 IIXg2Phm9i0H8+ecEvhcc4oIYBHJiEKK54Y0qUD9dqbFoDGPTCSqMHdSSMbpAY+J
 bIIXlVzj1En3PPNUJLPt8q8Qz6WxCT9mDST3QSGYnD4o90HT+1R9j92RxGL6McOq
 rUOyJDwmzFvpBvKK4raGdOU435M+ps2NPKKNIRaIGQPPY9rM1kN4YqvhXukEsC9L
 3a3+3cQLh7iKxBHncxeQsJfethP1CPkJnzvF9r+ZZLf2rcPH4pbQIE2uO0XnX/nd
 5/DKi0nGgAJ//GMMzdo3RiOA5zGFjIZ/KMvfhQldpP6qFJRhqdGi6FPlAcwr1z1n
 YnCByPwwlvfC4LTXFOGL
 =xodc
 -----END PGP SIGNATURE-----

Merge tag 'gpio-for-linus' of git://git.secretlab.ca/git/linux

Pull removal of GENERIC_GPIO from Grant Likely:
 "GENERIC_GPIO now synonymous with GPIOLIB.  There are no longer any
  valid cases for enableing GENERIC_GPIO without GPIOLIB, even though it
  is possible to do so which has been causing confusion and breakage.
  This branch does the work to completely eliminate GENERIC_GPIO."

* tag 'gpio-for-linus' of git://git.secretlab.ca/git/linux:
  gpio: update gpio Chinese documentation
  Remove GENERIC_GPIO config option
  Convert selectors of GENERIC_GPIO to GPIOLIB
  blackfin: force use of gpiolib
  m68k: coldfire: use gpiolib
  mips: pnx833x: remove requirement for GENERIC_GPIO
  openrisc: default GENERIC_GPIO to false
  avr32: default GENERIC_GPIO to false
  xtensa: remove explicit selection of GENERIC_GPIO
  sh: replace CONFIG_GENERIC_GPIO by CONFIG_GPIOLIB
  powerpc: remove redundant GENERIC_GPIO selection
  unicore32: default GENERIC_GPIO to false
  unicore32: remove unneeded select GENERIC_GPIO
  arm: plat-orion: use GPIO driver on CONFIG_GPIOLIB
  arm: remove redundant GENERIC_GPIO selection
  mips: alchemy: require gpiolib
  mips: txx9: change GENERIC_GPIO to GPIOLIB
  mips: loongson: use GPIO driver on CONFIG_GPIOLIB
  mips: remove redundant GENERIC_GPIO select
2013-05-09 09:59:16 -07:00
Alexandre Courbot 76ec9d18b8 Convert selectors of GENERIC_GPIO to GPIOLIB
GENERIC_GPIO is now equivalent to GPIOLIB and features that depended on
GENERIC_GPIO can now depend on GPIOLIB to allow removal of this option.

Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Grant Likely <grant.likely@secretlab.ca>
2013-04-16 18:47:14 +09:00
Jingoo Han df92d5ff5e leds: leds-asic3: switch to using SIMPLE_DEV_PM_OPS
Switch to using SIMPLE_DEV_PM_OPS  macro to declare the driver's
pm_ops. It reduces code size. Also, CONFIG_PM_SLEEP is added to
suspend/ resume functions to prevent build warnings when
CONFIG_PM_SLEEP is not selected.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-04-01 11:04:54 -07:00
Jingoo Han cceba0e4b8 leds: leds-bd2802: add CONFIG_PM_SLEEP to suspend/resume functions
Add CONFIG_PM_SLEEP to suspend/resume functions to fix the following
build warning when CONFIG_PM_SLEEP is not selected. This is because
sleep PM callbacks defined by SIMPLE_DEV_PM_OPS are only used when
the CONFIG_PM_SLEEP is enabled.

drivers/leds/leds-bd2802.c:766:12: warning: 'bd2802_suspend' defined but not used [-Wunused-function]
drivers/leds/leds-bd2802.c:776:12: warning: 'bd2802_resume' defined but not used [-Wunused-function]

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-04-01 11:04:53 -07:00
Kim, Milo 81f2a5b4a0 leds: lp55xx: configure the clock detection
Now LP55xx provides automatic clock detection API, lp55xx_is_extclk_used().
The clock configuration can be done by the driver itself.

(a) Concept
The default value is set by each driver with clock selection.
The internal clock selection bit is updated in case that the external clock
is not detected or clock rate is not 32KHz.

(b) Change on LP55xx platform data
The clock configuration is done automatically, so no need to define
'update_config' in the platform side.
Correlated information are removed in the documentations and header.

(c) Definitions moved from header to driver files
CONFIG register values are moved each driver, LP5521 and LP5562.
Not necessary definitions are removed also.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-04-01 11:04:53 -07:00
Kim, Milo 53b4192266 leds: lp55xx: use common clock framework when external clock is used
Program execution is timed with 32768Hz clock in the LP55xx family devices.
To run LED functionalities, LP55xx devices provide two options.
One is using internal clock. The other is using external clock.
This patch enables external clock detection automatically.
If external clock is not detected, then the internal clock will be used in the
LP55xx driver.

Valid clock rate is 32768Hz in LP55xx devices.

This new API is used in each LP55xx driver like LP5521 and LP5562.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-04-01 11:04:53 -07:00
Simon Guinot 3de1929ba6 leds: leds-ns2: fix oops at module removal
This patch fixes a regression introduced by commit 72052fcc10
("leds: leds-ns2: add device tree binding").

When the driver is initialized with device tree data, platform_data
pointer is NULL. This causes a kernel oops at removal.

To fix this bug, num_leds is moved into driver_data and platform_data
is not longer used from ns2_led_remove().

Signed-off-by: Simon Guinot <simon.guinot@sequanux.org>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-04-01 11:04:52 -07:00
Florian Vaussard c971ff185f leds: leds-pwm: Defer led_pwm_set() if PWM can sleep
Call to led_pwm_set() can happen inside atomic context, like triggers.
If the PWM call can sleep, defer using a worker.

Signed-off-by: Florian Vaussard <florian.vaussard@epfl.ch>
Reviewed-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Acked-by: Thierry Reding <thierry.reding@avionic-design.de>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-04-01 11:04:50 -07:00
Kim, Milo 24d3212847 leds: lp55xx: fix the sysfs read operation
According to a sysfs documentation(Documentation/filesystem/sysfs.txt),
scnprintf() should be used in a read operation method.
It guarantees safe buffer size(PAGE_SIZE) which is allocated by the sysfs.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-04-01 11:04:50 -07:00
Kim, Milo 313bf0b1a0 leds: lm355x, lm3642: support camera LED triggers for flash and torch
LM355x and LM3642 support flash and torch functionality.

 (Camera driver)          (LED trigger for camera)       (LED driver)
 Turn on the flash  ...>  ledtrig_flash_ctrl(true) ...>  LM355x or LM3642
                                                         brightness ctrl
                                                       <actual driving here>

Flash/torch LEDs are controlled by other driver using LED camera trigger
APIs, ledtrig_flash_ctrl()/ledtrig_torch_ctrl().
Then, actual device control is activated by each LED driver such like
LM355x or LM3642.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-04-01 11:04:50 -07:00
Kim, Milo 48a1d032c9 leds: add camera LED triggers
Some LED devices support flash/torch functionality through the LED subsystem.
This patch enables direct LED trigger controls by the driver.
Flash on/off and torch on/off can be done simply by other driver space.
Two trigger APIs are added, ledtrig_flash_ctrl() and ledtrig_torch_ctrl().

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-04-01 11:04:50 -07:00
Sachin Kamat fbd9df28fa leds: tca6507: Use of_match_ptr() macro
This eliminates having an #ifdef returning NULL for the case
when OF is disabled.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-04-01 11:04:50 -07:00
Mark Brown d67eb8e66c leds: wm8350: Complain if we fail to reenable DCDC
Provide some trace, though the hardware is most likely non-functional if
this happens.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-04-01 11:04:49 -07:00
Jingoo Han 901b74a3c4 leds: renesas: set gpio_request_one() flags param correctly
The gpio_request_one() flags parameter was set to:

  GPIOF_DIR_OUT | !!brightness

GPIOF_DIR_OUT and GPIOF_DIR_IN are defined as below:
  GPIOF_DIR_OUT   (0 << 0)
  GPIOF_DIR_IN    (1 << 0)

So, when '!!brightness' is 1, the gpio pin can be set as input,
instead of output.

To prevent this problem, GPIOF_OUT_INIT flags should be used when
using gpio_request_one().

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-04-01 11:04:49 -07:00
Jingoo Han 9d04cbaadf leds: leds-ns2: set devm_gpio_request_one() flags param correctly
The devm_gpio_request_one() flags parameter was set to:

  GPIOF_DIR_OUT | gpio_get_value(template->cmd)

GPIOF_DIR_OUT and GPIOF_DIR_IN are defined as below:

  GPIOF_DIR_OUT   (0 << 0)
  GPIOF_DIR_IN    (1 << 0)

So, when 'gpio_get_value(template->cmd)' is 1, the gpio pin can
be set as input, instead of output.

To prevent this problem, GPIOF_OUT_INIT flags should be used when
using devm_gpio_request_one().

Same goes for 'gpio_get_value(template->slow)' case.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-04-01 11:04:49 -07:00
Jingoo Han 84f6942cde leds: leds-lt3593: set devm_gpio_request_one() flags param correctly
The devm_gpio_request_one() flags parameter was set to:

  GPIOF_DIR_OUT | state

GPIOF_DIR_OUT and GPIOF_DIR_IN are defined as below:

  GPIOF_DIR_OUT   (0 << 0)
  GPIOF_DIR_IN    (1 << 0)

So, when 'state' is 1, the gpio pin can be set as input, instead
of output.

To prevent this problem, GPIOF_OUT_INIT flags should be used when
using devm_gpio_request_one().

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-04-01 11:04:49 -07:00
Jingoo Han e9dd68cf14 leds: leds-bd2802: remove erroneous __exit annotation
CONFIG_HOTPLUG was removed, so __devexit or __exit of remove()
should not be used.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-04-01 11:04:49 -07:00
Jingoo Han 6fd7962791 leds: atmel-pwm: remove erroneous __exit annotation
CONFIG_HOTPLUG was removed, so __devexit or __exit of remove()
should not be used.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-04-01 11:04:48 -07:00
Kim, Milo f07fb52107 leds: move LED trigger drivers into new subdirectory
For better driver management, new subdirectory, 'trigger' is created.
All LED trigger drivers are moved into this directory.

Internal header, 'leds.h' is included in each LED trigger drivers.
Fix the location of header file, "leds.h" -> "../leds.h" in driver files.
One exception is here, 'ledtrig-timer.c'.
There is no need to include 'leds.h'. so '#include "leds.h"' line was removed.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-04-01 11:04:48 -07:00
Kim, Milo ff45262a85 leds: add new LP5562 LED driver
LP5562 can drive up to 4 channels, RGB and White.
LEDs can be controlled directly via the led class control interface.

 LP55xx common driver
  LP5562 is one of LP55xx family device, so LP55xx common code are used.
  On the other hand, chip specific configuration is defined in the structure
  'lp55xx_device_config'

 LED pattern data
  LP5562 has also internal program memory which is used for running various LED
  patterns. LP5562 driver supports the firmware interface and the predefined
  pattern data as well.

 LP5562 device attributes: 'led_pattern' and 'engine_mux'
  A 'led_pattern' is an index code which runs the predefined pattern data.
  And 'engine_mux' is updated with the firmware interface is activated.
  Detailed description has been updated in the documentation files,
  'leds-lp55xx.txt' and 'leds-lp5562.txt'.

 Changes on the header file
  LP5562 configurable definitions are added.
  Pattern RGB data is fixed as constant value.
  (No side effect on other devices, LP5521 or LP5523.)

(cooloney@gmail.com: remove redundant mutex_unlock(). Reported by Dan
Carpenter <dan.carpenter@oracle.com>)

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-04-01 11:04:48 -07:00
Linus Torvalds 0512c04a2b Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/cooloney/linux-leds
Pull LED subsystem update from Bryan Wu.

* 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/cooloney/linux-leds: (61 commits)
  leds: leds-sunfire: use dev_err()/pr_err() instead of printk()
  leds: 88pm860x: Add missing of_node_put()
  leds: tca6507: Use of_get_child_count()
  leds: leds-pwm: make it depend on PWM and not HAVE_PWM
  Documentation: leds: update LP55xx family devices
  leds-lp55xx: fix problem on removing LED attributes
  leds-lp5521/5523: add author and copyright description
  leds-lp5521/5523: use new lp55xx common header
  leds-lp55xx: clean up headers
  leds-lp55xx: clean up definitions
  leds-lp55xx: clean up unused data and functions
  leds-lp55xx: clean up _remove()
  leds-lp55xx: add new function for removing device attribtues
  leds-lp55xx: code refactoring on selftest function
  leds-lp55xx: use common device attribute driver function
  leds-lp55xx: support device specific attributes
  leds-lp5523: use generic firmware interface
  leds-lp5521: use generic firmware interface
  leds-lp55xx: support firmware interface
  leds-lp55xx: add new lp55xx_register_sysfs() for the firmware interface
  ...
2013-02-26 09:29:02 -08:00
Jingoo Han 4b07c5d512 leds: leds-sunfire: use dev_err()/pr_err() instead of printk()
Fixed the checkpatch errors and warnings as below:

  ERROR: spaces required around that '=' (ctx:VxW)
  WARNING: Prefer netdev_err(netdev, ... then dev_err(dev, ... then pr_err(...  to printk(KERN_ERR ...

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-02-06 16:00:43 -08:00
Axel Lin 61d4eb2724 leds: 88pm860x: Add missing of_node_put()
of_find_node_by_name() returns a node pointer with refcount incremented, use
of_node_put() on it when done.

of_find_node_by_name() will call of_node_put() against from parameter,
thus we also need to call of_node_get(from) before calling
of_find_node_by_name().

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-02-06 16:00:43 -08:00
Axel Lin ef754e88e3 leds: tca6507: Use of_get_child_count()
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-02-06 16:00:42 -08:00
Peter Ujfalusi ad0ba85fab leds: leds-pwm: make it depend on PWM and not HAVE_PWM
The correct dependency for the leds-pwm is PWM and not HAVE_PWM
since PWM drivers now have their own subsystem.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-02-06 16:00:42 -08:00
Milo(Woogyom) Kim 109b833071 leds-lp55xx: fix problem on removing LED attributes
LP55XX common device attributes, 'led_current' and 'max_current' are created
 while loading the driver.
 Those are LED device attributes which are removed automatically on releasing
 led class devices - led_classdev_unregister().
 Therefore, this duplicate code should be removed.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-02-06 15:59:30 -08:00
Milo(Woogyom) Kim a2387cb9f6 leds-lp5521/5523: add author and copyright description
Now LP5521 and LP5523 drivers are based on new lp55xx structure.
 So the author and copyrights are updated.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-02-06 15:59:30 -08:00
Milo(Woogyom) Kim 79bcc10b8c leds-lp55xx: clean up headers
Remove unused headers and sort them alphabetically

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-02-06 15:59:30 -08:00
Milo(Woogyom) Kim 12f022d27b leds-lp55xx: clean up definitions
Remove unused definitions and change hex values to capital letters

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-02-06 15:59:30 -08:00
Milo(Woogyom) Kim 93ca4093ad leds-lp55xx: clean up unused data and functions
Old data structures and I2C function are not used any more.
 Each driver uses the lp55xx common data and functions.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-02-06 15:59:30 -08:00
Milo(Woogyom) Kim 87cc4bde2a leds-lp55xx: clean up _remove()
Replace lp5521/5523_unregister_sysfs() with lp55xx_unregister_sysfs().

 On unloading the driver, running engines should be stopped.
 Use explicit driver function, lp5521/5523_stop_engine().

 Unused functions are removed.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-02-06 15:59:29 -08:00
Milo(Woogyom) Kim ba6fa84651 leds-lp55xx: add new function for removing device attribtues
lp55xx_unregister_sysfs() is used for removing lp55xx device attributes.
 Chip specific and engine attributes are removed on unloading the driver.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-02-06 15:59:29 -08:00
Milo(Woogyom) Kim 9ca3bd8022 leds-lp55xx: code refactoring on selftest function
LP5521 and LP5523 have a selftest function which is run via the sysfs.
 Use lp55xx driver data and R/W functions rather than lp5521/5523 private data
 and functions.
 Additionally, if-statements are changed for code simplicity.
 Unused functions, lp5521/5523_read() are removed.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-02-06 15:59:29 -08:00
Milo(Woogyom) Kim e73c0ce6be leds-lp55xx: use common device attribute driver function
lp5521/5523_register_sysfs() are replaced with lp55xx common driver function,
 lp55xx_register_sysfs().
 Chip specific device attributes are configurable using 'dev_attr_group'.

 Error condition name is changed:
 use specific error condition, 'err_register_sysfs' rather than unclear name,
 'fail2'.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-02-06 15:59:29 -08:00
Milo(Woogyom) Kim 240085e255 leds-lp55xx: support device specific attributes
To support device specific attributes, new common driver function is added.
 Eventually those are created on registering the sysfs with common dev attrs.
 Furthermore, this patch makes adding device attributes simple in each driver.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-02-06 15:59:29 -08:00
Milo(Woogyom) Kim db6eaf8388 leds-lp5523: use generic firmware interface
LP55xx common driver provides generic firmware interface
 for running a LED pattern.
 LP5521 and LP5523 have many device attributes for running patterns.
 This patch cleans up those complex code.

 Removed device attributes:
 engine1_mode
 engine2_mode
 engine3_mode
 engine1_load
 engine2_load
 engine3_load
 engine1_leds
 engine2_leds
 engine3_leds

 All device attributes and functions are replaced with two callback functions,
 'firmware_cb' and 'run_engine'.

 New engine functions:
 lp5523_load/stop/run_engine(), lp5523_update_program_memory() and
 lp5523_wait_opmode_done()

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-02-06 15:59:29 -08:00
Milo(Woogyom) Kim 9ce7cb170f leds-lp5521: use generic firmware interface
LP55xx common driver provides generic firmware interface
 for running a LED pattern.
 LP5521 and LP5523 have many device attributes for running patterns.
 This patch cleans up those complex code.

 Removed device attributes:
 engine1_mode
 engine2_mode
 engine3_mode
 engine1_load
 engine2_load
 engine3_load
 led_pattern

 All device attributes and functions are replaced with two callback functions,
 'firmware_cb' and 'run_engine'.

 New engine functions:
 lp5521_load/stop/run_engine(), lp5521_update_program_memory() and
 lp5521_wait_opmode_done()

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-02-06 15:59:29 -08:00
Milo(Woogyom) Kim 10c06d178d leds-lp55xx: support firmware interface
This patch provides additional device attributes which enable
 loading the firmware. ('select_engine' and 'run_engine')
 To run a LED pattern, two parts of driver should be enabled.

 Common features : lp55xx-common
 ===============================
 Firmware interface for loading LED patterns

 Chip specific features : leds-lp5521, leds-lp5523
 =================================================
 Register addresses for loading firmware data
 Register addresses for running selected engine

 Pattern programming sequence
 ============================
 LP55xx chips have three program engines.
 To load and run a LED pattern, the programming sequence is as follows.
 (1) Select an engine number (1/2/3)
 (2) Set engine mode to load
 (3) Write pattern data into selected area
 (4) Set engine mode to run

 This sequence is almost same as the firmware interface.
 (1) Select an engine number               : 'select_engine' dev attribute
 (2) Mode change to load                   : 'loading' of firmware class
 (3) Write pattern data into selected area : 'data' of firmware class
 (4) Mode change to run                    : 'run_engine' dev attribute

 (1) and (4) are device specific features which provide callback functions
 (2) and (3) are common features.

 For example,
 echo 1 or 2 or 3 > /sys/bus/i2c/devices/xxxx/select_engine
 echo 1 > /sys/class/firmware/lp5521/loading
 echo "4000600040FF6000" > /sys/class/firmware/lp5521/data
 echo 0 > /sys/class/firmware/lp5521/loading
 echo 1 > /sys/bus/i2c/devices/xxxx/run_engine

 As soon as 'loading' is set to 0, registered callback is called.
 Inside the callback, the selected engine is loaded and memory is updated.
 To run programmed pattern, 'run_engine' attribute should be enabled.

 Device specific data structure
 ==============================
 o Firmware callback
   load selected engine and update program memory
 o Run engine
   change the engine mode
 o 'engine_idx' and firmware data, 'fw'
   Those are used in the driver internally with callback functions

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-02-06 15:59:28 -08:00
Milo(Woogyom) Kim b3b6f8119d leds-lp55xx: add new lp55xx_register_sysfs() for the firmware interface
LP55xx family chips have internal program memory which run various patterns.
 Using this memory, LEDs continue on blinking/dimming without continuous I2C
 commands. That means the I2C HOST can be entered into sleep once the memory
 is updated.

 An application can get hex data from a file and write them into
 the program memory through the I2C. This is general firwmare interface.

 This patch is the initial step for adding the firmware interface.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-02-06 15:59:28 -08:00
Milo(Woogyom) Kim d9067d2846 leds-lp55xx: fix error condition in lp55xx_register_leds()
Use lp55xx_unregister_leds() rather than duplicate code.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-02-06 15:59:28 -08:00
Milo(Woogyom) Kim c3a68ebfcd leds-lp55xx: use lp55xx_unregister_leds()
To unregister led class devices and sysfs attributes,
 LP5521 and LP5523 have each driver function.
 This patch makes both drivers simple using common driver function,
 lp55xx_unregister_leds().

 And some unused variables are removed.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-02-06 15:59:28 -08:00
Milo(Woogyom) Kim a96bfa135d leds-lp55xx: provide common LED current setting
LED current is configurable via the sysfs.
 Max current is a read-only attribute.
 These attributes code can be shared in lp55xx common driver.

 Device attributes: 'led_current' and 'max_current'
 move to lp55xx common driver

 Replaced functions:
 show_max_current()  => lp55xx_show_max_current()
 show_current()      => lp55xx_show_current()
 store_current()     => lp55xx_store_current()

 LED setting function: set_led_current()
 Current registers are device specific, so configurable function is added
 in each driver.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-02-06 15:59:28 -08:00
Milo(Woogyom) Kim a6e4679a09 leds-lp55xx: use lp55xx_set_brightness()
lp5521_set_brightness() and lp5523_set_brightness() are replaced with
 common function, lp55xx_set_brightness().
 This function is invoked when the brightness of each LED channel is updated.
 LP5521 and LP5523 have different register address for the brightness control,
 so this work is done by chip specific brightness_work_fn().

 lp5521/5523_led_brightness_work():
 use lp55xx_led and lp55xx_chip data structure.
 use lp55xx write function.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-02-06 15:59:28 -08:00
Milo(Woogyom) Kim 0e2023463a leds-lp55xx: use lp55xx_init_led() common function
lp5521_init_led() and lp5523_init_led() are replaced with one common function,
 lp55xx_init_led().
 Max channels is configurable, so it's used in lp55xx_init_led().

 'LP5523_LEDS' are changed to 'LP5523_MAX_LEDS'.

 lp55xx_set_brightness, lp55xx_led_attributes: skeleton
 Will be filled in next patches.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-02-06 15:59:28 -08:00
Milo(Woogyom) Kim 9e9b3db1b2 leds-lp55xx: use lp55xx common led registration function
LED class devices are registered in lp5521_register_leds() and
 lp5523_register_leds().
 Two separate functions are merged into consolidated lp55xx function,
 lp55xx_register_leds().

 Error handling fix:
 Unregistering LEDS are handled in lp55xx_register_leds() when LED registration
 failure occurs. So each driver error handler is changed to 'err_register_leds'

 Chip dependency: 'brightness_work_fn' and 'set_led_current'
 To make the structure abstract, both functions are configured in each driver.
 Those functions should be done by each driver because register control is
 chip-dependant work.

 lp55xx_init_led: skeleton
 Will be filled in next patch

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-02-06 15:59:28 -08:00
Milo(Woogyom) Kim 6ce6176263 leds-lp55xx: use lp55xx common deinit function
Two separate de-init functions are merged into one common function.
 And it is used in err_post_init of lp55xx_init_device().

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-02-06 15:59:27 -08:00
Milo(Woogyom) Kim 22ebeb488b leds-lp55xx: clean up init function
lp5521/5523_init_device() are replaced with lp55xx common function,
 lp55xx_init_device().

 Error handler in init_device:
 deinit function are matched with 'err_post_init' section in
 lp55xx_init_device().

 Remove LP5523 engine intialization code:
 Engine functionality is not mandatory but optional.
 Moreover engine initialization is done internally with device reset command.
 Therefore, this code is unnecessary.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-02-06 15:59:27 -08:00
Milo(Woogyom) Kim ffbdccdbba leds-lp55xx: use lp55xx common init function - post int
LP5521/5523 chip configuration is replaced with lp55xx common function,
 lp55xx_post_init_device().

 Name change:
 lp5521/5523_configure() to lp5521/5523_post_init_device()
 These are called in init function.

 Register access function
 Argument type is changed from 'i2c_client' to 'lp55xx_chip'.
 Use exported R/W functions of lp55xx common driver.

 Temporary variables in lp5521/5523_init_device()
 These functions will be removed but temporary variables are needed for
 blocking build warnings - incompatible pointer.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-02-06 15:59:27 -08:00
Milo(Woogyom) Kim e3a700d8aa leds-lp55xx: use lp55xx common init function - detect
LP5521/5523 chip detection functions are replaced with lp55xx common function,
 lp55xx_detect_device().
 Chip dependent address and values are configurable in each driver.
 In init function, chip detection is executed.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-02-06 15:59:27 -08:00
Milo(Woogyom) Kim 48068d5de1 leds-lp55xx: use lp55xx common init function - reset
LP5521/5523 reset device functions are moved to lp55xx common driver.
 Value of register address and value are chip dependent.
 Those are configured in each driver.
 In init function, reset command is executed.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-02-06 15:59:27 -08:00
Milo(Woogyom) Kim a85908dd77 leds-lp55xx: use lp55xx common init function - platform data
LP5521/5523 platform data functions are moved to lp55xx common driver.
 New init function, lp55xx_init_device() is created.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-02-06 15:59:27 -08:00
Milo(Woogyom) Kim 632418bf65 leds-lp5523: clean up lp5523_configure()
This patch is a preceding step for making common lp55xx init function.

 Return code:
 Do not use 'OR' arithmetic for the result.
 If some error occurs, just return it.

 Remove engine verification code:
 To check whether internal engine works or not, many lines of code are executed.
 However, this job is unnecessary during the chip initialization because
 the engine usage is not mandatory but optional function.
 LED engines are enabled when specific LED pattern is loaded.
 Therefore, this verification code is removed.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-02-06 15:59:27 -08:00
Milo(Woogyom) Kim 9448217403 leds-lp5521: clean up lp5521_configure()
This patch is a preceding step for making common lp55xx init function.

 LP5521_REG_R_CURRENT register code moved:
 Chip specific code moved from lp5521_init_device() to lp5521_configure().

 Remove engine init function:
 LP5521 has internal program engines which are used for running LED patterns.
 (blinking, ramp up/down and other emotional visual effects)
 Engine initialization is done by reset command in lp5521_init_device().
 Remove this duplicate code.

 Return code:
 Do not use 'OR' arithmetic for the result.
 If some error occus, just return it.

 Enable latency:
 Use explicit named function, lp5521_wait_enable_done().
 According to the datasheet, 500us is guaranteed time.
 Thus wait time is changed from 1000us to 500us.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-02-06 15:59:26 -08:00
Milo(Woogyom) Kim 6a0c9a4796 leds-lp55xx: use common lp55xx data structure in _probe()
LP5521 and LP5523 data structures have common features.
 Use common lp55xx data structures rather than chip specific data.
 Legacy code in probe is replaced with this new data structures.

 lp55xx_chip          : Common data between lp5521_chip and lp5523_chip
 lp55xx_led           : Common LED structure between lp5521_led and lp5523_led
 lp55xx_platform_data : Common platform data between lp5521_platform_data and
                        lp5523_platform_data

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-02-06 15:59:26 -08:00
Milo(Woogyom) Kim 945c700746 leds-lp55xx: replace name of data structure
Change the name of chip data structure and platform data.
 This patch is a preceding step for cleaning up lp5521/5523 probe and remove.
 These data will be replaced with new lp55xx common data structures
 in next patch.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-02-06 15:59:26 -08:00
Milo(Woogyom) Kim c93d08fa75 leds-lp55xx: add new common driver for lp5521/5523
This patch supports basic common driver code for LP5521, LP5523/55231 devices.

 ( Driver Structure Data )

 lp55xx_led and lp55xx_chip
 In lp55xx common driver, two different data structure is used.
 o lp55xx_led
   control multi output LED channels such as led current, channel index.
 o lp55xx_chip
   general chip control such like the I2C and platform data.

 For example, LP5521 has maximum 3 LED channels.
 LP5523/55231 has 9 output channels.

 lp55xx_chip for LP5521 ... lp55xx_led #1
                            lp55xx_led #2
                            lp55xx_led #3

 lp55xx_chip for LP5523 ... lp55xx_led #1
                            lp55xx_led #2
                            .
                            .
                            lp55xx_led #9

 ( Platform Data )

 LP5521 and LP5523/55231 have own specific platform data.
 However, this data can be handled with just one platform data structure.
 The lp55xx platform data is declared in the header.
 This structure is derived from leds-lp5521.h and leds-lp5523.h

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-02-06 15:59:26 -08:00
Milo(Woogyom) Kim f6c64c6fc8 leds-lp55xx: do chip specific configuration on device init
Chip specific function is configured when the device is initialized.
 So _configure() is moved to each device init function.

 If chip configuration gets failed, the device is de-initialized in
 each _init_device(), not probe().

 For compile error fix, function type declarations are added.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-02-06 15:59:26 -08:00
Milo(Woogyom) Kim 86eb7748ce leds-lp55xx: add device reset function in lp5521/5523
Use explicit each driver function rather than raw command.
 These function will be merged into the lp55xx common driver.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-02-06 15:59:26 -08:00
Milo(Woogyom) Kim 1904f83d56 leds-lp55xx: clean up deinit leds in lp5521/5523
To make LED unregistration code simple, new function, _unregister_leds()
 is added in each driver.
 This patch is a preceding step for lp55xx common driver architecture.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-02-06 15:59:26 -08:00
Milo(Woogyom) Kim f652480802 leds-lp55xx: clean up init leds in lp5521/5523
To make LED initialization code simple, new function, _register_leds()
 is added at each driver.
 This patch is a preceding step for lp55xx common driver architecture.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-02-06 15:59:26 -08:00
Milo(Woogyom) Kim 1a9914855d leds-lp55xx: clean up deinit_device() in lp5521/5523
Device de-initialization code is moved to _deinit_device() at each driver.
 This patch is a preceding step for lp55xx common driver architecture.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-02-06 15:59:26 -08:00
Milo(Woogyom) Kim 944f7b1ded leds-lp55xx: clean up init_device() in lp5521/5523
To make _probe() simple, device initialization code is moved to
 _init_device() at each driver.
 This patch is a preceding step for lp55xx common driver architecture.

 leds-lp5521:
 When 'lp5521_init_device()' gets failed, error handling should be 'fail1'
 rather than 'fail2'.
   fail1: releasing platform resource and return code
   fail2: releasing allocated LED devices with handling 'fail1'
 The 'lp5521_init_device()' is called before creating LED devices.
 Thus, 'goto fail1' is proper error handler of this function.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-02-06 15:59:25 -08:00
Jingoo Han 8a4529a38d leds: wm831x: add missing const
Fixed the checkpatch warning as below:

  WARNING: static const char * array should probably be static const char * const

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-02-01 17:47:06 -08:00
Jingoo Han d7789430de leds: leds-ss4200: use DEFINE_PCI_DEVICE_TABLE
This macro is used to create a struct pci_device_id array.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-02-01 17:47:06 -08:00
Jingoo Han 962363ceda leds: pca9532: fix suspect code indent for conditional statements
Fixed the checkpatch warning as below:

  WARNING: suspect code indent for conditional statements (8, 8)

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-02-01 17:47:06 -08:00
Jingoo Han 85b4b756f1 leds: lm3642: rename devAttr to avoid CamelCase
Fixed the checkpatch warning as below:

  WARNING: Avoid CamelCase: <devAttr>

Rename devAttr to attr.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-02-01 17:47:06 -08:00