Skip to content
This repository was archived by the owner on Oct 5, 2018. It is now read-only.

Commit 8bc8cde

Browse files
committed
Merge branch 'hikey' of github.com:96boards/linux into hikey
2 parents e5564fe + 89b4aa4 commit 8bc8cde

File tree

16 files changed

+948
-109
lines changed

16 files changed

+948
-109
lines changed

arch/arm64/boot/dts/hi6220.dtsi

Lines changed: 144 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66

77
#include <dt-bindings/clock/hi6220-clock.h>
8+
#include <dt-bindings/thermal/thermal.h>
89

910
/ {
1011
cpus {
@@ -20,12 +21,13 @@
2021
clock-latency = <0>;
2122
operating-points = <
2223
/* kHz */
23-
208000 0
24-
432000 0
25-
729000 0
26-
960000 0
2724
1200000 0
25+
960000 0
26+
729000 0
27+
432000 0
28+
208000 0
2829
>;
30+
#cooling-cells = <2>; /* min followed by max */
2931
};
3032
cpu1: cpu@1 {
3133
compatible = "arm,cortex-a53", "arm,armv8";
@@ -1114,42 +1116,148 @@
11141116
interrupts = <0 77 0x4>;
11151117
};
11161118

1117-
thermal {
1118-
compatible = "hisilicon,hisi-tsensor-driver";
1119-
reg = <0x0 0xf7030000 0x0 0x1000>;
1120-
tsensor-enable = <1>;
1121-
tsensor-num = <3>;
1122-
acpu-freq-limit-num = <3>;
1123-
acpu-freq-limit-table = <729000 432000 208000>; /* ~KHz */
1124-
1125-
acpu_c1: temp@a1 {
1126-
compatible = "hisilicon,hisi-tsensor0";
1127-
tsensor-type = <0x1>;
1128-
tsensor-sel = <1>;
1129-
tsensor-reset-value = <100>;
1130-
tsensor-thres-value = <70>;
1131-
tsensor-alarm-count = <4>;
1132-
tsensor-recover-count = <10>;
1119+
1120+
tsensor: tsensor@0,f7030700 {
1121+
compatible = "hisilicon,tsensor";
1122+
reg = <0x0 0xf7030700 0x0 0x1000>;
1123+
interrupts = <0 7 0x4>;
1124+
clocks = <&clock_sys HI6220_TSENSOR_CLK>;
1125+
clock-names = "thermal_clk";
1126+
#thermal-sensor-cells = <1>;
1127+
1128+
local_sensor {
1129+
hisilicon,tsensor-id = <0>;
1130+
hisilicon,tsensor-lag-value = <10>;
1131+
hisilicon,tsensor-thres-temp = <80000>;
1132+
hisilicon,tsensor-reset-temp = <100000>;
1133+
hisilicon,tsensor-bind-irq;
1134+
};
1135+
1136+
acpu1_sensor {
1137+
hisilicon,tsensor-id = <1>;
1138+
hisilicon,tsensor-lag-value = <10>;
1139+
hisilicon,tsensor-thres-temp = <80000>;
1140+
hisilicon,tsensor-reset-temp = <100000>;
1141+
};
1142+
1143+
acpu0_sensor {
1144+
hisilicon,tsensor-id = <2>;
1145+
hisilicon,tsensor-lag-value = <10>;
1146+
hisilicon,tsensor-thres-temp = <80000>;
1147+
hisilicon,tsensor-reset-temp = <100000>;
11331148
};
11341149

1135-
acpu_c0: temp@a2 {
1136-
compatible = "hisilicon,hisi-tsensor1";
1137-
tsensor-type = <0x0>;
1138-
tsensor-sel = <2>;
1139-
tsensor-reset-value = <100>;
1140-
tsensor-thres-value = <70>;
1141-
tsensor-alarm-count = <4>;
1142-
tsensor-recover-count = <10>;
1150+
gpu_sensor {
1151+
hisilicon,tsensor-id = <3>;
1152+
hisilicon,tsensor-lag-value = <10>;
1153+
hisilicon,tsensor-thres-temp = <80000>;
1154+
hisilicon,tsensor-reset-temp = <100000>;
11431155
};
1156+
};
1157+
1158+
thermal-zones {
1159+
local: local {
1160+
polling-delay-passive = <1000>; /* milliseconds */
1161+
polling-delay = <5000>; /* milliseconds */
1162+
1163+
/* sensor ID */
1164+
thermal-sensors = <&tsensor 0>;
1165+
1166+
trips {
1167+
local_alert: local_alert {
1168+
temperature = <70000>; /* millicelsius */
1169+
hysteresis = <2000>; /* millicelsius */
1170+
type = "passive";
1171+
};
1172+
local_crit: local_crit {
1173+
temperature = <90000>; /* millicelsius */
1174+
hysteresis = <2000>; /* millicelsius */
1175+
type = "critical";
1176+
};
1177+
};
1178+
1179+
cooling-maps {
1180+
/* There are currently no cooling maps because there are no cooling devices */
1181+
};
1182+
};
1183+
1184+
cluster1: cluster1 {
1185+
polling-delay-passive = <1000>; /* milliseconds */
1186+
polling-delay = <5000>; /* milliseconds */
1187+
1188+
/* sensor ID */
1189+
thermal-sensors = <&tsensor 1>;
11441190

1145-
gpu: temp@a3 {
1146-
compatible = "hisilicon,hisi-tsensor2";
1147-
tsensor-type = <0x2>;
1148-
tsensor-sel = <3>;
1149-
tsensor-reset-value = <100>;
1150-
tsensor-thres-value = <70>;
1151-
tsensor-alarm-count = <4>;
1152-
tsensor-recover-count = <10>;
1191+
trips {
1192+
cluster1_alert: cluster1_alert {
1193+
temperature = <70000>; /* millicelsius */
1194+
hysteresis = <2000>; /* millicelsius */
1195+
type = "passive";
1196+
};
1197+
cluster1_crit: cluster1_crit {
1198+
temperature = <90000>; /* millicelsius */
1199+
hysteresis = <2000>; /* millicelsius */
1200+
type = "critical";
1201+
};
1202+
};
1203+
1204+
cooling-maps {
1205+
/* There are currently no cooling maps because there are no cooling devices */
1206+
};
1207+
};
1208+
1209+
cluster0: cluster0 {
1210+
polling-delay-passive = <1000>; /* milliseconds */
1211+
polling-delay = <5000>; /* milliseconds */
1212+
1213+
/* sensor ID */
1214+
thermal-sensors = <&tsensor 2>;
1215+
1216+
trips {
1217+
cluster0_alert: cluster0_alert {
1218+
temperature = <70000>; /* millicelsius */
1219+
hysteresis = <2000>; /* millicelsius */
1220+
type = "passive";
1221+
};
1222+
cluster0_crit: cluster0_crit {
1223+
temperature = <90000>; /* millicelsius */
1224+
hysteresis = <2000>; /* millicelsius */
1225+
type = "critical";
1226+
};
1227+
};
1228+
1229+
cooling-maps {
1230+
map0 {
1231+
trip = <&cluster0_alert>;
1232+
cooling-device =
1233+
<&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
1234+
};
1235+
};
1236+
};
1237+
1238+
gpu: gpu {
1239+
polling-delay-passive = <1000>; /* milliseconds */
1240+
polling-delay = <5000>; /* milliseconds */
1241+
1242+
/* sensor ID */
1243+
thermal-sensors = <&tsensor 3>;
1244+
1245+
trips {
1246+
gpu_alert: gpu_alert {
1247+
temperature = <70000>; /* millicelsius */
1248+
hysteresis = <2000>; /* millicelsius */
1249+
type = "passive";
1250+
};
1251+
gpu_crit: gpu_crit {
1252+
temperature = <90000>; /* millicelsius */
1253+
hysteresis = <2000>; /* millicelsius */
1254+
type = "critical";
1255+
};
1256+
};
1257+
1258+
cooling-maps {
1259+
/* There are currently no cooling maps because there are no cooling devices */
1260+
};
11531261
};
11541262
};
11551263
};

arch/arm64/configs/defconfig

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,14 @@ CONFIG_SPI=y
249249
CONFIG_SPI_PL022=y
250250
CONFIG_GPIO_SYSFS=y
251251
CONFIG_GPIO_XGENE=y
252-
CONFIG_SENSORS_HI6220=y
252+
CONFIG_THERMAL=y
253+
CONFIG_THERMAL_HWMON=y
254+
CONFIG_THERMAL_OF=y
255+
CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE=y
256+
CONFIG_THERMAL_GOV_STEP_WISE=y
257+
CONFIG_THERMAL_GOV_USER_SPACE=y
258+
CONFIG_CPU_THERMAL=y
259+
CONFIG_HISI_THERMAL=y
253260
CONFIG_REGULATOR=y
254261
CONFIG_REGULATOR_FIXED_VOLTAGE=y
255262
CONFIG_REGULATOR_HI6220=y

drivers/clk/hisilicon/clk-hi6220.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ static struct hisi_gate_clock hi6220_separated_gate_clks_sys[] __initdata = {
132132
{ HI6220_UART3_PCLK, "uart3_pclk", "uart3_src", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x230, 7, 0, },
133133
{ HI6220_UART4_PCLK, "uart4_pclk", "uart4_src", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x230, 8, 0, },
134134
{ HI6220_SPI_CLK, "spi_clk", "clk_150m", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x230, 9, 0, },
135+
{ HI6220_TSENSOR_CLK, "tsensor_clk", "clk_bus", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x230, 12, 0, },
135136
{ HI6220_MMU_CLK, "mmu_clk", "ddrc_axi1", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x240, 11, 0, },
136137
{ HI6220_HIFI_SEL, "hifi_sel", "hifi_src", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x270, 0, 0, },
137138
{ HI6220_MMC0_SYSPLL, "mmc0_syspll", "syspll", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x270, 1, 0, },

drivers/cpufreq/hisi-acpu-cpufreq.c

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
1818

1919
#include <linux/clk.h>
20+
#include <linux/cpu_cooling.h>
2021
#include <linux/cpu.h>
2122
#include <linux/cpufreq.h>
2223
#include <linux/cpumask.h>
@@ -41,10 +42,16 @@ static atomic_t cluster_usage[MAX_CLUSTERS] = {
4142

4243
static struct clk *clk[MAX_CLUSTERS];
4344
static struct mutex cluster_lock[MAX_CLUSTERS];
45+
static struct thermal_cooling_device *cdev;
46+
47+
static inline int cpu_to_cluster(int cpu)
48+
{
49+
return coupled_clusters ? 0 : topology_physical_package_id(cpu);
50+
}
4451

4552
static unsigned int hisi_acpu_cpufreq_get_rate(unsigned int cpu)
4653
{
47-
int cluster = topology_physical_package_id(cpu);
54+
int cluster = cpu_to_cluster(cpu);
4855
unsigned int freq;
4956

5057
mutex_lock(&cluster_lock[cluster]);
@@ -63,7 +70,7 @@ static int hisi_acpu_cpufreq_set_target(struct cpufreq_policy *policy,
6370
unsigned int freqs_new;
6471
int ret = 0;
6572

66-
cluster = topology_physical_package_id(cpu);
73+
cluster = cpu_to_cluster(cpu);
6774
freqs_new = freq_table[cluster][index].frequency;
6875

6976
pr_debug("%s: cluster %d freq_new %d\n", __func__, cluster, freqs_new);
@@ -80,7 +87,7 @@ static int hisi_acpu_cpufreq_set_target(struct cpufreq_policy *policy,
8087

8188
static void put_cluster_clk_and_freq_table(struct device *cpu_dev)
8289
{
83-
u32 cluster = topology_physical_package_id(cpu_dev->id);
90+
u32 cluster = cpu_to_cluster(cpu_dev->id);
8491

8592
if (atomic_dec_return(&cluster_usage[cluster]))
8693
return;
@@ -100,7 +107,7 @@ static int get_cluster_clk_and_freq_table(struct device *cpu_dev)
100107
char name[6];
101108
int ret;
102109

103-
cluster = topology_physical_package_id(cpu_dev->id);
110+
cluster = cpu_to_cluster(cpu_dev->id);
104111

105112
if (atomic_inc_return(&cluster_usage[cluster]) != 1)
106113
return 0;
@@ -158,7 +165,7 @@ static int get_cluster_clk_and_freq_table(struct device *cpu_dev)
158165
/* Per-CPU initialization */
159166
static int hisi_acpu_cpufreq_init(struct cpufreq_policy *policy)
160167
{
161-
u32 cur_cluster = topology_physical_package_id(policy->cpu);
168+
u32 cur_cluster = cpu_to_cluster(policy->cpu);
162169
struct device *cpu_dev;
163170
int ret;
164171

@@ -243,7 +250,7 @@ MODULE_DEVICE_TABLE(of, hisi_acpu_cpufreq_match);
243250
static int hisi_acpu_cpufreq_probe(struct platform_device *pdev)
244251
{
245252
int ret = 0, i;
246-
struct device_node *np;
253+
struct device_node *np, *cpus;
247254

248255
np = pdev->dev.of_node;
249256
if (!np) {
@@ -264,12 +271,39 @@ static int hisi_acpu_cpufreq_probe(struct platform_device *pdev)
264271
dev_err(&pdev->dev,
265272
"%s: failed to register cpufreq driver\n", __func__);
266273

274+
cpus = of_find_node_by_path("/cpus");
275+
if (!cpus) {
276+
dev_err(&pdev->dev, "failed to find cpus node\n");
277+
return 0;
278+
}
279+
280+
np = of_get_next_child(cpus, NULL);
281+
if (!np) {
282+
dev_err(&pdev->dev, "failed to find cpus child node\n");
283+
of_node_put(cpus);
284+
return 0;
285+
}
286+
287+
if (of_find_property(np, "#cooling-cells", NULL)) {
288+
cdev = of_cpufreq_cooling_register(np, cpu_present_mask);
289+
if (IS_ERR(cdev)) {
290+
dev_err(&pdev->dev, "running cpufreq without cooling device: %ld\n",
291+
PTR_ERR(cdev));
292+
cdev = NULL;
293+
}
294+
}
295+
of_node_put(np);
296+
of_node_put(cpus);
297+
298+
return 0;
299+
267300
out:
268301
return ret;
269302
}
270303

271304
static int hisi_acpu_cpufreq_remove(struct platform_device *pdev)
272305
{
306+
cpufreq_cooling_unregister(cdev);
273307
cpufreq_unregister_driver(&hisi_acpu_cpufreq_driver);
274308
return 0;
275309
}

drivers/hwmon/lm75.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,10 @@ static struct attribute *lm75_attrs[] = {
176176
};
177177
ATTRIBUTE_GROUPS(lm75);
178178

179+
static const struct thermal_zone_of_device_ops lm75_of_thermal_ops = {
180+
.get_temp = lm75_read_temp,
181+
};
182+
179183
/*-----------------------------------------------------------------------*/
180184

181185
/* device probe and removal */
@@ -291,10 +295,9 @@ lm75_probe(struct i2c_client *client, const struct i2c_device_id *id)
291295
if (IS_ERR(data->hwmon_dev))
292296
return PTR_ERR(data->hwmon_dev);
293297

294-
data->tz = thermal_zone_of_sensor_register(data->hwmon_dev,
295-
0,
298+
data->tz = thermal_zone_of_sensor_register(data->hwmon_dev, 0,
296299
data->hwmon_dev,
297-
lm75_read_temp, NULL);
300+
&lm75_of_thermal_ops);
298301
if (IS_ERR(data->tz))
299302
data->tz = NULL;
300303

drivers/hwmon/ntc_thermistor.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,10 @@ static const struct attribute_group ntc_attr_group = {
486486
.attrs = ntc_attributes,
487487
};
488488

489+
static const struct thermal_zone_of_device_ops ntc_of_thermal_ops = {
490+
.get_temp = ntc_read_temp,
491+
};
492+
489493
static int ntc_thermistor_probe(struct platform_device *pdev)
490494
{
491495
const struct of_device_id *of_id =
@@ -579,7 +583,7 @@ static int ntc_thermistor_probe(struct platform_device *pdev)
579583
pdev_id->name);
580584

581585
data->tz = thermal_zone_of_sensor_register(data->dev, 0, data->dev,
582-
ntc_read_temp, NULL);
586+
&ntc_of_thermal_ops);
583587
if (IS_ERR(data->tz)) {
584588
dev_dbg(&pdev->dev, "Failed to register to thermal fw.\n");
585589
data->tz = NULL;

0 commit comments

Comments
 (0)