mediatek: backport upstream mediatek patches
[openwrt/staging/hauke.git] / target / linux / mediatek / patches-4.14 / 0200-thermal-mediatek-add-support-for-MT7622-SoC.patch
1 From b93889b200a963acde20e559dbf51886ad6b6229 Mon Sep 17 00:00:00 2001
2 From: Sean Wang <sean.wang@mediatek.com>
3 Date: Tue, 16 Jan 2018 23:50:48 +0800
4 Subject: [PATCH 200/224] thermal: mediatek: add support for MT7622 SoC
5
6 MT7622 SoC has built-in thermal controller with one sensing point, the
7 patch just is to extend the functionality of the existing logic.
8
9 Changes v1 -> v2: rebase to 4.16-rc1
10
11 Signed-off-by: Sean Wang <sean.wang@mediatek.com>
12 Signed-off-by: Shunli Wang <shunli.wang@mediatek.com>
13 ---
14 drivers/thermal/mtk_thermal.c | 35 +++++++++++++++++++++++++++++++++++
15 1 file changed, 35 insertions(+)
16
17 diff --git a/drivers/thermal/mtk_thermal.c b/drivers/thermal/mtk_thermal.c
18 index c75661a3801a..e709acb2235e 100644
19 --- a/drivers/thermal/mtk_thermal.c
20 +++ b/drivers/thermal/mtk_thermal.c
21 @@ -153,6 +153,12 @@
22 /* The number of sensing points per bank */
23 #define MT2712_NUM_SENSORS_PER_ZONE 4
24
25 +#define MT7622_TEMP_AUXADC_CHANNEL 11
26 +#define MT7622_NUM_SENSORS 1
27 +#define MT7622_NUM_ZONES 1
28 +#define MT7622_NUM_SENSORS_PER_ZONE 1
29 +#define MT7622_TS1 0
30 +
31 struct mtk_thermal;
32
33 struct thermal_bank_cfg {
34 @@ -242,6 +248,12 @@ static const int mt2712_adcpnp[MT2712_NUM_SENSORS_PER_ZONE] = {
35
36 static const int mt2712_mux_values[MT2712_NUM_SENSORS] = { 0, 1, 2, 3 };
37
38 +/* MT7622 thermal sensor data */
39 +static const int mt7622_bank_data[MT7622_NUM_SENSORS] = { MT7622_TS1, };
40 +static const int mt7622_msr[MT7622_NUM_SENSORS_PER_ZONE] = { TEMP_MSR0, };
41 +static const int mt7622_adcpnp[MT7622_NUM_SENSORS_PER_ZONE] = { TEMP_ADCPNP0, };
42 +static const int mt7622_mux_values[MT7622_NUM_SENSORS] = { 0, };
43 +
44 /**
45 * The MT8173 thermal controller has four banks. Each bank can read up to
46 * four temperature sensors simultaneously. The MT8173 has a total of 5
47 @@ -329,6 +341,25 @@ static const struct mtk_thermal_data mt2712_thermal_data = {
48 .sensor_mux_values = mt2712_mux_values,
49 };
50
51 +/*
52 + * MT7622 have only one sensing point which uses AUXADC Channel 11 for raw data
53 + * access.
54 + */
55 +static const struct mtk_thermal_data mt7622_thermal_data = {
56 + .auxadc_channel = MT7622_TEMP_AUXADC_CHANNEL,
57 + .num_banks = MT7622_NUM_ZONES,
58 + .num_sensors = MT7622_NUM_SENSORS,
59 + .bank_data = {
60 + {
61 + .num_sensors = 1,
62 + .sensors = mt7622_bank_data,
63 + },
64 + },
65 + .msr = mt7622_msr,
66 + .adcpnp = mt7622_adcpnp,
67 + .sensor_mux_values = mt7622_mux_values,
68 +};
69 +
70 /**
71 * raw_to_mcelsius - convert a raw ADC value to mcelsius
72 * @mt: The thermal controller
73 @@ -631,6 +662,10 @@ static const struct of_device_id mtk_thermal_of_match[] = {
74 {
75 .compatible = "mediatek,mt2712-thermal",
76 .data = (void *)&mt2712_thermal_data,
77 + },
78 + {
79 + .compatible = "mediatek,mt7622-thermal",
80 + .data = (void *)&mt7622_thermal_data,
81 }, {
82 },
83 };
84 --
85 2.11.0
86