Re: [PATCH v2] pwm: bcm2835: Support apply function for atomic configuration

2020-12-08 Thread Uwe Kleine-König
Hi Lino, On Tue, Dec 08, 2020 at 01:00:02AM +0100, Lino Sanfilippo wrote: > On 07.12.20 at 14:52, Uwe Kleine-König wrote: > > Given that the bcm2835 driver is quite trivial I would be happy to > > create a series that "fixes" the driver to round down and provide a > > prototype for pwm_round_neare

Re: [PATCH v2] pwm: bcm2835: Support apply function for atomic configuration

2020-12-07 Thread Lino Sanfilippo
Hi, On 07.12.20 at 14:52, Uwe Kleine-König wrote: > > Given that the bcm2835 driver is quite trivial I would be happy to > create a series that "fixes" the driver to round down and provide a > prototype for pwm_round_nearest for you to test on pwm-ir-tx. A willing > tester and a real use-case wer

Re: [PATCH v2] pwm: bcm2835: Support apply function for atomic configuration

2020-12-07 Thread Uwe Kleine-König
Hello Thierry, On Mon, Dec 07, 2020 at 04:29:36PM +0100, Thierry Reding wrote: > On Mon, Dec 07, 2020 at 02:52:09PM +0100, Uwe Kleine-König wrote: > > I asked in the hardware department of the company I work for and they > > had another usecase: Motors where for example a 1 ms pulse means "move >

Re: [PATCH v2] pwm: bcm2835: Support apply function for atomic configuration

2020-12-07 Thread Sean Young
Hi Uwe, On Mon, Dec 07, 2020 at 02:52:09PM +0100, Uwe Kleine-König wrote: > On Mon, Dec 07, 2020 at 09:43:20AM +, Sean Young wrote: > > On Mon, Dec 07, 2020 at 09:16:28AM +0100, Uwe Kleine-König wrote: > > > On Sun, Dec 06, 2020 at 02:19:41PM +, Sean Young wrote: > > > > On Sat, Dec 05, 20

Re: [PATCH v2] pwm: bcm2835: Support apply function for atomic configuration

2020-12-07 Thread Thierry Reding
On Mon, Dec 07, 2020 at 02:52:09PM +0100, Uwe Kleine-König wrote: > Hello Sean, > > On Mon, Dec 07, 2020 at 09:43:20AM +, Sean Young wrote: > > Thank you for taking the time to explain your thinking. > > I'm happy you have an open ear for it. With this I really enjoy spending > the time to fi

Re: [PATCH v2] pwm: bcm2835: Support apply function for atomic configuration

2020-12-07 Thread Uwe Kleine-König
Hello Sean, On Mon, Dec 07, 2020 at 09:43:20AM +, Sean Young wrote: > Thank you for taking the time to explain your thinking. I'm happy you have an open ear for it. With this I really enjoy spending the time to find the right arguments and examples. > On Mon, Dec 07, 2020 at 09:16:28AM +0100

Re: [PATCH v2] pwm: bcm2835: Support apply function for atomic configuration

2020-12-07 Thread Sean Young
Hello Uwe, Thank you for taking the time to explain your thinking. On Mon, Dec 07, 2020 at 09:16:28AM +0100, Uwe Kleine-König wrote: > On Sun, Dec 06, 2020 at 02:19:41PM +, Sean Young wrote: > > On Sat, Dec 05, 2020 at 08:25:10PM +0100, Uwe Kleine-König wrote: > > > On Sat, Dec 05, 2020 at

Re: [PATCH v2] pwm: bcm2835: Support apply function for atomic configuration

2020-12-07 Thread Uwe Kleine-König
On Sun, Dec 06, 2020 at 02:19:41PM +, Sean Young wrote: > Hello Uwe, > > On Sat, Dec 05, 2020 at 08:25:10PM +0100, Uwe Kleine-König wrote: > > On Sat, Dec 05, 2020 at 05:34:44PM +, Sean Young wrote: > > > What real life uses-cases are there for round down? If you want to round > > > down,

Re: [PATCH v2] pwm: bcm2835: Support apply function for atomic configuration

