Re: [PATCH v13 1/5] thermal: rockchip: add driver for thermal

2014-10-24 Thread Caesar Wang


在 2014/10/24 16:21, Dmitry Torokhov 写道:

On Thu, Oct 23, 2014 at 05:55:46PM -0700, Dmitry Torokhov wrote:

Hi Caesar,

On Thu, Oct 23, 2014 at 05:40:03PM +0800, Caesar Wang wrote:

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 
---
  drivers/thermal/Kconfig|   9 +
  drivers/thermal/Makefile   |   1 +
  drivers/thermal/rockchip_thermal.c | 693 +
  3 files changed, 703 insertions(+)
  create mode 100644 drivers/thermal/rockchip_thermal.c

diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
index ef5587f..5efcf73 100644
--- a/drivers/thermal/Kconfig
+++ b/drivers/thermal/Kconfig
@@ -133,6 +133,15 @@ config SPEAR_THERMAL
  Enable this to plug the SPEAr thermal sensor driver into the Linux
  thermal framework.
  
+config ROCKCHIP_THERMAL

+   tristate "Rockchip thermal driver"
+   depends on ARCH_ROCKCHIP
+   help
+ Rockchip thermal driver provides support for Temperature sensor
+ ADC (TS-ADC) found on Rockchip SoCs. It supports one critical
+ trip point. Cpufreq is used as the cooling device and will throttle
+ CPUs when the Temperature crosses the passive trip point.
+
  config RCAR_THERMAL
tristate "Renesas R-Car thermal driver"
depends on ARCH_SHMOBILE || COMPILE_TEST
diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile
index 31e232f..21da0a8 100644
--- a/drivers/thermal/Makefile
+++ b/drivers/thermal/Makefile
@@ -19,6 +19,7 @@ thermal_sys-$(CONFIG_CPU_THERMAL) += cpu_cooling.o
  
  # platform thermal drivers

  obj-$(CONFIG_SPEAR_THERMAL)   += spear_thermal.o
+obj-$(CONFIG_ROCKCHIP_THERMAL) += rockchip_thermal.o
  obj-$(CONFIG_RCAR_THERMAL)+= rcar_thermal.o
  obj-$(CONFIG_KIRKWOOD_THERMAL)  += kirkwood_thermal.o
  obj-y += samsung/
