Lines Matching +full:resistance +full:- +full:temp +full:- +full:table
2 * Copyright (C) ST-Ericsson 2010 - 2013
17 #include <linux/hwmon-sysfs.h>
19 #include <linux/mfd/abx500/ab8500-bm.h>
20 #include <linux/mfd/abx500/ab8500-gpadc.h>
52 * VCC----[ R_up ]-----[ NTC ]----GND
53 * where R_up is pull-up resistance, and GPADC measures voltage on NTC.
54 * and res_to_temp table is strictly sorted by falling resistance values.
57 int v_ntc, int *temp) in ab8500_voltage_to_temp() argument
59 int r_ntc, i = 0, tbl_sz = cfg->tbl_sz; in ab8500_voltage_to_temp()
60 const struct abx500_res_to_temp *tbl = cfg->temp_tbl; in ab8500_voltage_to_temp()
62 if (cfg->vcc < 0 || v_ntc >= cfg->vcc) in ab8500_voltage_to_temp()
63 return -EINVAL; in ab8500_voltage_to_temp()
65 r_ntc = v_ntc * cfg->r_up / (cfg->vcc - v_ntc); in ab8500_voltage_to_temp()
66 if (r_ntc > tbl[0].resist || r_ntc < tbl[tbl_sz - 1].resist) in ab8500_voltage_to_temp()
67 return -EINVAL; in ab8500_voltage_to_temp()
70 i < tbl_sz - 2) in ab8500_voltage_to_temp()
73 /* return milli-Celsius */ in ab8500_voltage_to_temp()
74 *temp = tbl[i].temp * 1000 + ((tbl[i + 1].temp - tbl[i].temp) * 1000 * in ab8500_voltage_to_temp()
75 (r_ntc - tbl[i].resist)) / (tbl[i + 1].resist - tbl[i].resist); in ab8500_voltage_to_temp()
80 static int ab8500_read_sensor(struct abx500_temp *data, u8 sensor, int *temp) in ab8500_read_sensor() argument
83 struct ab8500_temp *ab8500_data = data->plat_data; in ab8500_read_sensor()
86 *temp = ab8500_btemp_get_batctrl_temp(ab8500_data->btemp); in ab8500_read_sensor()
88 *temp = ab8500_btemp_get_temp(ab8500_data->btemp); in ab8500_read_sensor()
90 voltage = ab8500_gpadc_convert(ab8500_data->gpadc, sensor); in ab8500_read_sensor()
94 ret = ab8500_voltage_to_temp(&ab8500_data->cfg, voltage, temp); in ab8500_read_sensor()
106 struct abx500_temp *abx500_data = ab8500_data->abx500_data; in ab8500_thermal_power_off()
108 dev_warn(&abx500_data->pdev->dev, "Power off due to critical temp\n"); in ab8500_thermal_power_off()
124 int index = attr->index; in ab8500_show_label()
140 return -EINVAL; in ab8500_show_label()
148 struct ab8500_temp *ab8500_data = data->plat_data; in ab8500_temp_irq_handler()
150 dev_warn(&data->pdev->dev, "Power off in %d s\n", in ab8500_temp_irq_handler()
153 schedule_delayed_work(&ab8500_data->power_off_work, in ab8500_temp_irq_handler()
162 ab8500_data = devm_kzalloc(&data->pdev->dev, sizeof(*ab8500_data), in abx500_hwmon_init()
165 return -ENOMEM; in abx500_hwmon_init()
167 ab8500_data->gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); in abx500_hwmon_init()
168 if (IS_ERR(ab8500_data->gpadc)) in abx500_hwmon_init()
169 return PTR_ERR(ab8500_data->gpadc); in abx500_hwmon_init()
171 ab8500_data->btemp = ab8500_btemp_get(); in abx500_hwmon_init()
172 if (IS_ERR(ab8500_data->btemp)) in abx500_hwmon_init()
173 return PTR_ERR(ab8500_data->btemp); in abx500_hwmon_init()
175 INIT_DELAYED_WORK(&ab8500_data->power_off_work, in abx500_hwmon_init()
178 ab8500_data->cfg.vcc = THERMAL_VCC; in abx500_hwmon_init()
179 ab8500_data->cfg.r_up = PULL_UP_RESISTOR; in abx500_hwmon_init()
180 ab8500_data->cfg.temp_tbl = ab8500_temp_tbl_a_thermistor; in abx500_hwmon_init()
181 ab8500_data->cfg.tbl_sz = ab8500_temp_tbl_a_size; in abx500_hwmon_init()
183 data->plat_data = ab8500_data; in abx500_hwmon_init()
189 data->gpadc_addr[0] = ADC_AUX1; in abx500_hwmon_init()
190 data->gpadc_addr[1] = ADC_AUX2; in abx500_hwmon_init()
191 data->gpadc_addr[2] = BTEMP_BALL; in abx500_hwmon_init()
192 data->gpadc_addr[3] = BAT_CTRL; in abx500_hwmon_init()
193 data->monitored_sensors = NUM_MONITORED_SENSORS; in abx500_hwmon_init()
195 data->ops.read_sensor = ab8500_read_sensor; in abx500_hwmon_init()
196 data->ops.irq_handler = ab8500_temp_irq_handler; in abx500_hwmon_init()
197 data->ops.show_name = ab8500_show_name; in abx500_hwmon_init()
198 data->ops.show_label = ab8500_show_label; in abx500_hwmon_init()
199 data->ops.is_visible = NULL; in abx500_hwmon_init()