Commit | Line | Data |
---|---|---|
6fa3eb70 S |
1 | #include <cust_leds.h> |
2 | #include <cust_leds_def.h> | |
3 | #include <mach/mt_pwm.h> | |
4 | ||
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> | |
12 | ||
13 | extern int disp_bls_set_backlight(unsigned int level); | |
14 | ||
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 | |
19 | ||
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 | |
22 | ||
23 | unsigned int Cust_GetBacklightLevelSupport_byPWM(void) | |
24 | { | |
25 | return BACKLIGHT_LEVEL_PWM_MODE_CONFIG; | |
26 | } | |
27 | ||
28 | unsigned int brightness_mapping(unsigned int level) | |
29 | { | |
30 | unsigned int mapped_level; | |
31 | ||
32 | mapped_level = level; | |
33 | ||
34 | return mapped_level; | |
35 | } | |
36 | /* | |
37 | unsigned int Cust_SetBacklight(int level, int div) | |
38 | { | |
39 | kal_uint32 ret=0; | |
40 | // mtkfb_set_backlight_pwm(div); | |
41 | // mtkfb_set_backlight_level(brightness_mapping(level)); | |
42 | ||
43 | ||
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 | |
47 | * such as: | |
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 | |
54 | * | |
55 | *"data" para: control methord for led/backlight | |
56 | * such as: | |
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 | |
62 | * | |
63 | *"PWM_config" para:PWM(AP side Or BLS module), by default setting{0,0,0,0,0} Or {0} | |
64 | *struct PWM_config { | |
65 | * int clock_source; | |
66 | * int div; | |
67 | * int low_duration; | |
68 | * int High_duration; | |
69 | * BOOL pmic_pad;//AP side PWM pin in PMIC chip (only 89 needs confirm); 1:yes 0:no(default) | |
70 | *}; | |
71 | *------------------------------------------------------------------------------------------- | |
72 | * for AP PWM setting as follow: | |
73 | *1. PWM config data | |
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 | |
78 | * | |
79 | *2. PWM freq. | |
80 | * If BACKLIGHT_LEVEL_PWM_MODE_CONFIG = BACKLIGHT_LEVEL_PWM_256_SUPPORT, | |
81 | * PWM freq. = clock source / 2^(div) / 256 | |
82 | * | |
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) | |
86 | *Clock source: | |
87 | * 0: block clock/1625 = 26M/1625 = 16K (MT6571) | |
88 | * 1: block clock = 26M (MT6571) | |
89 | *Div: 0~7 | |
90 | * | |
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: | |
96 | *1. PWM config data | |
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 | |
101 | * pmic_pad: non-use | |
102 | * | |
103 | *2. PWM freq.= clock source / (div + 1) /1024 | |
104 | *Clock source: | |
105 | * 0: 26 MHz | |
106 | * 1: 104 MHz | |
107 | * 2: 124.8 MHz | |
108 | * 3: 156 MHz | |
109 | *Div: 0~1023 | |
110 | * | |
111 | *By default, clock_source = 0 and div = 0 => PWM freq. = 26 KHz | |
112 | *------------------------------------------------------------------------------------------- | |
113 | */ | |
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}}, | |
122 | }; | |
123 | ||
124 | struct cust_mt65xx_led *get_cust_led_list(void) | |
125 | { | |
126 | return cust_led_list; | |
127 | } | |
128 |