mirror of
https://github.com/torvalds/linux.git
synced 2026-05-28 17:13:52 +02:00
* Apple DWI Backlight:
* Added devicetree bindings for backlight controllers on Apple's
DWI interface.
* Added a new driver (apple_dwi_bl) for these controllers found
on some Apple mobile devices.
* Added MAINTAINERS entries for the new driver.
* led_bl: Fixed a locking issue by holding the led_access lock
when calling led_sysfs_disable() during device removal to
prevent potential warnings.
* Removed unnecessary <linux/fb.h> includes from a bunch of
drivers.
* tdo24m: Removed redundant whitespace in Kconfig description.
* pcf50633-backlight: Removed the driver as the underlying
pcf50633 MFD and s3c24xx platform support were removed.
-----BEGIN PGP SIGNATURE-----
iQIzBAABCgAdFiEEdrbJNaO+IJqU8IdIUa+KL4f8d2EFAmfmqtsACgkQUa+KL4f8
d2G/pQ//RPySheVMI6OC8WbmHNgwL12urjO5Gpin0npaVDBXpI0a+Cb1mCgsB331
Bx2Om8p0JCasL9XEvUkMtigli0+c9wWdBx/XAJnK1xoeB2Yroef2by98GAkIzl3T
Ol0URYIXMA4cMUqfJC7uMnvonfgAoPcKfPyKPE7JzD7pSDw9LrGBHGfsGAu1n62T
HpF/hPu1n/sTQX3xCwsxb+74Rl+G/zv77j0y6QTv010cCpkiJRMht7a9kzze4dEs
PruF9sgKa3RM9oLPGXNCkp614Bmeuj9C5phmSynLGylRS7FbxqgqgYpZZ13Kqts9
mlOlpwuWPkp4PlZF9Hci4Yx+sktOlCGbD9EznU/ZOxEKnIv/1dZ7LvQsSn/hp8eW
GdQ/Q4I2wcExRna2NEngjAMRx8/OH3cdH/9Z8Pj8/EzAy/MKkBR9Ks+OwR7FppFq
tdDj1lJ6jSQ0UH5LhG48UaC03b0M0BpjZHLBmEYQqC8KvOU3ODZx8jsZ8KNc0AFk
nm5PeC5rMCyVpX/eh/kwE8aXfmoxACWxDekuQL2K9rQ8ibAfcMIdNdrk12IJwTOw
PM/WoSpvezsXBefgqAbfSGPZXIcvvle6qjxvLUbgmS+AlPjX/ahFoUDEkdJPYDKJ
3QounH9XAm5Z3SqnSX9MnSk/jmz/41wd6/8p7J8a+kdRDDw4CXM=
=+rL+
-----END PGP SIGNATURE-----
Merge tag 'backlight-next-6.15' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight
Pull backlight updates from Lee Jones:
- Apple DWI Backlight:
- Added devicetree bindings for backlight controllers on Apple's DWI
interface.
- Added a new driver (apple_dwi_bl) for these controllers found on
some Apple mobile devices.
- Added MAINTAINERS entries for the new driver.
- led_bl: Fixed a locking issue by holding the led_access lock when
calling led_sysfs_disable() during device removal to prevent
potential warnings.
- Removed unnecessary <linux/fb.h> includes from a bunch of drivers.
- tdo24m: Removed redundant whitespace in Kconfig description.
- pcf50633-backlight: Removed the driver as the underlying pcf50633 MFD
and s3c24xx platform support were removed.
* tag 'backlight-next-6.15' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight: (22 commits)
backlight: pcf50633-backlight: Remove unused driver
backlight: tdo24m: Eliminate redundant whitespace
MAINTAINERS: Add entries for Apple DWI backlight controller
backlight: apple_dwi_bl: Add Apple DWI backlight driver
dt-bindings: leds: backlight: apple,dwi-bl: Add Apple DWI backlight
backlight: led_bl: Hold led_access lock when calling led_sysfs_disable()
backlight: wm831x_bl: Do not include <linux/fb.h>
backlight: vgg2432a4: Do not include <linux/fb.h>
backlight: tps65217_bl: Do not include <linux/fb.h>
backlight: max8925_bl: Do not include <linux/fb.h>
backlight: lv5207lp: Do not include <linux/fb.h>
backlight: locomolcd: Do not include <linux/fb.h>
backlight: hp680_bl: Do not include <linux/fb.h>
backlight: ep93xx_bl: Do not include <linux/fb.h>
backlight: da9052_bl: Do not include <linux/fb.h>
backlight: da903x_bl: Do not include <linux/fb.h>
backlight: bd6107_bl: Do not include <linux/fb.h>
backlight: as3711_bl: Do not include <linux/fb.h>
backlight: adp8870_bl: Do not include <linux/fb.h>
backlight: adp8860_bl: Do not include <linux/fb.h>
...
This commit is contained in:
commit
93d5228867
|
|
@ -0,0 +1,57 @@
|
|||
# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
|
||||
%YAML 1.2
|
||||
---
|
||||
$id: http://devicetree.org/schemas/leds/backlight/apple,dwi-bl.yaml#
|
||||
$schema: http://devicetree.org/meta-schemas/core.yaml#
|
||||
|
||||
title: Apple DWI 2-Wire Interface Backlight Controller
|
||||
|
||||
maintainers:
|
||||
- Nick Chan <towinchenmi@gmail.com>
|
||||
|
||||
description:
|
||||
Apple SoCs contain a 2-wire interface called DWI. On some Apple iPhones,
|
||||
iPads and iPod touches with a LCD display, 1-2 backlight controllers
|
||||
are connected via DWI. Interfacing with DWI controls all backlight
|
||||
controllers at the same time. As such, the backlight controllers are
|
||||
treated as a single controller regardless of the underlying
|
||||
configuration.
|
||||
|
||||
allOf:
|
||||
- $ref: common.yaml#
|
||||
|
||||
properties:
|
||||
compatible:
|
||||
items:
|
||||
- enum:
|
||||
- apple,s5l8960x-dwi-bl
|
||||
- apple,t7000-dwi-bl
|
||||
- apple,s8000-dwi-bl
|
||||
- apple,t8010-dwi-bl
|
||||
- apple,t8015-dwi-bl
|
||||
- const: apple,dwi-bl
|
||||
|
||||
reg:
|
||||
maxItems: 1
|
||||
|
||||
power-domains:
|
||||
maxItems: 1
|
||||
|
||||
required:
|
||||
- compatible
|
||||
- reg
|
||||
|
||||
unevaluatedProperties: false
|
||||
|
||||
examples:
|
||||
- |
|
||||
soc {
|
||||
#address-cells = <2>;
|
||||
#size-cells = <2>;
|
||||
|
||||
dwi_bl: backlight@20e200010 {
|
||||
compatible = "apple,s5l8960x-dwi-bl", "apple,dwi-bl";
|
||||
reg = <0x2 0x0e200010 0x0 0x8>;
|
||||
power-domains = <&ps_dwi>;
|
||||
};
|
||||
};
|
||||
|
|
@ -2232,6 +2232,7 @@ F: Documentation/devicetree/bindings/i2c/apple,i2c.yaml
|
|||
F: Documentation/devicetree/bindings/interrupt-controller/apple,*
|
||||
F: Documentation/devicetree/bindings/iommu/apple,dart.yaml
|
||||
F: Documentation/devicetree/bindings/iommu/apple,sart.yaml
|
||||
F: Documentation/devicetree/bindings/leds/backlight/apple,dwi-bl.yaml
|
||||
F: Documentation/devicetree/bindings/mailbox/apple,mailbox.yaml
|
||||
F: Documentation/devicetree/bindings/net/bluetooth/brcm,bcm4377-bluetooth.yaml
|
||||
F: Documentation/devicetree/bindings/nvme/apple,nvme-ans.yaml
|
||||
|
|
@ -2259,6 +2260,7 @@ F: drivers/pinctrl/pinctrl-apple-gpio.c
|
|||
F: drivers/pwm/pwm-apple.c
|
||||
F: drivers/soc/apple/*
|
||||
F: drivers/spi/spi-apple.c
|
||||
F: drivers/video/backlight/apple_dwi_bl.c
|
||||
F: drivers/watchdog/apple_wdt.c
|
||||
F: include/dt-bindings/interrupt-controller/apple-aic.h
|
||||
F: include/dt-bindings/pinctrl/apple.h
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@
|
|||
#include <linux/of.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/fb.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/backlight.h>
|
||||
#include <linux/mfd/88pm860x.h>
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ config LCD_ILI9320
|
|||
then say y to include a power driver for it.
|
||||
|
||||
config LCD_TDO24M
|
||||
tristate "Toppoly TDO24M and TDO35S LCD Panels support"
|
||||
tristate "Toppoly TDO24M and TDO35S LCD Panels support"
|
||||
depends on SPI_MASTER
|
||||
help
|
||||
If you have a Toppoly TDO24M/TDO35S series LCD panel, say y here to
|
||||
|
|
@ -290,6 +290,17 @@ config BACKLIGHT_APPLE
|
|||
If you have an Intel-based Apple say Y to enable a driver for its
|
||||
backlight.
|
||||
|
||||
config BACKLIGHT_APPLE_DWI
|
||||
tristate "Apple DWI 2-Wire Interface Backlight Driver"
|
||||
depends on ARCH_APPLE || COMPILE_TEST
|
||||
help
|
||||
Say Y to enable the backlight driver for backlight controllers
|
||||
attached via the Apple DWI 2-wire interface which is found in some
|
||||
Apple iPhones, iPads and iPod touches.
|
||||
|
||||
To compile this driver as a module, choose M here: the module will
|
||||
be called apple_dwi_bl.
|
||||
|
||||
config BACKLIGHT_QCOM_WLED
|
||||
tristate "Qualcomm PMIC WLED Driver"
|
||||
select REGMAP
|
||||
|
|
@ -359,13 +370,6 @@ config BACKLIGHT_88PM860X
|
|||
help
|
||||
Say Y to enable the backlight driver for Marvell 88PM8606.
|
||||
|
||||
config BACKLIGHT_PCF50633
|
||||
tristate "Backlight driver for NXP PCF50633 MFD"
|
||||
depends on MFD_PCF50633
|
||||
help
|
||||
If you have a backlight driven by a NXP PCF50633 MFD, say Y here to
|
||||
enable its driver.
|
||||
|
||||
config BACKLIGHT_AAT2870
|
||||
tristate "AnalogicTech AAT2870 Backlight"
|
||||
depends on MFD_AAT2870_CORE
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ obj-$(CONFIG_BACKLIGHT_ADP5520) += adp5520_bl.o
|
|||
obj-$(CONFIG_BACKLIGHT_ADP8860) += adp8860_bl.o
|
||||
obj-$(CONFIG_BACKLIGHT_ADP8870) += adp8870_bl.o
|
||||
obj-$(CONFIG_BACKLIGHT_APPLE) += apple_bl.o
|
||||
obj-$(CONFIG_BACKLIGHT_APPLE_DWI) += apple_dwi_bl.o
|
||||
obj-$(CONFIG_BACKLIGHT_AS3711) += as3711_bl.o
|
||||
obj-$(CONFIG_BACKLIGHT_BD6107) += bd6107.o
|
||||
obj-$(CONFIG_BACKLIGHT_CLASS_DEVICE) += backlight.o
|
||||
|
|
@ -49,7 +50,6 @@ obj-$(CONFIG_BACKLIGHT_MP3309C) += mp3309c.o
|
|||
obj-$(CONFIG_BACKLIGHT_MT6370) += mt6370-backlight.o
|
||||
obj-$(CONFIG_BACKLIGHT_OMAP1) += omap1_bl.o
|
||||
obj-$(CONFIG_BACKLIGHT_PANDORA) += pandora_bl.o
|
||||
obj-$(CONFIG_BACKLIGHT_PCF50633) += pcf50633-backlight.o
|
||||
obj-$(CONFIG_BACKLIGHT_PWM) += pwm_bl.o
|
||||
obj-$(CONFIG_BACKLIGHT_QCOM_WLED) += qcom-wled.o
|
||||
obj-$(CONFIG_BACKLIGHT_RT4831) += rt4831-backlight.o
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
#include <linux/kernel.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/fb.h>
|
||||
#include <linux/backlight.h>
|
||||
#include <linux/mfd/adp5520.h>
|
||||
#include <linux/slab.h>
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@
|
|||
#include <linux/pm.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/fb.h>
|
||||
#include <linux/backlight.h>
|
||||
#include <linux/leds.h>
|
||||
#include <linux/slab.h>
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@
|
|||
#include <linux/pm.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/fb.h>
|
||||
#include <linux/backlight.h>
|
||||
#include <linux/leds.h>
|
||||
#include <linux/workqueue.h>
|
||||
|
|
|
|||
123
drivers/video/backlight/apple_dwi_bl.c
Normal file
123
drivers/video/backlight/apple_dwi_bl.c
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
// SPDX-License-Identifier: GPL-2.0 OR MIT
|
||||
/*
|
||||
* Driver for backlight controllers attached via Apple DWI 2-wire interface
|
||||
*
|
||||
* Copyright (c) 2024 Nick Chan <towinchenmi@gmail.com>
|
||||
*/
|
||||
|
||||
#include <linux/backlight.h>
|
||||
#include <linux/bitfield.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/io.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/platform_device.h>
|
||||
|
||||
#define DWI_BL_CTL 0x0
|
||||
#define DWI_BL_CTL_SEND1 BIT(0)
|
||||
#define DWI_BL_CTL_SEND2 BIT(4)
|
||||
#define DWI_BL_CTL_SEND3 BIT(5)
|
||||
#define DWI_BL_CTL_LE_DATA BIT(6)
|
||||
/* Only used on Apple A9 and later */
|
||||
#define DWI_BL_CTL_SEND4 BIT(12)
|
||||
|
||||
#define DWI_BL_CMD 0x4
|
||||
#define DWI_BL_CMD_TYPE GENMASK(31, 28)
|
||||
#define DWI_BL_CMD_TYPE_SET_BRIGHTNESS 0xa
|
||||
#define DWI_BL_CMD_DATA GENMASK(10, 0)
|
||||
|
||||
#define DWI_BL_CTL_SEND (DWI_BL_CTL_SEND1 | \
|
||||
DWI_BL_CTL_SEND2 | \
|
||||
DWI_BL_CTL_SEND3 | \
|
||||
DWI_BL_CTL_LE_DATA | \
|
||||
DWI_BL_CTL_SEND4)
|
||||
|
||||
#define DWI_BL_MAX_BRIGHTNESS 2047
|
||||
|
||||
struct apple_dwi_bl {
|
||||
void __iomem *base;
|
||||
};
|
||||
|
||||
static int dwi_bl_update_status(struct backlight_device *bl)
|
||||
{
|
||||
struct apple_dwi_bl *dwi_bl = bl_get_data(bl);
|
||||
|
||||
int brightness = backlight_get_brightness(bl);
|
||||
|
||||
u32 cmd = 0;
|
||||
|
||||
cmd |= FIELD_PREP(DWI_BL_CMD_DATA, brightness);
|
||||
cmd |= FIELD_PREP(DWI_BL_CMD_TYPE, DWI_BL_CMD_TYPE_SET_BRIGHTNESS);
|
||||
|
||||
writel(cmd, dwi_bl->base + DWI_BL_CMD);
|
||||
writel(DWI_BL_CTL_SEND, dwi_bl->base + DWI_BL_CTL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dwi_bl_get_brightness(struct backlight_device *bl)
|
||||
{
|
||||
struct apple_dwi_bl *dwi_bl = bl_get_data(bl);
|
||||
|
||||
u32 cmd = readl(dwi_bl->base + DWI_BL_CMD);
|
||||
|
||||
return FIELD_GET(DWI_BL_CMD_DATA, cmd);
|
||||
}
|
||||
|
||||
static const struct backlight_ops dwi_bl_ops = {
|
||||
.options = BL_CORE_SUSPENDRESUME,
|
||||
.get_brightness = dwi_bl_get_brightness,
|
||||
.update_status = dwi_bl_update_status
|
||||
};
|
||||
|
||||
static int dwi_bl_probe(struct platform_device *dev)
|
||||
{
|
||||
struct apple_dwi_bl *dwi_bl;
|
||||
struct backlight_device *bl;
|
||||
struct backlight_properties props;
|
||||
struct resource *res;
|
||||
|
||||
dwi_bl = devm_kzalloc(&dev->dev, sizeof(*dwi_bl), GFP_KERNEL);
|
||||
if (!dwi_bl)
|
||||
return -ENOMEM;
|
||||
|
||||
dwi_bl->base = devm_platform_get_and_ioremap_resource(dev, 0, &res);
|
||||
if (IS_ERR(dwi_bl->base))
|
||||
return PTR_ERR(dwi_bl->base);
|
||||
|
||||
memset(&props, 0, sizeof(struct backlight_properties));
|
||||
props.type = BACKLIGHT_PLATFORM;
|
||||
props.max_brightness = DWI_BL_MAX_BRIGHTNESS;
|
||||
props.scale = BACKLIGHT_SCALE_LINEAR;
|
||||
|
||||
bl = devm_backlight_device_register(&dev->dev, dev->name, &dev->dev,
|
||||
dwi_bl, &dwi_bl_ops, &props);
|
||||
if (IS_ERR(bl))
|
||||
return PTR_ERR(bl);
|
||||
|
||||
platform_set_drvdata(dev, dwi_bl);
|
||||
|
||||
bl->props.brightness = dwi_bl_get_brightness(bl);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct of_device_id dwi_bl_of_match[] = {
|
||||
{ .compatible = "apple,dwi-bl" },
|
||||
{},
|
||||
};
|
||||
|
||||
MODULE_DEVICE_TABLE(of, dwi_bl_of_match);
|
||||
|
||||
static struct platform_driver dwi_bl_driver = {
|
||||
.driver = {
|
||||
.name = "apple-dwi-bl",
|
||||
.of_match_table = dwi_bl_of_match
|
||||
},
|
||||
.probe = dwi_bl_probe,
|
||||
};
|
||||
|
||||
module_platform_driver(dwi_bl_driver);
|
||||
|
||||
MODULE_DESCRIPTION("Apple DWI Backlight Driver");
|
||||
MODULE_AUTHOR("Nick Chan <towinchenmi@gmail.com>");
|
||||
MODULE_LICENSE("Dual MIT/GPL");
|
||||
|
|
@ -10,7 +10,6 @@
|
|||
#include <linux/delay.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/fb.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/mfd/as3711.h>
|
||||
#include <linux/module.h>
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@
|
|||
#include <linux/backlight.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/fb.h>
|
||||
#include <linux/gpio/consumer.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/module.h>
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@
|
|||
#include <linux/kernel.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/fb.h>
|
||||
#include <linux/backlight.h>
|
||||
#include <linux/mfd/da903x.h>
|
||||
#include <linux/slab.h>
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
|
||||
#include <linux/backlight.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/fb.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/platform_device.h>
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@
|
|||
#include <linux/module.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/io.h>
|
||||
#include <linux/fb.h>
|
||||
#include <linux/backlight.h>
|
||||
|
||||
#define EP93XX_MAX_COUNT 255
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@
|
|||
#include <linux/init.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/spinlock.h>
|
||||
#include <linux/fb.h>
|
||||
#include <linux/backlight.h>
|
||||
|
||||
#include <cpu/dac.h>
|
||||
|
|
|
|||
|
|
@ -229,8 +229,11 @@ static void led_bl_remove(struct platform_device *pdev)
|
|||
backlight_device_unregister(bl);
|
||||
|
||||
led_bl_power_off(priv);
|
||||
for (i = 0; i < priv->nb_leds; i++)
|
||||
for (i = 0; i < priv->nb_leds; i++) {
|
||||
mutex_lock(&priv->leds[i]->led_access);
|
||||
led_sysfs_enable(priv->leds[i]);
|
||||
mutex_unlock(&priv->leds[i]->led_access);
|
||||
}
|
||||
}
|
||||
|
||||
static const struct of_device_id led_bl_of_match[] = {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
#include <linux/delay.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/fb.h>
|
||||
#include <linux/backlight.h>
|
||||
|
||||
#include <asm/hardware/locomo.h>
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
|
||||
#include <linux/backlight.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/fb.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/platform_data/lv5207lp.h>
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
#include <linux/init.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/fb.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/backlight.h>
|
||||
#include <linux/mfd/max8925.h>
|
||||
|
|
|
|||
|
|
@ -1,154 +0,0 @@
|
|||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
/*
|
||||
* Copyright (C) 2009-2010, Lars-Peter Clausen <lars@metafoo.de>
|
||||
* PCF50633 backlight device driver
|
||||
*/
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/platform_device.h>
|
||||
|
||||
#include <linux/backlight.h>
|
||||
|
||||
#include <linux/mfd/pcf50633/core.h>
|
||||
#include <linux/mfd/pcf50633/backlight.h>
|
||||
|
||||
struct pcf50633_bl {
|
||||
struct pcf50633 *pcf;
|
||||
struct backlight_device *bl;
|
||||
|
||||
unsigned int brightness;
|
||||
unsigned int brightness_limit;
|
||||
};
|
||||
|
||||
/*
|
||||
* pcf50633_bl_set_brightness_limit
|
||||
*
|
||||
* Update the brightness limit for the pc50633 backlight. The actual brightness
|
||||
* will not go above the limit. This is useful to limit power drain for example
|
||||
* on low battery.
|
||||
*
|
||||
* @dev: Pointer to a pcf50633 device
|
||||
* @limit: The brightness limit. Valid values are 0-63
|
||||
*/
|
||||
int pcf50633_bl_set_brightness_limit(struct pcf50633 *pcf, unsigned int limit)
|
||||
{
|
||||
struct pcf50633_bl *pcf_bl = platform_get_drvdata(pcf->bl_pdev);
|
||||
|
||||
if (!pcf_bl)
|
||||
return -ENODEV;
|
||||
|
||||
pcf_bl->brightness_limit = limit & 0x3f;
|
||||
backlight_update_status(pcf_bl->bl);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int pcf50633_bl_update_status(struct backlight_device *bl)
|
||||
{
|
||||
struct pcf50633_bl *pcf_bl = bl_get_data(bl);
|
||||
unsigned int new_brightness;
|
||||
|
||||
|
||||
if (bl->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK) ||
|
||||
bl->props.power != BACKLIGHT_POWER_ON)
|
||||
new_brightness = 0;
|
||||
else if (bl->props.brightness < pcf_bl->brightness_limit)
|
||||
new_brightness = bl->props.brightness;
|
||||
else
|
||||
new_brightness = pcf_bl->brightness_limit;
|
||||
|
||||
|
||||
if (pcf_bl->brightness == new_brightness)
|
||||
return 0;
|
||||
|
||||
if (new_brightness) {
|
||||
pcf50633_reg_write(pcf_bl->pcf, PCF50633_REG_LEDOUT,
|
||||
new_brightness);
|
||||
if (!pcf_bl->brightness)
|
||||
pcf50633_reg_write(pcf_bl->pcf, PCF50633_REG_LEDENA, 1);
|
||||
} else {
|
||||
pcf50633_reg_write(pcf_bl->pcf, PCF50633_REG_LEDENA, 0);
|
||||
}
|
||||
|
||||
pcf_bl->brightness = new_brightness;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int pcf50633_bl_get_brightness(struct backlight_device *bl)
|
||||
{
|
||||
struct pcf50633_bl *pcf_bl = bl_get_data(bl);
|
||||
|
||||
return pcf_bl->brightness;
|
||||
}
|
||||
|
||||
static const struct backlight_ops pcf50633_bl_ops = {
|
||||
.get_brightness = pcf50633_bl_get_brightness,
|
||||
.update_status = pcf50633_bl_update_status,
|
||||
.options = BL_CORE_SUSPENDRESUME,
|
||||
};
|
||||
|
||||
static int pcf50633_bl_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct pcf50633_bl *pcf_bl;
|
||||
struct device *parent = pdev->dev.parent;
|
||||
struct pcf50633_platform_data *pcf50633_data = dev_get_platdata(parent);
|
||||
struct pcf50633_bl_platform_data *pdata = pcf50633_data->backlight_data;
|
||||
struct backlight_properties bl_props;
|
||||
|
||||
pcf_bl = devm_kzalloc(&pdev->dev, sizeof(*pcf_bl), GFP_KERNEL);
|
||||
if (!pcf_bl)
|
||||
return -ENOMEM;
|
||||
|
||||
memset(&bl_props, 0, sizeof(bl_props));
|
||||
bl_props.type = BACKLIGHT_RAW;
|
||||
bl_props.max_brightness = 0x3f;
|
||||
bl_props.power = BACKLIGHT_POWER_ON;
|
||||
|
||||
if (pdata) {
|
||||
bl_props.brightness = pdata->default_brightness;
|
||||
pcf_bl->brightness_limit = pdata->default_brightness_limit;
|
||||
} else {
|
||||
bl_props.brightness = 0x3f;
|
||||
pcf_bl->brightness_limit = 0x3f;
|
||||
}
|
||||
|
||||
pcf_bl->pcf = dev_to_pcf50633(pdev->dev.parent);
|
||||
|
||||
pcf_bl->bl = devm_backlight_device_register(&pdev->dev, pdev->name,
|
||||
&pdev->dev, pcf_bl,
|
||||
&pcf50633_bl_ops, &bl_props);
|
||||
|
||||
if (IS_ERR(pcf_bl->bl))
|
||||
return PTR_ERR(pcf_bl->bl);
|
||||
|
||||
platform_set_drvdata(pdev, pcf_bl);
|
||||
|
||||
pcf50633_reg_write(pcf_bl->pcf, PCF50633_REG_LEDDIM, pdata->ramp_time);
|
||||
|
||||
/*
|
||||
* Should be different from bl_props.brightness, so we do not exit
|
||||
* update_status early the first time it's called
|
||||
*/
|
||||
pcf_bl->brightness = pcf_bl->bl->props.brightness + 1;
|
||||
|
||||
backlight_update_status(pcf_bl->bl);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct platform_driver pcf50633_bl_driver = {
|
||||
.probe = pcf50633_bl_probe,
|
||||
.driver = {
|
||||
.name = "pcf50633-backlight",
|
||||
},
|
||||
};
|
||||
|
||||
module_platform_driver(pcf50633_bl_driver);
|
||||
|
||||
MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
|
||||
MODULE_DESCRIPTION("PCF50633 backlight driver");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_ALIAS("platform:pcf50633-backlight");
|
||||
|
|
@ -11,7 +11,6 @@
|
|||
#include <linux/kernel.h>
|
||||
#include <linux/backlight.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/fb.h>
|
||||
#include <linux/mfd/tps65217.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/platform_device.h>
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
#include <linux/delay.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/fb.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/lcd.h>
|
||||
#include <linux/module.h>
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
#include <linux/init.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/fb.h>
|
||||
#include <linux/backlight.h>
|
||||
#include <linux/slab.h>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,42 +0,0 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
/*
|
||||
* Copyright (C) 2009-2010, Lars-Peter Clausen <lars@metafoo.de>
|
||||
* PCF50633 backlight device driver
|
||||
*/
|
||||
|
||||
#ifndef __LINUX_MFD_PCF50633_BACKLIGHT
|
||||
#define __LINUX_MFD_PCF50633_BACKLIGHT
|
||||
|
||||
/*
|
||||
* @default_brightness: Backlight brightness is initialized to this value
|
||||
*
|
||||
* Brightness to be used after the driver has been probed.
|
||||
* Valid range 0-63.
|
||||
*
|
||||
* @default_brightness_limit: The actual brightness is limited by this value
|
||||
*
|
||||
* Brightness limit to be used after the driver has been probed. This is useful
|
||||
* when it is not known how much power is available for the backlight during
|
||||
* probe.
|
||||
* Valid range 0-63. Can be changed later with pcf50633_bl_set_brightness_limit.
|
||||
*
|
||||
* @ramp_time: Display ramp time when changing brightness
|
||||
*
|
||||
* When changing the backlights brightness the change is not instant, instead
|
||||
* it fades smooth from one state to another. This value specifies how long
|
||||
* the fade should take. The lower the value the higher the fade time.
|
||||
* Valid range 0-255
|
||||
*/
|
||||
struct pcf50633_bl_platform_data {
|
||||
unsigned int default_brightness;
|
||||
unsigned int default_brightness_limit;
|
||||
uint8_t ramp_time;
|
||||
};
|
||||
|
||||
|
||||
struct pcf50633;
|
||||
|
||||
int pcf50633_bl_set_brightness_limit(struct pcf50633 *pcf, unsigned int limit);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -15,7 +15,6 @@
|
|||
#include <linux/regulator/machine.h>
|
||||
#include <linux/pm.h>
|
||||
#include <linux/power_supply.h>
|
||||
#include <linux/mfd/pcf50633/backlight.h>
|
||||
|
||||
struct pcf50633;
|
||||
struct regmap;
|
||||
|
|
@ -42,8 +41,6 @@ struct pcf50633_platform_data {
|
|||
void (*force_shutdown)(struct pcf50633 *);
|
||||
|
||||
u8 resumers[5];
|
||||
|
||||
struct pcf50633_bl_platform_data *backlight_data;
|
||||
};
|
||||
|
||||
struct pcf50633_irq {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user