2011-04-18 14:12:22

by Haojian Zhuang

[permalink] [raw]
Subject: [PATCH 06/14] mfd: pxa-w1: MFD driver for PXA 1wire control + DS1WM chip

This driver provides registers and IRQ of PXA3xx chips to the ds1wm driver.

Signed-off-by: Haojian Zhuang <[email protected]>
Cc: Evgeniy Polyakov <[email protected]>
---
drivers/mfd/Kconfig | 7 ++
drivers/mfd/Makefile | 1 +
drivers/mfd/pxa-w1.c | 150 ++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 158 insertions(+), 0 deletions(-)
create mode 100644 drivers/mfd/pxa-w1.c

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index e2fea58..b6ecf90 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -34,6 +34,13 @@ config MFD_88PM860X
select individual components like voltage regulators, RTC and
battery-charger under the corresponding menus.

+config MFD_PXA_DS1WM
+ tristate "Support DS1WM chip on Marvell silicons"
+ select MFD_CORE
+ help
+ This core driver provides register access for PXA_DS1WM.
+ Actual functionality is handled by the ds1wm drivers.
+
config MFD_SM501
tristate "Support for Silicon Motion SM501"
---help---
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 419caa9..4f8d1d2 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -4,6 +4,7 @@

88pm860x-objs := 88pm860x-core.o 88pm860x-i2c.o
obj-$(CONFIG_MFD_88PM860X) += 88pm860x.o
+obj-$(CONFIG_MFD_PXA_DS1WM) += pxa-w1.o
obj-$(CONFIG_MFD_SM501) += sm501.o
obj-$(CONFIG_MFD_ASIC3) += asic3.o tmio_core.o

