* [PATCH V2 1/2] dt-bindings: Add thermal zone to bcm2835-thermal example @ 2017-02-12 19:38 Stefan Wahren 2017-02-12 19:38 ` [PATCH V2 2/2] ARM: dts: bcm283x: Add CPU thermal zone with 1 trip point Stefan Wahren ` (2 more replies) 0 siblings, 3 replies; 10+ messages in thread From: Stefan Wahren @ 2017-02-12 19:38 UTC (permalink / raw) To: Eduardo Valentin, Zhang Rui, kernel Cc: Eric Anholt, Rob Herring, Frank Rowand, Florian Fainelli, linux-rpi-kernel, devicetree, linux-pm, Stefan Wahren Add a thermal zone in order to make the example complete. Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com> --- Changes in V2: - add missing thermal-sensor-cells property - change gpu-thermal to cpu-thermal .../bindings/thermal/brcm,bcm2835-thermal.txt | 29 +++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/Documentation/devicetree/bindings/thermal/brcm,bcm2835-thermal.txt b/Documentation/devicetree/bindings/thermal/brcm,bcm2835-thermal.txt index 474531d..6b8607a 100644 --- a/Documentation/devicetree/bindings/thermal/brcm,bcm2835-thermal.txt +++ b/Documentation/devicetree/bindings/thermal/brcm,bcm2835-thermal.txt @@ -3,15 +3,36 @@ Binding for Thermal Sensor driver for BCM2835 SoCs. Required parameters: ------------------- -compatible: should be one of: "brcm,bcm2835-thermal", - "brcm,bcm2836-thermal" or "brcm,bcm2837-thermal" -reg: Address range of the thermal registers. -clocks: Phandle of the clock used by the thermal sensor. +compatible: should be one of: "brcm,bcm2835-thermal", + "brcm,bcm2836-thermal" or "brcm,bcm2837-thermal" +reg: Address range of the thermal registers. +clocks: Phandle of the clock used by the thermal sensor. +#thermal-sensor-cells: should be 0 (see thermal.txt) Example: +thermal-zones { + cpu_thermal: cpu-thermal { + polling-delay-passive = <0>; + polling-delay = <1000>; + + thermal-sensors = <&thermal>; + + trips { + cpu-crit { + temperature = <80000>; + hysteresis = <0>; + type = "critical"; + }; + }; + cooling-maps { + }; + }; +}; + thermal: thermal@7e212000 { compatible = "brcm,bcm2835-thermal"; reg = <0x7e212000 0x8>; clocks = <&clocks BCM2835_CLOCK_TSENS>; + #thermal-sensor-cells = <0>; }; -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH V2 2/2] ARM: dts: bcm283x: Add CPU thermal zone with 1 trip point 2017-02-12 19:38 [PATCH V2 1/2] dt-bindings: Add thermal zone to bcm2835-thermal example Stefan Wahren @ 2017-02-12 19:38 ` Stefan Wahren [not found] ` <1486928328-25870-2-git-send-email-stefan.wahren-eS4NqCHxEME@public.gmane.org> [not found] ` <1486928328-25870-1-git-send-email-stefan.wahren-eS4NqCHxEME@public.gmane.org> 2017-02-22 14:55 ` Rob Herring 2 siblings, 1 reply; 10+ messages in thread From: Stefan Wahren @ 2017-02-12 19:38 UTC (permalink / raw) To: Eduardo Valentin, Zhang Rui, kernel Cc: Eric Anholt, Rob Herring, Frank Rowand, Florian Fainelli, linux-rpi-kernel, devicetree, linux-pm, Stefan Wahren As suggested by Eduardo Valentin this adds the thermal zone for the bcm2835 SoC with its single thermal sensor. We start with the criticial trip point and leave the cooling devices empty since we don't have any at the moment. Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com> --- Changes in V2: - add missing thermal-sensor-cells property - change gpu-thermal to cpu-thermal arch/arm/boot/dts/bcm283x.dtsi | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/arch/arm/boot/dts/bcm283x.dtsi b/arch/arm/boot/dts/bcm283x.dtsi index a3106aa..4dc74f6 100644 --- a/arch/arm/boot/dts/bcm283x.dtsi +++ b/arch/arm/boot/dts/bcm283x.dtsi @@ -19,6 +19,25 @@ bootargs = "earlyprintk console=ttyAMA0"; }; + thermal-zones { + cpu_thermal: cpu-thermal { + polling-delay-passive = <0>; + polling-delay = <1000>; + + thermal-sensors = <&thermal>; + + trips { + cpu-crit { + temperature = <80000>; + hysteresis = <0>; + type = "critical"; + }; + }; + cooling-maps { + }; + }; + }; + soc { compatible = "simple-bus"; #address-cells = <1>; @@ -394,6 +413,7 @@ compatible = "brcm,bcm2835-thermal"; reg = <0x7e212000 0x8>; clocks = <&clocks BCM2835_CLOCK_TSENS>; + #thermal-sensor-cells = <0>; status = "disabled"; }; -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 10+ messages in thread
[parent not found: <1486928328-25870-2-git-send-email-stefan.wahren-eS4NqCHxEME@public.gmane.org>]
* Re: [PATCH V2 2/2] ARM: dts: bcm283x: Add CPU thermal zone with 1 trip point [not found] ` <1486928328-25870-2-git-send-email-stefan.wahren-eS4NqCHxEME@public.gmane.org> @ 2017-02-19 1:17 ` Eduardo Valentin [not found] ` <20170219011753.GB21016-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org> 0 siblings, 1 reply; 10+ messages in thread From: Eduardo Valentin @ 2017-02-19 1:17 UTC (permalink / raw) To: Stefan Wahren Cc: Zhang Rui, kernel-TqfNSX0MhmxHKSADF0wUEw, Eric Anholt, Rob Herring, Frank Rowand, Florian Fainelli, linux-rpi-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, devicetree-u79uwXL29TY76Z2rM5mHXA, linux-pm-u79uwXL29TY76Z2rM5mHXA On Sun, Feb 12, 2017 at 07:38:48PM +0000, Stefan Wahren wrote: > As suggested by Eduardo Valentin this adds the thermal zone for > the bcm2835 SoC with its single thermal sensor. We start with > the criticial trip point and leave the cooling devices empty > since we don't have any at the moment. > > Signed-off-by: Stefan Wahren <stefan.wahren-eS4NqCHxEME@public.gmane.org> > --- > > Changes in V2: > - add missing thermal-sensor-cells property > - change gpu-thermal to cpu-thermal > > arch/arm/boot/dts/bcm283x.dtsi | 20 ++++++++++++++++++++ > 1 file changed, 20 insertions(+) > > diff --git a/arch/arm/boot/dts/bcm283x.dtsi b/arch/arm/boot/dts/bcm283x.dtsi > index a3106aa..4dc74f6 100644 > --- a/arch/arm/boot/dts/bcm283x.dtsi > +++ b/arch/arm/boot/dts/bcm283x.dtsi > @@ -19,6 +19,25 @@ > bootargs = "earlyprintk console=ttyAMA0"; > }; > > + thermal-zones { > + cpu_thermal: cpu-thermal { > + polling-delay-passive = <0>; > + polling-delay = <1000>; > + Check the diff I sent and also add the following for differentiating the offsets and slopes depending on which chip the zone describes: coefficients = <-538 407000>; /* for the zone on bcm2835 and bcm2836 */ and coefficients = <-538 412000>; /* for the zone on bcm2837 */ Despite the changes mentioned for the driver and DT, I am ok with the driver and the DTS descriptors. BR, -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <20170219011753.GB21016-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>]
* Re: [PATCH V2 2/2] ARM: dts: bcm283x: Add CPU thermal zone with 1 trip point [not found] ` <20170219011753.GB21016-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org> @ 2017-02-19 12:31 ` Stefan Wahren 2017-02-19 21:27 ` Eduardo Valentin 0 siblings, 1 reply; 10+ messages in thread From: Stefan Wahren @ 2017-02-19 12:31 UTC (permalink / raw) To: Eduardo Valentin Cc: Frank Rowand, kernel-TqfNSX0MhmxHKSADF0wUEw, Eric Anholt, Zhang Rui, Rob Herring, Florian Fainelli, linux-rpi-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, linux-pm-u79uwXL29TY76Z2rM5mHXA, devicetree-u79uwXL29TY76Z2rM5mHXA Hi Eduardo, > Eduardo Valentin <edubezval-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> hat am 19. Februar 2017 um 02:17 geschrieben: > > > On Sun, Feb 12, 2017 at 07:38:48PM +0000, Stefan Wahren wrote: > > As suggested by Eduardo Valentin this adds the thermal zone for > > the bcm2835 SoC with its single thermal sensor. We start with > > the criticial trip point and leave the cooling devices empty > > since we don't have any at the moment. > > > > Signed-off-by: Stefan Wahren <stefan.wahren-eS4NqCHxEME@public.gmane.org> > > --- > > > > Changes in V2: > > - add missing thermal-sensor-cells property > > - change gpu-thermal to cpu-thermal > > > > arch/arm/boot/dts/bcm283x.dtsi | 20 ++++++++++++++++++++ > > 1 file changed, 20 insertions(+) > > > > diff --git a/arch/arm/boot/dts/bcm283x.dtsi b/arch/arm/boot/dts/bcm283x.dtsi > > index a3106aa..4dc74f6 100644 > > --- a/arch/arm/boot/dts/bcm283x.dtsi > > +++ b/arch/arm/boot/dts/bcm283x.dtsi > > @@ -19,6 +19,25 @@ > > bootargs = "earlyprintk console=ttyAMA0"; > > }; > > > > + thermal-zones { > > + cpu_thermal: cpu-thermal { > > + polling-delay-passive = <0>; > > + polling-delay = <1000>; > > + > > Check the diff I sent and also add the following for differentiating the > offsets and slopes depending on which chip the zone describes: > coefficients = <-538 407000>; /* for the zone on bcm2835 and bcm2836 */ > > and > > coefficients = <-538 412000>; /* for the zone on bcm2837 */ > > > Despite the changes mentioned for the driver and DT, I am ok with the driver and the DTS descriptors. thanks for providing the necessary driver changes, but the coefficients above causes a DTC parse error. The Device Tree doesn't provide support for native signed integer. Looking at this old thread [1] suggests to add parentheses which fixed the parse issue. But of-thermal expected u32 for coefficients [2]. Any suggestions? [1] - http://lists.infradead.org/pipermail/linux-arm-kernel/2013-April/159681.html [2] - http://elixir.free-electrons.com/source/drivers/thermal/of-thermal.c?v=4.10-rc7#L854 > > BR, -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH V2 2/2] ARM: dts: bcm283x: Add CPU thermal zone with 1 trip point 2017-02-19 12:31 ` Stefan Wahren @ 2017-02-19 21:27 ` Eduardo Valentin 2017-02-21 18:14 ` Stefan Wahren 0 siblings, 1 reply; 10+ messages in thread From: Eduardo Valentin @ 2017-02-19 21:27 UTC (permalink / raw) To: Stefan Wahren Cc: Frank Rowand, kernel, Eric Anholt, Zhang Rui, Rob Herring, Florian Fainelli, linux-rpi-kernel, linux-pm, devicetree Hey Stefan, On Sun, Feb 19, 2017 at 01:31:49PM +0100, Stefan Wahren wrote: > Hi Eduardo, > > > Eduardo Valentin <edubezval@gmail.com> hat am 19. Februar 2017 um 02:17 geschrieben: > > > > > > On Sun, Feb 12, 2017 at 07:38:48PM +0000, Stefan Wahren wrote: > > > As suggested by Eduardo Valentin this adds the thermal zone for > > > the bcm2835 SoC with its single thermal sensor. We start with > > > the criticial trip point and leave the cooling devices empty > > > since we don't have any at the moment. > > > > > > Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com> > > > --- > > > > > > Changes in V2: > > > - add missing thermal-sensor-cells property > > > - change gpu-thermal to cpu-thermal > > > > > > arch/arm/boot/dts/bcm283x.dtsi | 20 ++++++++++++++++++++ > > > 1 file changed, 20 insertions(+) > > > > > > diff --git a/arch/arm/boot/dts/bcm283x.dtsi b/arch/arm/boot/dts/bcm283x.dtsi > > > index a3106aa..4dc74f6 100644 > > > --- a/arch/arm/boot/dts/bcm283x.dtsi > > > +++ b/arch/arm/boot/dts/bcm283x.dtsi > > > @@ -19,6 +19,25 @@ > > > bootargs = "earlyprintk console=ttyAMA0"; > > > }; > > > > > > + thermal-zones { > > > + cpu_thermal: cpu-thermal { > > > + polling-delay-passive = <0>; > > > + polling-delay = <1000>; > > > + > > > > Check the diff I sent and also add the following for differentiating the > > offsets and slopes depending on which chip the zone describes: > > coefficients = <-538 407000>; /* for the zone on bcm2835 and bcm2836 */ > > > > and > > > > coefficients = <-538 412000>; /* for the zone on bcm2837 */ > > > > > > Despite the changes mentioned for the driver and DT, I am ok with the driver and the DTS descriptors. > > thanks for providing the necessary driver changes, but the coefficients above causes a DTC parse error. The Device Tree doesn't provide support for native signed integer. Looking at this old thread [1] suggests to add parentheses which fixed the parse issue. But of-thermal expected u32 for coefficients [2]. > > Any suggestions? I am OK if you provide a patch to of-thermal in your series, assuming that would fix the representation issue the data of your driver has. BR, > > [1] - http://lists.infradead.org/pipermail/linux-arm-kernel/2013-April/159681.html > [2] - http://elixir.free-electrons.com/source/drivers/thermal/of-thermal.c?v=4.10-rc7#L854 > > > > > BR, ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH V2 2/2] ARM: dts: bcm283x: Add CPU thermal zone with 1 trip point 2017-02-19 21:27 ` Eduardo Valentin @ 2017-02-21 18:14 ` Stefan Wahren 2017-02-23 1:54 ` Eduardo Valentin 0 siblings, 1 reply; 10+ messages in thread From: Stefan Wahren @ 2017-02-21 18:14 UTC (permalink / raw) To: Eduardo Valentin, kernel Cc: Frank Rowand, Eric Anholt, Zhang Rui, Rob Herring, Florian Fainelli, linux-rpi-kernel, linux-pm, devicetree > Eduardo Valentin <edubezval@gmail.com> hat am 19. Februar 2017 um 22:27 geschrieben: > > > Hey Stefan, > > > On Sun, Feb 19, 2017 at 01:31:49PM +0100, Stefan Wahren wrote: > > Hi Eduardo, > > > > > Eduardo Valentin <edubezval@gmail.com> hat am 19. Februar 2017 um 02:17 geschrieben: > > > > > > > > > On Sun, Feb 12, 2017 at 07:38:48PM +0000, Stefan Wahren wrote: > > > > As suggested by Eduardo Valentin this adds the thermal zone for > > > > the bcm2835 SoC with its single thermal sensor. We start with > > > > the criticial trip point and leave the cooling devices empty > > > > since we don't have any at the moment. > > > > > > > > Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com> > > > > --- > > > > > > > > Changes in V2: > > > > - add missing thermal-sensor-cells property > > > > - change gpu-thermal to cpu-thermal > > > > > > > > arch/arm/boot/dts/bcm283x.dtsi | 20 ++++++++++++++++++++ > > > > 1 file changed, 20 insertions(+) > > > > > > > > diff --git a/arch/arm/boot/dts/bcm283x.dtsi b/arch/arm/boot/dts/bcm283x.dtsi > > > > index a3106aa..4dc74f6 100644 > > > > --- a/arch/arm/boot/dts/bcm283x.dtsi > > > > +++ b/arch/arm/boot/dts/bcm283x.dtsi > > > > @@ -19,6 +19,25 @@ > > > > bootargs = "earlyprintk console=ttyAMA0"; > > > > }; > > > > > > > > + thermal-zones { > > > > + cpu_thermal: cpu-thermal { > > > > + polling-delay-passive = <0>; > > > > + polling-delay = <1000>; > > > > + > > > > > > Check the diff I sent and also add the following for differentiating the > > > offsets and slopes depending on which chip the zone describes: > > > coefficients = <-538 407000>; /* for the zone on bcm2835 and bcm2836 */ > > > > > > and > > > > > > coefficients = <-538 412000>; /* for the zone on bcm2837 */ > > > > > > > > > Despite the changes mentioned for the driver and DT, I am ok with the driver and the DTS descriptors. > > > > thanks for providing the necessary driver changes, but the coefficients above causes a DTC parse error. The Device Tree doesn't provide support for native signed integer. Looking at this old thread [1] suggests to add parentheses which fixed the parse issue. But of-thermal expected u32 for coefficients [2]. > > > > Any suggestions? > > I am OK if you provide a patch to of-thermal in your series, assuming > that would fix the representation issue the data of your driver has. > I prepared a new patch series to fix that issue in my github repo [1]. At first we need to implement a new function of_property_read_s32_array() [2]. After that we could use this function in of-thermal in order to use signed integer for both coefficients [3]. @Eduardo: Is it okay for you? @Martin: Do you want to send the next version of the patch series or should i? [1] - https://github.com/lategoodbye/rpi-zero/commits/thermal [2] - https://github.com/lategoodbye/rpi-zero/commit/3dc43581ada74d1345f79b4c36562fdf5f7941e5 [3] - https://github.com/lategoodbye/rpi-zero/commit/c02ed37c0ebdca98aee570862af10e90b3c9a0d0 > BR, > > > > > [1] - http://lists.infradead.org/pipermail/linux-arm-kernel/2013-April/159681.html > > [2] - http://elixir.free-electrons.com/source/drivers/thermal/of-thermal.c?v=4.10-rc7#L854 > > > > > > > > BR, ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH V2 2/2] ARM: dts: bcm283x: Add CPU thermal zone with 1 trip point 2017-02-21 18:14 ` Stefan Wahren @ 2017-02-23 1:54 ` Eduardo Valentin 0 siblings, 0 replies; 10+ messages in thread From: Eduardo Valentin @ 2017-02-23 1:54 UTC (permalink / raw) To: Stefan Wahren Cc: kernel, Frank Rowand, Eric Anholt, Zhang Rui, Rob Herring, Florian Fainelli, linux-rpi-kernel, linux-pm, devicetree Hey, On Tue, Feb 21, 2017 at 07:14:36PM +0100, Stefan Wahren wrote: > > <cut> > > I prepared a new patch series to fix that issue in my github repo [1]. At first we need to implement a new function of_property_read_s32_array() [2]. After that we could use this function in of-thermal in order to use signed integer for both coefficients [3]. > > @Eduardo: Is it okay for you? > Yes, as I mentioned before, I am OK to patch of-thermal. And the representation of offset and slope are already signed. > @Martin: Do you want to send the next version of the patch series or should i? > > [1] - https://github.com/lategoodbye/rpi-zero/commits/thermal > [2] - https://github.com/lategoodbye/rpi-zero/commit/3dc43581ada74d1345f79b4c36562fdf5f7941e5 > [3] - https://github.com/lategoodbye/rpi-zero/commit/c02ed37c0ebdca98aee570862af10e90b3c9a0d0 > Number 3 is fine with me. Please send them in a single series for proper review in linux-pm. BR, ^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <1486928328-25870-1-git-send-email-stefan.wahren-eS4NqCHxEME@public.gmane.org>]
* Re: [PATCH V2 1/2] dt-bindings: Add thermal zone to bcm2835-thermal example [not found] ` <1486928328-25870-1-git-send-email-stefan.wahren-eS4NqCHxEME@public.gmane.org> @ 2017-02-13 21:42 ` Eric Anholt [not found] ` <878tp9kbt8.fsf-omZaPlIz5HhaEpDpdNBo/KxOck334EZe@public.gmane.org> 0 siblings, 1 reply; 10+ messages in thread From: Eric Anholt @ 2017-02-13 21:42 UTC (permalink / raw) To: Eduardo Valentin, Zhang Rui, kernel-TqfNSX0MhmxHKSADF0wUEw Cc: Rob Herring, Frank Rowand, Florian Fainelli, linux-rpi-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, devicetree-u79uwXL29TY76Z2rM5mHXA, linux-pm-u79uwXL29TY76Z2rM5mHXA, Stefan Wahren [-- Attachment #1: Type: text/plain, Size: 282 bytes --] Stefan Wahren <stefan.wahren-eS4NqCHxEME@public.gmane.org> writes: > Add a thermal zone in order to make the example complete. > > Signed-off-by: Stefan Wahren <stefan.wahren-eS4NqCHxEME@public.gmane.org> This looks fine to me. Eduardo, will this be enough to get the driver in? [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 832 bytes --] ^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <878tp9kbt8.fsf-omZaPlIz5HhaEpDpdNBo/KxOck334EZe@public.gmane.org>]
* Re: [PATCH V2 1/2] dt-bindings: Add thermal zone to bcm2835-thermal example [not found] ` <878tp9kbt8.fsf-omZaPlIz5HhaEpDpdNBo/KxOck334EZe@public.gmane.org> @ 2017-02-19 1:13 ` Eduardo Valentin 0 siblings, 0 replies; 10+ messages in thread From: Eduardo Valentin @ 2017-02-19 1:13 UTC (permalink / raw) To: Eric Anholt Cc: Stefan Wahren, Zhang Rui, kernel-TqfNSX0MhmxHKSADF0wUEw, Rob Herring, Frank Rowand, Florian Fainelli, linux-rpi-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, devicetree-u79uwXL29TY76Z2rM5mHXA, linux-pm-u79uwXL29TY76Z2rM5mHXA On Mon, Feb 13, 2017 at 01:42:11PM -0800, Eric Anholt wrote: > Stefan Wahren <stefan.wahren-eS4NqCHxEME@public.gmane.org> writes: > > > Add a thermal zone in order to make the example complete. > > > > Signed-off-by: Stefan Wahren <stefan.wahren-eS4NqCHxEME@public.gmane.org> > > This looks fine to me. Eduardo, will this be enough to get the driver > in? Well, yes, but the driver needs to support the descriptors by registering to of-thermal. But that would actually simplify the driver as follows (patch on bcm2835 patch v9, so it supports the descriptors in this thread): ------------------------8------------------------ diff --git a/drivers/thermal/bcm2835_thermal.c b/drivers/thermal/bcm2835_thermal.c index 5e2fea9..ffcf847 100644 --- a/drivers/thermal/bcm2835_thermal.c +++ b/drivers/thermal/bcm2835_thermal.c @@ -61,14 +61,8 @@ #define BCM2835_TS_TSENSSTAT_VALID BIT(10) #define BCM2835_TS_TSENSSTAT_INTERRUPT BIT(11) -struct bcm2835_thermal_info { - int offset; - int slope; - int trip_temp; -}; - struct bcm2835_thermal_data { - const struct bcm2835_thermal_info *info; + struct thermal_zone_device *tz; void __iomem *regs; struct clk *clk; struct dentry *debugfsdir; @@ -92,40 +86,9 @@ static int bcm2835_thermal_temp2adc(int temp, int offset, int slope) return temp; } -static int bcm2835_thermal_get_trip_type( - struct thermal_zone_device *tz, int trip, - enum thermal_trip_type *type) +static int bcm2835_thermal_get_temp(void *d, int *temp) { - *type = THERMAL_TRIP_CRITICAL; - return 0; -} - -static int bcm2835_thermal_get_trip_temp( - struct thermal_zone_device *tz, int trip, int *temp) -{ - struct bcm2835_thermal_data *data = tz->devdata; - u32 val = readl(data->regs + BCM2835_TS_TSENSCTL); - - /* get the THOLD bits */ - val &= BCM2835_TS_TSENSCTL_THOLD_MASK; - val >>= BCM2835_TS_TSENSCTL_THOLD_SHIFT; - - /* if it is zero then use the info value */ - if (val) - *temp = bcm2835_thermal_adc2temp( - val, - thermal_zone_get_offset(tz), - thermal_zone_get_slope(tz)); - else - *temp = data->info->trip_temp; - - return 0; -} - -static int bcm2835_thermal_get_temp(struct thermal_zone_device *tz, - int *temp) -{ - struct bcm2835_thermal_data *data = tz->devdata; + struct bcm2835_thermal_data *data = d; u32 val = readl(data->regs + BCM2835_TS_TSENSSTAT); if (!(val & BCM2835_TS_TSENSSTAT_VALID)) @@ -135,8 +98,8 @@ static int bcm2835_thermal_get_temp(struct thermal_zone_device *tz, *temp = bcm2835_thermal_adc2temp( val, - thermal_zone_get_offset(tz), - thermal_zone_get_slope(tz)); + thermal_zone_get_offset(data->tz), + thermal_zone_get_slope(data->tz)); return 0; } @@ -174,10 +137,8 @@ static void bcm2835_thermal_debugfs(struct platform_device *pdev) data->debugfsdir, regset); } -static struct thermal_zone_device_ops bcm2835_thermal_ops = { +static struct thermal_zone_of_device_ops bcm2835_thermal_ops = { .get_temp = bcm2835_thermal_get_temp, - .get_trip_temp = bcm2835_thermal_get_trip_temp, - .get_trip_type = bcm2835_thermal_get_trip_type, }; static const struct of_device_id bcm2835_thermal_of_match_table[]; @@ -186,10 +147,9 @@ static int bcm2835_thermal_probe(struct platform_device *pdev) const struct of_device_id *match; struct thermal_zone_device *tz; struct thermal_zone_params *tzp; - const struct bcm2835_thermal_info *ti; struct bcm2835_thermal_data *data; struct resource *res; - int err; + int err = 0; u32 val; unsigned long rate; @@ -205,10 +165,6 @@ static int bcm2835_thermal_probe(struct platform_device *pdev) &pdev->dev); if (!match) return -EINVAL; - ti = match->data; - data->info = ti; - tzp->slope = ti->slope; - tzp->offset = ti->offset; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); data->regs = devm_ioremap_resource(&pdev->dev, res); @@ -236,6 +192,17 @@ static int bcm2835_thermal_probe(struct platform_device *pdev) "Clock %pCn running at %pCr Hz is outside of the recommended range: 1.92 to 5MHz\n", data->clk, data->clk); + /* register of thermal sensor and get info from DT */ + tz = thermal_zone_of_sensor_register(&pdev->dev, 0, data, + &bcm2835_thermal_ops); + if (IS_ERR(tz)) { + err = PTR_ERR(tz); + dev_err(&pdev->dev, + "Failed to register the thermal device: %d\n", + err); + goto err_clk; + } + /* * right now the FW does set up the HW-block, so we are not * touching the configuration registers. @@ -244,6 +211,23 @@ static int bcm2835_thermal_probe(struct platform_device *pdev) */ val = readl(data->regs + BCM2835_TS_TSENSCTL); if (!(val & BCM2835_TS_TSENSCTL_RSTB)) { + int trip_temp, offset, slope; + + slope = thermal_zone_get_slope(tz); + offset = thermal_zone_get_offset(tz); + /* + * For now we deal only with critical, otherwise + * would need to iterate + */ + err = tz->ops->get_trip_temp(tz, 0, &trip_temp); + if (err < 0) { + err = PTR_ERR(tz); + dev_err(&pdev->dev, + "Not able to read trip_temp: %d\n", + err); + goto err_tz; + } + /* the basic required flags */ val = (BCM2835_TS_TSENSCTL_CTRL_DEFAULT << BCM2835_TS_TSENSCTL_CTRL_SHIFT) | @@ -256,9 +240,9 @@ static int bcm2835_thermal_probe(struct platform_device *pdev) val |= (14 << BCM2835_TS_TSENSCTL_RSTDELAY_SHIFT); /* trip_adc value from info */ - val |= bcm2835_thermal_temp2adc(data->info->trip_temp, - data->info->offset, - data->info->slope) + val |= bcm2835_thermal_temp2adc(trip_temp, + offset, + slope) << BCM2835_TS_TSENSCTL_THOLD_SHIFT; /* write the value back to the register as 2 steps */ @@ -267,26 +251,18 @@ static int bcm2835_thermal_probe(struct platform_device *pdev) writel(val, data->regs + BCM2835_TS_TSENSCTL); } - /* register thermal zone with 1 trip point an 1s polling */ - tz = thermal_zone_device_register("bcm2835_thermal", - 1, 0, data, - &bcm2835_thermal_ops, - tzp, - 0, 1000); - if (IS_ERR(tz)) { - clk_disable_unprepare(data->clk); - err = PTR_ERR(tz); - dev_err(&pdev->dev, - "Failed to register the thermal device: %d\n", - err); - return err; - } + data->tz = tz; platform_set_drvdata(pdev, tz); bcm2835_thermal_debugfs(pdev); - return 0; +err_tz: + thermal_zone_of_sensor_unregister(&pdev->dev, tz); +err_clk: + clk_disable_unprepare(data->clk); + + return err; } static int bcm2835_thermal_remove(struct platform_device *pdev) @@ -295,7 +271,7 @@ static int bcm2835_thermal_remove(struct platform_device *pdev) struct bcm2835_thermal_data *data = tz->devdata; debugfs_remove_recursive(data->debugfsdir); - thermal_zone_device_unregister(tz); + thermal_zone_of_sensor_unregister(&pdev->dev, tz); clk_disable_unprepare(data->clk); return 0; @@ -312,28 +288,12 @@ static int bcm2835_thermal_remove(struct platform_device *pdev) static const struct of_device_id bcm2835_thermal_of_match_table[] = { { .compatible = "brcm,bcm2835-thermal", - .data = &(struct bcm2835_thermal_info) { - .offset = 407000, - .slope = -538, - .trip_temp = 80000 - } }, { .compatible = "brcm,bcm2836-thermal", - .data = &(struct bcm2835_thermal_info) { - .offset = 407000, - .slope = -538, - .trip_temp = 80000 - } }, { .compatible = "brcm,bcm2837-thermal", - .data = &(struct bcm2835_thermal_info) { - /* the bcm2837 needs adjustment of +5C */ - .offset = 407000 + 5000, - .slope = -538, - .trip_temp = 80000 - } }, {}, }; ------------------------8------------------------ -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH V2 1/2] dt-bindings: Add thermal zone to bcm2835-thermal example 2017-02-12 19:38 [PATCH V2 1/2] dt-bindings: Add thermal zone to bcm2835-thermal example Stefan Wahren 2017-02-12 19:38 ` [PATCH V2 2/2] ARM: dts: bcm283x: Add CPU thermal zone with 1 trip point Stefan Wahren [not found] ` <1486928328-25870-1-git-send-email-stefan.wahren-eS4NqCHxEME@public.gmane.org> @ 2017-02-22 14:55 ` Rob Herring 2 siblings, 0 replies; 10+ messages in thread From: Rob Herring @ 2017-02-22 14:55 UTC (permalink / raw) To: Stefan Wahren Cc: Eduardo Valentin, Zhang Rui, kernel, Eric Anholt, Frank Rowand, Florian Fainelli, linux-rpi-kernel, devicetree, linux-pm On Sun, Feb 12, 2017 at 07:38:47PM +0000, Stefan Wahren wrote: > Add a thermal zone in order to make the example complete. > > Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com> > --- > > Changes in V2: > - add missing thermal-sensor-cells property > - change gpu-thermal to cpu-thermal > > .../bindings/thermal/brcm,bcm2835-thermal.txt | 29 +++++++++++++++++--- > 1 file changed, 25 insertions(+), 4 deletions(-) Acked-by: Rob Herring <robh@kernel.org> ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2017-02-23 1:54 UTC | newest] Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2017-02-12 19:38 [PATCH V2 1/2] dt-bindings: Add thermal zone to bcm2835-thermal example Stefan Wahren 2017-02-12 19:38 ` [PATCH V2 2/2] ARM: dts: bcm283x: Add CPU thermal zone with 1 trip point Stefan Wahren [not found] ` <1486928328-25870-2-git-send-email-stefan.wahren-eS4NqCHxEME@public.gmane.org> 2017-02-19 1:17 ` Eduardo Valentin [not found] ` <20170219011753.GB21016-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org> 2017-02-19 12:31 ` Stefan Wahren 2017-02-19 21:27 ` Eduardo Valentin 2017-02-21 18:14 ` Stefan Wahren 2017-02-23 1:54 ` Eduardo Valentin [not found] ` <1486928328-25870-1-git-send-email-stefan.wahren-eS4NqCHxEME@public.gmane.org> 2017-02-13 21:42 ` [PATCH V2 1/2] dt-bindings: Add thermal zone to bcm2835-thermal example Eric Anholt [not found] ` <878tp9kbt8.fsf-omZaPlIz5HhaEpDpdNBo/KxOck334EZe@public.gmane.org> 2017-02-19 1:13 ` Eduardo Valentin 2017-02-22 14:55 ` Rob Herring
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.