All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH v5 04/21] dt-bindings: Add doc for the Ingenic TCU drivers
@ 2018-10-03 10:32 Paul Cercueil
  2018-10-06  9:20 ` Alexandre Belloni
  0 siblings, 1 reply; 27+ messages in thread
From: Paul Cercueil @ 2018-10-03 10:32 UTC (permalink / raw)
  To: Daniel Lezcano, robh
  Cc: Thomas Gleixner, Guenter Roeck, linux-doc, linux-watchdog,
	Jonathan Corbet, linux-mips, Stephen Boyd, Wim Van Sebroeck,
	Mark Rutland, Paul Burton, Michael Turquette, linux-clk,
	linux-kernel, devicetree, Ralf Baechle, Lee Jones,
	Thierry Reding, linux-pwm


Le 1 oct. 2018 10:48, Daniel Lezcano <daniel.lezcano@linaro.org> a écrit :
>
> On 31/07/2018 00:01, Paul Cercueil wrote: 
>
> [ ... ] 
>
> >>>  +- ingenic,timer-channel: Specifies the TCU channel that should be 
> >>> used as 
> >>>  +  system timer. If not provided, the TCU channel 0 is used for the 
> >>> system timer. 
> >>>  + 
> >>>  +- ingenic,clocksource-channel: Specifies the TCU channel that 
> >>> should be used 
> >>>  +  as clocksource and sched_clock. It must be a different channel 
> >>> than the one 
> >>>  +  used as system timer. If not provided, neither a clocksource nor a 
> >>>  +  sched_clock is instantiated. 
> >> 
> >> clocksource and sched_clock are Linux specific and don't belong in DT. 
> >> You should define properties of the hardware or use existing properties 
> >> like interrupts or clocks to figure out which channel to use. For 
> >> example, if some channels don't have an interrupt, then use them for 
> >> clocksource and not a clockevent. Or you could have timers that run in 
> >> low-power modes or not. If all the channels are identical, then it 
> >> shouldn't matter which ones the OS picks. 
>
> It can't work in this case because the pmw and the timer driver are not 
> communicating and the first one can stole a channel to the last one. 

In that particular case the timer driver will always request its channels first; with no timer set the system hangs before subsys_initcall, and the PWM driver is a subnode of the timer node, so is probed only after the timer probed.

> > We already talked about that. All the TCU channels can be used for PWM. 
> > The problem is I cannot know from the driver's scope which channels will 
> > be free and which channels will be requested for PWM. You suggested that I 
> > parse the devicetree for clients, and I did that in the V3/V4 patchset. But 
> > it only works for clients requesting through devicetree, not from platform 
> > code or even sysfs. 
> > 
> > One thing I can try is to dynamically change the channels the system timer 
> > and clocksource are using when the current ones are requested for PWM. But 
> > that sounds hardcore... 
>
> Yes, it is :/ 
>
> Sorry for letting you wasting time and effort to write an overkill code 
> not suitable for upstream. 
>
> A very gross thought, wouldn't be possible to "register" a channel from 
> the timer driver code in a shared data area (but well self-encapsulated) 
> and the pwm code will check such channel isn't in use ? 

Probably, but it's the contrary I need to do. The timer driver code can use any channel, and probes first. The PWM driver code must use specific channels, and probes last. So either the timer driver knows what channels it can't use, thanks to a device property, or it adapts itself when a channel in use is requested for PWM, which is what I tried in v7.

I think we could find a way to use a devicetree property that doesn't trigger Rob. That would still be the easiest and cleanest solution. 

Maybe "ingenic,reserved-channels-mask", which would contain a mask of channels that can only be used by the timer driver. And what the timer driver does with these channels, would be specific to the implementation and would not appear in the bindings. I hope Rob can work with that.

-Paul

^ permalink raw reply	[flat|nested] 27+ messages in thread
* Re: [PATCH v5 04/21] dt-bindings: Add doc for the Ingenic TCU drivers
@ 2018-10-10 10:38 Paul Cercueil
  0 siblings, 0 replies; 27+ messages in thread
From: Paul Cercueil @ 2018-10-10 10:38 UTC (permalink / raw)
  To: Lee Jones
  Cc: Thomas Gleixner, Guenter Roeck, linux-doc, Jonathan Corbet,
	linux-watchdog, Daniel Lezcano, robh, linux-mips, Stephen Boyd,
	Wim Van Sebroeck, Michael Turquette, Mark Rutland, Paul Burton,
	linux-kernel, linux-clk, devicetree, Ralf Baechle,
	Thierry Reding, linux-pwm

 [ ... ] 

> Paul, 
>
> I think there is something wrong with your mailer since your replies 
> are being scattered across my inbox un-threaded, making conversations 
> very difficult to follow. 

Oh, I'm sorry about that. I use the standard email client of Android (I'm on the road), is it known for not handling threads?

- Paul

^ permalink raw reply	[flat|nested] 27+ messages in thread
* Re: [PATCH v5 04/21] dt-bindings: Add doc for the Ingenic TCU drivers
@ 2018-10-10 10:38 Paul Cercueil
  0 siblings, 0 replies; 27+ messages in thread
From: Paul Cercueil @ 2018-10-10 10:38 UTC (permalink / raw)
  To: Lee Jones
  Cc: Thomas Gleixner, Guenter Roeck, linux-doc, Jonathan Corbet,
	linux-watchdog, Daniel Lezcano, robh, linux-mips, Stephen Boyd,
	Wim Van Sebroeck, Michael Turquette, Mark Rutland, Paul Burton,
	linux-kernel, linux-clk, devicetree, Ralf Baechle,
	Thierry Reding, linux-pwm

 [ ... ] 

> Paul, 
>
> I think there is something wrong with your mailer since your replies 
> are being scattered across my inbox un-threaded, making conversations 
> very difficult to follow. 

Oh, I'm sorry about that. I use the standard email client of Android (I'm on the road), is it known for not handling threads?

- Paul

^ permalink raw reply	[flat|nested] 27+ messages in thread
* Re: [PATCH v5 04/21] dt-bindings: Add doc for the Ingenic TCU drivers
@ 2018-10-10 10:38 Paul Cercueil
  0 siblings, 0 replies; 27+ messages in thread
From: Paul Cercueil @ 2018-10-10 10:38 UTC (permalink / raw)
  To: Lee Jones
  Cc: Thomas Gleixner, Guenter Roeck, linux-doc, Jonathan Corbet,
	linux-watchdog, Daniel Lezcano, robh, linux-mips, Stephen Boyd,
	Wim Van Sebroeck, Michael Turquette, Mark Rutland, Paul Burton,
	linux-kernel, linux-clk, devicetree, Ralf Baechle,
	Thierry Reding, linux-pwm

 [ ... ] 

> Paul, 
>
> I think there is something wrong with your mailer since your replies 
> are being scattered across my inbox un-threaded, making conversations 
> very difficult to follow. 

Oh, I'm sorry about that. I use the standard email client of Android (I'm on the road), is it known for not handling threads?

- Paul

^ permalink raw reply	[flat|nested] 27+ messages in thread
[parent not found: <5bb4c6ad.1c69fb81.42bb.93ecSMTPIN_ADDED_MISSING@mx.google.com>]
* Re: [PATCH v5 04/21] dt-bindings: Add doc for the Ingenic TCU drivers
@ 2018-10-07 19:14 Paul Cercueil
  0 siblings, 0 replies; 27+ messages in thread
From: Paul Cercueil @ 2018-10-07 19:14 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: Thomas Gleixner, Guenter Roeck, linux-doc, linux-watchdog,
	Daniel Lezcano, Jonathan Corbet, robh, linux-mips, Stephen Boyd,
	Wim Van Sebroeck, Michael Turquette, Mark Rutland, Paul Burton,
	linux-kernel, linux-clk, devicetree, Ralf Baechle, Lee Jones,
	Thierry Reding, linux-pwm


Le 6 oct. 2018 11:20 AM, Alexandre Belloni <alexandre.belloni@bootlin.com> a écrit :
>
> On 03/10/2018 12:32:51+0200, Paul Cercueil wrote: 
> > 
> > Le 1 oct. 2018 10:48, Daniel Lezcano <daniel.lezcano@linaro.org> a écrit : 
> > > 
> > > On 31/07/2018 00:01, Paul Cercueil wrote: 
> > > 
> > > [ ... ] 
> > > 
> > > >>>  +- ingenic,timer-channel: Specifies the TCU channel that should be 
> > > >>> used as 
> > > >>>  +  system timer. If not provided, the TCU channel 0 is used for the 
> > > >>> system timer. 
> > > >>>  + 
> > > >>>  +- ingenic,clocksource-channel: Specifies the TCU channel that 
> > > >>> should be used 
> > > >>>  +  as clocksource and sched_clock. It must be a different channel 
> > > >>> than the one 
> > > >>>  +  used as system timer. If not provided, neither a clocksource nor a 
> > > >>>  +  sched_clock is instantiated. 
> > > >> 
> > > >> clocksource and sched_clock are Linux specific and don't belong in DT. 
> > > >> You should define properties of the hardware or use existing properties 
> > > >> like interrupts or clocks to figure out which channel to use. For 
> > > >> example, if some channels don't have an interrupt, then use them for 
> > > >> clocksource and not a clockevent. Or you could have timers that run in 
> > > >> low-power modes or not. If all the channels are identical, then it 
> > > >> shouldn't matter which ones the OS picks. 
> > > 
> > > It can't work in this case because the pmw and the timer driver are not 
> > > communicating and the first one can stole a channel to the last one. 
> > 
> > In that particular case the timer driver will always request its channels first; with no timer set the system hangs before subsys_initcall, and the PWM driver is a subnode of the timer node, so is probed only after the timer probed. 
> > 
> > > > We already talked about that. All the TCU channels can be used for PWM. 
> > > > The problem is I cannot know from the driver's scope which channels will 
> > > > be free and which channels will be requested for PWM. You suggested that I 
> > > > parse the devicetree for clients, and I did that in the V3/V4 patchset. But 
> > > > it only works for clients requesting through devicetree, not from platform 
> > > > code or even sysfs. 
> > > > 
> > > > One thing I can try is to dynamically change the channels the system timer 
> > > > and clocksource are using when the current ones are requested for PWM. But 
> > > > that sounds hardcore... 
> > > 
> > > Yes, it is :/ 
> > > 
> > > Sorry for letting you wasting time and effort to write an overkill code 
> > > not suitable for upstream. 
> > > 
> > > A very gross thought, wouldn't be possible to "register" a channel from 
> > > the timer driver code in a shared data area (but well self-encapsulated) 
> > > and the pwm code will check such channel isn't in use ? 
> > 
> > Probably, but it's the contrary I need to do. The timer driver code can use any channel, and probes first. The PWM driver code must use specific channels, and probes last. So either the timer driver knows what channels it can't use, thanks to a device property, or it adapts itself when a channel in use is requested for PWM, which is what I tried in v7. 
> > 
> > I think we could find a way to use a devicetree property that doesn't trigger Rob. That would still be the easiest and cleanest solution. 
> > 
> > Maybe "ingenic,reserved-channels-mask", which would contain a mask of channels that can only be used by the timer driver. And what the timer driver does with these channels, would be specific to the implementation and would not appear in the bindings. I hope Rob can work with that. 
> > 
>
> Rob did ack the following binding: 
>
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/mfd/atmel-tcb.txt 
>
> another subdevice is a PWM (not documented here). 

I'm not sure that it would be the cleanest in my case, my PWM and watchdog sub-nodes already specify memory resources in their "reg" property. And if I add memory resources to the same "timers" sub-nodes as in your example, the ranges will overlap and Rob still won't be happy :)

-Paul

^ permalink raw reply	[flat|nested] 27+ messages in thread
* Re: [PATCH v5 04/21] dt-bindings: Add doc for the Ingenic TCU drivers
@ 2018-10-07 19:14 Paul Cercueil
  0 siblings, 0 replies; 27+ messages in thread
From: Paul Cercueil @ 2018-10-07 19:14 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: Thomas Gleixner, Guenter Roeck, linux-doc, linux-watchdog,
	Daniel Lezcano, Jonathan Corbet, robh, linux-mips, Stephen Boyd,
	Wim Van Sebroeck, Michael Turquette, Mark Rutland, Paul Burton,
	linux-kernel, linux-clk, devicetree, Ralf Baechle, Lee Jones,
	Thierry Reding, linux-pwm


Le 6 oct. 2018 11:20 AM, Alexandre Belloni <alexandre.belloni@bootlin.com> a écrit :
>
> On 03/10/2018 12:32:51+0200, Paul Cercueil wrote: 
> > 
> > Le 1 oct. 2018 10:48, Daniel Lezcano <daniel.lezcano@linaro.org> a écrit : 
> > > 
> > > On 31/07/2018 00:01, Paul Cercueil wrote: 
> > > 
> > > [ ... ] 
> > > 
> > > >>>  +- ingenic,timer-channel: Specifies the TCU channel that should be 
> > > >>> used as 
> > > >>>  +  system timer. If not provided, the TCU channel 0 is used for the 
> > > >>> system timer. 
> > > >>>  + 
> > > >>>  +- ingenic,clocksource-channel: Specifies the TCU channel that 
> > > >>> should be used 
> > > >>>  +  as clocksource and sched_clock. It must be a different channel 
> > > >>> than the one 
> > > >>>  +  used as system timer. If not provided, neither a clocksource nor a 
> > > >>>  +  sched_clock is instantiated. 
> > > >> 
> > > >> clocksource and sched_clock are Linux specific and don't belong in DT. 
> > > >> You should define properties of the hardware or use existing properties 
> > > >> like interrupts or clocks to figure out which channel to use. For 
> > > >> example, if some channels don't have an interrupt, then use them for 
> > > >> clocksource and not a clockevent. Or you could have timers that run in 
> > > >> low-power modes or not. If all the channels are identical, then it 
> > > >> shouldn't matter which ones the OS picks. 
> > > 
> > > It can't work in this case because the pmw and the timer driver are not 
> > > communicating and the first one can stole a channel to the last one. 
> > 
> > In that particular case the timer driver will always request its channels first; with no timer set the system hangs before subsys_initcall, and the PWM driver is a subnode of the timer node, so is probed only after the timer probed. 
> > 
> > > > We already talked about that. All the TCU channels can be used for PWM. 
> > > > The problem is I cannot know from the driver's scope which channels will 
> > > > be free and which channels will be requested for PWM. You suggested that I 
> > > > parse the devicetree for clients, and I did that in the V3/V4 patchset. But 
> > > > it only works for clients requesting through devicetree, not from platform 
> > > > code or even sysfs. 
> > > > 
> > > > One thing I can try is to dynamically change the channels the system timer 
> > > > and clocksource are using when the current ones are requested for PWM. But 
> > > > that sounds hardcore... 
> > > 
> > > Yes, it is :/ 
> > > 
> > > Sorry for letting you wasting time and effort to write an overkill code 
> > > not suitable for upstream. 
> > > 
> > > A very gross thought, wouldn't be possible to "register" a channel from 
> > > the timer driver code in a shared data area (but well self-encapsulated) 
> > > and the pwm code will check such channel isn't in use ? 
> > 
> > Probably, but it's the contrary I need to do. The timer driver code can use any channel, and probes first. The PWM driver code must use specific channels, and probes last. So either the timer driver knows what channels it can't use, thanks to a device property, or it adapts itself when a channel in use is requested for PWM, which is what I tried in v7. 
> > 
> > I think we could find a way to use a devicetree property that doesn't trigger Rob. That would still be the easiest and cleanest solution. 
> > 
> > Maybe "ingenic,reserved-channels-mask", which would contain a mask of channels that can only be used by the timer driver. And what the timer driver does with these channels, would be specific to the implementation and would not appear in the bindings. I hope Rob can work with that. 
> > 
>
> Rob did ack the following binding: 
>
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/mfd/atmel-tcb.txt 
>
> another subdevice is a PWM (not documented here). 

I'm not sure that it would be the cleanest in my case, my PWM and watchdog sub-nodes already specify memory resources in their "reg" property. And if I add memory resources to the same "timers" sub-nodes as in your example, the ranges will overlap and Rob still won't be happy :)

-Paul

^ permalink raw reply	[flat|nested] 27+ messages in thread
* Re: [PATCH v5 04/21] dt-bindings: Add doc for the Ingenic TCU drivers
@ 2018-10-07 19:14 Paul Cercueil
  0 siblings, 0 replies; 27+ messages in thread
From: Paul Cercueil @ 2018-10-07 19:14 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: Thomas Gleixner, Guenter Roeck, linux-doc, linux-watchdog,
	Daniel Lezcano, Jonathan Corbet, robh, linux-mips, Stephen Boyd,
	Wim Van Sebroeck, Michael Turquette, Mark Rutland, Paul Burton,
	linux-kernel, linux-clk, devicetree, Ralf Baechle, Lee Jones,
	Thierry Reding, linux-pwm


Le 6 oct. 2018 11:20 AM, Alexandre Belloni <alexandre.belloni@bootlin.com> a écrit :
>
> On 03/10/2018 12:32:51+0200, Paul Cercueil wrote: 
> > 
> > Le 1 oct. 2018 10:48, Daniel Lezcano <daniel.lezcano@linaro.org> a écrit : 
> > > 
> > > On 31/07/2018 00:01, Paul Cercueil wrote: 
> > > 
> > > [ ... ] 
> > > 
> > > >>>  +- ingenic,timer-channel: Specifies the TCU channel that should be 
> > > >>> used as 
> > > >>>  +  system timer. If not provided, the TCU channel 0 is used for the 
> > > >>> system timer. 
> > > >>>  + 
> > > >>>  +- ingenic,clocksource-channel: Specifies the TCU channel that 
> > > >>> should be used 
> > > >>>  +  as clocksource and sched_clock. It must be a different channel 
> > > >>> than the one 
> > > >>>  +  used as system timer. If not provided, neither a clocksource nor a 
> > > >>>  +  sched_clock is instantiated. 
> > > >> 
> > > >> clocksource and sched_clock are Linux specific and don't belong in DT. 
> > > >> You should define properties of the hardware or use existing properties 
> > > >> like interrupts or clocks to figure out which channel to use. For 
> > > >> example, if some channels don't have an interrupt, then use them for 
> > > >> clocksource and not a clockevent. Or you could have timers that run in 
> > > >> low-power modes or not. If all the channels are identical, then it 
> > > >> shouldn't matter which ones the OS picks. 
> > > 
> > > It can't work in this case because the pmw and the timer driver are not 
> > > communicating and the first one can stole a channel to the last one. 
> > 
> > In that particular case the timer driver will always request its channels first; with no timer set the system hangs before subsys_initcall, and the PWM driver is a subnode of the timer node, so is probed only after the timer probed. 
> > 
> > > > We already talked about that. All the TCU channels can be used for PWM. 
> > > > The problem is I cannot know from the driver's scope which channels will 
> > > > be free and which channels will be requested for PWM. You suggested that I 
> > > > parse the devicetree for clients, and I did that in the V3/V4 patchset. But 
> > > > it only works for clients requesting through devicetree, not from platform 
> > > > code or even sysfs. 
> > > > 
> > > > One thing I can try is to dynamically change the channels the system timer 
> > > > and clocksource are using when the current ones are requested for PWM. But 
> > > > that sounds hardcore... 
> > > 
> > > Yes, it is :/ 
> > > 
> > > Sorry for letting you wasting time and effort to write an overkill code 
> > > not suitable for upstream. 
> > > 
> > > A very gross thought, wouldn't be possible to "register" a channel from 
> > > the timer driver code in a shared data area (but well self-encapsulated) 
> > > and the pwm code will check such channel isn't in use ? 
> > 
> > Probably, but it's the contrary I need to do. The timer driver code can use any channel, and probes first. The PWM driver code must use specific channels, and probes last. So either the timer driver knows what channels it can't use, thanks to a device property, or it adapts itself when a channel in use is requested for PWM, which is what I tried in v7. 
> > 
> > I think we could find a way to use a devicetree property that doesn't trigger Rob. That would still be the easiest and cleanest solution. 
> > 
> > Maybe "ingenic,reserved-channels-mask", which would contain a mask of channels that can only be used by the timer driver. And what the timer driver does with these channels, would be specific to the implementation and would not appear in the bindings. I hope Rob can work with that. 
> > 
>
> Rob did ack the following binding: 
>
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/mfd/atmel-tcb.txt 
>
> another subdevice is a PWM (not documented here). 

I'm not sure that it would be the cleanest in my case, my PWM and watchdog sub-nodes already specify memory resources in their "reg" property. And if I add memory resources to the same "timers" sub-nodes as in your example, the ranges will overlap and Rob still won't be happy :)

-Paul

^ permalink raw reply	[flat|nested] 27+ messages in thread
* Re: [PATCH v5 04/21] dt-bindings: Add doc for the Ingenic TCU drivers
@ 2018-10-03 13:39 Paul Cercueil
  0 siblings, 0 replies; 27+ messages in thread
From: Paul Cercueil @ 2018-10-03 13:39 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: Thomas Gleixner, Guenter Roeck, linux-doc, linux-watchdog,
	Jonathan Corbet, robh, linux-mips, Stephen Boyd,
	Wim Van Sebroeck, Mark Rutland, Paul Burton, Michael Turquette,
	linux-clk, linux-kernel, devicetree, Ralf Baechle, Lee Jones,
	Thierry Reding, linux-pwm


Le 3 oct. 2018 3:02 PM, Daniel Lezcano <daniel.lezcano@linaro.org> a écrit :
>
> On 03/10/2018 14:51, Paul Cercueil wrote: 
> > 
> > Le 3 oct. 2018 2:47 PM, Daniel Lezcano <daniel.lezcano@linaro.org> a 
> > écrit : 
> >> 
> >> On 03/10/2018 12:32, Paul Cercueil wrote: 
> >>> 
> >>> Le 1 oct. 2018 10:48, Daniel Lezcano <daniel.lezcano@linaro.org> 
> >>> a écrit : 
> >>>> 
> >>>> On 31/07/2018 00:01, Paul Cercueil wrote: 
> >>>> 
> >>>> [ ... ] 
> >>>> 
> >>>>>>> +- ingenic,timer-channel: Specifies the TCU channel that 
> >>>>>>>  should be used as +  system timer. If not provided, the 
> >>>>>>> TCU channel 0 is used for the system timer. + +- 
> >>>>>>> ingenic,clocksource-channel: Specifies the TCU channel 
> >>>>>>> that should be used +  as clocksource and sched_clock. It 
> >>>>>>> must be a different channel than the one +  used as 
> >>>>>>> system timer. If not provided, neither a clocksource nor 
> >>>>>>> a +  sched_clock is instantiated. 
> >>>>>> 
> >>>>>> clocksource and sched_clock are Linux specific and don't 
> >>>>>> belong in DT. You should define properties of the hardware 
> >>>>>> or use existing properties like interrupts or clocks to 
> >>>>>> figure out which channel to use. For example, if some 
> >>>>>> channels don't have an interrupt, then use them for 
> >>>>>> clocksource and not a clockevent. Or you could have timers 
> >>>>>> that run in low-power modes or not. If all the channels are 
> >>>>>> identical, then it shouldn't matter which ones the OS 
> >>>>>> picks. 
> >>>> 
> >>>> It can't work in this case because the pmw and the timer driver 
> >>>> are not communicating and the first one can stole a channel to 
> >>>> the last one. 
> >>> 
> >>> In that particular case the timer driver will always request its 
> >>>  channels first; with no timer set the system hangs before 
> >>> subsys_initcall, and the PWM driver is a subnode of the timer 
> >>> node, so is probed only after the timer probed. 
> >>> 
> >>>>> We already talked about that. All the TCU channels can be 
> >>>>> used for PWM. The problem is I cannot know from the driver's 
> >>>>> scope which channels will be free and which channels will be 
> >>>>> requested for PWM. You suggested that I parse the devicetree 
> >>>>> for clients, and I did that in the V3/V4 patchset. But it 
> >>>>> only works for clients requesting through devicetree, not 
> >>>>> from platform code or even sysfs. 
> >>>>> 
> >>>>> One thing I can try is to dynamically change the channels the 
> >>>>>  system timer and clocksource are using when the current ones 
> >>>>> are requested for PWM. But that sounds hardcore... 
> >>>> 
> >>>> Yes, it is :/ 
> >>>> 
> >>>> Sorry for letting you wasting time and effort to write an 
> >>>> overkill code not suitable for upstream. 
> >>>> 
> >>>> A very gross thought, wouldn't be possible to "register" a 
> >>>> channel from the timer driver code in a shared data area (but 
> >>>> well self-encapsulated) and the pwm code will check such 
> >>>> channel isn't in use ? 
> >>> 
> >>> Probably, but it's the contrary I need to do. The timer driver 
> >>> code can use any channel, and probes first. The PWM driver code 
> >>> must use specific channels, and probes last. So either the timer 
> >>> driver knows what channels it can't use, thanks to a device 
> >>> property, or it adapts itself when a channel in use is requested 
> >>> for PWM, which is what I tried in v7. 
> >> 
> >> When you say "must use specific channels", where is coming this 
> >> information ? 
> > 
> > If the backlight for the LCD is connected to the pin that corresponds 
> > to PWM1, then you must use the TCU channel 1. It's that simple. 
>
> Is it a runtime detection or is it hardcoded somewhere ? 
>
> (just trying to understand the whole picture) 

The PWM channel can be hardcoded in the "pwms" property of the clients. It can also be hardcoded in platform code, or simply requested from sysfs.

> >>> I think we could find a way to use a devicetree property that 
> >>> doesn't trigger Rob. That would still be the easiest and cleanest 
> >>> solution. 
> >>> 
> >>> Maybe "ingenic,reserved-channels-mask", which would contain a 
> >>> mask of channels that can only be used by the timer driver. And 
> >>> what the timer driver does with these channels, would be specific 
> >>> to the implementation and would not appear in the bindings. I 
> >>> hope Rob can work with that. 
> >>> 
> >>> -Paul 
>
>
> -- 
> <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs 
>
> Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook | 
> <http://twitter.com/#!/linaroorg> Twitter | 
> <http://www.linaro.org/linaro-blog/> Blog 
>

^ permalink raw reply	[flat|nested] 27+ messages in thread
* Re: [PATCH v5 04/21] dt-bindings: Add doc for the Ingenic TCU drivers
@ 2018-10-03 13:39 Paul Cercueil
  0 siblings, 0 replies; 27+ messages in thread
From: Paul Cercueil @ 2018-10-03 13:39 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: Thomas Gleixner, Guenter Roeck, linux-doc, linux-watchdog,
	Jonathan Corbet, robh, linux-mips, Stephen Boyd,
	Wim Van Sebroeck, Mark Rutland, Paul Burton, Michael Turquette,
	linux-clk, linux-kernel, devicetree, Ralf Baechle, Lee Jones,
	Thierry Reding, linux-pwm


Le 3 oct. 2018 3:02 PM, Daniel Lezcano <daniel.lezcano@linaro.org> a écrit :
>
> On 03/10/2018 14:51, Paul Cercueil wrote: 
> > 
> > Le 3 oct. 2018 2:47 PM, Daniel Lezcano <daniel.lezcano@linaro.org> a 
> > écrit : 
> >> 
> >> On 03/10/2018 12:32, Paul Cercueil wrote: 
> >>> 
> >>> Le 1 oct. 2018 10:48, Daniel Lezcano <daniel.lezcano@linaro.org> 
> >>> a écrit : 
> >>>> 
> >>>> On 31/07/2018 00:01, Paul Cercueil wrote: 
> >>>> 
> >>>> [ ... ] 
> >>>> 
> >>>>>>> +- ingenic,timer-channel: Specifies the TCU channel that 
> >>>>>>>  should be used as +  system timer. If not provided, the 
> >>>>>>> TCU channel 0 is used for the system timer. + +- 
> >>>>>>> ingenic,clocksource-channel: Specifies the TCU channel 
> >>>>>>> that should be used +  as clocksource and sched_clock. It 
> >>>>>>> must be a different channel than the one +  used as 
> >>>>>>> system timer. If not provided, neither a clocksource nor 
> >>>>>>> a +  sched_clock is instantiated. 
> >>>>>> 
> >>>>>> clocksource and sched_clock are Linux specific and don't 
> >>>>>> belong in DT. You should define properties of the hardware 
> >>>>>> or use existing properties like interrupts or clocks to 
> >>>>>> figure out which channel to use. For example, if some 
> >>>>>> channels don't have an interrupt, then use them for 
> >>>>>> clocksource and not a clockevent. Or you could have timers 
> >>>>>> that run in low-power modes or not. If all the channels are 
> >>>>>> identical, then it shouldn't matter which ones the OS 
> >>>>>> picks. 
> >>>> 
> >>>> It can't work in this case because the pmw and the timer driver 
> >>>> are not communicating and the first one can stole a channel to 
> >>>> the last one. 
> >>> 
> >>> In that particular case the timer driver will always request its 
> >>>  channels first; with no timer set the system hangs before 
> >>> subsys_initcall, and the PWM driver is a subnode of the timer 
> >>> node, so is probed only after the timer probed. 
> >>> 
> >>>>> We already talked about that. All the TCU channels can be 
> >>>>> used for PWM. The problem is I cannot know from the driver's 
> >>>>> scope which channels will be free and which channels will be 
> >>>>> requested for PWM. You suggested that I parse the devicetree 
> >>>>> for clients, and I did that in the V3/V4 patchset. But it 
> >>>>> only works for clients requesting through devicetree, not 
> >>>>> from platform code or even sysfs. 
> >>>>> 
> >>>>> One thing I can try is to dynamically change the channels the 
> >>>>>  system timer and clocksource are using when the current ones 
> >>>>> are requested for PWM. But that sounds hardcore... 
> >>>> 
> >>>> Yes, it is :/ 
> >>>> 
> >>>> Sorry for letting you wasting time and effort to write an 
> >>>> overkill code not suitable for upstream. 
> >>>> 
> >>>> A very gross thought, wouldn't be possible to "register" a 
> >>>> channel from the timer driver code in a shared data area (but 
> >>>> well self-encapsulated) and the pwm code will check such 
> >>>> channel isn't in use ? 
> >>> 
> >>> Probably, but it's the contrary I need to do. The timer driver 
> >>> code can use any channel, and probes first. The PWM driver code 
> >>> must use specific channels, and probes last. So either the timer 
> >>> driver knows what channels it can't use, thanks to a device 
> >>> property, or it adapts itself when a channel in use is requested 
> >>> for PWM, which is what I tried in v7. 
> >> 
> >> When you say "must use specific channels", where is coming this 
> >> information ? 
> > 
> > If the backlight for the LCD is connected to the pin that corresponds 
> > to PWM1, then you must use the TCU channel 1. It's that simple. 
>
> Is it a runtime detection or is it hardcoded somewhere ? 
>
> (just trying to understand the whole picture) 

The PWM channel can be hardcoded in the "pwms" property of the clients. It can also be hardcoded in platform code, or simply requested from sysfs.

> >>> I think we could find a way to use a devicetree property that 
> >>> doesn't trigger Rob. That would still be the easiest and cleanest 
> >>> solution. 
> >>> 
> >>> Maybe "ingenic,reserved-channels-mask", which would contain a 
> >>> mask of channels that can only be used by the timer driver. And 
> >>> what the timer driver does with these channels, would be specific 
> >>> to the implementation and would not appear in the bindings. I 
> >>> hope Rob can work with that. 
> >>> 
> >>> -Paul 
>
>
> -- 
> <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs 
>
> Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook | 
> <http://twitter.com/#!/linaroorg> Twitter | 
> <http://www.linaro.org/linaro-blog/> Blog 
>

^ permalink raw reply	[flat|nested] 27+ messages in thread
* Re: [PATCH v5 04/21] dt-bindings: Add doc for the Ingenic TCU drivers
@ 2018-10-03 13:39 Paul Cercueil
  0 siblings, 0 replies; 27+ messages in thread
From: Paul Cercueil @ 2018-10-03 13:39 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: Thomas Gleixner, Guenter Roeck, linux-doc, linux-watchdog,
	Jonathan Corbet, robh, linux-mips, Stephen Boyd,
	Wim Van Sebroeck, Mark Rutland, Paul Burton, Michael Turquette,
	linux-clk, linux-kernel, devicetree, Ralf Baechle, Lee Jones,
	Thierry Reding, linux-pwm


Le 3 oct. 2018 3:02 PM, Daniel Lezcano <daniel.lezcano@linaro.org> a écrit :
>
> On 03/10/2018 14:51, Paul Cercueil wrote: 
> > 
> > Le 3 oct. 2018 2:47 PM, Daniel Lezcano <daniel.lezcano@linaro.org> a 
> > écrit : 
> >> 
> >> On 03/10/2018 12:32, Paul Cercueil wrote: 
> >>> 
> >>> Le 1 oct. 2018 10:48, Daniel Lezcano <daniel.lezcano@linaro.org> 
> >>> a écrit : 
> >>>> 
> >>>> On 31/07/2018 00:01, Paul Cercueil wrote: 
> >>>> 
> >>>> [ ... ] 
> >>>> 
> >>>>>>> +- ingenic,timer-channel: Specifies the TCU channel that 
> >>>>>>>  should be used as +  system timer. If not provided, the 
> >>>>>>> TCU channel 0 is used for the system timer. + +- 
> >>>>>>> ingenic,clocksource-channel: Specifies the TCU channel 
> >>>>>>> that should be used +  as clocksource and sched_clock. It 
> >>>>>>> must be a different channel than the one +  used as 
> >>>>>>> system timer. If not provided, neither a clocksource nor 
> >>>>>>> a +  sched_clock is instantiated. 
> >>>>>> 
> >>>>>> clocksource and sched_clock are Linux specific and don't 
> >>>>>> belong in DT. You should define properties of the hardware 
> >>>>>> or use existing properties like interrupts or clocks to 
> >>>>>> figure out which channel to use. For example, if some 
> >>>>>> channels don't have an interrupt, then use them for 
> >>>>>> clocksource and not a clockevent. Or you could have timers 
> >>>>>> that run in low-power modes or not. If all the channels are 
> >>>>>> identical, then it shouldn't matter which ones the OS 
> >>>>>> picks. 
> >>>> 
> >>>> It can't work in this case because the pmw and the timer driver 
> >>>> are not communicating and the first one can stole a channel to 
> >>>> the last one. 
> >>> 
> >>> In that particular case the timer driver will always request its 
> >>>  channels first; with no timer set the system hangs before 
> >>> subsys_initcall, and the PWM driver is a subnode of the timer 
> >>> node, so is probed only after the timer probed. 
> >>> 
> >>>>> We already talked about that. All the TCU channels can be 
> >>>>> used for PWM. The problem is I cannot know from the driver's 
> >>>>> scope which channels will be free and which channels will be 
> >>>>> requested for PWM. You suggested that I parse the devicetree 
> >>>>> for clients, and I did that in the V3/V4 patchset. But it 
> >>>>> only works for clients requesting through devicetree, not 
> >>>>> from platform code or even sysfs. 
> >>>>> 
> >>>>> One thing I can try is to dynamically change the channels the 
> >>>>>  system timer and clocksource are using when the current ones 
> >>>>> are requested for PWM. But that sounds hardcore... 
> >>>> 
> >>>> Yes, it is :/ 
> >>>> 
> >>>> Sorry for letting you wasting time and effort to write an 
> >>>> overkill code not suitable for upstream. 
> >>>> 
> >>>> A very gross thought, wouldn't be possible to "register" a 
> >>>> channel from the timer driver code in a shared data area (but 
> >>>> well self-encapsulated) and the pwm code will check such 
> >>>> channel isn't in use ? 
> >>> 
> >>> Probably, but it's the contrary I need to do. The timer driver 
> >>> code can use any channel, and probes first. The PWM driver code 
> >>> must use specific channels, and probes last. So either the timer 
> >>> driver knows what channels it can't use, thanks to a device 
> >>> property, or it adapts itself when a channel in use is requested 
> >>> for PWM, which is what I tried in v7. 
> >> 
> >> When you say "must use specific channels", where is coming this 
> >> information ? 
> > 
> > If the backlight for the LCD is connected to the pin that corresponds 
> > to PWM1, then you must use the TCU channel 1. It's that simple. 
>
> Is it a runtime detection or is it hardcoded somewhere ? 
>
> (just trying to understand the whole picture) 

The PWM channel can be hardcoded in the "pwms" property of the clients. It can also be hardcoded in platform code, or simply requested from sysfs.

> >>> I think we could find a way to use a devicetree property that 
> >>> doesn't trigger Rob. That would still be the easiest and cleanest 
> >>> solution. 
> >>> 
> >>> Maybe "ingenic,reserved-channels-mask", which would contain a 
> >>> mask of channels that can only be used by the timer driver. And 
> >>> what the timer driver does with these channels, would be specific 
> >>> to the implementation and would not appear in the bindings. I 
> >>> hope Rob can work with that. 
> >>> 
> >>> -Paul 
>
>
> -- 
> <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs 
>
> Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook | 
> <http://twitter.com/#!/linaroorg> Twitter | 
> <http://www.linaro.org/linaro-blog/> Blog 
>

^ permalink raw reply	[flat|nested] 27+ messages in thread
[parent not found: <5bb4bb5d.1c69fb81.ed9a6.adc6SMTPIN_ADDED_MISSING@mx.google.com>]
* Re: [PATCH v5 04/21] dt-bindings: Add doc for the Ingenic TCU drivers
@ 2018-10-03 12:51 Paul Cercueil
  0 siblings, 0 replies; 27+ messages in thread
From: Paul Cercueil @ 2018-10-03 12:51 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: Thomas Gleixner, Guenter Roeck, linux-doc, Jonathan Corbet,
	linux-watchdog, robh, linux-mips, Stephen Boyd, Wim Van Sebroeck,
	Mark Rutland, Paul Burton, Michael Turquette, linux-kernel,
	linux-clk, devicetree, Ralf Baechle, Lee Jones, Thierry Reding,
	linux-pwm


Le 3 oct. 2018 2:47 PM, Daniel Lezcano <daniel.lezcano@linaro.org> a écrit :
>
> On 03/10/2018 12:32, Paul Cercueil wrote: 
> > 
> > Le 1 oct. 2018 10:48, Daniel Lezcano <daniel.lezcano@linaro.org> a 
> > écrit : 
> >> 
> >> On 31/07/2018 00:01, Paul Cercueil wrote: 
> >> 
> >> [ ... ] 
> >> 
> >>>>> +- ingenic,timer-channel: Specifies the TCU channel that 
> >>>>> should be used as +  system timer. If not provided, the TCU 
> >>>>> channel 0 is used for the system timer. + +- 
> >>>>> ingenic,clocksource-channel: Specifies the TCU channel that 
> >>>>> should be used +  as clocksource and sched_clock. It must be 
> >>>>> a different channel than the one +  used as system timer. If 
> >>>>> not provided, neither a clocksource nor a +  sched_clock is 
> >>>>> instantiated. 
> >>>> 
> >>>> clocksource and sched_clock are Linux specific and don't belong 
> >>>> in DT. You should define properties of the hardware or use 
> >>>> existing properties like interrupts or clocks to figure out 
> >>>> which channel to use. For example, if some channels don't have 
> >>>> an interrupt, then use them for clocksource and not a 
> >>>> clockevent. Or you could have timers that run in low-power 
> >>>> modes or not. If all the channels are identical, then it 
> >>>> shouldn't matter which ones the OS picks. 
> >> 
> >> It can't work in this case because the pmw and the timer driver are 
> >> not communicating and the first one can stole a channel to the last 
> >> one. 
> > 
> > In that particular case the timer driver will always request its 
> > channels first; with no timer set the system hangs before 
> > subsys_initcall, and the PWM driver is a subnode of the timer node, 
> > so is probed only after the timer probed. 
> > 
> >>> We already talked about that. All the TCU channels can be used 
> >>> for PWM. The problem is I cannot know from the driver's scope 
> >>> which channels will be free and which channels will be requested 
> >>> for PWM. You suggested that I parse the devicetree for clients, 
> >>> and I did that in the V3/V4 patchset. But it only works for 
> >>> clients requesting through devicetree, not from platform code or 
> >>> even sysfs. 
> >>> 
> >>> One thing I can try is to dynamically change the channels the 
> >>> system timer and clocksource are using when the current ones are 
> >>> requested for PWM. But that sounds hardcore... 
> >> 
> >> Yes, it is :/ 
> >> 
> >> Sorry for letting you wasting time and effort to write an overkill 
> >> code not suitable for upstream. 
> >> 
> >> A very gross thought, wouldn't be possible to "register" a channel 
> >> from the timer driver code in a shared data area (but well 
> >> self-encapsulated) and the pwm code will check such channel isn't 
> >> in use ? 
> > 
> > Probably, but it's the contrary I need to do. The timer driver code 
> > can use any channel, and probes first. The PWM driver code must use 
> > specific channels, and probes last. So either the timer driver knows 
> > what channels it can't use, thanks to a device property, or it adapts 
> > itself when a channel in use is requested for PWM, which is what I 
> > tried in v7. 
>
> When you say "must use specific channels", where is coming this 
> information ? 

If the backlight for the LCD is connected to the pin that corresponds to PWM1, then you must use the TCU channel 1. It's that simple.

> > I think we could find a way to use a devicetree property that doesn't 
> > trigger Rob. That would still be the easiest and cleanest solution. 
> > 
> > Maybe "ingenic,reserved-channels-mask", which would contain a mask of 
> > channels that can only be used by the timer driver. And what the 
> > timer driver does with these channels, would be specific to the 
> > implementation and would not appear in the bindings. I hope Rob can 
> > work with that. 
> > 
> > -Paul 
> > 

^ permalink raw reply	[flat|nested] 27+ messages in thread
* Re: [PATCH v5 04/21] dt-bindings: Add doc for the Ingenic TCU drivers
@ 2018-10-03 12:51 Paul Cercueil
  0 siblings, 0 replies; 27+ messages in thread
From: Paul Cercueil @ 2018-10-03 12:51 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: Thomas Gleixner, Guenter Roeck, linux-doc, Jonathan Corbet,
	linux-watchdog, robh, linux-mips, Stephen Boyd, Wim Van Sebroeck,
	Mark Rutland, Paul Burton, Michael Turquette, linux-kernel,
	linux-clk, devicetree, Ralf Baechle, Lee Jones, Thierry Reding,
	linux-pwm


Le 3 oct. 2018 2:47 PM, Daniel Lezcano <daniel.lezcano@linaro.org> a écrit :
>
> On 03/10/2018 12:32, Paul Cercueil wrote: 
> > 
> > Le 1 oct. 2018 10:48, Daniel Lezcano <daniel.lezcano@linaro.org> a 
> > écrit : 
> >> 
> >> On 31/07/2018 00:01, Paul Cercueil wrote: 
> >> 
> >> [ ... ] 
> >> 
> >>>>> +- ingenic,timer-channel: Specifies the TCU channel that 
> >>>>> should be used as +  system timer. If not provided, the TCU 
> >>>>> channel 0 is used for the system timer. + +- 
> >>>>> ingenic,clocksource-channel: Specifies the TCU channel that 
> >>>>> should be used +  as clocksource and sched_clock. It must be 
> >>>>> a different channel than the one +  used as system timer. If 
> >>>>> not provided, neither a clocksource nor a +  sched_clock is 
> >>>>> instantiated. 
> >>>> 
> >>>> clocksource and sched_clock are Linux specific and don't belong 
> >>>> in DT. You should define properties of the hardware or use 
> >>>> existing properties like interrupts or clocks to figure out 
> >>>> which channel to use. For example, if some channels don't have 
> >>>> an interrupt, then use them for clocksource and not a 
> >>>> clockevent. Or you could have timers that run in low-power 
> >>>> modes or not. If all the channels are identical, then it 
> >>>> shouldn't matter which ones the OS picks. 
> >> 
> >> It can't work in this case because the pmw and the timer driver are 
> >> not communicating and the first one can stole a channel to the last 
> >> one. 
> > 
> > In that particular case the timer driver will always request its 
> > channels first; with no timer set the system hangs before 
> > subsys_initcall, and the PWM driver is a subnode of the timer node, 
> > so is probed only after the timer probed. 
> > 
> >>> We already talked about that. All the TCU channels can be used 
> >>> for PWM. The problem is I cannot know from the driver's scope 
> >>> which channels will be free and which channels will be requested 
> >>> for PWM. You suggested that I parse the devicetree for clients, 
> >>> and I did that in the V3/V4 patchset. But it only works for 
> >>> clients requesting through devicetree, not from platform code or 
> >>> even sysfs. 
> >>> 
> >>> One thing I can try is to dynamically change the channels the 
> >>> system timer and clocksource are using when the current ones are 
> >>> requested for PWM. But that sounds hardcore... 
> >> 
> >> Yes, it is :/ 
> >> 
> >> Sorry for letting you wasting time and effort to write an overkill 
> >> code not suitable for upstream. 
> >> 
> >> A very gross thought, wouldn't be possible to "register" a channel 
> >> from the timer driver code in a shared data area (but well 
> >> self-encapsulated) and the pwm code will check such channel isn't 
> >> in use ? 
> > 
> > Probably, but it's the contrary I need to do. The timer driver code 
> > can use any channel, and probes first. The PWM driver code must use 
> > specific channels, and probes last. So either the timer driver knows 
> > what channels it can't use, thanks to a device property, or it adapts 
> > itself when a channel in use is requested for PWM, which is what I 
> > tried in v7. 
>
> When you say "must use specific channels", where is coming this 
> information ? 

If the backlight for the LCD is connected to the pin that corresponds to PWM1, then you must use the TCU channel 1. It's that simple.

> > I think we could find a way to use a devicetree property that doesn't 
> > trigger Rob. That would still be the easiest and cleanest solution. 
> > 
> > Maybe "ingenic,reserved-channels-mask", which would contain a mask of 
> > channels that can only be used by the timer driver. And what the 
> > timer driver does with these channels, would be specific to the 
> > implementation and would not appear in the bindings. I hope Rob can 
> > work with that. 
> > 
> > -Paul 
> > 

^ permalink raw reply	[flat|nested] 27+ messages in thread
* Re: [PATCH v5 04/21] dt-bindings: Add doc for the Ingenic TCU drivers
@ 2018-10-03 12:51 Paul Cercueil
  0 siblings, 0 replies; 27+ messages in thread
From: Paul Cercueil @ 2018-10-03 12:51 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: Thomas Gleixner, Guenter Roeck, linux-doc, Jonathan Corbet,
	linux-watchdog, robh, linux-mips, Stephen Boyd, Wim Van Sebroeck,
	Mark Rutland, Paul Burton, Michael Turquette, linux-kernel,
	linux-clk, devicetree, Ralf Baechle, Lee Jones, Thierry Reding,
	linux-pwm


Le 3 oct. 2018 2:47 PM, Daniel Lezcano <daniel.lezcano@linaro.org> a écrit :
>
> On 03/10/2018 12:32, Paul Cercueil wrote: 
> > 
> > Le 1 oct. 2018 10:48, Daniel Lezcano <daniel.lezcano@linaro.org> a 
> > écrit : 
> >> 
> >> On 31/07/2018 00:01, Paul Cercueil wrote: 
> >> 
> >> [ ... ] 
> >> 
> >>>>> +- ingenic,timer-channel: Specifies the TCU channel that 
> >>>>> should be used as +  system timer. If not provided, the TCU 
> >>>>> channel 0 is used for the system timer. + +- 
> >>>>> ingenic,clocksource-channel: Specifies the TCU channel that 
> >>>>> should be used +  as clocksource and sched_clock. It must be 
> >>>>> a different channel than the one +  used as system timer. If 
> >>>>> not provided, neither a clocksource nor a +  sched_clock is 
> >>>>> instantiated. 
> >>>> 
> >>>> clocksource and sched_clock are Linux specific and don't belong 
> >>>> in DT. You should define properties of the hardware or use 
> >>>> existing properties like interrupts or clocks to figure out 
> >>>> which channel to use. For example, if some channels don't have 
> >>>> an interrupt, then use them for clocksource and not a 
> >>>> clockevent. Or you could have timers that run in low-power 
> >>>> modes or not. If all the channels are identical, then it 
> >>>> shouldn't matter which ones the OS picks. 
> >> 
> >> It can't work in this case because the pmw and the timer driver are 
> >> not communicating and the first one can stole a channel to the last 
> >> one. 
> > 
> > In that particular case the timer driver will always request its 
> > channels first; with no timer set the system hangs before 
> > subsys_initcall, and the PWM driver is a subnode of the timer node, 
> > so is probed only after the timer probed. 
> > 
> >>> We already talked about that. All the TCU channels can be used 
> >>> for PWM. The problem is I cannot know from the driver's scope 
> >>> which channels will be free and which channels will be requested 
> >>> for PWM. You suggested that I parse the devicetree for clients, 
> >>> and I did that in the V3/V4 patchset. But it only works for 
> >>> clients requesting through devicetree, not from platform code or 
> >>> even sysfs. 
> >>> 
> >>> One thing I can try is to dynamically change the channels the 
> >>> system timer and clocksource are using when the current ones are 
> >>> requested for PWM. But that sounds hardcore... 
> >> 
> >> Yes, it is :/ 
> >> 
> >> Sorry for letting you wasting time and effort to write an overkill 
> >> code not suitable for upstream. 
> >> 
> >> A very gross thought, wouldn't be possible to "register" a channel 
> >> from the timer driver code in a shared data area (but well 
> >> self-encapsulated) and the pwm code will check such channel isn't 
> >> in use ? 
> > 
> > Probably, but it's the contrary I need to do. The timer driver code 
> > can use any channel, and probes first. The PWM driver code must use 
> > specific channels, and probes last. So either the timer driver knows 
> > what channels it can't use, thanks to a device property, or it adapts 
> > itself when a channel in use is requested for PWM, which is what I 
> > tried in v7. 
>
> When you say "must use specific channels", where is coming this 
> information ? 

If the backlight for the LCD is connected to the pin that corresponds to PWM1, then you must use the TCU channel 1. It's that simple.

> > I think we could find a way to use a devicetree property that doesn't 
> > trigger Rob. That would still be the easiest and cleanest solution. 
> > 
> > Maybe "ingenic,reserved-channels-mask", which would contain a mask of 
> > channels that can only be used by the timer driver. And what the 
> > timer driver does with these channels, would be specific to the 
> > implementation and would not appear in the bindings. I hope Rob can 
> > work with that. 
> > 
> > -Paul 
> > 

^ permalink raw reply	[flat|nested] 27+ messages in thread
[parent not found: <5bb49c78.1c69fb81.4b6a9.fb44SMTPIN_ADDED_MISSING@mx.google.com>]
* Re: [PATCH v5 04/21] dt-bindings: Add doc for the Ingenic TCU drivers
@ 2018-10-03 10:32 Paul Cercueil
  0 siblings, 0 replies; 27+ messages in thread
From: Paul Cercueil @ 2018-10-03 10:32 UTC (permalink / raw)
  To: Daniel Lezcano, robh
  Cc: Thomas Gleixner, Guenter Roeck, linux-doc, linux-watchdog,
	Jonathan Corbet, linux-mips, Stephen Boyd, Wim Van Sebroeck,
	Mark Rutland, Paul Burton, Michael Turquette, linux-clk,
	linux-kernel, devicetree, Ralf Baechle, Lee Jones,
	Thierry Reding, linux-pwm


Le 1 oct. 2018 10:48, Daniel Lezcano <daniel.lezcano@linaro.org> a écrit :
>
> On 31/07/2018 00:01, Paul Cercueil wrote: 
>
> [ ... ] 
>
> >>>  +- ingenic,timer-channel: Specifies the TCU channel that should be 
> >>> used as 
> >>>  +  system timer. If not provided, the TCU channel 0 is used for the 
> >>> system timer. 
> >>>  + 
> >>>  +- ingenic,clocksource-channel: Specifies the TCU channel that 
> >>> should be used 
> >>>  +  as clocksource and sched_clock. It must be a different channel 
> >>> than the one 
> >>>  +  used as system timer. If not provided, neither a clocksource nor a 
> >>>  +  sched_clock is instantiated. 
> >> 
> >> clocksource and sched_clock are Linux specific and don't belong in DT. 
> >> You should define properties of the hardware or use existing properties 
> >> like interrupts or clocks to figure out which channel to use. For 
> >> example, if some channels don't have an interrupt, then use them for 
> >> clocksource and not a clockevent. Or you could have timers that run in 
> >> low-power modes or not. If all the channels are identical, then it 
> >> shouldn't matter which ones the OS picks. 
>
> It can't work in this case because the pmw and the timer driver are not 
> communicating and the first one can stole a channel to the last one. 

In that particular case the timer driver will always request its channels first; with no timer set the system hangs before subsys_initcall, and the PWM driver is a subnode of the timer node, so is probed only after the timer probed.

> > We already talked about that. All the TCU channels can be used for PWM. 
> > The problem is I cannot know from the driver's scope which channels will 
> > be free and which channels will be requested for PWM. You suggested that I 
> > parse the devicetree for clients, and I did that in the V3/V4 patchset. But 
> > it only works for clients requesting through devicetree, not from platform 
> > code or even sysfs. 
> > 
> > One thing I can try is to dynamically change the channels the system timer 
> > and clocksource are using when the current ones are requested for PWM. But 
> > that sounds hardcore... 
>
> Yes, it is :/ 
>
> Sorry for letting you wasting time and effort to write an overkill code 
> not suitable for upstream. 
>
> A very gross thought, wouldn't be possible to "register" a channel from 
> the timer driver code in a shared data area (but well self-encapsulated) 
> and the pwm code will check such channel isn't in use ? 

Probably, but it's the contrary I need to do. The timer driver code can use any channel, and probes first. The PWM driver code must use specific channels, and probes last. So either the timer driver knows what channels it can't use, thanks to a device property, or it adapts itself when a channel in use is requested for PWM, which is what I tried in v7.

I think we could find a way to use a devicetree property that doesn't trigger Rob. That would still be the easiest and cleanest solution. 

Maybe "ingenic,reserved-channels-mask", which would contain a mask of channels that can only be used by the timer driver. And what the timer driver does with these channels, would be specific to the implementation and would not appear in the bindings. I hope Rob can work with that.

-Paul

^ permalink raw reply	[flat|nested] 27+ messages in thread
* Re: [PATCH v5 04/21] dt-bindings: Add doc for the Ingenic TCU drivers
@ 2018-10-03 10:32 Paul Cercueil
  0 siblings, 0 replies; 27+ messages in thread
From: Paul Cercueil @ 2018-10-03 10:32 UTC (permalink / raw)
  To: Daniel Lezcano, robh
  Cc: Thomas Gleixner, Guenter Roeck, linux-doc, linux-watchdog,
	Jonathan Corbet, linux-mips, Stephen Boyd, Wim Van Sebroeck,
	Mark Rutland, Paul Burton, Michael Turquette, linux-clk,
	linux-kernel, devicetree, Ralf Baechle, Lee Jones,
	Thierry Reding, linux-pwm


Le 1 oct. 2018 10:48, Daniel Lezcano <daniel.lezcano@linaro.org> a écrit :
>
> On 31/07/2018 00:01, Paul Cercueil wrote: 
>
> [ ... ] 
>
> >>>  +- ingenic,timer-channel: Specifies the TCU channel that should be 
> >>> used as 
> >>>  +  system timer. If not provided, the TCU channel 0 is used for the 
> >>> system timer. 
> >>>  + 
> >>>  +- ingenic,clocksource-channel: Specifies the TCU channel that 
> >>> should be used 
> >>>  +  as clocksource and sched_clock. It must be a different channel 
> >>> than the one 
> >>>  +  used as system timer. If not provided, neither a clocksource nor a 
> >>>  +  sched_clock is instantiated. 
> >> 
> >> clocksource and sched_clock are Linux specific and don't belong in DT. 
> >> You should define properties of the hardware or use existing properties 
> >> like interrupts or clocks to figure out which channel to use. For 
> >> example, if some channels don't have an interrupt, then use them for 
> >> clocksource and not a clockevent. Or you could have timers that run in 
> >> low-power modes or not. If all the channels are identical, then it 
> >> shouldn't matter which ones the OS picks. 
>
> It can't work in this case because the pmw and the timer driver are not 
> communicating and the first one can stole a channel to the last one. 

In that particular case the timer driver will always request its channels first; with no timer set the system hangs before subsys_initcall, and the PWM driver is a subnode of the timer node, so is probed only after the timer probed.

> > We already talked about that. All the TCU channels can be used for PWM. 
> > The problem is I cannot know from the driver's scope which channels will 
> > be free and which channels will be requested for PWM. You suggested that I 
> > parse the devicetree for clients, and I did that in the V3/V4 patchset. But 
> > it only works for clients requesting through devicetree, not from platform 
> > code or even sysfs. 
> > 
> > One thing I can try is to dynamically change the channels the system timer 
> > and clocksource are using when the current ones are requested for PWM. But 
> > that sounds hardcore... 
>
> Yes, it is :/ 
>
> Sorry for letting you wasting time and effort to write an overkill code 
> not suitable for upstream. 
>
> A very gross thought, wouldn't be possible to "register" a channel from 
> the timer driver code in a shared data area (but well self-encapsulated) 
> and the pwm code will check such channel isn't in use ? 

Probably, but it's the contrary I need to do. The timer driver code can use any channel, and probes first. The PWM driver code must use specific channels, and probes last. So either the timer driver knows what channels it can't use, thanks to a device property, or it adapts itself when a channel in use is requested for PWM, which is what I tried in v7.

I think we could find a way to use a devicetree property that doesn't trigger Rob. That would still be the easiest and cleanest solution. 

Maybe "ingenic,reserved-channels-mask", which would contain a mask of channels that can only be used by the timer driver. And what the timer driver does with these channels, would be specific to the implementation and would not appear in the bindings. I hope Rob can work with that.

-Paul

^ permalink raw reply	[flat|nested] 27+ messages in thread
* [PATCH v5 00/21] Ingenic JZ47xx TCU patchset v5
@ 2018-07-24 23:19 Paul Cercueil
  2018-07-24 23:19   ` Paul Cercueil
  0 siblings, 1 reply; 27+ messages in thread
