Skip to content

Commit 21c91bb

Browse files
committed
Merge tag 'backlight-next-6.8' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight
Pull backlight updates from Lee Jones: "New Drivers: - Add support for Monolithic Power Systems MP3309C WLED Step-up Converter Fix-ups: - Use/convert to new/better APIs/helpers/MACROs instead of hand-rolling implementations - Device Tree Binding updates - Demote non-kerneldoc header comments - Improve error handling; return proper error values, simplify, avoid duplicates, etc - Convert over to the new (kinda) GPIOD API Bug Fixes: - Fix uninitialised local variable" * tag 'backlight-next-6.8' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight: backlight: hx8357: Convert to agnostic GPIO API backlight: ili922x: Add an error code check in ili922x_write() backlight: ili922x: Drop kernel-doc for local macros backlight: mp3309c: Fix uninitialized local variable backlight: pwm_bl: Use dev_err_probe backlight: mp3309c: Add support for MPS MP3309C dt-bindings: backlight: mp3309c: Remove two required properties
2 parents 17e232b + 7d84a63 commit 21c91bb

File tree

9 files changed

+515
-78
lines changed

9 files changed

+515
-78
lines changed

Documentation/devicetree/bindings/leds/backlight/mps,mp3309c.yaml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ description: |
1414
programmable switching frequency to optimize efficiency.
1515
It supports two different dimming modes:
1616
17-
- analog mode, via I2C commands (default)
18-
- PWM controlled mode.
17+
- analog mode, via I2C commands, as default mode (32 dimming levels)
18+
- PWM controlled mode (optional)
1919
2020
The datasheet is available at:
2121
https://www.monolithicpower.com/en/mp3309c.html
@@ -50,8 +50,6 @@ properties:
5050
required:
5151
- compatible
5252
- reg
53-
- max-brightness
54-
- default-brightness
5553

5654
unevaluatedProperties: false
5755

@@ -66,8 +64,8 @@ examples:
6664
compatible = "mps,mp3309c";
6765
reg = <0x17>;
6866
pwms = <&pwm1 0 3333333 0>; /* 300 Hz --> (1/f) * 1*10^9 */
69-
max-brightness = <100>;
70-
default-brightness = <80>;
67+
brightness-levels = <0 4 8 16 32 64 128 255>;
68+
default-brightness = <6>;
7169
mps,overvoltage-protection-microvolt = <24000000>;
7270
};
7371
};

MAINTAINERS

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14804,6 +14804,13 @@ S: Maintained
1480414804
F: Documentation/driver-api/tty/moxa-smartio.rst
1480514805
F: drivers/tty/mxser.*
1480614806

14807+
MP3309C BACKLIGHT DRIVER
14808+
M: Flavio Suligoi <[email protected]>
14809+
14810+
S: Maintained
14811+
F: Documentation/devicetree/bindings/leds/backlight/mps,mp3309c.yaml
14812+
F: drivers/video/backlight/mp3309c.c
14813+
1480714814
MR800 AVERMEDIA USB FM RADIO DRIVER
1480814815
M: Alexey Klimov <[email protected]>
1480914816

