* [PATCH 2/2] thermal: sun8i: add R329 THS [not found] <20220422161156.1075227-1-icenowy@outlook.com> @ 2022-04-22 16:11 ` icenowy 2022-04-22 18:49 ` Vasily Khoruzhick 2022-04-22 23:39 ` Samuel Holland 0 siblings, 2 replies; 4+ messages in thread From: icenowy @ 2022-04-22 16:11 UTC (permalink / raw) To: Vasily Khoruzhick, Yangtao Li, Rafael J . Wysocki, Daniel Lezcano, Amit Kucheria, Zhang Rui, Rob Herring, Chen-Yu Tsai, Jernej Skrabec, Samuel Holland Cc: linux-pm, devicetree, linux-arm-kernel, linux-sunxi, linux-kernel, Icenowy Zheng From: Icenowy Zheng <icenowy@aosc.io> The thermal sensor controller on R329 is similar to the one on H6, but with only one sensor. Calibration method is still unknown because no calibration is implemented in BSP kernel, neither is it documented in the user manual. Add its support to sun8i-thermal driver. Calibrating it is now prevented. Signed-off-by: Icenowy Zheng <icenowy@aosc.io> --- drivers/thermal/sun8i_thermal.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/thermal/sun8i_thermal.c b/drivers/thermal/sun8i_thermal.c index d9cd23cbb671..3a2f381005b4 100644 --- a/drivers/thermal/sun8i_thermal.c +++ b/drivers/thermal/sun8i_thermal.c @@ -312,7 +312,8 @@ static int sun8i_ths_calibrate(struct ths_device *tmdev) goto out; } - tmdev->chip->calibrate(tmdev, caldata, callen); + if (tmdev->chip->calibrate) + tmdev->chip->calibrate(tmdev, caldata, callen); kfree(caldata); out: @@ -628,6 +629,17 @@ static const struct ths_thermal_chip sun50i_h6_ths = { .calc_temp = sun8i_ths_calc_temp, }; +static const struct ths_thermal_chip sun50i_r329_ths = { + .sensor_num = 1, + .has_bus_clk_reset = true, + .offset = 188744, + .scale = 672, + .temp_data_base = SUN50I_H6_THS_TEMP_DATA, + .init = sun50i_h6_thermal_init, + .irq_ack = sun50i_h6_irq_ack, + .calc_temp = sun8i_ths_calc_temp, +}; + static const struct of_device_id of_ths_match[] = { { .compatible = "allwinner,sun8i-a83t-ths", .data = &sun8i_a83t_ths }, { .compatible = "allwinner,sun8i-h3-ths", .data = &sun8i_h3_ths }, @@ -636,6 +648,7 @@ static const struct of_device_id of_ths_match[] = { { .compatible = "allwinner,sun50i-a100-ths", .data = &sun50i_a100_ths }, { .compatible = "allwinner,sun50i-h5-ths", .data = &sun50i_h5_ths }, { .compatible = "allwinner,sun50i-h6-ths", .data = &sun50i_h6_ths }, + { .compatible = "allwinner,sun50i-r329-ths", .data = &sun50i_r329_ths }, { /* sentinel */ }, }; MODULE_DEVICE_TABLE(of, of_ths_match); -- 2.35.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] thermal: sun8i: add R329 THS 2022-04-22 16:11 ` [PATCH 2/2] thermal: sun8i: add R329 THS icenowy @ 2022-04-22 18:49 ` Vasily Khoruzhick 2022-04-22 23:39 ` Samuel Holland 1 sibling, 0 replies; 4+ messages in thread From: Vasily Khoruzhick @ 2022-04-22 18:49 UTC (permalink / raw) To: icenowy Cc: Yangtao Li, Rafael J . Wysocki, Daniel Lezcano, Amit Kucheria, Zhang Rui, Rob Herring, Chen-Yu Tsai, Jernej Skrabec, Samuel Holland, Linux PM, devicetree, arm-linux, linux-sunxi, linux-kernel, Icenowy Zheng On Fri, Apr 22, 2022 at 9:12 AM <icenowy@outlook.com> wrote: > > From: Icenowy Zheng <icenowy@aosc.io> > > The thermal sensor controller on R329 is similar to the one on H6, but > with only one sensor. Calibration method is still unknown because no > calibration is implemented in BSP kernel, neither is it documented in > the user manual. > > Add its support to sun8i-thermal driver. Calibrating it is now > prevented. > > Signed-off-by: Icenowy Zheng <icenowy@aosc.io> > --- > drivers/thermal/sun8i_thermal.c | 15 ++++++++++++++- > 1 file changed, 14 insertions(+), 1 deletion(-) > > diff --git a/drivers/thermal/sun8i_thermal.c b/drivers/thermal/sun8i_thermal.c > index d9cd23cbb671..3a2f381005b4 100644 > --- a/drivers/thermal/sun8i_thermal.c > +++ b/drivers/thermal/sun8i_thermal.c > @@ -312,7 +312,8 @@ static int sun8i_ths_calibrate(struct ths_device *tmdev) > goto out; > } > > - tmdev->chip->calibrate(tmdev, caldata, callen); > + if (tmdev->chip->calibrate) > + tmdev->chip->calibrate(tmdev, caldata, callen); I think it's a bit late to check it here since you already read nvmem cell if you got here. I'd suggest moving the check to sun8i_ths_resource_init(), i.e. call sun8i_ths_calibrate() conditionally depending on whether calibrate callback is present. > kfree(caldata); > out: > @@ -628,6 +629,17 @@ static const struct ths_thermal_chip sun50i_h6_ths = { > .calc_temp = sun8i_ths_calc_temp, > }; > > +static const struct ths_thermal_chip sun50i_r329_ths = { > + .sensor_num = 1, > + .has_bus_clk_reset = true, > + .offset = 188744, > + .scale = 672, > + .temp_data_base = SUN50I_H6_THS_TEMP_DATA, > + .init = sun50i_h6_thermal_init, > + .irq_ack = sun50i_h6_irq_ack, > + .calc_temp = sun8i_ths_calc_temp, > +}; > + > static const struct of_device_id of_ths_match[] = { > { .compatible = "allwinner,sun8i-a83t-ths", .data = &sun8i_a83t_ths }, > { .compatible = "allwinner,sun8i-h3-ths", .data = &sun8i_h3_ths }, > @@ -636,6 +648,7 @@ static const struct of_device_id of_ths_match[] = { > { .compatible = "allwinner,sun50i-a100-ths", .data = &sun50i_a100_ths }, > { .compatible = "allwinner,sun50i-h5-ths", .data = &sun50i_h5_ths }, > { .compatible = "allwinner,sun50i-h6-ths", .data = &sun50i_h6_ths }, > + { .compatible = "allwinner,sun50i-r329-ths", .data = &sun50i_r329_ths }, > { /* sentinel */ }, > }; > MODULE_DEVICE_TABLE(of, of_ths_match); > -- > 2.35.1 > ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] thermal: sun8i: add R329 THS 2022-04-22 16:11 ` [PATCH 2/2] thermal: sun8i: add R329 THS icenowy 2022-04-22 18:49 ` Vasily Khoruzhick @ 2022-04-22 23:39 ` Samuel Holland 2022-04-22 23:41 ` Icenowy Zheng 1 sibling, 1 reply; 4+ messages in thread From: Samuel Holland @ 2022-04-22 23:39 UTC (permalink / raw) To: Icenowy Zheng, Vasily Khoruzhick, Yangtao Li, Rafael J . Wysocki, Daniel Lezcano, Amit Kucheria, Zhang Rui, Rob Herring, Chen-Yu Tsai, Jernej Skrabec Cc: linux-pm, devicetree, linux-arm-kernel, linux-sunxi, linux-kernel, Icenowy Zheng Hi Icenowy, On 4/22/22 11:11 AM, icenowy@outlook.com wrote: > From: Icenowy Zheng <icenowy@aosc.io> > > The thermal sensor controller on R329 is similar to the one on H6, but > with only one sensor. Calibration method is still unknown because no > calibration is implemented in BSP kernel, neither is it documented in > the user manual. Looking at the BSP smartx-r329-tina-for-jishu-community-v0.2, I see: ths_calib: calib@14 { reg = <0x14 4>; }; And the BSP driver (drivers/thermal/sunxi_thermal-ng.c) claims that R329 uses the same calibration method as for H616. Maybe you are looking at an older BSP? Regards, Samuel > > Add its support to sun8i-thermal driver. Calibrating it is now > prevented. > > Signed-off-by: Icenowy Zheng <icenowy@aosc.io> > --- > drivers/thermal/sun8i_thermal.c | 15 ++++++++++++++- > 1 file changed, 14 insertions(+), 1 deletion(-) > > diff --git a/drivers/thermal/sun8i_thermal.c b/drivers/thermal/sun8i_thermal.c > index d9cd23cbb671..3a2f381005b4 100644 > --- a/drivers/thermal/sun8i_thermal.c > +++ b/drivers/thermal/sun8i_thermal.c > @@ -312,7 +312,8 @@ static int sun8i_ths_calibrate(struct ths_device *tmdev) > goto out; > } > > - tmdev->chip->calibrate(tmdev, caldata, callen); > + if (tmdev->chip->calibrate) > + tmdev->chip->calibrate(tmdev, caldata, callen); > > kfree(caldata); > out: > @@ -628,6 +629,17 @@ static const struct ths_thermal_chip sun50i_h6_ths = { > .calc_temp = sun8i_ths_calc_temp, > }; > > +static const struct ths_thermal_chip sun50i_r329_ths = { > + .sensor_num = 1, > + .has_bus_clk_reset = true, > + .offset = 188744, > + .scale = 672, > + .temp_data_base = SUN50I_H6_THS_TEMP_DATA, > + .init = sun50i_h6_thermal_init, > + .irq_ack = sun50i_h6_irq_ack, > + .calc_temp = sun8i_ths_calc_temp, > +}; > + > static const struct of_device_id of_ths_match[] = { > { .compatible = "allwinner,sun8i-a83t-ths", .data = &sun8i_a83t_ths }, > { .compatible = "allwinner,sun8i-h3-ths", .data = &sun8i_h3_ths }, > @@ -636,6 +648,7 @@ static const struct of_device_id of_ths_match[] = { > { .compatible = "allwinner,sun50i-a100-ths", .data = &sun50i_a100_ths }, > { .compatible = "allwinner,sun50i-h5-ths", .data = &sun50i_h5_ths }, > { .compatible = "allwinner,sun50i-h6-ths", .data = &sun50i_h6_ths }, > + { .compatible = "allwinner,sun50i-r329-ths", .data = &sun50i_r329_ths }, > { /* sentinel */ }, > }; > MODULE_DEVICE_TABLE(of, of_ths_match); > ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] thermal: sun8i: add R329 THS 2022-04-22 23:39 ` Samuel Holland @ 2022-04-22 23:41 ` Icenowy Zheng 0 siblings, 0 replies; 4+ messages in thread From: Icenowy Zheng @ 2022-04-22 23:41 UTC (permalink / raw) To: Samuel Holland, Vasily Khoruzhick, Yangtao Li, Rafael J . Wysocki, Daniel Lezcano, Amit Kucheria, Zhang Rui, Rob Herring, Chen-Yu Tsai, Jernej Skrabec Cc: linux-pm, devicetree, linux-arm-kernel, linux-sunxi, linux-kernel 在 2022-04-22星期五的 18:39 -0500,Samuel Holland写道: > Hi Icenowy, > > On 4/22/22 11:11 AM, icenowy@outlook.com wrote: > > From: Icenowy Zheng <icenowy@aosc.io> > > > > The thermal sensor controller on R329 is similar to the one on H6, > > but > > with only one sensor. Calibration method is still unknown because > > no > > calibration is implemented in BSP kernel, neither is it documented > > in > > the user manual. > > Looking at the BSP smartx-r329-tina-for-jishu-community-v0.2, I see: > > ths_calib: calib@14 { > reg = <0x14 4>; > }; > > And the BSP driver (drivers/thermal/sunxi_thermal-ng.c) claims that > R329 uses > the same calibration method as for H616. Maybe you are looking at an > older BSP? Yes. All these r329 work is done the last year during my internship at Sipeed. I will check the newer version of BSP and if okay I will add the calibrate routine in the next revision. > > Regards, > Samuel > > > > > Add its support to sun8i-thermal driver. Calibrating it is now > > prevented. > > > > Signed-off-by: Icenowy Zheng <icenowy@aosc.io> > > --- > > drivers/thermal/sun8i_thermal.c | 15 ++++++++++++++- > > 1 file changed, 14 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/thermal/sun8i_thermal.c > > b/drivers/thermal/sun8i_thermal.c > > index d9cd23cbb671..3a2f381005b4 100644 > > --- a/drivers/thermal/sun8i_thermal.c > > +++ b/drivers/thermal/sun8i_thermal.c > > @@ -312,7 +312,8 @@ static int sun8i_ths_calibrate(struct > > ths_device *tmdev) > > goto out; > > } > > > > - tmdev->chip->calibrate(tmdev, caldata, callen); > > + if (tmdev->chip->calibrate) > > + tmdev->chip->calibrate(tmdev, caldata, callen); > > > > kfree(caldata); > > out: > > @@ -628,6 +629,17 @@ static const struct ths_thermal_chip > > sun50i_h6_ths = { > > .calc_temp = sun8i_ths_calc_temp, > > }; > > > > +static const struct ths_thermal_chip sun50i_r329_ths = { > > + .sensor_num = 1, > > + .has_bus_clk_reset = true, > > + .offset = 188744, > > + .scale = 672, > > + .temp_data_base = SUN50I_H6_THS_TEMP_DATA, > > + .init = sun50i_h6_thermal_init, > > + .irq_ack = sun50i_h6_irq_ack, > > + .calc_temp = sun8i_ths_calc_temp, > > +}; > > + > > static const struct of_device_id of_ths_match[] = { > > { .compatible = "allwinner,sun8i-a83t-ths", .data = > > &sun8i_a83t_ths }, > > { .compatible = "allwinner,sun8i-h3-ths", .data = > > &sun8i_h3_ths }, > > @@ -636,6 +648,7 @@ static const struct of_device_id of_ths_match[] > > = { > > { .compatible = "allwinner,sun50i-a100-ths", .data = > > &sun50i_a100_ths }, > > { .compatible = "allwinner,sun50i-h5-ths", .data = > > &sun50i_h5_ths }, > > { .compatible = "allwinner,sun50i-h6-ths", .data = > > &sun50i_h6_ths }, > > + { .compatible = "allwinner,sun50i-r329-ths", .data = > > &sun50i_r329_ths }, > > { /* sentinel */ }, > > }; > > MODULE_DEVICE_TABLE(of, of_ths_match); > > > > ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-04-22 23:42 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20220422161156.1075227-1-icenowy@outlook.com>
2022-04-22 16:11 ` [PATCH 2/2] thermal: sun8i: add R329 THS icenowy
2022-04-22 18:49 ` Vasily Khoruzhick
2022-04-22 23:39 ` Samuel Holland
2022-04-22 23:41 ` Icenowy Zheng
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).