2020-12-06 Thread Sean Young
Hello Uwe, On Sat, Dec 05, 2020 at 08:25:10PM +0100, Uwe Kleine-König wrote: > On Sat, Dec 05, 2020 at 05:34:44PM +, Sean Young wrote: > > What real life uses-cases are there for round down? If you want to round > > down, is there any need for round up? > > The scenario I have in mind is for

Re: [PATCH v2] pwm: bcm2835: Support apply function for atomic configuration

2020-12-05 Thread Uwe Kleine-König
Hello Sean, On Sat, Dec 05, 2020 at 05:34:44PM +, Sean Young wrote: > On Sat, Dec 05, 2020 at 12:28:34AM +0100, Uwe Kleine-König wrote: > > On Fri, Dec 04, 2020 at 11:38:46AM +, Sean Young wrote: > > > On Fri, Dec 04, 2020 at 12:13:26PM +0100, Uwe Kleine-König wrote: > > > > On Fri, Dec 04

Re: [PATCH v2] pwm: bcm2835: Support apply function for atomic configuration

2020-12-05 Thread Sean Young
Hello Uwe, On Sat, Dec 05, 2020 at 12:28:34AM +0100, Uwe Kleine-König wrote: > Hello Sean, > > On Fri, Dec 04, 2020 at 11:38:46AM +, Sean Young wrote: > > On Fri, Dec 04, 2020 at 12:13:26PM +0100, Uwe Kleine-König wrote: > > > On Fri, Dec 04, 2020 at 08:44:17AM +, Sean Young wrote: > > >

Re: [PATCH v2] pwm: bcm2835: Support apply function for atomic configuration

2020-12-04 Thread Uwe Kleine-König
Hello Sean, On Fri, Dec 04, 2020 at 11:38:46AM +, Sean Young wrote: > On Fri, Dec 04, 2020 at 12:13:26PM +0100, Uwe Kleine-König wrote: > > On Fri, Dec 04, 2020 at 08:44:17AM +, Sean Young wrote: > > > On Fri, Dec 04, 2020 at 12:42:15AM +0100, Lino Sanfilippo wrote: > > > > > You're storin

Re: [PATCH v2] pwm: bcm2835: Support apply function for atomic configuration

2020-12-04 Thread Lino Sanfilippo
Hi, On 04.12.20 at 12:21, Uwe Kleine-König wrote: > > I'd make value an unsigned long long and check for > 0x instead > of repeating the (expensive) division. (Hmm, maybe the compiler is smart > enough to not actually repeat it, but still.) I also prefer unsigned long long over u64 sinc

Re: [PATCH v2] pwm: bcm2835: Support apply function for atomic configuration

2020-12-04 Thread Lino Sanfilippo
Hi Sean, On 04.12.20 at 09:44, Sean Young wrote: >> What about an extra check then to make sure that the period has not been >> truncated, >> e.g: >> >> value = DIV_ROUND_CLOSEST_ULL(state->period, scaler); >> >> /* dont accept a period that is too small or has been truncated */ >>

Re: [PATCH v2] pwm: bcm2835: Support apply function for atomic configuration

2020-12-04 Thread Sean Young
Hi Uwe, On Fri, Dec 04, 2020 at 10:55:25PM +0100, Uwe Kleine-König wrote: > On Fri, Dec 04, 2020 at 11:40:36AM +, Sean Young wrote: > > On Fri, Dec 04, 2020 at 12:21:15PM +0100, Uwe Kleine-König wrote: > > > On Fri, Dec 04, 2020 at 12:42:15AM +0100, Lino Sanfilippo wrote: > > > > On 29.11.20 a

Re: [PATCH v2] pwm: bcm2835: Support apply function for atomic configuration

2020-12-04 Thread Uwe Kleine-König
Hello Sean, On Fri, Dec 04, 2020 at 11:40:36AM +, Sean Young wrote: > On Fri, Dec 04, 2020 at 12:21:15PM +0100, Uwe Kleine-König wrote: > > On Fri, Dec 04, 2020 at 12:42:15AM +0100, Lino Sanfilippo wrote: > > > On 29.11.20 at 19:10, Uwe Kleine-König wrote: > > > > You're storing an unsigned lo

Re: [PATCH v2] pwm: bcm2835: Support apply function for atomic configuration

