devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RESEND 0/3] pwm support for Broadcom iProc SoC's
@ 2016-03-29 14:22 Yendapally Reddy Dhananjaya Reddy
  2016-03-29 14:22 ` [PATCH RESEND 1/3] Documentation: dt: Add Broadcom iproc pwm controller binding Yendapally Reddy Dhananjaya Reddy
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Yendapally Reddy Dhananjaya Reddy @ 2016-03-29 14:22 UTC (permalink / raw)
  To: Thierry Reding, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala, Russell King, Ray Jui, Scott Branden,
	Jon Mason
  Cc: linux-pwm, devicetree, linux-kernel, linux-arm-kernel,
	bcm-kernel-feedback-list, Yendapally Reddy Dhananjaya Reddy

This patchset contains the pwm support for the Broadcom's iProc SoC's.

The first patch provides the documentation details and the
second patch contains the controller support details. The third patch
contains the enable method for Northstar Plus SoC.

This patch series has been tested on NSP bcm958625HR board with oscilloscope.
The pwm is not enabled for this board as the pins are open and not used.

This patch series is based on v4.6.0-rc1 and is available from github
repo: https://github.com/Broadcom/cygnus-linux.git
branch: iproc-pwm-v1

This patch series was originally sent on 03/01/16.
See https://lkml.org/lkml/2016/3/1/487

Yendapally Reddy Dhananjaya Reddy (3):
  Documentation: dt: Add Broadcom iproc pwm controller binding
  pwm: kona: Add support for Broadcom iproc pwm controller
  ARM: dts: NSP: Add PWM Support to DT

 .../devicetree/bindings/pwm/brcm,kona-pwm.txt      |   2 +-
 arch/arm/boot/dts/bcm-nsp.dtsi                     |   8 +
 drivers/pwm/Kconfig                                |   6 +-
 drivers/pwm/pwm-bcm-kona.c                         | 183 ++++++++++++++++++---
 4 files changed, 172 insertions(+), 27 deletions(-)

-- 
2.1.0

^ permalink raw reply	[flat|nested] 10+ messages in thread
* Re: [PATCH RESEND 2/3] pwm: kona: Add support for Broadcom iproc pwm controller
@ 2016-05-10 15:11 Yendapally Reddy Dhananjaya Reddy
  0 siblings, 0 replies; 10+ messages in thread
From: Yendapally Reddy Dhananjaya Reddy @ 2016-05-10 15:11 UTC (permalink / raw)
  To: Thierry Reding
  Cc: Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
	Russell King, Ray Jui, Scott Branden, Jon Mason, linux-pwm,
	devicetree, linux-kernel, linux-arm-kernel, BCM Kernel Feedback

Hi Thierry,

On Tue, May 10, 2016 at 8:10 PM, Thierry Reding
<thierry.reding@gmail.com> wrote:
> On Tue, Mar 29, 2016 at 10:22:29AM -0400, Yendapally Reddy Dhananjaya Reddy wrote:
>> Update the kona driver to support Broadcom iproc pwm controller
>>
>> Signed-off-by: Yendapally Reddy Dhananjaya Reddy <yendapally.reddy@broadcom.com>
>> ---
>>  drivers/pwm/Kconfig        |   6 +-
>>  drivers/pwm/pwm-bcm-kona.c | 183 +++++++++++++++++++++++++++++++++++++++------
>>  2 files changed, 163 insertions(+), 26 deletions(-)
>>
>> diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig
>> index c182efc..e45ea33 100644
>> --- a/drivers/pwm/Kconfig
>> +++ b/drivers/pwm/Kconfig
>> @@ -76,9 +76,11 @@ config PWM_ATMEL_TCB
>>
>>  config PWM_BCM_KONA
>>       tristate "Kona PWM support"
>> -     depends on ARCH_BCM_MOBILE
>> +     depends on ARCH_BCM_MOBILE || ARCH_BCM_IPROC
>> +     default ARCH_BCM_IPROC
>
> Why the default? Typically you'd enable this in one or more of the
> default configurations. default ARCH_* is really only useful if the
> driver is essential. PWM doesn't usually fall into this category.
>
>> diff --git a/drivers/pwm/pwm-bcm-kona.c b/drivers/pwm/pwm-bcm-kona.c
>> index c634183..ef152e3a 100644
>> --- a/drivers/pwm/pwm-bcm-kona.c
>> +++ b/drivers/pwm/pwm-bcm-kona.c
>> @@ -19,6 +19,7 @@
>>  #include <linux/math64.h>
>>  #include <linux/module.h>
>>  #include <linux/of.h>
>> +#include <linux/of_device.h>
>>  #include <linux/platform_device.h>
>>  #include <linux/pwm.h>
>>  #include <linux/slab.h>
>> @@ -47,30 +48,90 @@
>>
>>  #define PWM_CONTROL_OFFSET                   (0x00000000)
>>  #define PWM_CONTROL_SMOOTH_SHIFT(chan)               (24 + (chan))
>> -#define PWM_CONTROL_TYPE_SHIFT(chan)         (16 + (chan))
>> +#define PWM_CONTROL_TYPE_SHIFT(shift, chan)  (shift + chan)
>
> You need to put the parameters into parentheses to avoid expansion from
> potentially messing up the expression.
>
>>  #define PWM_CONTROL_POLARITY_SHIFT(chan)     (8 + (chan))
>>  #define PWM_CONTROL_TRIGGER_SHIFT(chan)              (chan)
>>
>>  #define PRESCALE_OFFSET                              (0x00000004)
>> -#define PRESCALE_SHIFT(chan)                 ((chan) << 2)
>> -#define PRESCALE_MASK(chan)                  (0x7 << PRESCALE_SHIFT(chan))
>> +#define PRESCALE_SHIFT                               (0x00000004)
>> +#define PRESCALE_MASK                                (0x00000007)
>
> Hmm... this looks odd. Why are you dropping the chan parameter here?
>
>>  #define PRESCALE_MIN                         (0x00000000)
>>  #define PRESCALE_MAX                         (0x00000007)
>>
>> -#define PERIOD_COUNT_OFFSET(chan)            (0x00000008 + ((chan) << 3))
>> +#define PERIOD_COUNT_OFFSET(offset, chan)    (offset + (chan << 3))
>
> Need parentheses here as well.
>
>>  #define PERIOD_COUNT_MIN                     (0x00000002)
>>  #define PERIOD_COUNT_MAX                     (0x00ffffff)
>> +#define KONA_PERIOD_COUNT_OFFSET             (0x00000008)
>>
>> -#define DUTY_CYCLE_HIGH_OFFSET(chan)         (0x0000000c + ((chan) << 3))
>> +#define DUTY_CYCLE_HIGH_OFFSET(offset, chan) (offset + (chan << 3))
>>  #define DUTY_CYCLE_HIGH_MIN                  (0x00000000)
>>  #define DUTY_CYCLE_HIGH_MAX                  (0x00ffffff)
>> +#define KONA_DUTY_CYCLE_HIGH_OFFSET          (0x0000000c)
>> +
>> +#define PWM_CHANNEL_CNT                              (0x00000006)
>> +#define SIGNAL_PUSH_PULL                     (0x00000001)
>> +#define PWMOUT_TYPE_SHIFT                    (0x00000010)
>> +
>> +#define IPROC_PRESCALE_OFFSET                        (0x00000024)
>> +#define IPROC_PRESCALE_SHIFT                 (0x00000006)
>> +#define IPROC_PRESCALE_MAX                   (0x0000003f)
>> +
>> +#define IPROC_PERIOD_COUNT_OFFSET            (0x00000004)
>> +#define IPROC_PERIOD_COUNT_MIN                       (0x00000002)
>> +#define IPROC_PERIOD_COUNT_MAX                       (0x0000ffff)
>> +
>> +#define IPROC_DUTY_CYCLE_HIGH_OFFSET         (0x00000008)
>> +#define IPROC_DUTY_CYCLE_HIGH_MIN            (0x00000000)
>> +#define IPROC_DUTY_CYCLE_HIGH_MAX            (0x0000ffff)
>> +
>> +#define IPROC_PWM_CHANNEL_CNT                        (0x00000004)
>> +#define IPROC_SIGNAL_PUSH_PULL                       (0x00000000)
>> +#define IPROC_PWMOUT_TYPE_SHIFT                      (0x0000000f)
>> +
>> +/*
>> + * pwm controller reg structure
>> + *
>> + * @prescale_offset: prescale register offset
>> + * @period_offset: period register offset
>> + * @duty_offset: duty register offset
>> + * @no_of_channels: number of channels
>> + * @out_type_shift: out type shift in the register
>> + * @signal_type: push-pull or open drain
>> + * @prescale_max: prescale max
>> + * @prescale_shift: prescale shift in register
>> + * @prescale_ch_ascending: prescale ch order in prescale register
>> + * @duty_cycle_max: value of max duty cycle
>> + * @duty_cycle_min: value of min duty cycle
>> + * @period_count_max: max period count val
>> + * @period_count_min: min period count val
>> + * @smooth_output_support: pwm smooth output support
>> + */
>> +struct kona_pwmc_reg {
>> +     u32 prescale_offset;
>> +     u32 period_offset;
>> +     u32 duty_offset;
>> +     u32 no_of_channels;
>> +     u32 out_type_shift;
>> +     u32 signal_type;
>> +     u32 prescale_max;
>> +     u32 prescale_shift;
>> +     bool prescale_ch_ascending;
>> +     u32 duty_cycle_max;
>> +     u32 duty_cycle_min;
>> +     u32 period_count_max;
>> +     u32 period_count_min;
>> +     bool smooth_output_support;
>> +};
>
> This is rather tedious. It looks to me like this isn't very similar to
> the existing driver. Register offsets move around, bitfield positions
> change, feature set is different. Might be better off turning this into
> a separate driver after all.
>
>> +static const struct kona_pwmc_reg kona_pwmc_reg_data = {
>> +     .prescale_offset = PRESCALE_OFFSET,
>> +     .period_offset = KONA_PERIOD_COUNT_OFFSET,
>> +     .duty_offset = KONA_DUTY_CYCLE_HIGH_OFFSET,
>> +     .no_of_channels = PWM_CHANNEL_CNT,
>> +     .out_type_shift = PWMOUT_TYPE_SHIFT,
>> +     .signal_type = SIGNAL_PUSH_PULL,
>> +     .prescale_max = PRESCALE_MAX,
>> +     .prescale_shift = PRESCALE_SHIFT,
>> +     .prescale_ch_ascending = false,
>> +     .duty_cycle_max = DUTY_CYCLE_HIGH_MAX,
>> +     .duty_cycle_min = DUTY_CYCLE_HIGH_MIN,
>> +     .period_count_max = PERIOD_COUNT_MAX,
>> +     .period_count_min = PERIOD_COUNT_MIN,
>> +     .smooth_output_support = true,
>> +};
>> +
>> +static const struct kona_pwmc_reg iproc_pwmc_reg_data = {
>> +     .prescale_offset = IPROC_PRESCALE_OFFSET,
>> +     .period_offset = IPROC_PERIOD_COUNT_OFFSET,
>> +     .duty_offset = IPROC_DUTY_CYCLE_HIGH_OFFSET,
>> +     .no_of_channels = IPROC_PWM_CHANNEL_CNT,
>> +     .out_type_shift = IPROC_PWMOUT_TYPE_SHIFT,
>> +     .signal_type = IPROC_SIGNAL_PUSH_PULL,
>> +     .prescale_max = IPROC_PRESCALE_MAX,
>> +     .prescale_shift = IPROC_PRESCALE_SHIFT,
>> +     .prescale_ch_ascending = true,
>> +     .duty_cycle_max = IPROC_DUTY_CYCLE_HIGH_MAX,
>> +     .duty_cycle_min = IPROC_DUTY_CYCLE_HIGH_MIN,
>> +     .period_count_max = IPROC_PERIOD_COUNT_MAX,
>> +     .period_count_min = IPROC_PERIOD_COUNT_MIN,
>> +     .smooth_output_support = false,
>> +};
>
> This looks like you could possible support a lot more hardware with this
> driver because it's now almost completely parameterized.
>
> I don't see much sense in keeping this in the same driver and I think
> it'd be better to write a new one from scratch, even if that means
> slight duplication.
>

These two variants have the same block with different reg offsets and
bit fields. I thought of having a same driver, will address the fixes for
both if any. I will generate a new one as suggested and submit a
v2 version.

> Or you'll have to make a very compelling argument as to why this is the
> better option.
>
> Thierry

Thanks
Dhananjay

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

end of thread, other threads:[~2016-07-04 13:37 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-29 14:22 [PATCH RESEND 0/3] pwm support for Broadcom iProc SoC's Yendapally Reddy Dhananjaya Reddy
2016-03-29 14:22 ` [PATCH RESEND 1/3] Documentation: dt: Add Broadcom iproc pwm controller binding Yendapally Reddy Dhananjaya Reddy
2016-03-29 14:22 ` [PATCH RESEND 2/3] pwm: kona: Add support for Broadcom iproc pwm controller Yendapally Reddy Dhananjaya Reddy
2016-05-10 14:40   ` Thierry Reding
2016-06-23 20:32     ` Boris Brezillon
2016-06-28 12:52       ` Thierry Reding
2016-07-04 13:37         ` Boris Brezillon
2016-03-29 14:22 ` [PATCH RESEND 3/3] ARM: dts: NSP: Add PWM Support to DT Yendapally Reddy Dhananjaya Reddy
2016-05-10 13:55 ` [PATCH RESEND 0/3] pwm support for Broadcom iProc SoC's Yendapally Reddy Dhananjaya Reddy
2016-05-10 15:11 [PATCH RESEND 2/3] pwm: kona: Add support for Broadcom iproc pwm controller Yendapally Reddy Dhananjaya Reddy

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).