Re: [Q] tps65185 EPD PMIC temperature interface - which subsystem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Apr 30, 2021 at 11:24:04PM +0200, Andreas Kemnade wrote:
> Hi,
> 
> I am going about to clean up stuff to further upstream support for my
> ebook readers. One question arises about the temperature interface of
> the EPD PMIC. Vendor code uses regulator_get_voltage in the EPDC
> driver to read a temperature in celsius and provides temperature through
> the regulator interface (besides sysfs/hwmon). That is ugly. But what
> are the options, if a kernel consumer should be able to reference it via
> devicetree phandle and read out from it? I see temperature sensors
> both in the iio and the hwmon subsystem, but do not find a description
> why these things are there. If I put it into the iio-subsystem
> iio_channel_get() and friends can be used, if I understand things
> correctly, there are no such functions in the hwmon subsystem, so I
> would not be able to use it there. So the better choice is to put it
> into the iio subsystem?
> 

I am guessing a bit here since a lot of context is missing. Presumably
there is a regulator driver. That regulator driver could register itself
with the hwmon subsystem using [devm_]hwmon_device_register_with_info()
and tell it to register a thermal zone sensor. It should then be possible
to read the temperature of that sensor using thermal_zone_get_temp().

Guenter

> On the consumer side, the temperature, which is pratically the ambient
> temperature, is used to choose the right waveform for the corresponding
> temperature range. Here are some code snippets in the vendor kernel:
> 
> temperature = regulator_get_voltage(fb_data->tmst_regulator);
> dev_dbg(fb_data->dev, "auto temperature reading = %d\n", temperature);
> 
> if (temperature != 0xFF) {
> 	fb_data->last_time_temp_auto_update = now;
> 	fb_data->temp_index = mxc_epdc_fb_get_temp_index(fb_data, temperature);
> }
> 
> static int mxc_epdc_fb_get_temp_index(struct mxc_epdc_fb_data *fb_data, int temp
> )
> {
>         int i;
>         int index = -1;
> 
>         if (fb_data->trt_entries == 0) {
>                 dev_err(fb_data->dev,
>                         "No TRT exists...using default temp index\n");
>                 return DEFAULT_TEMP_INDEX;
>         }
> 
>         /* Search temperature ranges for a match */
>         for (i = 0; i < fb_data->trt_entries - 1; i++) {
>                 if ((temp >= fb_data->temp_range_bounds[i])
>                         && (temp < fb_data->temp_range_bounds[i+1])) {
>                         index = i;
>                         break;
>                 }
>         }
> 
> ... and writing that index to some register in the EPDC.
> 
> As the consumer is not upstream (I have a basic drm-based variant also
> in my clean-up queue), compatibilty to existing systems does not matter
> that much. Also I see no drivers for similar chips upstream.
> 
> Regards,
> Andreas



[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux