linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/6] fix PASIC3/DS1WM, use MFD core
@ 2009-02-05 16:53 Philipp Zabel
  2009-02-05 16:53 ` [PATCH 1/6] mfd: DS1WM: convert to " Philipp Zabel
                   ` (7 more replies)
  0 siblings, 8 replies; 10+ messages in thread
From: Philipp Zabel @ 2009-02-05 16:53 UTC (permalink / raw)
  To: linux-kernel; +Cc: Samuel Ortiz, Evgeniy Polyakov, Matt Reimer

Hi,

the following patches turn DS1WM into an MFD cell driver, make PASIC3 use 
the MFD core functions to register it and remove the generic clock API
code from DS1WM as MFDs currently can't register their clocks with it.
With those applied, 1-Wire is finally in a working state on magician.

Patch #2 depends on #1, patch #4 depends on #3 and patch #6 depends on #5.
Therefor I propose that this whole patchset be queued in the mfd tree.
If so, #4 could be merged into #2. But it won't hurt to just leave out 
#3 and #4 for now and apply them as cleanups later.

Philipp Zabel (6):
      mfd: DS1WM: convert to use MFD core
      mfd: PASIC3: convert to use MFD core
      pxa/magician: remove deprecated .bus_shift from PASIC3 platform_data
      mfd: PASIC3: remove unused bus_shift field
      mfd: DS1WM: remove clock handling
      mfd: PASIC3: supply clock_rate to DS1WM via driver_data

 arch/arm/mach-pxa/magician.c   |    1 -
 drivers/mfd/Kconfig            |    1 +
 drivers/mfd/htc-pasic3.c       |  169 ++++++++++++++++------------------------
 drivers/w1/masters/ds1wm.c     |   53 ++++++-------
 include/linux/ds1wm.h          |   12 ---
 include/linux/mfd/ds1wm.h      |    6 ++
 include/linux/mfd/htc-pasic3.h |    1 -
 7 files changed, 100 insertions(+), 143 deletions(-)
 delete mode 100644 include/linux/ds1wm.h
 create mode 100644 include/linux/mfd/ds1wm.h

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

* [PATCH 1/6] mfd: DS1WM: convert to use MFD core
  2009-02-05 16:53 [PATCH 0/6] fix PASIC3/DS1WM, use MFD core Philipp Zabel
@ 2009-02-05 16:53 ` Philipp Zabel
  2009-02-05 16:53 ` [PATCH 2/6] mfd: PASIC3: " Philipp Zabel
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Philipp Zabel @ 2009-02-05 16:53 UTC (permalink / raw)
  To: linux-kernel; +Cc: Samuel Ortiz, Evgeniy Polyakov, Matt Reimer, Philipp Zabel

This patch converts the DS1WM driver into an MFD cell. It also
calculates the bus_shift parameter from the memory resource size.

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
---
 drivers/w1/masters/ds1wm.c |   31 ++++++++++++++++++++-----------
 include/linux/ds1wm.h      |   12 ------------
 include/linux/mfd/ds1wm.h  |    5 +++++
 3 files changed, 25 insertions(+), 23 deletions(-)
 delete mode 100644 include/linux/ds1wm.h
 create mode 100644 include/linux/mfd/ds1wm.h

diff --git a/drivers/w1/masters/ds1wm.c b/drivers/w1/masters/ds1wm.c
index 29e144f..f1e6b3d 100644
--- a/drivers/w1/masters/ds1wm.c
+++ b/drivers/w1/masters/ds1wm.c
@@ -19,7 +19,8 @@
 #include <linux/clk.h>
 #include <linux/err.h>
 #include <linux/delay.h>
-#include <linux/ds1wm.h>
+#include <linux/mfd/core.h>
+#include <linux/mfd/ds1wm.h>
 
 #include <asm/io.h>
 
