linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Paul Barker <pbarker@konsulko.com>
To: "Thierry Reding" <thierry.reding@gmail.com>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	"Shawn Guo" <shawnguo@kernel.org>,
	"NXP Linux Team" <linux-imx@nxp.com>
Cc: linux-pwm@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	devicetree@vger.kernel.org
Subject: Inverted PWM output on iMX6
Date: Thu, 5 Mar 2020 13:22:32 +0000	[thread overview]
Message-ID: <20200305132232.1aced378@ub1910> (raw)

Hi folks,

I recently ran into an issue using the pwm-fan driver with an inverted
PWM output on iMX6.

The fan is defined in the device tree as follows:

	fan0: pwm-fan {
		compatible = "pwm-fan";
		pwms = <&pwm2 0 25000 PWM_POLARITY_INVERTED>;
		...
	}

In pwm_imx27_probe() the support for a third `flags` argument in a pwm
reference is enabled:

	imx->chip.of_xlate = of_pwm_xlate_with_flags;
	imx->chip.of_pwm_n_cells = 3;

However, the flag is ignored and the output is not inverted.

By adding some prints I saw that when of_pwm_xlate_with_flags() is
called, args->args_count is 2 instead of 3.

Looking at the definition of the pwm device itself in imx6qdl.dtsi I
can see that the number of cells in a pwm reference is set to 2 not 3:

	pwm2: pwm@2084000 {
		#pwm-cells = <2>;
		...
	};

That seems to be preventing a third argument from being passed.

I can change `#pwm-cells` to <3> and then everything works for my
device but I'm not sure that is the correct solution for everyone. That
would require all pwm references on iMX6 devices to use 3 cells. The
code in of_pwm_xlate_with_flags() seems to be built to handle either 2
or 3 argument cells but I can't see any way to allow this choice in the
device tree.

If the solution is to set `#pwm-cells` to <3> I'm happy to send a patch
which does this and updates all pwm references in device trees which
include `imx6dql.dtsi`. Before I do that I'd like to know that it's the
correct approach though.

For context I've confirmed this is the case in Linux 5.4 and that the
relevant files haven't changed between that release and 5.6.0-rc4.

Thanks,

-- 
Paul Barker
Konsulko Group

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

             reply	other threads:[~2020-03-05 13:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-05 13:22 Paul Barker [this message]
2020-03-05 13:36 ` Inverted PWM output on iMX6 Uwe Kleine-König
2020-03-06  7:43   ` Michal Vokáč
2020-03-06 20:17     ` Paul Barker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200305132232.1aced378@ub1910 \
    --to=pbarker@konsulko.com \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-pwm@vger.kernel.org \
    --cc=shawnguo@kernel.org \
    --cc=thierry.reding@gmail.com \
    --cc=u.kleine-koenig@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).