linux/drivers/thermal/hisi_thermal.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * HiSilicon thermal sensor driver
 *
 * Copyright (c) 2014-2015 HiSilicon Limited.
 * Copyright (c) 2014-2015 Linaro Limited.
 *
 * Xinwei Kong <[email protected]>
 * Leo Yan <[email protected]>
 */

#include <linux/cpufreq.h>
#include <linux/delay.h>
#include <linux/interrupt.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/io.h>
#include <linux/thermal.h>

#define HI6220_TEMP0_LAG
#define HI6220_TEMP0_TH
#define HI6220_TEMP0_RST_TH
#define HI6220_TEMP0_CFG
#define HI6220_TEMP0_CFG_SS_MSK
#define HI6220_TEMP0_CFG_HDAK_MSK
#define HI6220_TEMP0_EN
#define HI6220_TEMP0_INT_EN
#define HI6220_TEMP0_INT_CLR
#define HI6220_TEMP0_RST_MSK
#define HI6220_TEMP0_VALUE

#define HI3660_OFFSET(chan)
#define HI3660_TEMP(chan)
#define HI3660_TH(chan)
#define HI3660_LAG(chan)
#define HI3660_INT_EN(chan)
#define HI3660_INT_CLR(chan)

#define HI6220_TEMP_BASE
#define HI6220_TEMP_RESET
#define HI6220_TEMP_STEP
#define HI6220_TEMP_LAG

#define HI3660_TEMP_BASE
#define HI3660_TEMP_STEP
#define HI3660_TEMP_LAG

#define HI6220_CLUSTER0_SENSOR
#define HI6220_CLUSTER1_SENSOR

#define HI3660_LITTLE_SENSOR
#define HI3660_BIG_SENSOR
#define HI3660_G3D_SENSOR
#define HI3660_MODEM_SENSOR

struct hisi_thermal_data;

struct hisi_thermal_sensor {};

struct hisi_thermal_ops {};

struct hisi_thermal_data {};

/*
 * The temperature computation on the tsensor is as follow:
 *	Unit: millidegree Celsius
 *	Step: 200/255 (0.7843)
 *	Temperature base: -60°C
 *
 * The register is programmed in temperature steps, every step is 785
 * millidegree and begins at -60 000 m°C
 *
 * The temperature from the steps:
 *
 *	Temp = TempBase + (steps x 785)
 *
 * and the steps from the temperature:
 *
 *	steps = (Temp - TempBase) / 785
 *
 */
static inline int hi6220_thermal_step_to_temp(int step)
{}

static inline int hi6220_thermal_temp_to_step(int temp)
{}

/*
 * for Hi3660,
 *	Step: 189/922 (0.205)
 *	Temperature base: -63.780°C
 *
 * The register is programmed in temperature steps, every step is 205
 * millidegree and begins at -63 780 m°C
 */
static inline int hi3660_thermal_step_to_temp(int step)
{}

static inline int hi3660_thermal_temp_to_step(int temp)
{}

/*
 * The lag register contains 5 bits encoding the temperature in steps.
 *
 * Each time the temperature crosses the threshold boundary, an
 * interrupt is raised. It could be when the temperature is going
 * above the threshold or below. However, if the temperature is
 * fluctuating around this value due to the load, we can receive
 * several interrupts which may not desired.
 *
 * We can setup a temperature representing the delta between the
 * threshold and the current temperature when the temperature is
 * decreasing.
 *
 * For instance: the lag register is 5°C, the threshold is 65°C, when
 * the temperature reaches 65°C an interrupt is raised and when the
 * temperature decrease to 65°C - 5°C another interrupt is raised.
 *
 * A very short lag can lead to an interrupt storm, a long lag
 * increase the latency to react to the temperature changes.  In our
 * case, that is not really a problem as we are polling the
 * temperature.
 *
 * [0:4] : lag register
 *
 * The temperature is coded in steps, cf. HI6220_TEMP_STEP.
 *
 * Min : 0x00 :  0.0 °C
 * Max : 0x1F : 24.3 °C
 *
 * The 'value' parameter is in milliCelsius.
 */
static inline void hi6220_thermal_set_lag(void __iomem *addr, int value)
{}

static inline void hi6220_thermal_alarm_clear(void __iomem *addr, int value)
{}

