* Re: [PATCH v3 1/4] thermal: rockchip: add driver for thermal
[not found] ` <1409187562-12370-2-git-send-email-caesar.wang@rock-chips.com>
@ 2014-08-28 8:48 ` Arnd Bergmann
2014-08-28 14:37 ` Eduardo Valentin
0 siblings, 1 reply; 10+ messages in thread
From: Arnd Bergmann @ 2014-08-28 8:48 UTC (permalink / raw)
To: Caesar Wang
Cc: heiko, rui.zhang, edubezval, grant.likely, robh+dt, linux-kernel,
linux-pm, linux-arm-kernel, devicetree, linux-doc, huangtao, cf,
dianders, dtor, zyw, addy.ke, dmitry.torokhov, zhaoyifeng,
linux-iio, Jonathan Cameron
On Thursday 28 August 2014 08:59:19 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 <zyf@rock-chips.com>
> Signed-off-by: Caesar Wang <caesar.wang@rock-chips.com>
Hi Caesar,
After looking at the driver (last time I only received the patch for
the binding), I have a more general comment:
This looks like a general-purpose ADC device, not an IP block that is
specific to thermal management. The binding looks ok for that purpose
but should probably be moved into Documentation/devicetree/bindings/iio/adc/
as a minor change.
On the driver side, I believe the correct way to deal with this setup
is to split your driver into a generic drivers/iio/adc/rockchips-tsadc.c
file, and a smaller thermal driver that uses the iio in-kernel interfaces,
ideally one that is independent of the underlying hardware and can
work on any ADC implementation.
I've put the IIO maintainer on Cc in this mail, maybe Jonathan or someone
else on the linux-iio mailing list has some extra insight.
Arnd
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v3 1/4] thermal: rockchip: add driver for thermal
2014-08-28 8:48 ` [PATCH v3 1/4] thermal: rockchip: add driver for thermal Arnd Bergmann
@ 2014-08-28 14:37 ` Eduardo Valentin
2014-08-28 16:11 ` Heiko Stübner
0 siblings, 1 reply; 10+ messages in thread
From: Eduardo Valentin @ 2014-08-28 14:37 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Caesar Wang, heiko, rui.zhang, grant.likely, robh+dt,
linux-kernel, linux-pm, linux-arm-kernel, devicetree, linux-doc,
huangtao, cf, dianders, dtor, zyw, addy.ke, dmitry.torokhov,
zhaoyifeng, linux-iio, Jonathan Cameron
Ceasar and Arnd,
On Thu, Aug 28, 2014 at 10:48:23AM +0200, Arnd Bergmann wrote:
> On Thursday 28 August 2014 08:59:19 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 <zyf@rock-chips.com>
> > Signed-off-by: Caesar Wang <caesar.wang@rock-chips.com>
>
> Hi Caesar,
>
> After looking at the driver (last time I only received the patch for
> the binding), I have a more general comment:
>
> This looks like a general-purpose ADC device, not an IP block that is
> specific to thermal management. The binding looks ok for that purpose
> but should probably be moved into Documentation/devicetree/bindings/iio/adc/
> as a minor change.
>
I agree with Arnd's point here. It makes sense to me to have this driver
under the IIO umbrella.
> On the driver side, I believe the correct way to deal with this setup
> is to split your driver into a generic drivers/iio/adc/rockchips-tsadc.c
> file, and a smaller thermal driver that uses the iio in-kernel interfaces,
> ideally one that is independent of the underlying hardware and can
> work on any ADC implementation.
>
Agreed. If you can write such interface and make your driver to work in
such way, that would be great.
> I've put the IIO maintainer on Cc in this mail, maybe Jonathan or someone
> else on the linux-iio mailing list has some extra insight.
>
> Arnd
Cheers,
Eduardo
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v3 1/4] thermal: rockchip: add driver for thermal
2014-08-28 14:37 ` Eduardo Valentin
@ 2014-08-28 16:11 ` Heiko Stübner
2014-08-28 16:16 ` Arnd Bergmann
2014-08-29 1:54 ` 赵仪峰
0 siblings, 2 replies; 10+ messages in thread
From: Heiko Stübner @ 2014-08-28 16:11 UTC (permalink / raw)
To: Eduardo Valentin
Cc: Arnd Bergmann, Caesar Wang, rui.zhang, grant.likely, robh+dt,
linux-kernel, linux-pm, linux-arm-kernel, devicetree, linux-doc,
huangtao, cf, dianders, dtor, zyw, addy.ke, dmitry.torokhov,
zhaoyifeng, linux-iio, Jonathan Cameron
Am Donnerstag, 28. August 2014, 10:37:35 schrieb Eduardo Valentin:
> Ceasar and Arnd,
>
> On Thu, Aug 28, 2014 at 10:48:23AM +0200, Arnd Bergmann wrote:
> > On Thursday 28 August 2014 08:59:19 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 <zyf@rock-chips.com>
> > > Signed-off-by: Caesar Wang <caesar.wang@rock-chips.com>
> >
> > Hi Caesar,
> >
> > After looking at the driver (last time I only received the patch for
> > the binding), I have a more general comment:
> >
> > This looks like a general-purpose ADC device, not an IP block that is
> > specific to thermal management. The binding looks ok for that purpose
> > but should probably be moved into
> > Documentation/devicetree/bindings/iio/adc/ as a minor change.
>
> I agree with Arnd's point here. It makes sense to me to have this driver
> under the IIO umbrella.
interesting suggestion :-)
I've just taken another look at the registers of the ts-adc on the rk3066
which is completely different from the rk3288 one. Interestingly the rk3066 one
is "just" another saradc IP, so for this one it would really make sense.
> > On the driver side, I believe the correct way to deal with this setup
> > is to split your driver into a generic drivers/iio/adc/rockchips-tsadc.c
> > file, and a smaller thermal driver that uses the iio in-kernel interfaces,
> > ideally one that is independent of the underlying hardware and can
> > work on any ADC implementation.
>
> Agreed. If you can write such interface and make your driver to work in
> such way, that would be great.
But I currently don't see how you would model the temperature handling parts
from a generic thermal driver to a generic adc driver for the rk3288-tsadc.
I guess the general temperature irq handling would use iio-triggers? But how
does the target temperature get into the TSADC_COMP1_INT register.
Also when getting the temperature, Caesar's driver compares it to its trip
points and sets the next trip point depending on the current temperature
(passive <-> critical) in rockchip_get_temp.
Maybe there is some completely easy way for this, but currently I don't see
it.
Heiko
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v3 1/4] thermal: rockchip: add driver for thermal
2014-08-28 16:11 ` Heiko Stübner
@ 2014-08-28 16:16 ` Arnd Bergmann
2014-08-28 19:36 ` Caesar Wang
2014-08-29 1:54 ` 赵仪峰
1 sibling, 1 reply; 10+ messages in thread
From: Arnd Bergmann @ 2014-08-28 16:16 UTC (permalink / raw)
To: Heiko Stübner
Cc: Eduardo Valentin, Caesar Wang, rui.zhang, grant.likely, robh+dt,
linux-kernel, linux-pm, linux-arm-kernel, devicetree, linux-doc,
huangtao, cf, dianders, dtor, zyw, addy.ke, dmitry.torokhov,
zhaoyifeng, linux-iio, Jonathan Cameron
On Thursday 28 August 2014 18:11:43 Heiko Stübner wrote:
> Am Donnerstag, 28. August 2014, 10:37:35 schrieb Eduardo Valentin:
> > > On the driver side, I believe the correct way to deal with this setup
> > > is to split your driver into a generic drivers/iio/adc/rockchips-tsadc.c
> > > file, and a smaller thermal driver that uses the iio in-kernel interfaces,
> > > ideally one that is independent of the underlying hardware and can
> > > work on any ADC implementation.
> >
> > Agreed. If you can write such interface and make your driver to work in
> > such way, that would be great.
>
> But I currently don't see how you would model the temperature handling parts
> from a generic thermal driver to a generic adc driver for the rk3288-tsadc.
>
> I guess the general temperature irq handling would use iio-triggers? But how
> does the target temperature get into the TSADC_COMP1_INT register.
>
> Also when getting the temperature, Caesar's driver compares it to its trip
> points and sets the next trip point depending on the current temperature
> (passive <-> critical) in rockchip_get_temp.
>
> Maybe there is some completely easy way for this, but currently I don't see
> it.
Eduardo earlier today replied to an email about a generic driver for
thermal, which was posted in February but hasn't been merged.
See https://lkml.org/lkml/2014/2/5/810
There may be a newer version of this patch, which I haven't found.
Arnd
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v3 1/4] thermal: rockchip: add driver for thermal
2014-08-28 16:16 ` Arnd Bergmann
@ 2014-08-28 19:36 ` Caesar Wang
2014-08-28 23:01 ` Heiko Stübner
0 siblings, 1 reply; 10+ messages in thread
From: Caesar Wang @ 2014-08-28 19:36 UTC (permalink / raw)
To: Arnd Bergmann, Heiko Stübner
Cc: Eduardo Valentin, rui.zhang, grant.likely, robh+dt, linux-kernel,
linux-pm, linux-arm-kernel, devicetree, linux-doc, huangtao, cf,
dianders, dtor, zyw, addy.ke, dmitry.torokhov, zhaoyifeng,
linux-iio, Jonathan Cameron
Arnd & Heiko & Eduardo,
OK. Maybe you are right.
This driver should be put into drivers/iio/adc/* ,
Anyway,I will re-edit it ASAP.
在 2014/8/29 0:16, Arnd Bergmann 写道:
> On Thursday 28 August 2014 18:11:43 Heiko Stübner wrote:
>> Am Donnerstag, 28. August 2014, 10:37:35 schrieb Eduardo Valentin:
>>>> On the driver side, I believe the correct way to deal with this setup
>>>> is to split your driver into a generic drivers/iio/adc/rockchips-tsadc.c
>>>> file, and a smaller thermal driver that uses the iio in-kernel interfaces,
>>>> ideally one that is independent of the underlying hardware and can
>>>> work on any ADC implementation.
>>> Agreed. If you can write such interface and make your driver to work in
>>> such way, that would be great.
>> But I currently don't see how you would model the temperature handling parts
>> from a generic thermal driver to a generic adc driver for the rk3288-tsadc.
>>
>> I guess the general temperature irq handling would use iio-triggers? But how
>> does the target temperature get into the TSADC_COMP1_INT register.
>>
>> Also when getting the temperature, Caesar's driver compares it to its trip
>> points and sets the next trip point depending on the current temperature
>> (passive <-> critical) in rockchip_get_temp.
>>
>> Maybe there is some completely easy way for this, but currently I don't see
>> it.
> Eduardo earlier today replied to an email about a generic driver for
> thermal, which was posted in February but hasn't been merged.
> See https://lkml.org/lkml/2014/2/5/810
>
> There may be a newer version of this patch, which I haven't found.
>
> Arnd
>
>
>
--
Best regards,
Caesar
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v3 1/4] thermal: rockchip: add driver for thermal
2014-08-28 19:36 ` Caesar Wang
@ 2014-08-28 23:01 ` Heiko Stübner
0 siblings, 0 replies; 10+ messages in thread
From: Heiko Stübner @ 2014-08-28 23:01 UTC (permalink / raw)
To: Caesar Wang, Eduardo Valentin, Jonathan Cameron
Cc: Arnd Bergmann, rui.zhang, grant.likely, robh+dt, linux-kernel,
linux-pm, linux-arm-kernel, devicetree, linux-doc, huangtao, cf,
dianders, dtor, zyw, addy.ke, dmitry.torokhov, zhaoyifeng,
linux-iio, Courtney Cavin
Hi Caesar,
Am Freitag, 29. August 2014, 03:36:36 schrieb Caesar Wang:
> Arnd & Heiko & Eduardo,
>
> OK. Maybe you are right.
>
> This driver should be put into drivers/iio/adc/* ,
> Anyway,I will re-edit it ASAP.
I pieced together an example on how this could look, if you need inspiration.
As I've written, the tsadc on the rk3066 is simply another saradc, so it was
easy to build a usable example with it, which you can find in my
devel/workbench branch [0].
Things to note, the adc values are converted to voltages instead of the
"code"-values listed in the TRM [formula: (code * vref_mv) >> 12)] and the
temperatures are listed in millikelvin (C+273150) as expected by the pending
iio-thermal driver.
@Courtney: (not sure how to reply to the old thread from february)
the only issue I found was the unit of the voltages. The binding doc lists
them as uV, while iio (and the driver itself) expect to use mV.
Otherwise the iio-thermal driver:
Tested-by: Heiko Stuebner <heiko@sntech.de>
Heiko
[0] https://github.com/mmind/linux-rockchip/commits/devel/workbench
(recent commits till "thermal: add generic IIO channel thermal sensor driver")
> 在 2014/8/29 0:16, Arnd Bergmann 写道:
> > On Thursday 28 August 2014 18:11:43 Heiko Stübner wrote:
> >> Am Donnerstag, 28. August 2014, 10:37:35 schrieb Eduardo Valentin:
> >>>> On the driver side, I believe the correct way to deal with this setup
> >>>> is to split your driver into a generic
> >>>> drivers/iio/adc/rockchips-tsadc.c
> >>>> file, and a smaller thermal driver that uses the iio in-kernel
> >>>> interfaces,
> >>>> ideally one that is independent of the underlying hardware and can
> >>>> work on any ADC implementation.
> >>>
> >>> Agreed. If you can write such interface and make your driver to work in
> >>> such way, that would be great.
> >>
> >> But I currently don't see how you would model the temperature handling
> >> parts from a generic thermal driver to a generic adc driver for the
> >> rk3288-tsadc.
> >>
> >> I guess the general temperature irq handling would use iio-triggers? But
> >> how does the target temperature get into the TSADC_COMP1_INT register.
> >>
> >> Also when getting the temperature, Caesar's driver compares it to its
> >> trip
> >> points and sets the next trip point depending on the current temperature
> >> (passive <-> critical) in rockchip_get_temp.
> >>
> >> Maybe there is some completely easy way for this, but currently I don't
> >> see
> >> it.
> >
> > Eduardo earlier today replied to an email about a generic driver for
> > thermal, which was posted in February but hasn't been merged.
> > See https://lkml.org/lkml/2014/2/5/810
> >
> > There may be a newer version of this patch, which I haven't found.
> >
> > Arnd
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Re: [PATCH v3 1/4] thermal: rockchip: add driver for thermal
2014-08-28 16:11 ` Heiko Stübner
2014-08-28 16:16 ` Arnd Bergmann
@ 2014-08-29 1:54 ` 赵仪峰
2014-08-29 11:39 ` edubezval
1 sibling, 1 reply; 10+ messages in thread
From: 赵仪峰 @ 2014-08-29 1:54 UTC (permalink / raw)
To: HeikoStübner, Eduardo Valentin
Cc: Arnd Bergmann, Caesar Wang, rui.zhang, grant.likely, robh+dt,
linux-kernel, linux-pm, linux-arm-kernel, devicetree, linux-doc,
黄涛, 蔡枫, dianders, dtor,
钟勇汪, addy.ke@rock-chips.com, dmitry.torokhov,
linux-iio, Jonathan Cameron
[-- Attachment #1: Type: text/plain, Size: 3904 bytes --]
Hi Heiko,
The TS-ADC on RK3288 has two component, a tsadc and a tsadc controller. The tsadc controller is similar like the thermal manager unit on other SOCs. We followed the naming of 3066, but not named as the Thermal Manager.
Moreover,there is only one set of apb registers to access the tsadc controller,and the tsadc is controlled by the tsadc controller,could not access directly. If we write a general tsadc driver by accessed tsadc controller registers, and it hardly to write a driver for the tsadc controller.
So, I do not agree to write a generic adc driver for the rk3288-tsadc.
Yifeng Zhao
发件人: HeikoStübner
发送时间: 2014-08-29 00:11
收件人: Eduardo Valentin
抄送: Arnd Bergmann; Caesar Wang; rui.zhang; grant.likely; robh+dt; linux-kernel; linux-pm; linux-arm-kernel; devicetree; linux-doc; huangtao; cf; dianders; dtor; zyw; addy.ke; dmitry.torokhov; zhaoyifeng; linux-iio; Jonathan Cameron
主题: Re: [PATCH v3 1/4] thermal: rockchip: add driver for thermal
Am Donnerstag, 28. August 2014, 10:37:35 schrieb Eduardo Valentin:
> Ceasar and Arnd,
>
> On Thu, Aug 28, 2014 at 10:48:23AM +0200, Arnd Bergmann wrote:
> > On Thursday 28 August 2014 08:59:19 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 <zyf@rock-chips.com>
> > > Signed-off-by: Caesar Wang <caesar.wang@rock-chips.com>
> >
> > Hi Caesar,
> >
> > After looking at the driver (last time I only received the patch for
> > the binding), I have a more general comment:
> >
> > This looks like a general-purpose ADC device, not an IP block that is
> > specific to thermal management. The binding looks ok for that purpose
> > but should probably be moved into
> > Documentation/devicetree/bindings/iio/adc/ as a minor change.
>
> I agree with Arnd's point here. It makes sense to me to have this driver
> under the IIO umbrella.
interesting suggestion :-)
I've just taken another look at the registers of the ts-adc on the rk3066
which is completely different from the rk3288 one. Interestingly the rk3066 one
is "just" another saradc IP, so for this one it would really make sense.
> > On the driver side, I believe the correct way to deal with this setup
> > is to split your driver into a generic drivers/iio/adc/rockchips-tsadc.c
> > file, and a smaller thermal driver that uses the iio in-kernel interfaces,
> > ideally one that is independent of the underlying hardware and can
> > work on any ADC implementation.
>
> Agreed. If you can write such interface and make your driver to work in
> such way, that would be great.
But I currently don't see how you would model the temperature handling parts
from a generic thermal driver to a generic adc driver for the rk3288-tsadc.
I guess the general temperature irq handling would use iio-triggers? But how
does the target temperature get into the TSADC_COMP1_INT register.
Also when getting the temperature, Caesar's driver compares it to its trip
points and sets the next trip point depending on the current temperature
(passive <-> critical) in rockchip_get_temp.
Maybe there is some completely easy way for this, but currently I don't see
it.
Heiko
[-- Attachment #2: Type: text/html, Size: 7469 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Re: [PATCH v3 1/4] thermal: rockchip: add driver for thermal
2014-08-29 1:54 ` 赵仪峰
@ 2014-08-29 11:39 ` edubezval
2014-08-29 12:08 ` Huang Tao
0 siblings, 1 reply; 10+ messages in thread
From: edubezval @ 2014-08-29 11:39 UTC (permalink / raw)
To: 赵仪峰
Cc: HeikoStübner, Arnd Bergmann, Caesar Wang, rui.zhang,
grant.likely, robh+dt, linux-kernel, linux-pm, linux-arm-kernel,
devicetree, linux-doc, 黄涛, 蔡枫,
dianders, dtor, 钟勇汪, addy.ke@rock-chips.com,
dmitry.torokhov, linux-iio, Jonathan Cameron
Hello Zhao,
On Thu, Aug 28, 2014 at 9:54 PM, 赵仪峰 <zyf@rock-chips.com> wrote:
> Hi Heiko,
>
> The TS-ADC on RK3288 has two component, a tsadc and a tsadc controller.
> The tsadc controller is similar like the thermal manager unit on other SOCs.
> We followed the naming of 3066, but not named as the Thermal Manager.
>
> Moreover,there is only one set of apb registers to access the tsadc
> controller,and the tsadc is controlled by the tsadc controller,could not
> access directly. If we write a general tsadc driver by accessed tsadc
> controller registers, and it hardly to write a driver for the tsadc
> controller.
As suggested by Arnd, you can use the generic driver as interface
between thermal framework and IIO layer. The driver you are going to
write to your ADC is going to be in the IIO subsystem. The only
difference is that the generic driver would work for any ADC driver in
the IIO subsystem.
https://lkml.org/lkml/2014/2/5/810
In fact, there is already a generic driver. We just need to get it up
to date. I see some testing has been already done, and results sound
promising.
>
> So, I do not agree to write a generic adc driver for the rk3288-tsadc.
>
> ________________________________
> Yifeng Zhao
>
> 发件人: HeikoStübner
> 发送时间: 2014-08-29 00:11
> 收件人: Eduardo Valentin
> 抄送: Arnd Bergmann; Caesar Wang; rui.zhang; grant.likely; robh+dt;
> linux-kernel; linux-pm; linux-arm-kernel; devicetree; linux-doc; huangtao;
> cf; dianders; dtor; zyw; addy.ke; dmitry.torokhov; zhaoyifeng; linux-iio;
> Jonathan Cameron
> 主题: Re: [PATCH v3 1/4] thermal: rockchip: add driver for thermal
>
> Am Donnerstag, 28. August 2014, 10:37:35 schrieb Eduardo Valentin:
>> Ceasar and Arnd,
>>
>> On Thu, Aug 28, 2014 at 10:48:23AM +0200, Arnd Bergmann wrote:
>> > On Thursday 28 August 2014 08:59:19 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 <zyf@rock-chips.com>
>> > > Signed-off-by: Caesar Wang <caesar.wang@rock-chips.com>
>> >
>> > Hi Caesar,
>> >
>> > After looking at the driver (last time I only received the patch for
>> > the binding), I have a more general comment:
>> >
>> > This looks like a general-purpose ADC device, not an IP block that is
>> > specific to thermal management. The binding looks ok for that purpose
>> > but should probably be moved into
>> > Documentation/devicetree/bindings/iio/adc/ as a minor change.
>>
>> I agree with Arnd's point here. It makes sense to me to have this driver
>> under the IIO umbrella.
>
> interesting suggestion :-)
>
> I've just taken another look at the registers of the ts-adc on the rk3066
> which is completely different from the rk3288 one. Interestingly the rk3066
> one
> is "just" another saradc IP, so for this one it would really make sense.
>
>
>> > On the driver side, I believe the correct way to deal with this setup
>> > is to split your driver into a generic drivers/iio/adc/rockchips-tsadc.c
>> > file, and a smaller thermal driver that uses the iio in-kernel
>> > interfaces,
>> > ideally one that is independent of the underlying hardware and can
>> > work on any ADC implementation.
>>
>> Agreed. If you can write such interface and make your driver to work in
>> such way, that would be great.
>
> But I currently don't see how you would model the temperature handling parts
> from a generic thermal driver to a generic adc driver for the rk3288-tsadc.
>
> I guess the general temperature irq handling would use iio-triggers? But how
> does the target temperature get into the TSADC_COMP1_INT register.
>
> Also when getting the temperature, Caesar's driver compares it to its trip
> points and sets the next trip point depending on the current temperature
> (passive <-> critical) in rockchip_get_temp.
>
> Maybe there is some completely easy way for this, but currently I don't see
> it.
>
>
> Heiko
>
>
--
Eduardo Bezerra Valentin
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v3 1/4] thermal: rockchip: add driver for thermal
2014-08-29 11:39 ` edubezval
@ 2014-08-29 12:08 ` Huang Tao
2014-08-30 9:30 ` Jonathan Cameron
0 siblings, 1 reply; 10+ messages in thread
From: Huang Tao @ 2014-08-29 12:08 UTC (permalink / raw)
To: edubezval@gmail.com, 赵仪峰
Cc: HeikoStübner, Arnd Bergmann, Caesar Wang, rui.zhang,
grant.likely, robh+dt, linux-kernel, linux-pm, linux-arm-kernel,
devicetree, linux-doc, 蔡枫, dianders, dtor,
钟勇汪, addy.ke@rock-chips.com, dmitry.torokhov,
linux-iio, Jonathan Cameron
Dear Eduardo Bezerra Valentin:
在 2014年08月29日 19:39, edubezval@gmail.com 写道:
> Hello Zhao,
>
> On Thu, Aug 28, 2014 at 9:54 PM, 赵仪峰 <zyf@rock-chips.com> wrote:
>> Hi Heiko,
>>
>> The TS-ADC on RK3288 has two component, a tsadc and a tsadc controller.
>> The tsadc controller is similar like the thermal manager unit on other SOCs.
>> We followed the naming of 3066, but not named as the Thermal Manager.
>>
>> Moreover,there is only one set of apb registers to access the tsadc
>> controller,and the tsadc is controlled by the tsadc controller,could not
>> access directly. If we write a general tsadc driver by accessed tsadc
>> controller registers, and it hardly to write a driver for the tsadc
>> controller.
> As suggested by Arnd, you can use the generic driver as interface
> between thermal framework and IIO layer. The driver you are going to
> write to your ADC is going to be in the IIO subsystem. The only
> difference is that the generic driver would work for any ADC driver in
> the IIO subsystem.
> https://lkml.org/lkml/2014/2/5/810
>
> In fact, there is already a generic driver. We just need to get it up
> to date. I see some testing has been already done, and results sound
> promising.
This iio_thermal driver only support get temperature from the ADC IIO
channel.
It dose not support any advanced feature such as configure the
temperature when system should be reset.
So if we adapt it, we will access the register form both TSADC IIO
driver and thermal driver.
I don't thank this is a good ideal.
In fact, we should ignore the "ADC" stuff. This sensor use ADC internal,
but it is transparent to software, especially in automatic mode.
>
>> So, I do not agree to write a generic adc driver for the rk3288-tsadc.
>>
>> ________________________________
>> Yifeng Zhao
>>
>>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v3 1/4] thermal: rockchip: add driver for thermal
2014-08-29 12:08 ` Huang Tao
@ 2014-08-30 9:30 ` Jonathan Cameron
0 siblings, 0 replies; 10+ messages in thread
From: Jonathan Cameron @ 2014-08-30 9:30 UTC (permalink / raw)
To: Huang Tao, edubezval@gmail.com, 赵仪峰
Cc: HeikoStübner, Arnd Bergmann, Caesar Wang, rui.zhang,
grant.likely, robh+dt, linux-kernel, linux-pm, linux-arm-kernel,
devicetree, linux-doc, 蔡枫, dianders, dtor,
钟勇汪, addy.ke@rock-chips.com, dmitry.torokhov,
linux-iio
On 29/08/14 13:08, Huang Tao wrote:
> Dear Eduardo Bezerra Valentin:
>
> 在 2014年08月29日 19:39, edubezval@gmail.com 写道:
>> Hello Zhao,
>>
>> On Thu, Aug 28, 2014 at 9:54 PM, 赵仪峰 <zyf@rock-chips.com> wrote:
>>> Hi Heiko,
>>>
>>> The TS-ADC on RK3288 has two component, a tsadc and a tsadc controller.
>>> The tsadc controller is similar like the thermal manager unit on other SOCs.
>>> We followed the naming of 3066, but not named as the Thermal Manager.
>>>
>>> Moreover,there is only one set of apb registers to access the tsadc
>>> controller,and the tsadc is controlled by the tsadc controller,could not
>>> access directly. If we write a general tsadc driver by accessed tsadc
>>> controller registers, and it hardly to write a driver for the tsadc
>>> controller.
>> As suggested by Arnd, you can use the generic driver as interface
>> between thermal framework and IIO layer. The driver you are going to
>> write to your ADC is going to be in the IIO subsystem. The only
>> difference is that the generic driver would work for any ADC driver in
>> the IIO subsystem.
>> https://lkml.org/lkml/2014/2/5/810
>>
>> In fact, there is already a generic driver. We just need to get it up
>> to date. I see some testing has been already done, and results sound
>> promising.
> This iio_thermal driver only support get temperature from the ADC IIO
> channel.
> It dose not support any advanced feature such as configure the
> temperature when system should be reset.
> So if we adapt it, we will access the register form both TSADC IIO
> driver and thermal driver.
> I don't thank this is a good ideal.
Interesting bit of functionality. I agree this doesn't fit overwelmingly well
into an iio consumer driver as things currently stand.
Looking briefly at your code, this is basically a threshold interrupt?
If so then we do have threshold type event handling in IIO (simply termed
events). The snag is that it is the one area that doesn't currently have
any in kernel interfaces.
Such an interface would be similar to that used for the buffered data access (raw
data stream - we should probably rename that as it isn't always buffered anymore).
The nasty bit (as it was with the buffered interface) is writing a reasonably
efficient demux that can split out the data to those devices that have registered
their interest in it. It would involve some additional code in iio_push_event and
some indirection in the code that controls what events are enabled.
Actually, you could probably skip this an just squirt all events recieved out through
the direct IIO to userspace interface (nothing prevents another process turning
more on anyway!). We could event for now specify that any in kernel users might
get other events and it is up to them to sanity check them.
We'd also need to add some basic access functions to set limits etc.
I'm afraid the 'events' bit of IIO is one of our least developed elements and is
lagging way behind the work done on the main data flows. It's been on the
list for a while, particularly as we need it to finish separating the
userspace interfaces of IIO from the backend.
So, looking at the wider picture, with a few additions to IIO we can support
some ADC based thermal drivers - whether all of them is a bit dependent on
whether they have weird and wonderful domain specific hardware (which I might
have missed here, but does not seem to be present).
Note this is based on a rather brief scan read so I may well have missed some
important details!
>
> In fact, we should ignore the "ADC" stuff. This sensor use ADC internal,
> but it is transparent to software, especially in automatic mode.
Is this adc ever used for anything else? If so, then there is your reason to
go through the pain of a generic driver.
Jonathan
p.s. I'd never seen the driver Arnd highlighted. Could anyone working on
IIO clients cc linux-iio@vger.kernel.org as it's useful to know what people
are using the interfaces for (particularly as they might change so it is
good to know what is in the pipeline).
>>
>>> So, I do not agree to write a generic adc driver for the rk3288-tsadc.
>>>
>>> ________________________________
>>> Yifeng Zhao
>>>
>>>
>
>
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2014-08-30 9:30 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1409187562-12370-1-git-send-email-caesar.wang@rock-chips.com>
[not found] ` <1409187562-12370-2-git-send-email-caesar.wang@rock-chips.com>
2014-08-28 8:48 ` [PATCH v3 1/4] thermal: rockchip: add driver for thermal Arnd Bergmann
2014-08-28 14:37 ` Eduardo Valentin
2014-08-28 16:11 ` Heiko Stübner
2014-08-28 16:16 ` Arnd Bergmann
2014-08-28 19:36 ` Caesar Wang
2014-08-28 23:01 ` Heiko Stübner
2014-08-29 1:54 ` 赵仪峰
2014-08-29 11:39 ` edubezval
2014-08-29 12:08 ` Huang Tao
2014-08-30 9:30 ` Jonathan Cameron
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).