From: Philipp Zabel <p.zabel@pengutronix.de>
The i.MX pwm core has two clocks: The ipg clock and the ipg highfreq
(peripheral) clock. The ipg clock has to be enabled for this hardware
to work. The actual pwm output can either be driven by the ipg clock
or the ipg highfreq. The ipg highfreq has the advantage that it runs
even when the SoC is in low power modes.
This patch requests both clocks and enables the ipg clock for accessing
registers and the peripheral clock to actually turn on the pwm.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/pwm/pwm-imx.c | 33 +++++++++++++++++++++++++--------
1 file changed, 25 insertions(+), 8 deletions(-)
@@ -238,10 +246,19 @@ static int __devinit imx_pwm_probe(struct platform_device *pdev)return-ENOMEM;}-imx->clk=devm_clk_get(&pdev->dev,"pwm");+imx->clk_per=devm_clk_get(&pdev->dev,"per");+if(IS_ERR(imx->clk_per)){+dev_err(&pdev->dev,"getting per clock failed with %ld\n",+PTR_ERR(imx->clk_per));+returnPTR_ERR(imx->clk_per);+}-if(IS_ERR(imx->clk))-returnPTR_ERR(imx->clk);+imx->clk_ipg=devm_clk_get(&pdev->dev,"ipg");+if(IS_ERR(imx->clk_ipg)){+dev_err(&pdev->dev,"getting ipg clock failed with %ld\n",+PTR_ERR(imx->clk_ipg));+returnPTR_ERR(imx->clk_ipg);+}imx->chip.ops=&imx_pwm_ops;imx->chip.dev=&pdev->dev;
On Wednesday, September 5, 2012 3:35:26 PM, Sascha Hauer wrote:
quoted hunk
From: Philipp Zabel <p.zabel@pengutronix.de>
The i.MX pwm core has two clocks: The ipg clock and the ipg highfreq
(peripheral) clock. The ipg clock has to be enabled for this hardware
to work. The actual pwm output can either be driven by the ipg clock
or the ipg highfreq. The ipg highfreq has the advantage that it runs
even when the SoC is in low power modes.
This patch requests both clocks and enables the ipg clock for
accessing
registers and the peripheral clock to actually turn on the pwm.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/pwm/pwm-imx.c | 33 +++++++++++++++++++++++++--------
1 file changed, 25 insertions(+), 8 deletions(-)
On Wed, Sep 05, 2012 at 11:48:51PM +0200, Beno?t Th?baudeau wrote:
quoted
- c = clk_get_rate(imx->clk);
+ c = clk_get_rate(imx->clk_per);
c = c * period_ns;
do_div(c, 1000000000);
period_cycles = c;
@@ -160,8 +161,15 @@ static int imx_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, int duty_ns, int period_ns) { struct imx_chip *imx = to_imx_chip(chip);+ int ret;- return imx->config(chip, pwm, duty_ns, period_ns);+ clk_prepare_enable(imx->clk_ipg);
Why don't you test the return value like in imx_pwm_enable()?
Will do next time.
Sascha
I have reviewed the whole series. Apart from the comments I made, it looks good
to me.
Thanks. I can take this as a reviewed-by, right?
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
@@ -455,6 +455,10 @@ int __init mx53_clocks_init(unsigned long rate_ckil, unsigned long rate_osc,clk_register_clkdev(clk[ssi1_ipg_gate],NULL,"63fcc000.ssi");clk_register_clkdev(clk[ssi2_ipg_gate],NULL,"50014000.ssi");clk_register_clkdev(clk[ssi3_ipg_gate],NULL,"63fd0000.ssi");+clk_register_clkdev(clk[pwm1_ipg_gate],"ipg","53fb4000.pwm");+clk_register_clkdev(clk[pwm1_hf_gate],"per","53fb4000.pwm");+clk_register_clkdev(clk[pwm2_ipg_gate],"ipg","53fb8000.pwm");+clk_register_clkdev(clk[pwm2_hf_gate],"per","53fb8000.pwm");/* set SDHC root clock to 200MHZ*/clk_set_rate(clk[esdhc_a_podf],200000000);
The i.MX pwm core has two clocks: The ipg clock and the ipg highfreq
(peripheral) clock. The ipg clock has to be enabled for this hardware
to work. The actual pwm output can either be driven by the ipg clock
or the ipg highfreq. The ipg highfreq has the advantage that it runs
even when the SoC is in low power modes.
Use the always running clock also on i.MX25.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/pwm/pwm-imx.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
We used to enable/disable the pwm only by switching the
clock on or off. Instead, use the dedicated register bits.
These differ on different SoCs, so introduce a SoC specific
function for this.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/pwm/pwm-imx.c | 48 ++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 44 insertions(+), 4 deletions(-)
The pwm core makes sure that pwm_enable/disable are called only
once. Still keep the enabled state since we will need it in
pwm_config.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/pwm/pwm-imx.c | 25 +++++++++++--------------
1 file changed, 11 insertions(+), 14 deletions(-)
From: Philipp Zabel <p.zabel@pengutronix.de>
At the same time remove platform based support. No user for
this driver has made it into mainline so far, so all we break
is out of tree stuff.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
Documentation/devicetree/bindings/pwm/imx-pwm.txt | 17 ++++++++
drivers/pwm/pwm-imx.c | 45 ++++++++++++++++-----
2 files changed, 52 insertions(+), 10 deletions(-)
create mode 100644 Documentation/devicetree/bindings/pwm/imx-pwm.txt
@@ -0,0 +1,17 @@+Freescale i.MX PWM controller++Required properties:+- compatible: should be "fsl,<soc>-pwm"+- reg: physical base address and length of the controller's registers+- #pwm-cells: should be 2. The first cell specifies the per-chip index+ of the PWM to use and the second cell is the duty cycle in nanoseconds.+- interrupts: The interrupt for the pwm controller++Example:++pwm1: pwm at 53fb4000 {+ #pwm-cells = <2>;+ compatible = "fsl,imx53-pwm", "fsl,imx27-pwm";+ reg = <0x53fb4000 0x4000>;+ interrupts = <61>;+};
@@ -16,8 +16,7 @@#include<linux/clk.h>#include<linux/io.h>#include<linux/pwm.h>-#include<mach/hardware.h>-+#include<linux/of_device.h>/* i.MX1 and i.MX21 share the same PWM function block: */
On Wednesday, September 5, 2012 3:35:24 PM, Sascha Hauer wrote:
quoted hunk
From: Philipp Zabel <p.zabel@pengutronix.de>
At the same time remove platform based support. No user for
this driver has made it into mainline so far, so all we break
is out of tree stuff.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
Documentation/devicetree/bindings/pwm/imx-pwm.txt | 17 ++++++++
drivers/pwm/pwm-imx.c | 45
++++++++++++++++-----
2 files changed, 52 insertions(+), 10 deletions(-)
create mode 100644 Documentation/devicetree/bindings/pwm/imx-pwm.txt
@@ -0,0 +1,17 @@+Freescale i.MX PWM controller++Required properties:+- compatible: should be "fsl,<soc>-pwm"+- reg: physical base address and length of the controller's
registers
+- #pwm-cells: should be 2. The first cell specifies the per-chip
index
+ of the PWM to use and the second cell is the duty cycle in
nanoseconds.
+- interrupts: The interrupt for the pwm controller
+
+Example:
+
+pwm1: pwm at 53fb4000 {
+ #pwm-cells = <2>;
+ compatible = "fsl,imx53-pwm", "fsl,imx27-pwm";
+ reg = <0x53fb4000 0x4000>;
+ interrupts = <61>;
+};
@@ -16,8 +16,7 @@#include<linux/clk.h>#include<linux/io.h>#include<linux/pwm.h>-#include<mach/hardware.h>-+#include<linux/of_device.h>/* i.MX1 and i.MX21 share the same PWM function block: */
Since this is supposed to remove platform-based support, why don't you also
remove the PWM stuff from arch/arm/plat-mxc and
arch/arm/mach-imx/devices-imx*.h?
Best regards,
Beno?t
On Wed, Sep 05, 2012 at 11:42:34PM +0200, Beno?t Th?baudeau wrote:
Since this is supposed to remove platform-based support, why don't you also
remove the PWM stuff from arch/arm/plat-mxc and
arch/arm/mach-imx/devices-imx*.h?
Simple answer: I was too lazy yesterday. I will include it in the next
round.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
On Wed, Sep 05, 2012 at 03:35:19PM +0200, Sascha Hauer wrote:
Changes since v1:
- Add devicetree binding documentation
- Merge 5/9 and 9/9
- fix #pwm-cells (must be 2 instead of 3)
- fix wrong name in MODULE_DEVICE_TABLE
- drop platform based probing while introducing devicetree based probe
----------------------------------------------------------------
Philipp Zabel (2):
pwm i.MX: add devicetree support
pwm i.MX: fix clock lookup
Sascha Hauer (6):
pwm i.MX: factor out SoC specific functions
pwm i.MX: remove unnecessary if in pwm_[en|dis]able
pwm i.MX: add functions to enable/disable pwm.
pwm i.MX: Use module_platform_driver
pwm i.MX: use per clock unconditionally
ARM i.MX53: Add pwm support