2020-12-04 Thread Sean Young
On Fri, Dec 04, 2020 at 12:21:15PM +0100, Uwe Kleine-König wrote: > Hello Lino, > > On Fri, Dec 04, 2020 at 12:42:15AM +0100, Lino Sanfilippo wrote: > > On 29.11.20 at 19:10, Uwe Kleine-König wrote: > > > You're storing an unsigned long long (i.e. 64 bits) in an u32. If > > > you are sure that thi

Re: [PATCH v2] pwm: bcm2835: Support apply function for atomic configuration

2020-12-04 Thread Sean Young
Hi, On Fri, Dec 04, 2020 at 12:13:26PM +0100, Uwe Kleine-König wrote: > On Fri, Dec 04, 2020 at 08:44:17AM +, Sean Young wrote: > > On Fri, Dec 04, 2020 at 12:42:15AM +0100, Lino Sanfilippo wrote: > > > > You're storing an unsigned long long (i.e. 64 bits) in an u32. If > > > > you are sure th

Re: [PATCH v2] pwm: bcm2835: Support apply function for atomic configuration

2020-12-04 Thread Uwe Kleine-König
Hello Lino, On Fri, Dec 04, 2020 at 12:42:15AM +0100, Lino Sanfilippo wrote: > On 29.11.20 at 19:10, Uwe Kleine-König wrote: > > You're storing an unsigned long long (i.e. 64 bits) in an u32. If > > you are sure that this won't discard relevant bits, please explain > > this in a comment for the cu

Re: [PATCH v2] pwm: bcm2835: Support apply function for atomic configuration

2020-12-04 Thread Uwe Kleine-König
Hello, On Fri, Dec 04, 2020 at 08:44:17AM +, Sean Young wrote: > On Fri, Dec 04, 2020 at 12:42:15AM +0100, Lino Sanfilippo wrote: > > > You're storing an unsigned long long (i.e. 64 bits) in an u32. If > > > you are sure that this won't discard relevant bits, please explain > > > this in a com

Re: [PATCH v2] pwm: bcm2835: Support apply function for atomic configuration

2020-12-04 Thread Sean Young
On Fri, Dec 04, 2020 at 08:44:17AM +, Sean Young wrote: > On Fri, Dec 04, 2020 at 12:42:15AM +0100, Lino Sanfilippo wrote: > > According to commit 11fc4edc4 rounding to the closest integer has been > > introduced > > to improve precision in case that the pwm controller is used by the > > pwm-

Re: [PATCH v2] pwm: bcm2835: Support apply function for atomic configuration

2020-12-04 Thread Sean Young
Hi, On Fri, Dec 04, 2020 at 12:42:15AM +0100, Lino Sanfilippo wrote: > > You're storing an unsigned long long (i.e. 64 bits) in an u32. If > > you are sure that this won't discard relevant bits, please explain > > this in a comment for the cursory reader. > > What about an extra check then to mak

Re: [PATCH v2] pwm: bcm2835: Support apply function for atomic configuration

2020-12-03 Thread Lino Sanfilippo
Hi Uwe, First off, thanks for the review! On 29.11.20 at 19:10, Uwe Kleine-König wrote: > > Changelog between review rounds go to below the tripple-dash below. > Right, will do so in the next patch version. > > You're storing an unsigned long long (i.e. 64 bits) in an u32. If > you are sure

Re: [PATCH v2] pwm: bcm2835: Support apply function for atomic configuration

2020-11-29 Thread Uwe Kleine-König
On Sat, Nov 28, 2020 at 01:02:06PM +0100, Lino Sanfilippo wrote: > Use the newer apply function of pwm_ops instead of config, enable, disable > and set_polarity. > > This guarantees atomic changes of the pwm controller configuration. It also > reduces the size of the driver. > > This has been tes

[PATCH v2] pwm: bcm2835: Support apply function for atomic configuration

2020-11-28 Thread Lino Sanfilippo
Use the newer apply function of pwm_ops instead of config, enable, disable and set_polarity. This guarantees atomic changes of the pwm controller configuration. It also reduces the size of the driver. This has been tested on a Raspberry PI 4. v2: Fixed compiler error Signed-off-by: Lino Sanfili