Author Topic: A2x SoC temperature readout  (Read 2980 times)

Offline hds

  • Newbie
  • *
  • Posts: 7
  • Karma: +2/-0
    • View Profile
A2x SoC temperature readout
« on: June 18, 2015, 06:01:36 am »

i've written a short driver to readout the SoC temperature to sysfs.
Access is transparent to the user and the THS (TP) registers are user settable.
When the module is loaded conversion does not start automatically to prevent additional power consumption.
To start the conversion:
echo "0x10000" > /sys/bus/platform/devices/a2x_thermal/ths_en
or load module with param
modprobe a2x_thermal start_on_load=1

Read temperature value:
/sys/bus/platform/devices/a2x_thermal/ths_data and divie by 100.

Module should compile with all major Kernel Versions. Tested on 3.4.107 and 4.1.rc7.

I would like to know if this kind of module makes sense as i'am getting an A80 board within the next days. So this might be more sensible with the octa core or even th A33 quad core SoC.

To compile:
1) Copy source code to a2x_thermal.c and move to linux/drivers/hwmon/a2x_thermal.c
2) Add in linux/drivers/hwmon/Kconfig a new symbol
config A2X_THERMAL
        tristate "A2x SoC TP sensor controller"
        depends on !TOUCHSCREEN_SUN4I_TS
          If you say yes here you get support for the hardware temperature
          monitoring sensor present in the touch screen controller on A2x SoC.
3) Add in linux/drivers/hwmon/Makefile
obj-$(CONFIG_A2X_THERMAL)       += a2x_thermal.o

Start "make menuconfig"
Select: Device Drivers -> Hardware Monitoring -> A2x SoC TP sensor controller

Compile modules, cp to /lib/modules/yourKernelVersion/drivers/hwmon
depmod -a
modinfo a2x_thermal -> should display some infos
modprobe a2x_thermal start_on_load=1
cat /sys/bus/platform/devices/a2x_thermal/ths_data

Maybe you get one or two EAGAIN errors for the start because the ADC needs some time to start running.

Have fun.

Offline actkk2000

  • Hero Member
  • *****
  • Posts: 572
  • Karma: +2/-11
    • View Profile
Re: A2x SoC temperature readout
« Reply #1 on: June 18, 2015, 11:59:15 pm »
Thank you!  ;)