From e0084aa9e0ce157a5f53d9d39657a00d24dc6a66 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Sat, 30 Oct 2010 14:08:32 -0700 Subject: mfd: Update WARN uses Remove KERN_. Signed-off-by: Joe Perches Signed-off-by: Samuel Ortiz --- drivers/mfd/ezx-pcap.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/mfd/ezx-pcap.c b/drivers/mfd/ezx-pcap.c index c2b698d69a9..4f6742753c4 100644 --- a/drivers/mfd/ezx-pcap.c +++ b/drivers/mfd/ezx-pcap.c @@ -199,8 +199,7 @@ static void pcap_isr_work(struct work_struct *work) if (service & 1) { struct irq_desc *desc = irq_to_desc(irq); - if (WARN(!desc, KERN_WARNING - "Invalid PCAP IRQ %d\n", irq)) + if (WARN(!desc, "Invalid PCAP IRQ %d\n", irq)) break; if (desc->status & IRQ_DISABLED) @@ -282,7 +281,7 @@ static irqreturn_t pcap_adc_irq(int irq, void *_pcap) mutex_lock(&pcap->adc_mutex); req = pcap->adc_queue[pcap->adc_head]; - if (WARN(!req, KERN_WARNING "adc irq without pending request\n")) { + if (WARN(!req, "adc irq without pending request\n")) { mutex_unlock(&pcap->adc_mutex); return IRQ_HANDLED; } -- cgit v1.2.3-70-g09d2 From f77401d4da8180211b5fb5b7903ec8d8b22762ab Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Wed, 10 Nov 2010 15:47:51 +0800 Subject: mfd: Include instead of As warned by checkpatch.pl, use #include instead of Signed-off-by: Axel Lin Acked-by: Ben Dooks Signed-off-by: Samuel Ortiz --- drivers/mfd/sm501.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mfd/sm501.c b/drivers/mfd/sm501.c index bc9275c1213..c24bed769fe 100644 --- a/drivers/mfd/sm501.c +++ b/drivers/mfd/sm501.c @@ -26,7 +26,7 @@ #include #include -#include +#include struct sm501_device { struct list_head list; -- cgit v1.2.3-70-g09d2 From 77b22897da093e80c40f03e8d83bf23e756b9fba Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Wed, 10 Nov 2010 15:49:41 +0800 Subject: mfd: Include instead of As warned by checkpatch.pl, use #include instead of . Signed-off-by: Axel Lin Signed-off-by: Samuel Ortiz --- drivers/mfd/tps65010.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mfd/tps65010.c b/drivers/mfd/tps65010.c index 90187fe33e0..93d5fdf020c 100644 --- a/drivers/mfd/tps65010.c +++ b/drivers/mfd/tps65010.c @@ -34,7 +34,7 @@ #include -#include +#include /*-------------------------------------------------------------------------*/ -- cgit v1.2.3-70-g09d2 From e1b88eb0e08335d2f6c00b35b67b4ffc78fd46d6 Mon Sep 17 00:00:00 2001 From: Uwe Kleine-König Date: Thu, 11 Nov 2010 16:47:50 +0100 Subject: mfd: Don't open-code mc13xxx_unlock MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Uwe Kleine-König Signed-off-by: Samuel Ortiz --- drivers/mfd/mc13xxx-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mfd/mc13xxx-core.c b/drivers/mfd/mc13xxx-core.c index a2ac2ed6d64..b9fcaf0004d 100644 --- a/drivers/mfd/mc13xxx-core.c +++ b/drivers/mfd/mc13xxx-core.c @@ -749,7 +749,7 @@ static int mc13xxx_probe(struct spi_device *spi) if (ret) { err_mask: err_revision: - mutex_unlock(&mc13xxx->lock); + mc13xxx_unlock(mc13xxx); dev_set_drvdata(&spi->dev, NULL); kfree(mc13xxx); return ret; -- cgit v1.2.3-70-g09d2 From f71e1afdd588ec60fd799b1e5a6f0b2e6cf9605e Mon Sep 17 00:00:00 2001 From: Andres Salomon Date: Fri, 26 Nov 2010 11:52:35 +0100 Subject: mfd: Add cs5535-mfd driver for AMD Geode's CS5535/CS5536 support Add an MFD driver to handle the ISA device on CS5535 and CS5536 southbridges. This ISA bridge is actually multiple devices: GPIOs, MFGPTs, etc. Signed-off-by: Andres Salomon Signed-off-by: Samuel Ortiz --- drivers/mfd/Kconfig | 8 +++ drivers/mfd/Makefile | 1 + drivers/mfd/cs5535-mfd.c | 151 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 160 insertions(+) create mode 100644 drivers/mfd/cs5535-mfd.c diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index da9d2971102..b5e3e09f563 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -537,6 +537,14 @@ config AB3550_CORE LEDs, vibrator, system power and temperature, power management and ALSA sound. +config MFD_CS5535 + tristate "Support for CS5535 and CS5536 southbridge core functions" + select MFD_CORE + depends on PCI + ---help--- + This is the core driver for CS5535/CS5536 MFD functions. This is + necessary for using the board's GPIO and MFGPT functionality. + config MFD_TIMBERDALE tristate "Support for the Timberdale FPGA" select MFD_CORE diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index 848e7eac75a..5f35de9386e 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -82,3 +82,4 @@ obj-$(CONFIG_MFD_JZ4740_ADC) += jz4740-adc.o obj-$(CONFIG_MFD_TPS6586X) += tps6586x.o obj-$(CONFIG_MFD_VX855) += vx855.o obj-$(CONFIG_MFD_WL1273_CORE) += wl1273-core.o +obj-$(CONFIG_MFD_CS5535) += cs5535-mfd.o diff --git a/drivers/mfd/cs5535-mfd.c b/drivers/mfd/cs5535-mfd.c new file mode 100644 index 00000000000..b141ca7c777 --- /dev/null +++ b/drivers/mfd/cs5535-mfd.c @@ -0,0 +1,151 @@ +/* + * cs5535-mfd.c - core MFD driver for CS5535/CS5536 southbridges + * + * The CS5535 and CS5536 has an ISA bridge on the PCI bus that is + * used for accessing GPIOs, MFGPTs, ACPI, etc. Each subdevice has + * an IO range that's specified in a single BAR. The BAR order is + * hardcoded in the CS553x specifications. + * + * Copyright (c) 2010 Andres Salomon + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include + +#define DRV_NAME "cs5535-mfd" + +enum cs5535_mfd_bars { + SMB_BAR = 0, + GPIO_BAR = 1, + MFGPT_BAR = 2, + PMS_BAR = 4, + ACPI_BAR = 5, + NR_BARS, +}; + +static __devinitdata struct resource cs5535_mfd_resources[NR_BARS]; + +static __devinitdata struct mfd_cell cs5535_mfd_cells[] = { + { + .id = SMB_BAR, + .name = "cs5535-smb", + .num_resources = 1, + .resources = &cs5535_mfd_resources[SMB_BAR], + }, + { + .id = GPIO_BAR, + .name = "cs5535-gpio", + .num_resources = 1, + .resources = &cs5535_mfd_resources[GPIO_BAR], + }, + { + .id = MFGPT_BAR, + .name = "cs5535-mfgpt", + .num_resources = 1, + .resources = &cs5535_mfd_resources[MFGPT_BAR], + }, + { + .id = PMS_BAR, + .name = "cs5535-pms", + .num_resources = 1, + .resources = &cs5535_mfd_resources[PMS_BAR], + }, + { + .id = ACPI_BAR, + .name = "cs5535-acpi", + .num_resources = 1, + .resources = &cs5535_mfd_resources[ACPI_BAR], + }, +}; + +static int __devinit cs5535_mfd_probe(struct pci_dev *pdev, + const struct pci_device_id *id) +{ + int err, i; + + err = pci_enable_device(pdev); + if (err) + return err; + + /* fill in IO range for each cell; subdrivers handle the region */ + for (i = 0; i < ARRAY_SIZE(cs5535_mfd_cells); i++) { + int bar = cs5535_mfd_cells[i].id; + struct resource *r = &cs5535_mfd_resources[bar]; + + r->flags = IORESOURCE_IO; + r->start = pci_resource_start(pdev, bar); + r->end = pci_resource_end(pdev, bar); + + /* id is used for temporarily storing BAR; unset it now */ + cs5535_mfd_cells[i].id = 0; + } + + err = mfd_add_devices(&pdev->dev, -1, cs5535_mfd_cells, + ARRAY_SIZE(cs5535_mfd_cells), NULL, 0); + if (err) { + dev_err(&pdev->dev, "MFD add devices failed: %d\n", err); + goto err_disable; + } + + dev_info(&pdev->dev, "%d devices registered.\n", + ARRAY_SIZE(cs5535_mfd_cells)); + + return 0; + +err_disable: + pci_disable_device(pdev); + return err; +} + +static void __devexit cs5535_mfd_remove(struct pci_dev *pdev) +{ + mfd_remove_devices(&pdev->dev); + pci_disable_device(pdev); +} + +static struct pci_device_id cs5535_mfd_pci_tbl[] = { + { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_CS5535_ISA) }, + { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_ISA) }, + { 0, } +}; +MODULE_DEVICE_TABLE(pci, cs5535_mfd_pci_tbl); + +static struct pci_driver cs5535_mfd_drv = { + .name = DRV_NAME, + .id_table = cs5535_mfd_pci_tbl, + .probe = cs5535_mfd_probe, + .remove = __devexit_p(cs5535_mfd_remove), +}; + +static int __init cs5535_mfd_init(void) +{ + return pci_register_driver(&cs5535_mfd_drv); +} + +static void __exit cs5535_mfd_exit(void) +{ + pci_unregister_driver(&cs5535_mfd_drv); +} + +module_init(cs5535_mfd_init); +module_exit(cs5535_mfd_exit); + +MODULE_AUTHOR("Andres Salomon "); +MODULE_DESCRIPTION("MFD driver for CS5535/CS5536 southbridge's ISA PCI device"); +MODULE_LICENSE("GPL"); -- cgit v1.2.3-70-g09d2 From 3f3d4310bdb083b9331239e1a1bb09e19f763115 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Fri, 12 Nov 2010 13:37:56 -0800 Subject: mfd: Use printf extension %pR for struct resource Using %pR standardizes the struct resource output. Signed-off-by: Joe Perches Signed-off-by: Samuel Ortiz --- drivers/mfd/sm501.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/mfd/sm501.c b/drivers/mfd/sm501.c index c24bed769fe..5de3a760ea1 100644 --- a/drivers/mfd/sm501.c +++ b/drivers/mfd/sm501.c @@ -745,11 +745,8 @@ static int sm501_register_device(struct sm501_devdata *sm, int ret; for (ptr = 0; ptr < pdev->num_resources; ptr++) { - printk(KERN_DEBUG "%s[%d] flags %08lx: %08llx..%08llx\n", - pdev->name, ptr, - pdev->resource[ptr].flags, - (unsigned long long)pdev->resource[ptr].start, - (unsigned long long)pdev->resource[ptr].end); + printk(KERN_DEBUG "%s[%d] %pR\n", + pdev->name, ptr, &pdev->resource[ptr]); } ret = platform_device_register(pdev); -- cgit v1.2.3-70-g09d2 From 798e6e321f807c46d81be1572118e031577ea9ab Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Wed, 24 Nov 2010 18:01:40 +0000 Subject: mfd: Simplify WM832x subdevice instantiation All the current WM832x devices have the same set of subdevices so can just use multiple case statements with a single body. Signed-off-by: Mark Brown Signed-off-by: Samuel Ortiz --- drivers/mfd/wm831x-core.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/drivers/mfd/wm831x-core.c b/drivers/mfd/wm831x-core.c index 76cadcf3b1f..d1b2d534b99 100644 --- a/drivers/mfd/wm831x-core.c +++ b/drivers/mfd/wm831x-core.c @@ -1610,17 +1610,7 @@ int wm831x_device_init(struct wm831x *wm831x, unsigned long id, int irq) break; case WM8320: - ret = mfd_add_devices(wm831x->dev, -1, - wm8320_devs, ARRAY_SIZE(wm8320_devs), - NULL, 0); - break; - case WM8321: - ret = mfd_add_devices(wm831x->dev, -1, - wm8320_devs, ARRAY_SIZE(wm8320_devs), - NULL, 0); - break; - case WM8325: ret = mfd_add_devices(wm831x->dev, -1, wm8320_devs, ARRAY_SIZE(wm8320_devs), -- cgit v1.2.3-70-g09d2 From 412dc11d3fd01f96fdf4a8cbfbc5584a17dab7c8 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Wed, 24 Nov 2010 18:01:41 +0000 Subject: mfd: Add WM8326 support The WM8326 is a high performance variant of the WM832x series with no software visible differences. Signed-off-by: Mark Brown Signed-off-by: Samuel Ortiz --- drivers/mfd/wm831x-core.c | 7 +++++++ drivers/mfd/wm831x-i2c.c | 1 + drivers/mfd/wm831x-spi.c | 18 ++++++++++++++++++ include/linux/mfd/wm831x/core.h | 1 + 4 files changed, 27 insertions(+) diff --git a/drivers/mfd/wm831x-core.c b/drivers/mfd/wm831x-core.c index d1b2d534b99..3fe9a58fe6c 100644 --- a/drivers/mfd/wm831x-core.c +++ b/drivers/mfd/wm831x-core.c @@ -1541,6 +1541,12 @@ int wm831x_device_init(struct wm831x *wm831x, unsigned long id, int irq) dev_info(wm831x->dev, "WM8325 revision %c\n", 'A' + rev); break; + case WM8326: + parent = WM8326; + wm831x->num_gpio = 12; + dev_info(wm831x->dev, "WM8326 revision %c\n", 'A' + rev); + break; + default: dev_err(wm831x->dev, "Unknown WM831x device %04x\n", ret); ret = -EINVAL; @@ -1612,6 +1618,7 @@ int wm831x_device_init(struct wm831x *wm831x, unsigned long id, int irq) case WM8320: case WM8321: case WM8325: + case WM8326: ret = mfd_add_devices(wm831x->dev, -1, wm8320_devs, ARRAY_SIZE(wm8320_devs), NULL, wm831x->irq_base); diff --git a/drivers/mfd/wm831x-i2c.c b/drivers/mfd/wm831x-i2c.c index 156b19859e8..38be5201c78 100644 --- a/drivers/mfd/wm831x-i2c.c +++ b/drivers/mfd/wm831x-i2c.c @@ -108,6 +108,7 @@ static const struct i2c_device_id wm831x_i2c_id[] = { { "wm8320", WM8320 }, { "wm8321", WM8321 }, { "wm8325", WM8325 }, + { "wm8326", WM8326 }, { } }; MODULE_DEVICE_TABLE(i2c, wm831x_i2c_id); diff --git a/drivers/mfd/wm831x-spi.c b/drivers/mfd/wm831x-spi.c index 2789b151b0f..0a8f772be88 100644 --- a/drivers/mfd/wm831x-spi.c +++ b/drivers/mfd/wm831x-spi.c @@ -81,6 +81,8 @@ static int __devinit wm831x_spi_probe(struct spi_device *spi) type = WM8321; else if (strcmp(spi->modalias, "wm8325") == 0) type = WM8325; + else if (strcmp(spi->modalias, "wm8326") == 0) + type = WM8326; else { dev_err(&spi->dev, "Unknown device type\n"); return -EINVAL; @@ -184,6 +186,17 @@ static struct spi_driver wm8325_spi_driver = { .suspend = wm831x_spi_suspend, }; +static struct spi_driver wm8326_spi_driver = { + .driver = { + .name = "wm8326", + .bus = &spi_bus_type, + .owner = THIS_MODULE, + }, + .probe = wm831x_spi_probe, + .remove = __devexit_p(wm831x_spi_remove), + .suspend = wm831x_spi_suspend, +}; + static int __init wm831x_spi_init(void) { int ret; @@ -212,12 +225,17 @@ static int __init wm831x_spi_init(void) if (ret != 0) pr_err("Failed to register WM8325 SPI driver: %d\n", ret); + ret = spi_register_driver(&wm8326_spi_driver); + if (ret != 0) + pr_err("Failed to register WM8326 SPI driver: %d\n", ret); + return 0; } subsys_initcall(wm831x_spi_init); static void __exit wm831x_spi_exit(void) { + spi_unregister_driver(&wm8326_spi_driver); spi_unregister_driver(&wm8325_spi_driver); spi_unregister_driver(&wm8321_spi_driver); spi_unregister_driver(&wm8320_spi_driver); diff --git a/include/linux/mfd/wm831x/core.h b/include/linux/mfd/wm831x/core.h index a1239c48b41..903280d2186 100644 --- a/include/linux/mfd/wm831x/core.h +++ b/include/linux/mfd/wm831x/core.h @@ -245,6 +245,7 @@ enum wm831x_parent { WM8320 = 0x8320, WM8321 = 0x8321, WM8325 = 0x8325, + WM8326 = 0x8326, }; struct wm831x { -- cgit v1.2.3-70-g09d2 From ba81cd393348b504ecc80d5fc363857f49410d5e Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Wed, 24 Nov 2010 18:01:42 +0000 Subject: mfd: Convert WM831x to new irq_ interrupt methods Kernel 2.6.37 adds new interrupt methods which take a struct irq_data rather than an irq number. Convert over to these as they will become mandatory in future. Signed-off-by: Mark Brown Signed-off-by: Samuel Ortiz --- drivers/mfd/wm831x-irq.c | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/drivers/mfd/wm831x-irq.c b/drivers/mfd/wm831x-irq.c index 294183b6260..eae52726bf3 100644 --- a/drivers/mfd/wm831x-irq.c +++ b/drivers/mfd/wm831x-irq.c @@ -345,16 +345,16 @@ static inline struct wm831x_irq_data *irq_to_wm831x_irq(struct wm831x *wm831x, return &wm831x_irqs[irq - wm831x->irq_base]; } -static void wm831x_irq_lock(unsigned int irq) +static void wm831x_irq_lock(struct irq_data *data) { - struct wm831x *wm831x = get_irq_chip_data(irq); + struct wm831x *wm831x = data->chip_data; mutex_lock(&wm831x->irq_lock); } -static void wm831x_irq_sync_unlock(unsigned int irq) +static void wm831x_irq_sync_unlock(struct irq_data *data) { - struct wm831x *wm831x = get_irq_chip_data(irq); + struct wm831x *wm831x = data->chip_data; int i; for (i = 0; i < ARRAY_SIZE(wm831x->irq_masks_cur); i++) { @@ -371,28 +371,30 @@ static void wm831x_irq_sync_unlock(unsigned int irq) mutex_unlock(&wm831x->irq_lock); } -static void wm831x_irq_unmask(unsigned int irq) +static void wm831x_irq_unmask(struct irq_data *data) { - struct wm831x *wm831x = get_irq_chip_data(irq); - struct wm831x_irq_data *irq_data = irq_to_wm831x_irq(wm831x, irq); + struct wm831x *wm831x = data->chip_data; + struct wm831x_irq_data *irq_data = irq_to_wm831x_irq(wm831x, + data->irq); wm831x->irq_masks_cur[irq_data->reg - 1] &= ~irq_data->mask; } -static void wm831x_irq_mask(unsigned int irq) +static void wm831x_irq_mask(struct irq_data *data) { - struct wm831x *wm831x = get_irq_chip_data(irq); - struct wm831x_irq_data *irq_data = irq_to_wm831x_irq(wm831x, irq); + struct wm831x *wm831x = data->chip_data; + struct wm831x_irq_data *irq_data = irq_to_wm831x_irq(wm831x, + data->irq); wm831x->irq_masks_cur[irq_data->reg - 1] |= irq_data->mask; } -static int wm831x_irq_set_type(unsigned int irq, unsigned int type) +static int wm831x_irq_set_type(struct irq_data *data, unsigned int type) { - struct wm831x *wm831x = get_irq_chip_data(irq); - int val; + struct wm831x *wm831x = data->chip_data; + int val, irq; - irq = irq - wm831x->irq_base; + irq = data->irq - wm831x->irq_base; if (irq < WM831X_IRQ_GPIO_1 || irq > WM831X_IRQ_GPIO_11) { /* Ignore internal-only IRQs */ @@ -421,12 +423,12 @@ static int wm831x_irq_set_type(unsigned int irq, unsigned int type) } static struct irq_chip wm831x_irq_chip = { - .name = "wm831x", - .bus_lock = wm831x_irq_lock, - .bus_sync_unlock = wm831x_irq_sync_unlock, - .mask = wm831x_irq_mask, - .unmask = wm831x_irq_unmask, - .set_type = wm831x_irq_set_type, + .name = "wm831x", + .irq_bus_lock = wm831x_irq_lock, + .irq_bus_sync_unlock = wm831x_irq_sync_unlock, + .irq_mask = wm831x_irq_mask, + .irq_unmask = wm831x_irq_unmask, + .irq_set_type = wm831x_irq_set_type, }; /* The processing of the primary interrupt occurs in a thread so that -- cgit v1.2.3-70-g09d2 From fdcc475b968f4715ce7a214c061c97a95c77fd21 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Wed, 24 Nov 2010 18:01:43 +0000 Subject: mfd: Convert WM835x to new irq_ interrupt methods Kernel 2.6.37 adds new interrupt methods which take a struct irq_data rather than an irq number. Convert over to these as they will become mandatory in future. Signed-off-by: Mark Brown Signed-off-by: Samuel Ortiz --- drivers/mfd/wm8350-irq.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/drivers/mfd/wm8350-irq.c b/drivers/mfd/wm8350-irq.c index f56c9adf949..ba966ae88dc 100644 --- a/drivers/mfd/wm8350-irq.c +++ b/drivers/mfd/wm8350-irq.c @@ -417,16 +417,16 @@ static irqreturn_t wm8350_irq(int irq, void *irq_data) return IRQ_HANDLED; } -static void wm8350_irq_lock(unsigned int irq) +static void wm8350_irq_lock(struct irq_data *data) { - struct wm8350 *wm8350 = get_irq_chip_data(irq); + struct wm8350 *wm8350 = data->chip_data; mutex_lock(&wm8350->irq_lock); } -static void wm8350_irq_sync_unlock(unsigned int irq) +static void wm8350_irq_sync_unlock(struct irq_data *data) { - struct wm8350 *wm8350 = get_irq_chip_data(irq); + struct wm8350 *wm8350 = data->chip_data; int i; for (i = 0; i < ARRAY_SIZE(wm8350->irq_masks); i++) { @@ -442,28 +442,30 @@ static void wm8350_irq_sync_unlock(unsigned int irq) mutex_unlock(&wm8350->irq_lock); } -static void wm8350_irq_enable(unsigned int irq) +static void wm8350_irq_enable(struct irq_data *data) { - struct wm8350 *wm8350 = get_irq_chip_data(irq); - struct wm8350_irq_data *irq_data = irq_to_wm8350_irq(wm8350, irq); + struct wm8350 *wm8350 = data->chip_data; + struct wm8350_irq_data *irq_data = irq_to_wm8350_irq(wm8350, + data->irq); wm8350->irq_masks[irq_data->reg] &= ~irq_data->mask; } -static void wm8350_irq_disable(unsigned int irq) +static void wm8350_irq_disable(struct irq_data *data) { - struct wm8350 *wm8350 = get_irq_chip_data(irq); - struct wm8350_irq_data *irq_data = irq_to_wm8350_irq(wm8350, irq); + struct wm8350 *wm8350 = data->chip_data; + struct wm8350_irq_data *irq_data = irq_to_wm8350_irq(wm8350, + data->irq); wm8350->irq_masks[irq_data->reg] |= irq_data->mask; } static struct irq_chip wm8350_irq_chip = { - .name = "wm8350", - .bus_lock = wm8350_irq_lock, - .bus_sync_unlock = wm8350_irq_sync_unlock, - .disable = wm8350_irq_disable, - .enable = wm8350_irq_enable, + .name = "wm8350", + .irq_bus_lock = wm8350_irq_lock, + .irq_bus_sync_unlock = wm8350_irq_sync_unlock, + .irq_disable = wm8350_irq_disable, + .irq_enable = wm8350_irq_enable, }; int wm8350_irq_init(struct wm8350 *wm8350, int irq, -- cgit v1.2.3-70-g09d2 From baa3f63b88c9138bb923a29a3d5fddc204d1f5e6 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Wed, 24 Nov 2010 18:01:44 +0000 Subject: mfd: Convert WM8994 to new irq_ interrupt methods Kernel 2.6.37 adds new interrupt methods which take a struct irq_data rather than an irq number. Convert over to these as they will become mandatory in future. Signed-off-by: Mark Brown Signed-off-by: Samuel Ortiz --- drivers/mfd/wm8994-irq.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/drivers/mfd/wm8994-irq.c b/drivers/mfd/wm8994-irq.c index 8400eb1ee5d..62598840ad0 100644 --- a/drivers/mfd/wm8994-irq.c +++ b/drivers/mfd/wm8994-irq.c @@ -156,16 +156,16 @@ static inline struct wm8994_irq_data *irq_to_wm8994_irq(struct wm8994 *wm8994, return &wm8994_irqs[irq - wm8994->irq_base]; } -static void wm8994_irq_lock(unsigned int irq) +static void wm8994_irq_lock(struct irq_data *data) { - struct wm8994 *wm8994 = get_irq_chip_data(irq); + struct wm8994 *wm8994 = data->chip_data; mutex_lock(&wm8994->irq_lock); } -static void wm8994_irq_sync_unlock(unsigned int irq) +static void wm8994_irq_sync_unlock(struct irq_data *data) { - struct wm8994 *wm8994 = get_irq_chip_data(irq); + struct wm8994 *wm8994 = data->chip_data; int i; for (i = 0; i < ARRAY_SIZE(wm8994->irq_masks_cur); i++) { @@ -182,28 +182,30 @@ static void wm8994_irq_sync_unlock(unsigned int irq) mutex_unlock(&wm8994->irq_lock); } -static void wm8994_irq_unmask(unsigned int irq) +static void wm8994_irq_unmask(struct irq_data *data) { - struct wm8994 *wm8994 = get_irq_chip_data(irq); - struct wm8994_irq_data *irq_data = irq_to_wm8994_irq(wm8994, irq); + struct wm8994 *wm8994 = data->chip_data; + struct wm8994_irq_data *irq_data = irq_to_wm8994_irq(wm8994, + data->irq); wm8994->irq_masks_cur[irq_data->reg - 1] &= ~irq_data->mask; } -static void wm8994_irq_mask(unsigned int irq) +static void wm8994_irq_mask(struct irq_data *data) { - struct wm8994 *wm8994 = get_irq_chip_data(irq); - struct wm8994_irq_data *irq_data = irq_to_wm8994_irq(wm8994, irq); + struct wm8994 *wm8994 = data->chip_data; + struct wm8994_irq_data *irq_data = irq_to_wm8994_irq(wm8994, + data->irq); wm8994->irq_masks_cur[irq_data->reg - 1] |= irq_data->mask; } static struct irq_chip wm8994_irq_chip = { - .name = "wm8994", - .bus_lock = wm8994_irq_lock, - .bus_sync_unlock = wm8994_irq_sync_unlock, - .mask = wm8994_irq_mask, - .unmask = wm8994_irq_unmask, + .name = "wm8994", + .irq_bus_lock = wm8994_irq_lock, + .irq_bus_sync_unlock = wm8994_irq_sync_unlock, + .irq_mask = wm8994_irq_mask, + .irq_unmask = wm8994_irq_unmask, }; /* The processing of the primary interrupt occurs in a thread so that -- cgit v1.2.3-70-g09d2 From d7b9f3220fd97522559316cdd72778f42ac4de04 Mon Sep 17 00:00:00 2001 From: Mattias Wallin Date: Fri, 26 Nov 2010 13:06:39 +0100 Subject: mfd: Fix ab8500-debug indentation errors Replace spaces with proper tabs. Signed-off-by: Mattias Wallin Signed-off-by: Samuel Ortiz --- drivers/mfd/ab8500-debugfs.c | 1016 +++++++++++++++++++++--------------------- 1 file changed, 508 insertions(+), 508 deletions(-) diff --git a/drivers/mfd/ab8500-debugfs.c b/drivers/mfd/ab8500-debugfs.c index 8d1e05a3981..dfdc76e0b96 100644 --- a/drivers/mfd/ab8500-debugfs.c +++ b/drivers/mfd/ab8500-debugfs.c @@ -24,9 +24,9 @@ static u32 debug_address; * @perm: access permissions for the range */ struct ab8500_reg_range { - u8 first; - u8 last; - u8 perm; + u8 first; + u8 last; + u8 perm; }; /** @@ -36,9 +36,9 @@ struct ab8500_reg_range { * @range: the list of register ranges */ struct ab8500_i2c_ranges { - u8 num_ranges; - u8 bankid; - const struct ab8500_reg_range *range; + u8 num_ranges; + u8 bankid; + const struct ab8500_reg_range *range; }; #define AB8500_NAME_STRING "ab8500" @@ -47,521 +47,521 @@ struct ab8500_i2c_ranges { #define AB8500_REV_REG 0x80 static struct ab8500_i2c_ranges debug_ranges[AB8500_NUM_BANKS] = { - [0x0] = { - .num_ranges = 0, - .range = 0, - }, - [AB8500_SYS_CTRL1_BLOCK] = { - .num_ranges = 3, - .range = (struct ab8500_reg_range[]) { - { - .first = 0x00, - .last = 0x02, - }, - { - .first = 0x42, - .last = 0x42, - }, - { - .first = 0x80, - .last = 0x81, - }, - }, - }, - [AB8500_SYS_CTRL2_BLOCK] = { - .num_ranges = 4, - .range = (struct ab8500_reg_range[]) { - { - .first = 0x00, - .last = 0x0D, - }, - { - .first = 0x0F, - .last = 0x17, - }, - { - .first = 0x30, - .last = 0x30, - }, - { - .first = 0x32, - .last = 0x33, - }, - }, - }, - [AB8500_REGU_CTRL1] = { - .num_ranges = 3, - .range = (struct ab8500_reg_range[]) { - { - .first = 0x00, - .last = 0x00, - }, - { - .first = 0x03, - .last = 0x10, - }, - { - .first = 0x80, - .last = 0x84, - }, - }, - }, - [AB8500_REGU_CTRL2] = { - .num_ranges = 5, - .range = (struct ab8500_reg_range[]) { - { - .first = 0x00, - .last = 0x15, - }, - { - .first = 0x17, - .last = 0x19, - }, - { - .first = 0x1B, - .last = 0x1D, - }, - { - .first = 0x1F, - .last = 0x22, - }, - { - .first = 0x40, - .last = 0x44, - }, - /* 0x80-0x8B is SIM registers and should - * not be accessed from here */ - }, - }, - [AB8500_USB] = { - .num_ranges = 2, - .range = (struct ab8500_reg_range[]) { - { - .first = 0x80, - .last = 0x83, - }, - { - .first = 0x87, - .last = 0x8A, - }, - }, - }, - [AB8500_TVOUT] = { - .num_ranges = 9, - .range = (struct ab8500_reg_range[]) { - { - .first = 0x00, - .last = 0x12, - }, - { - .first = 0x15, - .last = 0x17, - }, - { - .first = 0x19, - .last = 0x21, - }, - { - .first = 0x27, - .last = 0x2C, - }, - { - .first = 0x41, - .last = 0x41, - }, - { - .first = 0x45, - .last = 0x5B, - }, - { - .first = 0x5D, - .last = 0x5D, - }, - { - .first = 0x69, - .last = 0x69, - }, - { - .first = 0x80, - .last = 0x81, - }, - }, - }, - [AB8500_DBI] = { - .num_ranges = 0, - .range = 0, - }, - [AB8500_ECI_AV_ACC] = { - .num_ranges = 1, - .range = (struct ab8500_reg_range[]) { - { - .first = 0x80, - .last = 0x82, - }, - }, - }, - [0x9] = { - .num_ranges = 0, - .range = 0, - }, - [AB8500_GPADC] = { - .num_ranges = 1, - .range = (struct ab8500_reg_range[]) { - { - .first = 0x00, - .last = 0x08, - }, - }, - }, - [AB8500_CHARGER] = { - .num_ranges = 8, - .range = (struct ab8500_reg_range[]) { - { - .first = 0x00, - .last = 0x03, - }, - { - .first = 0x05, - .last = 0x05, - }, - { - .first = 0x40, - .last = 0x40, - }, - { - .first = 0x42, - .last = 0x42, - }, - { - .first = 0x44, - .last = 0x44, - }, - { - .first = 0x50, - .last = 0x55, - }, - { - .first = 0x80, - .last = 0x82, - }, - { - .first = 0xC0, - .last = 0xC2, - }, - }, - }, - [AB8500_GAS_GAUGE] = { - .num_ranges = 3, - .range = (struct ab8500_reg_range[]) { - { - .first = 0x00, - .last = 0x00, - }, - { - .first = 0x07, - .last = 0x0A, - }, - { - .first = 0x10, - .last = 0x14, - }, - }, - }, - [AB8500_AUDIO] = { - .num_ranges = 1, - .range = (struct ab8500_reg_range[]) { - { - .first = 0x00, - .last = 0x6F, - }, - }, - }, - [AB8500_INTERRUPT] = { - .num_ranges = 0, - .range = 0, - }, - [AB8500_RTC] = { - .num_ranges = 1, - .range = (struct ab8500_reg_range[]) { - { - .first = 0x00, - .last = 0x0F, - }, - }, - }, - [AB8500_MISC] = { - .num_ranges = 8, - .range = (struct ab8500_reg_range[]) { - { - .first = 0x00, - .last = 0x05, - }, - { - .first = 0x10, - .last = 0x15, - }, - { - .first = 0x20, - .last = 0x25, - }, - { - .first = 0x30, - .last = 0x35, - }, - { - .first = 0x40, - .last = 0x45, - }, - { - .first = 0x50, - .last = 0x50, - }, - { - .first = 0x60, - .last = 0x67, - }, - { - .first = 0x80, - .last = 0x80, - }, - }, - }, - [0x11] = { - .num_ranges = 0, - .range = 0, - }, - [0x12] = { - .num_ranges = 0, - .range = 0, - }, - [0x13] = { - .num_ranges = 0, - .range = 0, - }, - [0x14] = { - .num_ranges = 0, - .range = 0, - }, - [AB8500_OTP_EMUL] = { - .num_ranges = 1, - .range = (struct ab8500_reg_range[]) { - { - .first = 0x01, - .last = 0x0F, - }, - }, - }, + [0x0] = { + .num_ranges = 0, + .range = 0, + }, + [AB8500_SYS_CTRL1_BLOCK] = { + .num_ranges = 3, + .range = (struct ab8500_reg_range[]) { + { + .first = 0x00, + .last = 0x02, + }, + { + .first = 0x42, + .last = 0x42, + }, + { + .first = 0x80, + .last = 0x81, + }, + }, + }, + [AB8500_SYS_CTRL2_BLOCK] = { + .num_ranges = 4, + .range = (struct ab8500_reg_range[]) { + { + .first = 0x00, + .last = 0x0D, + }, + { + .first = 0x0F, + .last = 0x17, + }, + { + .first = 0x30, + .last = 0x30, + }, + { + .first = 0x32, + .last = 0x33, + }, + }, + }, + [AB8500_REGU_CTRL1] = { + .num_ranges = 3, + .range = (struct ab8500_reg_range[]) { + { + .first = 0x00, + .last = 0x00, + }, + { + .first = 0x03, + .last = 0x10, + }, + { + .first = 0x80, + .last = 0x84, + }, + }, + }, + [AB8500_REGU_CTRL2] = { + .num_ranges = 5, + .range = (struct ab8500_reg_range[]) { + { + .first = 0x00, + .last = 0x15, + }, + { + .first = 0x17, + .last = 0x19, + }, + { + .first = 0x1B, + .last = 0x1D, + }, + { + .first = 0x1F, + .last = 0x22, + }, + { + .first = 0x40, + .last = 0x44, + }, + /* 0x80-0x8B is SIM registers and should + * not be accessed from here */ + }, + }, + [AB8500_USB] = { + .num_ranges = 2, + .range = (struct ab8500_reg_range[]) { + { + .first = 0x80, + .last = 0x83, + }, + { + .first = 0x87, + .last = 0x8A, + }, + }, + }, + [AB8500_TVOUT] = { + .num_ranges = 9, + .range = (struct ab8500_reg_range[]) { + { + .first = 0x00, + .last = 0x12, + }, + { + .first = 0x15, + .last = 0x17, + }, + { + .first = 0x19, + .last = 0x21, + }, + { + .first = 0x27, + .last = 0x2C, + }, + { + .first = 0x41, + .last = 0x41, + }, + { + .first = 0x45, + .last = 0x5B, + }, + { + .first = 0x5D, + .last = 0x5D, + }, + { + .first = 0x69, + .last = 0x69, + }, + { + .first = 0x80, + .last = 0x81, + }, + }, + }, + [AB8500_DBI] = { + .num_ranges = 0, + .range = 0, + }, + [AB8500_ECI_AV_ACC] = { + .num_ranges = 1, + .range = (struct ab8500_reg_range[]) { + { + .first = 0x80, + .last = 0x82, + }, + }, + }, + [0x9] = { + .num_ranges = 0, + .range = 0, + }, + [AB8500_GPADC] = { + .num_ranges = 1, + .range = (struct ab8500_reg_range[]) { + { + .first = 0x00, + .last = 0x08, + }, + }, + }, + [AB8500_CHARGER] = { + .num_ranges = 8, + .range = (struct ab8500_reg_range[]) { + { + .first = 0x00, + .last = 0x03, + }, + { + .first = 0x05, + .last = 0x05, + }, + { + .first = 0x40, + .last = 0x40, + }, + { + .first = 0x42, + .last = 0x42, + }, + { + .first = 0x44, + .last = 0x44, + }, + { + .first = 0x50, + .last = 0x55, + }, + { + .first = 0x80, + .last = 0x82, + }, + { + .first = 0xC0, + .last = 0xC2, + }, + }, + }, + [AB8500_GAS_GAUGE] = { + .num_ranges = 3, + .range = (struct ab8500_reg_range[]) { + { + .first = 0x00, + .last = 0x00, + }, + { + .first = 0x07, + .last = 0x0A, + }, + { + .first = 0x10, + .last = 0x14, + }, + }, + }, + [AB8500_AUDIO] = { + .num_ranges = 1, + .range = (struct ab8500_reg_range[]) { + { + .first = 0x00, + .last = 0x6F, + }, + }, + }, + [AB8500_INTERRUPT] = { + .num_ranges = 0, + .range = 0, + }, + [AB8500_RTC] = { + .num_ranges = 1, + .range = (struct ab8500_reg_range[]) { + { + .first = 0x00, + .last = 0x0F, + }, + }, + }, + [AB8500_MISC] = { + .num_ranges = 8, + .range = (struct ab8500_reg_range[]) { + { + .first = 0x00, + .last = 0x05, + }, + { + .first = 0x10, + .last = 0x15, + }, + { + .first = 0x20, + .last = 0x25, + }, + { + .first = 0x30, + .last = 0x35, + }, + { + .first = 0x40, + .last = 0x45, + }, + { + .first = 0x50, + .last = 0x50, + }, + { + .first = 0x60, + .last = 0x67, + }, + { + .first = 0x80, + .last = 0x80, + }, + }, + }, + [0x11] = { + .num_ranges = 0, + .range = 0, + }, + [0x12] = { + .num_ranges = 0, + .range = 0, + }, + [0x13] = { + .num_ranges = 0, + .range = 0, + }, + [0x14] = { + .num_ranges = 0, + .range = 0, + }, + [AB8500_OTP_EMUL] = { + .num_ranges = 1, + .range = (struct ab8500_reg_range[]) { + { + .first = 0x01, + .last = 0x0F, + }, + }, + }, }; static int ab8500_registers_print(struct seq_file *s, void *p) { - struct device *dev = s->private; - unsigned int i; - u32 bank = debug_bank; - - seq_printf(s, AB8500_NAME_STRING " register values:\n"); - - seq_printf(s, " bank %u:\n", bank); - for (i = 0; i < debug_ranges[bank].num_ranges; i++) { - u32 reg; - - for (reg = debug_ranges[bank].range[i].first; - reg <= debug_ranges[bank].range[i].last; - reg++) { - u8 value; - int err; - - err = abx500_get_register_interruptible(dev, - (u8)bank, (u8)reg, &value); - if (err < 0) { - dev_err(dev, "ab->read fail %d\n", err); - return err; - } - - err = seq_printf(s, " [%u/0x%02X]: 0x%02X\n", bank, - reg, value); - if (err < 0) { - dev_err(dev, "seq_printf overflow\n"); - /* Error is not returned here since - * the output is wanted in any case */ - return 0; - } - } - } - return 0; + struct device *dev = s->private; + unsigned int i; + u32 bank = debug_bank; + + seq_printf(s, AB8500_NAME_STRING " register values:\n"); + + seq_printf(s, " bank %u:\n", bank); + for (i = 0; i < debug_ranges[bank].num_ranges; i++) { + u32 reg; + + for (reg = debug_ranges[bank].range[i].first; + reg <= debug_ranges[bank].range[i].last; + reg++) { + u8 value; + int err; + + err = abx500_get_register_interruptible(dev, + (u8)bank, (u8)reg, &value); + if (err < 0) { + dev_err(dev, "ab->read fail %d\n", err); + return err; + } + + err = seq_printf(s, " [%u/0x%02X]: 0x%02X\n", bank, + reg, value); + if (err < 0) { + dev_err(dev, "seq_printf overflow\n"); + /* Error is not returned here since + * the output is wanted in any case */ + return 0; + } + } + } + return 0; } static int ab8500_registers_open(struct inode *inode, struct file *file) { - return single_open(file, ab8500_registers_print, inode->i_private); + return single_open(file, ab8500_registers_print, inode->i_private); } static const struct file_operations ab8500_registers_fops = { - .open = ab8500_registers_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, - .owner = THIS_MODULE, + .open = ab8500_registers_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, + .owner = THIS_MODULE, }; static int ab8500_bank_print(struct seq_file *s, void *p) { - return seq_printf(s, "%d\n", debug_bank); + return seq_printf(s, "%d\n", debug_bank); } static int ab8500_bank_open(struct inode *inode, struct file *file) { - return single_open(file, ab8500_bank_print, inode->i_private); + return single_open(file, ab8500_bank_print, inode->i_private); } static ssize_t ab8500_bank_write(struct file *file, - const char __user *user_buf, - size_t count, loff_t *ppos) + const char __user *user_buf, + size_t count, loff_t *ppos) { - struct device *dev = ((struct seq_file *)(file->private_data))->private; - char buf[32]; - int buf_size; - unsigned long user_bank; - int err; - - /* Get userspace string and assure termination */ - buf_size = min(count, (sizeof(buf) - 1)); - if (copy_from_user(buf, user_buf, buf_size)) - return -EFAULT; - buf[buf_size] = 0; - - err = strict_strtoul(buf, 0, &user_bank); - if (err) - return -EINVAL; - - if (user_bank >= AB8500_NUM_BANKS) { - dev_err(dev, "debugfs error input > number of banks\n"); - return -EINVAL; - } - - debug_bank = user_bank; - - return buf_size; + struct device *dev = ((struct seq_file *)(file->private_data))->private; + char buf[32]; + int buf_size; + unsigned long user_bank; + int err; + + /* Get userspace string and assure termination */ + buf_size = min(count, (sizeof(buf) - 1)); + if (copy_from_user(buf, user_buf, buf_size)) + return -EFAULT; + buf[buf_size] = 0; + + err = strict_strtoul(buf, 0, &user_bank); + if (err) + return -EINVAL; + + if (user_bank >= AB8500_NUM_BANKS) { + dev_err(dev, "debugfs error input > number of banks\n"); + return -EINVAL; + } + + debug_bank = user_bank; + + return buf_size; } static int ab8500_address_print(struct seq_file *s, void *p) { - return seq_printf(s, "0x%02X\n", debug_address); + return seq_printf(s, "0x%02X\n", debug_address); } static int ab8500_address_open(struct inode *inode, struct file *file) { - return single_open(file, ab8500_address_print, inode->i_private); + return single_open(file, ab8500_address_print, inode->i_private); } static ssize_t ab8500_address_write(struct file *file, - const char __user *user_buf, - size_t count, loff_t *ppos) + const char __user *user_buf, + size_t count, loff_t *ppos) { - struct device *dev = ((struct seq_file *)(file->private_data))->private; - char buf[32]; - int buf_size; - unsigned long user_address; - int err; - - /* Get userspace string and assure termination */ - buf_size = min(count, (sizeof(buf) - 1)); - if (copy_from_user(buf, user_buf, buf_size)) - return -EFAULT; - buf[buf_size] = 0; - - err = strict_strtoul(buf, 0, &user_address); - if (err) - return -EINVAL; - if (user_address > 0xff) { - dev_err(dev, "debugfs error input > 0xff\n"); - return -EINVAL; - } - debug_address = user_address; - return buf_size; + struct device *dev = ((struct seq_file *)(file->private_data))->private; + char buf[32]; + int buf_size; + unsigned long user_address; + int err; + + /* Get userspace string and assure termination */ + buf_size = min(count, (sizeof(buf) - 1)); + if (copy_from_user(buf, user_buf, buf_size)) + return -EFAULT; + buf[buf_size] = 0; + + err = strict_strtoul(buf, 0, &user_address); + if (err) + return -EINVAL; + if (user_address > 0xff) { + dev_err(dev, "debugfs error input > 0xff\n"); + return -EINVAL; + } + debug_address = user_address; + return buf_size; } static int ab8500_val_print(struct seq_file *s, void *p) { - struct device *dev = s->private; - int ret; - u8 regvalue; - - ret = abx500_get_register_interruptible(dev, - (u8)debug_bank, (u8)debug_address, ®value); - if (ret < 0) { - dev_err(dev, "abx500_get_reg fail %d, %d\n", - ret, __LINE__); - return -EINVAL; - } - seq_printf(s, "0x%02X\n", regvalue); - - return 0; + struct device *dev = s->private; + int ret; + u8 regvalue; + + ret = abx500_get_register_interruptible(dev, + (u8)debug_bank, (u8)debug_address, ®value); + if (ret < 0) { + dev_err(dev, "abx500_get_reg fail %d, %d\n", + ret, __LINE__); + return -EINVAL; + } + seq_printf(s, "0x%02X\n", regvalue); + + return 0; } static int ab8500_val_open(struct inode *inode, struct file *file) { - return single_open(file, ab8500_val_print, inode->i_private); + return single_open(file, ab8500_val_print, inode->i_private); } static ssize_t ab8500_val_write(struct file *file, - const char __user *user_buf, - size_t count, loff_t *ppos) + const char __user *user_buf, + size_t count, loff_t *ppos) { - struct device *dev = ((struct seq_file *)(file->private_data))->private; - char buf[32]; - int buf_size; - unsigned long user_val; - int err; - - /* Get userspace string and assure termination */ - buf_size = min(count, (sizeof(buf)-1)); - if (copy_from_user(buf, user_buf, buf_size)) - return -EFAULT; - buf[buf_size] = 0; - - err = strict_strtoul(buf, 0, &user_val); - if (err) - return -EINVAL; - if (user_val > 0xff) { - dev_err(dev, "debugfs error input > 0xff\n"); - return -EINVAL; - } - err = abx500_set_register_interruptible(dev, - (u8)debug_bank, debug_address, (u8)user_val); - if (err < 0) { - printk(KERN_ERR "abx500_set_reg failed %d, %d", err, __LINE__); - return -EINVAL; - } - - return buf_size; + struct device *dev = ((struct seq_file *)(file->private_data))->private; + char buf[32]; + int buf_size; + unsigned long user_val; + int err; + + /* Get userspace string and assure termination */ + buf_size = min(count, (sizeof(buf)-1)); + if (copy_from_user(buf, user_buf, buf_size)) + return -EFAULT; + buf[buf_size] = 0; + + err = strict_strtoul(buf, 0, &user_val); + if (err) + return -EINVAL; + if (user_val > 0xff) { + dev_err(dev, "debugfs error input > 0xff\n"); + return -EINVAL; + } + err = abx500_set_register_interruptible(dev, + (u8)debug_bank, debug_address, (u8)user_val); + if (err < 0) { + printk(KERN_ERR "abx500_set_reg failed %d, %d", err, __LINE__); + return -EINVAL; + } + + return buf_size; } static const struct file_operations ab8500_bank_fops = { - .open = ab8500_bank_open, - .write = ab8500_bank_write, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, - .owner = THIS_MODULE, + .open = ab8500_bank_open, + .write = ab8500_bank_write, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, + .owner = THIS_MODULE, }; static const struct file_operations ab8500_address_fops = { - .open = ab8500_address_open, - .write = ab8500_address_write, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, - .owner = THIS_MODULE, + .open = ab8500_address_open, + .write = ab8500_address_write, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, + .owner = THIS_MODULE, }; static const struct file_operations ab8500_val_fops = { - .open = ab8500_val_open, - .write = ab8500_val_write, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, - .owner = THIS_MODULE, + .open = ab8500_val_open, + .write = ab8500_val_write, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, + .owner = THIS_MODULE, }; static struct dentry *ab8500_dir; @@ -572,77 +572,77 @@ static struct dentry *ab8500_val_file; static int __devinit ab8500_debug_probe(struct platform_device *plf) { - debug_bank = AB8500_MISC; - debug_address = AB8500_REV_REG & 0x00FF; + debug_bank = AB8500_MISC; + debug_address = AB8500_REV_REG & 0x00FF; - ab8500_dir = debugfs_create_dir(AB8500_NAME_STRING, NULL); - if (!ab8500_dir) - goto exit_no_debugfs; + ab8500_dir = debugfs_create_dir(AB8500_NAME_STRING, NULL); + if (!ab8500_dir) + goto exit_no_debugfs; - ab8500_reg_file = debugfs_create_file("all-bank-registers", - S_IRUGO, ab8500_dir, &plf->dev, &ab8500_registers_fops); - if (!ab8500_reg_file) - goto exit_destroy_dir; + ab8500_reg_file = debugfs_create_file("all-bank-registers", + S_IRUGO, ab8500_dir, &plf->dev, &ab8500_registers_fops); + if (!ab8500_reg_file) + goto exit_destroy_dir; - ab8500_bank_file = debugfs_create_file("register-bank", - (S_IRUGO | S_IWUGO), ab8500_dir, &plf->dev, &ab8500_bank_fops); - if (!ab8500_bank_file) - goto exit_destroy_reg; + ab8500_bank_file = debugfs_create_file("register-bank", + (S_IRUGO | S_IWUGO), ab8500_dir, &plf->dev, &ab8500_bank_fops); + if (!ab8500_bank_file) + goto exit_destroy_reg; - ab8500_address_file = debugfs_create_file("register-address", - (S_IRUGO | S_IWUGO), ab8500_dir, &plf->dev, - &ab8500_address_fops); - if (!ab8500_address_file) - goto exit_destroy_bank; + ab8500_address_file = debugfs_create_file("register-address", + (S_IRUGO | S_IWUGO), ab8500_dir, &plf->dev, + &ab8500_address_fops); + if (!ab8500_address_file) + goto exit_destroy_bank; - ab8500_val_file = debugfs_create_file("register-value", - (S_IRUGO | S_IWUGO), ab8500_dir, &plf->dev, &ab8500_val_fops); - if (!ab8500_val_file) - goto exit_destroy_address; + ab8500_val_file = debugfs_create_file("register-value", + (S_IRUGO | S_IWUGO), ab8500_dir, &plf->dev, &ab8500_val_fops); + if (!ab8500_val_file) + goto exit_destroy_address; - return 0; + return 0; exit_destroy_address: - debugfs_remove(ab8500_address_file); + debugfs_remove(ab8500_address_file); exit_destroy_bank: - debugfs_remove(ab8500_bank_file); + debugfs_remove(ab8500_bank_file); exit_destroy_reg: - debugfs_remove(ab8500_reg_file); + debugfs_remove(ab8500_reg_file); exit_destroy_dir: - debugfs_remove(ab8500_dir); + debugfs_remove(ab8500_dir); exit_no_debugfs: - dev_err(&plf->dev, "failed to create debugfs entries.\n"); - return -ENOMEM; + dev_err(&plf->dev, "failed to create debugfs entries.\n"); + return -ENOMEM; } static int __devexit ab8500_debug_remove(struct platform_device *plf) { - debugfs_remove(ab8500_val_file); - debugfs_remove(ab8500_address_file); - debugfs_remove(ab8500_bank_file); - debugfs_remove(ab8500_reg_file); - debugfs_remove(ab8500_dir); + debugfs_remove(ab8500_val_file); + debugfs_remove(ab8500_address_file); + debugfs_remove(ab8500_bank_file); + debugfs_remove(ab8500_reg_file); + debugfs_remove(ab8500_dir); - return 0; + return 0; } static struct platform_driver ab8500_debug_driver = { - .driver = { - .name = "ab8500-debug", - .owner = THIS_MODULE, - }, - .probe = ab8500_debug_probe, - .remove = __devexit_p(ab8500_debug_remove) + .driver = { + .name = "ab8500-debug", + .owner = THIS_MODULE, + }, + .probe = ab8500_debug_probe, + .remove = __devexit_p(ab8500_debug_remove) }; static int __init ab8500_debug_init(void) { - return platform_driver_register(&ab8500_debug_driver); + return platform_driver_register(&ab8500_debug_driver); } static void __exit ab8500_debug_exit(void) { - platform_driver_unregister(&ab8500_debug_driver); + platform_driver_unregister(&ab8500_debug_driver); } subsys_initcall(ab8500_debug_init); module_exit(ab8500_debug_exit); -- cgit v1.2.3-70-g09d2 From 4c90aa94f6b3e33f57faaf19ef9819195dff61d3 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Fri, 26 Nov 2010 17:19:34 +0000 Subject: mfd: Provide pm_runtime_no_callbacks flag in cell data Allow MFD cells to have pm_runtime_no_callbacks() called on them during registration. This causes the runtime PM framework to ignore them, allowing use of runtime PM to suspend the device as a whole even if not all drivers for the MFD can usefully implement runtime PM. For example, RTCs are likely to run continuously regardless of the power state of the system. Signed-off-by: Mark Brown Signed-off-by: Samuel Ortiz --- drivers/mfd/mfd-core.c | 4 ++++ include/linux/mfd/core.h | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c index ec99f681e77..d83ad0f141a 100644 --- a/drivers/mfd/mfd-core.c +++ b/drivers/mfd/mfd-core.c @@ -15,6 +15,7 @@ #include #include #include +#include #include static int mfd_add_device(struct device *parent, int id, @@ -82,6 +83,9 @@ static int mfd_add_device(struct device *parent, int id, if (ret) goto fail_res; + if (cell->pm_runtime_no_callbacks) + pm_runtime_no_callbacks(&pdev->dev); + kfree(res); return 0; diff --git a/include/linux/mfd/core.h b/include/linux/mfd/core.h index 5582ab3d3e4..835996e167e 100644 --- a/include/linux/mfd/core.h +++ b/include/linux/mfd/core.h @@ -47,6 +47,12 @@ struct mfd_cell { /* don't check for resource conflicts */ bool ignore_resource_conflicts; + + /* + * Disable runtime PM callbacks for this subdevice - see + * pm_runtime_no_callbacks(). + */ + bool pm_runtime_no_callbacks; }; extern int mfd_add_devices(struct device *parent, int id, -- cgit v1.2.3-70-g09d2 From d450f19eea0c3f64d60dc37655bae03b2455e5bb Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Fri, 26 Nov 2010 17:19:35 +0000 Subject: mfd: Implement runtime PM for WM8994 core driver Allow the WM8994 to completely power off, including disabling the LDOs if they are software controlled, when it goes idle. The CODEC subdevice controls activity for the MFD as a whole. If the GPIOs need to be used while the device is active runtime PM should be disabled for the device by machine specific code. Signed-off-by: Mark Brown Signed-off-by: Samuel Ortiz --- drivers/mfd/wm8994-core.c | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/drivers/mfd/wm8994-core.c b/drivers/mfd/wm8994-core.c index 8d221ba5e38..41233c7fa58 100644 --- a/drivers/mfd/wm8994-core.c +++ b/drivers/mfd/wm8994-core.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -169,8 +170,16 @@ out: EXPORT_SYMBOL_GPL(wm8994_set_bits); static struct mfd_cell wm8994_regulator_devs[] = { - { .name = "wm8994-ldo", .id = 1 }, - { .name = "wm8994-ldo", .id = 2 }, + { + .name = "wm8994-ldo", + .id = 1, + .pm_runtime_no_callbacks = true, + }, + { + .name = "wm8994-ldo", + .id = 2, + .pm_runtime_no_callbacks = true, + }, }; static struct resource wm8994_codec_resources[] = { @@ -200,6 +209,7 @@ static struct mfd_cell wm8994_devs[] = { .name = "wm8994-gpio", .num_resources = ARRAY_SIZE(wm8994_gpio_resources), .resources = wm8994_gpio_resources, + .pm_runtime_no_callbacks = true, }, }; @@ -231,7 +241,7 @@ static const char *wm8958_main_supplies[] = { }; #ifdef CONFIG_PM -static int wm8994_device_suspend(struct device *dev) +static int wm8994_suspend(struct device *dev) { struct wm8994 *wm8994 = dev_get_drvdata(dev); int ret; @@ -261,7 +271,7 @@ static int wm8994_device_suspend(struct device *dev) return 0; } -static int wm8994_device_resume(struct device *dev) +static int wm8994_resume(struct device *dev) { struct wm8994 *wm8994 = dev_get_drvdata(dev); int ret; @@ -471,6 +481,9 @@ static int wm8994_device_init(struct wm8994 *wm8994, int irq) goto err_irq; } + pm_runtime_enable(wm8994->dev); + pm_runtime_resume(wm8994->dev); + return 0; err_irq: @@ -490,6 +503,7 @@ err: static void wm8994_device_exit(struct wm8994 *wm8994) { + pm_runtime_disable(wm8994->dev); mfd_remove_devices(wm8994->dev); wm8994_irq_exit(wm8994); regulator_bulk_disable(wm8994->num_supplies, @@ -573,21 +587,6 @@ static int wm8994_i2c_remove(struct i2c_client *i2c) return 0; } -#ifdef CONFIG_PM -static int wm8994_i2c_suspend(struct i2c_client *i2c, pm_message_t state) -{ - return wm8994_device_suspend(&i2c->dev); -} - -static int wm8994_i2c_resume(struct i2c_client *i2c) -{ - return wm8994_device_resume(&i2c->dev); -} -#else -#define wm8994_i2c_suspend NULL -#define wm8994_i2c_resume NULL -#endif - static const struct i2c_device_id wm8994_i2c_id[] = { { "wm8994", WM8994 }, { "wm8958", WM8958 }, @@ -595,15 +594,16 @@ static const struct i2c_device_id wm8994_i2c_id[] = { }; MODULE_DEVICE_TABLE(i2c, wm8994_i2c_id); +UNIVERSAL_DEV_PM_OPS(wm8994_pm_ops, wm8994_suspend, wm8994_resume, NULL); + static struct i2c_driver wm8994_i2c_driver = { .driver = { - .name = "wm8994", - .owner = THIS_MODULE, + .name = "wm8994", + .owner = THIS_MODULE, + .pm = &wm8994_pm_ops, }, .probe = wm8994_i2c_probe, .remove = wm8994_i2c_remove, - .suspend = wm8994_i2c_suspend, - .resume = wm8994_i2c_resume, .id_table = wm8994_i2c_id, }; -- cgit v1.2.3-70-g09d2 From 816b4580cef948c7d9ac9e3e63fb1b663012f057 Mon Sep 17 00:00:00 2001 From: Andres Salomon Date: Tue, 30 Nov 2010 13:54:39 -0800 Subject: mfd: Fix cs5535 warning on x86-64 ARRAY_SIZE() returns size_t; use %zu instead of %d so that we don't get warnings on x86-64. Signed-off-by: Andres Salomon Acked-by: Randy Dunlap Signed-off-by: Samuel Ortiz --- drivers/mfd/cs5535-mfd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mfd/cs5535-mfd.c b/drivers/mfd/cs5535-mfd.c index b141ca7c777..59ca6f151e7 100644 --- a/drivers/mfd/cs5535-mfd.c +++ b/drivers/mfd/cs5535-mfd.c @@ -103,7 +103,7 @@ static int __devinit cs5535_mfd_probe(struct pci_dev *pdev, goto err_disable; } - dev_info(&pdev->dev, "%d devices registered.\n", + dev_info(&pdev->dev, "%zu devices registered.\n", ARRAY_SIZE(cs5535_mfd_cells)); return 0; -- cgit v1.2.3-70-g09d2 From df96669401cb8bac216f911f5bf92910357b29d3 Mon Sep 17 00:00:00 2001 From: Andres Salomon Date: Sat, 23 Oct 2010 00:41:09 -0700 Subject: gpio: Convert cs5535 from pci device to platform device The cs5535-mfd driver now takes care of the PCI BAR handling; this simplifies the gpio driver a lot. Signed-off-by: Andres Salomon Signed-off-by: Samuel Ortiz --- drivers/gpio/cs5535-gpio.c | 93 ++++++++++++++++------------------------------ 1 file changed, 31 insertions(+), 62 deletions(-) diff --git a/drivers/gpio/cs5535-gpio.c b/drivers/gpio/cs5535-gpio.c index 815d98b2c1b..70967e23bc3 100644 --- a/drivers/gpio/cs5535-gpio.c +++ b/drivers/gpio/cs5535-gpio.c @@ -11,14 +11,13 @@ #include #include #include -#include +#include #include #include #include #include #define DRV_NAME "cs5535-gpio" -#define GPIO_BAR 1 /* * Some GPIO pins @@ -47,7 +46,7 @@ static struct cs5535_gpio_chip { struct gpio_chip chip; resource_size_t base; - struct pci_dev *pdev; + struct platform_device *pdev; spinlock_t lock; } cs5535_gpio_chip; @@ -301,10 +300,10 @@ static struct cs5535_gpio_chip cs5535_gpio_chip = { }, }; -static int __init cs5535_gpio_probe(struct pci_dev *pdev, - const struct pci_device_id *pci_id) +static int __devinit cs5535_gpio_probe(struct platform_device *pdev) { - int err; + struct resource *res; + int err = -EIO; ulong mask_orig = mask; /* There are two ways to get the GPIO base address; one is by @@ -314,25 +313,24 @@ static int __init cs5535_gpio_probe(struct pci_dev *pdev, * it turns out to be unreliable in the face of crappy BIOSes, we * can always go back to using MSRs.. */ - err = pci_enable_device_io(pdev); - if (err) { - dev_err(&pdev->dev, "can't enable device IO\n"); + res = platform_get_resource(pdev, IORESOURCE_IO, 0); + if (!res) { + dev_err(&pdev->dev, "can't fetch device resource info\n"); goto done; } - err = pci_request_region(pdev, GPIO_BAR, DRV_NAME); - if (err) { - dev_err(&pdev->dev, "can't alloc PCI BAR #%d\n", GPIO_BAR); + if (!request_region(res->start, resource_size(res), pdev->name)) { + dev_err(&pdev->dev, "can't request region\n"); goto done; } /* set up the driver-specific struct */ - cs5535_gpio_chip.base = pci_resource_start(pdev, GPIO_BAR); + cs5535_gpio_chip.base = res->start; cs5535_gpio_chip.pdev = pdev; spin_lock_init(&cs5535_gpio_chip.lock); - dev_info(&pdev->dev, "allocated PCI BAR #%d: base 0x%llx\n", GPIO_BAR, - (unsigned long long) cs5535_gpio_chip.base); + dev_info(&pdev->dev, "region 0x%x - 0x%x reserved\n", + res->start, res->end); /* mask out reserved pins */ mask &= 0x1F7FFFFF; @@ -350,78 +348,49 @@ static int __init cs5535_gpio_probe(struct pci_dev *pdev, if (err) goto release_region; - dev_info(&pdev->dev, DRV_NAME ": GPIO support successfully loaded.\n"); + dev_info(&pdev->dev, "GPIO support successfully loaded.\n"); return 0; release_region: - pci_release_region(pdev, GPIO_BAR); + release_region(res->start, resource_size(res)); done: return err; } -static void __exit cs5535_gpio_remove(struct pci_dev *pdev) +static int __devexit cs5535_gpio_remove(struct platform_device *pdev) { + struct resource *r; int err; err = gpiochip_remove(&cs5535_gpio_chip.chip); if (err) { /* uhh? */ dev_err(&pdev->dev, "unable to remove gpio_chip?\n"); + return err; } - pci_release_region(pdev, GPIO_BAR); -} - -static struct pci_device_id cs5535_gpio_pci_tbl[] = { - { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_CS5535_ISA) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_ISA) }, - { 0, }, -}; -MODULE_DEVICE_TABLE(pci, cs5535_gpio_pci_tbl); -/* - * We can't use the standard PCI driver registration stuff here, since - * that allows only one driver to bind to each PCI device (and we want - * multiple drivers to be able to bind to the device). Instead, manually - * scan for the PCI device, request a single region, and keep track of the - * devices that we're using. - */ - -static int __init cs5535_gpio_scan_pci(void) -{ - struct pci_dev *pdev; - int err = -ENODEV; - int i; - - for (i = 0; i < ARRAY_SIZE(cs5535_gpio_pci_tbl); i++) { - pdev = pci_get_device(cs5535_gpio_pci_tbl[i].vendor, - cs5535_gpio_pci_tbl[i].device, NULL); - if (pdev) { - err = cs5535_gpio_probe(pdev, &cs5535_gpio_pci_tbl[i]); - if (err) - pci_dev_put(pdev); - - /* we only support a single CS5535/6 southbridge */ - break; - } - } - - return err; + r = platform_get_resource(pdev, IORESOURCE_IO, 0); + release_region(r->start, resource_size(r)); + return 0; } -static void __exit cs5535_gpio_free_pci(void) -{ - cs5535_gpio_remove(cs5535_gpio_chip.pdev); - pci_dev_put(cs5535_gpio_chip.pdev); -} +static struct platform_driver cs5535_gpio_drv = { + .driver = { + .name = DRV_NAME, + .owner = THIS_MODULE, + }, + .probe = cs5535_gpio_probe, + .remove = __devexit_p(cs5535_gpio_remove), +}; static int __init cs5535_gpio_init(void) { - return cs5535_gpio_scan_pci(); + return platform_driver_register(&cs5535_gpio_drv); } static void __exit cs5535_gpio_exit(void) { - cs5535_gpio_free_pci(); + platform_driver_unregister(&cs5535_gpio_drv); } module_init(cs5535_gpio_init); -- cgit v1.2.3-70-g09d2 From 69bc6def395ebfdb137898179d7e559ba4c779d8 Mon Sep 17 00:00:00 2001 From: Andres Salomon Date: Sat, 23 Oct 2010 00:41:14 -0700 Subject: misc: Convert cs5535-mfgpt from pci device to platform device The cs5535-mfd driver now takes care of the PCI BAR handling; this simplifies the mfgpt driver a bunch. Signed-off-by: Andres Salomon Signed-off-by: Samuel Ortiz --- drivers/misc/cs5535-mfgpt.c | 73 +++++++++++++-------------------------------- 1 file changed, 21 insertions(+), 52 deletions(-) diff --git a/drivers/misc/cs5535-mfgpt.c b/drivers/misc/cs5535-mfgpt.c index 6f6218061b0..499bd64e4d1 100644 --- a/drivers/misc/cs5535-mfgpt.c +++ b/drivers/misc/cs5535-mfgpt.c @@ -16,12 +16,11 @@ #include #include #include -#include +#include #include #include #define DRV_NAME "cs5535-mfgpt" -#define MFGPT_BAR 2 static int mfgpt_reset_timers; module_param_named(mfgptfix, mfgpt_reset_timers, int, 0644); @@ -37,7 +36,7 @@ static struct cs5535_mfgpt_chip { DECLARE_BITMAP(avail, MFGPT_MAX_TIMERS); resource_size_t base; - struct pci_dev *pdev; + struct platform_device *pdev; spinlock_t lock; int initialized; } cs5535_mfgpt_chip; @@ -290,10 +289,10 @@ static int __init scan_timers(struct cs5535_mfgpt_chip *mfgpt) return timers; } -static int __init cs5535_mfgpt_probe(struct pci_dev *pdev, - const struct pci_device_id *pci_id) +static int __devinit cs5535_mfgpt_probe(struct platform_device *pdev) { - int err, t; + struct resource *res; + int err = -EIO, t; /* There are two ways to get the MFGPT base address; one is by * fetching it from MSR_LBAR_MFGPT, the other is by reading the @@ -302,29 +301,28 @@ static int __init cs5535_mfgpt_probe(struct pci_dev *pdev, * it turns out to be unreliable in the face of crappy BIOSes, we * can always go back to using MSRs.. */ - err = pci_enable_device_io(pdev); - if (err) { - dev_err(&pdev->dev, "can't enable device IO\n"); + res = platform_get_resource(pdev, IORESOURCE_IO, 0); + if (!res) { + dev_err(&pdev->dev, "can't fetch device resource info\n"); goto done; } - err = pci_request_region(pdev, MFGPT_BAR, DRV_NAME); - if (err) { - dev_err(&pdev->dev, "can't alloc PCI BAR #%d\n", MFGPT_BAR); + if (!request_region(res->start, resource_size(res), pdev->name)) { + dev_err(&pdev->dev, "can't request region\n"); goto done; } /* set up the driver-specific struct */ - cs5535_mfgpt_chip.base = pci_resource_start(pdev, MFGPT_BAR); + cs5535_mfgpt_chip.base = res->start; cs5535_mfgpt_chip.pdev = pdev; spin_lock_init(&cs5535_mfgpt_chip.lock); - dev_info(&pdev->dev, "allocated PCI BAR #%d: base 0x%llx\n", MFGPT_BAR, - (unsigned long long) cs5535_mfgpt_chip.base); + dev_info(&pdev->dev, "region 0x%x - 0x%x reserved\n", res->start, + res->end); /* detect the available timers */ t = scan_timers(&cs5535_mfgpt_chip); - dev_info(&pdev->dev, DRV_NAME ": %d MFGPT timers available\n", t); + dev_info(&pdev->dev, "%d MFGPT timers available\n", t); cs5535_mfgpt_chip.initialized = 1; return 0; @@ -332,47 +330,18 @@ done: return err; } -static struct pci_device_id cs5535_mfgpt_pci_tbl[] = { - { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_CS5535_ISA) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_ISA) }, - { 0, }, +static struct platform_driver cs5535_mfgpt_drv = { + .driver = { + .name = DRV_NAME, + .owner = THIS_MODULE, + }, + .probe = cs5535_mfgpt_probe, }; -MODULE_DEVICE_TABLE(pci, cs5535_mfgpt_pci_tbl); -/* - * Just like with the cs5535-gpio driver, we can't use the standard PCI driver - * registration stuff. It only allows only one driver to bind to each PCI - * device, and we want the GPIO and MFGPT drivers to be able to share a PCI - * device. Instead, we manually scan for the PCI device, request a single - * region, and keep track of the devices that we're using. - */ - -static int __init cs5535_mfgpt_scan_pci(void) -{ - struct pci_dev *pdev; - int err = -ENODEV; - int i; - - for (i = 0; i < ARRAY_SIZE(cs5535_mfgpt_pci_tbl); i++) { - pdev = pci_get_device(cs5535_mfgpt_pci_tbl[i].vendor, - cs5535_mfgpt_pci_tbl[i].device, NULL); - if (pdev) { - err = cs5535_mfgpt_probe(pdev, - &cs5535_mfgpt_pci_tbl[i]); - if (err) - pci_dev_put(pdev); - - /* we only support a single CS5535/6 southbridge */ - break; - } - } - - return err; -} static int __init cs5535_mfgpt_init(void) { - return cs5535_mfgpt_scan_pci(); + return platform_driver_register(&cs5535_mfgpt_drv); } module_init(cs5535_mfgpt_init); -- cgit v1.2.3-70-g09d2 From ec9d0cf578007fa3f86fa34d77d9ccba82f03b29 Mon Sep 17 00:00:00 2001 From: Andres Salomon Date: Wed, 1 Dec 2010 19:55:10 -0800 Subject: gpio/misc: Add MODULE_ALIAS entries for CS5535 functions This adds MODULE_ALIAS entries to the various cs5535 subdevice modules; this allows the modules to automatically be loaded when cs5535-mfd loads. Signed-off-by: Andres Salomon Signed-off-by: Samuel Ortiz --- drivers/gpio/cs5535-gpio.c | 1 + drivers/misc/cs5535-mfgpt.c | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/gpio/cs5535-gpio.c b/drivers/gpio/cs5535-gpio.c index 70967e23bc3..f9813ef4853 100644 --- a/drivers/gpio/cs5535-gpio.c +++ b/drivers/gpio/cs5535-gpio.c @@ -399,3 +399,4 @@ module_exit(cs5535_gpio_exit); MODULE_AUTHOR("Andres Salomon "); MODULE_DESCRIPTION("AMD CS5535/CS5536 GPIO driver"); MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:" DRV_NAME); diff --git a/drivers/misc/cs5535-mfgpt.c b/drivers/misc/cs5535-mfgpt.c index 499bd64e4d1..26693060b29 100644 --- a/drivers/misc/cs5535-mfgpt.c +++ b/drivers/misc/cs5535-mfgpt.c @@ -349,3 +349,4 @@ module_init(cs5535_mfgpt_init); MODULE_AUTHOR("Andres Salomon "); MODULE_DESCRIPTION("CS5535/CS5536 MFGPT timer driver"); MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:" DRV_NAME); -- cgit v1.2.3-70-g09d2 From 6bce7bf1a1f8a79a57ff69910c115e1d2ed8913d Mon Sep 17 00:00:00 2001 From: Mattias Wallin Date: Thu, 2 Dec 2010 15:08:32 +0100 Subject: mfd: ab8500-core improved error handling in get_chip_id We check for dev before dereferencing it. Signed-off-by: Mattias Wallin Signed-off-by: Samuel Ortiz --- drivers/mfd/ab8500-core.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/mfd/ab8500-core.c b/drivers/mfd/ab8500-core.c index d9640a623ff..e91b5b75900 100644 --- a/drivers/mfd/ab8500-core.c +++ b/drivers/mfd/ab8500-core.c @@ -103,8 +103,12 @@ static const int ab8500_irq_regoffset[AB8500_NUM_IRQ_REGS] = { static int ab8500_get_chip_id(struct device *dev) { - struct ab8500 *ab8500 = dev_get_drvdata(dev->parent); - return (int)ab8500->chip_id; + struct ab8500 *ab8500; + + if (!dev) + return -EINVAL; + ab8500 = dev_get_drvdata(dev->parent); + return ab8500 ? (int)ab8500->chip_id : -EINVAL; } static int set_register_interruptible(struct ab8500 *ab8500, u8 bank, -- cgit v1.2.3-70-g09d2 From cca69b67b3ba954ed8642583295b51933f902227 Mon Sep 17 00:00:00 2001 From: Mattias Wallin Date: Thu, 2 Dec 2010 15:09:36 +0100 Subject: mfd: Export ab8500 chip id to sysfs This patch adds a file into sysfs for reading out chip id. It has been requested for modem silent reboot. Signed-off-by: Mattias Wallin Signed-off-by: Ludovic Barre Signed-off-by: Samuel Ortiz --- drivers/mfd/ab8500-core.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/mfd/ab8500-core.c b/drivers/mfd/ab8500-core.c index e91b5b75900..2bd4437cf33 100644 --- a/drivers/mfd/ab8500-core.c +++ b/drivers/mfd/ab8500-core.c @@ -436,6 +436,26 @@ static struct mfd_cell ab8500_devs[] = { }, }; +static ssize_t show_chip_id(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct ab8500 *ab8500; + + ab8500 = dev_get_drvdata(dev); + return sprintf(buf, "%#x\n", ab8500 ? ab8500->chip_id : -EINVAL); +} + +static DEVICE_ATTR(chip_id, S_IRUGO, show_chip_id, NULL); + +static struct attribute *ab8500_sysfs_entries[] = { + &dev_attr_chip_id.attr, + NULL, +}; + +static struct attribute_group ab8500_attr_group = { + .attrs = ab8500_sysfs_entries, +}; + int __devinit ab8500_init(struct ab8500 *ab8500) { struct ab8500_platform_data *plat = dev_get_platdata(ab8500->dev); @@ -510,6 +530,10 @@ int __devinit ab8500_init(struct ab8500 *ab8500) if (ret) goto out_freeirq; + ret = sysfs_create_group(&ab8500->dev->kobj, &ab8500_attr_group); + if (ret) + dev_err(ab8500->dev, "error creating sysfs entries\n"); + return ret; out_freeirq: @@ -523,6 +547,7 @@ out_removeirq: int __devexit ab8500_exit(struct ab8500 *ab8500) { + sysfs_remove_group(&ab8500->dev->kobj, &ab8500_attr_group); mfd_remove_devices(ab8500->dev); if (ab8500->irq_base) { free_irq(ab8500->irq, ab8500); -- cgit v1.2.3-70-g09d2 From 4f079985b2caacfda5103dd85fb028a2848c84ab Mon Sep 17 00:00:00 2001 From: Mattias Wallin Date: Thu, 2 Dec 2010 15:10:27 +0100 Subject: mfd: ab8500-core wake up from suspend This patch makes the system wake up from suspend when an ab8500 interrupt occur. This can for example be USB cable insert or an RTC alarm. Signed-off-by: Mattias Wallin Signed-off-by: Samuel Ortiz --- drivers/mfd/ab8500-core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/mfd/ab8500-core.c b/drivers/mfd/ab8500-core.c index 2bd4437cf33..e464e94c4bc 100644 --- a/drivers/mfd/ab8500-core.c +++ b/drivers/mfd/ab8500-core.c @@ -519,7 +519,8 @@ int __devinit ab8500_init(struct ab8500 *ab8500) return ret; ret = request_threaded_irq(ab8500->irq, NULL, ab8500_irq, - IRQF_ONESHOT, "ab8500", ab8500); + IRQF_ONESHOT | IRQF_NO_SUSPEND, + "ab8500", ab8500); if (ret) goto out_removeirq; } -- cgit v1.2.3-70-g09d2 From e098aded79f24e2024139e82f778ff9db6dc142a Mon Sep 17 00:00:00 2001 From: Mattias Wallin Date: Thu, 2 Dec 2010 15:40:31 +0100 Subject: mfd: ab8500-core ioresources irq for subdrivers added This patch adds the ioresources used by subdrivers to retrieve their interrupt. Signed-off-by: Mattias Wallin Signed-off-by: Samuel Ortiz --- drivers/mfd/ab8500-core.c | 206 +++++++++++++++++++++++++++++++++++++++++++-- include/linux/mfd/ab8500.h | 4 +- 2 files changed, 201 insertions(+), 9 deletions(-) diff --git a/drivers/mfd/ab8500-core.c b/drivers/mfd/ab8500-core.c index e464e94c4bc..7f01a3a1d10 100644 --- a/drivers/mfd/ab8500-core.c +++ b/drivers/mfd/ab8500-core.c @@ -397,12 +397,188 @@ static struct resource ab8500_poweronkey_db_resources[] = { }, }; +static struct resource ab8500_bm_resources[] = { + { + .name = "MAIN_EXT_CH_NOT_OK", + .start = AB8500_INT_MAIN_EXT_CH_NOT_OK, + .end = AB8500_INT_MAIN_EXT_CH_NOT_OK, + .flags = IORESOURCE_IRQ, + }, + { + .name = "BATT_OVV", + .start = AB8500_INT_BATT_OVV, + .end = AB8500_INT_BATT_OVV, + .flags = IORESOURCE_IRQ, + }, + { + .name = "MAIN_CH_UNPLUG_DET", + .start = AB8500_INT_MAIN_CH_UNPLUG_DET, + .end = AB8500_INT_MAIN_CH_UNPLUG_DET, + .flags = IORESOURCE_IRQ, + }, + { + .name = "MAIN_CHARGE_PLUG_DET", + .start = AB8500_INT_MAIN_CH_PLUG_DET, + .end = AB8500_INT_MAIN_CH_PLUG_DET, + .flags = IORESOURCE_IRQ, + }, + { + .name = "VBUS_DET_F", + .start = AB8500_INT_VBUS_DET_F, + .end = AB8500_INT_VBUS_DET_F, + .flags = IORESOURCE_IRQ, + }, + { + .name = "VBUS_DET_R", + .start = AB8500_INT_VBUS_DET_R, + .end = AB8500_INT_VBUS_DET_R, + .flags = IORESOURCE_IRQ, + }, + { + .name = "BAT_CTRL_INDB", + .start = AB8500_INT_BAT_CTRL_INDB, + .end = AB8500_INT_BAT_CTRL_INDB, + .flags = IORESOURCE_IRQ, + }, + { + .name = "CH_WD_EXP", + .start = AB8500_INT_CH_WD_EXP, + .end = AB8500_INT_CH_WD_EXP, + .flags = IORESOURCE_IRQ, + }, + { + .name = "VBUS_OVV", + .start = AB8500_INT_VBUS_OVV, + .end = AB8500_INT_VBUS_OVV, + .flags = IORESOURCE_IRQ, + }, + { + .name = "NCONV_ACCU", + .start = AB8500_INT_CCN_CONV_ACC, + .end = AB8500_INT_CCN_CONV_ACC, + .flags = IORESOURCE_IRQ, + }, + { + .name = "LOW_BAT_F", + .start = AB8500_INT_LOW_BAT_F, + .end = AB8500_INT_LOW_BAT_F, + .flags = IORESOURCE_IRQ, + }, + { + .name = "LOW_BAT_R", + .start = AB8500_INT_LOW_BAT_R, + .end = AB8500_INT_LOW_BAT_R, + .flags = IORESOURCE_IRQ, + }, + { + .name = "BTEMP_LOW", + .start = AB8500_INT_BTEMP_LOW, + .end = AB8500_INT_BTEMP_LOW, + .flags = IORESOURCE_IRQ, + }, + { + .name = "BTEMP_HIGH", + .start = AB8500_INT_BTEMP_HIGH, + .end = AB8500_INT_BTEMP_HIGH, + .flags = IORESOURCE_IRQ, + }, + { + .name = "USB_CHARGER_NOT_OKR", + .start = AB8500_INT_USB_CHARGER_NOT_OK, + .end = AB8500_INT_USB_CHARGER_NOT_OK, + .flags = IORESOURCE_IRQ, + }, + { + .name = "USB_CHARGE_DET_DONE", + .start = AB8500_INT_USB_CHG_DET_DONE, + .end = AB8500_INT_USB_CHG_DET_DONE, + .flags = IORESOURCE_IRQ, + }, + { + .name = "USB_CH_TH_PROT_R", + .start = AB8500_INT_USB_CH_TH_PROT_R, + .end = AB8500_INT_USB_CH_TH_PROT_R, + .flags = IORESOURCE_IRQ, + }, + { + .name = "MAIN_CH_TH_PROT_R", + .start = AB8500_INT_MAIN_CH_TH_PROT_R, + .end = AB8500_INT_MAIN_CH_TH_PROT_R, + .flags = IORESOURCE_IRQ, + }, + { + .name = "USB_CHARGER_NOT_OKF", + .start = AB8500_INT_USB_CHARGER_NOT_OKF, + .end = AB8500_INT_USB_CHARGER_NOT_OKF, + .flags = IORESOURCE_IRQ, + }, +}; + +static struct resource ab8500_debug_resources[] = { + { + .name = "IRQ_FIRST", + .start = AB8500_INT_MAIN_EXT_CH_NOT_OK, + .end = AB8500_INT_MAIN_EXT_CH_NOT_OK, + .flags = IORESOURCE_IRQ, + }, + { + .name = "IRQ_LAST", + .start = AB8500_INT_USB_CHARGER_NOT_OKF, + .end = AB8500_INT_USB_CHARGER_NOT_OKF, + .flags = IORESOURCE_IRQ, + }, +}; + +static struct resource ab8500_usb_resources[] = { + { + .name = "ID_WAKEUP_R", + .start = AB8500_INT_ID_WAKEUP_R, + .end = AB8500_INT_ID_WAKEUP_R, + .flags = IORESOURCE_IRQ, + }, + { + .name = "ID_WAKEUP_F", + .start = AB8500_INT_ID_WAKEUP_F, + .end = AB8500_INT_ID_WAKEUP_F, + .flags = IORESOURCE_IRQ, + }, + { + .name = "VBUS_DET_F", + .start = AB8500_INT_VBUS_DET_F, + .end = AB8500_INT_VBUS_DET_F, + .flags = IORESOURCE_IRQ, + }, + { + .name = "VBUS_DET_R", + .start = AB8500_INT_VBUS_DET_R, + .end = AB8500_INT_VBUS_DET_R, + .flags = IORESOURCE_IRQ, + }, +}; + +static struct resource ab8500_temp_resources[] = { + { + .name = "AB8500_TEMP_WARM", + .start = AB8500_INT_TEMP_WARM, + .end = AB8500_INT_TEMP_WARM, + .flags = IORESOURCE_IRQ, + }, +}; + static struct mfd_cell ab8500_devs[] = { #ifdef CONFIG_DEBUG_FS { .name = "ab8500-debug", + .num_resources = ARRAY_SIZE(ab8500_debug_resources), + .resources = ab8500_debug_resources, }, #endif + { + .name = "ab8500-sysctrl", + }, + { + .name = "ab8500-regulator", + }, { .name = "ab8500-gpadc", .num_resources = ARRAY_SIZE(ab8500_gpadc_resources), @@ -413,6 +589,22 @@ static struct mfd_cell ab8500_devs[] = { .num_resources = ARRAY_SIZE(ab8500_rtc_resources), .resources = ab8500_rtc_resources, }, + { + .name = "ab8500-bm", + .num_resources = ARRAY_SIZE(ab8500_bm_resources), + .resources = ab8500_bm_resources, + }, + { .name = "ab8500-codec", }, + { + .name = "ab8500-usb", + .num_resources = ARRAY_SIZE(ab8500_usb_resources), + .resources = ab8500_usb_resources, + }, + { + .name = "ab8500-poweron-key", + .num_resources = ARRAY_SIZE(ab8500_poweronkey_db_resources), + .resources = ab8500_poweronkey_db_resources, + }, { .name = "ab8500-pwm", .id = 1, @@ -425,14 +617,14 @@ static struct mfd_cell ab8500_devs[] = { .name = "ab8500-pwm", .id = 3, }, - { .name = "ab8500-charger", }, - { .name = "ab8500-audio", }, - { .name = "ab8500-usb", }, - { .name = "ab8500-regulator", }, + { .name = "ab8500-leds", }, { - .name = "ab8500-poweron-key", - .num_resources = ARRAY_SIZE(ab8500_poweronkey_db_resources), - .resources = ab8500_poweronkey_db_resources, + .name = "ab8500-denc", + }, + { + .name = "ab8500-temp", + .num_resources = ARRAY_SIZE(ab8500_temp_resources), + .resources = ab8500_temp_resources, }, }; diff --git a/include/linux/mfd/ab8500.h b/include/linux/mfd/ab8500.h index 85cf2c28fac..1ad16965523 100644 --- a/include/linux/mfd/ab8500.h +++ b/include/linux/mfd/ab8500.h @@ -91,8 +91,8 @@ #define AB8500_INT_ID_DET_R4F 93 #define AB8500_INT_USB_CHG_DET_DONE 94 #define AB8500_INT_USB_CH_TH_PROT_F 96 -#define AB8500_INT_USB_CH_TH_PROP_R 97 -#define AB8500_INT_MAIN_CH_TH_PROP_F 98 +#define AB8500_INT_USB_CH_TH_PROT_R 97 +#define AB8500_INT_MAIN_CH_TH_PROT_F 98 #define AB8500_INT_MAIN_CH_TH_PROT_R 99 #define AB8500_INT_USB_CHARGER_NOT_OKF 103 -- cgit v1.2.3-70-g09d2 From 5b9cecd68f3ef72ab9e586b0c2995a40a2f1e630 Mon Sep 17 00:00:00 2001 From: Bryan Wu Date: Wed, 8 Dec 2010 10:42:04 +0800 Subject: mfd: Fix twl_probe section mismatch warning in mfd/twl-core.c Fix the following section mismatch warning when building omap2plus_defconfig: WARNING: vmlinux.o(.data+0x47d7c): Section mismatch in reference from the variable twl_driver to the function .init.text:twl_probe() Signed-off-by: Bryan Wu Signed-off-by: Paul Walmsley Signed-off-by: Samuel Ortiz --- drivers/mfd/twl-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c index 12abd5b924b..a35fa7dcbf5 100644 --- a/drivers/mfd/twl-core.c +++ b/drivers/mfd/twl-core.c @@ -1003,7 +1003,7 @@ static int twl_remove(struct i2c_client *client) } /* NOTE: this driver only handles a single twl4030/tps659x0 chip */ -static int __init +static int __devinit twl_probe(struct i2c_client *client, const struct i2c_device_id *id) { int status; -- cgit v1.2.3-70-g09d2 From 4d1cdbf696501c0a942c5b71f3fab9434a4465c4 Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Thu, 9 Dec 2010 10:30:11 -0700 Subject: mfd: Remove tps6586x device ID check ... and convert it to a dev_info print at probe time. There are many variants of this chip with different values of VERSIONCRC. The set of values is large, and not useful to enumerate. All are SW compatible. The difference lies in default settings of the various power rails, and other similar differences. The driver, or clients of the driver, shouldn't be affected by this, since all rails should be programmed into the desired state in all cases for correct operation. Derived-from-code-by: Andrew Chew Signed-off-by: Stephen Warren Signed-off-by: Samuel Ortiz --- drivers/mfd/tps6586x.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/mfd/tps6586x.c b/drivers/mfd/tps6586x.c index b4931ab3492..35757399add 100644 --- a/drivers/mfd/tps6586x.c +++ b/drivers/mfd/tps6586x.c @@ -46,8 +46,6 @@ /* device id */ #define TPS6586X_VERSIONCRC 0xcd -#define TPS658621A_VERSIONCRC 0x15 -#define TPS658621C_VERSIONCRC 0x2c struct tps6586x_irq_data { u8 mask_reg; @@ -498,11 +496,7 @@ static int __devinit tps6586x_i2c_probe(struct i2c_client *client, return -EIO; } - if ((ret != TPS658621A_VERSIONCRC) && - (ret != TPS658621C_VERSIONCRC)) { - dev_err(&client->dev, "Unsupported chip ID: %x\n", ret); - return -ENODEV; - } + dev_info(&client->dev, "VERSIONCRC is %02x\n", ret); tps6586x = kzalloc(sizeof(struct tps6586x), GFP_KERNEL); if (tps6586x == NULL) -- cgit v1.2.3-70-g09d2 From 59f2ad2e0ee13bbb4cfb399e08df8c54b264dd39 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Sat, 11 Dec 2010 12:59:35 +0000 Subject: mfd: Staticise unexported symbols in ASIC3 There's no use of either of these outside of the driver so they can be declared static. Signed-off-by: Mark Brown Signed-off-by: Samuel Ortiz --- drivers/mfd/asic3.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/mfd/asic3.c b/drivers/mfd/asic3.c index 7de708d15d7..6b82eb0fa55 100644 --- a/drivers/mfd/asic3.c +++ b/drivers/mfd/asic3.c @@ -57,7 +57,7 @@ struct asic3_clk { .rate = _rate, \ } -struct asic3_clk asic3_clk_init[] __initdata = { +static struct asic3_clk asic3_clk_init[] __initdata = { INIT_CDEX(SPI, 0), INIT_CDEX(OWM, 5000000), INIT_CDEX(PWM0, 0), @@ -102,7 +102,7 @@ static inline u32 asic3_read_register(struct asic3 *asic, (reg >> asic->bus_shift)); } -void asic3_set_register(struct asic3 *asic, u32 reg, u32 bits, bool set) +static void asic3_set_register(struct asic3 *asic, u32 reg, u32 bits, bool set) { unsigned long flags; u32 val; -- cgit v1.2.3-70-g09d2 From fe421425d78176f4a3509ce11b8d683cf1604e3a Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Sat, 11 Dec 2010 13:00:34 +0000 Subject: mfd: Correct ASIC3 IRQ_OWM resource setup We should specify both a start and an end for the IRQ range rather than initialise the start twice. Signed-off-by: Mark Brown Signed-off-by: Samuel Ortiz --- drivers/mfd/asic3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mfd/asic3.c b/drivers/mfd/asic3.c index 6b82eb0fa55..3c7dc5ebfe4 100644 --- a/drivers/mfd/asic3.c +++ b/drivers/mfd/asic3.c @@ -635,7 +635,7 @@ static struct resource ds1wm_resources[] = { }, { .start = ASIC3_IRQ_OWM, - .start = ASIC3_IRQ_OWM, + .end = ASIC3_IRQ_OWM, .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE, }, }; -- cgit v1.2.3-70-g09d2 From 87fff232cb76828b44312843d96854704f71ed19 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Mon, 13 Dec 2010 14:06:47 +0000 Subject: mfd: Use NULL to initialise NULL pointers in ab8500-debugfs Partly for coding style reasons, but mostly because sparse warns on it. Signed-off-by: Mark Brown Acked-by: Mattias Wallin Signed-off-by: Samuel Ortiz --- drivers/mfd/ab8500-debugfs.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/mfd/ab8500-debugfs.c b/drivers/mfd/ab8500-debugfs.c index dfdc76e0b96..3c1541ae722 100644 --- a/drivers/mfd/ab8500-debugfs.c +++ b/drivers/mfd/ab8500-debugfs.c @@ -189,7 +189,7 @@ static struct ab8500_i2c_ranges debug_ranges[AB8500_NUM_BANKS] = { }, [AB8500_DBI] = { .num_ranges = 0, - .range = 0, + .range = NULL, }, [AB8500_ECI_AV_ACC] = { .num_ranges = 1, @@ -202,7 +202,7 @@ static struct ab8500_i2c_ranges debug_ranges[AB8500_NUM_BANKS] = { }, [0x9] = { .num_ranges = 0, - .range = 0, + .range = NULL, }, [AB8500_GPADC] = { .num_ranges = 1, @@ -278,7 +278,7 @@ static struct ab8500_i2c_ranges debug_ranges[AB8500_NUM_BANKS] = { }, [AB8500_INTERRUPT] = { .num_ranges = 0, - .range = 0, + .range = NULL, }, [AB8500_RTC] = { .num_ranges = 1, @@ -328,19 +328,19 @@ static struct ab8500_i2c_ranges debug_ranges[AB8500_NUM_BANKS] = { }, [0x11] = { .num_ranges = 0, - .range = 0, + .range = NULL, }, [0x12] = { .num_ranges = 0, - .range = 0, + .range = NULL, }, [0x13] = { .num_ranges = 0, - .range = 0, + .range = NULL, }, [0x14] = { .num_ranges = 0, - .range = 0, + .range = NULL, }, [AB8500_OTP_EMUL] = { .num_ranges = 1, -- cgit v1.2.3-70-g09d2 From 8d2d3a3a329ebf20f733ac1499ebc565f497f051 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Sat, 11 Dec 2010 16:44:49 +0000 Subject: mfd: Staticise internal functions in HTC I2CCPLD driver Most of these are GPIO operations, though a couple are just internal only functions. Signed-off-by: Mark Brown Acked-by: Cory Maccarrone Signed-off-by: Samuel Ortiz --- drivers/mfd/htc-i2cpld.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/mfd/htc-i2cpld.c b/drivers/mfd/htc-i2cpld.c index 594c9a8e25e..dd24355c965 100644 --- a/drivers/mfd/htc-i2cpld.c +++ b/drivers/mfd/htc-i2cpld.c @@ -235,7 +235,7 @@ static irqreturn_t htcpld_handler(int irq, void *dev) * and that work is scheduled in the set routine. The kernel can then run * the I2C functions, which will sleep, in process context. */ -void htcpld_chip_set(struct gpio_chip *chip, unsigned offset, int val) +static void htcpld_chip_set(struct gpio_chip *chip, unsigned offset, int val) { struct i2c_client *client; struct htcpld_chip *chip_data; @@ -259,7 +259,7 @@ void htcpld_chip_set(struct gpio_chip *chip, unsigned offset, int val) schedule_work(&(chip_data->set_val_work)); } -void htcpld_chip_set_ni(struct work_struct *work) +static void htcpld_chip_set_ni(struct work_struct *work) { struct htcpld_chip *chip_data; struct i2c_client *client; @@ -269,7 +269,7 @@ void htcpld_chip_set_ni(struct work_struct *work) i2c_smbus_read_byte_data(client, chip_data->cache_out); } -int htcpld_chip_get(struct gpio_chip *chip, unsigned offset) +static int htcpld_chip_get(struct gpio_chip *chip, unsigned offset) { struct htcpld_chip *chip_data; int val = 0; @@ -316,7 +316,7 @@ static int htcpld_direction_input(struct gpio_chip *chip, return (offset < chip->ngpio) ? 0 : -EINVAL; } -int htcpld_chip_to_irq(struct gpio_chip *chip, unsigned offset) +static int htcpld_chip_to_irq(struct gpio_chip *chip, unsigned offset) { struct htcpld_chip *chip_data; @@ -328,7 +328,7 @@ int htcpld_chip_to_irq(struct gpio_chip *chip, unsigned offset) return -EINVAL; } -void htcpld_chip_reset(struct i2c_client *client) +static void htcpld_chip_reset(struct i2c_client *client) { struct htcpld_chip *chip_data = i2c_get_clientdata(client); if (!chip_data) -- cgit v1.2.3-70-g09d2 From 49f89d9acb6cba6475923e42a3d13540a70a926e Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Sat, 11 Dec 2010 12:31:31 +0000 Subject: mfd: Convert 88PM860x driver to new irq_ APIs The interrupt controller APIs are being updated to pass a struct irq_data rather than the interrupt number. Signed-off-by: Mark Brown Signed-off-by: Samuel Ortiz --- drivers/mfd/88pm860x-core.c | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/drivers/mfd/88pm860x-core.c b/drivers/mfd/88pm860x-core.c index 20895e7a99c..793300c554b 100644 --- a/drivers/mfd/88pm860x-core.c +++ b/drivers/mfd/88pm860x-core.c @@ -361,12 +361,6 @@ static struct pm860x_irq_data pm860x_irqs[] = { }, }; -static inline struct pm860x_irq_data *irq_to_pm860x(struct pm860x_chip *chip, - int irq) -{ - return &pm860x_irqs[irq - chip->irq_base]; -} - static irqreturn_t pm860x_irq(int irq, void *data) { struct pm860x_chip *chip = data; @@ -388,16 +382,16 @@ static irqreturn_t pm860x_irq(int irq, void *data) return IRQ_HANDLED; } -static void pm860x_irq_lock(unsigned int irq) +static void pm860x_irq_lock(struct irq_data *data) { - struct pm860x_chip *chip = get_irq_chip_data(irq); + struct pm860x_chip *chip = irq_data_get_irq_chip_data(data); mutex_lock(&chip->irq_lock); } -static void pm860x_irq_sync_unlock(unsigned int irq) +static void pm860x_irq_sync_unlock(struct irq_data *data) { - struct pm860x_chip *chip = get_irq_chip_data(irq); + struct pm860x_chip *chip = irq_data_get_irq_chip_data(data); struct pm860x_irq_data *irq_data; struct i2c_client *i2c; static unsigned char cached[3] = {0x0, 0x0, 0x0}; @@ -439,25 +433,25 @@ static void pm860x_irq_sync_unlock(unsigned int irq) mutex_unlock(&chip->irq_lock); } -static void pm860x_irq_enable(unsigned int irq) +static void pm860x_irq_enable(struct irq_data *data) { - struct pm860x_chip *chip = get_irq_chip_data(irq); - pm860x_irqs[irq - chip->irq_base].enable - = pm860x_irqs[irq - chip->irq_base].offs; + struct pm860x_chip *chip = irq_data_get_irq_chip_data(data); + pm860x_irqs[data->irq - chip->irq_base].enable + = pm860x_irqs[data->irq - chip->irq_base].offs; } -static void pm860x_irq_disable(unsigned int irq) +static void pm860x_irq_disable(struct irq_data *data) { - struct pm860x_chip *chip = get_irq_chip_data(irq); - pm860x_irqs[irq - chip->irq_base].enable = 0; + struct pm860x_chip *chip = irq_data_get_irq_chip_data(data); + pm860x_irqs[data->irq - chip->irq_base].enable = 0; } static struct irq_chip pm860x_irq_chip = { .name = "88pm860x", - .bus_lock = pm860x_irq_lock, - .bus_sync_unlock = pm860x_irq_sync_unlock, - .enable = pm860x_irq_enable, - .disable = pm860x_irq_disable, + .irq_bus_lock = pm860x_irq_lock, + .irq_bus_sync_unlock = pm860x_irq_sync_unlock, + .irq_enable = pm860x_irq_enable, + .irq_disable = pm860x_irq_disable, }; static int __devinit device_gpadc_init(struct pm860x_chip *chip, -- cgit v1.2.3-70-g09d2 From 0f76aaebe8015d6a850cb03622382bacb7860398 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Sat, 11 Dec 2010 13:08:57 +0000 Subject: mfd: Convert ASIC3 to new irq_ APIs The interrupt controller APIs are being updated to pass a struct irq_data rather than the interrupt number. Signed-off-by: Mark Brown Acked-by: Ian Molton Signed-off-by: Samuel Ortiz --- drivers/mfd/asic3.c | 56 ++++++++++++++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/drivers/mfd/asic3.c b/drivers/mfd/asic3.c index 3c7dc5ebfe4..6a1f9404261 100644 --- a/drivers/mfd/asic3.c +++ b/drivers/mfd/asic3.c @@ -226,14 +226,14 @@ static inline int asic3_irq_to_index(struct asic3 *asic, int irq) return (irq - asic->irq_base) & 0xf; } -static void asic3_mask_gpio_irq(unsigned int irq) +static void asic3_mask_gpio_irq(struct irq_data *data) { - struct asic3 *asic = get_irq_chip_data(irq); + struct asic3 *asic = irq_data_get_irq_chip_data(data); u32 val, bank, index; unsigned long flags; - bank = asic3_irq_to_bank(asic, irq); - index = asic3_irq_to_index(asic, irq); + bank = asic3_irq_to_bank(asic, data->irq); + index = asic3_irq_to_index(asic, data->irq); spin_lock_irqsave(&asic->lock, flags); val = asic3_read_register(asic, bank + ASIC3_GPIO_MASK); @@ -242,9 +242,9 @@ static void asic3_mask_gpio_irq(unsigned int irq) spin_unlock_irqrestore(&asic->lock, flags); } -static void asic3_mask_irq(unsigned int irq) +static void asic3_mask_irq(struct irq_data *data) { - struct asic3 *asic = get_irq_chip_data(irq); + struct asic3 *asic = irq_data_get_irq_chip_data(data); int regval; unsigned long flags; @@ -254,7 +254,7 @@ static void asic3_mask_irq(unsigned int irq) ASIC3_INTR_INT_MASK); regval &= ~(ASIC3_INTMASK_MASK0 << - (irq - (asic->irq_base + ASIC3_NUM_GPIOS))); + (data->irq - (asic->irq_base + ASIC3_NUM_GPIOS))); asic3_write_register(asic, ASIC3_INTR_BASE + @@ -263,14 +263,14 @@ static void asic3_mask_irq(unsigned int irq) spin_unlock_irqrestore(&asic->lock, flags); } -static void asic3_unmask_gpio_irq(unsigned int irq) +static void asic3_unmask_gpio_irq(struct irq_data *data) { - struct asic3 *asic = get_irq_chip_data(irq); + struct asic3 *asic = irq_data_get_irq_chip_data(data); u32 val, bank, index; unsigned long flags; - bank = asic3_irq_to_bank(asic, irq); - index = asic3_irq_to_index(asic, irq); + bank = asic3_irq_to_bank(asic, data->irq); + index = asic3_irq_to_index(asic, data->irq); spin_lock_irqsave(&asic->lock, flags); val = asic3_read_register(asic, bank + ASIC3_GPIO_MASK); @@ -279,9 +279,9 @@ static void asic3_unmask_gpio_irq(unsigned int irq) spin_unlock_irqrestore(&asic->lock, flags); } -static void asic3_unmask_irq(unsigned int irq) +static void asic3_unmask_irq(struct irq_data *data) { - struct asic3 *asic = get_irq_chip_data(irq); + struct asic3 *asic = irq_data_get_irq_chip_data(data); int regval; unsigned long flags; @@ -291,7 +291,7 @@ static void asic3_unmask_irq(unsigned int irq) ASIC3_INTR_INT_MASK); regval |= (ASIC3_INTMASK_MASK0 << - (irq - (asic->irq_base + ASIC3_NUM_GPIOS))); + (data->irq - (asic->irq_base + ASIC3_NUM_GPIOS))); asic3_write_register(asic, ASIC3_INTR_BASE + @@ -300,15 +300,15 @@ static void asic3_unmask_irq(unsigned int irq) spin_unlock_irqrestore(&asic->lock, flags); } -static int asic3_gpio_irq_type(unsigned int irq, unsigned int type) +static int asic3_gpio_irq_type(struct irq_data *data, unsigned int type) { - struct asic3 *asic = get_irq_chip_data(irq); + struct asic3 *asic = irq_data_get_irq_chip_data(data); u32 bank, index; u16 trigger, level, edge, bit; unsigned long flags; - bank = asic3_irq_to_bank(asic, irq); - index = asic3_irq_to_index(asic, irq); + bank = asic3_irq_to_bank(asic, data->irq); + index = asic3_irq_to_index(asic, data->irq); bit = 1<lock, flags); @@ -318,7 +318,7 @@ static int asic3_gpio_irq_type(unsigned int irq, unsigned int type) bank + ASIC3_GPIO_EDGE_TRIGGER); trigger = asic3_read_register(asic, bank + ASIC3_GPIO_TRIGGER_TYPE); - asic->irq_bothedge[(irq - asic->irq_base) >> 4] &= ~bit; + asic->irq_bothedge[(data->irq - asic->irq_base) >> 4] &= ~bit; if (type == IRQ_TYPE_EDGE_RISING) { trigger |= bit; @@ -328,11 +328,11 @@ static int asic3_gpio_irq_type(unsigned int irq, unsigned int type) edge &= ~bit; } else if (type == IRQ_TYPE_EDGE_BOTH) { trigger |= bit; - if (asic3_gpio_get(&asic->gpio, irq - asic->irq_base)) + if (asic3_gpio_get(&asic->gpio, data->irq - asic->irq_base)) edge &= ~bit; else edge |= bit; - asic->irq_bothedge[(irq - asic->irq_base) >> 4] |= bit; + asic->irq_bothedge[(data->irq - asic->irq_base) >> 4] |= bit; } else if (type == IRQ_TYPE_LEVEL_LOW) { trigger &= ~bit; level &= ~bit; @@ -359,17 +359,17 @@ static int asic3_gpio_irq_type(unsigned int irq, unsigned int type) static struct irq_chip asic3_gpio_irq_chip = { .name = "ASIC3-GPIO", - .ack = asic3_mask_gpio_irq, - .mask = asic3_mask_gpio_irq, - .unmask = asic3_unmask_gpio_irq, - .set_type = asic3_gpio_irq_type, + .irq_ack = asic3_mask_gpio_irq, + .irq_mask = asic3_mask_gpio_irq, + .irq_unmask = asic3_unmask_gpio_irq, + .irq_set_type = asic3_gpio_irq_type, }; static struct irq_chip asic3_irq_chip = { .name = "ASIC3", - .ack = asic3_mask_irq, - .mask = asic3_mask_irq, - .unmask = asic3_unmask_irq, + .irq_ack = asic3_mask_irq, + .irq_mask = asic3_mask_irq, + .irq_unmask = asic3_unmask_irq, }; static int __init asic3_irq_probe(struct platform_device *pdev) -- cgit v1.2.3-70-g09d2 From c91ad349d084f8c034ff60fb56d41a9667f71ae4 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Sat, 11 Dec 2010 13:14:12 +0000 Subject: mfd: Convert AB3500 to new irq_ APIs The genirq core is being updated to pass struct irq_data rather than irq numbers into chip drivers. As part of the update assignments to NULL for unused operations are removed, these are not needed and the genirq docs should be good enough. Signed-off-by: Mark Brown Acked-by: Mattias Wallin Signed-off-by: Samuel Ortiz --- drivers/mfd/ab3550-core.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/drivers/mfd/ab3550-core.c b/drivers/mfd/ab3550-core.c index 8a98739e6d9..5fbca346b99 100644 --- a/drivers/mfd/ab3550-core.c +++ b/drivers/mfd/ab3550-core.c @@ -1159,15 +1159,16 @@ static void ab3550_mask_work(struct work_struct *work) } } -static void ab3550_mask(unsigned int irq) +static void ab3550_mask(struct irq_data *data) { unsigned long flags; struct ab3550 *ab; struct ab3550_platform_data *plf_data; + int irq; - ab = get_irq_chip_data(irq); + ab = irq_data_get_irq_chip_data(data); plf_data = ab->i2c_client[0]->dev.platform_data; - irq -= plf_data->irq.base; + irq = data->irq - plf_data->irq.base; spin_lock_irqsave(&ab->event_lock, flags); ab->event_mask[irq / 8] |= BIT(irq % 8); @@ -1176,15 +1177,16 @@ static void ab3550_mask(unsigned int irq) schedule_work(&ab->mask_work); } -static void ab3550_unmask(unsigned int irq) +static void ab3550_unmask(struct irq_data *data) { unsigned long flags; struct ab3550 *ab; struct ab3550_platform_data *plf_data; + int irq; - ab = get_irq_chip_data(irq); + ab = irq_data_get_irq_chip_data(data); plf_data = ab->i2c_client[0]->dev.platform_data; - irq -= plf_data->irq.base; + irq = data->irq - plf_data->irq.base; spin_lock_irqsave(&ab->event_lock, flags); ab->event_mask[irq / 8] &= ~BIT(irq % 8); @@ -1193,20 +1195,16 @@ static void ab3550_unmask(unsigned int irq) schedule_work(&ab->mask_work); } -static void noop(unsigned int irq) +static void noop(struct irq_data *data) { } static struct irq_chip ab3550_irq_chip = { .name = "ab3550-core", /* Keep the same name as the request */ - .startup = NULL, /* defaults to enable */ - .shutdown = NULL, /* defaults to disable */ - .enable = NULL, /* defaults to unmask */ - .disable = ab3550_mask, /* No default to mask in chip.c */ - .ack = noop, - .mask = ab3550_mask, - .unmask = ab3550_unmask, - .end = NULL, + .irq_disable = ab3550_mask, /* No default to mask in chip.c */ + .irq_ack = noop, + .irq_mask = ab3550_mask, + .irq_unmask = ab3550_unmask, }; struct ab_family_id { -- cgit v1.2.3-70-g09d2 From 9505a0a0ac6160480eaab8d592dce6161e67e05d Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Sat, 11 Dec 2010 13:16:08 +0000 Subject: mfd: Convert AB8500 to new irq_ methods The genirq core is being converted to supply struct irq_data to chips rather than the interrupt number. Signed-off-by: Mark Brown Acked-by: Mattias Wallin Signed-off-by: Samuel Ortiz --- drivers/mfd/ab8500-core.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/mfd/ab8500-core.c b/drivers/mfd/ab8500-core.c index 7f01a3a1d10..86cc8874e6d 100644 --- a/drivers/mfd/ab8500-core.c +++ b/drivers/mfd/ab8500-core.c @@ -232,16 +232,16 @@ static struct abx500_ops ab8500_ops = { .startup_irq_enabled = NULL, }; -static void ab8500_irq_lock(unsigned int irq) +static void ab8500_irq_lock(struct irq_data *data) { - struct ab8500 *ab8500 = get_irq_chip_data(irq); + struct ab8500 *ab8500 = irq_data_get_irq_chip_data(data); mutex_lock(&ab8500->irq_lock); } -static void ab8500_irq_sync_unlock(unsigned int irq) +static void ab8500_irq_sync_unlock(struct irq_data *data) { - struct ab8500 *ab8500 = get_irq_chip_data(irq); + struct ab8500 *ab8500 = irq_data_get_irq_chip_data(data); int i; for (i = 0; i < AB8500_NUM_IRQ_REGS; i++) { @@ -261,20 +261,20 @@ static void ab8500_irq_sync_unlock(unsigned int irq) mutex_unlock(&ab8500->irq_lock); } -static void ab8500_irq_mask(unsigned int irq) +static void ab8500_irq_mask(struct irq_data *data) { - struct ab8500 *ab8500 = get_irq_chip_data(irq); - int offset = irq - ab8500->irq_base; + struct ab8500 *ab8500 = irq_data_get_irq_chip_data(data); + int offset = data->irq - ab8500->irq_base; int index = offset / 8; int mask = 1 << (offset % 8); ab8500->mask[index] |= mask; } -static void ab8500_irq_unmask(unsigned int irq) +static void ab8500_irq_unmask(struct irq_data *data) { - struct ab8500 *ab8500 = get_irq_chip_data(irq); - int offset = irq - ab8500->irq_base; + struct ab8500 *ab8500 = irq_data_get_irq_chip_data(data); + int offset = data->irq - ab8500->irq_base; int index = offset / 8; int mask = 1 << (offset % 8); @@ -283,10 +283,10 @@ static void ab8500_irq_unmask(unsigned int irq) static struct irq_chip ab8500_irq_chip = { .name = "ab8500", - .bus_lock = ab8500_irq_lock, - .bus_sync_unlock = ab8500_irq_sync_unlock, - .mask = ab8500_irq_mask, - .unmask = ab8500_irq_unmask, + .irq_bus_lock = ab8500_irq_lock, + .irq_bus_sync_unlock = ab8500_irq_sync_unlock, + .irq_mask = ab8500_irq_mask, + .irq_unmask = ab8500_irq_unmask, }; static irqreturn_t ab8500_irq(int irq, void *dev) -- cgit v1.2.3-70-g09d2 From c232f22fc6aac1797d0ca9beddddf0fea4beb7f3 Mon Sep 17 00:00:00 2001 From: Lennert Buytenhek Date: Mon, 13 Dec 2010 13:30:09 +0100 Subject: mfd: Convert ezx-pcap to new irq_ methods Signed-off-by: Lennert Buytenhek Signed-off-by: Mark Brown Signed-off-by: Samuel Ortiz --- drivers/mfd/ezx-pcap.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/mfd/ezx-pcap.c b/drivers/mfd/ezx-pcap.c index 4f6742753c4..9e2d8dd5f9e 100644 --- a/drivers/mfd/ezx-pcap.c +++ b/drivers/mfd/ezx-pcap.c @@ -144,26 +144,26 @@ int pcap_to_irq(struct pcap_chip *pcap, int irq) } EXPORT_SYMBOL_GPL(pcap_to_irq); -static void pcap_mask_irq(unsigned int irq) +static void pcap_mask_irq(struct irq_data *d) { - struct pcap_chip *pcap = get_irq_chip_data(irq); + struct pcap_chip *pcap = irq_data_get_irq_chip_data(d); - pcap->msr |= 1 << irq_to_pcap(pcap, irq); + pcap->msr |= 1 << irq_to_pcap(pcap, d->irq); queue_work(pcap->workqueue, &pcap->msr_work); } -static void pcap_unmask_irq(unsigned int irq) +static void pcap_unmask_irq(struct irq_data *d) { - struct pcap_chip *pcap = get_irq_chip_data(irq); + struct pcap_chip *pcap = irq_data_get_irq_chip_data(d); - pcap->msr &= ~(1 << irq_to_pcap(pcap, irq)); + pcap->msr &= ~(1 << irq_to_pcap(pcap, d->irq)); queue_work(pcap->workqueue, &pcap->msr_work); } static struct irq_chip pcap_irq_chip = { - .name = "pcap", - .mask = pcap_mask_irq, - .unmask = pcap_unmask_irq, + .name = "pcap", + .irq_mask = pcap_mask_irq, + .irq_unmask = pcap_unmask_irq, }; static void pcap_msr_work(struct work_struct *work) @@ -217,7 +217,7 @@ static void pcap_irq_handler(unsigned int irq, struct irq_desc *desc) { struct pcap_chip *pcap = get_irq_data(irq); - desc->chip->ack(irq); + desc->irq_data.chip->irq_ack(&desc->irq_data); queue_work(pcap->workqueue, &pcap->isr_work); return; } -- cgit v1.2.3-70-g09d2 From 949b9decaed059f25ed9639d3dbfe839972cf01b Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Sat, 11 Dec 2010 16:43:59 +0000 Subject: mfd: Convert HTC EGPIO driver to irq_ API The genirq core is being converted to pass a struct irq_data to interrupt operations rather than an IRQ number. Signed-off-by: Mark Brown Signed-off-by: Samuel Ortiz --- drivers/mfd/htc-egpio.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/drivers/mfd/htc-egpio.c b/drivers/mfd/htc-egpio.c index d3e74f8585e..d00b6d1a69e 100644 --- a/drivers/mfd/htc-egpio.c +++ b/drivers/mfd/htc-egpio.c @@ -70,31 +70,32 @@ static inline void ack_irqs(struct egpio_info *ei) ei->ack_write, ei->ack_register << ei->bus_shift); } -static void egpio_ack(unsigned int irq) +static void egpio_ack(struct irq_data *data) { } /* There does not appear to be a way to proactively mask interrupts * on the egpio chip itself. So, we simply ignore interrupts that * aren't desired. */ -static void egpio_mask(unsigned int irq) +static void egpio_mask(struct irq_data *data) { - struct egpio_info *ei = get_irq_chip_data(irq); - ei->irqs_enabled &= ~(1 << (irq - ei->irq_start)); - pr_debug("EGPIO mask %d %04x\n", irq, ei->irqs_enabled); + struct egpio_info *ei = irq_data_get_irq_chip_data(data); + ei->irqs_enabled &= ~(1 << (data->irq - ei->irq_start)); + pr_debug("EGPIO mask %d %04x\n", data->irq, ei->irqs_enabled); } -static void egpio_unmask(unsigned int irq) + +static void egpio_unmask(struct irq_data *data) { - struct egpio_info *ei = get_irq_chip_data(irq); - ei->irqs_enabled |= 1 << (irq - ei->irq_start); - pr_debug("EGPIO unmask %d %04x\n", irq, ei->irqs_enabled); + struct egpio_info *ei = irq_data_get_irq_chip_data(data); + ei->irqs_enabled |= 1 << (data->irq - ei->irq_start); + pr_debug("EGPIO unmask %d %04x\n", data->irq, ei->irqs_enabled); } static struct irq_chip egpio_muxed_chip = { - .name = "htc-egpio", - .ack = egpio_ack, - .mask = egpio_mask, - .unmask = egpio_unmask, + .name = "htc-egpio", + .irq_ack = egpio_ack, + .irq_mask = egpio_mask, + .irq_unmask = egpio_unmask, }; static void egpio_handler(unsigned int irq, struct irq_desc *desc) -- cgit v1.2.3-70-g09d2 From e6a4c4a48a80ddfaa5abf59146e0beb5faa86fba Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Sat, 11 Dec 2010 16:44:11 +0000 Subject: mfd: Convert HTC I2C CPLD driver to irq_ API The genirq core is being converted to pass a struct irq_data to interrupt operations rather than an IRQ number. Signed-off-by: Mark Brown Acked-by: Cory Maccarrone Signed-off-by: Samuel Ortiz --- drivers/mfd/htc-i2cpld.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/mfd/htc-i2cpld.c b/drivers/mfd/htc-i2cpld.c index dd24355c965..296ad1562f6 100644 --- a/drivers/mfd/htc-i2cpld.c +++ b/drivers/mfd/htc-i2cpld.c @@ -82,25 +82,25 @@ struct htcpld_data { /* There does not appear to be a way to proactively mask interrupts * on the htcpld chip itself. So, we simply ignore interrupts that * aren't desired. */ -static void htcpld_mask(unsigned int irq) +static void htcpld_mask(struct irq_data *data) { - struct htcpld_chip *chip = get_irq_chip_data(irq); - chip->irqs_enabled &= ~(1 << (irq - chip->irq_start)); - pr_debug("HTCPLD mask %d %04x\n", irq, chip->irqs_enabled); + struct htcpld_chip *chip = irq_data_get_irq_chip_data(data); + chip->irqs_enabled &= ~(1 << (data->irq - chip->irq_start)); + pr_debug("HTCPLD mask %d %04x\n", data->irq, chip->irqs_enabled); } -static void htcpld_unmask(unsigned int irq) +static void htcpld_unmask(struct irq_data *data) { - struct htcpld_chip *chip = get_irq_chip_data(irq); - chip->irqs_enabled |= 1 << (irq - chip->irq_start); - pr_debug("HTCPLD unmask %d %04x\n", irq, chip->irqs_enabled); + struct htcpld_chip *chip = irq_data_get_irq_chip_data(data); + chip->irqs_enabled |= 1 << (data->irq - chip->irq_start); + pr_debug("HTCPLD unmask %d %04x\n", data->irq, chip->irqs_enabled); } -static int htcpld_set_type(unsigned int irq, unsigned int flags) +static int htcpld_set_type(struct irq_data *data, unsigned int flags) { - struct irq_desc *d = irq_to_desc(irq); + struct irq_desc *d = irq_to_desc(data->irq); if (!d) { - pr_err("HTCPLD invalid IRQ: %d\n", irq); + pr_err("HTCPLD invalid IRQ: %d\n", data->irq); return -EINVAL; } @@ -118,10 +118,10 @@ static int htcpld_set_type(unsigned int irq, unsigned int flags) } static struct irq_chip htcpld_muxed_chip = { - .name = "htcpld", - .mask = htcpld_mask, - .unmask = htcpld_unmask, - .set_type = htcpld_set_type, + .name = "htcpld", + .irq_mask = htcpld_mask, + .irq_unmask = htcpld_unmask, + .irq_set_type = htcpld_set_type, }; /* To properly dispatch IRQ events, we need to read from the -- cgit v1.2.3-70-g09d2 From 5af3bde8b264e78565b6d1963ba86bbf6c6b10f6 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Sun, 12 Dec 2010 20:08:30 +0100 Subject: mfd: Convert jz4740-adc to new irq_ methods Convert the jz4740-adc driver to use the recently introduced IRQ API variants which are passed struct irq_data rather than an IRQ number. Signed-off-by: Mark Brown Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown Signed-off-by: Samuel Ortiz --- drivers/mfd/jz4740-adc.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/drivers/mfd/jz4740-adc.c b/drivers/mfd/jz4740-adc.c index 9dd1b33f227..0cc59795f60 100644 --- a/drivers/mfd/jz4740-adc.c +++ b/drivers/mfd/jz4740-adc.c @@ -84,31 +84,30 @@ static inline void jz4740_adc_irq_set_masked(struct jz4740_adc *adc, int irq, spin_unlock_irqrestore(&adc->lock, flags); } -static void jz4740_adc_irq_mask(unsigned int irq) +static void jz4740_adc_irq_mask(struct irq_data *data) { - struct jz4740_adc *adc = get_irq_chip_data(irq); - jz4740_adc_irq_set_masked(adc, irq, true); + struct jz4740_adc *adc = irq_data_get_irq_chip_data(data); + jz4740_adc_irq_set_masked(adc, data->irq, true); } -static void jz4740_adc_irq_unmask(unsigned int irq) +static void jz4740_adc_irq_unmask(struct irq_data *data) { - struct jz4740_adc *adc = get_irq_chip_data(irq); - jz4740_adc_irq_set_masked(adc, irq, false); + struct jz4740_adc *adc = irq_data_get_irq_chip_data(data); + jz4740_adc_irq_set_masked(adc, data->irq, false); } -static void jz4740_adc_irq_ack(unsigned int irq) +static void jz4740_adc_irq_ack(struct irq_data *data) { - struct jz4740_adc *adc = get_irq_chip_data(irq); - - irq -= adc->irq_base; + struct jz4740_adc *adc = irq_data_get_irq_chip_data(data); + unsigned int irq = data->irq - adc->irq_base; writeb(BIT(irq), adc->base + JZ_REG_ADC_STATUS); } static struct irq_chip jz4740_adc_irq_chip = { .name = "jz4740-adc", - .mask = jz4740_adc_irq_mask, - .unmask = jz4740_adc_irq_unmask, - .ack = jz4740_adc_irq_ack, + .irq_mask = jz4740_adc_irq_mask, + .irq_unmask = jz4740_adc_irq_unmask, + .irq_ack = jz4740_adc_irq_ack, }; static void jz4740_adc_irq_demux(unsigned int irq, struct irq_desc *desc) -- cgit v1.2.3-70-g09d2 From 98d9bc13cd19e544e8ea15b97f5cfef166cc9294 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Sat, 11 Dec 2010 18:20:55 +0000 Subject: mfd: Convert max8925 to new irq_ API The genirq infrastructure is being converted to pass struct irq_data rather than an irq number to irq_chip operations, update max8925 to the new APIs. Signed-off-by: Mark Brown Signed-off-by: Samuel Ortiz --- drivers/mfd/max8925-core.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/mfd/max8925-core.c b/drivers/mfd/max8925-core.c index 44695f5a180..0e998dc4e7d 100644 --- a/drivers/mfd/max8925-core.c +++ b/drivers/mfd/max8925-core.c @@ -407,16 +407,16 @@ static irqreturn_t max8925_tsc_irq(int irq, void *data) return IRQ_HANDLED; } -static void max8925_irq_lock(unsigned int irq) +static void max8925_irq_lock(struct irq_data *data) { - struct max8925_chip *chip = get_irq_chip_data(irq); + struct max8925_chip *chip = irq_data_get_irq_chip_data(data); mutex_lock(&chip->irq_lock); } -static void max8925_irq_sync_unlock(unsigned int irq) +static void max8925_irq_sync_unlock(struct irq_data *data) { - struct max8925_chip *chip = get_irq_chip_data(irq); + struct max8925_chip *chip = irq_data_get_irq_chip_data(data); struct max8925_irq_data *irq_data; static unsigned char cache_chg[2] = {0xff, 0xff}; static unsigned char cache_on[2] = {0xff, 0xff}; @@ -492,25 +492,25 @@ static void max8925_irq_sync_unlock(unsigned int irq) mutex_unlock(&chip->irq_lock); } -static void max8925_irq_enable(unsigned int irq) +static void max8925_irq_enable(struct irq_data *data) { - struct max8925_chip *chip = get_irq_chip_data(irq); - max8925_irqs[irq - chip->irq_base].enable - = max8925_irqs[irq - chip->irq_base].offs; + struct max8925_chip *chip = irq_data_get_irq_chip_data(data); + max8925_irqs[data->irq - chip->irq_base].enable + = max8925_irqs[data->irq - chip->irq_base].offs; } -static void max8925_irq_disable(unsigned int irq) +static void max8925_irq_disable(struct irq_data *data) { - struct max8925_chip *chip = get_irq_chip_data(irq); - max8925_irqs[irq - chip->irq_base].enable = 0; + struct max8925_chip *chip = irq_data_get_irq_chip_data(data); + max8925_irqs[data->irq - chip->irq_base].enable = 0; } static struct irq_chip max8925_irq_chip = { .name = "max8925", - .bus_lock = max8925_irq_lock, - .bus_sync_unlock = max8925_irq_sync_unlock, - .enable = max8925_irq_enable, - .disable = max8925_irq_disable, + .irq_bus_lock = max8925_irq_lock, + .irq_bus_sync_unlock = max8925_irq_sync_unlock, + .irq_enable = max8925_irq_enable, + .irq_disable = max8925_irq_disable, }; static int max8925_irq_init(struct max8925_chip *chip, int irq, -- cgit v1.2.3-70-g09d2 From 2898577e160c7d60d2b11cb3b1c3b55d0e1468db Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Sat, 11 Dec 2010 18:31:03 +0000 Subject: mfd: Convert MAX8998 driver to irq_ API The genirq core is being updated to pass struct irq_data to interrupt operations, update the MAX8998 driver to the new API. Signed-off-by: Mark Brown Signed-off-by: Samuel Ortiz --- drivers/mfd/max8998-irq.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/drivers/mfd/max8998-irq.c b/drivers/mfd/max8998-irq.c index 45bfe77b639..c6b61fcc580 100644 --- a/drivers/mfd/max8998-irq.c +++ b/drivers/mfd/max8998-irq.c @@ -102,16 +102,16 @@ irq_to_max8998_irq(struct max8998_dev *max8998, int irq) return &max8998_irqs[irq - max8998->irq_base]; } -static void max8998_irq_lock(unsigned int irq) +static void max8998_irq_lock(struct irq_data *data) { - struct max8998_dev *max8998 = get_irq_chip_data(irq); + struct max8998_dev *max8998 = irq_data_get_irq_chip_data(data); mutex_lock(&max8998->irqlock); } -static void max8998_irq_sync_unlock(unsigned int irq) +static void max8998_irq_sync_unlock(struct irq_data *data) { - struct max8998_dev *max8998 = get_irq_chip_data(irq); + struct max8998_dev *max8998 = irq_data_get_irq_chip_data(data); int i; for (i = 0; i < ARRAY_SIZE(max8998->irq_masks_cur); i++) { @@ -129,28 +129,30 @@ static void max8998_irq_sync_unlock(unsigned int irq) mutex_unlock(&max8998->irqlock); } -static void max8998_irq_unmask(unsigned int irq) +static void max8998_irq_unmask(struct irq_data *data) { - struct max8998_dev *max8998 = get_irq_chip_data(irq); - struct max8998_irq_data *irq_data = irq_to_max8998_irq(max8998, irq); + struct max8998_dev *max8998 = irq_data_get_irq_chip_data(data); + struct max8998_irq_data *irq_data = irq_to_max8998_irq(max8998, + data->irq); max8998->irq_masks_cur[irq_data->reg - 1] &= ~irq_data->mask; } -static void max8998_irq_mask(unsigned int irq) +static void max8998_irq_mask(struct irq_data *data) { - struct max8998_dev *max8998 = get_irq_chip_data(irq); - struct max8998_irq_data *irq_data = irq_to_max8998_irq(max8998, irq); + struct max8998_dev *max8998 = irq_data_get_irq_chip_data(data); + struct max8998_irq_data *irq_data = irq_to_max8998_irq(max8998, + data->irq); max8998->irq_masks_cur[irq_data->reg - 1] |= irq_data->mask; } static struct irq_chip max8998_irq_chip = { .name = "max8998", - .bus_lock = max8998_irq_lock, - .bus_sync_unlock = max8998_irq_sync_unlock, - .mask = max8998_irq_mask, - .unmask = max8998_irq_unmask, + .irq_bus_lock = max8998_irq_lock, + .irq_bus_sync_unlock = max8998_irq_sync_unlock, + .irq_mask = max8998_irq_mask, + .irq_unmask = max8998_irq_unmask, }; static irqreturn_t max8998_irq_thread(int irq, void *data) -- cgit v1.2.3-70-g09d2 From 43b8c08402de2fb85cd18ebc746b598ce2473664 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Sun, 12 Dec 2010 12:01:08 +0000 Subject: mfd: Convert SMTPE driver to new irq_ APIs The genirq core is being updated to supply struct irq_data to irq_chip operations rather than an irq number. Update the SMTPE driver to the new APIs. Signed-off-by: Mark Brown Acked-by: Rabin Vincent Signed-off-by: Samuel Ortiz --- drivers/mfd/stmpe.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/mfd/stmpe.c b/drivers/mfd/stmpe.c index b11487f1e1c..3e5732b58c4 100644 --- a/drivers/mfd/stmpe.c +++ b/drivers/mfd/stmpe.c @@ -699,16 +699,16 @@ static irqreturn_t stmpe_irq(int irq, void *data) return IRQ_HANDLED; } -static void stmpe_irq_lock(unsigned int irq) +static void stmpe_irq_lock(struct irq_data *data) { - struct stmpe *stmpe = get_irq_chip_data(irq); + struct stmpe *stmpe = irq_data_get_irq_chip_data(data); mutex_lock(&stmpe->irq_lock); } -static void stmpe_irq_sync_unlock(unsigned int irq) +static void stmpe_irq_sync_unlock(struct irq_data *data) { - struct stmpe *stmpe = get_irq_chip_data(irq); + struct stmpe *stmpe = irq_data_get_irq_chip_data(data); struct stmpe_variant_info *variant = stmpe->variant; int num = DIV_ROUND_UP(variant->num_irqs, 8); int i; @@ -727,20 +727,20 @@ static void stmpe_irq_sync_unlock(unsigned int irq) mutex_unlock(&stmpe->irq_lock); } -static void stmpe_irq_mask(unsigned int irq) +static void stmpe_irq_mask(struct irq_data *data) { - struct stmpe *stmpe = get_irq_chip_data(irq); - int offset = irq - stmpe->irq_base; + struct stmpe *stmpe = irq_data_get_irq_chip_data(data); + int offset = data->irq - stmpe->irq_base; int regoffset = offset / 8; int mask = 1 << (offset % 8); stmpe->ier[regoffset] &= ~mask; } -static void stmpe_irq_unmask(unsigned int irq) +static void stmpe_irq_unmask(struct irq_data *data) { - struct stmpe *stmpe = get_irq_chip_data(irq); - int offset = irq - stmpe->irq_base; + struct stmpe *stmpe = irq_data_get_irq_chip_data(data); + int offset = data->irq - stmpe->irq_base; int regoffset = offset / 8; int mask = 1 << (offset % 8); @@ -749,10 +749,10 @@ static void stmpe_irq_unmask(unsigned int irq) static struct irq_chip stmpe_irq_chip = { .name = "stmpe", - .bus_lock = stmpe_irq_lock, - .bus_sync_unlock = stmpe_irq_sync_unlock, - .mask = stmpe_irq_mask, - .unmask = stmpe_irq_unmask, + .irq_bus_lock = stmpe_irq_lock, + .irq_bus_sync_unlock = stmpe_irq_sync_unlock, + .irq_mask = stmpe_irq_mask, + .irq_unmask = stmpe_irq_unmask, }; static int __devinit stmpe_irq_init(struct stmpe *stmpe) -- cgit v1.2.3-70-g09d2 From a4e7feadcc2aa5754f5ebfe67b9f07b5fddede51 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Sun, 12 Dec 2010 12:18:58 +0000 Subject: mfd: Convert t7166xb driver to new irq_ API The genirq core is being updated to pass struct irq_data rather than an irq number to irq_chip operations. Update the t7166xb driver to the new APIs. Signed-off-by: Mark Brown Acked-by: Ian Molton Signed-off-by: Samuel Ortiz --- drivers/mfd/t7l66xb.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/mfd/t7l66xb.c b/drivers/mfd/t7l66xb.c index 006c121f3f0..9caeb4ac6ea 100644 --- a/drivers/mfd/t7l66xb.c +++ b/drivers/mfd/t7l66xb.c @@ -199,37 +199,37 @@ static void t7l66xb_irq(unsigned int irq, struct irq_desc *desc) generic_handle_irq(irq_base + i); } -static void t7l66xb_irq_mask(unsigned int irq) +static void t7l66xb_irq_mask(struct irq_data *data) { - struct t7l66xb *t7l66xb = get_irq_chip_data(irq); + struct t7l66xb *t7l66xb = irq_data_get_irq_chip_data(data); unsigned long flags; u8 imr; spin_lock_irqsave(&t7l66xb->lock, flags); imr = tmio_ioread8(t7l66xb->scr + SCR_IMR); - imr |= 1 << (irq - t7l66xb->irq_base); + imr |= 1 << (data->irq - t7l66xb->irq_base); tmio_iowrite8(imr, t7l66xb->scr + SCR_IMR); spin_unlock_irqrestore(&t7l66xb->lock, flags); } -static void t7l66xb_irq_unmask(unsigned int irq) +static void t7l66xb_irq_unmask(struct irq_data *data) { - struct t7l66xb *t7l66xb = get_irq_chip_data(irq); + struct t7l66xb *t7l66xb = irq_data_get_irq_chip_data(data); unsigned long flags; u8 imr; spin_lock_irqsave(&t7l66xb->lock, flags); imr = tmio_ioread8(t7l66xb->scr + SCR_IMR); - imr &= ~(1 << (irq - t7l66xb->irq_base)); + imr &= ~(1 << (data->irq - t7l66xb->irq_base)); tmio_iowrite8(imr, t7l66xb->scr + SCR_IMR); spin_unlock_irqrestore(&t7l66xb->lock, flags); } static struct irq_chip t7l66xb_chip = { - .name = "t7l66xb", - .ack = t7l66xb_irq_mask, - .mask = t7l66xb_irq_mask, - .unmask = t7l66xb_irq_unmask, + .name = "t7l66xb", + .irq_ack = t7l66xb_irq_mask, + .irq_mask = t7l66xb_irq_mask, + .irq_unmask = t7l66xb_irq_unmask, }; /*--------------------------------------------------------------------------*/ -- cgit v1.2.3-70-g09d2 From 01af22eb15e46488cf3de67f6d2222c2eed5f763 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Sun, 12 Dec 2010 12:34:04 +0000 Subject: mfd: Convert tc6393xb driver to new irq_ APIs The genirq core is being update to pass struct irq_data to irq_chip rather than an irq number to operations. Update tc6393 to the new API. Signed-off-by: Mark Brown Acked-by: Ian Molton Signed-off-by: Samuel Ortiz --- drivers/mfd/tc6393xb.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/mfd/tc6393xb.c b/drivers/mfd/tc6393xb.c index 1ea80d8ad91..9a238633a54 100644 --- a/drivers/mfd/tc6393xb.c +++ b/drivers/mfd/tc6393xb.c @@ -527,41 +527,41 @@ tc6393xb_irq(unsigned int irq, struct irq_desc *desc) } } -static void tc6393xb_irq_ack(unsigned int irq) +static void tc6393xb_irq_ack(struct irq_data *data) { } -static void tc6393xb_irq_mask(unsigned int irq) +static void tc6393xb_irq_mask(struct irq_data *data) { - struct tc6393xb *tc6393xb = get_irq_chip_data(irq); + struct tc6393xb *tc6393xb = irq_data_get_irq_chip_data(data); unsigned long flags; u8 imr; spin_lock_irqsave(&tc6393xb->lock, flags); imr = tmio_ioread8(tc6393xb->scr + SCR_IMR); - imr |= 1 << (irq - tc6393xb->irq_base); + imr |= 1 << (data->irq - tc6393xb->irq_base); tmio_iowrite8(imr, tc6393xb->scr + SCR_IMR); spin_unlock_irqrestore(&tc6393xb->lock, flags); } -static void tc6393xb_irq_unmask(unsigned int irq) +static void tc6393xb_irq_unmask(struct irq_data *data) { - struct tc6393xb *tc6393xb = get_irq_chip_data(irq); + struct tc6393xb *tc6393xb = irq_data_get_irq_chip_data(data); unsigned long flags; u8 imr; spin_lock_irqsave(&tc6393xb->lock, flags); imr = tmio_ioread8(tc6393xb->scr + SCR_IMR); - imr &= ~(1 << (irq - tc6393xb->irq_base)); + imr &= ~(1 << (data->irq - tc6393xb->irq_base)); tmio_iowrite8(imr, tc6393xb->scr + SCR_IMR); spin_unlock_irqrestore(&tc6393xb->lock, flags); } static struct irq_chip tc6393xb_chip = { - .name = "tc6393xb", - .ack = tc6393xb_irq_ack, - .mask = tc6393xb_irq_mask, - .unmask = tc6393xb_irq_unmask, + .name = "tc6393xb", + .irq_ack = tc6393xb_irq_ack, + .irq_mask = tc6393xb_irq_mask, + .irq_unmask = tc6393xb_irq_unmask, }; static void tc6393xb_attach_irq(struct platform_device *dev) -- cgit v1.2.3-70-g09d2 From 96e824bdf3349a7e581004286274be6c0df6c710 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Sun, 12 Dec 2010 12:39:28 +0000 Subject: mfd: Convert tps6586x driver to new irq_ API The genirq core is being updated to supply struct irq_data to irq_chip operations rather than an irq number. Update the tps6586x driver to the new APIs. Signed-off-by: Mark Brown Acked-by: Mike Rapoport Signed-off-by: Samuel Ortiz --- drivers/mfd/tps6586x.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/mfd/tps6586x.c b/drivers/mfd/tps6586x.c index 35757399add..627cf577b16 100644 --- a/drivers/mfd/tps6586x.c +++ b/drivers/mfd/tps6586x.c @@ -323,37 +323,37 @@ static int tps6586x_remove_subdevs(struct tps6586x *tps6586x) return device_for_each_child(tps6586x->dev, NULL, __remove_subdev); } -static void tps6586x_irq_lock(unsigned int irq) +static void tps6586x_irq_lock(struct irq_data *data) { - struct tps6586x *tps6586x = get_irq_chip_data(irq); + struct tps6586x *tps6586x = irq_data_get_irq_chip_data(data); mutex_lock(&tps6586x->irq_lock); } -static void tps6586x_irq_enable(unsigned int irq) +static void tps6586x_irq_enable(struct irq_data *irq_data) { - struct tps6586x *tps6586x = get_irq_chip_data(irq); - unsigned int __irq = irq - tps6586x->irq_base; + struct tps6586x *tps6586x = irq_data_get_irq_chip_data(irq_data); + unsigned int __irq = irq_data->irq - tps6586x->irq_base; const struct tps6586x_irq_data *data = &tps6586x_irqs[__irq]; tps6586x->mask_reg[data->mask_reg] &= ~data->mask_mask; tps6586x->irq_en |= (1 << __irq); } -static void tps6586x_irq_disable(unsigned int irq) +static void tps6586x_irq_disable(struct irq_data *irq_data) { - struct tps6586x *tps6586x = get_irq_chip_data(irq); + struct tps6586x *tps6586x = irq_data_get_irq_chip_data(irq_data); - unsigned int __irq = irq - tps6586x->irq_base; + unsigned int __irq = irq_data->irq - tps6586x->irq_base; const struct tps6586x_irq_data *data = &tps6586x_irqs[__irq]; tps6586x->mask_reg[data->mask_reg] |= data->mask_mask; tps6586x->irq_en &= ~(1 << __irq); } -static void tps6586x_irq_sync_unlock(unsigned int irq) +static void tps6586x_irq_sync_unlock(struct irq_data *data) { - struct tps6586x *tps6586x = get_irq_chip_data(irq); + struct tps6586x *tps6586x = irq_data_get_irq_chip_data(data); int i; for (i = 0; i < ARRAY_SIZE(tps6586x->mask_reg); i++) { @@ -419,10 +419,10 @@ static int __devinit tps6586x_irq_init(struct tps6586x *tps6586x, int irq, tps6586x->irq_base = irq_base; tps6586x->irq_chip.name = "tps6586x"; - tps6586x->irq_chip.enable = tps6586x_irq_enable; - tps6586x->irq_chip.disable = tps6586x_irq_disable; - tps6586x->irq_chip.bus_lock = tps6586x_irq_lock; - tps6586x->irq_chip.bus_sync_unlock = tps6586x_irq_sync_unlock; + tps6586x->irq_chip.irq_enable = tps6586x_irq_enable; + tps6586x->irq_chip.irq_disable = tps6586x_irq_disable; + tps6586x->irq_chip.irq_bus_lock = tps6586x_irq_lock; + tps6586x->irq_chip.irq_bus_sync_unlock = tps6586x_irq_sync_unlock; for (i = 0; i < ARRAY_SIZE(tps6586x_irqs); i++) { int __irq = i + tps6586x->irq_base; -- cgit v1.2.3-70-g09d2 From 845aeab5f1e0ef1a85b618a1bf917520a62a9c02 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Sun, 12 Dec 2010 12:51:39 +0000 Subject: mfd: Convert TWL4030 to new irq_ APIs The genirq core is being updated to pass struct irq_data to irq_chip operations. Update the TWL4030 driver to the new APIs. Signed-off-by: Mark Brown Signed-off-by: Samuel Ortiz --- drivers/mfd/twl4030-irq.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c index 5d3a1478004..63a30e88908 100644 --- a/drivers/mfd/twl4030-irq.c +++ b/drivers/mfd/twl4030-irq.c @@ -599,38 +599,38 @@ static void twl4030_sih_do_edge(struct work_struct *work) * completion, potentially including some re-ordering, of these requests. */ -static void twl4030_sih_mask(unsigned irq) +static void twl4030_sih_mask(struct irq_data *data) { - struct sih_agent *sih = get_irq_chip_data(irq); + struct sih_agent *sih = irq_data_get_irq_chip_data(data); unsigned long flags; spin_lock_irqsave(&sih_agent_lock, flags); - sih->imr |= BIT(irq - sih->irq_base); + sih->imr |= BIT(data->irq - sih->irq_base); sih->imr_change_pending = true; queue_work(wq, &sih->mask_work); spin_unlock_irqrestore(&sih_agent_lock, flags); } -static void twl4030_sih_unmask(unsigned irq) +static void twl4030_sih_unmask(struct irq_data *data) { - struct sih_agent *sih = get_irq_chip_data(irq); + struct sih_agent *sih = irq_data_get_irq_chip_data(data); unsigned long flags; spin_lock_irqsave(&sih_agent_lock, flags); - sih->imr &= ~BIT(irq - sih->irq_base); + sih->imr &= ~BIT(data->irq - sih->irq_base); sih->imr_change_pending = true; queue_work(wq, &sih->mask_work); spin_unlock_irqrestore(&sih_agent_lock, flags); } -static int twl4030_sih_set_type(unsigned irq, unsigned trigger) +static int twl4030_sih_set_type(struct irq_data *data, unsigned trigger) { - struct sih_agent *sih = get_irq_chip_data(irq); - struct irq_desc *desc = irq_to_desc(irq); + struct sih_agent *sih = irq_data_get_irq_chip_data(data); + struct irq_desc *desc = irq_to_desc(data->irq); unsigned long flags; if (!desc) { - pr_err("twl4030: Invalid IRQ: %d\n", irq); + pr_err("twl4030: Invalid IRQ: %d\n", data->irq); return -EINVAL; } @@ -641,7 +641,7 @@ static int twl4030_sih_set_type(unsigned irq, unsigned trigger) if ((desc->status & IRQ_TYPE_SENSE_MASK) != trigger) { desc->status &= ~IRQ_TYPE_SENSE_MASK; desc->status |= trigger; - sih->edge_change |= BIT(irq - sih->irq_base); + sih->edge_change |= BIT(data->irq - sih->irq_base); queue_work(wq, &sih->edge_work); } spin_unlock_irqrestore(&sih_agent_lock, flags); @@ -650,9 +650,9 @@ static int twl4030_sih_set_type(unsigned irq, unsigned trigger) static struct irq_chip twl4030_sih_irq_chip = { .name = "twl4030", - .mask = twl4030_sih_mask, - .unmask = twl4030_sih_unmask, - .set_type = twl4030_sih_set_type, + .irq_mask = twl4030_sih_mask, + .irq_unmask = twl4030_sih_unmask, + .irq_set_type = twl4030_sih_set_type, }; /*----------------------------------------------------------------------*/ -- cgit v1.2.3-70-g09d2 From 25a947f805b4132b69f2561589e17a0fe45552b6 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Sat, 11 Dec 2010 13:21:21 +0000 Subject: mfd: Convert Wolfson MFD drivers to use irq_data accessor function Actually makes the code larger rathe rthan smaller but does provide some isolation against core API changes. Signed-off-by: Mark Brown Signed-off-by: Samuel Ortiz --- drivers/mfd/wm831x-irq.c | 10 +++++----- drivers/mfd/wm8350-irq.c | 8 ++++---- drivers/mfd/wm8994-irq.c | 8 ++++---- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/mfd/wm831x-irq.c b/drivers/mfd/wm831x-irq.c index eae52726bf3..ee88f6a05ce 100644 --- a/drivers/mfd/wm831x-irq.c +++ b/drivers/mfd/wm831x-irq.c @@ -347,14 +347,14 @@ static inline struct wm831x_irq_data *irq_to_wm831x_irq(struct wm831x *wm831x, static void wm831x_irq_lock(struct irq_data *data) { - struct wm831x *wm831x = data->chip_data; + struct wm831x *wm831x = irq_data_get_irq_chip_data(data); mutex_lock(&wm831x->irq_lock); } static void wm831x_irq_sync_unlock(struct irq_data *data) { - struct wm831x *wm831x = data->chip_data; + struct wm831x *wm831x = irq_data_get_irq_chip_data(data); int i; for (i = 0; i < ARRAY_SIZE(wm831x->irq_masks_cur); i++) { @@ -373,7 +373,7 @@ static void wm831x_irq_sync_unlock(struct irq_data *data) static void wm831x_irq_unmask(struct irq_data *data) { - struct wm831x *wm831x = data->chip_data; + struct wm831x *wm831x = irq_data_get_irq_chip_data(data); struct wm831x_irq_data *irq_data = irq_to_wm831x_irq(wm831x, data->irq); @@ -382,7 +382,7 @@ static void wm831x_irq_unmask(struct irq_data *data) static void wm831x_irq_mask(struct irq_data *data) { - struct wm831x *wm831x = data->chip_data; + struct wm831x *wm831x = irq_data_get_irq_chip_data(data); struct wm831x_irq_data *irq_data = irq_to_wm831x_irq(wm831x, data->irq); @@ -391,7 +391,7 @@ static void wm831x_irq_mask(struct irq_data *data) static int wm831x_irq_set_type(struct irq_data *data, unsigned int type) { - struct wm831x *wm831x = data->chip_data; + struct wm831x *wm831x = irq_data_get_irq_chip_data(data); int val, irq; irq = data->irq - wm831x->irq_base; diff --git a/drivers/mfd/wm8350-irq.c b/drivers/mfd/wm8350-irq.c index ba966ae88dc..5839966ebd8 100644 --- a/drivers/mfd/wm8350-irq.c +++ b/drivers/mfd/wm8350-irq.c @@ -419,14 +419,14 @@ static irqreturn_t wm8350_irq(int irq, void *irq_data) static void wm8350_irq_lock(struct irq_data *data) { - struct wm8350 *wm8350 = data->chip_data; + struct wm8350 *wm8350 = irq_data_get_irq_chip_data(data); mutex_lock(&wm8350->irq_lock); } static void wm8350_irq_sync_unlock(struct irq_data *data) { - struct wm8350 *wm8350 = data->chip_data; + struct wm8350 *wm8350 = irq_data_get_irq_chip_data(data); int i; for (i = 0; i < ARRAY_SIZE(wm8350->irq_masks); i++) { @@ -444,7 +444,7 @@ static void wm8350_irq_sync_unlock(struct irq_data *data) static void wm8350_irq_enable(struct irq_data *data) { - struct wm8350 *wm8350 = data->chip_data; + struct wm8350 *wm8350 = irq_data_get_irq_chip_data(data); struct wm8350_irq_data *irq_data = irq_to_wm8350_irq(wm8350, data->irq); @@ -453,7 +453,7 @@ static void wm8350_irq_enable(struct irq_data *data) static void wm8350_irq_disable(struct irq_data *data) { - struct wm8350 *wm8350 = data->chip_data; + struct wm8350 *wm8350 = irq_data_get_irq_chip_data(data); struct wm8350_irq_data *irq_data = irq_to_wm8350_irq(wm8350, data->irq); diff --git a/drivers/mfd/wm8994-irq.c b/drivers/mfd/wm8994-irq.c index 62598840ad0..29e8faf9c01 100644 --- a/drivers/mfd/wm8994-irq.c +++ b/drivers/mfd/wm8994-irq.c @@ -158,14 +158,14 @@ static inline struct wm8994_irq_data *irq_to_wm8994_irq(struct wm8994 *wm8994, static void wm8994_irq_lock(struct irq_data *data) { - struct wm8994 *wm8994 = data->chip_data; + struct wm8994 *wm8994 = irq_data_get_irq_chip_data(data); mutex_lock(&wm8994->irq_lock); } static void wm8994_irq_sync_unlock(struct irq_data *data) { - struct wm8994 *wm8994 = data->chip_data; + struct wm8994 *wm8994 = irq_data_get_irq_chip_data(data); int i; for (i = 0; i < ARRAY_SIZE(wm8994->irq_masks_cur); i++) { @@ -184,7 +184,7 @@ static void wm8994_irq_sync_unlock(struct irq_data *data) static void wm8994_irq_unmask(struct irq_data *data) { - struct wm8994 *wm8994 = data->chip_data; + struct wm8994 *wm8994 = irq_data_get_irq_chip_data(data); struct wm8994_irq_data *irq_data = irq_to_wm8994_irq(wm8994, data->irq); @@ -193,7 +193,7 @@ static void wm8994_irq_unmask(struct irq_data *data) static void wm8994_irq_mask(struct irq_data *data) { - struct wm8994 *wm8994 = data->chip_data; + struct wm8994 *wm8994 = irq_data_get_irq_chip_data(data); struct wm8994_irq_data *irq_data = irq_to_wm8994_irq(wm8994, data->irq); -- cgit v1.2.3-70-g09d2 From 7eb19812eead8d0faf30682b69970b36dc02e570 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Mon, 20 Dec 2010 11:26:19 +0100 Subject: misc: Fix cs5535 printk warnings drivers/misc/cs5535-mfgpt.c: In function 'cs5535_mfgpt_probe': drivers/misc/cs5535-mfgpt.c:320: warning: format '%x' expects type 'unsigned int', but argument 3 has type 'resource_size_t' drivers/misc/cs5535-mfgpt.c:320: warning: format '%x' expects type 'unsigned int', but argument 4 has type 'resource_size_t' Use vsprintf extension %pR to format resource. Original-patch-by: Randy Dunlap Signed-off-by: Joe Perches Signed-off-by: Samuel Ortiz --- drivers/misc/cs5535-mfgpt.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/misc/cs5535-mfgpt.c b/drivers/misc/cs5535-mfgpt.c index 26693060b29..d02d302ee6d 100644 --- a/drivers/misc/cs5535-mfgpt.c +++ b/drivers/misc/cs5535-mfgpt.c @@ -317,8 +317,7 @@ static int __devinit cs5535_mfgpt_probe(struct platform_device *pdev) cs5535_mfgpt_chip.pdev = pdev; spin_lock_init(&cs5535_mfgpt_chip.lock); - dev_info(&pdev->dev, "region 0x%x - 0x%x reserved\n", res->start, - res->end); + dev_info(&pdev->dev, "reserved resource region %pR\n", res); /* detect the available timers */ t = scan_timers(&cs5535_mfgpt_chip); -- cgit v1.2.3-70-g09d2 From 1db0b427eec6f18477fa95aab8edf6176dffcea4 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Mon, 20 Dec 2010 11:28:40 +0100 Subject: gpio: Fix cs5535 printk warnings drivers/gpio/cs5535-gpio.c: In function 'cs5535_gpio_probe': drivers/gpio/cs5535-gpio.c:269: warning: format '%x' expects type 'unsigned int', but argument 3 has type 'resource_size_t' drivers/gpio/cs5535-gpio.c:269: warning: format '%x' expects type 'unsigned int', but argument 4 has type 'resource_size_t' Use vsprintf extension %pR to format resource. Original-patch-by: Randy Dunlap Signed-off-by: Joe Perches Signed-off-by: Samuel Ortiz --- drivers/gpio/cs5535-gpio.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/gpio/cs5535-gpio.c b/drivers/gpio/cs5535-gpio.c index f9813ef4853..0d05ea7d499 100644 --- a/drivers/gpio/cs5535-gpio.c +++ b/drivers/gpio/cs5535-gpio.c @@ -329,8 +329,7 @@ static int __devinit cs5535_gpio_probe(struct platform_device *pdev) cs5535_gpio_chip.pdev = pdev; spin_lock_init(&cs5535_gpio_chip.lock); - dev_info(&pdev->dev, "region 0x%x - 0x%x reserved\n", - res->start, res->end); + dev_info(&pdev->dev, "reserved resource region %pR\n", res); /* mask out reserved pins */ mask &= 0x1F7FFFFF; -- cgit v1.2.3-70-g09d2 From c45c685c1a582e27787b5aa85844f2ee6986018c Mon Sep 17 00:00:00 2001 From: Lennert Buytenhek Date: Mon, 13 Dec 2010 13:31:18 +0100 Subject: mfd: twl6030 irq_data conversion. Signed-off-by: Lennert Buytenhek Acked-by: Santosh Shilimkar Signed-off-by: Samuel Ortiz --- drivers/mfd/twl6030-irq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mfd/twl6030-irq.c b/drivers/mfd/twl6030-irq.c index 06c8955907e..4082ed73613 100644 --- a/drivers/mfd/twl6030-irq.c +++ b/drivers/mfd/twl6030-irq.c @@ -332,7 +332,7 @@ int twl6030_init_irq(int irq_num, unsigned irq_base, unsigned irq_end) */ twl6030_irq_chip = dummy_irq_chip; twl6030_irq_chip.name = "twl6030"; - twl6030_irq_chip.set_type = NULL; + twl6030_irq_chip.irq_set_type = NULL; for (i = irq_base; i < irq_end; i++) { set_irq_chip_and_handler(i, &twl6030_irq_chip, -- cgit v1.2.3-70-g09d2 From 3ec33012dc07ab7e12fdd3f7f927c09264dcb5ec Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Mon, 20 Dec 2010 10:02:06 +0800 Subject: mfd: Add __devexit annotation for vx855_remove Signed-off-by: Axel Lin Acked-by: Harald Welte Signed-off-by: Samuel Ortiz --- drivers/mfd/vx855.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mfd/vx855.c b/drivers/mfd/vx855.c index ebb059765ed..348052aa5db 100644 --- a/drivers/mfd/vx855.c +++ b/drivers/mfd/vx855.c @@ -112,7 +112,7 @@ out: return ret; } -static void vx855_remove(struct pci_dev *pdev) +static void __devexit vx855_remove(struct pci_dev *pdev) { mfd_remove_devices(&pdev->dev); pci_disable_device(pdev); -- cgit v1.2.3-70-g09d2 From b14375800751da9fcd63ec11d39a86077f214dc2 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Mon, 20 Dec 2010 12:28:11 +0000 Subject: misc: Make AB8500_PWM driver depend on U8500 due to PWM breakage Since we don't have a PWM API every PWM driver ends up exporting its own version and we need to limit the platforms we try to build them on in order to avoid multiple definitions. As the AB8500 is normally a companion chip for the U8500 CPU depend on that architecture. Signed-off-by: Mark Brown Signed-off-by: Samuel Ortiz --- drivers/misc/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index 1e1a4be8eb6..cc8e49db45f 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -64,7 +64,7 @@ config ATMEL_PWM config AB8500_PWM bool "AB8500 PWM support" - depends on AB8500_CORE + depends on AB8500_CORE && ARCH_U8500 select HAVE_PWM help This driver exports functions to enable/disble/config/free Pulse -- cgit v1.2.3-70-g09d2 From 1d83864cab272f764beb381bbd3837f91fc0abed Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Sat, 11 Dec 2010 13:07:49 +0000 Subject: mfd: Remove ARCH_U8500 dependency from AB8500 While it is vanishingly unlikely that the device will be deployed on other architectures removing the dependency facilitates build testing when doing generic work on both the MFD core for the device and the subsystem drivers. There appears to be no actual code dependency. Signed-off-by: Mark Brown Signed-off-by: Samuel Ortiz --- drivers/mfd/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index b5e3e09f563..c32b62a8a1f 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -496,7 +496,7 @@ config EZX_PCAP config AB8500_CORE bool "ST-Ericsson AB8500 Mixed Signal Power Management chip" - depends on GENERIC_HARDIRQS && ABX500_CORE && SPI_MASTER && ARCH_U8500 + depends on GENERIC_HARDIRQS && ABX500_CORE && SPI_MASTER select MFD_CORE help Select this option to enable access to AB8500 power management -- cgit v1.2.3-70-g09d2 From 6680d940b80dbb0617226c5b76b071a3977feb1c Mon Sep 17 00:00:00 2001 From: Sundar Iyer Date: Fri, 24 Dec 2010 11:52:08 +0100 Subject: mfd/ab8500: remove spi support Since the Ab8500 v1.0, the SPI support is deprecated on the HW. Signed-off-by: Sundar Iyer Signed-off-by: Samuel Ortiz --- drivers/mfd/Kconfig | 8 +-- drivers/mfd/Makefile | 2 +- drivers/mfd/ab8500-spi.c | 143 ----------------------------------------------- 3 files changed, 5 insertions(+), 148 deletions(-) delete mode 100644 drivers/mfd/ab8500-spi.c diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index c32b62a8a1f..fd018366d67 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -496,13 +496,13 @@ config EZX_PCAP config AB8500_CORE bool "ST-Ericsson AB8500 Mixed Signal Power Management chip" - depends on GENERIC_HARDIRQS && ABX500_CORE && SPI_MASTER + depends on GENERIC_HARDIRQS && ABX500_CORE select MFD_CORE help Select this option to enable access to AB8500 power management - chip. This connects to U8500 either on the SSP/SPI bus - or the I2C bus via PRCMU. It also adds the irq_chip - parts for handling the Mixed Signal chip events. + chip. This connects to U8500 either on the SSP/SPI bus (deprecated + since hardware version v1.0) or the I2C bus via PRCMU. It also adds + the irq_chip parts for handling the Mixed Signal chip events. This chip embeds various other multimedia funtionalities as well. config AB8500_I2C_CORE diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index 5f35de9386e..a54e2c7c6a1 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -70,7 +70,7 @@ obj-$(CONFIG_ABX500_CORE) += abx500-core.o obj-$(CONFIG_AB3100_CORE) += ab3100-core.o obj-$(CONFIG_AB3100_OTP) += ab3100-otp.o obj-$(CONFIG_AB3550_CORE) += ab3550-core.o -obj-$(CONFIG_AB8500_CORE) += ab8500-core.o ab8500-spi.o +obj-$(CONFIG_AB8500_CORE) += ab8500-core.o obj-$(CONFIG_AB8500_I2C_CORE) += ab8500-i2c.o obj-$(CONFIG_AB8500_DEBUG) += ab8500-debugfs.o obj-$(CONFIG_MFD_TIMBERDALE) += timberdale.o diff --git a/drivers/mfd/ab8500-spi.c b/drivers/mfd/ab8500-spi.c deleted file mode 100644 index b1653421edb..00000000000 --- a/drivers/mfd/ab8500-spi.c +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright (C) ST-Ericsson SA 2010 - * - * License Terms: GNU General Public License v2 - * Author: Srinidhi Kasagar - */ - -#include -#include -#include -#include -#include -#include -#include - -/* - * This funtion writes to any AB8500 registers using - * SPI protocol & before it writes it packs the data - * in the below 24 bit frame format - * - * *|------------------------------------| - * *| 23|22...18|17.......10|9|8|7......0| - * *| r/w bank adr data | - * * ------------------------------------ - * - * This function shouldn't be called from interrupt - * context - */ -static int ab8500_spi_write(struct ab8500 *ab8500, u16 addr, u8 data) -{ - struct spi_device *spi = container_of(ab8500->dev, struct spi_device, - dev); - unsigned long spi_data = addr << 10 | data; - struct spi_transfer xfer; - struct spi_message msg; - - ab8500->tx_buf[0] = spi_data; - ab8500->rx_buf[0] = 0; - - xfer.tx_buf = ab8500->tx_buf; - xfer.rx_buf = NULL; - xfer.len = sizeof(unsigned long); - - spi_message_init(&msg); - spi_message_add_tail(&xfer, &msg); - - return spi_sync(spi, &msg); -} - -static int ab8500_spi_read(struct ab8500 *ab8500, u16 addr) -{ - struct spi_device *spi = container_of(ab8500->dev, struct spi_device, - dev); - unsigned long spi_data = 1 << 23 | addr << 10; - struct spi_transfer xfer; - struct spi_message msg; - int ret; - - ab8500->tx_buf[0] = spi_data; - ab8500->rx_buf[0] = 0; - - xfer.tx_buf = ab8500->tx_buf; - xfer.rx_buf = ab8500->rx_buf; - xfer.len = sizeof(unsigned long); - - spi_message_init(&msg); - spi_message_add_tail(&xfer, &msg); - - ret = spi_sync(spi, &msg); - if (!ret) - /* - * Only the 8 lowermost bytes are - * defined with value, the rest may - * vary depending on chip/board noise. - */ - ret = ab8500->rx_buf[0] & 0xFFU; - - return ret; -} - -static int __devinit ab8500_spi_probe(struct spi_device *spi) -{ - struct ab8500 *ab8500; - int ret; - - spi->bits_per_word = 24; - ret = spi_setup(spi); - if (ret < 0) - return ret; - - ab8500 = kzalloc(sizeof *ab8500, GFP_KERNEL); - if (!ab8500) - return -ENOMEM; - - ab8500->dev = &spi->dev; - ab8500->irq = spi->irq; - - ab8500->read = ab8500_spi_read; - ab8500->write = ab8500_spi_write; - - spi_set_drvdata(spi, ab8500); - - ret = ab8500_init(ab8500); - if (ret) - kfree(ab8500); - - return ret; -} - -static int __devexit ab8500_spi_remove(struct spi_device *spi) -{ - struct ab8500 *ab8500 = spi_get_drvdata(spi); - - ab8500_exit(ab8500); - kfree(ab8500); - - return 0; -} - -static struct spi_driver ab8500_spi_driver = { - .driver = { - .name = "ab8500-spi", - .owner = THIS_MODULE, - }, - .probe = ab8500_spi_probe, - .remove = __devexit_p(ab8500_spi_remove) -}; - -static int __init ab8500_spi_init(void) -{ - return spi_register_driver(&ab8500_spi_driver); -} -subsys_initcall(ab8500_spi_init); - -static void __exit ab8500_spi_exit(void) -{ - spi_unregister_driver(&ab8500_spi_driver); -} -module_exit(ab8500_spi_exit); - -MODULE_AUTHOR("Srinidhi KASAGAR Date: Thu, 23 Dec 2010 17:53:36 +0900 Subject: mfd: MAX8998/LP3974 hibernation support This patch makes the driver to save and restore register values for hibernation. Signed-off-by: MyungJoo Ham Signed-off-by: Kyungmin Park Signed-off-by: Samuel Ortiz --- drivers/mfd/max8998-irq.c | 7 +++ drivers/mfd/max8998.c | 108 ++++++++++++++++++++++++++++++++++++ include/linux/mfd/max8998-private.h | 2 + include/linux/mfd/max8998.h | 1 + 4 files changed, 118 insertions(+) diff --git a/drivers/mfd/max8998-irq.c b/drivers/mfd/max8998-irq.c index c6b61fcc580..3903e1fbb33 100644 --- a/drivers/mfd/max8998-irq.c +++ b/drivers/mfd/max8998-irq.c @@ -183,6 +183,13 @@ static irqreturn_t max8998_irq_thread(int irq, void *data) return IRQ_HANDLED; } +int max8998_irq_resume(struct max8998_dev *max8998) +{ + if (max8998->irq && max8998->irq_base) + max8998_irq_thread(max8998->irq_base, max8998); + return 0; +} + int max8998_irq_init(struct max8998_dev *max8998) { int i; diff --git a/drivers/mfd/max8998.c b/drivers/mfd/max8998.c index bb9977bebe7..5ce00ad5241 100644 --- a/drivers/mfd/max8998.c +++ b/drivers/mfd/max8998.c @@ -25,6 +25,8 @@ #include #include #include +#include +#include #include #include #include @@ -135,6 +137,7 @@ static int max8998_i2c_probe(struct i2c_client *i2c, if (pdata) { max8998->ono = pdata->ono; max8998->irq_base = pdata->irq_base; + max8998->wakeup = pdata->wakeup; } mutex_init(&max8998->iolock); @@ -146,6 +149,8 @@ static int max8998_i2c_probe(struct i2c_client *i2c, ret = mfd_add_devices(max8998->dev, -1, max8998_devs, ARRAY_SIZE(max8998_devs), NULL, 0); + pm_runtime_set_active(max8998->dev); + if (ret < 0) goto err; @@ -178,10 +183,113 @@ static const struct i2c_device_id max8998_i2c_id[] = { }; MODULE_DEVICE_TABLE(i2c, max8998_i2c_id); +static int max8998_suspend(struct device *dev) +{ + struct i2c_client *i2c = container_of(dev, struct i2c_client, dev); + struct max8998_dev *max8998 = i2c_get_clientdata(i2c); + + if (max8998->wakeup) + set_irq_wake(max8998->irq, 1); + return 0; +} + +static int max8998_resume(struct device *dev) +{ + struct i2c_client *i2c = container_of(dev, struct i2c_client, dev); + struct max8998_dev *max8998 = i2c_get_clientdata(i2c); + + if (max8998->wakeup) + set_irq_wake(max8998->irq, 0); + /* + * In LP3974, if IRQ registers are not "read & clear" + * when it's set during sleep, the interrupt becomes + * disabled. + */ + return max8998_irq_resume(i2c_get_clientdata(i2c)); +} + +struct max8998_reg_dump { + u8 addr; + u8 val; +}; +#define SAVE_ITEM(x) { .addr = (x), .val = 0x0, } +struct max8998_reg_dump max8998_dump[] = { + SAVE_ITEM(MAX8998_REG_IRQM1), + SAVE_ITEM(MAX8998_REG_IRQM2), + SAVE_ITEM(MAX8998_REG_IRQM3), + SAVE_ITEM(MAX8998_REG_IRQM4), + SAVE_ITEM(MAX8998_REG_STATUSM1), + SAVE_ITEM(MAX8998_REG_STATUSM2), + SAVE_ITEM(MAX8998_REG_CHGR1), + SAVE_ITEM(MAX8998_REG_CHGR2), + SAVE_ITEM(MAX8998_REG_LDO_ACTIVE_DISCHARGE1), + SAVE_ITEM(MAX8998_REG_LDO_ACTIVE_DISCHARGE1), + SAVE_ITEM(MAX8998_REG_BUCK_ACTIVE_DISCHARGE3), + SAVE_ITEM(MAX8998_REG_ONOFF1), + SAVE_ITEM(MAX8998_REG_ONOFF2), + SAVE_ITEM(MAX8998_REG_ONOFF3), + SAVE_ITEM(MAX8998_REG_ONOFF4), + SAVE_ITEM(MAX8998_REG_BUCK1_VOLTAGE1), + SAVE_ITEM(MAX8998_REG_BUCK1_VOLTAGE2), + SAVE_ITEM(MAX8998_REG_BUCK1_VOLTAGE3), + SAVE_ITEM(MAX8998_REG_BUCK1_VOLTAGE4), + SAVE_ITEM(MAX8998_REG_BUCK2_VOLTAGE1), + SAVE_ITEM(MAX8998_REG_BUCK2_VOLTAGE2), + SAVE_ITEM(MAX8998_REG_LDO2_LDO3), + SAVE_ITEM(MAX8998_REG_LDO4), + SAVE_ITEM(MAX8998_REG_LDO5), + SAVE_ITEM(MAX8998_REG_LDO6), + SAVE_ITEM(MAX8998_REG_LDO7), + SAVE_ITEM(MAX8998_REG_LDO8_LDO9), + SAVE_ITEM(MAX8998_REG_LDO10_LDO11), + SAVE_ITEM(MAX8998_REG_LDO12), + SAVE_ITEM(MAX8998_REG_LDO13), + SAVE_ITEM(MAX8998_REG_LDO14), + SAVE_ITEM(MAX8998_REG_LDO15), + SAVE_ITEM(MAX8998_REG_LDO16), + SAVE_ITEM(MAX8998_REG_LDO17), + SAVE_ITEM(MAX8998_REG_BKCHR), + SAVE_ITEM(MAX8998_REG_LBCNFG1), + SAVE_ITEM(MAX8998_REG_LBCNFG2), +}; +/* Save registers before hibernation */ +static int max8998_freeze(struct device *dev) +{ + struct i2c_client *i2c = container_of(dev, struct i2c_client, dev); + int i; + + for (i = 0; i < ARRAY_SIZE(max8998_dump); i++) + max8998_read_reg(i2c, max8998_dump[i].addr, + &max8998_dump[i].val); + + return 0; +} + +/* Restore registers after hibernation */ +static int max8998_restore(struct device *dev) +{ + struct i2c_client *i2c = container_of(dev, struct i2c_client, dev); + int i; + + for (i = 0; i < ARRAY_SIZE(max8998_dump); i++) + max8998_write_reg(i2c, max8998_dump[i].addr, + max8998_dump[i].val); + + return 0; +} + +const struct dev_pm_ops max8998_pm = { + .suspend = max8998_suspend, + .resume = max8998_resume, + .freeze = max8998_freeze, + .restore = max8998_restore, +}; + static struct i2c_driver max8998_i2c_driver = { .driver = { .name = "max8998", .owner = THIS_MODULE, + .pm = &max8998_pm, }, .probe = max8998_i2c_probe, .remove = max8998_i2c_remove, diff --git a/include/linux/mfd/max8998-private.h b/include/linux/mfd/max8998-private.h index 7363dea6bbc..effa5d3b96a 100644 --- a/include/linux/mfd/max8998-private.h +++ b/include/linux/mfd/max8998-private.h @@ -159,10 +159,12 @@ struct max8998_dev { u8 irq_masks_cur[MAX8998_NUM_IRQ_REGS]; u8 irq_masks_cache[MAX8998_NUM_IRQ_REGS]; int type; + bool wakeup; }; int max8998_irq_init(struct max8998_dev *max8998); void max8998_irq_exit(struct max8998_dev *max8998); +int max8998_irq_resume(struct max8998_dev *max8998); extern int max8998_read_reg(struct i2c_client *i2c, u8 reg, u8 *dest); extern int max8998_bulk_read(struct i2c_client *i2c, u8 reg, int count, diff --git a/include/linux/mfd/max8998.h b/include/linux/mfd/max8998.h index f8c9f884aff..686a744e63f 100644 --- a/include/linux/mfd/max8998.h +++ b/include/linux/mfd/max8998.h @@ -88,6 +88,7 @@ struct max8998_platform_data { int buck1_set1; int buck1_set2; int buck2_set3; + bool wakeup; }; #endif /* __LINUX_MFD_MAX8998_H */ -- cgit v1.2.3-70-g09d2 From 419cdc54ea597d307fade607a65e4885634eb8c8 Mon Sep 17 00:00:00 2001 From: Andres Salomon Date: Mon, 29 Nov 2010 15:45:06 -0800 Subject: x86: OLPC: convert olpc-xo1 driver from pci device to platform device The cs5535-mfd driver now takes care of the PCI BAR handling; this means the olpc-xo1 driver shouldn't be touching the PCI device at all. This patch uses both cs5535-acpi and cs5535-pms platform devices rather than a single platform device because the cs5535-mfd driver may be used by other CS5535 platform-specific drivers; OLPC doesn't get to dictate that ACPI and PMS will always be used together. Signed-off-by: Andres Salomon Acked-by: H. Peter Anvin Signed-off-by: Samuel Ortiz --- arch/x86/Kconfig | 2 +- arch/x86/platform/olpc/olpc-xo1.c | 101 +++++++++++++++++++++----------------- 2 files changed, 56 insertions(+), 47 deletions(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 36ed2e2c896..50aa81f2ffc 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -2068,7 +2068,7 @@ config OLPC config OLPC_XO1 tristate "OLPC XO-1 support" - depends on OLPC && PCI + depends on OLPC && MFD_CS5535 ---help--- Add support for non-essential features of the OLPC XO-1 laptop. diff --git a/arch/x86/platform/olpc/olpc-xo1.c b/arch/x86/platform/olpc/olpc-xo1.c index f5442c03abc..127775696d6 100644 --- a/arch/x86/platform/olpc/olpc-xo1.c +++ b/arch/x86/platform/olpc/olpc-xo1.c @@ -1,6 +1,7 @@ /* * Support for features of the OLPC XO-1 laptop * + * Copyright (C) 2010 Andres Salomon * Copyright (C) 2010 One Laptop per Child * Copyright (C) 2006 Red Hat, Inc. * Copyright (C) 2006 Advanced Micro Devices, Inc. @@ -12,8 +13,6 @@ */ #include -#include -#include #include #include @@ -22,9 +21,6 @@ #define DRV_NAME "olpc-xo1" -#define PMS_BAR 4 -#define ACPI_BAR 5 - /* PMC registers (PMS block) */ #define PM_SCLK 0x10 #define PM_IN_SLPCTL 0x20 @@ -57,65 +53,67 @@ static void xo1_power_off(void) outl(0x00002000, acpi_base + PM1_CNT); } -/* Read the base addresses from the PCI BAR info */ -static int __devinit setup_bases(struct pci_dev *pdev) +static int __devinit olpc_xo1_probe(struct platform_device *pdev) { - int r; + struct resource *res; - r = pci_enable_device_io(pdev); - if (r) { - dev_err(&pdev->dev, "can't enable device IO\n"); - return r; - } + /* don't run on non-XOs */ + if (!machine_is_olpc()) + return -ENODEV; - r = pci_request_region(pdev, ACPI_BAR, DRV_NAME); - if (r) { - dev_err(&pdev->dev, "can't alloc PCI BAR #%d\n", ACPI_BAR); - return r; + res = platform_get_resource(pdev, IORESOURCE_IO, 0); + if (!res) { + dev_err(&pdev->dev, "can't fetch device resource info\n"); + return -EIO; } - r = pci_request_region(pdev, PMS_BAR, DRV_NAME); - if (r) { - dev_err(&pdev->dev, "can't alloc PCI BAR #%d\n", PMS_BAR); - pci_release_region(pdev, ACPI_BAR); - return r; + if (!request_region(res->start, resource_size(res), DRV_NAME)) { + dev_err(&pdev->dev, "can't request region\n"); + return -EIO; } - acpi_base = pci_resource_start(pdev, ACPI_BAR); - pms_base = pci_resource_start(pdev, PMS_BAR); + if (strcmp(pdev->name, "cs5535-pms") == 0) + pms_base = res->start; + else if (strcmp(pdev->name, "cs5535-acpi") == 0) + acpi_base = res->start; + + /* If we have both addresses, we can override the poweroff hook */ + if (pms_base && acpi_base) { + pm_power_off = xo1_power_off; + printk(KERN_INFO "OLPC XO-1 support registered\n"); + } return 0; } -static int __devinit olpc_xo1_probe(struct platform_device *pdev) +static int __devexit olpc_xo1_remove(struct platform_device *pdev) { - struct pci_dev *pcidev; - int r; - - pcidev = pci_get_device(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_ISA, - NULL); - if (!pdev) - return -ENODEV; - - r = setup_bases(pcidev); - if (r) - return r; + struct resource *r; - pm_power_off = xo1_power_off; + r = platform_get_resource(pdev, IORESOURCE_IO, 0); + release_region(r->start, resource_size(r)); - printk(KERN_INFO "OLPC XO-1 support registered\n"); - return 0; -} + if (strcmp(pdev->name, "cs5535-pms") == 0) + pms_base = 0; + else if (strcmp(pdev->name, "cs5535-acpi") == 0) + acpi_base = 0; -static int __devexit olpc_xo1_remove(struct platform_device *pdev) -{ pm_power_off = NULL; return 0; } -static struct platform_driver olpc_xo1_driver = { +static struct platform_driver cs5535_pms_drv = { + .driver = { + .name = "cs5535-pms", + .owner = THIS_MODULE, + }, + .probe = olpc_xo1_probe, + .remove = __devexit_p(olpc_xo1_remove), +}; + +static struct platform_driver cs5535_acpi_drv = { .driver = { - .name = DRV_NAME, + .name = "cs5535-acpi", .owner = THIS_MODULE, }, .probe = olpc_xo1_probe, @@ -124,12 +122,23 @@ static struct platform_driver olpc_xo1_driver = { static int __init olpc_xo1_init(void) { - return platform_driver_register(&olpc_xo1_driver); + int r; + + r = platform_driver_register(&cs5535_pms_drv); + if (r) + return r; + + r = platform_driver_register(&cs5535_acpi_drv); + if (r) + platform_driver_unregister(&cs5535_pms_drv); + + return r; } static void __exit olpc_xo1_exit(void) { - platform_driver_unregister(&olpc_xo1_driver); + platform_driver_unregister(&cs5535_acpi_drv); + platform_driver_unregister(&cs5535_pms_drv); } MODULE_AUTHOR("Daniel Drake "); -- cgit v1.2.3-70-g09d2 From de8255ccd219267cfd34139022b197c1ef8f032f Mon Sep 17 00:00:00 2001 From: Andres Salomon Date: Thu, 30 Dec 2010 20:27:33 -0800 Subject: i2c: Convert SCx200 driver from using raw PCI to platform device The SCx200 ACB driver supports ISA hardware as well as PCI. The PCI hardware is CS5535/CS5536 based, and the device that it grabs is handled by the cs5535-mfd driver. This converts the SCx200 driver to use a platform_driver rather than the previous PCI hackery. The driver used to manually track the iface list (via linked list); now it only does this for ISA devices. PCI ifaces are handled through standard driver model lists. It's unclear what happens in case of errors in the old ISA code; rather than pretending the code actually cares, I've dropped the (implicit) ignorance of return values and marked it with a comment. Signed-off-by: Andres Salomon Signed-off-by: Samuel Ortiz --- drivers/i2c/busses/scx200_acb.c | 200 ++++++++++++++++------------------------ 1 file changed, 80 insertions(+), 120 deletions(-) diff --git a/drivers/i2c/busses/scx200_acb.c b/drivers/i2c/busses/scx200_acb.c index 53fab518b3d..986e5f62deb 100644 --- a/drivers/i2c/busses/scx200_acb.c +++ b/drivers/i2c/busses/scx200_acb.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -40,6 +41,7 @@ MODULE_AUTHOR("Christer Weinigel "); MODULE_DESCRIPTION("NatSemi SCx200 ACCESS.bus Driver"); +MODULE_ALIAS("platform:cs5535-smb"); MODULE_LICENSE("GPL"); #define MAX_DEVICES 4 @@ -84,10 +86,6 @@ struct scx200_acb_iface { u8 *ptr; char needs_reset; unsigned len; - - /* PCI device info */ - struct pci_dev *pdev; - int bar; }; /* Register Definitions */ @@ -391,7 +389,7 @@ static const struct i2c_algorithm scx200_acb_algorithm = { static struct scx200_acb_iface *scx200_acb_list; static DEFINE_MUTEX(scx200_acb_list_mutex); -static __init int scx200_acb_probe(struct scx200_acb_iface *iface) +static __devinit int scx200_acb_probe(struct scx200_acb_iface *iface) { u8 val; @@ -427,7 +425,7 @@ static __init int scx200_acb_probe(struct scx200_acb_iface *iface) return 0; } -static __init struct scx200_acb_iface *scx200_create_iface(const char *text, +static __devinit struct scx200_acb_iface *scx200_create_iface(const char *text, struct device *dev, int index) { struct scx200_acb_iface *iface; @@ -452,7 +450,7 @@ static __init struct scx200_acb_iface *scx200_create_iface(const char *text, return iface; } -static int __init scx200_acb_create(struct scx200_acb_iface *iface) +static int __devinit scx200_acb_create(struct scx200_acb_iface *iface) { struct i2c_adapter *adapter; int rc; @@ -472,183 +470,145 @@ static int __init scx200_acb_create(struct scx200_acb_iface *iface) return -ENODEV; } - mutex_lock(&scx200_acb_list_mutex); - iface->next = scx200_acb_list; - scx200_acb_list = iface; - mutex_unlock(&scx200_acb_list_mutex); + if (!adapter->dev.parent) { + /* If there's no dev, we're tracking (ISA) ifaces manually */ + mutex_lock(&scx200_acb_list_mutex); + iface->next = scx200_acb_list; + scx200_acb_list = iface; + mutex_unlock(&scx200_acb_list_mutex); + } return 0; } -static __init int scx200_create_pci(const char *text, struct pci_dev *pdev, - int bar) +static struct scx200_acb_iface * __devinit scx200_create_dev(const char *text, + unsigned long base, int index, struct device *dev) { struct scx200_acb_iface *iface; int rc; - iface = scx200_create_iface(text, &pdev->dev, 0); + iface = scx200_create_iface(text, dev, index); if (iface == NULL) - return -ENOMEM; - - iface->pdev = pdev; - iface->bar = bar; - - rc = pci_enable_device_io(iface->pdev); - if (rc) - goto errout_free; + return NULL; - rc = pci_request_region(iface->pdev, iface->bar, iface->adapter.name); - if (rc) { - printk(KERN_ERR NAME ": can't allocate PCI BAR %d\n", - iface->bar); + if (!request_region(base, 8, iface->adapter.name)) { + printk(KERN_ERR NAME ": can't allocate io 0x%lx-0x%lx\n", + base, base + 8 - 1); goto errout_free; } - iface->base = pci_resource_start(iface->pdev, iface->bar); + iface->base = base; rc = scx200_acb_create(iface); if (rc == 0) - return 0; + return iface; - pci_release_region(iface->pdev, iface->bar); - pci_dev_put(iface->pdev); + release_region(base, 8); errout_free: kfree(iface); - return rc; + return NULL; } -static int __init scx200_create_isa(const char *text, unsigned long base, - int index) +static int __devinit scx200_probe(struct platform_device *pdev) { struct scx200_acb_iface *iface; - int rc; - - iface = scx200_create_iface(text, NULL, index); - - if (iface == NULL) - return -ENOMEM; + struct resource *res; - if (!request_region(base, 8, iface->adapter.name)) { - printk(KERN_ERR NAME ": can't allocate io 0x%lx-0x%lx\n", - base, base + 8 - 1); - rc = -EBUSY; - goto errout_free; + res = platform_get_resource(pdev, IORESOURCE_IO, 0); + if (!res) { + dev_err(&pdev->dev, "can't fetch device resource info\n"); + return -ENODEV; } - iface->base = base; - rc = scx200_acb_create(iface); + iface = scx200_create_dev("CS5535", res->start, 0, &pdev->dev); + if (!iface) + return -EIO; - if (rc == 0) - return 0; + dev_info(&pdev->dev, "SCx200 device '%s' registered\n", + iface->adapter.name); + platform_set_drvdata(pdev, iface); - release_region(base, 8); - errout_free: - kfree(iface); - return rc; + return 0; } -/* Driver data is an index into the scx200_data array that indicates - * the name and the BAR where the I/O address resource is located. ISA - * devices are flagged with a bar value of -1 */ - -static const struct pci_device_id scx200_pci[] __initconst = { - { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_SCx200_BRIDGE), - .driver_data = 0 }, - { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_SC1100_BRIDGE), - .driver_data = 0 }, - { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_CS5535_ISA), - .driver_data = 1 }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_ISA), - .driver_data = 2 }, - { 0, } -}; - -static struct { - const char *name; - int bar; -} scx200_data[] = { - { "SCx200", -1 }, - { "CS5535", 0 }, - { "CS5536", 0 } -}; +static void __devexit scx200_cleanup_iface(struct scx200_acb_iface *iface) +{ + i2c_del_adapter(&iface->adapter); + release_region(iface->base, 8); + kfree(iface); +} -static __init int scx200_scan_pci(void) +static int __devexit scx200_remove(struct platform_device *pdev) { - int data, dev; - int rc = -ENODEV; - struct pci_dev *pdev; + struct scx200_acb_iface *iface; - for(dev = 0; dev < ARRAY_SIZE(scx200_pci); dev++) { - pdev = pci_get_device(scx200_pci[dev].vendor, - scx200_pci[dev].device, NULL); + iface = platform_get_drvdata(pdev); + platform_set_drvdata(pdev, NULL); + scx200_cleanup_iface(iface); - if (pdev == NULL) - continue; + return 0; +} - data = scx200_pci[dev].driver_data; +static struct platform_driver scx200_pci_drv = { + .driver = { + .name = "cs5535-smb", + .owner = THIS_MODULE, + }, + .probe = scx200_probe, + .remove = __devexit_p(scx200_remove), +}; - /* if .bar is greater or equal to zero, this is a - * PCI device - otherwise, we assume - that the ports are ISA based - */ +static const struct pci_device_id scx200_isa[] __initconst = { + { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_SCx200_BRIDGE) }, + { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_SC1100_BRIDGE) }, + { 0, } +}; - if (scx200_data[data].bar >= 0) - rc = scx200_create_pci(scx200_data[data].name, pdev, - scx200_data[data].bar); - else { - int i; +static __init void scx200_scan_isa(void) +{ + int i; - pci_dev_put(pdev); - for (i = 0; i < MAX_DEVICES; ++i) { - if (base[i] == 0) - continue; + if (!pci_dev_present(scx200_isa)) + return; - rc = scx200_create_isa(scx200_data[data].name, - base[i], - i); - } - } + for (i = 0; i < MAX_DEVICES; ++i) { + if (base[i] == 0) + continue; - break; + /* XXX: should we care about failures? */ + scx200_create_dev("SCx200", base[i], i, NULL); } - - return rc; } static int __init scx200_acb_init(void) { - int rc; - pr_debug(NAME ": NatSemi SCx200 ACCESS.bus Driver\n"); - rc = scx200_scan_pci(); + /* First scan for ISA-based devices */ + scx200_scan_isa(); /* XXX: should we care about errors? */ /* If at least one bus was created, init must succeed */ if (scx200_acb_list) return 0; - return rc; + + /* No ISA devices; register the platform driver for PCI-based devices */ + return platform_driver_register(&scx200_pci_drv); } static void __exit scx200_acb_cleanup(void) { struct scx200_acb_iface *iface; + platform_driver_unregister(&scx200_pci_drv); + mutex_lock(&scx200_acb_list_mutex); while ((iface = scx200_acb_list) != NULL) { scx200_acb_list = iface->next; mutex_unlock(&scx200_acb_list_mutex); - i2c_del_adapter(&iface->adapter); - - if (iface->pdev) { - pci_release_region(iface->pdev, iface->bar); - pci_dev_put(iface->pdev); - } - else - release_region(iface->base, 8); + scx200_cleanup_iface(iface); - kfree(iface); mutex_lock(&scx200_acb_list_mutex); } mutex_unlock(&scx200_acb_list_mutex); -- cgit v1.2.3-70-g09d2 From 337ce5d1c5759644cea6c47220ce7e84f0398362 Mon Sep 17 00:00:00 2001 From: MyungJoo Ham Date: Tue, 4 Jan 2011 14:17:39 +0900 Subject: mfd: Support LP3974 RTC The first releases of LP3974 have a large delay in RTC registers, which requires 2 seconds of delay after writing to a rtc register (recommended by National Semiconductor's engineers) before reading it. If "rtc_delay" field of the platform data is true, the rtc driver assumes that such delays are required. Although we have not seen LP3974s without requiring such delays, we assume that such LP3974s will be released soon (or they have done so already) and they are supported by "lp3974" without setting "rtc_delay" at the platform data. This patch adds delays with msleep when writing values to RTC registers if the platform data has rtc_delay set. Signed-off-by: MyungJoo Ham Signed-off-by: Kyungmin Park Reviewed-by: Mark Brown Signed-off-by: Samuel Ortiz --- drivers/mfd/max8998.c | 26 +++++++++++++++++++--- drivers/regulator/max8998.c | 7 ++++++ drivers/rtc/rtc-max8998.c | 54 ++++++++++++++++++++++++++++++++++++++++----- include/linux/mfd/max8998.h | 4 ++++ 4 files changed, 83 insertions(+), 8 deletions(-) diff --git a/drivers/mfd/max8998.c b/drivers/mfd/max8998.c index 5ce00ad5241..bbfe8673260 100644 --- a/drivers/mfd/max8998.c +++ b/drivers/mfd/max8998.c @@ -42,6 +42,14 @@ static struct mfd_cell max8998_devs[] = { }, }; +static struct mfd_cell lp3974_devs[] = { + { + .name = "lp3974-pmic", + }, { + .name = "lp3974-rtc", + }, +}; + int max8998_read_reg(struct i2c_client *i2c, u8 reg, u8 *dest) { struct max8998_dev *max8998 = i2c_get_clientdata(i2c); @@ -146,11 +154,23 @@ static int max8998_i2c_probe(struct i2c_client *i2c, max8998_irq_init(max8998); - ret = mfd_add_devices(max8998->dev, -1, - max8998_devs, ARRAY_SIZE(max8998_devs), - NULL, 0); pm_runtime_set_active(max8998->dev); + switch (id->driver_data) { + case TYPE_LP3974: + ret = mfd_add_devices(max8998->dev, -1, + lp3974_devs, ARRAY_SIZE(lp3974_devs), + NULL, 0); + break; + case TYPE_MAX8998: + ret = mfd_add_devices(max8998->dev, -1, + max8998_devs, ARRAY_SIZE(max8998_devs), + NULL, 0); + break; + default: + ret = -EINVAL; + } + if (ret < 0) goto err; diff --git a/drivers/regulator/max8998.c b/drivers/regulator/max8998.c index 7568df6122a..af52ebfc492 100644 --- a/drivers/regulator/max8998.c +++ b/drivers/regulator/max8998.c @@ -835,6 +835,12 @@ static int __devexit max8998_pmic_remove(struct platform_device *pdev) return 0; } +static const struct platform_device_id max8998_pmic_id[] = { + { "max8998-pmic", TYPE_MAX8998 }, + { "lp3974-pmic", TYPE_LP3974 }, + { } +}; + static struct platform_driver max8998_pmic_driver = { .driver = { .name = "max8998-pmic", @@ -842,6 +848,7 @@ static struct platform_driver max8998_pmic_driver = { }, .probe = max8998_pmic_probe, .remove = __devexit_p(max8998_pmic_remove), + .id_table = max8998_pmic_id, }; static int __init max8998_pmic_init(void) diff --git a/drivers/rtc/rtc-max8998.c b/drivers/rtc/rtc-max8998.c index f22dee35f33..3f7bc6b9fef 100644 --- a/drivers/rtc/rtc-max8998.c +++ b/drivers/rtc/rtc-max8998.c @@ -20,6 +20,7 @@ #include #include #include +#include #define MAX8998_RTC_SEC 0x00 #define MAX8998_RTC_MIN 0x01 @@ -73,6 +74,7 @@ struct max8998_rtc_info { struct i2c_client *rtc; struct rtc_device *rtc_dev; int irq; + bool lp3974_bug_workaround; }; static void max8998_data_to_tm(u8 *data, struct rtc_time *tm) @@ -124,10 +126,16 @@ static int max8998_rtc_set_time(struct device *dev, struct rtc_time *tm) { struct max8998_rtc_info *info = dev_get_drvdata(dev); u8 data[8]; + int ret; max8998_tm_to_data(tm, data); - return max8998_bulk_write(info->rtc, MAX8998_RTC_SEC, 8, data); + ret = max8998_bulk_write(info->rtc, MAX8998_RTC_SEC, 8, data); + + if (info->lp3974_bug_workaround) + msleep(2000); + + return ret; } static int max8998_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) @@ -163,12 +171,29 @@ static int max8998_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) static int max8998_rtc_stop_alarm(struct max8998_rtc_info *info) { - return max8998_write_reg(info->rtc, MAX8998_ALARM0_CONF, 0); + int ret = max8998_write_reg(info->rtc, MAX8998_ALARM0_CONF, 0); + + if (info->lp3974_bug_workaround) + msleep(2000); + + return ret; } static int max8998_rtc_start_alarm(struct max8998_rtc_info *info) { - return max8998_write_reg(info->rtc, MAX8998_ALARM0_CONF, 0x77); + int ret; + u8 alarm0_conf = 0x77; + + /* LP3974 with delay bug chips has rtc alarm bugs with "MONTH" field */ + if (info->lp3974_bug_workaround) + alarm0_conf = 0x57; + + ret = max8998_write_reg(info->rtc, MAX8998_ALARM0_CONF, alarm0_conf); + + if (info->lp3974_bug_workaround) + msleep(2000); + + return ret; } static int max8998_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) @@ -187,10 +212,13 @@ static int max8998_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) if (ret < 0) return ret; + if (info->lp3974_bug_workaround) + msleep(2000); + if (alrm->enabled) - return max8998_rtc_start_alarm(info); + ret = max8998_rtc_start_alarm(info); - return 0; + return ret; } static int max8998_rtc_alarm_irq_enable(struct device *dev, @@ -224,6 +252,7 @@ static const struct rtc_class_ops max8998_rtc_ops = { static int __devinit max8998_rtc_probe(struct platform_device *pdev) { struct max8998_dev *max8998 = dev_get_drvdata(pdev->dev.parent); + struct max8998_platform_data *pdata = dev_get_platdata(max8998->dev); struct max8998_rtc_info *info; int ret; @@ -249,10 +278,18 @@ static int __devinit max8998_rtc_probe(struct platform_device *pdev) ret = request_threaded_irq(info->irq, NULL, max8998_rtc_alarm_irq, 0, "rtc-alarm0", info); + if (ret < 0) dev_err(&pdev->dev, "Failed to request alarm IRQ: %d: %d\n", info->irq, ret); + dev_info(&pdev->dev, "RTC CHIP NAME: %s\n", pdev->id_entry->name); + if (pdata->rtc_delay) { + info->lp3974_bug_workaround = true; + dev_warn(&pdev->dev, "LP3974 with RTC REGERR option." + " RTC updates will be extremely slow.\n"); + } + return 0; out_rtc: @@ -273,6 +310,12 @@ static int __devexit max8998_rtc_remove(struct platform_device *pdev) return 0; } +static const struct platform_device_id max8998_rtc_id[] = { + { "max8998-rtc", TYPE_MAX8998 }, + { "lp3974-rtc", TYPE_LP3974 }, + { } +}; + static struct platform_driver max8998_rtc_driver = { .driver = { .name = "max8998-rtc", @@ -280,6 +323,7 @@ static struct platform_driver max8998_rtc_driver = { }, .probe = max8998_rtc_probe, .remove = __devexit_p(max8998_rtc_remove), + .id_table = max8998_rtc_id, }; static int __init max8998_rtc_init(void) diff --git a/include/linux/mfd/max8998.h b/include/linux/mfd/max8998.h index 686a744e63f..c22b9a417c3 100644 --- a/include/linux/mfd/max8998.h +++ b/include/linux/mfd/max8998.h @@ -76,6 +76,9 @@ struct max8998_regulator_data { * @buck1_set1: BUCK1 gpio pin 1 to set output voltage * @buck1_set2: BUCK1 gpio pin 2 to set output voltage * @buck2_set3: BUCK2 gpio pin to set output voltage + * @wakeup: Allow to wake up from suspend + * @rtc_delay: LP3974 RTC chip bug that requires delay after a register + * write before reading it. */ struct max8998_platform_data { struct max8998_regulator_data *regulators; @@ -89,6 +92,7 @@ struct max8998_platform_data { int buck1_set2; int buck2_set3; bool wakeup; + bool rtc_delay; }; #endif /* __LINUX_MFD_MAX8998_H */ -- cgit v1.2.3-70-g09d2 From 735a3d9efdc5aeebe201008e6655b235c7f02aeb Mon Sep 17 00:00:00 2001 From: MyungJoo Ham Date: Tue, 11 Jan 2011 12:20:05 +0100 Subject: regulator: Support MAX8998/LP3974 DVS-GPIO The previous driver did not support BUCK1-DVS3, BUCK1-DVS4, and BUCK2-DVS2 modes. This patch adds such modes and an option to block setting buck1/2 voltages out of the preset values. Signed-off-by: MyungJoo Ham Signed-off-by: Kyungmin Park Acked-by: Mark Brown Signed-off-by: Samuel Ortiz --- drivers/regulator/max8998.c | 87 ++++++++++++++++++++++++++++++++++----------- include/linux/mfd/max8998.h | 26 ++++++++++---- 2 files changed, 87 insertions(+), 26 deletions(-) diff --git a/drivers/regulator/max8998.c b/drivers/regulator/max8998.c index af52ebfc492..0ec49ca527a 100644 --- a/drivers/regulator/max8998.c +++ b/drivers/regulator/max8998.c @@ -424,6 +424,9 @@ static int max8998_set_voltage_buck(struct regulator_dev *rdev, } } + if (pdata->buck_voltage_lock) + return -EINVAL; + /* no predefine regulator found */ max8998->buck1_idx = (buck1_last_val % 2) + 2; dev_dbg(max8998->dev, "max8998->buck1_idx:%d\n", @@ -451,18 +454,26 @@ buck1_exit: "BUCK2, i:%d buck2_vol1:%d, buck2_vol2:%d\n" , i, max8998->buck2_vol[0], max8998->buck2_vol[1]); if (gpio_is_valid(pdata->buck2_set3)) { - if (max8998->buck2_vol[0] == i) { - max8998->buck1_idx = 0; - buck2_gpio_set(pdata->buck2_set3, 0); - } else { - max8998->buck1_idx = 1; - ret = max8998_get_voltage_register(rdev, ®, - &shift, - &mask); - ret = max8998_write_reg(i2c, reg, i); - max8998->buck2_vol[1] = i; - buck2_gpio_set(pdata->buck2_set3, 1); + + /* check if requested voltage */ + /* value is already defined */ + for (j = 0; j < ARRAY_SIZE(max8998->buck2_vol); j++) { + if (max8998->buck2_vol[j] == i) { + max8998->buck2_idx = j; + buck2_gpio_set(pdata->buck2_set3, j); + goto buck2_exit; + } } + + if (pdata->buck_voltage_lock) + return -EINVAL; + + max8998_get_voltage_register(rdev, + ®, &shift, &mask); + ret = max8998_write_reg(i2c, reg, i); + max8998->buck2_vol[max8998->buck2_idx] = i; + buck2_gpio_set(pdata->buck2_set3, max8998->buck2_idx); +buck2_exit: dev_dbg(max8998->dev, "%s: SET3:%d\n", i2c->name, gpio_get_value(pdata->buck2_set3)); } else { @@ -707,6 +718,9 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev) platform_set_drvdata(pdev, max8998); i2c = max8998->iodev->i2c; + max8998->buck1_idx = pdata->buck1_default_idx; + max8998->buck2_idx = pdata->buck2_default_idx; + /* NOTE: */ /* For unused GPIO NOT marked as -1 (thereof equal to 0) WARN_ON */ /* will be displayed */ @@ -739,23 +753,46 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev) i = 0; while (buck12_voltage_map_desc.min + buck12_voltage_map_desc.step*i - != (pdata->buck1_max_voltage1 / 1000)) + < (pdata->buck1_voltage1 / 1000)) i++; - printk(KERN_ERR "i:%d, buck1_idx:%d\n", i, max8998->buck1_idx); max8998->buck1_vol[0] = i; ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE1, i); + if (ret) + return ret; /* Set predefined value for BUCK1 register 2 */ i = 0; while (buck12_voltage_map_desc.min + buck12_voltage_map_desc.step*i - != (pdata->buck1_max_voltage2 / 1000)) + < (pdata->buck1_voltage2 / 1000)) i++; max8998->buck1_vol[1] = i; - printk(KERN_ERR "i:%d, buck1_idx:%d\n", i, max8998->buck1_idx); - ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE2, i) - + ret; + ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE2, i); + if (ret) + return ret; + + /* Set predefined value for BUCK1 register 3 */ + i = 0; + while (buck12_voltage_map_desc.min + + buck12_voltage_map_desc.step*i + < (pdata->buck1_voltage3 / 1000)) + i++; + + max8998->buck1_vol[2] = i; + ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE3, i); + if (ret) + return ret; + + /* Set predefined value for BUCK1 register 4 */ + i = 0; + while (buck12_voltage_map_desc.min + + buck12_voltage_map_desc.step*i + < (pdata->buck1_voltage4 / 1000)) + i++; + + max8998->buck1_vol[3] = i; + ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE4, i); if (ret) return ret; @@ -772,18 +809,28 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev) gpio_direction_output(pdata->buck2_set3, max8998->buck2_idx & 0x1); - /* BUCK2 - set preset default voltage value to buck2_vol[0] */ + /* BUCK2 register 1 */ i = 0; while (buck12_voltage_map_desc.min + buck12_voltage_map_desc.step*i - != (pdata->buck2_max_voltage / 1000)) + < (pdata->buck2_voltage1 / 1000)) i++; - printk(KERN_ERR "i:%d, buck2_idx:%d\n", i, max8998->buck2_idx); max8998->buck2_vol[0] = i; ret = max8998_write_reg(i2c, MAX8998_REG_BUCK2_VOLTAGE1, i); if (ret) return ret; + /* BUCK2 register 2 */ + i = 0; + while (buck12_voltage_map_desc.min + + buck12_voltage_map_desc.step*i + < (pdata->buck2_voltage2 / 1000)) + i++; + printk(KERN_ERR "i2:%d, buck2_idx:%d\n", i, max8998->buck2_idx); + max8998->buck2_vol[1] = i; + ret = max8998_write_reg(i2c, MAX8998_REG_BUCK2_VOLTAGE2, i); + if (ret) + return ret; } for (i = 0; i < pdata->num_regulators; i++) { diff --git a/include/linux/mfd/max8998.h b/include/linux/mfd/max8998.h index c22b9a417c3..61daa167b57 100644 --- a/include/linux/mfd/max8998.h +++ b/include/linux/mfd/max8998.h @@ -70,12 +70,20 @@ struct max8998_regulator_data { * @num_regulators: number of regultors used * @irq_base: base IRQ number for max8998, required for IRQs * @ono: power onoff IRQ number for max8998 - * @buck1_max_voltage1: BUCK1 maximum alowed voltage register 1 - * @buck1_max_voltage2: BUCK1 maximum alowed voltage register 2 - * @buck2_max_voltage: BUCK2 maximum alowed voltage + * @buck_voltage_lock: Do NOT change the values of the following six + * registers set by buck?_voltage?. The voltage of BUCK1/2 cannot + * be other than the preset values. + * @buck1_voltage1: BUCK1 DVS mode 1 voltage register + * @buck1_voltage2: BUCK1 DVS mode 2 voltage register + * @buck1_voltage3: BUCK1 DVS mode 3 voltage register + * @buck1_voltage4: BUCK1 DVS mode 4 voltage register + * @buck2_voltage1: BUCK2 DVS mode 1 voltage register + * @buck2_voltage2: BUCK2 DVS mode 2 voltage register * @buck1_set1: BUCK1 gpio pin 1 to set output voltage * @buck1_set2: BUCK1 gpio pin 2 to set output voltage + * @buck1_default_idx: Default for BUCK1 gpio pin 1, 2 * @buck2_set3: BUCK2 gpio pin to set output voltage + * @buck2_default_idx: Default for BUCK2 gpio pin. * @wakeup: Allow to wake up from suspend * @rtc_delay: LP3974 RTC chip bug that requires delay after a register * write before reading it. @@ -85,12 +93,18 @@ struct max8998_platform_data { int num_regulators; int irq_base; int ono; - int buck1_max_voltage1; - int buck1_max_voltage2; - int buck2_max_voltage; + bool buck_voltage_lock; + int buck1_voltage1; + int buck1_voltage2; + int buck1_voltage3; + int buck1_voltage4; + int buck2_voltage1; + int buck2_voltage2; int buck1_set1; int buck1_set2; + int buck1_default_idx; int buck2_set3; + int buck2_default_idx; bool wakeup; bool rtc_delay; }; -- cgit v1.2.3-70-g09d2 From c538ddbe4fc70ef97af02d57abad34b246b19082 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Wed, 5 Jan 2011 15:12:39 +0000 Subject: mfd: Convert WM831x away from legacy I2C PM operations Since the legacy bus PM operations are deprecated move the suspend method over to dev_pm_ops. Signed-off-by: Mark Brown Signed-off-by: Samuel Ortiz --- drivers/mfd/wm831x-i2c.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/mfd/wm831x-i2c.c b/drivers/mfd/wm831x-i2c.c index 38be5201c78..3853fa8e7cc 100644 --- a/drivers/mfd/wm831x-i2c.c +++ b/drivers/mfd/wm831x-i2c.c @@ -94,9 +94,9 @@ static int wm831x_i2c_remove(struct i2c_client *i2c) return 0; } -static int wm831x_i2c_suspend(struct i2c_client *i2c, pm_message_t mesg) +static int wm831x_i2c_suspend(struct device *dev) { - struct wm831x *wm831x = i2c_get_clientdata(i2c); + struct wm831x *wm831x = dev_get_drvdata(dev); return wm831x_device_suspend(wm831x); } @@ -113,15 +113,18 @@ static const struct i2c_device_id wm831x_i2c_id[] = { }; MODULE_DEVICE_TABLE(i2c, wm831x_i2c_id); +static const struct dev_pm_ops wm831x_pm_ops = { + .suspend = wm831x_i2c_suspend, +}; static struct i2c_driver wm831x_i2c_driver = { .driver = { - .name = "wm831x", - .owner = THIS_MODULE, + .name = "wm831x", + .owner = THIS_MODULE, + .pm = &wm831x_pm_ops, }, .probe = wm831x_i2c_probe, .remove = wm831x_i2c_remove, - .suspend = wm831x_i2c_suspend, .id_table = wm831x_i2c_id, }; -- cgit v1.2.3-70-g09d2 From 180e4f5f20ef2b03ce2b38634274dde5ccbd8951 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Wed, 5 Jan 2011 17:56:01 +0000 Subject: mfd: Flag WM831x /IRQ as a wake source The WM831x can generate wake events, some unconditionally, so flag the primary IRQ as a wake source in order to help the CPU treat the /IRQ signal appropriately. Signed-off-by: Mark Brown Signed-off-by: Samuel Ortiz --- drivers/mfd/wm831x-irq.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/mfd/wm831x-irq.c b/drivers/mfd/wm831x-irq.c index ee88f6a05ce..f7192d438aa 100644 --- a/drivers/mfd/wm831x-irq.c +++ b/drivers/mfd/wm831x-irq.c @@ -517,6 +517,17 @@ int wm831x_irq_init(struct wm831x *wm831x, int irq) return 0; } + /* Try to flag /IRQ as a wake source; there are a number of + * unconditional wake sources in the PMIC so this isn't + * conditional but we don't actually care *too* much if it + * fails. + */ + ret = enable_irq_wake(irq); + if (ret != 0) { + dev_warn(wm831x->dev, "Can't enable IRQ as wake source: %d\n", + ret); + } + wm831x->irq = irq; wm831x->irq_base = pdata->irq_base; -- cgit v1.2.3-70-g09d2 From 92d50a4132977b932ed830fa58c05deeb5c524f0 Mon Sep 17 00:00:00 2001 From: Mattias Wallin Date: Tue, 7 Dec 2010 11:20:47 +0100 Subject: mfd: ab8500-core chip version cut 2.0 support This patch adds support for chip version 2.0 or cut 2.0. One new interrupt latch register - latch 12 - is introduced. Signed-off-by: Mattias Wallin Acked-by: Linus Walleij Signed-off-by: Samuel Ortiz --- drivers/mfd/ab8500-core.c | 36 +++++++++++++++++++++---------- include/linux/mfd/ab8500.h | 53 ++++++++++++++++++++++++++-------------------- 2 files changed, 55 insertions(+), 34 deletions(-) diff --git a/drivers/mfd/ab8500-core.c b/drivers/mfd/ab8500-core.c index 86cc8874e6d..b6887014d68 100644 --- a/drivers/mfd/ab8500-core.c +++ b/drivers/mfd/ab8500-core.c @@ -52,6 +52,7 @@ #define AB8500_IT_LATCH8_REG 0x27 #define AB8500_IT_LATCH9_REG 0x28 #define AB8500_IT_LATCH10_REG 0x29 +#define AB8500_IT_LATCH12_REG 0x2B #define AB8500_IT_LATCH19_REG 0x32 #define AB8500_IT_LATCH20_REG 0x33 #define AB8500_IT_LATCH21_REG 0x34 @@ -98,7 +99,7 @@ * offset 0. */ static const int ab8500_irq_regoffset[AB8500_NUM_IRQ_REGS] = { - 0, 1, 2, 3, 4, 6, 7, 8, 9, 18, 19, 20, 21, + 0, 1, 2, 3, 4, 6, 7, 8, 9, 11, 18, 19, 20, 21, }; static int ab8500_get_chip_id(struct device *dev) @@ -252,6 +253,10 @@ static void ab8500_irq_sync_unlock(struct irq_data *data) if (new == old) continue; + /* Interrupt register 12 does'nt exist prior to version 0x20 */ + if (ab8500_irq_regoffset[i] == 11 && ab8500->chip_id < 0x20) + continue; + ab8500->oldmask[i] = new; reg = AB8500_IT_MASK1_REG + ab8500_irq_regoffset[i]; @@ -301,6 +306,10 @@ static irqreturn_t ab8500_irq(int irq, void *dev) int status; u8 value; + /* Interrupt register 12 does'nt exist prior to version 0x20 */ + if (regoffset == 11 && ab8500->chip_id < 0x20) + continue; + status = get_register_interruptible(ab8500, AB8500_INTERRUPT, AB8500_IT_LATCH1_REG + regoffset, &value); if (status < 0 || value == 0) @@ -554,6 +563,12 @@ static struct resource ab8500_usb_resources[] = { .end = AB8500_INT_VBUS_DET_R, .flags = IORESOURCE_IRQ, }, + { + .name = "USB_LINK_STATUS", + .start = AB8500_INT_USB_LINK_STATUS, + .end = AB8500_INT_USB_LINK_STATUS, + .flags = IORESOURCE_IRQ, + }, }; static struct resource ab8500_temp_resources[] = { @@ -670,8 +685,9 @@ int __devinit ab8500_init(struct ab8500 *ab8500) * 0x0 - Early Drop * 0x10 - Cut 1.0 * 0x11 - Cut 1.1 + * 0x20 - Cut 2.0 */ - if (value == 0x0 || value == 0x10 || value == 0x11) { + if (value == 0x0 || value == 0x10 || value == 0x11 || value == 0x20) { ab8500->revision = value; dev_info(ab8500->dev, "detected chip, revision: %#x\n", value); } else { @@ -684,18 +700,16 @@ int __devinit ab8500_init(struct ab8500 *ab8500) plat->init(ab8500); /* Clear and mask all interrupts */ - for (i = 0; i < 10; i++) { - get_register_interruptible(ab8500, AB8500_INTERRUPT, - AB8500_IT_LATCH1_REG + i, &value); - set_register_interruptible(ab8500, AB8500_INTERRUPT, - AB8500_IT_MASK1_REG + i, 0xff); - } + for (i = 0; i < AB8500_NUM_IRQ_REGS; i++) { + /* Interrupt register 12 does'nt exist prior to version 0x20 */ + if (ab8500_irq_regoffset[i] == 11 && ab8500->chip_id < 0x20) + continue; - for (i = 18; i < 24; i++) { get_register_interruptible(ab8500, AB8500_INTERRUPT, - AB8500_IT_LATCH1_REG + i, &value); + AB8500_IT_LATCH1_REG + ab8500_irq_regoffset[i], + &value); set_register_interruptible(ab8500, AB8500_INTERRUPT, - AB8500_IT_MASK1_REG + i, 0xff); + AB8500_IT_MASK1_REG + ab8500_irq_regoffset[i], 0xff); } ret = abx500_register_ops(ab8500->dev, &ab8500_ops); diff --git a/include/linux/mfd/ab8500.h b/include/linux/mfd/ab8500.h index 1ad16965523..37f56b7c4c1 100644 --- a/include/linux/mfd/ab8500.h +++ b/include/linux/mfd/ab8500.h @@ -74,30 +74,37 @@ #define AB8500_INT_ACC_DETECT_21DB_F 37 #define AB8500_INT_ACC_DETECT_21DB_R 38 #define AB8500_INT_GP_SW_ADC_CONV_END 39 -#define AB8500_INT_BTEMP_LOW 72 -#define AB8500_INT_BTEMP_LOW_MEDIUM 73 -#define AB8500_INT_BTEMP_MEDIUM_HIGH 74 -#define AB8500_INT_BTEMP_HIGH 75 -#define AB8500_INT_USB_CHARGER_NOT_OK 81 -#define AB8500_INT_ID_WAKEUP_R 82 -#define AB8500_INT_ID_DET_R1R 84 -#define AB8500_INT_ID_DET_R2R 85 -#define AB8500_INT_ID_DET_R3R 86 -#define AB8500_INT_ID_DET_R4R 87 -#define AB8500_INT_ID_WAKEUP_F 88 -#define AB8500_INT_ID_DET_R1F 90 -#define AB8500_INT_ID_DET_R2F 91 -#define AB8500_INT_ID_DET_R3F 92 -#define AB8500_INT_ID_DET_R4F 93 -#define AB8500_INT_USB_CHG_DET_DONE 94 -#define AB8500_INT_USB_CH_TH_PROT_F 96 -#define AB8500_INT_USB_CH_TH_PROT_R 97 -#define AB8500_INT_MAIN_CH_TH_PROT_F 98 -#define AB8500_INT_MAIN_CH_TH_PROT_R 99 -#define AB8500_INT_USB_CHARGER_NOT_OKF 103 +#define AB8500_INT_ADP_SOURCE_ERROR 72 +#define AB8500_INT_ADP_SINK_ERROR 73 +#define AB8500_INT_ADP_PROBE_PLUG 74 +#define AB8500_INT_ADP_PROBE_UNPLUG 75 +#define AB8500_INT_ADP_SENSE_OFF 76 +#define AB8500_INT_USB_PHY_POWER_ERR 78 +#define AB8500_INT_USB_LINK_STATUS 79 +#define AB8500_INT_BTEMP_LOW 80 +#define AB8500_INT_BTEMP_LOW_MEDIUM 81 +#define AB8500_INT_BTEMP_MEDIUM_HIGH 82 +#define AB8500_INT_BTEMP_HIGH 83 +#define AB8500_INT_USB_CHARGER_NOT_OK 89 +#define AB8500_INT_ID_WAKEUP_R 90 +#define AB8500_INT_ID_DET_R1R 92 +#define AB8500_INT_ID_DET_R2R 93 +#define AB8500_INT_ID_DET_R3R 94 +#define AB8500_INT_ID_DET_R4R 95 +#define AB8500_INT_ID_WAKEUP_F 96 +#define AB8500_INT_ID_DET_R1F 98 +#define AB8500_INT_ID_DET_R2F 99 +#define AB8500_INT_ID_DET_R3F 100 +#define AB8500_INT_ID_DET_R4F 101 +#define AB8500_INT_USB_CHG_DET_DONE 102 +#define AB8500_INT_USB_CH_TH_PROT_F 104 +#define AB8500_INT_USB_CH_TH_PROT_R 105 +#define AB8500_INT_MAIN_CH_TH_PROT_F 106 +#define AB8500_INT_MAIN_CH_TH_PROT_R 107 +#define AB8500_INT_USB_CHARGER_NOT_OKF 111 -#define AB8500_NR_IRQS 104 -#define AB8500_NUM_IRQ_REGS 13 +#define AB8500_NR_IRQS 112 +#define AB8500_NUM_IRQ_REGS 14 /** * struct ab8500 - ab8500 internal structure -- cgit v1.2.3-70-g09d2