@@ -89,7 +90,7 @@ struct ds1wm_data {
 	void		__iomem *map;
 	int		bus_shift; /* # of shifts to calc register offsets */
 	struct platform_device *pdev;
-	struct ds1wm_platform_data *pdata;
+	struct mfd_cell	*cell;
 	int		irq;
 	int		active_high;
 	struct clk	*clk;
@@ -217,8 +218,8 @@ static void ds1wm_up(struct ds1wm_data *ds1wm_data)
 {
 	int gclk, divisor;
 
-	if (ds1wm_data->pdata->enable)
-		ds1wm_data->pdata->enable(ds1wm_data->pdev);
+	if (ds1wm_data->cell->enable)
+		ds1wm_data->cell->enable(ds1wm_data->pdev);
 
 	gclk = clk_get_rate(ds1wm_data->clk);
 	clk_enable(ds1wm_data->clk);
@@ -244,8 +245,8 @@ static void ds1wm_down(struct ds1wm_data *ds1wm_data)
 	ds1wm_write_register(ds1wm_data, DS1WM_INT_EN,
 			     ds1wm_data->active_high ? DS1WM_INTEN_IAS : 0);
 
-	if (ds1wm_data->pdata->disable)
-		ds1wm_data->pdata->disable(ds1wm_data->pdev);
+	if (ds1wm_data->cell->disable)
+		ds1wm_data->cell->disable(ds1wm_data->pdev);
 
 	clk_disable(ds1wm_data->clk);
 }
@@ -330,13 +331,18 @@ static struct w1_bus_master ds1wm_master = {
 static int ds1wm_probe(struct platform_device *pdev)
 {
 	struct ds1wm_data *ds1wm_data;
-	struct ds1wm_platform_data *plat;
+	struct ds1wm_driver_data *plat;
 	struct resource *res;
+	struct mfd_cell *cell;
 	int ret;
 
 	if (!pdev)
 		return -ENODEV;
 
+	cell = pdev->dev.platform_data;
+	if (!cell)
+		return -ENODEV;
+
 	ds1wm_data = kzalloc(sizeof(*ds1wm_data), GFP_KERNEL);
 	if (!ds1wm_data)
 		return -ENOMEM;
@@ -348,15 +354,18 @@ static int ds1wm_probe(struct platform_device *pdev)
 		ret = -ENXIO;
 		goto err0;
 	}
-	ds1wm_data->map = ioremap(res->start, res->end - res->start + 1);
+	ds1wm_data->map = ioremap(res->start, resource_size(res));
 	if (!ds1wm_data->map) {
 		ret = -ENOMEM;
 		goto err0;
 	}
-	plat = pdev->dev.platform_data;
-	ds1wm_data->bus_shift = plat->bus_shift;
+	plat = cell->driver_data;
+
+	/* calculate bus shift from mem resource */
+	ds1wm_data->bus_shift = resource_size(res) >> 3;
+
 	ds1wm_data->pdev = pdev;
-	ds1wm_data->pdata = plat;
+	ds1wm_data->cell = cell;
 
 	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
 	if (!res) {
diff --git a/include/linux/ds1wm.h b/include/linux/ds1wm.h
deleted file mode 100644
index d3c65e4..0000000
--- a/include/linux/ds1wm.h
+++ /dev/null
@@ -1,12 +0,0 @@
-/* platform data for the DS1WM driver */
-
-struct ds1wm_platform_data {
-	int bus_shift;	    /* number of shifts needed to calculate the
-			     * offset between DS1WM registers;
-			     * e.g. on h5xxx and h2200 this is 2
-			     * (registers aligned to 4-byte boundaries),
-			     * while on hx4700 this is 1 */
-	int active_high;
-	void (*enable)(struct platform_device *pdev);
-	void (*disable)(struct platform_device *pdev);
-};
diff --git a/include/linux/mfd/ds1wm.h b/include/linux/mfd/ds1wm.h
new file mode 100644
index 0000000..d4898ba
--- /dev/null
+++ b/include/linux/mfd/ds1wm.h
@@ -0,0 +1,5 @@
+/* MFD cell driver data for the DS1WM driver */
+
+struct ds1wm_driver_data {
+	int active_high;
+};
-- 
1.5.6.5


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

* [PATCH 2/6] mfd: PASIC3: convert to use MFD core
  2009-02-05 16:53 [PATCH 0/6] fix PASIC3/DS1WM, use MFD core Philipp Zabel
  2009-02-05 16:53 ` [PATCH 1/6] mfd: DS1WM: convert to " Philipp Zabel
@ 2009-02-05 16:53 ` Philipp Zabel
  2009-02-05 16:53 ` [PATCH 3/6] pxa/magician: remove deprecated .bus_shift from PASIC3 platform_data Philipp Zabel
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Philipp Zabel @ 2009-02-05 16:53 UTC (permalink / raw)
  To: linux-kernel; +Cc: Samuel Ortiz, Evgeniy Polyakov, Matt Reimer, Philipp Zabel

This patch makes htc-pasic3 register the DS1WM and LED cell drivers
through the MFD core infrastructure instead of allocating the platform
devices manually. It also calculates the bus_shift parameter from the
memory resource size.

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
---
 drivers/mfd/Kconfig      |    1 +
 drivers/mfd/htc-pasic3.c |  159 ++++++++++++++++++----------------------------
 2 files changed, 62 insertions(+), 98 deletions(-)

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 06a2b0f..da2d4c5 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -52,6 +52,7 @@ config HTC_EGPIO
 
 config HTC_PASIC3
 	tristate "HTC PASIC3 LED/DS1WM chip support"
+	select MFD_CORE
 	help
 	  This core driver provides register access for the LED/DS1WM
 	  chips labeled "AIC2" and "AIC3", found on HTC Blueangel and
diff --git a/drivers/mfd/htc-pasic3.c b/drivers/mfd/htc-pasic3.c
index 91b294d..92b6837 100644
--- a/drivers/mfd/htc-pasic3.c
+++ b/drivers/mfd/htc-pasic3.c
@@ -12,18 +12,17 @@
 #include <linux/module.h>
 #include <linux/platform_device.h>
 
-#include <linux/ds1wm.h>
 #include <linux/gpio.h>
 #include <linux/io.h>
 #include <linux/irq.h>
 #include <linux/interrupt.h>
+#include <linux/mfd/core.h>
+#include <linux/mfd/ds1wm.h>
 #include <linux/mfd/htc-pasic3.h>
 
 struct pasic3_data {
 	void __iomem *mapping;
 	unsigned int bus_shift;
-	struct platform_device *ds1wm_pdev;
-	struct platform_device *led_pdev;
 };
 
 #define REG_ADDR  5
@@ -65,46 +64,15 @@ EXPORT_SYMBOL(pasic3_read_register); /* for leds-pasic3 */
  * LEDs
  */
 
-static int led_device_add(struct device *pasic3_dev,
-				const struct pasic3_leds_machinfo *pdata)
-{
-	struct pasic3_data *asic = pasic3_dev->driver_data;
-	struct platform_device *pdev;
-	int ret;
-
-	pdev = platform_device_alloc("pasic3-led", -1);
-	if (!pdev) {
-		dev_dbg(pasic3_dev, "failed to allocate LED platform device\n");
-		return -ENOMEM;
-	}
-
-	ret = platform_device_add_data(pdev, pdata,
-					sizeof(struct pasic3_leds_machinfo));
-	if (ret < 0) {
-		dev_dbg(pasic3_dev, "failed to add LED platform data\n");
-		goto exit_pdev_put;
-	}
-
-	pdev->dev.parent = pasic3_dev;
-	ret = platform_device_add(pdev);
-	if (ret < 0) {
-		dev_dbg(pasic3_dev, "failed to add LED platform device\n");
-		goto exit_pdev_put;
-	}
-
-	asic->led_pdev = pdev;
-	return 0;
-
-exit_pdev_put:
-	platform_device_put(pdev);
-	return ret;
-}
+static struct mfd_cell led_cell __initdata = {
+	.name = "leds-pasic3",
+};
 
 /*
  * DS1WM
  */
 
-static void ds1wm_enable(struct platform_device *pdev)
+static int ds1wm_enable(struct platform_device *pdev)
 {
 	struct device *dev = pdev->dev.parent;
 	int c;
@@ -113,9 +81,10 @@ static void ds1wm_enable(struct platform_device *pdev)
 	pasic3_write_register(dev, 0x28, c & 0x7f);
 
 	dev_dbg(dev, "DS1WM OWM_EN low (active) %02x\n", c & 0x7f);
+	return 0;
 }
 
-static void ds1wm_disable(struct platform_device *pdev)
+static int ds1wm_disable(struct platform_device *pdev)
 {
 	struct device *dev = pdev->dev.parent;
 	int c;
@@ -124,56 +93,33 @@ static void ds1wm_disable(struct platform_device *pdev)
 	pasic3_write_register(dev, 0x28, c | 0x80);
 
 	dev_dbg(dev, "DS1WM OWM_EN high (inactive) %02x\n", c | 0x80);
+	return 0;
 }
 
-static struct ds1wm_platform_data ds1wm_pdata = {
-	.bus_shift = 2,
-	.enable    = ds1wm_enable,
-	.disable   = ds1wm_disable,
+static struct ds1wm_driver_data ds1wm_pdata = {
+	.active_high = 0,
 };
 
-static int ds1wm_device_add(struct platform_device *pasic3_pdev, int bus_shift)
-{
-	struct device *pasic3_dev = &pasic3_pdev->dev;
-	struct pasic3_data *asic = pasic3_dev->driver_data;
-	struct platform_device *pdev;
-	int ret;
-
-	pdev = platform_device_alloc("ds1wm", -1);
-	if (!pdev) {
-		dev_dbg(pasic3_dev, "failed to allocate DS1WM platform device\n");
-		return -ENOMEM;
-	}
-
-	ret = platform_device_add_resources(pdev, pasic3_pdev->resource,
-						pasic3_pdev->num_resources);
-	if (ret < 0) {
-		dev_dbg(pasic3_dev, "failed to add DS1WM resources\n");
-		goto exit_pdev_put;
-	}
-
-	ds1wm_pdata.bus_shift = asic->bus_shift;
-	ret = platform_device_add_data(pdev, &ds1wm_pdata,
-					sizeof(struct ds1wm_platform_data));
-	if (ret < 0) {
-		dev_dbg(pasic3_dev, "failed to add DS1WM platform data\n");
-		goto exit_pdev_put;
-	}
-
-	pdev->dev.parent = pasic3_dev;
-	ret = platform_device_add(pdev);
-	if (ret < 0) {
-		dev_dbg(pasic3_dev, "failed to add DS1WM platform device\n");
-		goto exit_pdev_put;
-	}
-
-	asic->ds1wm_pdev = pdev;
-	return 0;
+static struct resource ds1wm_resources[] __initdata = {
+	[0] = {
+		.start  = 0,
+		.flags  = IORESOURCE_MEM,
+	},
+	[1] = {
+		.start  = 0,
+		.end    = 0,
+		.flags  = IORESOURCE_IRQ,
+	},
+};
 
-exit_pdev_put:
-	platform_device_put(pdev);
-	return ret;
-}
+static struct mfd_cell ds1wm_cell __initdata = {
+	.name          = "ds1wm",
+	.enable        = ds1wm_enable,
+	.disable       = ds1wm_disable,
+	.driver_data   = &ds1wm_pdata,
+	.num_resources = 2,
+	.resources     = ds1wm_resources,
+};
 
 static int __init pasic3_probe(struct platform_device *pdev)
 {
@@ -182,12 +128,27 @@ static int __init pasic3_probe(struct platform_device *pdev)
 	struct pasic3_data *asic;
 	struct resource *r;
 	int ret;
+	int irq = 0;
+
+	r = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+	if (r) {
+		ds1wm_resources[1].flags = IORESOURCE_IRQ | (r->flags &
+			(IORESOURCE_IRQ_HIGHEDGE | IORESOURCE_IRQ_LOWEDGE));
+		irq = r->start;
+	}
+
+	r = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+	if (r) {
+		ds1wm_resources[1].flags = IORESOURCE_IRQ | (r->flags &
+			(IORESOURCE_IRQ_HIGHEDGE | IORESOURCE_IRQ_LOWEDGE));
+		irq = r->start;
+	}
 
 	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!r)
 		return -ENXIO;
 
-	if (!request_mem_region(r->start, r->end - r->start + 1, "pasic3"))
+	if (!request_mem_region(r->start, resource_size(r), "pasic3"))
 		return -EBUSY;
 
 	asic = kzalloc(sizeof(struct pasic3_data), GFP_KERNEL);
@@ -196,24 +157,29 @@ static int __init pasic3_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, asic);
 
-	if (pdata && pdata->bus_shift)
-		asic->bus_shift = pdata->bus_shift;
-	else
-		asic->bus_shift = 2;
-
-	asic->mapping = ioremap(r->start, r->end - r->start + 1);
+	asic->mapping = ioremap(r->start, resource_size(r));
 	if (!asic->mapping) {
 		dev_err(dev, "couldn't ioremap PASIC3\n");
 		kfree(asic);
 		return -ENOMEM;
 	}
 
-	ret = ds1wm_device_add(pdev, asic->bus_shift);
+	/* calculate bus shift from mem resource */
+	asic->bus_shift = (resource_size(r) - 5) >> 3;
+
+	/* the first 5 PASIC3 registers control the DS1WM */
+	ds1wm_resources[0].end = (5 << asic->bus_shift) - 1;
+	ds1wm_cell.platform_data = &ds1wm_cell;
+	ds1wm_cell.data_size = sizeof(ds1wm_cell);
+	ret = mfd_add_devices(&pdev->dev, pdev->id, &ds1wm_cell, 1, r, irq);
 	if (ret < 0)
 		dev_warn(dev, "failed to register DS1WM\n");
 
 	if (pdata->led_pdata) {
-		ret = led_device_add(dev, pdata->led_pdata);
+		led_cell.driver_data = pdata->led_pdata;
+		led_cell.platform_data = &led_cell;
+		led_cell.data_size = sizeof(ds1wm_cell);
+		ret = mfd_add_devices(&pdev->dev, pdev->id, &led_cell, 1, r, 0);
 		if (ret < 0)
 			dev_warn(dev, "failed to register LED device\n");
 	}
@@ -226,14 +192,11 @@ static int pasic3_remove(struct platform_device *pdev)
 	struct pasic3_data *asic = platform_get_drvdata(pdev);
 	struct resource *r;
 
-	if (asic->led_pdev)
-		platform_device_unregister(asic->led_pdev);
-	if (asic->ds1wm_pdev)
-		platform_device_unregister(asic->ds1wm_pdev);
+	mfd_remove_devices(&pdev->dev);
 
 	iounmap(asic->mapping);
 	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	release_mem_region(r->start, r->end - r->start + 1);
+	release_mem_region(r->start, resource_size(r));
 	kfree(asic);
 	return 0;
 }
-- 
1.5.6.5


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

* [PATCH 3/6] pxa/magician: remove deprecated .bus_shift from PASIC3 platform_data
  2009-02-05 16:53 [PATCH 0/6] fix PASIC3/DS1WM, use MFD core Philipp Zabel
  2009-02-05 16:53 ` [PATCH 1/6] mfd: DS1WM: convert to " Philipp Zabel
  2009-02-05 16:53 ` [PATCH 2/6] mfd: PASIC3: " Philipp Zabel
@ 2009-02-05 16:53 ` Philipp Zabel
  2009-02-05 16:53 ` [PATCH 4/6] mfd: PASIC3: remove unused bus_shift field Philipp Zabel
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Philipp Zabel @ 2009-02-05 16:53 UTC (permalink / raw)
  To: linux-kernel; +Cc: Samuel Ortiz, Evgeniy Polyakov, Matt Reimer, Philipp Zabel

The PASIC3 driver now calculates its register spacing from the resource
size.

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
---
 arch/arm/mach-pxa/magician.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-pxa/magician.c b/arch/arm/mach-pxa/magician.c
index 21b821e..8e21181 100644
--- a/arch/arm/mach-pxa/magician.c
+++ b/arch/arm/mach-pxa/magician.c
@@ -495,7 +495,6 @@ static struct resource pasic3_resources[] = {
 };
 
 static struct pasic3_platform_data pasic3_platform_data = {
-	.bus_shift  = 2,
 	.led_pdata  = &pasic3_leds_info,
 	.clock_rate = 4000000,
 };
-- 
1.5.6.5


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

* [PATCH 4/6] mfd: PASIC3: remove unused bus_shift field
  2009-02-05 16:53 [PATCH 0/6] fix PASIC3/DS1WM, use MFD core Philipp Zabel
                   ` (2 preceding siblings ...)
  2009-02-05 16:53 ` [PATCH 3/6] pxa/magician: remove deprecated .bus_shift from PASIC3 platform_data Philipp Zabel
@ 2009-02-05 16:53 ` Philipp Zabel
  2009-02-05 16:53 ` [PATCH 5/6] mfd: DS1WM: remove clock handling Philipp Zabel
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Philipp Zabel @ 2009-02-05 16:53 UTC (permalink / raw)
  To: linux-kernel; +Cc: Samuel Ortiz, Evgeniy Polyakov, Matt Reimer, Philipp Zabel

Removes the now-unused bus_shift field from pasic3_platform_data.

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
---
 include/linux/mfd/htc-pasic3.h |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/include/linux/mfd/htc-pasic3.h b/include/linux/mfd/htc-pasic3.h
index b4294f1..3d3ed67 100644
--- a/include/linux/mfd/htc-pasic3.h
+++ b/include/linux/mfd/htc-pasic3.h
@@ -48,7 +48,6 @@ struct pasic3_leds_machinfo {
 
 struct pasic3_platform_data {
 	struct pasic3_leds_machinfo *led_pdata;
-	unsigned int                 bus_shift;
 	unsigned int                 clock_rate;
 };
 
-- 
1.5.6.5


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

* [PATCH 5/6] mfd: DS1WM: remove clock handling
  2009-02-05 16:53 [PATCH 0/6] fix PASIC3/DS1WM, use MFD core Philipp Zabel
                   ` (3 preceding siblings ...)
  2009-02-05 16:53 ` [PATCH 4/6] mfd: PASIC3: remove unused bus_shift field Philipp Zabel
@ 2009-02-05 16:53 ` Philipp Zabel
  2009-02-06 16:31   ` [PATCH] mfd: DS1WM: remove warning about unused label err2 Philipp Zabel
  2009-02-05 16:53 ` [PATCH 6/6] mfd: PASIC3: supply clock_rate to DS1WM via driver_data Philipp Zabel
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 10+ messages in thread
From: Philipp Zabel @ 2009-02-05 16:53 UTC (permalink / raw)
  To: linux-kernel; +Cc: Samuel Ortiz, Evgeniy Polyakov, Matt Reimer, Philipp Zabel

This driver requests a clock that usually is supplied by the MFD in which
the DS1WM is contained. Currently, it is impossible for a MFD to register
their clocks with the generic clock API due to different implementations
across architectures.
For now, this patch removes the clock handling from DS1WM altogether,
trusting that the MFD enable/disable functions will switch the clock if
needed. The clock rate is obtained from a new parameter in driver_data.

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
---
 drivers/w1/masters/ds1wm.c |   22 +++++-----------------
 include/linux/mfd/ds1wm.h  |    1 +
 2 files changed, 6 insertions(+), 17 deletions(-)

diff --git a/drivers/w1/masters/ds1wm.c b/drivers/w1/masters/ds1wm.c
index f1e6b3d..b982aa6 100644
--- a/drivers/w1/masters/ds1wm.c
+++ b/drivers/w1/masters/ds1wm.c
@@ -16,7 +16,6 @@
 #include <linux/irq.h>
 #include <linux/pm.h>
 #include <linux/platform_device.h>
-#include <linux/clk.h>
 #include <linux/err.h>
 #include <linux/delay.h>
 #include <linux/mfd/core.h>
@@ -93,7 +92,6 @@ struct ds1wm_data {
 	struct mfd_cell	*cell;
 	int		irq;
 	int		active_high;
-	struct clk	*clk;
 	int		slave_present;
 	void		*reset_complete;
 	void		*read_complete;
@@ -216,17 +214,17 @@ static int ds1wm_find_divisor(int gclk)
 
 static void ds1wm_up(struct ds1wm_data *ds1wm_data)
 {
-	int gclk, divisor;
+	int divisor;
+	struct ds1wm_driver_data *plat = ds1wm_data->cell->driver_data;
 
 	if (ds1wm_data->cell->enable)
 		ds1wm_data->cell->enable(ds1wm_data->pdev);
 
-	gclk = clk_get_rate(ds1wm_data->clk);
-	clk_enable(ds1wm_data->clk);
-	divisor = ds1wm_find_divisor(gclk);
+	divisor = ds1wm_find_divisor(plat->clock_rate);
 	if (divisor == 0) {
 		dev_err(&ds1wm_data->pdev->dev,
-			"no suitable divisor for %dHz clock\n", gclk);
+			"no suitable divisor for %dHz clock\n",
+			plat->clock_rate);
 		return;
 	}
 	ds1wm_write_register(ds1wm_data, DS1WM_CLKDIV, divisor);
@@ -247,8 +245,6 @@ static void ds1wm_down(struct ds1wm_data *ds1wm_data)
 
 	if (ds1wm_data->cell->disable)
 		ds1wm_data->cell->disable(ds1wm_data->pdev);
-
-	clk_disable(ds1wm_data->clk);
 }
 
 /* --------------------------------------------------------------------- */
@@ -385,12 +381,6 @@ static int ds1wm_probe(struct platform_device *pdev)
 	if (ret)
 		goto err1;
 
-	ds1wm_data->clk = clk_get(&pdev->dev, "ds1wm");
-	if (IS_ERR(ds1wm_data->clk)) {
-		ret = PTR_ERR(ds1wm_data->clk);
-		goto err2;
-	}
-
 	ds1wm_up(ds1wm_data);
 
 	ds1wm_master.data = (void *)ds1wm_data;
@@ -403,7 +393,6 @@ static int ds1wm_probe(struct platform_device *pdev)
 
 err3:
 	ds1wm_down(ds1wm_data);
-	clk_put(ds1wm_data->clk);
 err2:
 	free_irq(ds1wm_data->irq, ds1wm_data);
 err1:
@@ -443,7 +432,6 @@ static int ds1wm_remove(struct platform_device *pdev)
 
 	w1_remove_master_device(&ds1wm_master);
 	ds1wm_down(ds1wm_data);
-	clk_put(ds1wm_data->clk);
 	free_irq(ds1wm_data->irq, ds1wm_data);
 	iounmap(ds1wm_data->map);
 	kfree(ds1wm_data);
diff --git a/include/linux/mfd/ds1wm.h b/include/linux/mfd/ds1wm.h
index d4898ba..be469a3 100644
--- a/include/linux/mfd/ds1wm.h
+++ b/include/linux/mfd/ds1wm.h
@@ -2,4 +2,5 @@
 
 struct ds1wm_driver_data {
 	int active_high;
+	int clock_rate;
 };
-- 
1.5.6.5


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

* [PATCH 6/6] mfd: PASIC3: supply clock_rate to DS1WM via driver_data
  2009-02-05 16:53 [PATCH 0/6] fix PASIC3/DS1WM, use MFD core Philipp Zabel
                   ` (4 preceding siblings ...)
  2009-02-05 16:53 ` [PATCH 5/6] mfd: DS1WM: remove clock handling Philipp Zabel
@ 2009-02-05 16:53 ` Philipp Zabel
  2009-02-05 21:14 ` [PATCH 0/6] fix PASIC3/DS1WM, use MFD core Evgeniy Polyakov
  2009-02-06 14:16 ` Samuel Ortiz
  7 siblings, 0 replies; 10+ messages in thread
From: Philipp Zabel @ 2009-02-05 16:53 UTC (permalink / raw)
  To: linux-kernel; +Cc: Samuel Ortiz, Evgeniy Polyakov, Matt Reimer, Philipp Zabel

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
---
 drivers/mfd/htc-pasic3.c |   22 +++++++++++++---------
 1 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/drivers/mfd/htc-pasic3.c b/drivers/mfd/htc-pasic3.c
index 92b6837..386da15 100644
--- a/drivers/mfd/htc-pasic3.c
+++ b/drivers/mfd/htc-pasic3.c
@@ -167,15 +167,19 @@ static int __init pasic3_probe(struct platform_device *pdev)
 	/* calculate bus shift from mem resource */
 	asic->bus_shift = (resource_size(r) - 5) >> 3;
 
-	/* the first 5 PASIC3 registers control the DS1WM */
-	ds1wm_resources[0].end = (5 << asic->bus_shift) - 1;
-	ds1wm_cell.platform_data = &ds1wm_cell;
-	ds1wm_cell.data_size = sizeof(ds1wm_cell);
-	ret = mfd_add_devices(&pdev->dev, pdev->id, &ds1wm_cell, 1, r, irq);
-	if (ret < 0)
-		dev_warn(dev, "failed to register DS1WM\n");
-
-	if (pdata->led_pdata) {
+	if (pdata && pdata->clock_rate) {
+		ds1wm_pdata.clock_rate = pdata->clock_rate;
+		/* the first 5 PASIC3 registers control the DS1WM */
+		ds1wm_resources[0].end = (5 << asic->bus_shift) - 1;
+		ds1wm_cell.platform_data = &ds1wm_cell;
+		ds1wm_cell.data_size = sizeof(ds1wm_cell);
+		ret = mfd_add_devices(&pdev->dev, pdev->id,
+				&ds1wm_cell, 1, r, irq);
+		if (ret < 0)
+			dev_warn(dev, "failed to register DS1WM\n");
+	}
+
+	if (pdata && pdata->led_pdata) {
 		led_cell.driver_data = pdata->led_pdata;
 		led_cell.platform_data = &led_cell;
 		led_cell.data_size = sizeof(ds1wm_cell);
-- 
1.5.6.5


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

* Re: [PATCH 0/6] fix PASIC3/DS1WM, use MFD core
  2009-02-05 16:53 [PATCH 0/6] fix PASIC3/DS1WM, use MFD core Philipp Zabel
                   ` (5 preceding siblings ...)
  2009-02-05 16:53 ` [PATCH 6/6] mfd: PASIC3: supply clock_rate to DS1WM via driver_data Philipp Zabel
@ 2009-02-05 21:14 ` Evgeniy Polyakov
  2009-02-06 14:16 ` Samuel Ortiz
  7 siblings, 0 replies; 10+ messages in thread
From: Evgeniy Polyakov @ 2009-02-05 21:14 UTC (permalink / raw)
  To: Philipp Zabel; +Cc: linux-kernel, Samuel Ortiz, Matt Reimer

Hi Philipp.

On Thu, Feb 05, 2009 at 05:53:34PM +0100, Philipp Zabel (philipp.zabel@gmail.com) wrote:
> the following patches turn DS1WM into an MFD cell driver, make PASIC3 use 
> the MFD core functions to register it and remove the generic clock API
> code from DS1WM as MFDs currently can't register their clocks with it.
> With those applied, 1-Wire is finally in a working state on magician.

Looks good. Feel free to add my ack if needed.
Drop a mail if you want to me to push it upstream separately from the
core part it depends on.

-- 
	Evgeniy Polyakov

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

* Re: [PATCH 0/6] fix PASIC3/DS1WM, use MFD core
  2009-02-05 16:53 [PATCH 0/6] fix PASIC3/DS1WM, use MFD core Philipp Zabel
                   ` (6 preceding siblings ...)
  2009-02-05 21:14 ` [PATCH 0/6] fix PASIC3/DS1WM, use MFD core Evgeniy Polyakov
@ 2009-02-06 14:16 ` Samuel Ortiz
  7 siblings, 0 replies; 10+ messages in thread
From: Samuel Ortiz @ 2009-02-06 14:16 UTC (permalink / raw)
  To: Philipp Zabel; +Cc: linux-kernel, Evgeniy Polyakov, Matt Reimer

Hi Philipp,

On Thu, Feb 05, 2009 at 05:53:34PM +0100, Philipp Zabel wrote:
> Hi,
> 
> the following patches turn DS1WM into an MFD cell driver, make PASIC3 use 
> the MFD core functions to register it and remove the generic clock API
> code from DS1WM as MFDs currently can't register their clocks with it.
> With those applied, 1-Wire is finally in a working state on magician.
> 
> Patch #2 depends on #1, patch #4 depends on #3 and patch #6 depends on #5.
> Therefor I propose that this whole patchset be queued in the mfd tree.
> If so, #4 could be merged into #2. But it won't hurt to just leave out 
> #3 and #4 for now and apply them as cleanups later.
The patches look good to me. I'll merge the 6 of them into my for-next branch.

Thanks for this work.

Cheers,
Samuel.


> Philipp Zabel (6):
>       mfd: DS1WM: convert to use MFD core
>       mfd: PASIC3: convert to use MFD core
>       pxa/magician: remove deprecated .bus_shift from PASIC3 platform_data
>       mfd: PASIC3: remove unused bus_shift field
>       mfd: DS1WM: remove clock handling
>       mfd: PASIC3: supply clock_rate to DS1WM via driver_data
> 
>  arch/arm/mach-pxa/magician.c   |    1 -
>  drivers/mfd/Kconfig            |    1 +
>  drivers/mfd/htc-pasic3.c       |  169 ++++++++++++++++------------------------
>  drivers/w1/masters/ds1wm.c     |   53 ++++++-------
>  include/linux/ds1wm.h          |   12 ---
>  include/linux/mfd/ds1wm.h      |    6 ++
>  include/linux/mfd/htc-pasic3.h |    1 -
>  7 files changed, 100 insertions(+), 143 deletions(-)
>  delete mode 100644 include/linux/ds1wm.h
>  create mode 100644 include/linux/mfd/ds1wm.h

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

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

* [PATCH] mfd: DS1WM: remove warning about unused label err2
  2009-02-05 16:53 ` [PATCH 5/6] mfd: DS1WM: remove clock handling Philipp Zabel
@ 2009-02-06 16:31   ` Philipp Zabel
  0 siblings, 0 replies; 10+ messages in thread
From: Philipp Zabel @ 2009-02-06 16:31 UTC (permalink / raw)
  To: Samuel Ortiz; +Cc: linux-kernel, Philipp Zabel

Hi Samuel,

thanks for queuing the patchset. Could you please fold this into the DS1WM clock removal patch? 

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
---
 drivers/w1/masters/ds1wm.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/w1/masters/ds1wm.c b/drivers/w1/masters/ds1wm.c
index b982aa6..37f08c8 100644
--- a/drivers/w1/masters/ds1wm.c
+++ b/drivers/w1/masters/ds1wm.c
@@ -387,13 +387,12 @@ static int ds1wm_probe(struct platform_device *pdev)
 
 	ret = w1_add_master_device(&ds1wm_master);
 	if (ret)
-		goto err3;
+		goto err2;
 
 	return 0;
 
-err3:
-	ds1wm_down(ds1wm_data);
 err2:
+	ds1wm_down(ds1wm_data);
 	free_irq(ds1wm_data->irq, ds1wm_data);
 err1:
 	iounmap(ds1wm_data->map);
-- 
1.5.6.5


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

end of thread, other threads:[~2009-02-06 16:31 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-05 16:53 [PATCH 0/6] fix PASIC3/DS1WM, use MFD core Philipp Zabel
2009-02-05 16:53 ` [PATCH 1/6] mfd: DS1WM: convert to " Philipp Zabel
2009-02-05 16:53 ` [PATCH 2/6] mfd: PASIC3: " Philipp Zabel
2009-02-05 16:53 ` [PATCH 3/6] pxa/magician: remove deprecated .bus_shift from PASIC3 platform_data Philipp Zabel
2009-02-05 16:53 ` [PATCH 4/6] mfd: PASIC3: remove unused bus_shift field Philipp Zabel
2009-02-05 16:53 ` [PATCH 5/6] mfd: DS1WM: remove clock handling Philipp Zabel
2009-02-06 16:31   ` [PATCH] mfd: DS1WM: remove warning about unused label err2 Philipp Zabel
2009-02-05 16:53 ` [PATCH 6/6] mfd: PASIC3: supply clock_rate to DS1WM via driver_data Philipp Zabel
2009-02-05 21:14 ` [PATCH 0/6] fix PASIC3/DS1WM, use MFD core Evgeniy Polyakov
2009-02-06 14:16 ` Samuel Ortiz

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).