Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 333095
b: refs/heads/master
c: 479e2e3
h: refs/heads/master
i:
  333093: b4e958c
  333091: fed626d
  333087: 06eab1b
v: v3
  • Loading branch information
Philipp Zabel authored and Thierry Reding committed Sep 12, 2012
1 parent ad2dbb9 commit 50b6d34
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 10 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 208d038f4792b5ca0dc76deebbc0ae13b4f1a744
refs/heads/master: 479e2e301c626cc64fb27b6b1938655eaba8b036
17 changes: 17 additions & 0 deletions trunk/Documentation/devicetree/bindings/pwm/imx-pwm.txt
Original file line number Diff line number Diff line change
@@ -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@53fb4000 {
#pwm-cells = <2>;
compatible = "fsl,imx53-pwm", "fsl,imx27-pwm";
reg = <0x53fb4000 0x4000>;
interrupts = <61>;
};
44 changes: 35 additions & 9 deletions trunk/drivers/pwm/pwm-imx.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
#include <linux/clk.h>
#include <linux/io.h>
#include <linux/pwm.h>
#include <linux/of_device.h>
#include <mach/hardware.h>


/* i.MX1 and i.MX21 share the same PWM function block: */

#define MX1_PWMC 0x00 /* PWM Control Register */
Expand Down Expand Up @@ -204,12 +204,41 @@ static struct pwm_ops imx_pwm_ops = {
.owner = THIS_MODULE,
};

struct imx_pwm_data {
int (*config)(struct pwm_chip *chip,
struct pwm_device *pwm, int duty_ns, int period_ns);
void (*set_enable)(struct pwm_chip *chip, bool enable);
};

static struct imx_pwm_data imx_pwm_data_v1 = {
.config = imx_pwm_config_v1,
.set_enable = imx_pwm_set_enable_v1,
};

static struct imx_pwm_data imx_pwm_data_v2 = {
.config = imx_pwm_config_v2,
.set_enable = imx_pwm_set_enable_v2,
};

static const struct of_device_id imx_pwm_dt_ids[] = {
{ .compatible = "fsl,imx1-pwm", .data = &imx_pwm_data_v1, },
{ .compatible = "fsl,imx27-pwm", .data = &imx_pwm_data_v2, },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, imx_pwm_dt_ids);

static int __devinit imx_pwm_probe(struct platform_device *pdev)
{
const struct of_device_id *of_id =
of_match_device(imx_pwm_dt_ids, &pdev->dev);
struct imx_pwm_data *data;
struct imx_chip *imx;
struct resource *r;
int ret = 0;

if (!of_id)
return -ENODEV;

imx = devm_kzalloc(&pdev->dev, sizeof(*imx), GFP_KERNEL);
if (imx == NULL) {
dev_err(&pdev->dev, "failed to allocate memory\n");
Expand All @@ -236,13 +265,9 @@ static int __devinit imx_pwm_probe(struct platform_device *pdev)
if (imx->mmio_base == NULL)
return -EADDRNOTAVAIL;

if (cpu_is_mx1() || cpu_is_mx21()) {
imx->config = imx_pwm_config_v1;
imx->set_enable = imx_pwm_set_enable_v1;
} else {
imx->config = imx_pwm_config_v2;
imx->set_enable = imx_pwm_set_enable_v2;
}
data = of_id->data;
imx->config = data->config;
imx->set_enable = data->set_enable;

ret = pwmchip_add(&imx->chip);
if (ret < 0)
Expand All @@ -265,7 +290,8 @@ static int __devexit imx_pwm_remove(struct platform_device *pdev)

static struct platform_driver imx_pwm_driver = {
.driver = {
.name = "mxc_pwm",
.name = "imx-pwm",
.of_match_table = of_match_ptr(imx_pwm_dt_ids),
},
.probe = imx_pwm_probe,
.remove = __devexit_p(imx_pwm_remove),
Expand Down

0 comments on commit 50b6d34

Please sign in to comment.