27 Sep, 2016

6 commits

  • Added one additional parameter to thermal_zone_device_update() to provide
    caller with an optional capability to specify reason.
    Currently this event is used by user space governor to trigger different
    processing based on event code. Also it saves an additional call to read
    temperature when the event is received.
    The following events are cuurently defined:
    - Unspecified event
    - New temperature sample
    - Trip point violated
    - Trip point changed
    - thermal device up and down
    - thermal device power capability changed

    Signed-off-by: Srinivas Pandruvada
    Signed-off-by: Zhang Rui

    Srinivas Pandruvada
     
  • In less than 10 ms, the temperature of soc will arise 10 degree. 250 ms
    is too big for soc tempeture control. Setting 2.5 ms will speed up
    temperature accessing speed but introduce no more cpu's computing overhead.
    We set AUTO_PERIOD_TIME and TSADCV3_AUTO_PERIOD_HT_TIME the same value,
    because normal temperature update speed is also our consern in IPA.

    Signed-off-by: Rocky Hao
    Signed-off-by: Caesar Wang
    Cc: Zhang Rui
    Cc: Eduardo Valentin
    Cc: Heiko Stuebner
    Cc: linux-pm@vger.kernel.org
    Tested-by: Stephen Barber
    Signed-off-by: Zhang Rui

    Rocky Hao
     
  • Due to the voltage ripple, the sensing data of the tsadc is not accurate.
    And in this patch, the bandgap feature is enhanced to remove the voltage
    ripple, and then the tsadc can sense the temperature more precisely.

    Obsolete codes are removed as well.

    Signed-off-by: Rocky Hao
    Signed-off-by: Caesar Wang
    Cc: Eduardo Valentin
    Cc: Zhang Rui
    Cc: Heiko Stuebner
    Cc: linux-pm@vger.kernel.org
    Tested-by: Stephen Barber
    Signed-off-by: Zhang Rui

    Rocky Hao
     
  • The hardware-tracked trips will set the alarm interrupt value for
    registers. Then when the thermal zone has no trips to be set,
    That make the thermal trips callback a over range value.

    The root cause is the rk_tsadcv2_temp_to_code() function to handle the
    invalid temperature range is indeed incorrect, let's fix it on now.
    Otherwise, the thermal alarm interrupt will be triggered all the time
    on some SoCs.

    Fox example:
    localhost tmp # grep thermal /proc/interrupts; sleep 5;
    grep thermal /proc/interrupts

    23: 994830 .. GICv3 129 Level rockchip_thermal
    23: 1003423 .. GICv3 129 Level rockchip_thermal

    Reported-by: Rocky Hao
    Signed-off-by: Caesar Wang
    Cc: Zhang Rui
    Cc: Eduardo Valentin
    Cc: Heiko Stuebner
    Cc: linux-pm@vger.kernel.org
    Signed-off-by: Eduardo Valentin
    Signed-off-by: Zhang Rui

    Caesar Wang
     
  • We should increase the period cycles to save power since the rk3399 has
    the high frequency for tsadc clock.

    Fixes commit b0d70338bca22cb14
    ("thermal: rockchip: Support the RK3399 SoCs in thermal driver")

    Signed-off-by: Caesar Wang
    Cc: Zhang Rui
    Cc: Eduardo Valentin
    Cc: Heiko Stuebner
    Cc: linux-pm@vger.kernel.org
    Signed-off-by: Eduardo Valentin
    Signed-off-by: Zhang Rui

    Caesar Wang
     
  • Whenever the current temperature is updated, the trip points immediately
    below and above the current temperature are found. A sensor driver
    callback `set_trips' is then called with the temperatures.
    Lastly, The sensor will trigger the hardware high temperature interrupts
    to increase the sampleing rate and throttle frequency to limit the
    temperature rising When performing passive cooling.

    Signed-off-by: Caesar Wang
    Cc: Zhang Rui
    Cc: Eduardo Valentin
    Cc: linux-pm@vger.kernel.org
    Tested-by: Stephen Barber
    Signed-off-by: Eduardo Valentin
    Signed-off-by: Zhang Rui

    Caesar Wang
     

17 May, 2016

8 commits

  • Documentation/timers/timers-howto.txt recommends to use
    usleep_range on delays > 10usec.
    The usleep_range indeed reduces CPU load, since the udelay will busy wait
    for enough loop cycles to achieve the desired delay.

    Fixes commit b06c52db39fd ("thermal: rockchip:
    handle the power sequence for tsadc controller").

    Cc: Zhang Rui
    Cc: Eduardo Valentin
    Cc: Heiko Stuebner
    Suggested-by: Eduardo Valentin
    Signed-off-by: Caesar Wang
    Signed-off-by: Eduardo Valentin

    Caesar Wang
     
  • To update the notes for keeping in mind that quickly in case
    someone re-read this driver in the future.

    Signed-off-by: Caesar Wang
    Cc: Zhang Rui
    Cc: Eduardo Valentin
    Cc: Heiko Stuebner
    Signed-off-by: Eduardo Valentin

    Caesar Wang
     
  • The RK3366 SoCs have two Temperature Sensors, channel 0 is for CPU
    channel 1 is for GPU.

    Signed-off-by: Elaine Zhang
    Signed-off-by: Caesar Wang
    Signed-off-by: Eduardo Valentin

    Elaine Zhang
     
  • This adds the grf property to handle the tsadc power sequence on
    rockchip some SoCs.

    Verified on rk3399 can work with this patch on now.

    while true; do grep "" /sys/class/thermal/thermal_zone[0-1]/temp
    sleep .5; done
    /sys/class/thermal/thermal_zone0/temp:40555
    /sys/class/thermal/thermal_zone1/temp:41111
    /sys/class/thermal/thermal_zone0/temp:40555
    /sys/class/thermal/thermal_zone1/temp:41111
    /sys/class/thermal/thermal_zone0/temp:40555
    /sys/class/thermal/thermal_zone1/temp:41666
    /sys/class/thermal/thermal_zone0/temp:40555
    /sys/class/thermal/thermal_zone1/temp:41111
    /sys/class/thermal/thermal_zone0/temp:40555
    /sys/class/thermal/thermal_zone1/temp:41111
    /sys/class/thermal/thermal_zone0/temp:40555

    Signed-off-by: Caesar Wang
    Cc: Zhang Rui
    Cc: Eduardo Valentin
    Cc: Heiko Stuebner
    Signed-off-by: Eduardo Valentin

    Caesar Wang
     
  • This patch fixes the incorrect conversion table.
    The Code to Temperature mapping is updated based on sillcon results.

    Fixes commit b0d70338bca22cb14
    ("thermal: rockchip: Support the RK3399 SoCs in thermal driver").

    Signed-off-by: Caesar Wang
    Cc: Zhang Rui
    Cc: Eduardo Valentin
    Cc: Heiko Stuebner
    Signed-off-by: Eduardo Valentin

    Caesar Wang
     
  • We should judge the table.id[mid].code insearch algorithm on matter the
    adc value increment or decrement.

    Or otherwise, the temperature return the incorrect value in some cases.
    [ 1.438589] adc_val=402,temp=-40000
    [ 1.438903] adc_val=403,temp=-39375
    [ 1.439217] adc_val=404,temp=-38750
    ...
    [ 1.441102] adc_val=410,temp=-40000
    [ 1.441416] adc_val=411,temp=-34445
    [ 1.441737] adc_val=412,temp=-33889
    ...

    Let's fix it right now.

    Fixes commit 020ba95dbbbe ("thermal: rockchip:
    Add the sort mode for adc value increment or decrement").

    Reported-by: Rocky Hao
    Signed-off-by: Caesar Wang
    Cc: Zhang Rui
    Cc: Eduardo Valentin
    Cc: Heiko Stuebner
    Signed-off-by: Eduardo Valentin

    Caesar Wang
     
  • Disable thermal->clk when enabling pclk fails in
    resume routine.

    Signed-off-by: Shawn Lin
    Reviewed-by: Heiko Stuebner
    Reviewed-by: Caesar Wang
    Signed-off-by: Caesar Wang
    Signed-off-by: Eduardo Valentin

    Shawn Lin
     
  • This changes the driver to use the devm_ version
    of thermal_zone_of_sensor_register and cleans
    up the local points and unregister calls.

    Cc: Zhang Rui
    Cc: Heiko Stuebner
    Cc: linux-pm@vger.kernel.org
    Cc: linux-arm-kernel@lists.infradead.org
    Cc: linux-rockchip@lists.infradead.org
    Cc: linux-kernel@vger.kernel.org
    Tested-by: Caesar Wang
    Reviewed-by: Caesar Wang
    Reviewed-by: Heiko Stuebner
    Signed-off-by: Eduardo Valentin

    Eduardo Valentin
     

01 Mar, 2016

4 commits

  • As the TRM says, add the tsadc_q_sel to control the temperature-code
    sequence since the rk3228/rk3399 need set this bit (1024 - tsadc_q)
    as output.

    Fixes: commit
    b0d7033 "thermal: rockchip: Support the RK3399 SoCs in thermal driver"
    7b02a5e "thermal: rockchip: Support the RK3228 SoCs in thermal driver"

    Reported-by: Elaine Zhang
    Signed-off-by: Caesar Wang
    Signed-off-by: Eduardo Valentin

    Caesar Wang
     
  • This patch renames to be more adapter compatibles since more and more
    SoCs are supported in thermal driver.

    Reported-by: Huang,Tao
    Signed-off-by: Caesar Wang
    Signed-off-by: Eduardo Valentin

    Caesar Wang
     
  • the calculation use a global table, not their own table.
    so adapt the table to the correct one.

    Signed-off-by: Elaine Zhang
    Signed-off-by: Caesar Wang
    Signed-off-by: Eduardo Valentin

    Elaine Zhang
     
  • As the Dan report the smatch check the thermal driver warning:
    drivers/thermal/rockchip_thermal.c:551 rockchip_configure_from_dt()
    warn: impossible condition '(thermal->tshut_temp > ((~0 >> 1))) =>
    (s32min-s32max > s32max)'

    Although The shut_temp read from DT is u32,the temperature is currently
    represented as int not long in the thermal driver.
    Let's change to make shut_temp instead of the thermal->tshut_temp for
    the condition.

    Fixes: commit 437df2172e8d
    ("thermal: rockchip: consistently use int for temperatures")

    Reported-by: Dan Carpenter
    Signed-off-by: Caesar Wang
    Signed-off-by: Eduardo Valentin

    Caesar Wang
     

07 Jan, 2016

3 commits


13 Nov, 2015

6 commits


12 Nov, 2015

1 commit

  • Missing a include file caused compile error.

    drivers/thermal/rockchip_thermal.c: In function 'rockchip_thermal_suspend':
    drivers/thermal/rockchip_thermal.c:720:2: error: implicit declaration of function 'pinctrl_pm_select_sleep_state' [-Werror=implicit-function-declaration]
    ...

    Fixes: 7e38a5b1daa1 ("thermal: rockchip: support the sleep pinctrl state
    to avoid glitches")

    Reported-by: Stephen Rothwell
    Reported-by: kbuild test robot
    Signed-off-by: Caesar Wang
    Signed-off-by: Eduardo Valentin
    Signed-off-by: Linus Torvalds

    Caesar Wang
     

04 Nov, 2015

1 commit

  • When we come out of system suspend state (S3) the tsadc will have been
    reset and back at its default state. While reprogramming the tsadc
    it's possible that we'll glitch the output and unintentionally cause
    the "over temperature" GPIO to be asserted. Since the over
    temperature GPIO is often hooked up to something that will cause a
    reboot or shutdown in hardware, this glitch can be catastrophic on
    some boards.

    We'll add support for selecting the "sleep" pinctrl state at suspend
    time. Boards can use this to effectively disable the tsadc at suspend
    time and avoid glitches when the system is resumed.

    Reviewed-by: Douglas Anderson
    Signed-off-by: Caesar Wang
    Signed-off-by: Eduardo Valentin

    Caesar Wang
     

31 Oct, 2015

2 commits

  • When requested thermal shutdown signal polarity is low we need to make
    sure that the bit representing high level of signal is reset, and not
    set all other bits in that register.

    Also rename TSADCV2_INT_PD_CLEAR to TSADCV2_INT_PD_CLEAR_MASK to better
    reflect its nature.

    Acked-by: Caesar Wang
    Signed-off-by: Dmitry Torokhov
    Signed-off-by: Eduardo Valentin

    Dmitry Torokhov
     
  • We attempted to signal invalid code by returning -EAGAIN from
    rk_tsadcv2_code_to_temp(), unfortunately the return value was stuffed
    directly into the temperature pointer, potentially confusing upper
    layers with temperature of -EINVAL.

    Let's split temperature from error/success indicator to avoid such
    confusion.

    Also change the way we scan the temperature table to start with the 2nd
    element so that we do not need to worry that we may reference out of
    bounds element while doing binary search and keep checking that we end
    up with 'mid' equal to 0 (since we are looking for the temperature that
    would fall into interval between the 'mid' and 'mid - 1') .

    Tested-by: Caesar Wang
    Signed-off-by: Dmitry Torokhov
    Signed-off-by: Eduardo Valentin

    Dmitry Torokhov
     

03 Aug, 2015

1 commit

  • The thermal code uses int, long and unsigned long for temperatures
    in different places.

    Using an unsigned type limits the thermal framework to positive
    temperatures without need. Also several drivers currently will report
    temperatures near UINT_MAX for temperatures below 0°C. This will probably
    immediately shut the machine down due to overtemperature if started below
    0°C.

    'long' is 64bit on several architectures. This is not needed since INT_MAX °mC
    is above the melting point of all known materials.

    Consistently use a plain 'int' for temperatures throughout the thermal code and
    the drivers. This only changes the places in the drivers where the temperature
    is passed around as pointer, when drivers internally use another type this is
    not changed.

    Signed-off-by: Sascha Hauer
    Acked-by: Geert Uytterhoeven
    Reviewed-by: Jean Delvare
    Reviewed-by: Lukasz Majewski
    Reviewed-by: Darren Hart
    Reviewed-by: Heiko Stuebner
    Reviewed-by: Peter Feuerer
    Cc: Punit Agrawal
    Cc: Zhang Rui
    Cc: Eduardo Valentin
    Cc: linux-pm@vger.kernel.org
    Cc: linux-kernel@vger.kernel.org
    Cc: Jean Delvare
    Cc: Peter Feuerer
    Cc: Heiko Stuebner
    Cc: Lukasz Majewski
    Cc: Stephen Warren
    Cc: Thierry Reding
    Cc: linux-acpi@vger.kernel.org
    Cc: platform-driver-x86@vger.kernel.org
    Cc: linux-arm-kernel@lists.infradead.org
    Cc: linux-omap@vger.kernel.org
    Cc: linux-samsung-soc@vger.kernel.org
    Cc: Guenter Roeck
    Cc: Rafael J. Wysocki
    Cc: Maxime Ripard
    Cc: Darren Hart
    Cc: lm-sensors@lm-sensors.org
    Signed-off-by: Zhang Rui

    Sascha Hauer
     

09 May, 2015

1 commit

  • There is a copy and paste bug, "->clk" vs "->pclk", so we return the
    wrong error code here.

    Fixes: cbac8f639437 ('thermal: rockchip: add driver for thermal')
    Signed-off-by: Dan Carpenter
    Reviewed-by: Caesar Wang
    Reviewed-by: Doug Anderson
    Tested-by: Caesar Wang
    Signed-off-by: Zhang Rui

    Dan Carpenter
     

25 Jan, 2015

1 commit

  • In general, the kernel should report temperature readings exactly as
    reported by the hardware. The cpu / gpu thermal driver works in 5 degree
    increments,but we ought to do more accurate. The temperature will do
    linear interpolation between the entries in the table.

    Test= $md5sum /dev/zero &
    $while true; do grep "" /sys/class/thermal/thermal_zone[1-2]/temp;
    sleep .5; done

    e.g. We can get the result as follows:
    /sys/class/thermal/thermal_zone1/temp:39994
    /sys/class/thermal/thermal_zone2/temp:39086
    /sys/class/thermal/thermal_zone1/temp:39994
    /sys/class/thermal/thermal_zone2/temp:39540
    /sys/class/thermal/thermal_zone1/temp:39540
    /sys/class/thermal/thermal_zone2/temp:39540
    /sys/class/thermal/thermal_zone1/temp:39540
    /sys/class/thermal/thermal_zone2/temp:39994

    Reviewed-by: Dmitry Torokhov
    Reviewed-by: Daniel Kurtz
    Signed-off-by: Caesar Wang
    Signed-off-by: Eduardo Valentin

    Caesar Wang
     

22 Dec, 2014

1 commit


25 Nov, 2014

1 commit

  • Thermal is TS-ADC Controller module supports
    user-defined mode and automatic mode.

    User-defined mode refers,TSADC all the control signals entirely by
    software writing to register for direct control.

    Automaic mode refers to the module automatically poll TSADC output,
    and the results were checked.If you find that the temperature High
    in a period of time,an interrupt is generated to the processor
    down-measures taken;If the temperature over a period of time High,
    the resulting TSHUT gave CRU module,let it reset the entire chip,
    or via GPIO give PMIC.

    Signed-off-by: zhaoyifeng
    Signed-off-by: Caesar Wang
    Reviewed-by: Dmitry Torokhov
    Signed-off-by: Eduardo Valentin

    Caesar Wang