static inline void hi6220_thermal_alarm_enable(void __iomem *addr, int value)
{}

static inline void hi6220_thermal_alarm_set(void __iomem *addr, int temp)
{}

static inline void hi6220_thermal_reset_set(void __iomem *addr, int temp)
{}

static inline void hi6220_thermal_reset_enable(void __iomem *addr, int value)
{}

static inline void hi6220_thermal_enable(void __iomem *addr, int value)
{}

static inline int hi6220_thermal_get_temperature(void __iomem *addr)
{}

/*
 * [0:6] lag register
 *
 * The temperature is coded in steps, cf. HI3660_TEMP_STEP.
 *
 * Min : 0x00 :  0.0 °C
 * Max : 0x7F : 26.0 °C
 *
 */
static inline void hi3660_thermal_set_lag(void __iomem *addr,
					  int id, int value)
{}

static inline void hi3660_thermal_alarm_clear(void __iomem *addr,
					      int id, int value)
{}

static inline void hi3660_thermal_alarm_enable(void __iomem *addr,
					       int id, int value)
{}

static inline void hi3660_thermal_alarm_set(void __iomem *addr,
					    int id, int value)
{}

static inline int hi3660_thermal_get_temperature(void __iomem *addr, int id)
{}

/*
 * Temperature configuration register - Sensor selection
 *
 * Bits [19:12]
 *
 * 0x0: local sensor (default)
 * 0x1: remote sensor 1 (ACPU cluster 1)
 * 0x2: remote sensor 2 (ACPU cluster 0)
 * 0x3: remote sensor 3 (G3D)
 */
static inline void hi6220_thermal_sensor_select(void __iomem *addr, int sensor)
{}

/*
 * Temperature configuration register - Hdak conversion polling interval
 *
 * Bits [5:4]
 *
 * 0x0 :   0.768 ms
 * 0x1 :   6.144 ms
 * 0x2 :  49.152 ms
 * 0x3 : 393.216 ms
 */
static inline void hi6220_thermal_hdak_set(void __iomem *addr, int value)
{}

static int hi6220_thermal_irq_handler(struct hisi_thermal_sensor *sensor)
{}

static int hi3660_thermal_irq_handler(struct hisi_thermal_sensor *sensor)
{}

static int hi6220_thermal_get_temp(struct hisi_thermal_sensor *sensor)
{}

static int hi3660_thermal_get_temp(struct hisi_thermal_sensor *sensor)
{}

static int hi6220_thermal_disable_sensor(struct hisi_thermal_sensor *sensor)
{}

static int hi3660_thermal_disable_sensor(struct hisi_thermal_sensor *sensor)
{}

static int hi6220_thermal_enable_sensor(struct hisi_thermal_sensor *sensor)
{}

static int hi3660_thermal_enable_sensor(struct hisi_thermal_sensor *sensor)
{}

static int hi6220_thermal_probe(struct hisi_thermal_data *data)
{}

static int hi3660_thermal_probe(struct hisi_thermal_data *data)
{}

static int hisi_thermal_get_temp(struct thermal_zone_device *tz, int *temp)
{}

static const struct thermal_zone_device_ops hisi_of_thermal_ops =;

static irqreturn_t hisi_thermal_alarm_irq_thread(int irq, void *dev)
{}

static int hisi_thermal_register_sensor(struct platform_device *pdev,
					struct hisi_thermal_sensor *sensor)
{}

static const struct hisi_thermal_ops hi6220_ops =;

static const struct hisi_thermal_ops hi3660_ops =;

static const struct of_device_id of_hisi_thermal_match[] =;
MODULE_DEVICE_TABLE(of, of_hisi_thermal_match);

static void hisi_thermal_toggle_sensor(struct hisi_thermal_sensor *sensor,
				       bool on)
{}

static int hisi_thermal_probe(struct platform_device *pdev)
{}

static void hisi_thermal_remove(struct platform_device *pdev)
{}

static int hisi_thermal_suspend(struct device *dev)
{}

static int hisi_thermal_resume(struct device *dev)
{}

static DEFINE_SIMPLE_DEV_PM_OPS(hisi_thermal_pm_ops,
			 hisi_thermal_suspend, hisi_thermal_resume);

static struct platform_driver hisi_thermal_driver =;

module_platform_driver();

MODULE_AUTHOR();
MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();