MT6785平台默认LED的控制方式是硬件控制,如果要在preloader和lk中操作LED就要将LED切换到软件控制,下面以MTK MT6785平台为例,添加LED驱动。
MT6360_RGBLED=yes
ifeq ($(strip "$(MT6360_RGBLED)"),"yes")
C_OPTION += -DMT6360_RGBLED
endif
ifeq ("$(MT6360_RGBLED)","yes")
MOD_SRC += mt6360_rgbled.c
endif
#include
#include "pal_log.h"
#define RGB_EN_RG 0x80
#define ISINK1_CHRIND_EN_MASK 0x80
#define ISINK1_CHRIND_EN_SHIFT 7
#define ISINK1_CHRIND_EN_SEL_MASK 0x8
#define ISINK1_CHRIND_EN_SEL_SHIFT 3
#define RGB1_ISINK_RG 0x81
static struct mt_i2c_t i2c = {
.id = I2C5,
.addr = 0x34,
.mode = FS_MODE,
.speed = 400,
.pushpull = true,
};
void mt6360_enable_isink1(void){
...
}
void mt6360_disable_isink1(void){
...
}
void mt6360_restore_isink1_auto_mode(void){
...
}
提供三个操作函数,打开/关闭led灯和将LED切换到软件控制,下面再头文件目录下添加如下用户接口头文件,platform/mt6785/src/drivers/inc/mt6360_rgbled.h内容如下:
#ifndef _MT6360_RGBLED_H
#define _MT6360_RGBLED_H
extern void mt6360_enable_isink1(void);
extern void mt6360_disable_isink1(void);
extern void mt6360_restore_isink1_auto_mode(void);
#endif /* _MT6360_RGBLED_H */
a #include "mt6360_rgbled.h"
b 调用函数
MTK_MT6360_RGBLED_SUPPORT := yes
ifeq ($(MTK_MT6360_RGBLED_SUPPORT),yes)
OBJS += $(LOCAL_DIR)/mt6360_rgbled.o
DEFINES += MTK_MT6360_RGBLED_SUPPORT
endif
#include
#include
#include
#include
#define RGB_EN_RG 0x80
#define ISINK1_CHRIND_EN_MASK 0x80
#define ISINK1_CHRIND_EN_SHIFT 7
#define ISINK1_CHRIND_EN_SEL_MASK 0x8
#define ISINK1_CHRIND_EN_SEL_SHIFT 3
#define RGB1_ISINK_RG 0x81
#define ISINK1_CHRIND_DIM_MODE_MASK 0xC0
#define ISINK1_CHRIND_DIM_MODE_SHIFT 6
#define ISINK1_CHRIND_CUR_SEL_MASK 0xF
#define ISINK1_CHRIND_CUR_SEL_SHIFT 0
#define RGB1_DIM_RG 0x85
#define RGB1_2_Freq_RG 0x89
#define ISINK1_CHRIND_DIM_FSEL_MASK 0XE0
#define ISINK1_CHRIND_DIM_FSEL_SHIFT 5
/* ========================= */
/* I2C operations */
/* ========================= */
static struct mt_i2c_t i2c = {
.id = I2C5,
.addr = 0x34,
.mode = FS_MODE,
.speed = 400,
.pushpull = true,
};
.......
提供三个操作函数,打开/关闭led灯和将LED切换到软件控制,下面再头文件目录下添加如下用户接口头文件,platform/mt6785/include/platform/mt6360_rgbled.h内容如下:
#ifndef __MT6360_RGBLED_H
#define __MT6360_RGBLED_H
extern void mt6360_enable_isink1_flash(void);
extern void mt6360_disable_isink1(void);
extern void mt6360_set_isink1_on(void);
#endif /* __MT6360_RGBLED_H */
a #include "mt6360_rgbled.h"
b 调用函数