import PULS_20160108
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / misc / mediatek / power / mt8127 / tbl_helper_func.c
1 #include <linux/xlog.h>
2 #include <mach/mt_typedefs.h>
3
4 #ifdef CONFIG_MTK_FAN5405_SUPPORT
5 #include "fan5405.h"
6 #endif
7
8 #ifdef CONFIG_MTK_BQ24158_SUPPORT
9 #include "bq24158.h"
10 #endif
11
12 #ifdef CONFIG_MTK_BQ24196_SUPPORT
13 #include "bq24196.h"
14 #endif
15
16 #ifdef CONFIG_MTK_BQ24297_SUPPORT
17 #include "bq24297.h"
18 #endif
19
20 #ifdef CONFIG_MTK_BQ24296_SUPPORT
21 #include "bq24296.h"
22 #endif
23
24 #ifdef CONFIG_MTK_NCP1851_SUPPORT
25 #include "ncp1851.h"
26 #endif
27
28 #ifdef CONFIG_MTK_NCP1854_SUPPORT
29 #include "ncp1854.h"
30 #endif
31 /************* ATTENTATION ***************/
32 /* IF ANY NEW CHARGER IC SUPPORT IN THIS FILE, */
33 /* REMEMBER TO NOTIFY USB OWNER TO MODIFY OTG RELATED FILES!! */
34
35 #ifdef CONFIG_USB_MTK_HDRC_HCD
36 void tbl_charger_otg_vbus(int mode)
37 {
38 xlog_printk(ANDROID_LOG_INFO, "Power/Battery", "[tbl_charger_otg_vbus] mode = %d\n", mode);
39
40 if(mode&0xFF)
41 {
42 #ifdef CONFIG_MTK_FAN5405_SUPPORT
43 fan5405_set_opa_mode(1);
44 fan5405_set_otg_pl(1);
45 fan5405_set_otg_en(1);
46 #endif
47
48
49 #ifdef CONFIG_MTK_BQ24158_SUPPORT
50 bq24158_set_opa_mode(1);
51 bq24158_set_otg_pl(1);
52 bq24158_set_otg_en(1);
53 #endif
54
55
56 #ifdef CONFIG_MTK_BQ24196_SUPPORT
57 bq24196_set_chg_config(0x3); //OTG
58 bq24196_set_boost_lim(0x1); //1.3A on VBUS
59 bq24196_set_en_hiz(0x0);
60 #endif
61
62 #ifdef CONFIG_MTK_BQ24297_SUPPORT
63 bq24297_set_otg_config(0x1); //OTG
64 bq24297_set_boost_lim(0x1); //1.5A on VBUS
65 bq24297_set_en_hiz(0x0);
66 #endif
67
68 #ifdef CONFIG_MTK_BQ24296_SUPPORT
69 bq24296_set_chg_config(0x0); //disable charge
70 bq24296_set_otg_config(0x1); //OTG
71 bq24296_set_boostv(0x7); //boost voltage 4.998V
72 bq24296_set_boost_lim(0x1); //1.5A on VBUS
73 bq24296_set_en_hiz(0x0);
74 #endif
75
76 #ifdef CONFIG_MTK_NCP1851_SUPPORT
77 ncp1851_set_chg_en(0x0); //charger disable
78 ncp1851_set_otg_en(0x1); //otg enable
79 #endif
80
81 #ifdef CONFIG_MTK_NCP1854_SUPPORT
82 ncp1854_set_chg_en(0x0); //charger disable
83 ncp1854_set_otg_en(0x1); //otg enable
84 #endif
85 }
86 else
87 {
88 #ifdef CONFIG_MTK_FAN5405_SUPPORT
89 fan5405_reg_config_interface(0x01,0x30);
90 fan5405_reg_config_interface(0x02,0x8e);
91 #endif
92
93 #ifdef CONFIG_MTK_BQ24158_SUPPORT
94 bq24158_config_interface_liao(0x01,0x30);
95 bq24158_config_interface_liao(0x02,0x8e);
96 #endif
97
98
99 #ifdef CONFIG_MTK_BQ24196_SUPPORT
100 bq24196_set_chg_config(0x0); //OTG & Charge disabled
101 #endif
102
103 #ifdef CONFIG_MTK_BQ24297_SUPPORT
104 bq24297_set_otg_config(0x0); //OTG & Charge disabled
105 #endif
106
107 #ifdef CONFIG_MTK_BQ24296_SUPPORT
108 bq24296_set_otg_config(0x0); //OTG disabled
109 bq24296_set_chg_config(0x0); //Charge disabled
110 #endif
111
112 #ifdef CONFIG_MTK_NCP1851_SUPPORT
113 ncp1851_set_otg_en(0x0);
114 #endif
115
116 #ifdef CONFIG_MTK_NCP1854_SUPPORT
117 ncp1854_set_otg_en(0x0);
118 #endif
119 }
120 };
121 #endif