Message ID | 1387486402-30777-1-git-send-email-b20788@freescale.com (mailing list archive) |
---|---|
State | Superseded, archived |
Delegated to: | Zhang Rui |
Headers | show |
DQoNCkJlc3QgUmVnYXJkcy4NCkFuc29uIGh1YW5nIOm7hOWLh+aJjQ0KwqANCkZyZWVzY2FsZSBT ZW1pY29uZHVjdG9yIFNoYW5naGFpDQrkuIrmtbfmtabkuJzmlrDljLrkuq7mma/ot68xOTLlj7dB 5bqnMualvA0KMjAxMjAzDQpUZWw6MDIxLTI4OTM3MDU4DQoNCg0KPi0tLS0tT3JpZ2luYWwgTWVz c2FnZS0tLS0tDQo+RnJvbTogU2hhd24gR3VvIFttYWlsdG86c2hhd24uZ3VvQGxpbmFyby5vcmdd DQo+U2VudDogVGh1cnNkYXksIERlY2VtYmVyIDE5LCAyMDEzIDU6MTEgUE0NCj5UbzogSHVhbmcg WW9uZ2NhaS1CMjA3ODgNCj5DYzoga2VybmVsQHBlbmd1dHJvbml4LmRlOyBydWkuemhhbmdAaW50 ZWwuY29tOyBlZHVhcmRvLnZhbGVudGluQHRpLmNvbTsNCj5kZXZpY2V0cmVlQHZnZXIua2VybmVs Lm9yZzsgbGludXgtZG9jQHZnZXIua2VybmVsLm9yZzsgbGludXgtYXJtLQ0KPmtlcm5lbEBsaXN0 cy5pbmZyYWRlYWQub3JnOyBsaW51eC1wbUB2Z2VyLmtlcm5lbC5vcmcNCj5TdWJqZWN0OiBSZTog W1BBVENIIFYyIDIvMl0gdGhlcm1hbDogaW14OiBhZGQgbmVjZXNzYXJ5IGNsayBvcGVyYXRpb24N Cj4NCj5PbiBUaHUsIERlYyAxOSwgMjAxMyBhdCAwMzo1MzoyMlBNIC0wNTAwLCBBbnNvbiBIdWFu ZyB3cm90ZToNCj4+IFRoZXJtYWwgc2Vuc29yIG5lZWRzIHBsbDNfdXNiX290ZyB3aGVuIG1lYXN1 cmluZyB0ZW1wZXJhdHVyZSwNCj4+IG90aGVyd2lzZSB0aGUgdGVtcGVyYXR1cmUgcmV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BjbGsgYmVmb3JlIHRha2luZyBt ZWFzdXJlbWVudCBhbmQgZGlzYWJsZQ0KPj4gKwkJICogY2xrIGFmdGVyIG1lYXN1cmVtZW50IGlz IGRvbmUsIGJ1dCBpZiBhbGFybSBmdW5jdGlvbiBpcyBlbmFibGVkLA0KPj4gKwkJICogaGFyZHdh cmUgd2lsbCBhdXRvIG1lYXN1cmUgdGhlIHRlbXBlcmF0dXJlIHBlcmlvZGljYWxseSwgc28gd2UN Cj4+ICsJCSAqIG5lZWQgdG8ga2VlcCB0aGUgY2xrIGFsd2F5cyBvbiBmb3IgYWxhcm0gZnVuY3Rp b24uDQo+PiArCQkgKi8NCj4+ICsJCXJldCA9IGNsa19wcmVwYXJlX2VuYWJsZShkYXRhLT50aGVy bWFsX2Nsayk7DQo+PiArCQlpZiAocmV0KQ0KPj4gKwkJCWRldl93YXJuKCZwZGV2LT5kZXYsICJm YWlsZWQgdG8gZW5hYmxlIHRoZXJtYWwgY2xrOiAlZFxuIiwNCj5yZXQpOw0KPj4gKwl9DQo+PiAr DQo+PiAgCS8qIEVuYWJsZSBtZWFzdXJlbWVudHMgYXQgfiAxMCBIeiAqLw0KPj4gIAlyZWdtYXBf d3JpdGUobWFwLCBURU1QU0VOU0UxICsgUkVHX0NMUiwgVEVNUFNFTlNFMV9NRUFTVVJFX0ZSRVEp Ow0KPj4gIAltZWFzdXJlX2ZyZXEgPSBESVZfUk9VTkRfVVAoMzI3NjgsIDEwKTsgLyogMTAgSHog Ki8NCj4+IC0tDQo+PiAxLjcuOS41DQo+Pg0KPj4NCg0K -- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Thu, Dec 19, 2013 at 03:53:22PM -0500, Anson Huang wrote: > Thermal sensor needs pll3_usb_otg when measuring temperature, > otherwise the temperature read will be incorrect, so need to > enable this clk before sensor working, for alarm function, > as hardware will take measurement periodically, so we should > keep this clk always on once alarm function is enabled. > > Signed-off-by: Anson Huang <b20788@freescale.com> > --- > .../devicetree/bindings/thermal/imx-thermal.txt | 2 ++ > drivers/thermal/imx_thermal.c | 18 ++++++++++++++++++ > 2 files changed, 20 insertions(+) > > diff --git a/Documentation/devicetree/bindings/thermal/imx-thermal.txt b/Documentation/devicetree/bindings/thermal/imx-thermal.txt > index 541c25e..e518c6e 100644 > --- a/Documentation/devicetree/bindings/thermal/imx-thermal.txt > +++ b/Documentation/devicetree/bindings/thermal/imx-thermal.txt > @@ -7,6 +7,7 @@ Required properties: > - fsl,tempmon-data : phandle pointer to fuse controller that contains TEMPMON > calibration data, e.g. OCOTP on imx6q. The details about calibration data > can be found in SoC Reference Manual. > +- clocks : thermal sensor's clock source. This should be listed in 'Optional properties:' now. Shawn > > Example: > > @@ -14,4 +15,5 @@ tempmon { > compatible = "fsl,imx6q-tempmon"; > fsl,tempmon = <&anatop>; > fsl,tempmon-data = <&ocotp>; > + clocks = <&clks 172>; > }; > diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c > index 1d6c801..c2b8173 100644 > --- a/drivers/thermal/imx_thermal.c > +++ b/drivers/thermal/imx_thermal.c > @@ -7,6 +7,7 @@ > * > */ > > +#include <linux/clk.h> > #include <linux/cpu_cooling.h> > #include <linux/cpufreq.h> > #include <linux/delay.h> > @@ -73,6 +74,7 @@ struct imx_thermal_data { > unsigned long last_temp; > bool irq_enabled; > int irq; > + struct clk *thermal_clk; > }; > > static void imx_set_alarm_temp(struct imx_thermal_data *data, > @@ -457,6 +459,22 @@ static int imx_thermal_probe(struct platform_device *pdev) > return ret; > } > > + data->thermal_clk = devm_clk_get(&pdev->dev, NULL); > + if (IS_ERR(data->thermal_clk)) { > + dev_warn(&pdev->dev, "failed to get thermal clk!\n"); > + } else { > + /* > + * Thermal sensor needs clk on to get correct value, normally > + * we should enable its clk before taking measurement and disable > + * clk after measurement is done, but if alarm function is enabled, > + * hardware will auto measure the temperature periodically, so we > + * need to keep the clk always on for alarm function. > + */ > + ret = clk_prepare_enable(data->thermal_clk); > + if (ret) > + dev_warn(&pdev->dev, "failed to enable thermal clk: %d\n", ret); > + } > + > /* Enable measurements at ~ 10 Hz */ > regmap_write(map, TEMPSENSE1 + REG_CLR, TEMPSENSE1_MEASURE_FREQ); > measure_freq = DIV_ROUND_UP(32768, 10); /* 10 Hz */ > -- > 1.7.9.5 > > -- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/Documentation/devicetree/bindings/thermal/imx-thermal.txt b/Documentation/devicetree/bindings/thermal/imx-thermal.txt index 541c25e..e518c6e 100644 --- a/Documentation/devicetree/bindings/thermal/imx-thermal.txt +++ b/Documentation/devicetree/bindings/thermal/imx-thermal.txt @@ -7,6 +7,7 @@ Required properties: - fsl,tempmon-data : phandle pointer to fuse controller that contains TEMPMON calibration data, e.g. OCOTP on imx6q. The details about calibration data can be found in SoC Reference Manual. +- clocks : thermal sensor's clock source. Example: @@ -14,4 +15,5 @@ tempmon { compatible = "fsl,imx6q-tempmon"; fsl,tempmon = <&anatop>; fsl,tempmon-data = <&ocotp>; + clocks = <&clks 172>; }; diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c index 1d6c801..c2b8173 100644 --- a/drivers/thermal/imx_thermal.c +++ b/drivers/thermal/imx_thermal.c @@ -7,6 +7,7 @@ * */ +#include <linux/clk.h> #include <linux/cpu_cooling.h> #include <linux/cpufreq.h> #include <linux/delay.h> @@ -73,6 +74,7 @@ struct imx_thermal_data { unsigned long last_temp; bool irq_enabled; int irq; + struct clk *thermal_clk; }; static void imx_set_alarm_temp(struct imx_thermal_data *data, @@ -457,6 +459,22 @@ static int imx_thermal_probe(struct platform_device *pdev) return ret; } + data->thermal_clk = devm_clk_get(&pdev->dev, NULL); + if (IS_ERR(data->thermal_clk)) { + dev_warn(&pdev->dev, "failed to get thermal clk!\n"); + } else { + /* + * Thermal sensor needs clk on to get correct value, normally + * we should enable its clk before taking measurement and disable + * clk after measurement is done, but if alarm function is enabled, + * hardware will auto measure the temperature periodically, so we + * need to keep the clk always on for alarm function. + */ + ret = clk_prepare_enable(data->thermal_clk); + if (ret) + dev_warn(&pdev->dev, "failed to enable thermal clk: %d\n", ret); + } + /* Enable measurements at ~ 10 Hz */ regmap_write(map, TEMPSENSE1 + REG_CLR, TEMPSENSE1_MEASURE_FREQ); measure_freq = DIV_ROUND_UP(32768, 10); /* 10 Hz */
Thermal sensor needs pll3_usb_otg when measuring temperature, otherwise the temperature read will be incorrect, so need to enable this clk before sensor working, for alarm function, as hardware will take measurement periodically, so we should keep this clk always on once alarm function is enabled. Signed-off-by: Anson Huang <b20788@freescale.com> --- .../devicetree/bindings/thermal/imx-thermal.txt | 2 ++ drivers/thermal/imx_thermal.c | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+)