Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) #include <linux/export.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) #include <linux/power_supply.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) #include <linux/of.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) #include <linux/mfd/abx500.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) #include <linux/mfd/abx500/ab8500.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #include <linux/mfd/abx500/ab8500-bm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  * These are the defined batteries that uses a NTC and ID resistor placed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  * inside of the battery pack.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  * Note that the res_to_temp table must be strictly sorted by falling resistance
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  * values to work.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) const struct abx500_res_to_temp ab8500_temp_tbl_a_thermistor[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 	{-5, 53407},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 	{ 0, 48594},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 	{ 5, 43804},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 	{10, 39188},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 	{15, 34870},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 	{20, 30933},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 	{25, 27422},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 	{30, 24347},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 	{35, 21694},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 	{40, 19431},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	{45, 17517},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	{50, 15908},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	{55, 14561},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	{60, 13437},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	{65, 12500},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) EXPORT_SYMBOL(ab8500_temp_tbl_a_thermistor);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) const int ab8500_temp_tbl_a_size = ARRAY_SIZE(ab8500_temp_tbl_a_thermistor);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) EXPORT_SYMBOL(ab8500_temp_tbl_a_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) const struct abx500_res_to_temp ab8500_temp_tbl_b_thermistor[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	{-5, 200000},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	{ 0, 159024},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	{ 5, 151921},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	{10, 144300},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	{15, 136424},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	{20, 128565},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	{25, 120978},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	{30, 113875},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	{35, 107397},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	{40, 101629},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	{45,  96592},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	{50,  92253},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	{55,  88569},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	{60,  85461},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	{65,  82869},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) EXPORT_SYMBOL(ab8500_temp_tbl_b_thermistor);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) const int ab8500_temp_tbl_b_size = ARRAY_SIZE(ab8500_temp_tbl_b_thermistor);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) EXPORT_SYMBOL(ab8500_temp_tbl_b_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) static const struct abx500_v_to_cap cap_tbl_a_thermistor[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	{4171,	100},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	{4114,	 95},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	{4009,	 83},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	{3947,	 74},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	{3907,	 67},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	{3863,	 59},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	{3830,	 56},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	{3813,	 53},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	{3791,	 46},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	{3771,	 33},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	{3754,	 25},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	{3735,	 20},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	{3717,	 17},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	{3681,	 13},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	{3664,	  8},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	{3651,	  6},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	{3635,	  5},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	{3560,	  3},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	{3408,    1},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	{3247,	  0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) static const struct abx500_v_to_cap cap_tbl_b_thermistor[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	{4161,	100},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	{4124,	 98},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	{4044,	 90},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	{4003,	 85},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	{3966,	 80},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	{3933,	 75},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	{3888,	 67},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	{3849,	 60},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	{3813,	 55},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	{3787,	 47},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	{3772,	 30},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	{3751,	 25},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	{3718,	 20},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	{3681,	 16},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	{3660,	 14},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	{3589,	 10},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	{3546,	  7},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	{3495,	  4},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	{3404,	  2},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	{3250,	  0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) static const struct abx500_v_to_cap cap_tbl[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	{4186,	100},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	{4163,	 99},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	{4114,	 95},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	{4068,	 90},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	{3990,	 80},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	{3926,	 70},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	{3898,	 65},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	{3866,	 60},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	{3833,	 55},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	{3812,	 50},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	{3787,	 40},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	{3768,	 30},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	{3747,	 25},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	{3730,	 20},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	{3705,	 15},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	{3699,	 14},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	{3684,	 12},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	{3672,	  9},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	{3657,	  7},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	{3638,	  6},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	{3556,	  4},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	{3424,	  2},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	{3317,	  1},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	{3094,	  0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)  * Note that the res_to_temp table must be strictly sorted by falling
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)  * resistance values to work.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) static const struct abx500_res_to_temp temp_tbl[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	{-5, 214834},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	{ 0, 162943},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	{ 5, 124820},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	{10,  96520},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	{15,  75306},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	{20,  59254},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	{25,  47000},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	{30,  37566},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	{35,  30245},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	{40,  24520},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	{45,  20010},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	{50,  16432},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	{55,  13576},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	{60,  11280},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	{65,   9425},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)  * Note that the batres_vs_temp table must be strictly sorted by falling
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)  * temperature values to work.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) static const struct batres_vs_temp temp_to_batres_tbl_thermistor[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	{ 40, 120},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	{ 30, 135},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	{ 20, 165},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	{ 10, 230},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	{ 00, 325},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	{-10, 445},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	{-20, 595},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)  * Note that the batres_vs_temp table must be strictly sorted by falling
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170)  * temperature values to work.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) static const struct batres_vs_temp temp_to_batres_tbl_ext_thermistor[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	{ 60, 300},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	{ 30, 300},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	{ 20, 300},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	{ 10, 300},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	{ 00, 300},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	{-10, 300},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	{-20, 300},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) /* battery resistance table for LI ION 9100 battery */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) static const struct batres_vs_temp temp_to_batres_tbl_9100[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	{ 60, 180},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	{ 30, 180},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	{ 20, 180},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	{ 10, 180},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	{ 00, 180},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	{-10, 180},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	{-20, 180},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) static struct abx500_battery_type bat_type_thermistor[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	[BATTERY_UNKNOWN] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 		/* First element always represent the UNKNOWN battery */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 		.name = POWER_SUPPLY_TECHNOLOGY_UNKNOWN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 		.resis_high = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 		.resis_low = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 		.battery_resistance = 300,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 		.charge_full_design = 612,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 		.nominal_voltage = 3700,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 		.termination_vol = 4050,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 		.termination_curr = 200,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 		.recharge_cap = 95,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 		.normal_cur_lvl = 400,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 		.normal_vol_lvl = 4100,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 		.maint_a_cur_lvl = 400,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 		.maint_a_vol_lvl = 4050,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 		.maint_a_chg_timer_h = 60,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 		.maint_b_cur_lvl = 400,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 		.maint_b_vol_lvl = 4000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 		.maint_b_chg_timer_h = 200,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 		.low_high_cur_lvl = 300,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 		.low_high_vol_lvl = 4000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 		.n_temp_tbl_elements = ARRAY_SIZE(temp_tbl),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 		.r_to_t_tbl = temp_tbl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 		.n_v_cap_tbl_elements = ARRAY_SIZE(cap_tbl),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 		.v_to_cap_tbl = cap_tbl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 		.n_batres_tbl_elements = ARRAY_SIZE(temp_to_batres_tbl_thermistor),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 		.batres_tbl = temp_to_batres_tbl_thermistor,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 		.name = POWER_SUPPLY_TECHNOLOGY_LIPO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 		.resis_high = 53407,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 		.resis_low = 12500,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 		.battery_resistance = 300,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 		.charge_full_design = 900,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 		.nominal_voltage = 3600,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 		.termination_vol = 4150,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 		.termination_curr = 80,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 		.recharge_cap = 95,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 		.normal_cur_lvl = 700,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 		.normal_vol_lvl = 4200,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 		.maint_a_cur_lvl = 600,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 		.maint_a_vol_lvl = 4150,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 		.maint_a_chg_timer_h = 60,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 		.maint_b_cur_lvl = 600,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 		.maint_b_vol_lvl = 4100,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 		.maint_b_chg_timer_h = 200,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 		.low_high_cur_lvl = 300,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 		.low_high_vol_lvl = 4000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 		.n_temp_tbl_elements = ARRAY_SIZE(ab8500_temp_tbl_a_thermistor),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 		.r_to_t_tbl = ab8500_temp_tbl_a_thermistor,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 		.n_v_cap_tbl_elements = ARRAY_SIZE(cap_tbl_a_thermistor),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 		.v_to_cap_tbl = cap_tbl_a_thermistor,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 		.n_batres_tbl_elements = ARRAY_SIZE(temp_to_batres_tbl_thermistor),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 		.batres_tbl = temp_to_batres_tbl_thermistor,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 		.name = POWER_SUPPLY_TECHNOLOGY_LIPO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 		.resis_high = 200000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 		.resis_low = 82869,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 		.battery_resistance = 300,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 		.charge_full_design = 900,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 		.nominal_voltage = 3600,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 		.termination_vol = 4150,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 		.termination_curr = 80,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 		.recharge_cap = 95,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 		.normal_cur_lvl = 700,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 		.normal_vol_lvl = 4200,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 		.maint_a_cur_lvl = 600,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 		.maint_a_vol_lvl = 4150,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 		.maint_a_chg_timer_h = 60,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 		.maint_b_cur_lvl = 600,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 		.maint_b_vol_lvl = 4100,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 		.maint_b_chg_timer_h = 200,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 		.low_high_cur_lvl = 300,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 		.low_high_vol_lvl = 4000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 		.n_temp_tbl_elements = ARRAY_SIZE(ab8500_temp_tbl_b_thermistor),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 		.r_to_t_tbl = ab8500_temp_tbl_b_thermistor,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 		.n_v_cap_tbl_elements = ARRAY_SIZE(cap_tbl_b_thermistor),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 		.v_to_cap_tbl = cap_tbl_b_thermistor,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 		.n_batres_tbl_elements = ARRAY_SIZE(temp_to_batres_tbl_thermistor),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 		.batres_tbl = temp_to_batres_tbl_thermistor,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) static struct abx500_battery_type bat_type_ext_thermistor[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 	[BATTERY_UNKNOWN] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 		/* First element always represent the UNKNOWN battery */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 		.name = POWER_SUPPLY_TECHNOLOGY_UNKNOWN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 		.resis_high = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 		.resis_low = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 		.battery_resistance = 300,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 		.charge_full_design = 612,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 		.nominal_voltage = 3700,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 		.termination_vol = 4050,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 		.termination_curr = 200,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 		.recharge_cap = 95,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 		.normal_cur_lvl = 400,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 		.normal_vol_lvl = 4100,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 		.maint_a_cur_lvl = 400,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 		.maint_a_vol_lvl = 4050,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 		.maint_a_chg_timer_h = 60,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 		.maint_b_cur_lvl = 400,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 		.maint_b_vol_lvl = 4000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 		.maint_b_chg_timer_h = 200,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 		.low_high_cur_lvl = 300,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 		.low_high_vol_lvl = 4000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 		.n_temp_tbl_elements = ARRAY_SIZE(temp_tbl),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 		.r_to_t_tbl = temp_tbl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 		.n_v_cap_tbl_elements = ARRAY_SIZE(cap_tbl),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 		.v_to_cap_tbl = cap_tbl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 		.n_batres_tbl_elements = ARRAY_SIZE(temp_to_batres_tbl_thermistor),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 		.batres_tbl = temp_to_batres_tbl_thermistor,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309)  * These are the batteries that doesn't have an internal NTC resistor to measure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310)  * its temperature. The temperature in this case is measure with a NTC placed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311)  * near the battery but on the PCB.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 		.name = POWER_SUPPLY_TECHNOLOGY_LIPO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 		.resis_high = 76000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 		.resis_low = 53000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 		.battery_resistance = 300,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 		.charge_full_design = 900,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 		.nominal_voltage = 3700,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 		.termination_vol = 4150,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 		.termination_curr = 100,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 		.recharge_cap = 95,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 		.normal_cur_lvl = 700,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 		.normal_vol_lvl = 4200,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 		.maint_a_cur_lvl = 600,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 		.maint_a_vol_lvl = 4150,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 		.maint_a_chg_timer_h = 60,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 		.maint_b_cur_lvl = 600,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 		.maint_b_vol_lvl = 4100,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 		.maint_b_chg_timer_h = 200,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 		.low_high_cur_lvl = 300,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 		.low_high_vol_lvl = 4000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 		.n_temp_tbl_elements = ARRAY_SIZE(temp_tbl),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 		.r_to_t_tbl = temp_tbl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 		.n_v_cap_tbl_elements = ARRAY_SIZE(cap_tbl),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 		.v_to_cap_tbl = cap_tbl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 		.n_batres_tbl_elements = ARRAY_SIZE(temp_to_batres_tbl_thermistor),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 		.batres_tbl = temp_to_batres_tbl_thermistor,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 		.name = POWER_SUPPLY_TECHNOLOGY_LION,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 		.resis_high = 30000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 		.resis_low = 10000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 		.battery_resistance = 300,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 		.charge_full_design = 950,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 		.nominal_voltage = 3700,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 		.termination_vol = 4150,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 		.termination_curr = 100,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 		.recharge_cap = 95,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 		.normal_cur_lvl = 700,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 		.normal_vol_lvl = 4200,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 		.maint_a_cur_lvl = 600,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 		.maint_a_vol_lvl = 4150,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 		.maint_a_chg_timer_h = 60,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 		.maint_b_cur_lvl = 600,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 		.maint_b_vol_lvl = 4100,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 		.maint_b_chg_timer_h = 200,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 		.low_high_cur_lvl = 300,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 		.low_high_vol_lvl = 4000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 		.n_temp_tbl_elements = ARRAY_SIZE(temp_tbl),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 		.r_to_t_tbl = temp_tbl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 		.n_v_cap_tbl_elements = ARRAY_SIZE(cap_tbl),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 		.v_to_cap_tbl = cap_tbl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 		.n_batres_tbl_elements = ARRAY_SIZE(temp_to_batres_tbl_thermistor),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 		.batres_tbl = temp_to_batres_tbl_thermistor,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 		.name = POWER_SUPPLY_TECHNOLOGY_LION,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 		.resis_high = 95000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 		.resis_low = 76001,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 		.battery_resistance = 300,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 		.charge_full_design = 950,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 		.nominal_voltage = 3700,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 		.termination_vol = 4150,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 		.termination_curr = 100,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 		.recharge_cap = 95,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 		.normal_cur_lvl = 700,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 		.normal_vol_lvl = 4200,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 		.maint_a_cur_lvl = 600,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 		.maint_a_vol_lvl = 4150,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 		.maint_a_chg_timer_h = 60,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 		.maint_b_cur_lvl = 600,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 		.maint_b_vol_lvl = 4100,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 		.maint_b_chg_timer_h = 200,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 		.low_high_cur_lvl = 300,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 		.low_high_vol_lvl = 4000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 		.n_temp_tbl_elements = ARRAY_SIZE(temp_tbl),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 		.r_to_t_tbl = temp_tbl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 		.n_v_cap_tbl_elements = ARRAY_SIZE(cap_tbl),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 		.v_to_cap_tbl = cap_tbl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 		.n_batres_tbl_elements = ARRAY_SIZE(temp_to_batres_tbl_thermistor),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 		.batres_tbl = temp_to_batres_tbl_thermistor,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) static const struct abx500_bm_capacity_levels cap_levels = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 	.critical	= 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 	.low		= 10,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 	.normal		= 70,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 	.high		= 95,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 	.full		= 100,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) static const struct abx500_fg_parameters fg = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 	.recovery_sleep_timer = 10,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 	.recovery_total_time = 100,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 	.init_timer = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 	.init_discard_time = 5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 	.init_total_time = 40,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 	.high_curr_time = 60,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 	.accu_charging = 30,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 	.accu_high_curr = 30,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 	.high_curr_threshold = 50,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 	.lowbat_threshold = 3100,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 	.battok_falling_th_sel0 = 2860,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 	.battok_raising_th_sel1 = 2860,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 	.maint_thres = 95,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 	.user_cap_limit = 15,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 	.pcut_enable = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 	.pcut_max_time = 127,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 	.pcut_flag_time = 112,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 	.pcut_max_restart = 15,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 	.pcut_debounce_time = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) static const struct abx500_maxim_parameters ab8500_maxi_params = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 	.ena_maxi = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 	.chg_curr = 910,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 	.wait_cycles = 10,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 	.charger_curr_step = 100,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) static const struct abx500_bm_charger_parameters chg = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 	.usb_volt_max		= 5500,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 	.usb_curr_max		= 1500,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 	.ac_volt_max		= 7500,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 	.ac_curr_max		= 1500,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441)  * This array maps the raw hex value to charger output current used by the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442)  * AB8500 values
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) static int ab8500_charge_output_curr_map[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445)         100,    200,    300,    400,    500,    600,    700,    800,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446)         900,    1000,   1100,   1200,   1300,   1400,   1500,   1500,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450)  * This array maps the raw hex value to charger input current used by the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451)  * AB8500 values
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) static int ab8500_charge_input_curr_map[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454)         50,     98,     193,    290,    380,    450,    500,    600,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455)         700,    800,    900,    1000,   1100,   1300,   1400,   1500,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) struct abx500_bm_data ab8500_bm_data = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 	.temp_under             = 3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 	.temp_low               = 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 	.temp_high              = 43,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) 	.temp_over              = 48,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) 	.main_safety_tmr_h      = 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) 	.temp_interval_chg      = 20,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 	.temp_interval_nochg    = 120,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) 	.usb_safety_tmr_h       = 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 	.bkup_bat_v             = BUP_VCH_SEL_2P6V,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 	.bkup_bat_i             = BUP_ICH_SEL_150UA,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) 	.no_maintenance         = false,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 	.capacity_scaling       = false,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) 	.adc_therm              = ABx500_ADC_THERM_BATCTRL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) 	.chg_unknown_bat        = false,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) 	.enable_overshoot       = false,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) 	.fg_res                 = 100,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) 	.cap_levels             = &cap_levels,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) 	.bat_type               = bat_type_thermistor,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) 	.n_btypes               = ARRAY_SIZE(bat_type_thermistor),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) 	.batt_id                = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) 	.interval_charging      = 5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) 	.interval_not_charging  = 120,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) 	.temp_hysteresis        = 3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) 	.gnd_lift_resistance    = 34,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) 	.chg_output_curr        = ab8500_charge_output_curr_map,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) 	.n_chg_out_curr         = ARRAY_SIZE(ab8500_charge_output_curr_map),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) 	.maxi                   = &ab8500_maxi_params,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) 	.chg_params             = &chg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) 	.fg_params              = &fg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488)         .chg_input_curr         = ab8500_charge_input_curr_map,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489)         .n_chg_in_curr          = ARRAY_SIZE(ab8500_charge_input_curr_map),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) int ab8500_bm_of_probe(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) 		       struct device_node *np,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) 		       struct abx500_bm_data *bm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) 	const struct batres_vs_temp *tmp_batres_tbl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) 	struct device_node *battery_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) 	const char *btech;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) 	/* get phandle to 'battery-info' node */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) 	battery_node = of_parse_phandle(np, "battery", 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) 	if (!battery_node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) 		dev_err(dev, "battery node or reference missing\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) 	btech = of_get_property(battery_node, "stericsson,battery-type", NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) 	if (!btech) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) 		dev_warn(dev, "missing property battery-name/type\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) 		of_node_put(battery_node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) 	if (strncmp(btech, "LION", 4) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) 		bm->no_maintenance  = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) 		bm->chg_unknown_bat = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) 		bm->bat_type[BATTERY_UNKNOWN].charge_full_design = 2600;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) 		bm->bat_type[BATTERY_UNKNOWN].termination_vol    = 4150;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) 		bm->bat_type[BATTERY_UNKNOWN].recharge_cap       = 95;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) 		bm->bat_type[BATTERY_UNKNOWN].normal_cur_lvl     = 520;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) 		bm->bat_type[BATTERY_UNKNOWN].normal_vol_lvl     = 4200;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) 	if (of_property_read_bool(battery_node, "thermistor-on-batctrl")) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) 		if (strncmp(btech, "LION", 4) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) 			tmp_batres_tbl = temp_to_batres_tbl_9100;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) 			tmp_batres_tbl = temp_to_batres_tbl_thermistor;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) 		bm->n_btypes   = 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) 		bm->bat_type   = bat_type_ext_thermistor;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) 		bm->adc_therm  = ABx500_ADC_THERM_BATTEMP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) 		tmp_batres_tbl = temp_to_batres_tbl_ext_thermistor;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) 	/* select the battery resolution table */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) 	for (i = 0; i < bm->n_btypes; ++i)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) 		bm->bat_type[i].batres_tbl = tmp_batres_tbl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) 	of_node_put(battery_node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) }