Accessing temperature sensor


I am working on a kernel module to access temperature sensor. I saw that the address of the sensor is 0xFFF30000, however when I try to read from this address it always show the same value. Am I missing something? is it even possible to do with a kernel module?
ps. when writting my module I based it on the hisi_thermal driver so I don’t think there is a problem with it. I am also using AOSP.


You’re going to have to provide more details. To start with, what temperature sensor are you trying to use? You say you’re working with AOSP – are you trying to provide it as a user-accessible sensor? If so, forget about kernel modules and just write a HAL with a userspace driver. What is the interface that the sensor is connected with? Is this an onboard sensor or an external sensor?

I am trying to do measurement from kernel space directly and I am using the internal sensor of the board. I went through the device tree to get the information on the physical address.

So I managed to get the temperature. I made a mistake and used the offset of the hi6XXX instead of the offeset of Hi3660. However, I can’t find the offset to configure the pooling time. Is it possible to do on the the Hikey? also, is it possible to change the configuration of the ADC for the temperature sensor of the cluster 0 and 1?

Why not relying on existing driver: drivers/thermal/hisi_thermal.c

I did refer to the file but it does not specify a way to change the pooling time for the Hikey960

That’s probably because it doesn’t use polling.

It reads the sensor value on demand, and receives interrupts from the sensor.

On Hikey960, the thermal sensor registers are managed by MCU firmware, so this is why we don’t really access the thermal hardware registers from application processors.

I think below dts properties can be changed for polling time in the file arch/arm64/boot/dts/hisilicon/hi3660.dtsi:

1111                 thermal-zones {
1113                         cls0: cls0 {
1114                                 polling-delay = <1000>; 
1115                                 polling-delay-passive = <100>;