diff options
Diffstat (limited to 'drivers/mfd')
-rw-r--r-- | drivers/mfd/Kconfig | 3 | ||||
-rw-r--r-- | drivers/mfd/da903x.c | 2 | ||||
-rw-r--r-- | drivers/mfd/htc-pasic3.c | 169 | ||||
-rw-r--r-- | drivers/mfd/mcp-core.c | 2 | ||||
-rw-r--r-- | drivers/mfd/pcf50633-core.c | 1 | ||||
-rw-r--r-- | drivers/mfd/t7l66xb.c | 4 | ||||
-rw-r--r-- | drivers/mfd/tc6393xb.c | 2 | ||||
-rw-r--r-- | drivers/mfd/twl4030-core.c | 2 | ||||
-rw-r--r-- | drivers/mfd/twl4030-irq.c | 2 | ||||
-rw-r--r-- | drivers/mfd/ucb1x00-core.c | 2 | ||||
-rw-r--r-- | drivers/mfd/wm8350-core.c | 44 |
11 files changed, 110 insertions, 123 deletions
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index 06a2b0f7737c..ee3927ab11e0 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -52,6 +52,7 @@ config HTC_EGPIO config HTC_PASIC3 tristate "HTC PASIC3 LED/DS1WM chip support" + select MFD_CORE help This core driver provides register access for the LED/DS1WM chips labeled "AIC2" and "AIC3", found on HTC Blueangel and @@ -88,7 +89,7 @@ config MENELAUS help If you say yes here you get support for the Texas Instruments TWL92330/Menelaus Power Management chip. This include voltage - regulators, Dual slot memory card tranceivers, real-time clock + regulators, Dual slot memory card transceivers, real-time clock and other features that are often used in portable devices like cell phones and PDAs. diff --git a/drivers/mfd/da903x.c b/drivers/mfd/da903x.c index 99f8dcfe3d98..7283d88656af 100644 --- a/drivers/mfd/da903x.c +++ b/drivers/mfd/da903x.c @@ -413,7 +413,7 @@ static void da903x_irq_work(struct work_struct *work) enable_irq(chip->client->irq); } -static int da903x_irq_handler(int irq, void *data) +static irqreturn_t da903x_irq_handler(int irq, void *data) { struct da903x_chip *chip = data; diff --git a/drivers/mfd/htc-pasic3.c b/drivers/mfd/htc-pasic3.c index 91b294dcc133..386da1566fcc 100644 --- a/drivers/mfd/htc-pasic3.c +++ b/drivers/mfd/htc-pasic3.c @@ -12,18 +12,17 @@ #include <linux/module.h> #include <linux/platform_device.h> -#include <linux/ds1wm.h> #include <linux/gpio.h> #include <linux/io.h> #include <linux/irq.h> #include <linux/interrupt.h> +#include <linux/mfd/core.h> +#include <linux/mfd/ds1wm.h> #include <linux/mfd/htc-pasic3.h> struct pasic3_data { void __iomem *mapping; unsigned int bus_shift; - struct platform_device *ds1wm_pdev; - struct platform_device *led_pdev; }; #define REG_ADDR 5 @@ -65,46 +64,15 @@ EXPORT_SYMBOL(pasic3_read_register); /* for leds-pasic3 */ * LEDs */ -static int led_device_add(struct device *pasic3_dev, - const struct pasic3_leds_machinfo *pdata) -{ - struct pasic3_data *asic = pasic3_dev->driver_data; - struct platform_device *pdev; - int ret; - - pdev = platform_device_alloc("pasic3-led", -1); - if (!pdev) { - dev_dbg(pasic3_dev, "failed to allocate LED platform device\n"); - return -ENOMEM; - } - - ret = platform_device_add_data(pdev, pdata, - sizeof(struct pasic3_leds_machinfo)); - if (ret < 0) { - dev_dbg(pasic3_dev, "failed to add LED platform data\n"); - goto exit_pdev_put; - } - - pdev->dev.parent = pasic3_dev; - ret = platform_device_add(pdev); - if (ret < 0) { - dev_dbg(pasic3_dev, "failed to add LED platform device\n"); - goto exit_pdev_put; - } - - asic->led_pdev = pdev; - return 0; - -exit_pdev_put: - platform_device_put(pdev); - return ret; -} +static struct mfd_cell led_cell __initdata = { + .name = "leds-pasic3", +}; /* * DS1WM */ -static void ds1wm_enable(struct platform_device *pdev) +static int ds1wm_enable(struct platform_device *pdev) { struct device *dev = pdev->dev.parent; int c; @@ -113,9 +81,10 @@ static void ds1wm_enable(struct platform_device *pdev) pasic3_write_register(dev, 0x28, c & 0x7f); dev_dbg(dev, "DS1WM OWM_EN low (active) %02x\n", c & 0x7f); + return 0; } -static void ds1wm_disable(struct platform_device *pdev) +static int ds1wm_disable(struct platform_device *pdev) { struct device *dev = pdev->dev.parent; int c; @@ -124,56 +93,33 @@ static void ds1wm_disable(struct platform_device *pdev) pasic3_write_register(dev, 0x28, c | 0x80); dev_dbg(dev, "DS1WM OWM_EN high (inactive) %02x\n", c | 0x80); + return 0; } -static struct ds1wm_platform_data ds1wm_pdata = { - .bus_shift = 2, - .enable = ds1wm_enable, - .disable = ds1wm_disable, +static struct ds1wm_driver_data ds1wm_pdata = { + .active_high = 0, }; -static int ds1wm_device_add(struct platform_device *pasic3_pdev, int bus_shift) -{ - struct device *pasic3_dev = &pasic3_pdev->dev; - struct pasic3_data *asic = pasic3_dev->driver_data; - struct platform_device *pdev; - int ret; - - pdev = platform_device_alloc("ds1wm", -1); - if (!pdev) { - dev_dbg(pasic3_dev, "failed to allocate DS1WM platform device\n"); - return -ENOMEM; - } - - ret = platform_device_add_resources(pdev, pasic3_pdev->resource, - pasic3_pdev->num_resources); - if (ret < 0) { - dev_dbg(pasic3_dev, "failed to add DS1WM resources\n"); - goto exit_pdev_put; - } - - ds1wm_pdata.bus_shift = asic->bus_shift; - ret = platform_device_add_data(pdev, &ds1wm_pdata, - sizeof(struct ds1wm_platform_data)); - if (ret < 0) { - dev_dbg(pasic3_dev, "failed to add DS1WM platform data\n"); - goto exit_pdev_put; - } - - pdev->dev.parent = pasic3_dev; - ret = platform_device_add(pdev); - if (ret < 0) { - dev_dbg(pasic3_dev, "failed to add DS1WM platform device\n"); - goto exit_pdev_put; - } - - asic->ds1wm_pdev = pdev; - return 0; +static struct resource ds1wm_resources[] __initdata = { + [0] = { + .start = 0, + .flags = IORESOURCE_MEM, + }, + [1] = { + .start = 0, + .end = 0, + .flags = IORESOURCE_IRQ, + }, +}; -exit_pdev_put: - platform_device_put(pdev); - return ret; -} +static struct mfd_cell ds1wm_cell __initdata = { + .name = "ds1wm", + .enable = ds1wm_enable, + .disable = ds1wm_disable, + .driver_data = &ds1wm_pdata, + .num_resources = 2, + .resources = ds1wm_resources, +}; static int __init pasic3_probe(struct platform_device *pdev) { @@ -182,12 +128,27 @@ static int __init pasic3_probe(struct platform_device *pdev) struct pasic3_data *asic; struct resource *r; int ret; + int irq = 0; + + r = platform_get_resource(pdev, IORESOURCE_IRQ, 0); + if (r) { + ds1wm_resources[1].flags = IORESOURCE_IRQ | (r->flags & + (IORESOURCE_IRQ_HIGHEDGE | IORESOURCE_IRQ_LOWEDGE)); + irq = r->start; + } + + r = platform_get_resource(pdev, IORESOURCE_IRQ, 0); + if (r) { + ds1wm_resources[1].flags = IORESOURCE_IRQ | (r->flags & + (IORESOURCE_IRQ_HIGHEDGE | IORESOURCE_IRQ_LOWEDGE)); + irq = r->start; + } r = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!r) return -ENXIO; - if (!request_mem_region(r->start, r->end - r->start + 1, "pasic3")) + if (!request_mem_region(r->start, resource_size(r), "pasic3")) return -EBUSY; asic = kzalloc(sizeof(struct pasic3_data), GFP_KERNEL); @@ -196,24 +157,33 @@ static int __init pasic3_probe(struct platform_device *pdev) platform_set_drvdata(pdev, asic); - if (pdata && pdata->bus_shift) - asic->bus_shift = pdata->bus_shift; - else - asic->bus_shift = 2; - - asic->mapping = ioremap(r->start, r->end - r->start + 1); + asic->mapping = ioremap(r->start, resource_size(r)); if (!asic->mapping) { dev_err(dev, "couldn't ioremap PASIC3\n"); kfree(asic); return -ENOMEM; } - ret = ds1wm_device_add(pdev, asic->bus_shift); - if (ret < 0) - dev_warn(dev, "failed to register DS1WM\n"); + /* calculate bus shift from mem resource */ + asic->bus_shift = (resource_size(r) - 5) >> 3; + + if (pdata && pdata->clock_rate) { + ds1wm_pdata.clock_rate = pdata->clock_rate; + /* the first 5 PASIC3 registers control the DS1WM */ + ds1wm_resources[0].end = (5 << asic->bus_shift) - 1; + ds1wm_cell.platform_data = &ds1wm_cell; + ds1wm_cell.data_size = sizeof(ds1wm_cell); + ret = mfd_add_devices(&pdev->dev, pdev->id, + &ds1wm_cell, 1, r, irq); + if (ret < 0) + dev_warn(dev, "failed to register DS1WM\n"); + } - if (pdata->led_pdata) { - ret = led_device_add(dev, pdata->led_pdata); + if (pdata && pdata->led_pdata) { + led_cell.driver_data = pdata->led_pdata; + led_cell.platform_data = &led_cell; + led_cell.data_size = sizeof(ds1wm_cell); + ret = mfd_add_devices(&pdev->dev, pdev->id, &led_cell, 1, r, 0); if (ret < 0) dev_warn(dev, "failed to register LED device\n"); } @@ -226,14 +196,11 @@ static int pasic3_remove(struct platform_device *pdev) struct pasic3_data *asic = platform_get_drvdata(pdev); struct resource *r; - if (asic->led_pdev) - platform_device_unregister(asic->led_pdev); - if (asic->ds1wm_pdev) - platform_device_unregister(asic->ds1wm_pdev); + mfd_remove_devices(&pdev->dev); iounmap(asic->mapping); r = platform_get_resource(pdev, IORESOURCE_MEM, 0); - release_mem_region(r->start, r->end - r->start + 1); + release_mem_region(r->start, resource_size(r)); kfree(asic); return 0; } diff --git a/drivers/mfd/mcp-core.c b/drivers/mfd/mcp-core.c index 6063dc2b52e8..57271cb3b316 100644 --- a/drivers/mfd/mcp-core.c +++ b/drivers/mfd/mcp-core.c @@ -214,7 +214,7 @@ EXPORT_SYMBOL(mcp_host_alloc); int mcp_host_register(struct mcp *mcp) { - strcpy(mcp->attached_device.bus_id, "mcp0"); + dev_set_name(&mcp->attached_device, "mcp0"); return device_register(&mcp->attached_device); } EXPORT_SYMBOL(mcp_host_register); diff --git a/drivers/mfd/pcf50633-core.c b/drivers/mfd/pcf50633-core.c index 2e36057659e1..7793932a513b 100644 --- a/drivers/mfd/pcf50633-core.c +++ b/drivers/mfd/pcf50633-core.c @@ -15,7 +15,6 @@ #include <linux/kernel.h> #include <linux/device.h> #include <linux/sysfs.h> -#include <linux/device.h> #include <linux/module.h> #include <linux/types.h> #include <linux/interrupt.h> diff --git a/drivers/mfd/t7l66xb.c b/drivers/mfd/t7l66xb.c index 9f7024c0f8ec..e9f4323dd2cb 100644 --- a/drivers/mfd/t7l66xb.c +++ b/drivers/mfd/t7l66xb.c @@ -108,7 +108,7 @@ static int t7l66xb_mmc_disable(struct platform_device *mmc) /*--------------------------------------------------------------------------*/ -const static struct resource t7l66xb_mmc_resources[] = { +static const struct resource t7l66xb_mmc_resources[] = { { .start = 0x800, .end = 0x9ff, @@ -126,7 +126,7 @@ const static struct resource t7l66xb_mmc_resources[] = { }, }; -const static struct resource t7l66xb_nand_resources[] = { +static const struct resource t7l66xb_nand_resources[] = { { .start = 0xc00, .end = 0xc07, diff --git a/drivers/mfd/tc6393xb.c b/drivers/mfd/tc6393xb.c index f856e9463a9f..77a12fc8045e 100644 --- a/drivers/mfd/tc6393xb.c +++ b/drivers/mfd/tc6393xb.c @@ -172,7 +172,7 @@ static struct resource __devinitdata tc6393xb_mmc_resources[] = { }, }; -const static struct resource tc6393xb_ohci_resources[] = { +static const struct resource tc6393xb_ohci_resources[] = { { .start = 0x3000, .end = 0x31ff, diff --git a/drivers/mfd/twl4030-core.c b/drivers/mfd/twl4030-core.c index 68826f1e36bc..ec90e953adce 100644 --- a/drivers/mfd/twl4030-core.c +++ b/drivers/mfd/twl4030-core.c @@ -592,11 +592,9 @@ add_children(struct twl4030_platform_data *pdata, unsigned long features) /* maybe add LDOs that are omitted on cost-reduced parts */ if (twl_has_regulator() && !(features & TPS_SUBSET)) { - /* child = add_regulator(TWL4030_REG_VPLL2, pdata->vpll2); if (IS_ERR(child)) return PTR_ERR(child); - */ child = add_regulator(TWL4030_REG_VMMC2, pdata->vmmc2); if (IS_ERR(child)) diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c index b10876036983..aca2670afd78 100644 --- a/drivers/mfd/twl4030-irq.c +++ b/drivers/mfd/twl4030-irq.c @@ -182,7 +182,7 @@ static int twl4030_irq_thread(void *data) long irq = (long)data; struct irq_desc *desc = irq_to_desc(irq); static unsigned i2c_errors; - const static unsigned max_i2c_errors = 100; + static const unsigned max_i2c_errors = 100; if (!desc) { pr_err("twl4030: Invalid IRQ: %ld\n", irq); diff --git a/drivers/mfd/ucb1x00-core.c b/drivers/mfd/ucb1x00-core.c index 6860c924f364..fea9085fe52c 100644 --- a/drivers/mfd/ucb1x00-core.c +++ b/drivers/mfd/ucb1x00-core.c @@ -492,7 +492,7 @@ static int ucb1x00_probe(struct mcp *mcp) ucb->dev.class = &ucb1x00_class; ucb->dev.parent = &mcp->attached_device; - strlcpy(ucb->dev.bus_id, "ucb1x00", sizeof(ucb->dev.bus_id)); + dev_set_name(&ucb->dev, "ucb1x00"); spin_lock_init(&ucb->lock); spin_lock_init(&ucb->io_lock); diff --git a/drivers/mfd/wm8350-core.c b/drivers/mfd/wm8350-core.c index 84d5ea1ec171..c2be3088e2e1 100644 --- a/drivers/mfd/wm8350-core.c +++ b/drivers/mfd/wm8350-core.c @@ -1111,7 +1111,7 @@ int wm8350_read_auxadc(struct wm8350 *wm8350, int channel, int scale, int vref) do { schedule_timeout_interruptible(1); reg = wm8350_reg_read(wm8350, WM8350_DIGITISER_CONTROL_1); - } while (--tries && (reg & WM8350_AUXADC_POLL)); + } while ((reg & WM8350_AUXADC_POLL) && --tries); if (!tries) dev_err(wm8350->dev, "adc chn %d read timeout\n", channel); @@ -1238,7 +1238,7 @@ static int wm8350_create_cache(struct wm8350 *wm8350, int type, int mode) } wm8350->reg_cache = - kzalloc(sizeof(u16) * (WM8350_MAX_REGISTER + 1), GFP_KERNEL); + kmalloc(sizeof(u16) * (WM8350_MAX_REGISTER + 1), GFP_KERNEL); if (wm8350->reg_cache == NULL) return -ENOMEM; @@ -1246,17 +1246,20 @@ static int wm8350_create_cache(struct wm8350 *wm8350, int type, int mode) * a PMIC so the device many not be in a virgin state and we * can't rely on the silicon values. */ + ret = wm8350->read_dev(wm8350, 0, + sizeof(u16) * (WM8350_MAX_REGISTER + 1), + wm8350->reg_cache); + if (ret < 0) { + dev_err(wm8350->dev, + "failed to read initial cache values\n"); + goto out; + } + + /* Mask out uncacheable/unreadable bits and the audio. */ for (i = 0; i < WM8350_MAX_REGISTER; i++) { - /* audio register range */ if (wm8350_reg_io_map[i].readable && (i < WM8350_CLOCK_CONTROL_1 || i > WM8350_AIF_TEST)) { - ret = wm8350->read_dev(wm8350, i, 2, (char *)&value); - if (ret < 0) { - dev_err(wm8350->dev, - "failed to read initial cache value\n"); - goto out; - } - value = be16_to_cpu(value); + value = be16_to_cpu(wm8350->reg_cache[i]); value &= wm8350_reg_io_map[i].readable; value &= ~wm8350_reg_io_map[i].vol; wm8350->reg_cache[i] = value; @@ -1383,6 +1386,11 @@ int wm8350_device_init(struct wm8350 *wm8350, int irq, wm8350->power.rev_g_coeff = 1; break; + case 1: + dev_info(wm8350->dev, "WM8351 Rev B\n"); + wm8350->power.rev_g_coeff = 1; + break; + default: dev_err(wm8350->dev, "Unknown WM8351 CHIP_REV\n"); ret = -ENODEV; @@ -1430,7 +1438,21 @@ int wm8350_device_init(struct wm8350 *wm8350, int irq, mutex_init(&wm8350->irq_mutex); INIT_WORK(&wm8350->irq_work, wm8350_irq_worker); if (irq) { - ret = request_irq(irq, wm8350_irq, 0, + int flags = 0; + + if (pdata && pdata->irq_high) { + flags |= IRQF_TRIGGER_HIGH; + + wm8350_set_bits(wm8350, WM8350_SYSTEM_CONTROL_1, + WM8350_IRQ_POL); + } else { + flags |= IRQF_TRIGGER_LOW; + + wm8350_clear_bits(wm8350, WM8350_SYSTEM_CONTROL_1, + WM8350_IRQ_POL); + } + + ret = request_irq(irq, wm8350_irq, flags, "wm8350", wm8350); if (ret != 0) { dev_err(wm8350->dev, "Failed to request IRQ: %d\n", |