From: Paul Cercueil @ 2018-07-24 23:19 UTC (permalink / raw)
  To: Thierry Reding, Rob Herring, Mark Rutland, Daniel Lezcano,
	Thomas Gleixner, Wim Van Sebroeck, Guenter Roeck, Ralf Baechle,
	Paul Burton, Jonathan Corbet, Michael Turquette, Stephen Boyd,
	Lee Jones
  Cc: Paul Cercueil, linux-pwm, devicetree, linux-kernel,
	linux-watchdog, linux-mips, linux-doc, linux-clk

Hi,

This is the V5 of my patchset that adds support to the Timer/Counter
Unit (TCU) present on Ingenic JZ47xx SoCs.

Way too much has changed since V4, we went from 8 patches in V4 up to
21 patches in V5.
I did not know if I had to submit it as V5 or start a new series.
In doubt, I sent a V5.

Very succint description of the changes:

- The interrupt, clocks, clocksource drivers have been merged into one;
  ingenic-timer now inits the TCU clocks, handles the interrupts,
  provides a system timer and optionally also a clocksource and
  sched_clock. The TCU channel #0 will be used as system timer, unless
  another channel is specified from devicetree.

- The simple-mfd and syscon are gone. The ingenic-timer driver will
  probe the drivers registered as children in the devicetree.

