TDA4VH-Q1: Adding thermistor using generic-adc-thermal driver to tscadc

Part Number: TDA4VH-Q1

Tool/software:

Hello,

I'm trying to add the generic-adc-thermal driver for reading a thermistor off the tscadc driver.  That way the linux kernel automatically handles the ADC count to mC reading through the lookup table in the device tree.  The thermistor is tied to tscadc0 input 6.  Here is the device tree portion being added.

board_thermistor: thermal-sensor {
   compatible = "generic-adc-thermal";
   #thermal-sensor-cells = <0>;
   io-channels = <&tscadc0 6>;
   io-channel-names = "sensor-channel";
   temperature-lookup-table = < (-55000) 4093
                                (-54000) 4093
                                 ...
                                  150000 465>;
};

The error I'm getting

platform thermal-sensor: deferred probe pending: generic-adc-thermal: IIO channel not found

Is there something I'm doing wrong?  Is there an example of how to do this with the tscadc driver?

Thanks,

Jason

  • Hi Jason,

    We do not support generic-adc-thermal driver in the SDK.

    From the failure log:

    platform thermal-sensor: deferred probe pending: generic-adc-thermal: IIO channel not found

    The failure is from:

    static int gadc_thermal_probe(struct platform_device *pdev)
    {
    struct gadc_thermal_info *gti;
    int ret;

    if (!pdev->dev.of_node) {
    dev_err(&pdev->dev, "Only DT based supported\n");
    return -ENODEV;
    }

    gti = devm_kzalloc(&pdev->dev, sizeof(*gti), GFP_KERNEL);
    if (!gti)
    return -ENOMEM;

    gti->channel = devm_iio_channel_get(&pdev->dev, "sensor-channel");
    if (IS_ERR(gti->channel)) {
    ret = PTR_ERR(gti->channel);
    if (ret != -EPROBE_DEFER)
    dev_err(&pdev->dev, "IIO channel not found: %d\n", ret);
    return ret;
    }

    So there is an unmet dependency in the probe path. That needs to be taken care to avoid the probe-deferral.

    Seems like tscadc which is hooked as 

    io-channels = <&tscadc0 6>;

    is not probed correctly and hence the dependency is not met.

    - Keerthy

  • Hi Keerthy,

    Yes, I was aware where it was failing in thermal-generic-adc.c

    We are not using the SDK but instead building a custom kernel using the TI support in the kernel (6.13).  We have the tscadc0 setup properly and can read the raw adc count properly.  The device tree setting for the generic-adc-thermal is pointing back to the 6th tscadc channel, but for some reason the linkage doesn't properly occur.

    # pwd
    /proc/device-tree/thermal-sensor

    # cat io-channel-names
    sensor-channel

    # hexdump -C io-channels
    00000000 00 00 00 83 00 00 00 06

    This seems to be the correct channel and phandle to use.

    # pwd
    /proc/device-tree/bus@100000/bus@28380000/tscadc@40200000

    # hexdump -C phandle
    00000000 00 00 00 83

    For some reason the linkage between the thermal-generic-adc and the tscadc isn't occuring properly.

    Is this something TI could try and provide documentation on how to support?

    Thanks,

    Jason

  • Also initially I was getting the following error at bootup:

    [ 1.080481] OF: /thermal-sensor: could not get #io-channel-cells for /bus@100000/bus@28380000/tscadc@40200000
    [ 1.080505] generic-adc-thermal thermal-sensor: error -EINVAL: IIO channel not found
    [ 1.080510] generic-adc-thermal thermal-sensor: probe with driver generic-adc-thermal failed with error -22

    So I added 

    #io-channel-cells = <1>;

    to the file arch/arm64/boot/dts/ti/k3-j784s4-j742s2-mcu-wakeup-common.dtsi

    under 

    tscadc0: tscadc@40200000 {

    Then the error 

    platform thermal-sensor: deferred probe pending: generic-adc-thermal: IIO channel not found

    occurred.

  • Hello Jason,

    Can you check if the tscadc driver probe succeeded or was it ever probed?

    - Keerthy

  • Hi Keerthy,

    Sorry for the confusion.  tscadc works fine.  I'm able to read the adc values.  adc5 is our main system voltage while adc6 is the thermistor.  adc5 is the correct value, so I would assume adc6 is as well.

    # pwd
    /sys/bus/iio/devices/iio:device0
    # cat in_voltage5_raw
    1624
    # cat in_voltage6_raw
    3403

    It's the tie between the tscadc and generic-adc-thermal that I can't figure out.

    Thanks,

    Jason

  • Jason,

    We don't have a way to reproduce this on the EVM. Need to check if tscadc is probed before the generic adc is probed. Basically if the tscadc is probed after then it will result in the error as the dependency is not met. 

    Best Regards,

    Keerthy 

  • Keerthy,

    I think it could be tested on an EVM.  The J784S4XG01EVM exposes the ADC to J27.  The generic-adc-thermal device tree entry could be added for one of these channels.  It could be a simple two entry table.  Something like

    temperature-lookup-table = < 0 4093
    100000 465>;

    with the rest of the generic-adc-thermal device tree content.  This would mean that near 1.8V would be 0 degC and near 0V would be 100 degC.  

    An example of how to do this would be extremely helpful to me and probably others.

    Thanks,

    Jason

  • Jason,

    Allow me some time. I will check and get back mid of next week.

    - Keerthy

  • Jason,

    Apologies for the long delay. There is no example right now on TI dts for this. I checked internally on this but we do not have experience on the generic-adc-thermal driver.

    - Keerthy

  • Is this something that TI could support with built in ADC with an example?  I would think that would a common use case of the ADC.  The generic-adc-thermal driver itself seems to be fairly straightforward.

  • Jason,

    I will check with the development team and get back in a couple of days.

    - Keerthy

  • Jason,

    This is the first request on generic-adc-thermal. Hence we never had software support on this. I will check if we can give an out of tree patch.
    I could not get to this earlier. I will get back to you early next week.

    - Keerthy

  • No worries.  Thanks for looking into it!

  • Jason,

    Let us continue in this thread as the thread has context.

    I would like to close the new thread: TDA4VH-Q1: TDA4VH-Q1: Adding thermistor using generic-adc-thermal driver to tscadc

    - Keerthy

  • Thanks.  Can you provide a status update?

  • Jason,

    This is not coming in the 11.1 SDK. I will keep you posted on which this gets planned for. This request is unique on TSCADC.

    - Keerthy