diff --git a/drivers/mfd/pxa-w1.c b/drivers/mfd/pxa-w1.c
new file mode 100644
index 0000000..98074ff
--- /dev/null
+++ b/drivers/mfd/pxa-w1.c
@@ -0,0 +1,150 @@
+/*
+ * Core driver for PXA DS1WM chip.
+ *
+ * Copyright (C) 2010 Marvell <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ */
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/platform_device.h>
+#include <linux/gpio.h>
+#include <linux/io.h>
+#include <linux/irq.h>
+#include <linux/clk.h>
+#include <linux/err.h>
+#include <linux/interrupt.h>
+#include <linux/mfd/core.h>
+#include <linux/mfd/ds1wm.h>
+
+struct pxa_w1_info {
+ struct clk *clk;
+};
+
+static int ds1wm_enable(struct platform_device *pdev)
+{
+ struct device *dev = pdev->dev.parent;
+ struct pxa_w1_info *info = dev_get_drvdata(dev);
+
+ clk_enable(info->clk);
+ dev_dbg(dev, "pxa DS1WM clk (active)\n");
+ return 0;
+}
+
+static int ds1wm_disable(struct platform_device *pdev)
+{
+ struct device *dev = pdev->dev.parent;
+ struct pxa_w1_info *info = dev_get_drvdata(dev);
+
+ clk_disable(info->clk);
+ dev_dbg(dev, "pxa DS1WM clk (in-active)\n");
+ return 0;
+}
+
+static struct resource ds1wm_resources[] __devinitdata = {
+ {0, 0, "ds1wm-mem", IORESOURCE_MEM,},
+ {0, 0, "ds1wm-irq", IORESOURCE_IRQ,},
+};
+
+static struct ds1wm_driver_data ds1wm_pdata;
+
+static struct mfd_cell ds1wm_cell __devinitdata = {
+ .name = "ds1wm",
+ .enable = ds1wm_enable,
+ .disable = ds1wm_disable,
+ .platform_data = &ds1wm_pdata,
+ .pdata_size = sizeof(ds1wm_pdata),
+ .num_resources = ARRAY_SIZE(ds1wm_resources),
+ .resources = ds1wm_resources,
+};
+
+static int __devinit pxa_w1_probe(struct platform_device *pdev)
+{
+ struct ds1wm_driver_data *pdata = pdev->dev.platform_data;
+ struct pxa_w1_info *info;
+ struct resource *r;
+ int ret, irq;
+
+ info = kzalloc(sizeof(struct pxa_w1_info), GFP_KERNEL);
+ if (!info)
+ return -ENOMEM;
+
+ r = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+ if (r == NULL) {
+ ret = -ENXIO;
+ goto out;
+ }
+ irq = r->start;
+ if (pdata)
+ ds1wm_pdata.active_high = pdata->active_high;
+ if (ds1wm_pdata.active_high)
+ ds1wm_resources[1].flags |= IORESOURCE_IRQ_HIGHEDGE;
+ else
+ ds1wm_resources[1].flags |= IORESOURCE_IRQ_LOWEDGE;
+
+ r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (r == NULL) {
+ ret = -ENXIO;
+ goto out;
+ }
+ ds1wm_resources[0].end = resource_size(r) - 1;
+
+ info->clk = clk_get(&pdev->dev, NULL);
+ if (IS_ERR(info->clk)) {
+ ret = PTR_ERR(info->clk);
+ goto out;
+ }
+ platform_set_drvdata(pdev, info);
+
+ ds1wm_pdata.clock_rate = clk_get_rate(info->clk);
+ ret = mfd_add_devices(&pdev->dev, pdev->id, &ds1wm_cell, 1, r, irq);
+ if (ret < 0)
+ dev_err(&pdev->dev, "failed to register pxa DS1WM\n");
+
+ return 0;
+out:
+ kfree(info);
+ return ret;
+}
+
+static int __devexit pxa_w1_remove(struct platform_device *pdev)
+{
+ struct pxa_w1_info *info = platform_get_drvdata(pdev);
+
+ mfd_remove_devices(&pdev->dev);
+ clk_put(info->clk);
+ kfree(info);
+ platform_set_drvdata(pdev, NULL);
+ return 0;
+}
+
+static struct platform_driver pxa_w1_driver = {
+ .driver = {
+ .name = "pxa3xx-w1",
+ .owner = THIS_MODULE,
+ },
+ .probe = pxa_w1_probe,
+ .remove = __devexit_p(pxa_w1_remove),
+};
+
+static int __init pxa_w1_base_init(void)
+{
+ return platform_driver_register(&pxa_w1_driver);
+}
+
+static void __exit pxa_w1_base_exit(void)
+{
+ platform_driver_unregister(&pxa_w1_driver);
+}
+
+module_init(pxa_w1_base_init);
+module_exit(pxa_w1_base_exit);
+
+MODULE_AUTHOR("Jett Zhou <[email protected]>");
+MODULE_DESCRIPTION("one wire driver for PXA");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:pxa-w1");
--
1.5.6.5


2011-04-26 09:48:42

by Samuel Ortiz

[permalink] [raw]
Subject: Re: [PATCH 06/14] mfd: pxa-w1: MFD driver for PXA 1wire control + DS1WM chip

Hi Haojian,

On Mon, Apr 18, 2011 at 10:04:03PM +0800, Haojian Zhuang wrote:
> This driver provides registers and IRQ of PXA3xx chips to the ds1wm driver.
I see why this is needed, but I really think the ds1wm driver should be
converted to a regular platform device. The MFD driver below is just adding a
useless middle layer between your platform code and the ds1wm one.

Cheers,
Samuel.

--
Intel Open Source Technology Centre
http://oss.intel.com/

2011-05-14 14:21:30

by Haojian Zhuang

[permalink] [raw]
Subject: Re: [PATCH 06/14] mfd: pxa-w1: MFD driver for PXA 1wire control + DS1WM chip

On Tue, Apr 26, 2011 at 5:48 PM, Samuel Ortiz <[email protected]> wrote:
> Hi Haojian,
>
> On Mon, Apr 18, 2011 at 10:04:03PM +0800, Haojian Zhuang wrote:
>> This driver provides registers and IRQ of PXA3xx chips to the ds1wm driver.
> I see why this is needed, but I really think the ds1wm driver should be
> converted to a regular platform device. The MFD driver below is just adding a
> useless middle layer between your platform code and the ds1wm one.
>
I'm OK to use the regulator platform device for ds1wm driver except
for one concern.
ds1wm driver is designed for mfd cell driver. I need to update it as
regulator platform
driver first. cell->enable() / cell->disable() is used to enable clock
for ds1wm driver.
So I need to change the API from cell->enable/disable to clk_enable()
/ clk_disable().

