From: Frank Li <Frank.Li@nxp.com>
To: "Uwe Kleine-König" <ukleinek@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Shawn Guo" <shawnguo@kernel.org>,
"Sascha Hauer" <s.hauer@pengutronix.de>,
"Pengutronix Kernel Team" <kernel@pengutronix.de>,
"Fabio Estevam" <festevam@gmail.com>,
"Philipp Zabel" <p.zabel@pengutronix.de>
Cc: linux-pwm@vger.kernel.org, devicetree@vger.kernel.org,
imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, pratikmanvar09@gmail.com,
francesco@dolcini.it, Frank Li <Frank.Li@nxp.com>,
Liu Ying <victor.liu@nxp.com>
Subject: [PATCH v2 2/3] pwm: imx27: Add 32k clock for pwm in i.MX8QXP MIPI subsystem
Date: Mon, 15 Jul 2024 16:29:51 -0400 [thread overview]
Message-ID: <20240715-pwm-v2-2-ff3eece83cbb@nxp.com> (raw)
In-Reply-To: <20240715-pwm-v2-0-ff3eece83cbb@nxp.com>
From: Liu Ying <victor.liu@nxp.com>
PWM in i.MX8QXP MIPI subsystem needs the clock '32k'. Use it if the DTS
provides that.
Signed-off-by: Liu Ying <victor.liu@nxp.com>
Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
Change from v1 to v2
- remove if check for clk
- use dev_err_probe
- remove int val
---
drivers/pwm/pwm-imx27.c | 26 +++++++++++++++++++++-----
1 file changed, 21 insertions(+), 5 deletions(-)
diff --git a/drivers/pwm/pwm-imx27.c b/drivers/pwm/pwm-imx27.c
index 9e2bbf5b4a8ce..253afe94c4776 100644
--- a/drivers/pwm/pwm-imx27.c
+++ b/drivers/pwm/pwm-imx27.c
@@ -15,6 +15,7 @@
#include <linux/delay.h>
#include <linux/err.h>
#include <linux/io.h>
+#include <linux/iopoll.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/of.h>
@@ -82,6 +83,7 @@
struct pwm_imx27_chip {
struct clk *clk_ipg;
struct clk *clk_per;
+ struct clk *clk_32k;
void __iomem *mmio_base;
/*
@@ -101,23 +103,32 @@ static int pwm_imx27_clk_prepare_enable(struct pwm_imx27_chip *imx)
{
int ret;
+ ret = clk_prepare_enable(imx->clk_32k);
+ if (ret)
+ goto err1;
+
ret = clk_prepare_enable(imx->clk_ipg);
if (ret)
- return ret;
+ goto err2;
ret = clk_prepare_enable(imx->clk_per);
- if (ret) {
- clk_disable_unprepare(imx->clk_ipg);
- return ret;
- }
+ if (ret)
+ goto err3;
return 0;
+err3:
+ clk_disable_unprepare(imx->clk_ipg);
+err2:
+ clk_disable_unprepare(imx->clk_32k);
+err1:
+ return ret;
}
static void pwm_imx27_clk_disable_unprepare(struct pwm_imx27_chip *imx)
{
clk_disable_unprepare(imx->clk_per);
clk_disable_unprepare(imx->clk_ipg);
+ clk_disable_unprepare(imx->clk_32k);
}
static int pwm_imx27_get_state(struct pwm_chip *chip,
@@ -325,6 +336,11 @@ static int pwm_imx27_probe(struct platform_device *pdev)
return dev_err_probe(&pdev->dev, PTR_ERR(imx->clk_per),
"failed to get peripheral clock\n");
+ imx->clk_32k = devm_clk_get_optional(&pdev->dev, "32k");
+ if (IS_ERR(imx->clk_32k))
+ return dev_err_probe(&pdev->dev, PTR_ERR(imx->clk_32k),
+ "failed to get 32k clock\n");
+
chip->ops = &pwm_imx27_ops;
imx->mmio_base = devm_platform_ioremap_resource(pdev, 0);
--
2.34.1
next prev parent reply other threads:[~2024-07-15 20:31 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-15 20:29 [PATCH v2 0/3] pwm: imx: add 32k clock for 8qm/qxp and workaround a chip issue Frank Li
2024-07-15 20:29 ` [PATCH v2 1/3] dt-bindings: pwm: imx: Add optional clock '32k' Frank Li
2024-07-16 16:04 ` Conor Dooley
2024-07-15 20:29 ` Frank Li [this message]
2024-07-16 18:49 ` [PATCH v2 2/3] pwm: imx27: Add 32k clock for pwm in i.MX8QXP MIPI subsystem Christophe JAILLET
2024-07-15 20:29 ` [PATCH v2 3/3] pwm: imx27: workaround of the pwm output bug when decrease the duty cycle Frank Li
2024-09-05 17:12 ` Fabio Estevam
2024-09-05 18:26 ` Marek Vasut
2024-09-05 18:54 ` Frank Li
2024-09-05 19:01 ` Marek Vasut
2024-09-05 20:37 ` Frank Li
2024-09-06 4:33 ` Marek Vasut
2024-09-09 19:41 ` Frank Li
2024-09-09 20:16 ` Marek Vasut
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=20240715-pwm-v2-2-ff3eece83cbb@nxp.com \
--to=frank.li@nxp.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=festevam@gmail.com \
--cc=francesco@dolcini.it \
--cc=imx@lists.linux.dev \
--cc=kernel@pengutronix.de \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=p.zabel@pengutronix.de \
--cc=pratikmanvar09@gmail.com \
--cc=robh@kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
--cc=ukleinek@kernel.org \
--cc=victor.liu@nxp.com \
/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).