Lines Matching refs:gti
27 static int gadc_thermal_adc_to_temp(struct gadc_thermal_info *gti, int val) in gadc_thermal_adc_to_temp() argument
32 for (i = 0; i < gti->nlookup_table; i++) { in gadc_thermal_adc_to_temp()
33 if (val >= gti->lookup_table[2 * i + 1]) in gadc_thermal_adc_to_temp()
38 temp = gti->lookup_table[0]; in gadc_thermal_adc_to_temp()
39 } else if (i >= (gti->nlookup_table - 1)) { in gadc_thermal_adc_to_temp()
40 temp = gti->lookup_table[2 * (gti->nlookup_table - 1)]; in gadc_thermal_adc_to_temp()
42 adc_hi = gti->lookup_table[2 * i - 1]; in gadc_thermal_adc_to_temp()
43 adc_lo = gti->lookup_table[2 * i + 1]; in gadc_thermal_adc_to_temp()
44 temp = gti->lookup_table[2 * i]; in gadc_thermal_adc_to_temp()
53 struct gadc_thermal_info *gti = data; in gadc_thermal_get_temp() local
57 ret = iio_read_channel_processed(gti->channel, &val); in gadc_thermal_get_temp()
59 dev_err(gti->dev, "IIO channel read failed %d\n", ret); in gadc_thermal_get_temp()
62 *temp = gadc_thermal_adc_to_temp(gti, val); in gadc_thermal_get_temp()
72 struct gadc_thermal_info *gti) in gadc_thermal_read_linear_lookup_table() argument
90 gti->lookup_table = devm_kcalloc(dev, in gadc_thermal_read_linear_lookup_table()
91 ntable, sizeof(*gti->lookup_table), in gadc_thermal_read_linear_lookup_table()
93 if (!gti->lookup_table) in gadc_thermal_read_linear_lookup_table()
97 (u32 *)gti->lookup_table, ntable); in gadc_thermal_read_linear_lookup_table()
104 gti->nlookup_table = ntable / 2; in gadc_thermal_read_linear_lookup_table()
111 struct gadc_thermal_info *gti; in gadc_thermal_probe() local
119 gti = devm_kzalloc(&pdev->dev, sizeof(*gti), GFP_KERNEL); in gadc_thermal_probe()
120 if (!gti) in gadc_thermal_probe()
123 ret = gadc_thermal_read_linear_lookup_table(&pdev->dev, gti); in gadc_thermal_probe()
127 gti->dev = &pdev->dev; in gadc_thermal_probe()
128 platform_set_drvdata(pdev, gti); in gadc_thermal_probe()
130 gti->channel = devm_iio_channel_get(&pdev->dev, "sensor-channel"); in gadc_thermal_probe()
131 if (IS_ERR(gti->channel)) { in gadc_thermal_probe()
132 ret = PTR_ERR(gti->channel); in gadc_thermal_probe()
137 gti->tz_dev = devm_thermal_zone_of_sensor_register(&pdev->dev, 0, gti, in gadc_thermal_probe()
139 if (IS_ERR(gti->tz_dev)) { in gadc_thermal_probe()
140 ret = PTR_ERR(gti->tz_dev); in gadc_thermal_probe()