But the key issue is that there's no common structure for clkdev. Now
clkdev is only
designed for deeply machine depend.

>From my view is that we need a common structure for clkdev. Then mfd driver can
get benefit from this. Some client driver can be written as regulator
platform device.
And mfd driver can use them seamless. What's your opinion?

Best Regards
Haojian

2011-05-14 19:41:11

by Russell King - ARM Linux

[permalink] [raw]
Subject: Re: [PATCH 06/14] mfd: pxa-w1: MFD driver for PXA 1wire control + DS1WM chip

On Sat, May 14, 2011 at 10:21:25PM +0800, Haojian Zhuang wrote:
> But the key issue is that there's no common structure for clkdev. Now
> clkdev is only designed for deeply machine depend.
>
> >From my view is that we need a common structure for clkdev.

You mean struct clk.

As I said on our call on Thursday, everyone knows this, and it's
something that has been worked on for the last year. Concensus had
been reached and everyone had settled on a proposal, and just when
we were almost ready to merge it, the concensus fell apart again.

As a result of that, a common struct clk has been delayed - it's not
going to be in place for 2.6.40 (three months) but maybe we can reach
concensus again for the .41 merge window.

As I also said, this issue was talked about in a session at the Linaro
conference, and it will be interesting to hear what the result of that
session was. At the moment, I'm entirely out of the loop on many things
that were discussed there (except for a message from tglx.)

2011-05-14 22:23:57

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH 06/14] mfd: pxa-w1: MFD driver for PXA 1wire control + DS1WM chip

On Sat, May 14, 2011 at 08:40:17PM +0100, Russell King - ARM Linux wrote:

> As I also said, this issue was talked about in a session at the Linaro
> conference, and it will be interesting to hear what the result of that
> session was. At the moment, I'm entirely out of the loop on many things
> that were discussed there (except for a message from tglx.)

Everything should have had some live noted minutes linked off this site:

http://summit.ubuntu.com/uds-o/

probably everything interesting is on this page:

http://summit.ubuntu.com/uds-o/track/linaro-kernel/

(in etherpad, you want the icon that looks a bit like a notepad on the
left of the box in the talk). They won't always be accurate as they
were done live and not 100% reviewed but might be helpful.

Several people had actions to bring things to the list so I'd expect to
see some more digested mails hitting in the next week or two.

2011-05-22 20:00:38

by Samuel Ortiz

[permalink] [raw]
Subject: Re: [PATCH 06/14] mfd: pxa-w1: MFD driver for PXA 1wire control + DS1WM chip

Hi Haojian,

On Sat, May 14, 2011 at 10:21:25PM +0800, Haojian Zhuang wrote:
> On Tue, Apr 26, 2011 at 5:48 PM, Samuel Ortiz <[email protected]> wrote:
> > Hi Haojian,
> >
> > On Mon, Apr 18, 2011 at 10:04:03PM +0800, Haojian Zhuang wrote:
> >> This driver provides registers and IRQ of PXA3xx chips to the ds1wm driver.
> > I see why this is needed, but I really think the ds1wm driver should be
> > converted to a regular platform device. The MFD driver below is just adding a
> > useless middle layer between your platform code and the ds1wm one.
> >
> I'm OK to use the regulator platform device for ds1wm driver except
> for one concern.
> ds1wm driver is designed for mfd cell driver. I need to update it as
> regulator platform
> driver first. cell->enable() / cell->disable() is used to enable clock
> for ds1wm driver.
> So I need to change the API from cell->enable/disable to clk_enable()
> / clk_disable().
>
> But the key issue is that there's no common structure for clkdev. Now
> clkdev is only
> designed for deeply machine depend.
>
> From my view is that we need a common structure for clkdev. Then mfd driver can
> get benefit from this. Some client driver can be written as regulator
> platform device.
> And mfd driver can use them seamless. What's your opinion?
I may be missing your point, but what is preventing you from calling the clock
API from drivers/w1/masters/ds1wm.c, the same way you're calling it from this
patch ?

Cheers,
Samuel.

--
Intel Open Source Technology Centre
http://oss.intel.com/