All of lore.kernel.org
 help / color / mirror / Atom feed
* collie and SA1100 patches
@ 2009-10-05 21:35 Thomas Kunze
  2009-10-05 21:35 ` [PATCH 1/9] collie: fix scoop convesion to new api Thomas Kunze
                   ` (4 more replies)
  0 siblings, 5 replies; 34+ messages in thread
From: Thomas Kunze @ 2009-10-05 21:35 UTC (permalink / raw)
  To: linux-arm-kernel

Hi all!
   
This patchset implements prober power management for collie. To archieve this
some bugs were fixed and gpiolib-support was added to the ucb1x00 driver.
Please tell me if I should CC some other people or lists.

Regards,
Thomas

Statistics:
 arch/arm/mach-sa1100/collie.c              |   79 +++++-
 arch/arm/mach-sa1100/include/mach/collie.h |   77 +++---
 arch/arm/mach-sa1100/include/mach/gpio.h   |   19 +-
 arch/arm/mach-sa1100/include/mach/mcp.h    |    1 +
 drivers/leds/leds-locomo.c                 |    2 +-
 drivers/mfd/mcp-core.c                     |    2 +-
 drivers/mfd/mcp-sa11x0.c                   |    3 +-
 drivers/mfd/ucb1x00-assabet.c              |    2 +-
 drivers/mfd/ucb1x00-core.c                 |   89 ++++++-
 drivers/mfd/ucb1x00-ts.c                   |    2 +-
 drivers/power/Kconfig                      |    7 +
 drivers/power/Makefile                     |    1 +
 drivers/power/collie_battery.c             |  418 ++++++++++++++++++++++++++++
 {drivers => include/linux}/mfd/mcp.h       |    3 +
 {drivers => include/linux}/mfd/ucb1x00.h   |    7 +-
 15 files changed, 649 insertions(+), 63 deletions(-)
 create mode 100644 drivers/power/collie_battery.c
 rename {drivers => include/linux}/mfd/mcp.h (97%)
 rename {drivers => include/linux}/mfd/ucb1x00.h (98%)

^ permalink raw reply	[flat|nested] 34+ messages in thread
* [PATCH 6/9] add gpiolib support to ucb1x00
@ 2009-02-10 13:50 Thomas Kunze
  0 siblings, 0 replies; 34+ messages in thread
From: Thomas Kunze @ 2009-02-10 13:50 UTC (permalink / raw)
  To: linux-arm-kernel

The old access methods to the gpios will be removed when
all users has been converted. (mainly ucb1x00-ts)

Signed-off-by: Thomas Kunze <thommycheck@gmx.de>
---
 arch/arm/mach-sa1100/include/mach/mcp.h |    1 +
 drivers/mfd/mcp-sa11x0.c                |    1 +
 drivers/mfd/ucb1x00-core.c              |   87 ++++++++++++++++++++++++++++++-
 include/linux/mfd/mcp.h                 |    1 +
 include/linux/mfd/ucb1x00.h             |    3 +
 5 files changed, 91 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-sa1100/include/mach/mcp.h b/arch/arm/mach-sa1100/include/mach/mcp.h
index fb8b09a..ed1a331 100644
--- a/arch/arm/mach-sa1100/include/mach/mcp.h
+++ b/arch/arm/mach-sa1100/include/mach/mcp.h
@@ -16,6 +16,7 @@ struct mcp_plat_data {
 	u32 mccr0;
 	u32 mccr1;
 	unsigned int sclk_rate;
+	int gpio_base;
 };
 
 #endif
diff --git a/drivers/mfd/mcp-sa11x0.c b/drivers/mfd/mcp-sa11x0.c
index 2121898..2584272 100644
--- a/drivers/mfd/mcp-sa11x0.c
+++ b/drivers/mfd/mcp-sa11x0.c
@@ -163,6 +163,7 @@ static int mcp_sa11x0_probe(struct platform_device *pdev)
 	mcp->dma_audio_wr	= DMA_Ser4MCP0Wr;
 	mcp->dma_telco_rd	= DMA_Ser4MCP1Rd;
 	mcp->dma_telco_wr	= DMA_Ser4MCP1Wr;