drivers/gpio/gpiolib-of.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ static void of_gpio_try_fixup_polarity(const struct device_node *np,
184184
const char *propname;
185185
bool active_high;
186186
} gpios[] = {
187-
#if !IS_ENABLED(CONFIG_LCD_HX8357)
187+
#if IS_ENABLED(CONFIG_LCD_HX8357)
188188
/*
189189
* Himax LCD controllers used incorrectly named
190190
* "gpios-reset" property and also specified wrong
@@ -478,7 +478,7 @@ static struct gpio_desc *of_find_gpio_rename(struct device_node *np,
478478
*/
479479
const char *compatible;
480480
} gpios[] = {
481-
#if !IS_ENABLED(CONFIG_LCD_HX8357)
481+
#if IS_ENABLED(CONFIG_LCD_HX8357)
482482
/* Himax LCD controllers used "gpios-reset" */
483483
{ "reset", "gpios-reset", "himax,hx8357" },
484484
{ "reset", "gpios-reset", "himax,hx8369" },

drivers/video/backlight/Kconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,17 @@ config BACKLIGHT_LP8788
395395
help
396396
This supports TI LP8788 backlight driver.
397397

398+
config BACKLIGHT_MP3309C
399+
tristate "Backlight Driver for MPS MP3309C"
400+
depends on I2C && PWM
401+
select REGMAP_I2C
402+
help
403+
This supports MPS MP3309C backlight WLED driver in both PWM and
404+
analog/I2C dimming modes.
405+
406+
To compile this driver as a module, choose M here: the module will
407+
be called mp3309c.
408+
398409
config BACKLIGHT_PANDORA
399410
tristate "Backlight driver for Pandora console"
400411
depends on TWL4030_CORE

drivers/video/backlight/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ obj-$(CONFIG_BACKLIGHT_LP855X) += lp855x_bl.o
4343
obj-$(CONFIG_BACKLIGHT_LP8788) += lp8788_bl.o
4444
obj-$(CONFIG_BACKLIGHT_LV5207LP) += lv5207lp.o
4545
obj-$(CONFIG_BACKLIGHT_MAX8925) += max8925_bl.o
46+
obj-$(CONFIG_BACKLIGHT_MP3309C) += mp3309c.o
4647
obj-$(CONFIG_BACKLIGHT_MT6370) += mt6370-backlight.o
4748
obj-$(CONFIG_BACKLIGHT_OMAP1) += omap1_bl.o
4849
obj-$(CONFIG_BACKLIGHT_PANDORA) += pandora_bl.o

drivers/video/backlight/hx8357.c

Lines changed: 22 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
*/
77

88
#include <linux/delay.h>
9+
#include <linux/gpio/consumer.h>
910
#include <linux/lcd.h>
1011
#include <linux/module.h>
1112
#include <linux/of.h>
1213
#include <linux/of_device.h>
13-
#include <linux/of_gpio.h>
1414
#include <linux/spi/spi.h>
1515

1616
#define HX8357_NUM_IM_PINS 3
@@ -83,11 +83,10 @@
8383
#define HX8369_SET_GAMMA_CURVE_RELATED 0xe0
8484

8585
struct hx8357_data {
86-
unsigned im_pins[HX8357_NUM_IM_PINS];
87-
unsigned reset;
86+
struct gpio_descs *im_pins;
87+
struct gpio_desc *reset;
8888
struct spi_device *spi;
8989
int state;
90-
bool use_im_pins;
9190
};
9291

9392
static u8 hx8357_seq_power[] = {
@@ -321,11 +320,11 @@ static void hx8357_lcd_reset(struct lcd_device *lcdev)
321320
struct hx8357_data *lcd = lcd_get_data(lcdev);
322321

323322
/* Reset the screen */
324-
gpio_set_value(lcd->reset, 1);
323+
gpiod_set_value(lcd->reset, 0);
325324
usleep_range(10000, 12000);
326-
gpio_set_value(lcd->reset, 0);
325+
gpiod_set_value(lcd->reset, 1);
327326
usleep_range(10000, 12000);
328-
gpio_set_value(lcd->reset, 1);
327+
gpiod_set_value(lcd->reset, 0);
329328

330329
/* The controller needs 120ms to recover from reset */
331330
msleep(120);
@@ -340,10 +339,10 @@ static int hx8357_lcd_init(struct lcd_device *lcdev)
340339
* Set the interface selection pins to SPI mode, with three
341340
* wires
342341
*/
343-
if (lcd->use_im_pins) {
344-
gpio_set_value_cansleep(lcd->im_pins[0], 1);
345-
gpio_set_value_cansleep(lcd->im_pins[1], 0);
346-
gpio_set_value_cansleep(lcd->im_pins[2], 1);
342+
if (lcd->im_pins) {
343+
gpiod_set_value_cansleep(lcd->im_pins->desc[0], 1);
344+
gpiod_set_value_cansleep(lcd->im_pins->desc[1], 0);
345+
gpiod_set_value_cansleep(lcd->im_pins->desc[2], 1);
347346
}
348347

349348
ret = hx8357_spi_write_array(lcdev, hx8357_seq_power,
@@ -580,6 +579,7 @@ MODULE_DEVICE_TABLE(of, hx8357_dt_ids);
580579

581580
static int hx8357_probe(struct spi_device *spi)
582581
{
582+
struct device *dev = &spi->dev;
583583
struct lcd_device *lcdev;
584584
struct hx8357_data *lcd;
585585
const struct of_device_id *match;
@@ -601,49 +601,19 @@ static int hx8357_probe(struct spi_device *spi)
601601
if (!match || !match->data)
602602
return -EINVAL;
603603

604-
lcd->reset = of_get_named_gpio(spi->dev.of_node, "gpios-reset", 0);
605-
if (!gpio_is_valid(lcd->reset)) {
606-
dev_err(&spi->dev, "Missing dt property: gpios-reset\n");
607-
return -EINVAL;
608-
}
604+
lcd->reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW);
605+
if (IS_ERR(lcd->reset))
606+
return dev_err_probe(dev, PTR_ERR(lcd->reset), "failed to request reset GPIO\n");
607+
gpiod_set_consumer_name(lcd->reset, "hx8357-reset");
609608

610-
ret = devm_gpio_request_one(&spi->dev, lcd->reset,
611-
GPIOF_OUT_INIT_HIGH,
612-
"hx8357-reset");
613-
if (ret) {
614-
dev_err(&spi->dev,
615-
"failed to request gpio %d: %d\n",
616-
lcd->reset, ret);
617-
return -EINVAL;
618-
}
609+
lcd->im_pins = devm_gpiod_get_array_optional(dev, "im", GPIOD_OUT_LOW);
610+
if (IS_ERR(lcd->im_pins))
611+
return dev_err_probe(dev, PTR_ERR(lcd->im_pins), "failed to request im GPIOs\n");
612+
if (lcd->im_pins->ndescs < HX8357_NUM_IM_PINS)
613+
return dev_err_probe(dev, -EINVAL, "not enough im GPIOs\n");
619614

620-
if (of_property_present(spi->dev.of_node, "im-gpios")) {
621-
lcd->use_im_pins = 1;
622-
623-
for (i = 0; i < HX8357_NUM_IM_PINS; i++) {
624-
lcd->im_pins[i] = of_get_named_gpio(spi->dev.of_node,
625-
"im-gpios", i);
626-
if (lcd->im_pins[i] == -EPROBE_DEFER) {
627-
dev_info(&spi->dev, "GPIO requested is not here yet, deferring the probe\n");
628-
return -EPROBE_DEFER;
629-
}
630-
if (!gpio_is_valid(lcd->im_pins[i])) {
631-
dev_err(&spi->dev, "Missing dt property: im-gpios\n");
632-
return -EINVAL;
633-
}
634-
635-
ret = devm_gpio_request_one(&spi->dev, lcd->im_pins[i],
636-
GPIOF_OUT_INIT_LOW,
637-
"im_pins");
638-
if (ret) {
639-
dev_err(&spi->dev, "failed to request gpio %d: %d\n",
640-
lcd->im_pins[i], ret);
641-
return -EINVAL;
642-
}
643-
}
644-
} else {
645-
lcd->use_im_pins = 0;
646-
}
615+
for (i = 0; i < HX8357_NUM_IM_PINS; i++)
616+
gpiod_set_consumer_name(lcd->im_pins->desc[i], "im_pins");
647617

648618
lcdev = devm_lcd_device_register(&spi->dev, "mxsfb", &spi->dev, lcd,
649619
&hx8357_ops);

drivers/video/backlight/ili922x.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
#define START_RW_WRITE 0
8282
#define START_RW_READ 1
8383

84-
/**
84+
/*
8585
* START_BYTE(id, rs, rw)
8686
*
8787
* Set the start byte according to the required operation.
@@ -100,7 +100,7 @@
100100
#define START_BYTE(id, rs, rw) \
101101
(0x70 | (((id) & 0x01) << 2) | (((rs) & 0x01) << 1) | ((rw) & 0x01))
102102

103-
/**
103+
/*
104104
* CHECK_FREQ_REG(spi_device s, spi_transfer x) - Check the frequency
105105
* for the SPI transfer. According to the datasheet, the controller
106106
* accept higher frequency for the GRAM transfer, but it requires
@@ -269,6 +269,10 @@ static int ili922x_write(struct spi_device *spi, u8 reg, u16 value)
269269
spi_message_add_tail(&xfer_regindex, &msg);
270270

271271
ret = spi_sync(spi, &msg);
272+
if (ret < 0) {
273+
dev_err(&spi->dev, "Error sending SPI message 0x%x", ret);
274+
return ret;
275+
}
272276

273277
spi_message_init(&msg);
274278
tbuf[0] = set_tx_byte(START_BYTE(ili922x_id, START_RS_REG,

0 commit comments

Comments
 (0)