diff --git a/drivers/thermal/rockchip_thermal.c 
b/drivers/thermal/rockchip_thermal.c
new file mode 100644
index 000..6705981
--- /dev/null
+++ b/drivers/thermal/rockchip_thermal.c
@@ -0,0 +1,693 @@
+/*
+ * Copyright (c) 2014, Fuzhou Rockchip Electronics Co., Ltd
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/**
+ * 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.
+ */
+enum tshut_mode {
+   TSHUT_MODE_CRU = 0,
+   TSHUT_MODE_GPIO,
+};
+
+/**
+ * the system Temperature Sensors tshut(tshut) polarity
+ * the bit 8 is tshut polarity.
+ * 0: low active, 1: high active
+ */
+enum tshut_polarity {
+   TSHUT_LOW_ACTIVE = 0,
+   TSHUT_HIGH_ACTIVE,
+};
+
+/**
+ * The system has three Temperature Sensors.  channel 0 is reserved,
+ * channel 1 is for CPU, and channel 2 is for GPU.
+ */
+enum sensor_id {
+   SENSOR_CPU = 1,
+   SENSOR_GPU,
+};
+
+
+struct rockchip_tsadc_chip {
+   long hw_shut_temp;
+   enum tshut_mode tshut_mode;
+   enum tshut_polarity tshut_polarity;
+
+   /* Chip-wide methods */
+   void (*initialize)(void __iomem *reg, enum tshut_polarity p);
+   void (*irq_ack)(void __iomem *reg);
+
+   /* Per-sensor methods */
+   int (*get_temp)(int chn, void __iomem *reg, long *temp);
+   void (*set_alarm_temp)(int chn, void __iomem *reg, long temp);
+   void (*set_tshut_temp)(int chn, void __iomem *reg, long temp);
+   void (*set_tshut_mode)(int chn, void __iomem *reg, enum tshut_mode m);
+   void (*control)(int chn, void __iomem *reg, bool on);
+};
+
+struct rockchip_thermal_sensor {
+   struct rockchip_thermal_data *thermal;
+   struct thermal_zone_device *tzd;
+   enum sensor_id id;
+};
+
+#define NUM_SENSORS2 /* Ignore unused sensor 0 */
+
+struct rockchip_thermal_data {
+   const struct rockchip_tsadc_chip *chip;
+   struct platform_device *pdev;
+
+   struct rockchip_thermal_sensor sensors[NUM_SENSORS];
+
+   

Re: [PATCH v13 1/5] thermal: rockchip: add driver for thermal

2014-10-24 Thread Dmitry Torokhov
On Thu, Oct 23, 2014 at 05:55:46PM -0700, Dmitry Torokhov wrote:
> Hi Caesar,
> 
> On Thu, Oct 23, 2014 at 05:40:03PM +0800, Caesar Wang wrote:
> > 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 
> > ---
> >  drivers/thermal/Kconfig|   9 +
> >  drivers/thermal/Makefile   |   1 +
> >  drivers/thermal/rockchip_thermal.c | 693 
> > +
> >  3 files changed, 703 insertions(+)
> >  create mode 100644 drivers/thermal/rockchip_thermal.c
> > 
> > diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
> > index ef5587f..5efcf73 100644
> > --- a/drivers/thermal/Kconfig
> > +++ b/drivers/thermal/Kconfig
> > @@ -133,6 +133,15 @@ config SPEAR_THERMAL
> >   Enable this to plug the SPEAr thermal sensor driver into the Linux
> >   thermal framework.
> >  
> > +config ROCKCHIP_THERMAL
> > +   tristate "Rockchip thermal driver"
> > +   depends on ARCH_ROCKCHIP
> > +   help
> > + Rockchip thermal driver provides support for Temperature sensor
> > + ADC (TS-ADC) found on Rockchip SoCs. It supports one critical
> > + trip point. Cpufreq is used as the cooling device and will throttle
> > + CPUs when the Temperature crosses the passive trip point.
> > +
> >  config RCAR_THERMAL
> > tristate "Renesas R-Car thermal driver"
> > depends on ARCH_SHMOBILE || COMPILE_TEST
> > diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile
> > index 31e232f..21da0a8 100644
> > --- a/drivers/thermal/Makefile
> > +++ b/drivers/thermal/Makefile
> > @@ -19,6 +19,7 @@ thermal_sys-$(CONFIG_CPU_THERMAL) += cpu_cooling.o
> >  
> >  # platform thermal drivers
> >  obj-$(CONFIG_SPEAR_THERMAL)+= spear_thermal.o
> > +obj-$(CONFIG_ROCKCHIP_THERMAL) += rockchip_thermal.o
> >  obj-$(CONFIG_RCAR_THERMAL) += rcar_thermal.o
> >  obj-$(CONFIG_KIRKWOOD_THERMAL)  += kirkwood_thermal.o
> >  obj-y  += samsung/
> > diff --git a/drivers/thermal/rockchip_thermal.c 
> > b/drivers/thermal/rockchip_thermal.c
> > new file mode 100644
> > index 000..6705981
> > --- /dev/null
> > +++ b/drivers/thermal/rockchip_thermal.c
> > @@ -0,0 +1,693 @@
> > +/*
> > + * Copyright (c) 2014, Fuzhou Rockchip Electronics Co., Ltd
> > + *
> > + * This program is free software; you can redistribute it and/or modify it
> > + * under the terms and conditions of the GNU General Public License,
> > + * version 2, as published by the Free Software Foundation.
> > + *
> > + * This program is distributed in the hope it will be useful, but WITHOUT
> > + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> > + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License 
> > for
> > + * more details.
> > + */
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +/**
> > + * 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.
> > + */
> > +enum tshut_mode {
> > +   TSHUT_MODE_CRU = 0,
> > +   TSHUT_MODE_GPIO,
> > +};
> > +
> > +/**
> > + * the system Temperature Sensors tshut(tshut) polarity
> > + * the bit 8 is tshut polarity.
> > + * 0: low active, 1: high active
> > + */
> > +enum tshut_polarity {
> > +   TSHUT_LOW_ACTIVE = 0,
> > +   TSHUT_HIGH_ACTIVE,
> > +};
> > +
> > +/**
> > + * The system has three Temperature Sensors.  channel 0 is reserved,
> > + * channel 1 is for CPU, and channel 2 is for GPU.
> > + */
> > +enum sensor_id {
> > +   SENSOR_CPU = 1,
> > +   SENSOR_GPU,
> > +};
> > +
> > +
> > +struct rockchip_tsadc_chip {
> > +   long hw_shut_temp;
> > +   enum tshut_mode tshut_mode;
> > +   enum tshut_polarity tshut_polarity;
> > +
> > +   /* Chip-wide methods */
> > +   void (*initialize)(void __iomem *reg, enum tshut_polarity p);
> > +   void (*irq_ack)(void __iomem *reg);
> > +
> > +   /* Per-sensor methods */
> > +   int (*get_temp)(int chn, void __iomem *reg, long *temp);
> > +   void (*set_alarm_temp)(int chn, void __iomem *reg, long temp);
> > +   void (*set_tshut_temp)(int chn, void __iomem *reg, long temp);
> > +   void (*set_tshut_mode)(int chn, void __iomem *reg, enum tshut_mode m);
> > +   void (*control)(int chn, void __iomem *reg, bool on);
> > +};
> > +
> > +struct 

Re: [PATCH v13 1/5] thermal: rockchip: add driver for thermal

2014-10-24 Thread Dmitry Torokhov
On Thu, Oct 23, 2014 at 05:55:46PM -0700, Dmitry Torokhov wrote:
 Hi Caesar,
 
 On Thu, Oct 23, 2014 at 05:40:03PM +0800, Caesar Wang wrote:
  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 z...@rock-chips.com
  Signed-off-by: Caesar Wang caesar.w...@rock-chips.com
  ---
   drivers/thermal/Kconfig|   9 +
   drivers/thermal/Makefile   |   1 +
   drivers/thermal/rockchip_thermal.c | 693 
  +
   3 files changed, 703 insertions(+)
   create mode 100644 drivers/thermal/rockchip_thermal.c
  
  diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
  index ef5587f..5efcf73 100644
  --- a/drivers/thermal/Kconfig
  +++ b/drivers/thermal/Kconfig
  @@ -133,6 +133,15 @@ config SPEAR_THERMAL
Enable this to plug the SPEAr thermal sensor driver into the Linux
thermal framework.
   
  +config ROCKCHIP_THERMAL
  +   tristate Rockchip thermal driver
  +   depends on ARCH_ROCKCHIP
  +   help
  + Rockchip thermal driver provides support for Temperature sensor
  + ADC (TS-ADC) found on Rockchip SoCs. It supports one critical
  + trip point. Cpufreq is used as the cooling device and will throttle
  + CPUs when the Temperature crosses the passive trip point.
  +
   config RCAR_THERMAL
  tristate Renesas R-Car thermal driver
  depends on ARCH_SHMOBILE || COMPILE_TEST
  diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile
  index 31e232f..21da0a8 100644
  --- a/drivers/thermal/Makefile
  +++ b/drivers/thermal/Makefile
  @@ -19,6 +19,7 @@ thermal_sys-$(CONFIG_CPU_THERMAL) += cpu_cooling.o
   
   # platform thermal drivers
   obj-$(CONFIG_SPEAR_THERMAL)+= spear_thermal.o
  +obj-$(CONFIG_ROCKCHIP_THERMAL) += rockchip_thermal.o
   obj-$(CONFIG_RCAR_THERMAL) += rcar_thermal.o
   obj-$(CONFIG_KIRKWOOD_THERMAL)  += kirkwood_thermal.o
   obj-y  += samsung/
  diff --git a/drivers/thermal/rockchip_thermal.c 
  b/drivers/thermal/rockchip_thermal.c
  new file mode 100644
  index 000..6705981
  --- /dev/null
  +++ b/drivers/thermal/rockchip_thermal.c
  @@ -0,0 +1,693 @@
  +/*
  + * Copyright (c) 2014, Fuzhou Rockchip Electronics Co., Ltd
  + *
  + * This program is free software; you can redistribute it and/or modify it
  + * under the terms and conditions of the GNU General Public License,
  + * version 2, as published by the Free Software Foundation.
  + *
  + * This program is distributed in the hope it will be useful, but WITHOUT
  + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License 
  for
  + * more details.
  + */
  +
  +#include linux/clk.h
  +#include linux/cpu_cooling.h
  +#include linux/interrupt.h
  +#include linux/io.h
  +#include linux/module.h
  +#include linux/of.h
  +#include linux/of_address.h
  +#include linux/of_irq.h
  +#include linux/platform_device.h
  +#include linux/thermal.h
  +
  +/**
  + * 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.
  + */
  +enum tshut_mode {
  +   TSHUT_MODE_CRU = 0,
  +   TSHUT_MODE_GPIO,
  +};
  +
  +/**
  + * the system Temperature Sensors tshut(tshut) polarity
  + * the bit 8 is tshut polarity.
  + * 0: low active, 1: high active
  + */
  +enum tshut_polarity {
  +   TSHUT_LOW_ACTIVE = 0,
  +   TSHUT_HIGH_ACTIVE,
  +};
  +
  +/**
  + * The system has three Temperature Sensors.  channel 0 is reserved,
  + * channel 1 is for CPU, and channel 2 is for GPU.
  + */
  +enum sensor_id {
  +   SENSOR_CPU = 1,
  +   SENSOR_GPU,
  +};
  +
  +
  +struct rockchip_tsadc_chip {
  +   long hw_shut_temp;
  +   enum tshut_mode tshut_mode;
  +   enum tshut_polarity tshut_polarity;
  +
  +   /* Chip-wide methods */
  +   void (*initialize)(void __iomem *reg, enum tshut_polarity p);
  +   void (*irq_ack)(void __iomem *reg);
  +
  +   /* Per-sensor methods */
  +   int (*get_temp)(int chn, void __iomem *reg, long *temp);
  +   void (*set_alarm_temp)(int chn, void __iomem *reg, long temp);
  +   void (*set_tshut_temp)(int chn, void __iomem *reg, long temp);
  +   void (*set_tshut_mode)(int chn, void __iomem *reg, enum tshut_mode m);
  +   void (*control)(int chn, void __iomem *reg, bool on);
  +};
  +
  +struct rockchip_thermal_sensor {
  +   struct rockchip_thermal_data *thermal;
  +   struct 

Re: [PATCH v13 1/5] thermal: rockchip: add driver for thermal

2014-10-24 Thread Caesar Wang


在 2014/10/24 16:21, Dmitry Torokhov 写道:

On Thu, Oct 23, 2014 at 05:55:46PM -0700, Dmitry Torokhov wrote:

Hi Caesar,

On Thu, Oct 23, 2014 at 05:40:03PM +0800, Caesar Wang wrote:

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 z...@rock-chips.com
Signed-off-by: Caesar Wang caesar.w...@rock-chips.com
---
  drivers/thermal/Kconfig|   9 +
  drivers/thermal/Makefile   |   1 +
  drivers/thermal/rockchip_thermal.c | 693 +
  3 files changed, 703 insertions(+)
  create mode 100644 drivers/thermal/rockchip_thermal.c

diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
index ef5587f..5efcf73 100644
--- a/drivers/thermal/Kconfig
+++ b/drivers/thermal/Kconfig
@@ -133,6 +133,15 @@ config SPEAR_THERMAL
  Enable this to plug the SPEAr thermal sensor driver into the Linux
  thermal framework.
  
+config ROCKCHIP_THERMAL

+   tristate Rockchip thermal driver
+   depends on ARCH_ROCKCHIP
+   help
+ Rockchip thermal driver provides support for Temperature sensor
+ ADC (TS-ADC) found on Rockchip SoCs. It supports one critical
+ trip point. Cpufreq is used as the cooling device and will throttle
+ CPUs when the Temperature crosses the passive trip point.
+
  config RCAR_THERMAL
tristate Renesas R-Car thermal driver
depends on ARCH_SHMOBILE || COMPILE_TEST
diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile
index 31e232f..21da0a8 100644
--- a/drivers/thermal/Makefile
+++ b/drivers/thermal/Makefile
@@ -19,6 +19,7 @@ thermal_sys-$(CONFIG_CPU_THERMAL) += cpu_cooling.o
  
  # platform thermal drivers

  obj-$(CONFIG_SPEAR_THERMAL)   += spear_thermal.o
+obj-$(CONFIG_ROCKCHIP_THERMAL) += rockchip_thermal.o
  obj-$(CONFIG_RCAR_THERMAL)+= rcar_thermal.o
  obj-$(CONFIG_KIRKWOOD_THERMAL)  += kirkwood_thermal.o
  obj-y += samsung/
diff --git a/drivers/thermal/rockchip_thermal.c 
b/drivers/thermal/rockchip_thermal.c
new file mode 100644
index 000..6705981
--- /dev/null
+++ b/drivers/thermal/rockchip_thermal.c
@@ -0,0 +1,693 @@
+/*
+ * Copyright (c) 2014, Fuzhou Rockchip Electronics Co., Ltd
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ */
+
+#include linux/clk.h
+#include linux/cpu_cooling.h
+#include linux/interrupt.h
+#include linux/io.h
+#include linux/module.h
+#include linux/of.h
+#include linux/of_address.h
+#include linux/of_irq.h
+#include linux/platform_device.h
+#include linux/thermal.h
+
+/**
+ * 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.
+ */
+enum tshut_mode {
+   TSHUT_MODE_CRU = 0,
+   TSHUT_MODE_GPIO,
+};
+
+/**
+ * the system Temperature Sensors tshut(tshut) polarity
+ * the bit 8 is tshut polarity.
+ * 0: low active, 1: high active
+ */
+enum tshut_polarity {
+   TSHUT_LOW_ACTIVE = 0,
+   TSHUT_HIGH_ACTIVE,
+};
+
+/**
+ * The system has three Temperature Sensors.  channel 0 is reserved,
+ * channel 1 is for CPU, and channel 2 is for GPU.
+ */
+enum sensor_id {
+   SENSOR_CPU = 1,
+   SENSOR_GPU,
+};
+
+
+struct rockchip_tsadc_chip {
+   long hw_shut_temp;
+   enum tshut_mode tshut_mode;
+   enum tshut_polarity tshut_polarity;
+
+   /* Chip-wide methods */
+   void (*initialize)(void __iomem *reg, enum tshut_polarity p);
+   void (*irq_ack)(void __iomem *reg);
+
+   /* Per-sensor methods */
+   int (*get_temp)(int chn, void __iomem *reg, long *temp);
+   void (*set_alarm_temp)(int chn, void __iomem *reg, long temp);
+   void (*set_tshut_temp)(int chn, void __iomem *reg, long temp);
+   void (*set_tshut_mode)(int chn, void __iomem *reg, enum tshut_mode m);
+   void (*control)(int chn, void __iomem *reg, bool on);
+};
+
+struct rockchip_thermal_sensor {
+   struct rockchip_thermal_data *thermal;
+   struct thermal_zone_device *tzd;
+   enum sensor_id id;
+};
+
+#define NUM_SENSORS2 /* Ignore unused sensor 0 */
+

Re: [PATCH v13 1/5] thermal: rockchip: add driver for thermal

2014-10-23 Thread Dmitry Torokhov
Hi Caesar,

On Thu, Oct 23, 2014 at 05:40:03PM +0800, Caesar Wang wrote:
> 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 
> ---
>  drivers/thermal/Kconfig|   9 +
>  drivers/thermal/Makefile   |   1 +
>  drivers/thermal/rockchip_thermal.c | 693 
> +
>  3 files changed, 703 insertions(+)
>  create mode 100644 drivers/thermal/rockchip_thermal.c
> 
> diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
> index ef5587f..5efcf73 100644
> --- a/drivers/thermal/Kconfig
> +++ b/drivers/thermal/Kconfig
> @@ -133,6 +133,15 @@ config SPEAR_THERMAL
> Enable this to plug the SPEAr thermal sensor driver into the Linux
> thermal framework.
>  
> +config ROCKCHIP_THERMAL
> + tristate "Rockchip thermal driver"
> + depends on ARCH_ROCKCHIP
> + help
> +   Rockchip thermal driver provides support for Temperature sensor
> +   ADC (TS-ADC) found on Rockchip SoCs. It supports one critical
> +   trip point. Cpufreq is used as the cooling device and will throttle
> +   CPUs when the Temperature crosses the passive trip point.
> +
>  config RCAR_THERMAL
>   tristate "Renesas R-Car thermal driver"
>   depends on ARCH_SHMOBILE || COMPILE_TEST
> diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile
> index 31e232f..21da0a8 100644
> --- a/drivers/thermal/Makefile
> +++ b/drivers/thermal/Makefile
> @@ -19,6 +19,7 @@ thermal_sys-$(CONFIG_CPU_THERMAL)   += cpu_cooling.o
>  
>  # platform thermal drivers
>  obj-$(CONFIG_SPEAR_THERMAL)  += spear_thermal.o
> +obj-$(CONFIG_ROCKCHIP_THERMAL)   += rockchip_thermal.o
>  obj-$(CONFIG_RCAR_THERMAL)   += rcar_thermal.o
>  obj-$(CONFIG_KIRKWOOD_THERMAL)  += kirkwood_thermal.o
>  obj-y+= samsung/
> diff --git a/drivers/thermal/rockchip_thermal.c 
> b/drivers/thermal/rockchip_thermal.c
> new file mode 100644
> index 000..6705981
> --- /dev/null
> +++ b/drivers/thermal/rockchip_thermal.c
> @@ -0,0 +1,693 @@
> +/*
> + * Copyright (c) 2014, Fuzhou Rockchip Electronics Co., Ltd
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms and conditions of the GNU General Public License,
> + * version 2, as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope it will be useful, but WITHOUT
> + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
> + * more details.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +/**
> + * 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.
> + */
> +enum tshut_mode {
> + TSHUT_MODE_CRU = 0,
> + TSHUT_MODE_GPIO,
> +};
> +
> +/**
> + * the system Temperature Sensors tshut(tshut) polarity
> + * the bit 8 is tshut polarity.
> + * 0: low active, 1: high active
> + */
> +enum tshut_polarity {
> + TSHUT_LOW_ACTIVE = 0,
> + TSHUT_HIGH_ACTIVE,
> +};
> +
> +/**
> + * The system has three Temperature Sensors.  channel 0 is reserved,
> + * channel 1 is for CPU, and channel 2 is for GPU.
> + */
> +enum sensor_id {
> + SENSOR_CPU = 1,
> + SENSOR_GPU,
> +};
> +
> +
> +struct rockchip_tsadc_chip {
> + long hw_shut_temp;
> + enum tshut_mode tshut_mode;
> + enum tshut_polarity tshut_polarity;
> +
> + /* Chip-wide methods */
> + void (*initialize)(void __iomem *reg, enum tshut_polarity p);
> + void (*irq_ack)(void __iomem *reg);
> +
> + /* Per-sensor methods */
> + int (*get_temp)(int chn, void __iomem *reg, long *temp);
> + void (*set_alarm_temp)(int chn, void __iomem *reg, long temp);
> + void (*set_tshut_temp)(int chn, void __iomem *reg, long temp);
> + void (*set_tshut_mode)(int chn, void __iomem *reg, enum tshut_mode m);
> + void (*control)(int chn, void __iomem *reg, bool on);
> +};
> +
> +struct rockchip_thermal_sensor {
> + struct rockchip_thermal_data *thermal;
> + struct thermal_zone_device *tzd;
> + enum sensor_id id;
> +};
> +
> +#define NUM_SENSORS  2 /* Ignore unused sensor 0 */
> +
> +struct rockchip_thermal_data {
> + const struct rockchip_tsadc_chip *chip;
> + 

[PATCH v13 1/5] thermal: rockchip: add driver for thermal

2014-10-23 Thread Caesar Wang
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 
---
 drivers/thermal/Kconfig|   9 +
 drivers/thermal/Makefile   |   1 +
 drivers/thermal/rockchip_thermal.c | 693 +
 3 files changed, 703 insertions(+)
 create mode 100644 drivers/thermal/rockchip_thermal.c

diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
index ef5587f..5efcf73 100644
--- a/drivers/thermal/Kconfig
+++ b/drivers/thermal/Kconfig
@@ -133,6 +133,15 @@ config SPEAR_THERMAL
  Enable this to plug the SPEAr thermal sensor driver into the Linux
  thermal framework.
 
+config ROCKCHIP_THERMAL
+   tristate "Rockchip thermal driver"
+   depends on ARCH_ROCKCHIP
+   help
+ Rockchip thermal driver provides support for Temperature sensor
+ ADC (TS-ADC) found on Rockchip SoCs. It supports one critical
+ trip point. Cpufreq is used as the cooling device and will throttle
+ CPUs when the Temperature crosses the passive trip point.
+
 config RCAR_THERMAL
tristate "Renesas R-Car thermal driver"
depends on ARCH_SHMOBILE || COMPILE_TEST
diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile
index 31e232f..21da0a8 100644
--- a/drivers/thermal/Makefile
+++ b/drivers/thermal/Makefile
@@ -19,6 +19,7 @@ thermal_sys-$(CONFIG_CPU_THERMAL) += cpu_cooling.o
 
 # platform thermal drivers
 obj-$(CONFIG_SPEAR_THERMAL)+= spear_thermal.o
+obj-$(CONFIG_ROCKCHIP_THERMAL) += rockchip_thermal.o
 obj-$(CONFIG_RCAR_THERMAL) += rcar_thermal.o
 obj-$(CONFIG_KIRKWOOD_THERMAL)  += kirkwood_thermal.o
 obj-y  += samsung/
diff --git a/drivers/thermal/rockchip_thermal.c 
b/drivers/thermal/rockchip_thermal.c
new file mode 100644
index 000..6705981
--- /dev/null
+++ b/drivers/thermal/rockchip_thermal.c
@@ -0,0 +1,693 @@
+/*
+ * Copyright (c) 2014, Fuzhou Rockchip Electronics Co., Ltd
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/**
+ * 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.
+ */
+enum tshut_mode {
+   TSHUT_MODE_CRU = 0,
+   TSHUT_MODE_GPIO,
+};
+
+/**
+ * the system Temperature Sensors tshut(tshut) polarity
+ * the bit 8 is tshut polarity.
+ * 0: low active, 1: high active
+ */
+enum tshut_polarity {
+   TSHUT_LOW_ACTIVE = 0,
+   TSHUT_HIGH_ACTIVE,
+};
+
+/**
+ * The system has three Temperature Sensors.  channel 0 is reserved,
+ * channel 1 is for CPU, and channel 2 is for GPU.
+ */
+enum sensor_id {
+   SENSOR_CPU = 1,
+   SENSOR_GPU,
+};
+
+
+struct rockchip_tsadc_chip {
+   long hw_shut_temp;
+   enum tshut_mode tshut_mode;
+   enum tshut_polarity tshut_polarity;
+
+   /* Chip-wide methods */
+   void (*initialize)(void __iomem *reg, enum tshut_polarity p);
+   void (*irq_ack)(void __iomem *reg);
+
+   /* Per-sensor methods */
+   int (*get_temp)(int chn, void __iomem *reg, long *temp);
+   void (*set_alarm_temp)(int chn, void __iomem *reg, long temp);
+   void (*set_tshut_temp)(int chn, void __iomem *reg, long temp);
+   void (*set_tshut_mode)(int chn, void __iomem *reg, enum tshut_mode m);
+   void (*control)(int chn, void __iomem *reg, bool on);
+};
+
+struct rockchip_thermal_sensor {
+   struct rockchip_thermal_data *thermal;
+   struct thermal_zone_device *tzd;
+   enum sensor_id id;
+};
+
+#define NUM_SENSORS2 /* Ignore unused sensor 0 */
+
+struct rockchip_thermal_data {
+   const struct rockchip_tsadc_chip *chip;
+   struct platform_device *pdev;
+
+   struct rockchip_thermal_sensor sensors[NUM_SENSORS];
+
+   struct thermal_cooling_device *cdev;
+
+   struct clk *clk;
+   struct clk *pclk;
+
+   void __iomem *regs;
+
+   long hw_shut_temp;
+   enum tshut_mode tshut_mode;
+   enum 

[PATCH v13 1/5] thermal: rockchip: add driver for thermal

2014-10-23 Thread Caesar Wang
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 z...@rock-chips.com
Signed-off-by: Caesar Wang caesar.w...@rock-chips.com
---
 drivers/thermal/Kconfig|   9 +
 drivers/thermal/Makefile   |   1 +
 drivers/thermal/rockchip_thermal.c | 693 +
 3 files changed, 703 insertions(+)
 create mode 100644 drivers/thermal/rockchip_thermal.c

diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
index ef5587f..5efcf73 100644
--- a/drivers/thermal/Kconfig
+++ b/drivers/thermal/Kconfig
@@ -133,6 +133,15 @@ config SPEAR_THERMAL
  Enable this to plug the SPEAr thermal sensor driver into the Linux
  thermal framework.
 
+config ROCKCHIP_THERMAL
+   tristate Rockchip thermal driver
+   depends on ARCH_ROCKCHIP
+   help
+ Rockchip thermal driver provides support for Temperature sensor
+ ADC (TS-ADC) found on Rockchip SoCs. It supports one critical
+ trip point. Cpufreq is used as the cooling device and will throttle
+ CPUs when the Temperature crosses the passive trip point.
+
 config RCAR_THERMAL
tristate Renesas R-Car thermal driver
depends on ARCH_SHMOBILE || COMPILE_TEST
diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile
index 31e232f..21da0a8 100644
--- a/drivers/thermal/Makefile
+++ b/drivers/thermal/Makefile
@@ -19,6 +19,7 @@ thermal_sys-$(CONFIG_CPU_THERMAL) += cpu_cooling.o
 
 # platform thermal drivers
 obj-$(CONFIG_SPEAR_THERMAL)+= spear_thermal.o
+obj-$(CONFIG_ROCKCHIP_THERMAL) += rockchip_thermal.o
 obj-$(CONFIG_RCAR_THERMAL) += rcar_thermal.o
 obj-$(CONFIG_KIRKWOOD_THERMAL)  += kirkwood_thermal.o
 obj-y  += samsung/
diff --git a/drivers/thermal/rockchip_thermal.c 
b/drivers/thermal/rockchip_thermal.c
new file mode 100644
index 000..6705981
--- /dev/null
+++ b/drivers/thermal/rockchip_thermal.c
@@ -0,0 +1,693 @@
+/*
+ * Copyright (c) 2014, Fuzhou Rockchip Electronics Co., Ltd
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ */
+
+#include linux/clk.h
+#include linux/cpu_cooling.h
+#include linux/interrupt.h
+#include linux/io.h
+#include linux/module.h
+#include linux/of.h
+#include linux/of_address.h
+#include linux/of_irq.h
+#include linux/platform_device.h
+#include linux/thermal.h
+
+/**
+ * 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.
+ */
+enum tshut_mode {
+   TSHUT_MODE_CRU = 0,
+   TSHUT_MODE_GPIO,
+};
+
+/**
+ * the system Temperature Sensors tshut(tshut) polarity
+ * the bit 8 is tshut polarity.
+ * 0: low active, 1: high active
+ */
+enum tshut_polarity {
+   TSHUT_LOW_ACTIVE = 0,
+   TSHUT_HIGH_ACTIVE,
+};
+
+/**
+ * The system has three Temperature Sensors.  channel 0 is reserved,
+ * channel 1 is for CPU, and channel 2 is for GPU.
+ */
+enum sensor_id {
+   SENSOR_CPU = 1,
+   SENSOR_GPU,
+};
+
+
+struct rockchip_tsadc_chip {
+   long hw_shut_temp;
+   enum tshut_mode tshut_mode;
+   enum tshut_polarity tshut_polarity;
+
+   /* Chip-wide methods */
+   void (*initialize)(void __iomem *reg, enum tshut_polarity p);
+   void (*irq_ack)(void __iomem *reg);
+
+   /* Per-sensor methods */
+   int (*get_temp)(int chn, void __iomem *reg, long *temp);
+   void (*set_alarm_temp)(int chn, void __iomem *reg, long temp);
+   void (*set_tshut_temp)(int chn, void __iomem *reg, long temp);
+   void (*set_tshut_mode)(int chn, void __iomem *reg, enum tshut_mode m);
+   void (*control)(int chn, void __iomem *reg, bool on);
+};
+
+struct rockchip_thermal_sensor {
+   struct rockchip_thermal_data *thermal;
+   struct thermal_zone_device *tzd;
+   enum sensor_id id;
+};
+
+#define NUM_SENSORS2 /* Ignore unused sensor 0 */
+
+struct rockchip_thermal_data {
+   const struct rockchip_tsadc_chip *chip;
+   struct platform_device *pdev;
+
+   struct rockchip_thermal_sensor sensors[NUM_SENSORS];
+
+   struct 

Re: [PATCH v13 1/5] thermal: rockchip: add driver for thermal

2014-10-23 Thread Dmitry Torokhov
Hi Caesar,

On Thu, Oct 23, 2014 at 05:40:03PM +0800, Caesar Wang wrote:
 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 z...@rock-chips.com
 Signed-off-by: Caesar Wang caesar.w...@rock-chips.com
 ---
  drivers/thermal/Kconfig|   9 +
  drivers/thermal/Makefile   |   1 +
  drivers/thermal/rockchip_thermal.c | 693 
 +
  3 files changed, 703 insertions(+)
  create mode 100644 drivers/thermal/rockchip_thermal.c
 
 diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
 index ef5587f..5efcf73 100644
 --- a/drivers/thermal/Kconfig
 +++ b/drivers/thermal/Kconfig
 @@ -133,6 +133,15 @@ config SPEAR_THERMAL
 Enable this to plug the SPEAr thermal sensor driver into the Linux
 thermal framework.
  
 +config ROCKCHIP_THERMAL
 + tristate Rockchip thermal driver
 + depends on ARCH_ROCKCHIP
 + help
 +   Rockchip thermal driver provides support for Temperature sensor
 +   ADC (TS-ADC) found on Rockchip SoCs. It supports one critical
 +   trip point. Cpufreq is used as the cooling device and will throttle
 +   CPUs when the Temperature crosses the passive trip point.
 +
  config RCAR_THERMAL
   tristate Renesas R-Car thermal driver
   depends on ARCH_SHMOBILE || COMPILE_TEST
 diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile
 index 31e232f..21da0a8 100644
 --- a/drivers/thermal/Makefile
 +++ b/drivers/thermal/Makefile
 @@ -19,6 +19,7 @@ thermal_sys-$(CONFIG_CPU_THERMAL)   += cpu_cooling.o
  
  # platform thermal drivers
  obj-$(CONFIG_SPEAR_THERMAL)  += spear_thermal.o
 +obj-$(CONFIG_ROCKCHIP_THERMAL)   += rockchip_thermal.o
  obj-$(CONFIG_RCAR_THERMAL)   += rcar_thermal.o
  obj-$(CONFIG_KIRKWOOD_THERMAL)  += kirkwood_thermal.o
  obj-y+= samsung/
 diff --git a/drivers/thermal/rockchip_thermal.c 
 b/drivers/thermal/rockchip_thermal.c
 new file mode 100644
 index 000..6705981
 --- /dev/null
 +++ b/drivers/thermal/rockchip_thermal.c
 @@ -0,0 +1,693 @@
 +/*
 + * Copyright (c) 2014, Fuzhou Rockchip Electronics Co., Ltd
 + *
 + * This program is free software; you can redistribute it and/or modify it
 + * under the terms and conditions of the GNU General Public License,
 + * version 2, as published by the Free Software Foundation.
 + *
 + * This program is distributed in the hope it will be useful, but WITHOUT
 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 + * more details.
 + */
 +
 +#include linux/clk.h
 +#include linux/cpu_cooling.h
 +#include linux/interrupt.h
 +#include linux/io.h
 +#include linux/module.h
 +#include linux/of.h
 +#include linux/of_address.h
 +#include linux/of_irq.h
 +#include linux/platform_device.h
 +#include linux/thermal.h
 +
 +/**
 + * 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.
 + */
 +enum tshut_mode {
 + TSHUT_MODE_CRU = 0,
 + TSHUT_MODE_GPIO,
 +};
 +
 +/**
 + * the system Temperature Sensors tshut(tshut) polarity
 + * the bit 8 is tshut polarity.
 + * 0: low active, 1: high active
 + */
 +enum tshut_polarity {
 + TSHUT_LOW_ACTIVE = 0,
 + TSHUT_HIGH_ACTIVE,
 +};
 +
 +/**
 + * The system has three Temperature Sensors.  channel 0 is reserved,
 + * channel 1 is for CPU, and channel 2 is for GPU.
 + */
 +enum sensor_id {
 + SENSOR_CPU = 1,
 + SENSOR_GPU,
 +};
 +
 +
 +struct rockchip_tsadc_chip {
 + long hw_shut_temp;
 + enum tshut_mode tshut_mode;
 + enum tshut_polarity tshut_polarity;
 +
 + /* Chip-wide methods */
 + void (*initialize)(void __iomem *reg, enum tshut_polarity p);
 + void (*irq_ack)(void __iomem *reg);
 +
 + /* Per-sensor methods */
 + int (*get_temp)(int chn, void __iomem *reg, long *temp);
 + void (*set_alarm_temp)(int chn, void __iomem *reg, long temp);
 + void (*set_tshut_temp)(int chn, void __iomem *reg, long temp);
 + void (*set_tshut_mode)(int chn, void __iomem *reg, enum tshut_mode m);
 + void (*control)(int chn, void __iomem *reg, bool on);
 +};
 +
 +struct rockchip_thermal_sensor {
 + struct rockchip_thermal_data *thermal;
 + struct thermal_zone_device *tzd;
 + enum sensor_id id;
 +};
 +
 +#define NUM_SENSORS  2 /* Ignore unused sensor 0 */
 +
 +struct rockchip_thermal_data {
 +