mirror of
https://github.com/hardkernel/kernel_common_drivers.git
synced 2026-06-25 12:03:48 +09:00
led: dcon_led: add flip function and mode select [1/1]
PD#SWPL-180332 Problem: add flip function for led add data mode select for led Solution: add this config Verify: t6d br301 t5m ay301 Change-Id: Ice3e3ff86d2b0823e1f2b1aea852f4bafc9fd3b7 Signed-off-by: Junyi Zhao <junyi.zhao@amlogic.com>
This commit is contained in:
@@ -21,6 +21,8 @@
|
||||
#include <dt-bindings/mailbox/t5m-mbox.h>
|
||||
#include <dt-bindings/thermal/thermal.h>
|
||||
#include <dt-bindings/hwspinlock/amlogic,hwspinlock.h>
|
||||
#include <dt-bindings/leds/leds-meson.h>
|
||||
|
||||
|
||||
/ {
|
||||
cpus:cpus {
|
||||
@@ -981,6 +983,8 @@
|
||||
compatible = "amlogic,led_unipolar_ctrl";
|
||||
reg = <0x74000 0x88>;
|
||||
interrupts = <GIC_SPI 30 IRQ_TYPE_EDGE_RISING>;
|
||||
led-mode = <LED_MESON_GRB>;
|
||||
led_number = <2>;
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <dt-bindings/mailbox/t6d-mbox.h>
|
||||
#include <dt-bindings/thermal/thermal.h>
|
||||
#include <dt-bindings/hwspinlock/amlogic,hwspinlock.h>
|
||||
#include <dt-bindings/leds/leds-meson.h>
|
||||
|
||||
/ {
|
||||
cpus:cpus {
|
||||
@@ -742,6 +743,8 @@
|
||||
compatible = "amlogic,led_unipolar_ctrl";
|
||||
reg = <0x74000 0x88>;
|
||||
interrupts = <GIC_SPI 30 IRQ_TYPE_EDGE_RISING>;
|
||||
led-mode = <LED_MESON_RGB>;
|
||||
led_number = <2>;
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
#include <dt-bindings/hwspinlock/amlogic,hwspinlock.h>
|
||||
#include <dt-bindings/reset/amlogic,meson-txhd2-reset.h>
|
||||
#include "mesongxbb-gpu-mali450.dtsi"
|
||||
#include <dt-bindings/leds/leds-meson.h>
|
||||
|
||||
|
||||
/ {
|
||||
cpus:cpus {
|
||||
@@ -1480,6 +1482,8 @@
|
||||
compatible = "amlogic,led_unipolar_ctrl";
|
||||
reg = <0x1000 0x88>;
|
||||
interrupts = <GIC_SPI 199 IRQ_TYPE_LEVEL_HIGH>;
|
||||
led-mode = <LED_MESON_GRB>;
|
||||
led_number = <2>;
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
|
||||
@@ -1379,10 +1379,11 @@
|
||||
};
|
||||
|
||||
&dcon_led {
|
||||
status = "disabled";
|
||||
led_number = <13>;
|
||||
status = "okay";
|
||||
led_number = <2>;
|
||||
pinctrl-names = "default";
|
||||
pinctrl-0 = <&dcon_led_pins1>;
|
||||
// polarity-inversed;
|
||||
};
|
||||
|
||||
&i2c0 {
|
||||
|
||||
@@ -1379,10 +1379,11 @@
|
||||
};
|
||||
|
||||
&dcon_led {
|
||||
status = "disabled";
|
||||
led_number = <13>;
|
||||
status = "okay";
|
||||
led_number = <2>;
|
||||
pinctrl-names = "default";
|
||||
pinctrl-0 = <&dcon_led_pins1>;
|
||||
// polarity-inversed;
|
||||
};
|
||||
|
||||
&i2c0 {
|
||||
|
||||
@@ -1369,10 +1369,11 @@
|
||||
};
|
||||
|
||||
&dcon_led {
|
||||
status = "disabled";
|
||||
led_number = <13>;
|
||||
status = "okay";
|
||||
led_number = <1>;
|
||||
pinctrl-names = "default";
|
||||
pinctrl-0 = <&dcon_led_pins1>;
|
||||
// polarity-inversed;
|
||||
};
|
||||
|
||||
&i2c0 {
|
||||
|
||||
@@ -1370,10 +1370,11 @@
|
||||
};
|
||||
|
||||
&dcon_led {
|
||||
status = "disabled";
|
||||
led_number = <13>;
|
||||
status = "okay";
|
||||
led_number = <1>;
|
||||
pinctrl-names = "default";
|
||||
pinctrl-0 = <&dcon_led_pins1>;
|
||||
// polarity-inversed;
|
||||
};
|
||||
|
||||
&i2c0 {
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
#include "meson-ir-map.dtsi"
|
||||
#include "meson-valhall.dtsi"
|
||||
#include <dt-bindings/hwspinlock/amlogic,hwspinlock.h>
|
||||
#include <dt-bindings/leds/leds-meson.h>
|
||||
|
||||
|
||||
/ {
|
||||
cpus:cpus {
|
||||
@@ -1697,6 +1699,8 @@
|
||||
compatible = "amlogic,led_unipolar_ctrl";
|
||||
reg = <0x0 0x4c000 0x0 0x88>;
|
||||
interrupts = <GIC_SPI 31 IRQ_TYPE_EDGE_RISING>;
|
||||
led-mode = <LED_MESON_GRB>;
|
||||
led_number = <2>;
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
#include <dt-bindings/mailbox/t5m-mbox.h>
|
||||
#include <dt-bindings/thermal/thermal.h>
|
||||
#include <dt-bindings/hwspinlock/amlogic,hwspinlock.h>
|
||||
#include <dt-bindings/leds/leds-meson.h>
|
||||
#include <dt-bindings/leds/leds-meson.h>
|
||||
|
||||
|
||||
/ {
|
||||
cpus:cpus {
|
||||
@@ -989,6 +992,8 @@
|
||||
compatible = "amlogic,led_unipolar_ctrl";
|
||||
reg = <0x0 0x74000 0x0 0x88>;
|
||||
interrupts = <GIC_SPI 30 IRQ_TYPE_EDGE_RISING>;
|
||||
led-mode = <LED_MESON_GRB>;
|
||||
led_number = <2>;
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <linux/dma-mapping.h>
|
||||
#include <linux/leds.h>
|
||||
#include <linux/completion.h>
|
||||
#include <dt-bindings/leds/leds-meson.h>
|
||||
// #define M_DEBUG
|
||||
|
||||
#ifdef M_DEBUG
|
||||
@@ -56,6 +57,7 @@ enum {
|
||||
};
|
||||
|
||||
/* Control DCON_LED RATIO fields */
|
||||
#define RATIO_FLIP_CTRL BIT(30)
|
||||
#define RATIO_INTERRUPT_STATUS BIT(29)
|
||||
#define RATIO_BUSY_STATUS BIT(28)
|
||||
#define RATIO_PRE_RESETCODE BIT(27)
|
||||
@@ -78,6 +80,8 @@ struct meson_unipolar_ctrl {
|
||||
uint led_num;
|
||||
u8 *color_data;
|
||||
struct completion done;
|
||||
bool polarity_inversed;
|
||||
uint mode;
|
||||
};
|
||||
|
||||
#define MESON_UNIPOLAR_CTRL_CDEV_NAME "unipolar_led"
|
||||
@@ -144,7 +148,9 @@ static void meson_unipolar_ctrl_init(struct meson_unipolar_ctrl *dcon_led)
|
||||
/*set reset duration 0x240*1.25 = 300 us*/
|
||||
meson_unipolar_ctrl_set_mask(dcon_led, LED_CYCLE_RATIO_RES,
|
||||
RATIO_RESET_DURATION_MSK, 0xF0 << RATIO_RESET_DURATION_SHIFT);
|
||||
|
||||
if (dcon_led->polarity_inversed)
|
||||
meson_unipolar_ctrl_set_mask(dcon_led, LED_CYCLE_RATIO_RES,
|
||||
RATIO_FLIP_CTRL, RATIO_FLIP_CTRL);
|
||||
/*send data with out reset*/
|
||||
// meson_unipolar_ctrl_set_mask(dcon_led,LED_CYCLE_RATIO_RES,
|
||||
// RATIO_RESET_DURATION_MSK, RATIO_PRE_RESETCODE);
|
||||
@@ -175,14 +181,28 @@ static void meson_unipolar_ctrl_put_data_to_buffer(struct meson_unipolar_ctrl *d
|
||||
u8 buffer_id, u8 r_data, u8 g_data, u8 b_data)
|
||||
{
|
||||
spin_lock(&dcon_led->lock);
|
||||
/*R G B*/
|
||||
// dcon_led->color_data[buffer_id] = r_data;
|
||||
// dcon_led->color_data[buffer_id + 1] = g_data;
|
||||
// dcon_led->color_data[buffer_id + 2] = b_data;
|
||||
/*G R B*/
|
||||
dcon_led->color_data[buffer_id] = g_data;
|
||||
dcon_led->color_data[buffer_id + 1] = r_data;
|
||||
dcon_led->color_data[buffer_id + 2] = b_data;
|
||||
switch (dcon_led->mode) {
|
||||
case LED_MESON_RGB:
|
||||
/*R G B*/
|
||||
LEDCON_DBG("%s LED_MESON_RGB\n", __func__);
|
||||
dcon_led->color_data[buffer_id] = r_data;
|
||||
dcon_led->color_data[buffer_id + 1] = g_data;
|
||||
dcon_led->color_data[buffer_id + 2] = b_data;
|
||||
break;
|
||||
case LED_MESON_GRB:
|
||||
/*G R B*/
|
||||
LEDCON_DBG("%s LED_MESON_GRB\n", __func__);
|
||||
dcon_led->color_data[buffer_id] = g_data;
|
||||
dcon_led->color_data[buffer_id + 1] = r_data;
|
||||
dcon_led->color_data[buffer_id + 2] = b_data;
|
||||
break;
|
||||
default:
|
||||
/*R G B*/
|
||||
dcon_led->color_data[buffer_id] = r_data;
|
||||
dcon_led->color_data[buffer_id + 1] = g_data;
|
||||
dcon_led->color_data[buffer_id + 2] = b_data;
|
||||
break;
|
||||
}
|
||||
spin_unlock(&dcon_led->lock);
|
||||
|
||||
}
|
||||
@@ -431,6 +451,13 @@ static int unipolar_ctrl_probe(struct platform_device *pdev)
|
||||
dev_err(&pdev->dev, "erro, LED num over than LED_MAX_NUM:%d\n", LED_MAX_NUM);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (device_property_read_bool(&pdev->dev, "polarity-inversed"))
|
||||
dcon_led->polarity_inversed = true;
|
||||
ret = device_property_read_u32(&pdev->dev, "led-mode", &dcon_led->mode);
|
||||
if (ret < 0) {
|
||||
dev_err(&pdev->dev, "Failure to get led mode = %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
dcon_led->color_data = devm_kzalloc(&pdev->dev,
|
||||
dcon_led->led_num * COLOR_CHANNEL_NUM, GFP_KERNEL);
|
||||
if (!dcon_led->color_data)
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
/* SPDX-License-Identifier: (GPL-2.0+ OR MIT) */
|
||||
/*
|
||||
* Copyright (c) 2019 Amlogic, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef _DT_BINDINGS_LEDS_MESON_H
|
||||
#define _DT_BINDINGS_LEDS_MESON_H
|
||||
|
||||
/*defination for LEDS MODE index
|
||||
*
|
||||
*/
|
||||
#define LED_MESON_RGB 0
|
||||
#define LED_MESON_RBG 1
|
||||
#define LED_MESON_GBR 2
|
||||
#define LED_MESON_GRB 3
|
||||
#define LED_MESON_BRG 4
|
||||
#define LED_MESON_BGR 5
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user