Lines Matching refs:gti

26 static int gadc_thermal_adc_to_temp(struct gadc_thermal_info *gti, int val)  in gadc_thermal_adc_to_temp()  argument
31 if (!gti->lookup_table) in gadc_thermal_adc_to_temp()
34 for (i = 0; i < gti->nlookup_table; i++) { in gadc_thermal_adc_to_temp()
35 if (val >= gti->lookup_table[2 * i + 1]) in gadc_thermal_adc_to_temp()
40 temp = gti->lookup_table[0]; in gadc_thermal_adc_to_temp()
41 } else if (i >= gti->nlookup_table) { in gadc_thermal_adc_to_temp()
42 temp = gti->lookup_table[2 * (gti->nlookup_table - 1)]; in gadc_thermal_adc_to_temp()
44 adc_hi = gti->lookup_table[2 * i - 1]; in gadc_thermal_adc_to_temp()
45 adc_lo = gti->lookup_table[2 * i + 1]; in gadc_thermal_adc_to_temp()
47 temp_hi = gti->lookup_table[2 * i - 2]; in gadc_thermal_adc_to_temp()
48 temp_lo = gti->lookup_table[2 * i]; in gadc_thermal_adc_to_temp()
59 struct gadc_thermal_info *gti = thermal_zone_device_priv(tz); in gadc_thermal_get_temp() local
63 ret = iio_read_channel_processed(gti->channel, &val); in gadc_thermal_get_temp()
67 *temp = gadc_thermal_adc_to_temp(gti, val); in gadc_thermal_get_temp()
77 struct gadc_thermal_info *gti) in gadc_thermal_read_linear_lookup_table() argument
87 ret = iio_get_channel_type(gti->channel, &chan_type); in gadc_thermal_read_linear_lookup_table()
99 gti->lookup_table = devm_kcalloc(dev, in gadc_thermal_read_linear_lookup_table()
100 ntable, sizeof(*gti->lookup_table), in gadc_thermal_read_linear_lookup_table()
102 if (!gti->lookup_table) in gadc_thermal_read_linear_lookup_table()
106 (u32 *)gti->lookup_table, ntable); in gadc_thermal_read_linear_lookup_table()
113 gti->nlookup_table = ntable / 2; in gadc_thermal_read_linear_lookup_table()
121 struct gadc_thermal_info *gti; in gadc_thermal_probe() local
129 gti = devm_kzalloc(dev, sizeof(*gti), GFP_KERNEL); in gadc_thermal_probe()
130 if (!gti) in gadc_thermal_probe()
133 gti->channel = devm_iio_channel_get(dev, "sensor-channel"); in gadc_thermal_probe()
134 if (IS_ERR(gti->channel)) in gadc_thermal_probe()
135 return dev_err_probe(dev, PTR_ERR(gti->channel), "IIO channel not found\n"); in gadc_thermal_probe()
137 ret = gadc_thermal_read_linear_lookup_table(dev, gti); in gadc_thermal_probe()
141 gti->dev = dev; in gadc_thermal_probe()
143 gti->tz_dev = devm_thermal_of_zone_register(dev, 0, gti, in gadc_thermal_probe()
145 if (IS_ERR(gti->tz_dev)) { in gadc_thermal_probe()
146 ret = PTR_ERR(gti->tz_dev); in gadc_thermal_probe()
154 devm_thermal_add_hwmon_sysfs(dev, gti->tz_dev); in gadc_thermal_probe()