- The watchdog driver was updated to use the WDT clock and regmap
  provided by ingenic-timer. This breaks the devicetree ABI, but as
  explained in the corresponding commit message, right now all Ingenic
  boards compile the devicetree into the kernel anyway - so it's better
  to update it now before it's too late.

- The PWM driver was updated to use the TCU timer clocks as well as the
  regmap provided by ingenic-timer. Unused devicetree compatible strings
  were removed (the driver was never probed from devicetree), and
  support for the JZ4725B has been added.

- A new ingenic-ost driver was added, which provides a clocksource and
  a sched_clock that are more accurate than the ones provided by
  ingenic-timer (32 or 64-bit vs. 16-bit). It is not available on every
  SoC.

- Mostly tested on the JZ4725B and JZ4770. It would be great if somebody
  could test on the JZ4780 and JZ4740.

Thanks,
-Paul


^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2018-10-10 10:42 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-03 10:32 [PATCH v5 04/21] dt-bindings: Add doc for the Ingenic TCU drivers Paul Cercueil
2018-10-06  9:20 ` Alexandre Belloni
  -- strict thread matches above, loose matches on Subject: below --
2018-10-10 10:38 Paul Cercueil
2018-10-10 10:38 Paul Cercueil
2018-10-10 10:38 Paul Cercueil
     [not found] <5bb4c6ad.1c69fb81.42bb.93ecSMTPIN_ADDED_MISSING@mx.google.com>
2018-10-09  6:36 ` Lee Jones
2018-10-07 19:14 Paul Cercueil
2018-10-07 19:14 Paul Cercueil
2018-10-07 19:14 Paul Cercueil
2018-10-03 13:39 Paul Cercueil
2018-10-03 13:39 Paul Cercueil
2018-10-03 13:39 Paul Cercueil
     [not found] <5bb4bb5d.1c69fb81.ed9a6.adc6SMTPIN_ADDED_MISSING@mx.google.com>
2018-10-03 13:02 ` Daniel Lezcano
2018-10-03 12:51 Paul Cercueil
2018-10-03 12:51 Paul Cercueil
2018-10-03 12:51 Paul Cercueil
     [not found] <5bb49c78.1c69fb81.4b6a9.fb44SMTPIN_ADDED_MISSING@mx.google.com>
2018-10-03 12:47 ` Daniel Lezcano
2018-10-03 10:32 Paul Cercueil
2018-10-03 10:32 Paul Cercueil
2018-07-24 23:19 [PATCH v5 00/21] Ingenic JZ47xx TCU patchset v5 Paul Cercueil
2018-07-24 23:19 ` [PATCH v5 04/21] dt-bindings: Add doc for the Ingenic TCU drivers Paul Cercueil
2018-07-24 23:19   ` Paul Cercueil
2018-07-25 15:21   ` Rob Herring
2018-07-25 15:21     ` Rob Herring
2018-07-30 22:01     ` Paul Cercueil
2018-07-30 22:01       ` Paul Cercueil
2018-07-30 22:01       ` Paul Cercueil
2018-10-01  8:48       ` Daniel Lezcano

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.