2 #include <cust_leds_def.h>
3 #include <mach/mt_pwm.h>
5 #include <linux/kernel.h>
6 #include <mach/pmic_mt6329_hw_bank1.h>
7 #include <mach/pmic_mt6329_sw_bank1.h>
8 #include <mach/pmic_mt6329_hw.h>
9 #include <mach/pmic_mt6329_sw.h>
10 #include <mach/upmu_common_sw.h>
11 #include <mach/upmu_hw.h>
13 extern int disp_bls_set_backlight(unsigned int level
);
15 // Only support 64 levels of backlight (when lcd-backlight = MT65XX_LED_MODE_PWM)
16 #define BACKLIGHT_LEVEL_PWM_64_FIFO_MODE_SUPPORT 64
17 // Support 256 levels of backlight (when lcd-backlight = MT65XX_LED_MODE_PWM)
18 #define BACKLIGHT_LEVEL_PWM_256_SUPPORT 256
20 // Configure the support type "BACKLIGHT_LEVEL_PWM_256_SUPPORT" or "BACKLIGHT_LEVEL_PWM_64_FIFO_MODE_SUPPORT" !!
21 #define BACKLIGHT_LEVEL_PWM_MODE_CONFIG BACKLIGHT_LEVEL_PWM_256_SUPPORT
23 unsigned int Cust_GetBacklightLevelSupport_byPWM(void)
25 return BACKLIGHT_LEVEL_PWM_MODE_CONFIG
;
28 unsigned int brightness_mapping(unsigned int level
)
30 unsigned int mapped_level
;
37 unsigned int Cust_SetBacklight(int level, int div)
40 // mtkfb_set_backlight_pwm(div);
41 // mtkfb_set_backlight_level(brightness_mapping(level));
44 * To explain How to set these para for cust_led_list[] of led/backlight
45 * "name" para: led or backlight
46 * "mode" para:which mode for led/backlight
48 * MT65XX_LED_MODE_NONE,
49 * MT65XX_LED_MODE_PWM,
50 * MT65XX_LED_MODE_GPIO,
51 * MT65XX_LED_MODE_PMIC,
52 * MT65XX_LED_MODE_CUST_LCM,
53 * MT65XX_LED_MODE_CUST_BLS_PWM
55 *"data" para: control methord for led/backlight
57 * MT65XX_LED_PMIC_LCD_ISINK=0,
58 * MT65XX_LED_PMIC_NLED_ISINK0,
59 * MT65XX_LED_PMIC_NLED_ISINK1,
60 * MT65XX_LED_PMIC_NLED_ISINK2,
61 * MT65XX_LED_PMIC_NLED_ISINK3
63 *"PWM_config" para:PWM(AP side Or BLS module), by default setting{0,0,0,0,0} Or {0}
69 * BOOL pmic_pad;//AP side PWM pin in PMIC chip (only 89 needs confirm); 1:yes 0:no(default)
71 *-------------------------------------------------------------------------------------------
72 * for AP PWM setting as follow:
74 * clock_source: clock source frequency, can be 0/1
75 * div: clock division, can be any value within 0~7 (i.e. 1/2^(div) = /1, /2, /4, /8, /16, /32, /64, /128)
76 * low_duration: only for BACKLIGHT_LEVEL_PWM_64_FIFO_MODE_SUPPORT
77 * High_duration: only for BACKLIGHT_LEVEL_PWM_64_FIFO_MODE_SUPPORT
80 * If BACKLIGHT_LEVEL_PWM_MODE_CONFIG = BACKLIGHT_LEVEL_PWM_256_SUPPORT,
81 * PWM freq. = clock source / 2^(div) / 256
83 * If BACKLIGHT_LEVEL_PWM_MODE_CONFIG = BACKLIGHT_LEVEL_PWM_64_FIFO_MODE_SUPPORT,
84 * PWM freq. = clock source / 2^(div) / [(High_duration+1)(Level')+(low_duration+1)(64 - Level')]
85 * = clock source / 2^(div) / [(High_duration+1)*64] (when low_duration = High_duration)
87 * 0: block clock/1625 = 26M/1625 = 16K (MT6571)
88 * 1: block clock = 26M (MT6571)
91 *For example, in MT6571, PWM_config = {1,1,0,0,0}
92 * ==> PWM freq. = 26M/2^1/256 = 50.78 KHz ( when BACKLIGHT_LEVEL_PWM_256_SUPPORT )
93 * ==> PWM freq. = 26M/2^1/(0+1)*64 = 203.13 KHz ( when BACKLIGHT_LEVEL_PWM_64_FIFO_MODE_SUPPORT )
94 *-------------------------------------------------------------------------------------------
95 * for BLS PWM setting as follow:
97 * clock_source: clock source frequency, can be 0/1/2/3
98 * div: clock division, can be any value within 0~1023
99 * low_duration: non-use
100 * High_duration: non-use
103 *2. PWM freq.= clock source / (div + 1) /1024
111 *By default, clock_source = 0 and div = 0 => PWM freq. = 26 KHz
112 *-------------------------------------------------------------------------------------------
114 static struct cust_mt65xx_led cust_led_list
[MT65XX_LED_TYPE_TOTAL
] = {
115 {"red", MT65XX_LED_MODE_PMIC
, MT65XX_LED_PMIC_NLED_ISINK2
,{0}},
116 {"green", MT65XX_LED_MODE_PMIC
, MT65XX_LED_PMIC_NLED_ISINK1
,{0}},
117 {"blue", MT65XX_LED_MODE_PMIC
, MT65XX_LED_PMIC_NLED_ISINK0
,{0}},
118 {"jogball-backlight", MT65XX_LED_MODE_NONE
, -1,{0}},
119 {"keyboard-backlight",MT65XX_LED_MODE_NONE
, -1,{0}},
120 {"button-backlight", MT65XX_LED_MODE_NONE
, -1,{0}},
121 {"lcd-backlight", MT65XX_LED_MODE_CUST_BLS_PWM
, (int)disp_bls_set_backlight
,{0,0,0,0,0}},
124 struct cust_mt65xx_led
*get_cust_led_list(void)
126 return cust_led_list
;