+	mcp->gpio_base		= data->gpio_base;
 
 	platform_set_drvdata(pdev, mcp);
 
diff --git a/drivers/mfd/ucb1x00-core.c b/drivers/mfd/ucb1x00-core.c
index 61f3933..e0d7700 100644
--- a/drivers/mfd/ucb1x00-core.c
+++ b/drivers/mfd/ucb1x00-core.c
@@ -25,11 +25,11 @@
 #include <linux/device.h>
 #include <linux/mutex.h>
 #include <linux/mfd/ucb1x00.h>
+#include <linux/gpio.h>
 
 #include <mach/dma.h>
 #include <mach/hardware.h>
 
-
 static DEFINE_MUTEX(ucb1x00_mutex);
 static LIST_HEAD(ucb1x00_drivers);
 static LIST_HEAD(ucb1x00_devices);
@@ -107,6 +107,60 @@ unsigned int ucb1x00_io_read(struct ucb1x00 *ucb)
 	return ucb1x00_reg_read(ucb, UCB_IO_DATA);
 }
 
+static void ucb1x00_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
+{
+	struct ucb1x00 *ucb = container_of(chip, struct ucb1x00, gpio);
+	unsigned long flags;
+
+	spin_lock_irqsave(&ucb->io_lock, flags);
+	if (value)
+		ucb->io_out |= 1 << offset;
+	else
+		ucb->io_out &= ~(1 << offset);
+
+	ucb1x00_reg_write(ucb, UCB_IO_DATA, ucb->io_out);
+	spin_unlock_irqrestore(&ucb->io_lock, flags);
+}
+
+static int ucb1x00_gpio_get(struct gpio_chip *chip, unsigned offset)
+{
+	struct ucb1x00 *ucb = container_of(chip, struct ucb1x00, gpio);
+	return ucb1x00_reg_read(ucb, UCB_IO_DATA) & (1 << offset);
+}
+
+static int ucb1x00_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
+{
+	struct ucb1x00 *ucb = container_of(chip, struct ucb1x00, gpio);
+	unsigned long flags;
+
+	spin_lock_irqsave(&ucb->io_lock, flags);
+	ucb->io_dir &= ~(1 << offset);
+	ucb1x00_reg_write(ucb, UCB_IO_DIR, ucb->io_dir);
+	spin_unlock_irqrestore(&ucb->io_lock, flags);
+
+	return 0;
+}
+
+static int ucb1x00_gpio_direction_output(struct gpio_chip *chip, unsigned offset
+		, int value)
+{
+	struct ucb1x00 *ucb = container_of(chip, struct ucb1x00, gpio);
+	unsigned long flags;
+
+	spin_lock_irqsave(&ucb->io_lock, flags);
+	ucb->io_dir |= (1 << offset);
+	ucb1x00_reg_write(ucb, UCB_IO_DIR, ucb->io_dir);
+
+	if (value)
+		ucb->io_out |= 1 << offset;
+	else
+		ucb->io_out &= ~(1 << offset);
+	ucb1x00_reg_write(ucb, UCB_IO_DATA, ucb->io_out);
+	spin_unlock_irqrestore(&ucb->io_lock, flags);
+
+	return 0;
+}
+
 /*
  * UCB1300 data sheet says we must:
  *  1. enable ADC	=> 5us (including reference startup time)
@@ -475,6 +529,7 @@ static int ucb1x00_probe(struct mcp *mcp)
 	struct ucb1x00_driver *drv;
 	unsigned int id;
 	int ret = -ENODEV;
+	int temp;
 
 	mcp_enable(mcp);
 	id = mcp_reg_read(mcp, UCB_ID);
@@ -507,12 +562,27 @@ static int ucb1x00_probe(struct mcp *mcp)
 		goto err_free;
 	}
 
+	ucb->gpio.base = -1;
+	if (mcp->gpio_base != 0) {
+		ucb->gpio.label = dev_name(&ucb->dev);
+		ucb->gpio.base = mcp->gpio_base;
+		ucb->gpio.ngpio = 10;
+		ucb->gpio.set = ucb1x00_gpio_set;
+		ucb->gpio.get = ucb1x00_gpio_get;
+		ucb->gpio.direction_input = ucb1x00_gpio_direction_input;
+		ucb->gpio.direction_output = ucb1x00_gpio_direction_output;
+		ret = gpiochip_add(&ucb->gpio);
+		if (ret)
+			goto err_free;
+	} else
+		dev_info(&ucb->dev, "gpio_base not set so no gpiolib support");
+
 	ret = request_irq(ucb->irq, ucb1x00_irq, IRQF_TRIGGER_RISING,
 			  "UCB1x00", ucb);
 	if (ret) {
 		printk(KERN_ERR "ucb1x00: unable to grab irq%d: %d\n",
 			ucb->irq, ret);
-		goto err_free;
+		goto err_gpio;
 	}
 
 	mcp_set_drvdata(mcp, ucb);
@@ -521,6 +591,7 @@ static int ucb1x00_probe(struct mcp *mcp)
 	if (ret)
 		goto err_irq;
 
+
 	INIT_LIST_HEAD(&ucb->devs);
 	mutex_lock(&ucb1x00_mutex);
 	list_add(&ucb->node, &ucb1x00_devices);
@@ -528,10 +599,14 @@ static int ucb1x00_probe(struct mcp *mcp)
 		ucb1x00_add_dev(ucb, drv);
 	}
 	mutex_unlock(&ucb1x00_mutex);
+
 	goto out;
 
  err_irq:
 	free_irq(ucb->irq, ucb);
+ err_gpio:
+	if (ucb->gpio.base != -1)
+		temp = gpiochip_remove(&ucb->gpio);
  err_free:
 	kfree(ucb);
  err_disable:
@@ -544,6 +619,7 @@ static void ucb1x00_remove(struct mcp *mcp)
 {
 	struct ucb1x00 *ucb = mcp_get_drvdata(mcp);
 	struct list_head *l, *n;
+	int ret;
 
 	mutex_lock(&ucb1x00_mutex);
 	list_del(&ucb->node);
@@ -553,6 +629,12 @@ static void ucb1x00_remove(struct mcp *mcp)
 	}
 	mutex_unlock(&ucb1x00_mutex);
 
+	if (ucb->gpio.base != -1) {
+		ret = gpiochip_remove(&ucb->gpio);
+		if (ret)
+			dev_err(&ucb->dev, "Can't remove gpio chip: %d\n", ret);
+	}
+
 	free_irq(ucb->irq, ucb);
 	device_unregister(&ucb->dev);
 }
@@ -603,6 +685,7 @@ static int ucb1x00_resume(struct mcp *mcp)
 	struct ucb1x00 *ucb = mcp_get_drvdata(mcp);
 	struct ucb1x00_dev *dev;
 
+	ucb1x00_reg_write(ucb, UCB_IO_DIR, ucb->io_dir);
 	mutex_lock(&ucb1x00_mutex);
 	list_for_each_entry(dev, &ucb->devs, dev_node) {
 		if (dev->drv->resume)
diff --git a/include/linux/mfd/mcp.h b/include/linux/mfd/mcp.h
index be95e09..ee49670 100644
--- a/include/linux/mfd/mcp.h
+++ b/include/linux/mfd/mcp.h
@@ -26,6 +26,7 @@ struct mcp {
 	dma_device_t	dma_telco_rd;
 	dma_device_t	dma_telco_wr;
 	struct device	attached_device;
+	int		gpio_base;
 };
 
 struct mcp_ops {
diff --git a/include/linux/mfd/ucb1x00.h b/include/linux/mfd/ucb1x00.h
index eac3463..aa9c378 100644
--- a/include/linux/mfd/ucb1x00.h
+++ b/include/linux/mfd/ucb1x00.h
@@ -11,6 +11,8 @@
 #define UCB1200_H
 
 #include <linux/mfd/mcp.h>
+#include <linux/gpio.h>
+
 #define UCB_IO_DATA	0x00
 #define UCB_IO_DIR	0x01
 
@@ -123,6 +125,7 @@ struct ucb1x00 {
 	struct device		dev;
 	struct list_head	node;
 	struct list_head	devs;
+	struct gpio_chip 	gpio;
 };
 
 struct ucb1x00_driver;
-- 
1.6.0.4


--------------080106070900050803030700--

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

end of thread, other threads:[~2009-11-29 11:44 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-05 21:35 collie and SA1100 patches Thomas Kunze
2009-10-05 21:35 ` [PATCH 1/9] collie: fix scoop convesion to new api Thomas Kunze
2009-10-05 21:35   ` [PATCH 2/9] collie: prepare for gpiolib use Thomas Kunze
2009-10-05 21:35     ` [PATCH 3/9] move drivers/mfd/*.h to include/linux/mfd Thomas Kunze
2009-10-05 21:35       ` [PATCH 4/9] collie: locomo-led change default trigger Thomas Kunze
2009-10-05 21:35         ` [PATCH 5/9] SA1100: make gpio_to_irq and reverse a macro Thomas Kunze
2009-10-05 21:35           ` [PATCH 6/9] add gpiolib support to ucb1x00 Thomas Kunze
2009-10-05 21:35             ` [PATCH 7/9] collie: convert to gpiolib for ucb1x00 Thomas Kunze
2009-10-05 21:35               ` [PATCH 8/9] collie: add battery driver Thomas Kunze
2009-10-05 21:35                 ` [PATCH 9/9] collie: support pda_power driver Thomas Kunze
2009-11-28 12:47             ` [PATCH 6/9] add gpiolib support to ucb1x00 Russell King - ARM Linux
2009-11-29 11:44               ` Thomas Kunze
2009-10-11 12:15           ` [PATCH 5/9] SA1100: make gpio_to_irq and reverse a macro Pavel Machek
2009-10-12 17:31             ` Thomas Kunze
2009-10-07 11:08     ` [PATCH 2/9] collie: prepare for gpiolib use Dmitry Artamonow
2009-10-07 11:25       ` Russell King - ARM Linux
2009-10-07 11:48         ` Lothar Waßmann
2009-10-07 12:10           ` Sergei Shtylyov
2009-10-07 12:42         ` Dmitry Artamonow
2009-10-07 13:10           ` Russell King - ARM Linux
2009-10-07 14:33             ` RMK's sa1100 branch (was Re: [PATCH 2/9] collie: prepare for gpiolib use) Dmitry Artamonow
2009-10-07 16:41               ` Russell King - ARM Linux
2009-10-07 20:23       ` [PATCH 2/9] collie: prepare for gpiolib use Thomas Kunze
2009-10-06 10:33 ` collie and SA1100 patches Mark Brown
2009-10-06 10:57 ` Kristoffer Ericson
2009-10-06 16:36   ` Thomas Kunze
2009-10-11 12:16 ` Pavel Machek
2009-10-20 18:00 ` Thomas Kunze
2009-10-20 19:43   ` Eric Miao
2009-11-03 19:41     ` Thomas Kunze
2009-11-07  8:28       ` Pavel Machek
2009-11-07  8:53         ` Russell King - ARM Linux
2009-11-07 16:54         ` Kristoffer Ericson
  -- strict thread matches above, loose matches on Subject: below --
2009-02-10 13:50 [PATCH 6/9] add gpiolib support to ucb1x00 Thomas Kunze

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.