Linux Hardware Monitor development
 help / color / mirror / Atom feed
* [Q] tps65185 EPD PMIC temperature interface - which subsystem
@ 2021-04-30 21:24 Andreas Kemnade
  2021-05-01  3:02 ` Guenter Roeck
  0 siblings, 1 reply; 5+ messages in thread
From: Andreas Kemnade @ 2021-04-30 21:24 UTC (permalink / raw)
  To: linux-iio, jic23, linux-hwmon, linux, jdelvare, kernel, linux-imx
  Cc: Jonathan Neuschäfer, letux-kernel

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?

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-05-02 18:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-04-30 21:24 [Q] tps65185 EPD PMIC temperature interface - which subsystem Andreas Kemnade
2021-05-01  3:02 ` Guenter Roeck
2021-05-01  8:21   ` Andreas Kemnade
2021-05-01 19:05     ` Guenter Roeck
2021-05-02 18:56       ` Andreas Kemnade

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox