Commit 21c91bb9 authored by Linus Torvalds's avatar Linus Torvalds

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
parents 17e232b6 7d84a63a
...@@ -14,8 +14,8 @@ description: | ...@@ -14,8 +14,8 @@ description: |
programmable switching frequency to optimize efficiency. programmable switching frequency to optimize efficiency.
It supports two different dimming modes: It supports two different dimming modes:
- analog mode, via I2C commands (default) - analog mode, via I2C commands, as default mode (32 dimming levels)
- PWM controlled mode. - PWM controlled mode (optional)
The datasheet is available at: The datasheet is available at:
https://www.monolithicpower.com/en/mp3309c.html https://www.monolithicpower.com/en/mp3309c.html
...@@ -50,8 +50,6 @@ properties: ...@@ -50,8 +50,6 @@ properties:
required: required:
- compatible - compatible
- reg - reg
- max-brightness
- default-brightness
unevaluatedProperties: false unevaluatedProperties: false
...@@ -66,8 +64,8 @@ examples: ...@@ -66,8 +64,8 @@ examples:
compatible = "mps,mp3309c"; compatible = "mps,mp3309c";
reg = <0x17>; reg = <0x17>;
pwms = <&pwm1 0 3333333 0>; /* 300 Hz --> (1/f) * 1*10^9 */ pwms = <&pwm1 0 3333333 0>; /* 300 Hz --> (1/f) * 1*10^9 */
max-brightness = <100>; brightness-levels = <0 4 8 16 32 64 128 255>;
default-brightness = <80>; default-brightness = <6>;
mps,overvoltage-protection-microvolt = <24000000>; mps,overvoltage-protection-microvolt = <24000000>;
}; };
}; };
...@@ -14804,6 +14804,13 @@ S: Maintained ...@@ -14804,6 +14804,13 @@ S: Maintained
F: Documentation/driver-api/tty/moxa-smartio.rst F: Documentation/driver-api/tty/moxa-smartio.rst
F: drivers/tty/mxser.* F: drivers/tty/mxser.*
MP3309C BACKLIGHT DRIVER
M: Flavio Suligoi <f.suligoi@asem.it>
L: dri-devel@lists.freedesktop.org
S: Maintained
F: Documentation/devicetree/bindings/leds/backlight/mps,mp3309c.yaml
F: drivers/video/backlight/mp3309c.c
MR800 AVERMEDIA USB FM RADIO DRIVER MR800 AVERMEDIA USB FM RADIO DRIVER
M: Alexey Klimov <klimov.linux@gmail.com> M: Alexey Klimov <klimov.linux@gmail.com>
L: linux-media@vger.kernel.org L: linux-media@vger.kernel.org
......
...@@ -184,7 +184,7 @@ static void of_gpio_try_fixup_polarity(const struct device_node *np, ...@@ -184,7 +184,7 @@ static void of_gpio_try_fixup_polarity(const struct device_node *np,
const char *propname; const char *propname;
bool active_high; bool active_high;
} gpios[] = { } gpios[] = {
#if !IS_ENABLED(CONFIG_LCD_HX8357) #if IS_ENABLED(CONFIG_LCD_HX8357)
/* /*
* Himax LCD controllers used incorrectly named * Himax LCD controllers used incorrectly named
* "gpios-reset" property and also specified wrong * "gpios-reset" property and also specified wrong
...@@ -478,7 +478,7 @@ static struct gpio_desc *of_find_gpio_rename(struct device_node *np, ...@@ -478,7 +478,7 @@ static struct gpio_desc *of_find_gpio_rename(struct device_node *np,
*/ */
const char *compatible; const char *compatible;
} gpios[] = { } gpios[] = {
#if !IS_ENABLED(CONFIG_LCD_HX8357) #if IS_ENABLED(CONFIG_LCD_HX8357)
/* Himax LCD controllers used "gpios-reset" */ /* Himax LCD controllers used "gpios-reset" */
{ "reset", "gpios-reset", "himax,hx8357" }, { "reset", "gpios-reset", "himax,hx8357" },
{ "reset", "gpios-reset", "himax,hx8369" }, { "reset", "gpios-reset", "himax,hx8369" },
......
...@@ -395,6 +395,17 @@ config BACKLIGHT_LP8788 ...@@ -395,6 +395,17 @@ config BACKLIGHT_LP8788
help help
This supports TI LP8788 backlight driver. This supports TI LP8788 backlight driver.
config BACKLIGHT_MP3309C
tristate "Backlight Driver for MPS MP3309C"
depends on I2C && PWM
select REGMAP_I2C
help
This supports MPS MP3309C backlight WLED driver in both PWM and
analog/I2C dimming modes.
To compile this driver as a module, choose M here: the module will
be called mp3309c.
config BACKLIGHT_PANDORA config BACKLIGHT_PANDORA
tristate "Backlight driver for Pandora console" tristate "Backlight driver for Pandora console"
depends on TWL4030_CORE depends on TWL4030_CORE
......
...@@ -43,6 +43,7 @@ obj-$(CONFIG_BACKLIGHT_LP855X) += lp855x_bl.o ...@@ -43,6 +43,7 @@ obj-$(CONFIG_BACKLIGHT_LP855X) += lp855x_bl.o
obj-$(CONFIG_BACKLIGHT_LP8788) += lp8788_bl.o obj-$(CONFIG_BACKLIGHT_LP8788) += lp8788_bl.o
obj-$(CONFIG_BACKLIGHT_LV5207LP) += lv5207lp.o obj-$(CONFIG_BACKLIGHT_LV5207LP) += lv5207lp.o
obj-$(CONFIG_BACKLIGHT_MAX8925) += max8925_bl.o obj-$(CONFIG_BACKLIGHT_MAX8925) += max8925_bl.o
obj-$(CONFIG_BACKLIGHT_MP3309C) += mp3309c.o
obj-$(CONFIG_BACKLIGHT_MT6370) += mt6370-backlight.o obj-$(CONFIG_BACKLIGHT_MT6370) += mt6370-backlight.o
obj-$(CONFIG_BACKLIGHT_OMAP1) += omap1_bl.o obj-$(CONFIG_BACKLIGHT_OMAP1) += omap1_bl.o
obj-$(CONFIG_BACKLIGHT_PANDORA) += pandora_bl.o obj-$(CONFIG_BACKLIGHT_PANDORA) += pandora_bl.o
......
...@@ -6,11 +6,11 @@ ...@@ -6,11 +6,11 @@
*/ */
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/gpio/consumer.h>
#include <linux/lcd.h> #include <linux/lcd.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_device.h> #include <linux/of_device.h>
#include <linux/of_gpio.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#define HX8357_NUM_IM_PINS 3 #define HX8357_NUM_IM_PINS 3
...@@ -83,11 +83,10 @@ ...@@ -83,11 +83,10 @@
#define HX8369_SET_GAMMA_CURVE_RELATED 0xe0 #define HX8369_SET_GAMMA_CURVE_RELATED 0xe0
struct hx8357_data { struct hx8357_data {
unsigned im_pins[HX8357_NUM_IM_PINS]; struct gpio_descs *im_pins;
unsigned reset; struct gpio_desc *reset;
struct spi_device *spi; struct spi_device *spi;
int state; int state;
bool use_im_pins;
}; };
static u8 hx8357_seq_power[] = { static u8 hx8357_seq_power[] = {
...@@ -321,11 +320,11 @@ static void hx8357_lcd_reset(struct lcd_device *lcdev) ...@@ -321,11 +320,11 @@ static void hx8357_lcd_reset(struct lcd_device *lcdev)
struct hx8357_data *lcd = lcd_get_data(lcdev); struct hx8357_data *lcd = lcd_get_data(lcdev);
/* Reset the screen */ /* Reset the screen */
gpio_set_value(lcd->reset, 1); gpiod_set_value(lcd->reset, 0);
usleep_range(10000, 12000); usleep_range(10000, 12000);
gpio_set_value(lcd->reset, 0); gpiod_set_value(lcd->reset, 1);
usleep_range(10000, 12000); usleep_range(10000, 12000);
gpio_set_value(lcd->reset, 1); gpiod_set_value(lcd->reset, 0);
/* The controller needs 120ms to recover from reset */ /* The controller needs 120ms to recover from reset */
msleep(120); msleep(120);
...@@ -340,10 +339,10 @@ static int hx8357_lcd_init(struct lcd_device *lcdev) ...@@ -340,10 +339,10 @@ static int hx8357_lcd_init(struct lcd_device *lcdev)
* Set the interface selection pins to SPI mode, with three * Set the interface selection pins to SPI mode, with three
* wires * wires
*/ */
if (lcd->use_im_pins) { if (lcd->im_pins) {
gpio_set_value_cansleep(lcd->im_pins[0], 1); gpiod_set_value_cansleep(lcd->im_pins->desc[0], 1);
gpio_set_value_cansleep(lcd->im_pins[1], 0); gpiod_set_value_cansleep(lcd->im_pins->desc[1], 0);
gpio_set_value_cansleep(lcd->im_pins[2], 1); gpiod_set_value_cansleep(lcd->im_pins->desc[2], 1);
} }
ret = hx8357_spi_write_array(lcdev, hx8357_seq_power, ret = hx8357_spi_write_array(lcdev, hx8357_seq_power,
...@@ -580,6 +579,7 @@ MODULE_DEVICE_TABLE(of, hx8357_dt_ids); ...@@ -580,6 +579,7 @@ MODULE_DEVICE_TABLE(of, hx8357_dt_ids);
static int hx8357_probe(struct spi_device *spi) static int hx8357_probe(struct spi_device *spi)
{ {
struct device *dev = &spi->dev;
struct lcd_device *lcdev; struct lcd_device *lcdev;
struct hx8357_data *lcd; struct hx8357_data *lcd;
const struct of_device_id *match; const struct of_device_id *match;
...@@ -601,49 +601,19 @@ static int hx8357_probe(struct spi_device *spi) ...@@ -601,49 +601,19 @@ static int hx8357_probe(struct spi_device *spi)
if (!match || !match->data) if (!match || !match->data)
return -EINVAL; return -EINVAL;
lcd->reset = of_get_named_gpio(spi->dev.of_node, "gpios-reset", 0); lcd->reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW);
if (!gpio_is_valid(lcd->reset)) { if (IS_ERR(lcd->reset))
dev_err(&spi->dev, "Missing dt property: gpios-reset\n"); return dev_err_probe(dev, PTR_ERR(lcd->reset), "failed to request reset GPIO\n");
return -EINVAL; gpiod_set_consumer_name(lcd->reset, "hx8357-reset");
}
ret = devm_gpio_request_one(&spi->dev, lcd->reset,
GPIOF_OUT_INIT_HIGH,
"hx8357-reset");
if (ret) {
dev_err(&spi->dev,
"failed to request gpio %d: %d\n",
lcd->reset, ret);
return -EINVAL;
}
if (of_property_present(spi->dev.of_node, "im-gpios")) { lcd->im_pins = devm_gpiod_get_array_optional(dev, "im", GPIOD_OUT_LOW);
lcd->use_im_pins = 1; if (IS_ERR(lcd->im_pins))
return dev_err_probe(dev, PTR_ERR(lcd->im_pins), "failed to request im GPIOs\n");
if (lcd->im_pins->ndescs < HX8357_NUM_IM_PINS)
return dev_err_probe(dev, -EINVAL, "not enough im GPIOs\n");
for (i = 0; i < HX8357_NUM_IM_PINS; i++) { for (i = 0; i < HX8357_NUM_IM_PINS; i++)
lcd->im_pins[i] = of_get_named_gpio(spi->dev.of_node, gpiod_set_consumer_name(lcd->im_pins->desc[i], "im_pins");
"im-gpios", i);
if (lcd->im_pins[i] == -EPROBE_DEFER) {
dev_info(&spi->dev, "GPIO requested is not here yet, deferring the probe\n");
return -EPROBE_DEFER;
}
if (!gpio_is_valid(lcd->im_pins[i])) {
dev_err(&spi->dev, "Missing dt property: im-gpios\n");
return -EINVAL;
}
ret = devm_gpio_request_one(&spi->dev, lcd->im_pins[i],
GPIOF_OUT_INIT_LOW,
"im_pins");
if (ret) {
dev_err(&spi->dev, "failed to request gpio %d: %d\n",
lcd->im_pins[i], ret);
return -EINVAL;
}
}
} else {
lcd->use_im_pins = 0;
}
lcdev = devm_lcd_device_register(&spi->dev, "mxsfb", &spi->dev, lcd, lcdev = devm_lcd_device_register(&spi->dev, "mxsfb", &spi->dev, lcd,
&hx8357_ops); &hx8357_ops);
......
...@@ -81,7 +81,7 @@ ...@@ -81,7 +81,7 @@
#define START_RW_WRITE 0 #define START_RW_WRITE 0
#define START_RW_READ 1 #define START_RW_READ 1
/** /*
* START_BYTE(id, rs, rw) * START_BYTE(id, rs, rw)
* *
* Set the start byte according to the required operation. * Set the start byte according to the required operation.
...@@ -100,7 +100,7 @@ ...@@ -100,7 +100,7 @@
#define START_BYTE(id, rs, rw) \ #define START_BYTE(id, rs, rw) \
(0x70 | (((id) & 0x01) << 2) | (((rs) & 0x01) << 1) | ((rw) & 0x01)) (0x70 | (((id) & 0x01) << 2) | (((rs) & 0x01) << 1) | ((rw) & 0x01))
/** /*
* CHECK_FREQ_REG(spi_device s, spi_transfer x) - Check the frequency * CHECK_FREQ_REG(spi_device s, spi_transfer x) - Check the frequency
* for the SPI transfer. According to the datasheet, the controller * for the SPI transfer. According to the datasheet, the controller
* accept higher frequency for the GRAM transfer, but it requires * 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) ...@@ -269,6 +269,10 @@ static int ili922x_write(struct spi_device *spi, u8 reg, u16 value)
spi_message_add_tail(&xfer_regindex, &msg); spi_message_add_tail(&xfer_regindex, &msg);
ret = spi_sync(spi, &msg); ret = spi_sync(spi, &msg);
if (ret < 0) {
dev_err(&spi->dev, "Error sending SPI message 0x%x", ret);
return ret;
}
spi_message_init(&msg); spi_message_init(&msg);
tbuf[0] = set_tx_byte(START_BYTE(ili922x_id, START_RS_REG, tbuf[0] = set_tx_byte(START_BYTE(ili922x_id, START_RS_REG,
......
This diff is collapsed.
...@@ -461,10 +461,9 @@ static int pwm_backlight_probe(struct platform_device *pdev) ...@@ -461,10 +461,9 @@ static int pwm_backlight_probe(struct platform_device *pdev)
if (!data) { if (!data) {
ret = pwm_backlight_parse_dt(&pdev->dev, &defdata); ret = pwm_backlight_parse_dt(&pdev->dev, &defdata);
if (ret < 0) { if (ret < 0)
dev_err(&pdev->dev, "failed to find platform data\n"); return dev_err_probe(&pdev->dev, ret,
return ret; "failed to find platform data\n");
}
data = &defdata; data = &defdata;
} }
...@@ -493,24 +492,27 @@ static int pwm_backlight_probe(struct platform_device *pdev) ...@@ -493,24 +492,27 @@ static int pwm_backlight_probe(struct platform_device *pdev)
pb->enable_gpio = devm_gpiod_get_optional(&pdev->dev, "enable", pb->enable_gpio = devm_gpiod_get_optional(&pdev->dev, "enable",
GPIOD_ASIS); GPIOD_ASIS);
if (IS_ERR(pb->enable_gpio)) { if (IS_ERR(pb->enable_gpio)) {
ret = PTR_ERR(pb->enable_gpio); ret = dev_err_probe(&pdev->dev, PTR_ERR(pb->enable_gpio),
"failed to acquire enable GPIO\n");
goto err_alloc; goto err_alloc;
} }
pb->power_supply = devm_regulator_get_optional(&pdev->dev, "power"); pb->power_supply = devm_regulator_get_optional(&pdev->dev, "power");
if (IS_ERR(pb->power_supply)) { if (IS_ERR(pb->power_supply)) {
ret = PTR_ERR(pb->power_supply); ret = PTR_ERR(pb->power_supply);
if (ret == -ENODEV) if (ret == -ENODEV) {
pb->power_supply = NULL; pb->power_supply = NULL;
else } else {
dev_err_probe(&pdev->dev, ret,
"failed to acquire power regulator\n");
goto err_alloc; goto err_alloc;
} }
}
pb->pwm = devm_pwm_get(&pdev->dev, NULL); pb->pwm = devm_pwm_get(&pdev->dev, NULL);
if (IS_ERR(pb->pwm)) { if (IS_ERR(pb->pwm)) {
ret = PTR_ERR(pb->pwm); ret = dev_err_probe(&pdev->dev, PTR_ERR(pb->pwm),
if (ret != -EPROBE_DEFER) "unable to request PWM\n");
dev_err(&pdev->dev, "unable to request PWM\n");
goto err_alloc; goto err_alloc;
} }
...@@ -530,8 +532,8 @@ static int pwm_backlight_probe(struct platform_device *pdev) ...@@ -530,8 +532,8 @@ static int pwm_backlight_probe(struct platform_device *pdev)
ret = pwm_apply_might_sleep(pb->pwm, &state); ret = pwm_apply_might_sleep(pb->pwm, &state);
if (ret) { if (ret) {
dev_err(&pdev->dev, "failed to apply initial PWM state: %d\n", dev_err_probe(&pdev->dev, ret,
ret); "failed to apply initial PWM state");
goto err_alloc; goto err_alloc;
} }
...@@ -568,7 +570,7 @@ static int pwm_backlight_probe(struct platform_device *pdev) ...@@ -568,7 +570,7 @@ static int pwm_backlight_probe(struct platform_device *pdev)
ret = pwm_backlight_brightness_default(&pdev->dev, data, ret = pwm_backlight_brightness_default(&pdev->dev, data,
state.period); state.period);
if (ret < 0) { if (ret < 0) {
dev_err(&pdev->dev, dev_err_probe(&pdev->dev, ret,
"failed to setup default brightness table\n"); "failed to setup default brightness table\n");
goto err_alloc; goto err_alloc;
} }
...@@ -597,8 +599,8 @@ static int pwm_backlight_probe(struct platform_device *pdev) ...@@ -597,8 +599,8 @@ static int pwm_backlight_probe(struct platform_device *pdev)
bl = backlight_device_register(dev_name(&pdev->dev), &pdev->dev, pb, bl = backlight_device_register(dev_name(&pdev->dev), &pdev->dev, pb,
&pwm_backlight_ops, &props); &pwm_backlight_ops, &props);
if (IS_ERR(bl)) { if (IS_ERR(bl)) {
dev_err(&pdev->dev, "failed to register backlight\n"); ret = dev_err_probe(&pdev->dev, PTR_ERR(bl),
ret = PTR_ERR(bl); "failed to register backlight\n");
goto err_alloc; goto err_alloc;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment