public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] pwm: pxa: bug fix and device tree support
@ 2013-04-16  6:51 Chao Xie
  2013-04-16  6:51 ` [PATCH 1/3] pwm: pxa: ARCH_MMP share same pwm driver with ARCH_PXA Chao Xie
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Chao Xie @ 2013-04-16  6:51 UTC (permalink / raw)
  To: thierry.reding, linux-kernel, xiechao.mail; +Cc: Chao Xie

The patches fix some bugs
1. pwm-pxa driver is shared by ARCH_PXA and ARCH_MMP
2. use module_platform_driver for driver register

The patches also add device tree support for pwm.


Chao Xie (3):
  pwm: pxa: ARCH_MMP share same pwm driver with ARCH_PXA
  pwm: pxa: use module_platform_driver for driver register
  pwm: pxa: add device tree support

 drivers/pwm/Kconfig   |    2 +-
 drivers/pwm/pwm-pxa.c |   43 +++++++++++++++++++++++++++++++------------
 2 files changed, 32 insertions(+), 13 deletions(-)

-- 
1.7.4.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/3] pwm: pxa: ARCH_MMP share same pwm driver with ARCH_PXA
  2013-04-16  6:51 [PATCH 0/3] pwm: pxa: bug fix and device tree support Chao Xie
@ 2013-04-16  6:51 ` Chao Xie
  2013-04-16  6:51 ` [PATCH 2/3] pwm: pxa: use module_platform_driver for driver register Chao Xie
  2013-04-16  6:51 ` [PATCH 3/3] pwm: pxa: add device tree support Chao Xie
  2 siblings, 0 replies; 5+ messages in thread
From: Chao Xie @ 2013-04-16  6:51 UTC (permalink / raw)
  To: thierry.reding, linux-kernel, xiechao.mail; +Cc: Chao Xie

the pwm driver is not only used by ARCH_PXA but also ARCH_MMP

Signed-off-by: Chao Xie <chao.xie@marvell.com>
---
 drivers/pwm/Kconfig |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig
index e513cd9..ff79632 100644
--- a/drivers/pwm/Kconfig
+++ b/drivers/pwm/Kconfig
@@ -96,7 +96,7 @@ config PWM_PUV3
 
 config PWM_PXA
 	tristate "PXA PWM support"
-	depends on ARCH_PXA
+	depends on ARCH_PXA || ARCH_MMP
 	help
 	  Generic PWM framework driver for PXA.
 
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/3] pwm: pxa: use module_platform_driver for driver register
  2013-04-16  6:51 [PATCH 0/3] pwm: pxa: bug fix and device tree support Chao Xie
  2013-04-16  6:51 ` [PATCH 1/3] pwm: pxa: ARCH_MMP share same pwm driver with ARCH_PXA Chao Xie
@ 2013-04-16  6:51 ` Chao Xie
  2013-04-16  6:51 ` [PATCH 3/3] pwm: pxa: add device tree support Chao Xie
  2 siblings, 0 replies; 5+ messages in thread
From: Chao Xie @ 2013-04-16  6:51 UTC (permalink / raw)
  To: thierry.reding, linux-kernel, xiechao.mail; +Cc: Chao Xie

Signed-off-by: Chao Xie <chao.xie@marvell.com>
---
 drivers/pwm/pwm-pxa.c |   12 +-----------
 1 files changed, 1 insertions(+), 11 deletions(-)

diff --git a/drivers/pwm/pwm-pxa.c b/drivers/pwm/pwm-pxa.c
index f32fc4e..eafca4a 100644
--- a/drivers/pwm/pwm-pxa.c
+++ b/drivers/pwm/pwm-pxa.c
@@ -200,16 +200,6 @@ static struct platform_driver pwm_driver = {
 	.id_table	= pwm_id_table,
 };
 
-static int __init pwm_init(void)
-{
-	return platform_driver_register(&pwm_driver);
-}
-arch_initcall(pwm_init);
-
-static void __exit pwm_exit(void)
-{
-	platform_driver_unregister(&pwm_driver);
-}
-module_exit(pwm_exit);
+module_platform_driver(pwm_driver);
 
 MODULE_LICENSE("GPL v2");
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/3] pwm: pxa: add device tree support
  2013-04-16  6:51 [PATCH 0/3] pwm: pxa: bug fix and device tree support Chao Xie
  2013-04-16  6:51 ` [PATCH 1/3] pwm: pxa: ARCH_MMP share same pwm driver with ARCH_PXA Chao Xie
  2013-04-16  6:51 ` [PATCH 2/3] pwm: pxa: use module_platform_driver for driver register Chao Xie
@ 2013-04-16  6:51 ` Chao Xie
  2013-04-18  8:03   ` Thierry Reding
  2 siblings, 1 reply; 5+ messages in thread
From: Chao Xie @ 2013-04-16  6:51 UTC (permalink / raw)
  To: thierry.reding, linux-kernel, xiechao.mail; +Cc: Chao Xie

Add the deice tree support for pwm-pxa.

Signed-off-by: Chao Xie <chao.xie@marvell.com>
---
 drivers/pwm/pwm-pxa.c |   31 ++++++++++++++++++++++++++++++-
 1 files changed, 30 insertions(+), 1 deletions(-)

diff --git a/drivers/pwm/pwm-pxa.c b/drivers/pwm/pwm-pxa.c
index eafca4a..345aa83 100644
--- a/drivers/pwm/pwm-pxa.c
+++ b/drivers/pwm/pwm-pxa.c
@@ -18,6 +18,8 @@
 #include <linux/err.h>
 #include <linux/clk.h>
 #include <linux/io.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
 #include <linux/pwm.h>
 
 #include <asm/div64.h>
@@ -135,12 +137,34 @@ static struct pwm_ops pxa_pwm_ops = {
 	.owner = THIS_MODULE,
 };
 
+static struct of_device_id pxa_pwm_of_match[] = {
+	{
+		.compatible = "mrvl,pxa25x-pwm",
+		.data = (void *)0
+	}, {
+		.compatible = "mrvl,pxa27x-pwm",
+		.data = (void *)HAS_SECONDARY_PWM
+	}, {
+		.compatible = "mrvl,pxa168-pwm",
+		.data = (void *)0
+	}, {
+		.compatible = "mrvl,pxa910-pwm",
+		.data = (void *)0
+	},
+	{}
+};
+
+MODULE_DEVICE_TABLE(of, pxa_pwm_of_match);
+
 static int pwm_probe(struct platform_device *pdev)
 {
 	const struct platform_device_id *id = platform_get_device_id(pdev);
+	const struct of_device_id *of_id =
+			of_match_device(pxa_pwm_of_match, &pdev->dev);
 	struct pxa_pwm_chip *pwm;
 	struct resource *r;
 	int ret = 0;
+	unsigned int npwm;
 
 	pwm = devm_kzalloc(&pdev->dev, sizeof(*pwm), GFP_KERNEL);
 	if (pwm == NULL) {
@@ -157,7 +181,12 @@ static int pwm_probe(struct platform_device *pdev)
 	pwm->chip.dev = &pdev->dev;
 	pwm->chip.ops = &pxa_pwm_ops;
 	pwm->chip.base = -1;
-	pwm->chip.npwm = (id->driver_data & HAS_SECONDARY_PWM) ? 2 : 1;
+	if (of_id)
+		npwm = (unsigned int)(of_id->data);
+	else
+		npwm = id->driver_data;
+
+	pwm->chip.npwm = (npwm & HAS_SECONDARY_PWM) ? 2 : 1;
 
 	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (r == NULL) {
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 3/3] pwm: pxa: add device tree support
  2013-04-16  6:51 ` [PATCH 3/3] pwm: pxa: add device tree support Chao Xie
@ 2013-04-18  8:03   ` Thierry Reding
  0 siblings, 0 replies; 5+ messages in thread
From: Thierry Reding @ 2013-04-18  8:03 UTC (permalink / raw)
  To: Chao Xie; +Cc: linux-kernel, xiechao.mail

[-- Attachment #1: Type: text/plain, Size: 1986 bytes --]

On Tue, Apr 16, 2013 at 02:51:55AM -0400, Chao Xie wrote:
> Add the deice tree support for pwm-pxa.

"device" and you can drop "the".

>  drivers/pwm/pwm-pxa.c |   31 ++++++++++++++++++++++++++++++-
>  1 files changed, 30 insertions(+), 1 deletions(-)

This is missing a file in Documentation/devicetree/bindings/pwm that
describe the device tree bindings for this driver.

> diff --git a/drivers/pwm/pwm-pxa.c b/drivers/pwm/pwm-pxa.c
[...]
> +static struct of_device_id pxa_pwm_of_match[] = {

I know not all drivers do this, but this should be "static const".

> +	{
> +		.compatible = "mrvl,pxa25x-pwm",

According to Documentation/devicetree/bindings/vendor-prefixes.txt the
vendor prefix for Marvell is "marvell".

> +		.data = (void *)0

Initialization to 0 is redundant here.

>  static int pwm_probe(struct platform_device *pdev)
>  {
>  	const struct platform_device_id *id = platform_get_device_id(pdev);
> +	const struct of_device_id *of_id =
> +			of_match_device(pxa_pwm_of_match, &pdev->dev);
>  	struct pxa_pwm_chip *pwm;
>  	struct resource *r;
>  	int ret = 0;
> +	unsigned int npwm;
>  
>  	pwm = devm_kzalloc(&pdev->dev, sizeof(*pwm), GFP_KERNEL);
>  	if (pwm == NULL) {
> @@ -157,7 +181,12 @@ static int pwm_probe(struct platform_device *pdev)
>  	pwm->chip.dev = &pdev->dev;
>  	pwm->chip.ops = &pxa_pwm_ops;
>  	pwm->chip.base = -1;
> -	pwm->chip.npwm = (id->driver_data & HAS_SECONDARY_PWM) ? 2 : 1;
> +	if (of_id)
> +		npwm = (unsigned int)(of_id->data);
> +	else
> +		npwm = id->driver_data;
> +
> +	pwm->chip.npwm = (npwm & HAS_SECONDARY_PWM) ? 2 : 1;

Can you rebase this on my for-next branch since it has some patches that
this conflicts with.

Also I think this patch is missing the assignment of

	.of_match_table = pxa_pwm_of_match;

in the platform_driver structure initialization. And I think PXA hasn't
been fully converted to OF-only, so you need to conditionalize the OF
bits.

Thierry

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-04-18  8:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-16  6:51 [PATCH 0/3] pwm: pxa: bug fix and device tree support Chao Xie
2013-04-16  6:51 ` [PATCH 1/3] pwm: pxa: ARCH_MMP share same pwm driver with ARCH_PXA Chao Xie
2013-04-16  6:51 ` [PATCH 2/3] pwm: pxa: use module_platform_driver for driver register Chao Xie
2013-04-16  6:51 ` [PATCH 3/3] pwm: pxa: add device tree support Chao Xie
2013-04-18  8:03   ` Thierry Reding

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox