Hi Alex,

On Tue, 30 Jul 2019 at 01:15, @lex <alex.mob...@gmail.com> wrote:
>
> Clément,
>
> I gave it a try but still something missing.
>
> cat /sys/class/thermal/thermal_zone0/temp
> 22506
> cat /sys/class/thermal/thermal_zone0/temp
> 22471
> cat /sys/class/thermal/thermal_zone0/temp
> 22471
> cat /sys/class/thermal/thermal_zone0/temp
> 22480
> cat /sys/class/thermal/thermal_zone0/temp
> 22471
> cat /sys/class/thermal/thermal_zone0/temp
> 22462
>
>
> #define MULPA                   (u32)(0.1125*1024*1024)
> #define DIVPA                   (20)
> #define MINUPA                  (250*1024*1024)
>
>
>
> static int sun8i_ths_get_temp(void *_data, int *out)
> {
>  struct sun8i_ths_data *data = _data;
>  s32 reg;
>
>  if (data->temp == 0)
>      return -EBUSY;
>
>
>  /* Formula and parameters from the Allwinner BSP 4.4 kernel */
>  reg = (MINUPA - (data->temp << DIVPA));
>  reg = reg / MULPA;
>  *out = reg;
>  return 0;
> }
>
>
>
>
>     ths: ths@1c24c00 {
>         #thermal-sensor-cells = <0>;
>         compatible = "allwinner,sun8i-h3-ths";
>         reg = <0x1c24c00 0x400>,
>               <0x01c1b234 0x4>;
>         reg-names = "ths", "calibration";
>         interrupts = <GIC_SPI 36 IRQ_TYPE_LEVEL_HIGH>;
>         resets = <&ccu RST_BUS_THS>;
>         reset-names = "ahb";
>         clocks = <&ccu CLK_BUS_THS>, <&ccu CLK_THS>;
>         clock-names = "ahb", "ths";
>     };

I didn't check the formula but still the calibration address is wrong.

You have a SUN8IW11 which gives offset 0x40 :
https://github.com/BPI-SINOVOIP/BPI-M2U-bsp/blob/cbfb10bffba398dd109262af9704fe70cb4b2f3e/linux-sunxi/drivers/soc/allwinner/sunxi-sid-efuse.h#L49

>From the chip_id base address
https://github.com/BPI-SINOVOIP/BPI-M2U-bsp/blob/master/linux-sunxi/arch/arm/boot/dts/sun8iw11p1.dtsi#L205

So the correct calibration address is 0x1c1b240.

Regards,
Clément

