* [PATCH v2 1/3] pwm: hibvt: Use individual struct per of-data. @ 2019-02-13 15:05 Mathieu Othacehe 2019-02-13 15:05 ` [PATCH v2 2/3] dt-bindings: pwm: hibvt: Add hi3559v100 support Mathieu Othacehe 2019-02-13 15:05 ` [PATCH v2 3/3] " Mathieu Othacehe 0 siblings, 2 replies; 6+ messages in thread From: Mathieu Othacehe @ 2019-02-13 15:05 UTC (permalink / raw) To: thierry.reding, robh+dt, mark.rutland Cc: linux-pwm, devicetree, linux-kernel, Mathieu Othacehe Split pwm-soc array in one struct per soc and point to the corresponding on in of-data. Signed-off-by: Mathieu Othacehe <m.othacehe@gmail.com> --- drivers/pwm/pwm-hibvt.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/pwm/pwm-hibvt.c b/drivers/pwm/pwm-hibvt.c index 27c107e78d59..ffc803818c3c 100644 --- a/drivers/pwm/pwm-hibvt.c +++ b/drivers/pwm/pwm-hibvt.c @@ -49,15 +49,19 @@ struct hibvt_pwm_chip { struct clk *clk; void __iomem *base; struct reset_control *rstc; + const struct hibvt_pwm_soc *soc; }; struct hibvt_pwm_soc { u32 num_pwms; }; -static const struct hibvt_pwm_soc pwm_soc[2] = { - { .num_pwms = 4 }, - { .num_pwms = 8 }, +static const struct hibvt_pwm_soc hi3516cv300_soc_info = { + .num_pwms = 4, +}; + +static const struct hibvt_pwm_soc hi3519v100_soc_info = { + .num_pwms = 8, }; static inline struct hibvt_pwm_chip *to_hibvt_pwm_chip(struct pwm_chip *chip) @@ -198,6 +202,7 @@ static int hibvt_pwm_probe(struct platform_device *pdev) pwm_chip->chip.npwm = soc->num_pwms; pwm_chip->chip.of_xlate = of_pwm_xlate_with_flags; pwm_chip->chip.of_pwm_n_cells = 3; + pwm_chip->soc = soc; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); pwm_chip->base = devm_ioremap_resource(&pdev->dev, res); @@ -250,8 +255,10 @@ static int hibvt_pwm_remove(struct platform_device *pdev) } static const struct of_device_id hibvt_pwm_of_match[] = { - { .compatible = "hisilicon,hi3516cv300-pwm", .data = &pwm_soc[0] }, - { .compatible = "hisilicon,hi3519v100-pwm", .data = &pwm_soc[1] }, + { .compatible = "hisilicon,hi3516cv300-pwm", + .data = &hi3516cv300_soc_info }, + { .compatible = "hisilicon,hi3519v100-pwm", + .data = &hi3519v100_soc_info }, { } }; MODULE_DEVICE_TABLE(of, hibvt_pwm_of_match); -- 2.17.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 2/3] dt-bindings: pwm: hibvt: Add hi3559v100 support 2019-02-13 15:05 [PATCH v2 1/3] pwm: hibvt: Use individual struct per of-data Mathieu Othacehe @ 2019-02-13 15:05 ` Mathieu Othacehe 2019-02-18 20:03 ` Rob Herring 2019-02-13 15:05 ` [PATCH v2 3/3] " Mathieu Othacehe 1 sibling, 1 reply; 6+ messages in thread From: Mathieu Othacehe @ 2019-02-13 15:05 UTC (permalink / raw) To: thierry.reding, robh+dt, mark.rutland Cc: linux-pwm, devicetree, linux-kernel, Mathieu Othacehe Add support for hi3559v100-shub-pwm and hisilicon,hi3559v100-pwm platforms. Signed-off-by: Mathieu Othacehe <m.othacehe@gmail.com> --- Documentation/devicetree/bindings/pwm/pwm-hibvt.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt index fa7849d67836..daedfef09bb6 100644 --- a/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt +++ b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt @@ -5,6 +5,8 @@ Required properties: The SoC specific strings supported including: "hisilicon,hi3516cv300-pwm" "hisilicon,hi3519v100-pwm" + "hisilicon,hi3559v100-shub-pwm" + "hisilicon,hi3559v100-pwm - reg: physical base address and length of the controller's registers. - clocks: phandle and clock specifier of the PWM reference clock. - resets: phandle and reset specifier for the PWM controller reset. -- 2.17.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2 2/3] dt-bindings: pwm: hibvt: Add hi3559v100 support 2019-02-13 15:05 ` [PATCH v2 2/3] dt-bindings: pwm: hibvt: Add hi3559v100 support Mathieu Othacehe @ 2019-02-18 20:03 ` Rob Herring 0 siblings, 0 replies; 6+ messages in thread From: Rob Herring @ 2019-02-18 20:03 UTC (permalink / raw) Cc: thierry.reding, robh+dt, mark.rutland, linux-pwm, devicetree, linux-kernel, Mathieu Othacehe On Wed, 13 Feb 2019 16:05:07 +0100, Mathieu Othacehe wrote: > Add support for hi3559v100-shub-pwm and hisilicon,hi3559v100-pwm > platforms. > > Signed-off-by: Mathieu Othacehe <m.othacehe@gmail.com> > --- > Documentation/devicetree/bindings/pwm/pwm-hibvt.txt | 2 ++ > 1 file changed, 2 insertions(+) > Reviewed-by: Rob Herring <robh@kernel.org> ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 3/3] pwm: hibvt: Add hi3559v100 support 2019-02-13 15:05 [PATCH v2 1/3] pwm: hibvt: Use individual struct per of-data Mathieu Othacehe 2019-02-13 15:05 ` [PATCH v2 2/3] dt-bindings: pwm: hibvt: Add hi3559v100 support Mathieu Othacehe @ 2019-02-13 15:05 ` Mathieu Othacehe 2019-02-19 7:38 ` Uwe Kleine-König 1 sibling, 1 reply; 6+ messages in thread From: Mathieu Othacehe @ 2019-02-13 15:05 UTC (permalink / raw) To: thierry.reding, robh+dt, mark.rutland Cc: linux-pwm, devicetree, linux-kernel, Mathieu Othacehe Add support for hi3559v100-shub-pwm and hisilicon,hi3559v100-pwm platforms. They require a special quirk: pwm has to be enabled again to force duty_cycle refresh. Signed-off-by: Mathieu Othacehe <m.othacehe@gmail.com> --- drivers/pwm/pwm-hibvt.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/drivers/pwm/pwm-hibvt.c b/drivers/pwm/pwm-hibvt.c index ffc803818c3c..b6a7942b3367 100644 --- a/drivers/pwm/pwm-hibvt.c +++ b/drivers/pwm/pwm-hibvt.c @@ -54,6 +54,7 @@ struct hibvt_pwm_chip { struct hibvt_pwm_soc { u32 num_pwms; + bool quirk_force_enable; }; static const struct hibvt_pwm_soc hi3516cv300_soc_info = { @@ -64,6 +65,16 @@ static const struct hibvt_pwm_soc hi3519v100_soc_info = { .num_pwms = 8, }; +static const struct hibvt_pwm_soc hi3559v100_shub_soc_info = { + .num_pwms = 8, + .quirk_force_enable = true, +}; + +static const struct hibvt_pwm_soc hi3559v100_soc_info = { + .num_pwms = 2, + .quirk_force_enable = true, +}; + static inline struct hibvt_pwm_chip *to_hibvt_pwm_chip(struct pwm_chip *chip) { return container_of(chip, struct hibvt_pwm_chip, chip); @@ -152,13 +163,24 @@ static void hibvt_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, static int hibvt_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, struct pwm_state *state) { + struct hibvt_pwm_chip *hi_pwm_chip = to_hibvt_pwm_chip(chip); + if (state->polarity != pwm->state.polarity) hibvt_pwm_set_polarity(chip, pwm, state->polarity); if (state->period != pwm->state.period || - state->duty_cycle != pwm->state.duty_cycle) + state->duty_cycle != pwm->state.duty_cycle) { hibvt_pwm_config(chip, pwm, state->duty_cycle, state->period); + /* + * On those platforms, it is required to enable the + * pwm again each time we want to refresh the duty + * cycle. + */ + if (hi_pwm_chip->soc->quirk_force_enable && state->enabled) + hibvt_pwm_enable(chip, pwm); + } + if (state->enabled != pwm->state.enabled) { if (state->enabled) hibvt_pwm_enable(chip, pwm); @@ -259,6 +281,10 @@ static const struct of_device_id hibvt_pwm_of_match[] = { .data = &hi3516cv300_soc_info }, { .compatible = "hisilicon,hi3519v100-pwm", .data = &hi3519v100_soc_info }, + { .compatible = "hisilicon,hi3559v100-shub-pwm", + .data = &hi3559v100_shub_soc_info }, + { .compatible = "hisilicon,hi3559v100-pwm", + .data = &hi3559v100_soc_info }, { } }; MODULE_DEVICE_TABLE(of, hibvt_pwm_of_match); -- 2.17.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2 3/3] pwm: hibvt: Add hi3559v100 support 2019-02-13 15:05 ` [PATCH v2 3/3] " Mathieu Othacehe @ 2019-02-19 7:38 ` Uwe Kleine-König 2019-02-19 9:04 ` Mathieu Othacehe 0 siblings, 1 reply; 6+ messages in thread From: Uwe Kleine-König @ 2019-02-19 7:38 UTC (permalink / raw) To: Mathieu Othacehe Cc: thierry.reding, robh+dt, mark.rutland, linux-pwm, devicetree, linux-kernel On Wed, Feb 13, 2019 at 04:05:08PM +0100, Mathieu Othacehe wrote: > Add support for hi3559v100-shub-pwm and hisilicon,hi3559v100-pwm > platforms. They require a special quirk: pwm has to be enabled again > to force duty_cycle refresh. > > Signed-off-by: Mathieu Othacehe <m.othacehe@gmail.com> > --- > drivers/pwm/pwm-hibvt.c | 28 +++++++++++++++++++++++++++- > 1 file changed, 27 insertions(+), 1 deletion(-) > > diff --git a/drivers/pwm/pwm-hibvt.c b/drivers/pwm/pwm-hibvt.c > index ffc803818c3c..b6a7942b3367 100644 > --- a/drivers/pwm/pwm-hibvt.c > +++ b/drivers/pwm/pwm-hibvt.c > @@ -54,6 +54,7 @@ struct hibvt_pwm_chip { > > struct hibvt_pwm_soc { > u32 num_pwms; > + bool quirk_force_enable; > }; > > static const struct hibvt_pwm_soc hi3516cv300_soc_info = { > @@ -64,6 +65,16 @@ static const struct hibvt_pwm_soc hi3519v100_soc_info = { > .num_pwms = 8, > }; > > +static const struct hibvt_pwm_soc hi3559v100_shub_soc_info = { > + .num_pwms = 8, > + .quirk_force_enable = true, > +}; > + > +static const struct hibvt_pwm_soc hi3559v100_soc_info = { > + .num_pwms = 2, > + .quirk_force_enable = true, > +}; > + > static inline struct hibvt_pwm_chip *to_hibvt_pwm_chip(struct pwm_chip *chip) > { > return container_of(chip, struct hibvt_pwm_chip, chip); > @@ -152,13 +163,24 @@ static void hibvt_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > static int hibvt_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, > struct pwm_state *state) > { > + struct hibvt_pwm_chip *hi_pwm_chip = to_hibvt_pwm_chip(chip); > + > if (state->polarity != pwm->state.polarity) > hibvt_pwm_set_polarity(chip, pwm, state->polarity); > > if (state->period != pwm->state.period || > - state->duty_cycle != pwm->state.duty_cycle) > + state->duty_cycle != pwm->state.duty_cycle) { > hibvt_pwm_config(chip, pwm, state->duty_cycle, state->period); I would prefer to have the continued line in the if condition aligned to the opening parenthesis. Then it is optically separated from the first expression in the body of the if. > > + /* > + * On those platforms, it is required to enable the Which platforms? I think in a previous round it was obvious what was meant here because there was a test against two specific compatibles. Now something like Some implementations require the pwm to be enabled once more each time the duty cycle is refreshed. would be more suitable. Is there a publicly available reference manual available for the newly supported hardware? Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | http://www.pengutronix.de/ | ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 3/3] pwm: hibvt: Add hi3559v100 support 2019-02-19 7:38 ` Uwe Kleine-König @ 2019-02-19 9:04 ` Mathieu Othacehe 0 siblings, 0 replies; 6+ messages in thread From: Mathieu Othacehe @ 2019-02-19 9:04 UTC (permalink / raw) To: Uwe Kleine-König Cc: Thierry Reding, robh+dt, mark.rutland, linux-pwm, devicetree, LKML [-- Attachment #1: Type: text/plain, Size: 196 bytes --] Hi Uwe, Is there a publicly available reference manual available for the newly > supported hardware? > No sadly I don't think so :( I'll send a v3 fixing both of your remarks. Thanks, Mathieu [-- Attachment #2: Type: text/html, Size: 591 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-02-19 9:04 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2019-02-13 15:05 [PATCH v2 1/3] pwm: hibvt: Use individual struct per of-data Mathieu Othacehe 2019-02-13 15:05 ` [PATCH v2 2/3] dt-bindings: pwm: hibvt: Add hi3559v100 support Mathieu Othacehe 2019-02-18 20:03 ` Rob Herring 2019-02-13 15:05 ` [PATCH v2 3/3] " Mathieu Othacehe 2019-02-19 7:38 ` Uwe Kleine-König 2019-02-19 9:04 ` Mathieu Othacehe
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).