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

Commit

Permalink
Merge branch 'hikey' of github.com:96boards/linux into hikey
Browse files Browse the repository at this point in the history
  • Loading branch information
fboudra committed Mar 3, 2015
2 parents e5564fe + 89b4aa4 commit 8bc8cde
Show file tree
Hide file tree
Showing 16 changed files with 948 additions and 109 deletions.
180 changes: 144 additions & 36 deletions arch/arm64/boot/dts/hi6220.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

#include <dt-bindings/clock/hi6220-clock.h>
#include <dt-bindings/thermal/thermal.h>

/ {
cpus {
Expand All @@ -20,12 +21,13 @@
clock-latency = <0>;
operating-points = <
/* kHz */
208000 0
432000 0
729000 0
960000 0
1200000 0
960000 0
729000 0
432000 0
208000 0
>;
#cooling-cells = <2>; /* min followed by max */
};
cpu1: cpu@1 {
compatible = "arm,cortex-a53", "arm,armv8";
Expand Down Expand Up @@ -1114,42 +1116,148 @@
interrupts = <0 77 0x4>;
};

thermal {
compatible = "hisilicon,hisi-tsensor-driver";
reg = <0x0 0xf7030000 0x0 0x1000>;
tsensor-enable = <1>;
tsensor-num = <3>;
acpu-freq-limit-num = <3>;
acpu-freq-limit-table = <729000 432000 208000>; /* ~KHz */

acpu_c1: temp@a1 {
compatible = "hisilicon,hisi-tsensor0";
tsensor-type = <0x1>;
tsensor-sel = <1>;
tsensor-reset-value = <100>;
tsensor-thres-value = <70>;
tsensor-alarm-count = <4>;
tsensor-recover-count = <10>;

tsensor: tsensor@0,f7030700 {
compatible = "hisilicon,tsensor";
reg = <0x0 0xf7030700 0x0 0x1000>;
interrupts = <0 7 0x4>;
clocks = <&clock_sys HI6220_TSENSOR_CLK>;
clock-names = "thermal_clk";
#thermal-sensor-cells = <1>;

local_sensor {
hisilicon,tsensor-id = <0>;
hisilicon,tsensor-lag-value = <10>;
hisilicon,tsensor-thres-temp = <80000>;
hisilicon,tsensor-reset-temp = <100000>;
hisilicon,tsensor-bind-irq;
};

acpu1_sensor {
hisilicon,tsensor-id = <1>;
hisilicon,tsensor-lag-value = <10>;
hisilicon,tsensor-thres-temp = <80000>;
hisilicon,tsensor-reset-temp = <100000>;
};

acpu0_sensor {
hisilicon,tsensor-id = <2>;
hisilicon,tsensor-lag-value = <10>;
hisilicon,tsensor-thres-temp = <80000>;
hisilicon,tsensor-reset-temp = <100000>;
};

acpu_c0: temp@a2 {
compatible = "hisilicon,hisi-tsensor1";
tsensor-type = <0x0>;
tsensor-sel = <2>;
tsensor-reset-value = <100>;
tsensor-thres-value = <70>;
tsensor-alarm-count = <4>;
tsensor-recover-count = <10>;
gpu_sensor {
hisilicon,tsensor-id = <3>;
hisilicon,tsensor-lag-value = <10>;
hisilicon,tsensor-thres-temp = <80000>;
hisilicon,tsensor-reset-temp = <100000>;
};
};

thermal-zones {
local: local {
polling-delay-passive = <1000>; /* milliseconds */
polling-delay = <5000>; /* milliseconds */

/* sensor ID */
thermal-sensors = <&tsensor 0>;

trips {
local_alert: local_alert {
temperature = <70000>; /* millicelsius */
hysteresis = <2000>; /* millicelsius */
type = "passive";
};
local_crit: local_crit {
temperature = <90000>; /* millicelsius */
hysteresis = <2000>; /* millicelsius */
type = "critical";
};
};

cooling-maps {
/* There are currently no cooling maps because there are no cooling devices */
};
};

cluster1: cluster1 {
polling-delay-passive = <1000>; /* milliseconds */
polling-delay = <5000>; /* milliseconds */

/* sensor ID */
thermal-sensors = <&tsensor 1>;

gpu: temp@a3 {
compatible = "hisilicon,hisi-tsensor2";
tsensor-type = <0x2>;
tsensor-sel = <3>;
tsensor-reset-value = <100>;
tsensor-thres-value = <70>;
tsensor-alarm-count = <4>;
tsensor-recover-count = <10>;
trips {
cluster1_alert: cluster1_alert {
temperature = <70000>; /* millicelsius */
hysteresis = <2000>; /* millicelsius */
type = "passive";
};
cluster1_crit: cluster1_crit {
temperature = <90000>; /* millicelsius */
hysteresis = <2000>; /* millicelsius */
type = "critical";
};
};

cooling-maps {
/* There are currently no cooling maps because there are no cooling devices */
};
};

cluster0: cluster0 {
polling-delay-passive = <1000>; /* milliseconds */
polling-delay = <5000>; /* milliseconds */

/* sensor ID */
thermal-sensors = <&tsensor 2>;

trips {
cluster0_alert: cluster0_alert {
temperature = <70000>; /* millicelsius */
hysteresis = <2000>; /* millicelsius */
type = "passive";
};
cluster0_crit: cluster0_crit {
temperature = <90000>; /* millicelsius */
hysteresis = <2000>; /* millicelsius */
type = "critical";
};
};

cooling-maps {
map0 {
trip = <&cluster0_alert>;
cooling-device =
<&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
};
};
};

gpu: gpu {
polling-delay-passive = <1000>; /* milliseconds */
polling-delay = <5000>; /* milliseconds */

/* sensor ID */
thermal-sensors = <&tsensor 3>;

trips {
gpu_alert: gpu_alert {
temperature = <70000>; /* millicelsius */
hysteresis = <2000>; /* millicelsius */
type = "passive";
};
gpu_crit: gpu_crit {
temperature = <90000>; /* millicelsius */
hysteresis = <2000>; /* millicelsius */
type = "critical";
};
};

cooling-maps {
/* There are currently no cooling maps because there are no cooling devices */
};
};
};
};
9 changes: 8 additions & 1 deletion arch/arm64/configs/defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,14 @@ CONFIG_SPI=y
CONFIG_SPI_PL022=y
CONFIG_GPIO_SYSFS=y
CONFIG_GPIO_XGENE=y
CONFIG_SENSORS_HI6220=y
CONFIG_THERMAL=y
CONFIG_THERMAL_HWMON=y
CONFIG_THERMAL_OF=y
CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE=y
CONFIG_THERMAL_GOV_STEP_WISE=y
CONFIG_THERMAL_GOV_USER_SPACE=y
CONFIG_CPU_THERMAL=y
CONFIG_HISI_THERMAL=y
CONFIG_REGULATOR=y
CONFIG_REGULATOR_FIXED_VOLTAGE=y
CONFIG_REGULATOR_HI6220=y
Expand Down
1 change: 1 addition & 0 deletions drivers/clk/hisilicon/clk-hi6220.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ static struct hisi_gate_clock hi6220_separated_gate_clks_sys[] __initdata = {
{ HI6220_UART3_PCLK, "uart3_pclk", "uart3_src", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x230, 7, 0, },
{ HI6220_UART4_PCLK, "uart4_pclk", "uart4_src", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x230, 8, 0, },
{ HI6220_SPI_CLK, "spi_clk", "clk_150m", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x230, 9, 0, },
{ HI6220_TSENSOR_CLK, "tsensor_clk", "clk_bus", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x230, 12, 0, },
{ HI6220_MMU_CLK, "mmu_clk", "ddrc_axi1", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x240, 11, 0, },
{ HI6220_HIFI_SEL, "hifi_sel", "hifi_src", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x270, 0, 0, },
{ HI6220_MMC0_SYSPLL, "mmc0_syspll", "syspll", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x270, 1, 0, },
Expand Down
46 changes: 40 additions & 6 deletions drivers/cpufreq/hisi-acpu-cpufreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

#include <linux/clk.h>
#include <linux/cpu_cooling.h>
#include <linux/cpu.h>
#include <linux/cpufreq.h>
#include <linux/cpumask.h>
Expand All @@ -41,10 +42,16 @@ static atomic_t cluster_usage[MAX_CLUSTERS] = {

static struct clk *clk[MAX_CLUSTERS];
static struct mutex cluster_lock[MAX_CLUSTERS];
static struct thermal_cooling_device *cdev;

static inline int cpu_to_cluster(int cpu)
{
return coupled_clusters ? 0 : topology_physical_package_id(cpu);
}

static unsigned int hisi_acpu_cpufreq_get_rate(unsigned int cpu)
{
int cluster = topology_physical_package_id(cpu);
int cluster = cpu_to_cluster(cpu);
unsigned int freq;

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

cluster = topology_physical_package_id(cpu);
cluster = cpu_to_cluster(cpu);
freqs_new = freq_table[cluster][index].frequency;

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

static void put_cluster_clk_and_freq_table(struct device *cpu_dev)
{
u32 cluster = topology_physical_package_id(cpu_dev->id);
u32 cluster = cpu_to_cluster(cpu_dev->id);

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

cluster = topology_physical_package_id(cpu_dev->id);
cluster = cpu_to_cluster(cpu_dev->id);

if (atomic_inc_return(&cluster_usage[cluster]) != 1)
return 0;
Expand Down Expand Up @@ -158,7 +165,7 @@ static int get_cluster_clk_and_freq_table(struct device *cpu_dev)
/* Per-CPU initialization */
static int hisi_acpu_cpufreq_init(struct cpufreq_policy *policy)
{
u32 cur_cluster = topology_physical_package_id(policy->cpu);
u32 cur_cluster = cpu_to_cluster(policy->cpu);
struct device *cpu_dev;
int ret;

Expand Down Expand Up @@ -243,7 +250,7 @@ MODULE_DEVICE_TABLE(of, hisi_acpu_cpufreq_match);
static int hisi_acpu_cpufreq_probe(struct platform_device *pdev)
{
int ret = 0, i;
struct device_node *np;
struct device_node *np, *cpus;

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

cpus = of_find_node_by_path("/cpus");
if (!cpus) {
dev_err(&pdev->dev, "failed to find cpus node\n");
return 0;
}

np = of_get_next_child(cpus, NULL);
if (!np) {
dev_err(&pdev->dev, "failed to find cpus child node\n");
of_node_put(cpus);
return 0;
}

if (of_find_property(np, "#cooling-cells", NULL)) {
cdev = of_cpufreq_cooling_register(np, cpu_present_mask);
if (IS_ERR(cdev)) {
dev_err(&pdev->dev, "running cpufreq without cooling device: %ld\n",
PTR_ERR(cdev));
cdev = NULL;
}
}
of_node_put(np);
of_node_put(cpus);

return 0;

out:
return ret;
}

static int hisi_acpu_cpufreq_remove(struct platform_device *pdev)
{
cpufreq_cooling_unregister(cdev);
cpufreq_unregister_driver(&hisi_acpu_cpufreq_driver);
return 0;
}
Expand Down
9 changes: 6 additions & 3 deletions drivers/hwmon/lm75.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ static struct attribute *lm75_attrs[] = {
};
ATTRIBUTE_GROUPS(lm75);

static const struct thermal_zone_of_device_ops lm75_of_thermal_ops = {
.get_temp = lm75_read_temp,
};

/*-----------------------------------------------------------------------*/

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

data->tz = thermal_zone_of_sensor_register(data->hwmon_dev,
0,
data->tz = thermal_zone_of_sensor_register(data->hwmon_dev, 0,
data->hwmon_dev,
lm75_read_temp, NULL);
&lm75_of_thermal_ops);
if (IS_ERR(data->tz))
data->tz = NULL;

Expand Down
6 changes: 5 additions & 1 deletion drivers/hwmon/ntc_thermistor.c
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,10 @@ static const struct attribute_group ntc_attr_group = {
.attrs = ntc_attributes,
};

static const struct thermal_zone_of_device_ops ntc_of_thermal_ops = {
.get_temp = ntc_read_temp,
};

static int ntc_thermistor_probe(struct platform_device *pdev)
{
const struct of_device_id *of_id =
Expand Down Expand Up @@ -579,7 +583,7 @@ static int ntc_thermistor_probe(struct platform_device *pdev)
pdev_id->name);

data->tz = thermal_zone_of_sensor_register(data->dev, 0, data->dev,
ntc_read_temp, NULL);
&ntc_of_thermal_ops);
if (IS_ERR(data->tz)) {
dev_dbg(&pdev->dev, "Failed to register to thermal fw.\n");
data->tz = NULL;
Expand Down
Loading

0 comments on commit 8bc8cde

Please sign in to comment.