Skip to content

Commit 38984d7

Browse files
committed
Merge tag 'backlight-next-6.7' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight
Pull backlight updates from Lee Jones: "New Functionality: - Add new Device Tree binding for Monolithic Power (MPS) MP3309C step-up converter - Document brightness-levels in bindings for; generic, LED and PWM Bug Fixes: - Ensure PWMs are disabled on .shutdown(), .suspend() and .remove()" * tag 'backlight-next-6.7' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight: dt-bindings: backlight: Add brightness-levels related common properties backlight: pwm_bl: Disable PWM on shutdown, suspend and remove dt-bindings: backlight: Add MPS MP3309C
2 parents 27bc078 + d5272d3 commit 38984d7

File tree

5 files changed

+120
-31
lines changed

5 files changed

+120
-31
lines changed

Documentation/devicetree/bindings/leds/backlight/common.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,21 @@ properties:
3333
due to restrictions in a specific system, such as mounting conditions.
3434
$ref: /schemas/types.yaml#/definitions/uint32
3535

36+
brightness-levels:
37+
description:
38+
Array of distinct brightness levels. The levels must be in the range
39+
accepted by the underlying LED device. Typically these are in the range
40+
from 0 to 255, but any range starting at 0 will do, as long as they are
41+
accepted by the LED.
42+
The 0 value means a 0% of brightness (darkest/off), while the last value
43+
in the array represents a full 100% brightness (brightest).
44+
If this array is not provided, the driver default mapping is used.
45+
$ref: /schemas/types.yaml#/definitions/uint32-array
46+
47+
default-brightness-level:
48+
description:
49+
The default brightness level (index into the array defined by the
50+
"brightness-levels" property).
51+
$ref: /schemas/types.yaml#/definitions/uint32
52+
3653
additionalProperties: true

Documentation/devicetree/bindings/leds/backlight/led-backlight.yaml

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ description:
1616
can also be used to describe a backlight device controlled by the output of
1717
a LED driver.
1818

19+
allOf:
20+
- $ref: common.yaml#
21+
1922
properties:
2023
compatible:
2124
const: led-backlight
@@ -26,25 +29,11 @@ properties:
2629
items:
2730
maxItems: 1
2831

29-
brightness-levels:
30-
description:
31-
Array of distinct brightness levels. The levels must be in the range
32-
accepted by the underlying LED devices. This is used to translate a
33-
backlight brightness level into a LED brightness level. If it is not
34-
provided, the identity mapping is used.
35-
$ref: /schemas/types.yaml#/definitions/uint32-array
36-
37-
default-brightness-level:
38-
description:
39-
The default brightness level (index into the array defined by the
40-
"brightness-levels" property).
41-
$ref: /schemas/types.yaml#/definitions/uint32
42-
4332
required:
4433
- compatible
4534
- leds
4635

47-
additionalProperties: false
36+
unevaluatedProperties: false
4837

4938
examples:
5039
- |
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/leds/backlight/mps,mp3309c.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: MPS MP3309C backlight
8+
9+
maintainers:
10+
- Flavio Suligoi <f.suligoi@asem.it>
11+
12+
description: |
13+
The Monolithic Power (MPS) MP3309C is a WLED step-up converter, featuring a
14+
programmable switching frequency to optimize efficiency.
15+
It supports two different dimming modes:
16+
17+
- analog mode, via I2C commands (default)
18+
- PWM controlled mode.
19+
20+
The datasheet is available at:
21+
https://www.monolithicpower.com/en/mp3309c.html
22+
23+
allOf:
24+
- $ref: common.yaml#
25+
26+
properties:
27+
compatible:
28+
const: mps,mp3309c
29+
30+
reg:
31+
maxItems: 1
32+
33+
pwms:
34+
description: if present, the backlight is controlled in PWM mode.
35+
maxItems: 1
36+
37+
enable-gpios:
38+
description: GPIO used to enable the backlight in "analog-i2c" dimming mode.
39+
maxItems: 1
40+
41+
mps,overvoltage-protection-microvolt:
42+
description: Overvoltage protection (13.5V, 24V or 35.5V).
43+
enum: [ 13500000, 24000000, 35500000 ]
44+
default: 35500000
45+
46+
mps,no-sync-mode:
47+
description: disable synchronous rectification mode
48+
type: boolean
49+
50+
required:
51+
- compatible
52+
- reg
53+
- max-brightness
54+
- default-brightness
55+
56+
unevaluatedProperties: false
57+
58+
examples:
59+
- |
60+
i2c {
61+
#address-cells = <1>;
62+
#size-cells = <0>;
63+
64+
/* Backlight with PWM control */
65+
backlight_pwm: backlight@17 {
66+
compatible = "mps,mp3309c";
67+
reg = <0x17>;
68+
pwms = <&pwm1 0 3333333 0>; /* 300 Hz --> (1/f) * 1*10^9 */
69+
max-brightness = <100>;
70+
default-brightness = <80>;
71+
mps,overvoltage-protection-microvolt = <24000000>;
72+
};
73+
};

