linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: benoit.thebaudeau@advansee.com (Benoît Thébaudeau)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 5/8] pwm i.MX: add devicetree support
Date: Wed, 5 Sep 2012 23:42:34 +0200 (CEST)	[thread overview]
Message-ID: <811985020.3713350.1346881354214.JavaMail.root@advansee.com> (raw)
In-Reply-To: <1346852127-25226-6-git-send-email-s.hauer@pengutronix.de>

On Wednesday, September 5, 2012 3:35:24 PM, Sascha Hauer wrote:
> 
> 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
> 
> diff --git a/Documentation/devicetree/bindings/pwm/imx-pwm.txt
> b/Documentation/devicetree/bindings/pwm/imx-pwm.txt
> new file mode 100644
> index 0000000..9b9b185
> --- /dev/null
> +++ b/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>;
> +};
> diff --git a/drivers/pwm/pwm-imx.c b/drivers/pwm/pwm-imx.c
> index a689144..af77045 100644
> --- a/drivers/pwm/pwm-imx.c
> +++ b/drivers/pwm/pwm-imx.c
> @@ -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: */
>  
> @@ -203,12 +202,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");
> @@ -235,13 +263,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)
> @@ -264,7 +288,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),

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

  reply	other threads:[~2012-09-05 21:42 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-05 13:35 [PATCH v2] pwm i.MX: add devicetree support Sascha Hauer
2012-09-05 13:35 ` [PATCH 1/8] pwm i.MX: factor out SoC specific functions Sascha Hauer
2012-09-05 13:35 ` [PATCH 2/8] pwm i.MX: remove unnecessary if in pwm_[en|dis]able Sascha Hauer
2012-09-05 13:35 ` [PATCH 3/8] pwm i.MX: add functions to enable/disable pwm Sascha Hauer
2012-09-05 13:35 ` [PATCH 4/8] pwm i.MX: Use module_platform_driver Sascha Hauer
2012-09-05 13:35 ` [PATCH 5/8] pwm i.MX: add devicetree support Sascha Hauer
2012-09-05 21:42   ` Benoît Thébaudeau [this message]
2012-09-06  6:58     ` Sascha Hauer
2012-09-05 13:35 ` [PATCH 6/8] pwm i.MX: use per clock unconditionally Sascha Hauer
2012-09-05 13:35 ` [PATCH 7/8] pwm i.MX: fix clock lookup Sascha Hauer
2012-09-05 21:48   ` Benoît Thébaudeau
2012-09-06  7:15     ` Sascha Hauer
2012-09-05 13:35 ` [PATCH 8/8] ARM i.MX53: Add pwm support Sascha Hauer
2012-09-06  8:19 ` [PATCH v2] pwm i.MX: add devicetree support Shawn Guo

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=811985020.3713350.1346881354214.JavaMail.root@advansee.com \
    --to=benoit.thebaudeau@advansee.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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).