>
>
> Regards,
> @lex
>
>
> On Sunday, July 28, 2019 at 5:44:31 PM UTC-3, Clément Péron wrote:
>>
>> On Sun, 28 Jul 2019 at 22:21, Clément Péron <pero...@gmail.com> wrote:
>> >
>> > Hi Alex,
>> >
>> > On Thu, 25 Jul 2019 at 23:20, @lex <alex....@gmail.com> wrote:
>> > >
>> > > Hi Clément,
>> > >
>> > > I am using the H3 THS driver, maybe this needs a rewrite.
>> > > 3.15.3.2. Temperature Conversion Formula TBD. Could be just that, but 
>> > > who knows.
>> > > At least i tried.
>> >
>> > Yes maybe the formula is different but I just check for the
>> > calibration data and my previous message was wrong.
>> > The calibration data for the H3 are pointing to the SID (internal eeprom).
>> >
>> > H3 => 0x01C1 4000
>> > R40 => 0x01C1 B000
>> >
>> > So maybe you can try with this bindings.
>> >
>> >         reg = <0x1c24c00 0x400>,
>> >               <0x01c1b234 0x4>;
>>
>> You have to check this offset and the formula from the vendor kernel.
>>
>> For the calibration data this seems to be "0x01c1b240" :
>> https://github.com/BPI-SINOVOIP/BPI-M2U-bsp/blob/cbfb10bffba398dd109262af9704fe70cb4b2f3e/linux-sunxi/drivers/soc/allwinner/sunxi-sid-efuse.h#L49
>>
>> For the formula you have to check here:
>> https://github.com/BPI-SINOVOIP/BPI-M2U-bsp/blob/cbfb10bffba398dd109262af9704fe70cb4b2f3e/linux-sunxi/drivers/thermal/sunxi_thermal/sun8iw11_ths.c#L65
>>
>> And you can check a bit the dt bindings for IRQ and memory mapping here :
>> https://github.com/BPI-SINOVOIP/BPI-M2U-bsp/blob/master/linux-sunxi/arch/arm/boot/dts/sun8iw11p1.dtsi#L1601-L1607
>>
>>
>> >
>> > Hope this can help.
>> >
>> > Regards,
>> > Clément
>> >
>> > >
>> > > Thank you anyway.
>> > >
>> > > On Thursday, July 25, 2019 at 5:37:39 PM UTC-3, Clément Péron wrote:
>> > >>
>> > >> Hi Alex,
>> > >>
>> > >> On Thu, 25 Jul 2019 at 22:01, @lex <alex....@gmail.com> wrote:
>> > >> >
>> > >> > Thank you for the info.
>> > >> >
>> > >> > Almost there, i get negative values for the temp, still something 
>> > >> > missing or wrong.
>> > >>
>> > >> This mean that the calibration data are wrong.
>> > >>
>> > >> I don't know where the H3 is looking for his callibration data.
>> > >>
>> > >> But the R40 seems to have a register for that with an offset of 0x74:
>> > >> Maybe you should try :
>> > >>          reg = <0x1c24c00 0x400>,
>> > >>                <0x1c24c74 0x4>;
>> > >>
>> > >> Else you have to open the H3 user manual and understand what this
>> > >> "0x01c14234" address is pointing to.
>> > >> And look for the same information for R40.
>> > >>
>> > >> Regards,
>> > >> Clément
>> > >>
>> > >> >
>> > >> > I came up with this:
>> > >> >
>> > >> >> ths: ths@1c24c00 {
>> > >> >>         #thermal-sensor-cells = <0>;
>> > >> >>         compatible = "allwinner,sun8i-h3-ths";
>> > >> >>         reg = <0x1c24c00 0x400>,
>> > >> >>               <0x01c14234 0x4>;
>> > >> >>         reg-names = "ths", "calibration";
>> > >> >>         interrupts = <GIC_SPI 36 IRQ_TYPE_LEVEL_HIGH>;
>> > >> >>         resets = <&ccu RST_BUS_THS>;
>> > >> >>         reset-names = "ahb";
>> > >> >>         clocks = <&ccu CLK_BUS_THS>, <&ccu CLK_THS>;
>> > >> >>         clock-names = "ahb", "ths";
>> > >> >>     };
>> > >> >
>> > >> >
>> > >> > On Thursday, July 25, 2019 at 4:28:07 PM UTC-3, Clément Péron wrote:
>> > >> >>
>> > >> >> Hi Alex,
>> > >> >>
>> > >> >> On Thu, 25 Jul 2019 at 19:12, @lex <alex....@gmail.com> wrote:
>> > >> >> >
>> > >> >> > Hi Clément,
>> > >> >> >
>> > >> >> > No. i did not read the R40 manual until now, Base address: 1c24c00
>> > >> >> > But how to find the correct interrupt number and the correct 
>> > >> >> > Mapping in the Manual? What should o look for?
>> > >> >> You have to look for GIC interrupt table (page 205).
>> > >> >> And you have to find the correct interrupt number.
>> > >> >> To have it you have to subtract 32 (the first 32 interrupts are ARM 
>> > >> >> reserved).
>> > >> >>
>> > >> >> Regards,
>> > >> >> Clément
>> > >> >>
>> > >> >> >
>> > >> >> > Thanks for the answer.
>> > >> >> >
>> > >> >> > @lex
>> > >> >> >
>> > >> >> >
>> > >> >> >
>> > >> >> > On Wednesday, July 24, 2019 at 1:46:47 PM UTC-3, @lex wrote:
>> > >> >> >>
>> > >> >> >> Hi,
>> > >> >> >>
>> > >> >> >> I am trying to get the thermal readout to work on bpi m2 ultra 
>> > >> >> >> using the same setup from the H3 without success.
>> > >> >> >> i get:
>> > >> >> >> [  802.038807] thermal thermal_zone0: failed to read out thermal 
>> > >> >> >> zone (-16)
>> > >> >> >>
>> > >> >> >> Anyone have this working or have a fix for this?
>> > >> >> >>
>> > >> >> >> This is what i am using:
>> > >> >> >>
>> > >> >> >>     ths: ths@1c25000 {
>> > >> >> >>         #thermal-sensor-cells = <0>;
>> > >> >> >>         compatible = "allwinner,sun8i-h3-ths";
>> > >> >> >>         reg = <0x01c25000 0x400>,
>> > >> >> >>               <0x01c14234 0x4>;
>> > >> >> >>         reg-names = "ths", "calibration";
>> > >> >> >>         interrupts = <GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH>;
>> > >> >> >>         resets = <&ccu RST_BUS_THS>;
>> > >> >> >>         reset-names = "ahb";
>> > >> >> >>         clocks = <&ccu CLK_BUS_THS>, <&ccu CLK_THS>;
>> > >> >> >>         clock-names = "ahb", "ths";
>> > >> >> >>     };
>> > >> >> >>
>> > >> >> >> BR
>> > >> >> >
>> > >> >> > --
>> > >> >> > You received this message because you are subscribed to the Google 
>> > >> >> > Groups "linux-sunxi" group.
>> > >> >> > To unsubscribe from this group and stop receiving emails from it, 
>> > >> >> > send an email to linux...@googlegroups.com.
>> > >> >> > To view this discussion on the web, visit 
>> > >> >> > https://groups.google.com/d/msgid/linux-sunxi/29d0e510-bc3f-479d-9f8b-5f7f4fa3b77a%40googlegroups.com.
>> > >> >
>> > >> > --
>> > >> > You received this message because you are subscribed to the Google 
>> > >> > Groups "linux-sunxi" group.
>> > >> > To unsubscribe from this group and stop receiving emails from it, 
>> > >> > send an email to linux...@googlegroups.com.
>> > >> > To view this discussion on the web, visit 
>> > >> > https://groups.google.com/d/msgid/linux-sunxi/b8b52334-b423-4f74-bb64-67c937279d56%40googlegroups.com.
>> > >
>> > > --
>> > > You received this message because you are subscribed to the Google 
>> > > Groups "linux-sunxi" group.
>> > > To unsubscribe from this group and stop receiving emails from it, send 
>> > > an email to linux...@googlegroups.com.
>> > > To view this discussion on the web, visit 
>> > > https://groups.google.com/d/msgid/linux-sunxi/de28da19-0644-4c5c-a811-763712f40f11%40googlegroups.com.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "linux-sunxi" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to linux-sunxi+unsubscr...@googlegroups.com.
> To view this discussion on the web, visit 
> https://groups.google.com/d/msgid/linux-sunxi/a273ccf4-6aef-4b12-8a84-d343060c908b%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/linux-sunxi/CAJiuCce80uMq4wcFkq9KVjXFGuzRs2br5fuPA5BsURN3a8piTQ%40mail.gmail.com.

Reply via email to