drivers: leds: Add qpnp-flash-v2 driver

Add qpnp-flash-v2 driver for kona.

This is taken as a snapshot from msm-5.4 kernel
'commit 40ccd6775f80 ("qpnp-flash-v2: Add
support for qpnp-flash-v2 driver")'.

Also, replace the iio_channel_get with devm_iio_channel_get.

Change-Id: I90bfda0ace7b86deb96efac169978c6fb7f8fa23
Signed-off-by: Zihang Hu <quic_zihahu@quicinc.com>
This commit is contained in:
Zihang Hu 2022-10-25 07:53:15 +05:30 committed by Rakesh Kota
parent 8acdbd1706
commit a37b2a48dc
5 changed files with 3299 additions and 0 deletions

View File

@ -270,6 +270,17 @@ config LEDS_NET48XX
This option enables support for the Soekris net4801 and net4826 error
LED.
config LEDS_QPNP_FLASH_V2
tristate "Support for QPNP V2 Flash LEDs"
depends on LEDS_CLASS && MFD_SPMI_PMIC
select LEDS_TRIGGERS
help
This driver supports the flash V2 LED functionality of Qualcomm
Technologies, Inc. QPNP PMICs. This driver supports PMICs starting
from PMI8998, PM8150L and their derivatives. It can configure the
flash LED target current for several independent channels. It also
supports various over current and over temperature mitigation features.
config LEDS_WRAP
tristate "LED Support for the WRAP series LEDs"
depends on LEDS_CLASS

View File

@ -89,6 +89,7 @@ obj-$(CONFIG_LEDS_WM831X_STATUS) += leds-wm831x-status.o
obj-$(CONFIG_LEDS_WM8350) += leds-wm8350.o
obj-$(CONFIG_LEDS_WRAP) += leds-wrap.o
obj-$(CONFIG_LEDS_QTI_TRI_LED) += leds-qti-tri-led.o
obj-$(CONFIG_LEDS_QPNP_FLASH_V2) += leds-qpnp-flash-v2.o
obj-$(CONFIG_LEDS_QPNP_VIBRATOR_LDO) += leds-qpnp-vibrator-ldo.o
# LED SPI Drivers

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,27 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (c) 2016, 2020, The Linux Foundation. All rights reserved.
*/
#ifndef __LEDS_QPNP_FLASH_V2_H
#define __LEDS_QPNP_FLASH_V2_H
#include <linux/leds.h>
#include <linux/notifier.h>
enum flash_led_irq_type {
LED_FAULT_IRQ = BIT(0),
MITIGATION_IRQ = BIT(1),
FLASH_TIMER_EXP_IRQ = BIT(2),
ALL_RAMP_DOWN_DONE_IRQ = BIT(3),
ALL_RAMP_UP_DONE_IRQ = BIT(4),
LED3_RAMP_UP_DONE_IRQ = BIT(5),
LED2_RAMP_UP_DONE_IRQ = BIT(6),
LED1_RAMP_UP_DONE_IRQ = BIT(7),
INVALID_IRQ = BIT(8),
};
int qpnp_flash_led_register_irq_notifier(struct notifier_block *nb);
int qpnp_flash_led_unregister_irq_notifier(struct notifier_block *nb);
#endif

View File

@ -0,0 +1,42 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (c) 2016-2020, The Linux Foundation. All rights reserved.
*/
#ifndef __LEDS_QPNP_FLASH_H
#define __LEDS_QPNP_FLASH_H
#include <linux/leds.h>
#define ENABLE_REGULATOR BIT(0)
#define DISABLE_REGULATOR BIT(1)
#define QUERY_MAX_AVAIL_CURRENT BIT(2)
#define QUERY_MAX_CURRENT BIT(3)
#define FLASH_LED_PREPARE_OPTIONS_MASK GENMASK(3, 0)
int qpnp_flash_register_led_prepare(struct device *dev, void *data);
#if IS_ENABLED(CONFIG_LEDS_QPNP_FLASH_V2)
int qpnp_flash_led_prepare(struct led_trigger *trig, int options,
int *max_current);
#else
static inline int qpnp_flash_led_prepare(struct led_trigger *trig, int options,
int *max_current)
{
return -ENODEV;
}
#endif
#if IS_ENABLED(CONFIG_BACKLIGHT_QCOM_SPMI_WLED)
int wled_flash_led_prepare(struct led_trigger *trig, int options,
int *max_current);
#else
static inline int wled_flash_led_prepare(struct led_trigger *trig, int options,
int *max_current)
{
return -EINVAL;
}
#endif
#endif