H A D | ntc_thermistor.c | 45 unsigned int ohm; member in struct:ntc_compensation 60 * A compensation table should be sorted by the values of .ohm 66 { .temp_c = -40, .ohm = 1747920 }, 67 { .temp_c = -35, .ohm = 1245428 }, 68 { .temp_c = -30, .ohm = 898485 }, 69 { .temp_c = -25, .ohm = 655802 }, 70 { .temp_c = -20, .ohm = 483954 }, 71 { .temp_c = -15, .ohm = 360850 }, 72 { .temp_c = -10, .ohm = 271697 }, 73 { .temp_c = -5, .ohm = 206463 }, 74 { .temp_c = 0, .ohm = 158214 }, 75 { .temp_c = 5, .ohm = 122259 }, 76 { .temp_c = 10, .ohm = 95227 }, 77 { .temp_c = 15, .ohm = 74730 }, 78 { .temp_c = 20, .ohm = 59065 }, 79 { .temp_c = 25, .ohm = 47000 }, 80 { .temp_c = 30, .ohm = 37643 }, 81 { .temp_c = 35, .ohm = 30334 }, 82 { .temp_c = 40, .ohm = 24591 }, 83 { .temp_c = 45, .ohm = 20048 }, 84 { .temp_c = 50, .ohm = 16433 }, 85 { .temp_c = 55, .ohm = 13539 }, 86 { .temp_c = 60, .ohm = 11209 }, 87 { .temp_c = 65, .ohm = 9328 }, 88 { .temp_c = 70, .ohm = 7798 }, 89 { .temp_c = 75, .ohm = 6544 }, 90 { .temp_c = 80, .ohm = 5518 }, 91 { .temp_c = 85, .ohm = 4674 }, 92 { .temp_c = 90, .ohm = 3972 }, 93 { .temp_c = 95, .ohm = 3388 }, 94 { .temp_c = 100, .ohm = 2902 }, 95 { .temp_c = 105, .ohm = 2494 }, 96 { .temp_c = 110, .ohm = 2150 }, 97 { .temp_c = 115, .ohm = 1860 }, 98 { .temp_c = 120, .ohm = 1615 }, 99 { .temp_c = 125, .ohm = 1406 }, 102 { .temp_c = -40, .ohm = 1610154 }, 103 { .temp_c = -35, .ohm = 1130850 }, 104 { .temp_c = -30, .ohm = 802609 }, 105 { .temp_c = -25, .ohm = 575385 }, 106 { .temp_c = -20, .ohm = 416464 }, 107 { .temp_c = -15, .ohm = 304219 }, 108 { .temp_c = -10, .ohm = 224193 }, 109 { .temp_c = -5, .ohm = 166623 }, 110 { .temp_c = 0, .ohm = 124850 }, 111 { .temp_c = 5, .ohm = 94287 }, 112 { .temp_c = 10, .ohm = 71747 }, 113 { .temp_c = 15, .ohm = 54996 }, 114 { .temp_c = 20, .ohm = 42455 }, 115 { .temp_c = 25, .ohm = 33000 }, 116 { .temp_c = 30, .ohm = 25822 }, 117 { .temp_c = 35, .ohm = 20335 }, 118 { .temp_c = 40, .ohm = 16115 }, 119 { .temp_c = 45, .ohm = 12849 }, 120 { .temp_c = 50, .ohm = 10306 }, 121 { .temp_c = 55, .ohm = 8314 }, 122 { .temp_c = 60, .ohm = 6746 }, 123 { .temp_c = 65, .ohm = 5503 }, 124 { .temp_c = 70, .ohm = 4513 }, 125 { .temp_c = 75, .ohm = 3721 }, 126 { .temp_c = 80, .ohm = 3084 }, 127 { .temp_c = 85, .ohm = 2569 }, 128 { .temp_c = 90, .ohm = 2151 }, 129 { .temp_c = 95, .ohm = 1809 }, 130 { .temp_c = 100, .ohm = 1529 }, 131 { .temp_c = 105, .ohm = 1299 }, 132 { .temp_c = 110, .ohm = 1108 }, 133 { .temp_c = 115, .ohm = 949 }, 134 { .temp_c = 120, .ohm = 817 }, 135 { .temp_c = 125, .ohm = 707 }, 143 { .temp_c = -40, .ohm = 190030 }, 144 { .temp_c = -35, .ohm = 145360 }, 145 { .temp_c = -30, .ohm = 112060 }, 146 { .temp_c = -25, .ohm = 87041 }, 147 { .temp_c = -20, .ohm = 68104 }, 148 { .temp_c = -15, .ohm = 53665 }, 149 { .temp_c = -10, .ohm = 42576 }, 150 { .temp_c = -5, .ohm = 34001 }, 151 { .temp_c = 0, .ohm = 27326 }, 152 { .temp_c = 5, .ohm = 22096 }, 153 { .temp_c = 10, .ohm = 17973 }, 154 { .temp_c = 15, .ohm = 14703 }, 155 { .temp_c = 20, .ohm = 12090 }, 156 { .temp_c = 25, .ohm = 10000 }, 157 { .temp_c = 30, .ohm = 8311 }, 158 { .temp_c = 35, .ohm = 6941 }, 159 { .temp_c = 40, .ohm = 5825 }, 160 { .temp_c = 45, .ohm = 4911 }, 161 { .temp_c = 50, .ohm = 4158 }, 162 { .temp_c = 55, .ohm = 3536 }, 163 { .temp_c = 60, .ohm = 3019 }, 164 { .temp_c = 65, .ohm = 2588 }, 165 { .temp_c = 70, .ohm = 2227 }, 166 { .temp_c = 75, .ohm = 1924 }, 167 { .temp_c = 80, .ohm = 1668 }, 168 { .temp_c = 85, .ohm = 1451 }, 169 { .temp_c = 90, .ohm = 1266 }, 170 { .temp_c = 95, .ohm = 1108 }, 171 { .temp_c = 100, .ohm = 973 }, 172 { .temp_c = 105, .ohm = 857 }, 173 { .temp_c = 110, .ohm = 757 }, 174 { .temp_c = 115, .ohm = 671 }, 175 { .temp_c = 120, .ohm = 596 }, 176 { .temp_c = 125, .ohm = 531 }, 267 if (of_property_read_u32(np, "pullup-ohm", &pdata->pullup_ohm)) ntc_thermistor_parse_dt() 269 if (of_property_read_u32(np, "pulldown-ohm", &pdata->pulldown_ohm)) ntc_thermistor_parse_dt() 342 static void lookup_comp(struct ntc_data *data, unsigned int ohm, lookup_comp() argument 354 if (ohm >= data->comp[0].ohm) { lookup_comp() 359 if (ohm <= data->comp[data->n_comp - 1].ohm) { lookup_comp() 372 * data->comp[start].ohm > ohm >= data->comp[end].ohm lookup_comp() 374 * We could check for "ohm == data->comp[mid].ohm" here, but lookup_comp() 379 if (ohm >= data->comp[mid].ohm) { lookup_comp() 384 * ohm >= data->comp[start].ohm might be true here, lookup_comp() 389 if (ohm >= data->comp[start].ohm) lookup_comp() 394 * data->comp[start].ohm >= ohm >= data->comp[end].ohm lookup_comp() 399 * ohm >= data->comp[end].ohm lookup_comp() 402 if (ohm == data->comp[end].ohm) lookup_comp() 408 static int get_temp_mc(struct ntc_data *data, unsigned int ohm) get_temp_mc() argument 413 lookup_comp(data, ohm, &low, &high); get_temp_mc() 420 1000 * ((int)ohm - (int)data->comp[low].ohm)) / get_temp_mc() 421 ((int)data->comp[high].ohm - (int)data->comp[low].ohm); get_temp_mc() 445 int ohm; ntc_read_temp() local 447 ohm = ntc_thermistor_get_ohm(data); ntc_read_temp() 448 if (ohm < 0) ntc_read_temp() 449 return ohm; ntc_read_temp() 451 *temp = get_temp_mc(data, ohm); ntc_read_temp() 474 int ohm; ntc_show_temp() local 476 ohm = ntc_thermistor_get_ohm(data); ntc_show_temp() 477 if (ohm < 0) ntc_show_temp() 478 return ohm; ntc_show_temp() 480 return sprintf(buf, "%d\n", get_temp_mc(data, ohm)); ntc_show_temp()
|