• Home
  • Raw
  • Download

Lines Matching +full:temperature +full:- +full:lookup +full:- +full:table

1 // SPDX-License-Identifier: GPL-2.0-only
29 if (!gti->lookup_table) in gadc_thermal_adc_to_temp()
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) { 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()
45 temp_hi = gti->lookup_table[2 * i - 2]; in gadc_thermal_adc_to_temp()
46 temp_lo = gti->lookup_table[2 * i]; in gadc_thermal_adc_to_temp()
48 temp = temp_hi + mult_frac(temp_lo - temp_hi, val - adc_hi, in gadc_thermal_adc_to_temp()
49 adc_lo - adc_hi); in gadc_thermal_adc_to_temp()
61 ret = iio_read_channel_processed(gti->channel, &val); in gadc_thermal_get_temp()
63 dev_err(gti->dev, "IIO channel read failed %d\n", ret); in gadc_thermal_get_temp()
78 struct device_node *np = dev->of_node; in gadc_thermal_read_linear_lookup_table()
83 ntable = of_property_count_elems_of_size(np, "temperature-lookup-table", in gadc_thermal_read_linear_lookup_table()
86 ret = iio_get_channel_type(gti->channel, &chan_type); in gadc_thermal_read_linear_lookup_table()
89 "no lookup table, assuming DAC channel returns milliCelcius\n"); in gadc_thermal_read_linear_lookup_table()
94 dev_err(dev, "Pair of temperature vs ADC read value missing\n"); in gadc_thermal_read_linear_lookup_table()
95 return -EINVAL; in gadc_thermal_read_linear_lookup_table()
98 gti->lookup_table = devm_kcalloc(dev, in gadc_thermal_read_linear_lookup_table()
99 ntable, sizeof(*gti->lookup_table), in gadc_thermal_read_linear_lookup_table()
101 if (!gti->lookup_table) in gadc_thermal_read_linear_lookup_table()
102 return -ENOMEM; in gadc_thermal_read_linear_lookup_table()
104 ret = of_property_read_u32_array(np, "temperature-lookup-table", in gadc_thermal_read_linear_lookup_table()
105 (u32 *)gti->lookup_table, ntable); in gadc_thermal_read_linear_lookup_table()
107 dev_err(dev, "Failed to read temperature lookup table: %d\n", in gadc_thermal_read_linear_lookup_table()
112 gti->nlookup_table = ntable / 2; in gadc_thermal_read_linear_lookup_table()
122 if (!pdev->dev.of_node) { in gadc_thermal_probe()
123 dev_err(&pdev->dev, "Only DT based supported\n"); in gadc_thermal_probe()
124 return -ENODEV; in gadc_thermal_probe()
127 gti = devm_kzalloc(&pdev->dev, sizeof(*gti), GFP_KERNEL); in gadc_thermal_probe()
129 return -ENOMEM; in gadc_thermal_probe()
131 gti->channel = devm_iio_channel_get(&pdev->dev, "sensor-channel"); in gadc_thermal_probe()
132 if (IS_ERR(gti->channel)) { in gadc_thermal_probe()
133 ret = PTR_ERR(gti->channel); in gadc_thermal_probe()
134 if (ret != -EPROBE_DEFER) in gadc_thermal_probe()
135 dev_err(&pdev->dev, "IIO channel not found: %d\n", ret); in gadc_thermal_probe()
139 ret = gadc_thermal_read_linear_lookup_table(&pdev->dev, gti); in gadc_thermal_probe()
143 gti->dev = &pdev->dev; in gadc_thermal_probe()
146 gti->tz_dev = devm_thermal_zone_of_sensor_register(&pdev->dev, 0, gti, in gadc_thermal_probe()
148 if (IS_ERR(gti->tz_dev)) { in gadc_thermal_probe()
149 ret = PTR_ERR(gti->tz_dev); in gadc_thermal_probe()
150 if (ret != -EPROBE_DEFER) in gadc_thermal_probe()
151 dev_err(&pdev->dev, in gadc_thermal_probe()
161 { .compatible = "generic-adc-thermal", },
168 .name = "generic-adc-thermal",