Documentation/devicetree/bindings/leds/backlight/pwm-backlight.yaml

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ maintainers:
1111
- Daniel Thompson <daniel.thompson@linaro.org>
1212
- Jingoo Han <jingoohan1@gmail.com>
1313

14+
allOf:
15+
- $ref: common.yaml#
16+
1417
properties:
1518
compatible:
1619
const: pwm-backlight
@@ -39,21 +42,6 @@ properties:
3942
Delay in ms between disabling the backlight using GPIO and setting PWM
4043
value to 0.
4144

42-
brightness-levels:
43-
description:
44-
Array of distinct brightness levels. Typically these are in the range
45-
from 0 to 255, but any range starting at 0 will do. The actual brightness
46-
level (PWM duty cycle) will be interpolated from these values. 0 means a
47-
0% duty cycle (darkest/off), while the last value in the array represents
48-
a 100% duty cycle (brightest).
49-
$ref: /schemas/types.yaml#/definitions/uint32-array
50-
51-
default-brightness-level:
52-
description:
53-
The default brightness level (index into the array defined by the
54-
"brightness-levels" property).
55-
$ref: /schemas/types.yaml#/definitions/uint32
56-
5745
num-interpolated-steps:
5846
description:
5947
Number of interpolated steps between each value of brightness-levels
@@ -69,7 +57,7 @@ required:
6957
- compatible
7058
- pwms
7159

72-
additionalProperties: false
60+
unevaluatedProperties: false
7361

7462
examples:
7563
- |

drivers/video/backlight/pwm_bl.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,9 +626,14 @@ static void pwm_backlight_remove(struct platform_device *pdev)
626626
{
627627
struct backlight_device *bl = platform_get_drvdata(pdev);
628628
struct pwm_bl_data *pb = bl_get_data(bl);
629+
struct pwm_state state;
629630

630631
backlight_device_unregister(bl);
631632
pwm_backlight_power_off(pb);
633+
pwm_get_state(pb->pwm, &state);
634+
state.duty_cycle = 0;
635+
state.enabled = false;
636+
pwm_apply_state(pb->pwm, &state);
632637

633638
if (pb->exit)
634639
pb->exit(&pdev->dev);
@@ -638,21 +643,38 @@ static void pwm_backlight_shutdown(struct platform_device *pdev)
638643
{
639644
struct backlight_device *bl = platform_get_drvdata(pdev);
640645
struct pwm_bl_data *pb = bl_get_data(bl);
646+
struct pwm_state state;
641647

642648
pwm_backlight_power_off(pb);
649+
pwm_get_state(pb->pwm, &state);
650+
state.duty_cycle = 0;
651+
state.enabled = false;
652+
pwm_apply_state(pb->pwm, &state);
643653
}
644654

645655
#ifdef CONFIG_PM_SLEEP
646656
static int pwm_backlight_suspend(struct device *dev)
647657
{
648658
struct backlight_device *bl = dev_get_drvdata(dev);
649659
struct pwm_bl_data *pb = bl_get_data(bl);
660+
struct pwm_state state;
650661

651662
if (pb->notify)
652663
pb->notify(pb->dev, 0);
653664

654665
pwm_backlight_power_off(pb);
655666

667+
/*
668+
* Note that disabling the PWM doesn't guarantee that the output stays
669+
* at its inactive state. However without the PWM disabled, the PWM
670+
* driver refuses to suspend. So disable here even though this might
671+
* enable the backlight on poorly designed boards.
672+
*/
673+
pwm_get_state(pb->pwm, &state);
674+
state.duty_cycle = 0;
675+
state.enabled = false;
676+
pwm_apply_state(pb->pwm, &state);
677+
656678
if (pb->notify_after)
657679
pb->notify_after(pb->dev, 0);
658680

0 commit comments

Comments
 (0)