Commit 48f286a2 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'for-next' of git://git.o-hand.com/linux-mfd

* 'for-next' of git://git.o-hand.com/linux-mfd:
  mfd: fix da903x warning
  mfd: fix MAINTAINERS entry
  mfd: Use the value of the final spin when reading the AUXADC
  mfd: Storage class should be before const qualifier
  mfd: PASIC3: supply clock_rate to DS1WM via driver_data
  mfd: remove DS1WM clock handling
  mfd: remove unused PASIC3 bus_shift field
  pxa/magician: remove deprecated .bus_shift from PASIC3 platform_data
  mfd: convert PASIC3 to use MFD core
  mfd: convert DS1WM to use MFD core
  mfd: Support active high IRQs on WM835x
  mfd: Use bulk read to fill WM8350 register cache
  mfd: remove duplicated #include from pcf50633
parents ea431793 fa15ce8a
...@@ -3051,8 +3051,9 @@ S: Maintained ...@@ -3051,8 +3051,9 @@ S: Maintained
MULTIFUNCTION DEVICES (MFD) MULTIFUNCTION DEVICES (MFD)
P: Samuel Ortiz P: Samuel Ortiz
M: sameo@openedhand.com M: sameo@linux.intel.com
L: linux-kernel@vger.kernel.org L: linux-kernel@vger.kernel.org
T: git kernel.org:/pub/scm/linux/kernel/git/sameo/mfd-2.6.git
S: Supported S: Supported
MULTIMEDIA CARD (MMC), SECURE DIGITAL (SD) AND SDIO SUBSYSTEM MULTIMEDIA CARD (MMC), SECURE DIGITAL (SD) AND SDIO SUBSYSTEM
......
...@@ -507,7 +507,6 @@ static struct resource pasic3_resources[] = { ...@@ -507,7 +507,6 @@ static struct resource pasic3_resources[] = {
}; };
static struct pasic3_platform_data pasic3_platform_data = { static struct pasic3_platform_data pasic3_platform_data = {
.bus_shift = 2,
.led_pdata = &pasic3_leds_info, .led_pdata = &pasic3_leds_info,
.clock_rate = 4000000, .clock_rate = 4000000,
}; };
......
...@@ -52,6 +52,7 @@ config HTC_EGPIO ...@@ -52,6 +52,7 @@ config HTC_EGPIO
config HTC_PASIC3 config HTC_PASIC3
tristate "HTC PASIC3 LED/DS1WM chip support" tristate "HTC PASIC3 LED/DS1WM chip support"
select MFD_CORE
help help
This core driver provides register access for the LED/DS1WM This core driver provides register access for the LED/DS1WM
chips labeled "AIC2" and "AIC3", found on HTC Blueangel and chips labeled "AIC2" and "AIC3", found on HTC Blueangel and
......
...@@ -413,7 +413,7 @@ static void da903x_irq_work(struct work_struct *work) ...@@ -413,7 +413,7 @@ static void da903x_irq_work(struct work_struct *work)
enable_irq(chip->client->irq); 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; struct da903x_chip *chip = data;
......
...@@ -12,18 +12,17 @@ ...@@ -12,18 +12,17 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/ds1wm.h>
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/irq.h> #include <linux/irq.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/mfd/core.h>
#include <linux/mfd/ds1wm.h>
#include <linux/mfd/htc-pasic3.h> #include <linux/mfd/htc-pasic3.h>
struct pasic3_data { struct pasic3_data {
void __iomem *mapping; void __iomem *mapping;
unsigned int bus_shift; unsigned int bus_shift;
struct platform_device *ds1wm_pdev;
struct platform_device *led_pdev;
}; };
#define REG_ADDR 5 #define REG_ADDR 5
...@@ -65,46 +64,15 @@ EXPORT_SYMBOL(pasic3_read_register); /* for leds-pasic3 */ ...@@ -65,46 +64,15 @@ EXPORT_SYMBOL(pasic3_read_register); /* for leds-pasic3 */
* LEDs * LEDs
*/ */
static int led_device_add(struct device *pasic3_dev, static struct mfd_cell led_cell __initdata = {
const struct pasic3_leds_machinfo *pdata) .name = "leds-pasic3",
{ };
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;
}
/* /*
* DS1WM * DS1WM
*/ */
static void ds1wm_enable(struct platform_device *pdev) static int ds1wm_enable(struct platform_device *pdev)
{ {
struct device *dev = pdev->dev.parent; struct device *dev = pdev->dev.parent;
int c; int c;
...@@ -113,9 +81,10 @@ static void ds1wm_enable(struct platform_device *pdev) ...@@ -113,9 +81,10 @@ static void ds1wm_enable(struct platform_device *pdev)
pasic3_write_register(dev, 0x28, c & 0x7f); pasic3_write_register(dev, 0x28, c & 0x7f);
dev_dbg(dev, "DS1WM OWM_EN low (active) %02x\n", 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; struct device *dev = pdev->dev.parent;
int c; int c;
...@@ -124,56 +93,33 @@ static void ds1wm_disable(struct platform_device *pdev) ...@@ -124,56 +93,33 @@ static void ds1wm_disable(struct platform_device *pdev)
pasic3_write_register(dev, 0x28, c | 0x80); pasic3_write_register(dev, 0x28, c | 0x80);
dev_dbg(dev, "DS1WM OWM_EN high (inactive) %02x\n", c | 0x80); dev_dbg(dev, "DS1WM OWM_EN high (inactive) %02x\n", c | 0x80);
return 0;
} }
static struct ds1wm_platform_data ds1wm_pdata = { static struct ds1wm_driver_data ds1wm_pdata = {
.bus_shift = 2, .active_high = 0,
.enable = ds1wm_enable,
.disable = ds1wm_disable,
}; };
static int ds1wm_device_add(struct platform_device *pasic3_pdev, int bus_shift) static struct resource ds1wm_resources[] __initdata = {
{ [0] = {
struct device *pasic3_dev = &pasic3_pdev->dev; .start = 0,
struct pasic3_data *asic = pasic3_dev->driver_data; .flags = IORESOURCE_MEM,
struct platform_device *pdev; },
int ret; [1] = {
.start = 0,
pdev = platform_device_alloc("ds1wm", -1); .end = 0,
if (!pdev) { .flags = IORESOURCE_IRQ,
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;
exit_pdev_put: static struct mfd_cell ds1wm_cell __initdata = {
platform_device_put(pdev); .name = "ds1wm",
return ret; .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) static int __init pasic3_probe(struct platform_device *pdev)
{ {
...@@ -182,12 +128,27 @@ 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 pasic3_data *asic;
struct resource *r; struct resource *r;
int ret; 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); r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!r) if (!r)
return -ENXIO; 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; return -EBUSY;
asic = kzalloc(sizeof(struct pasic3_data), GFP_KERNEL); asic = kzalloc(sizeof(struct pasic3_data), GFP_KERNEL);
...@@ -196,24 +157,33 @@ static int __init pasic3_probe(struct platform_device *pdev) ...@@ -196,24 +157,33 @@ static int __init pasic3_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, asic); platform_set_drvdata(pdev, asic);
if (pdata && pdata->bus_shift) asic->mapping = ioremap(r->start, resource_size(r));
asic->bus_shift = pdata->bus_shift;
else
asic->bus_shift = 2;
asic->mapping = ioremap(r->start, r->end - r->start + 1);
if (!asic->mapping) { if (!asic->mapping) {
dev_err(dev, "couldn't ioremap PASIC3\n"); dev_err(dev, "couldn't ioremap PASIC3\n");
kfree(asic); kfree(asic);
return -ENOMEM; return -ENOMEM;
} }
ret = ds1wm_device_add(pdev, asic->bus_shift); /* 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) if (ret < 0)
dev_warn(dev, "failed to register DS1WM\n"); dev_warn(dev, "failed to register DS1WM\n");
}
if (pdata->led_pdata) { if (pdata && pdata->led_pdata) {
ret = led_device_add(dev, pdata->led_pdata); led_cell.driver_data = pdata->led_pdata;
led_cell.platform_data = &led_cell;
led_cell.data_size = sizeof(ds1wm_cell);
ret = mfd_add_devices(&pdev->dev, pdev->id, &led_cell, 1, r, 0);
if (ret < 0) if (ret < 0)
dev_warn(dev, "failed to register LED device\n"); dev_warn(dev, "failed to register LED device\n");
} }
...@@ -226,14 +196,11 @@ static int pasic3_remove(struct platform_device *pdev) ...@@ -226,14 +196,11 @@ static int pasic3_remove(struct platform_device *pdev)
struct pasic3_data *asic = platform_get_drvdata(pdev); struct pasic3_data *asic = platform_get_drvdata(pdev);
struct resource *r; struct resource *r;
if (asic->led_pdev) mfd_remove_devices(&pdev->dev);
platform_device_unregister(asic->led_pdev);
if (asic->ds1wm_pdev)
platform_device_unregister(asic->ds1wm_pdev);
iounmap(asic->mapping); iounmap(asic->mapping);
r = platform_get_resource(pdev, IORESOURCE_MEM, 0); 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); kfree(asic);
return 0; return 0;
} }
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/sysfs.h> #include <linux/sysfs.h>
#include <linux/device.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
......
...@@ -108,7 +108,7 @@ static int t7l66xb_mmc_disable(struct platform_device *mmc) ...@@ -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, .start = 0x800,
.end = 0x9ff, .end = 0x9ff,
...@@ -126,7 +126,7 @@ const static struct resource t7l66xb_mmc_resources[] = { ...@@ -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, .start = 0xc00,
.end = 0xc07, .end = 0xc07,
......
...@@ -172,7 +172,7 @@ static struct resource __devinitdata tc6393xb_mmc_resources[] = { ...@@ -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, .start = 0x3000,
.end = 0x31ff, .end = 0x31ff,
......
...@@ -182,7 +182,7 @@ static int twl4030_irq_thread(void *data) ...@@ -182,7 +182,7 @@ static int twl4030_irq_thread(void *data)
long irq = (long)data; long irq = (long)data;
struct irq_desc *desc = irq_to_desc(irq); struct irq_desc *desc = irq_to_desc(irq);
static unsigned i2c_errors; static unsigned i2c_errors;
const static unsigned max_i2c_errors = 100; static const unsigned max_i2c_errors = 100;
if (!desc) { if (!desc) {
pr_err("twl4030: Invalid IRQ: %ld\n", irq); pr_err("twl4030: Invalid IRQ: %ld\n", irq);
......
...@@ -1111,7 +1111,7 @@ int wm8350_read_auxadc(struct wm8350 *wm8350, int channel, int scale, int vref) ...@@ -1111,7 +1111,7 @@ int wm8350_read_auxadc(struct wm8350 *wm8350, int channel, int scale, int vref)
do { do {
schedule_timeout_interruptible(1); schedule_timeout_interruptible(1);
reg = wm8350_reg_read(wm8350, WM8350_DIGITISER_CONTROL_1); reg = wm8350_reg_read(wm8350, WM8350_DIGITISER_CONTROL_1);
} while (--tries && (reg & WM8350_AUXADC_POLL)); } while ((reg & WM8350_AUXADC_POLL) && --tries);
if (!tries) if (!tries)
dev_err(wm8350->dev, "adc chn %d read timeout\n", channel); 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) ...@@ -1238,7 +1238,7 @@ static int wm8350_create_cache(struct wm8350 *wm8350, int type, int mode)
} }
wm8350->reg_cache = 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) if (wm8350->reg_cache == NULL)
return -ENOMEM; return -ENOMEM;
...@@ -1246,17 +1246,20 @@ static int wm8350_create_cache(struct wm8350 *wm8350, int type, int mode) ...@@ -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 * a PMIC so the device many not be in a virgin state and we
* can't rely on the silicon values. * can't rely on the silicon values.
*/ */
for (i = 0; i < WM8350_MAX_REGISTER; i++) { ret = wm8350->read_dev(wm8350, 0,
/* audio register range */ sizeof(u16) * (WM8350_MAX_REGISTER + 1),
if (wm8350_reg_io_map[i].readable && wm8350->reg_cache);
(i < WM8350_CLOCK_CONTROL_1 || i > WM8350_AIF_TEST)) {
ret = wm8350->read_dev(wm8350, i, 2, (char *)&value);
if (ret < 0) { if (ret < 0) {
dev_err(wm8350->dev, dev_err(wm8350->dev,
"failed to read initial cache value\n"); "failed to read initial cache values\n");
goto out; goto out;
} }
value = be16_to_cpu(value);
/* Mask out uncacheable/unreadable bits and the audio. */
for (i = 0; i < WM8350_MAX_REGISTER; i++) {
if (wm8350_reg_io_map[i].readable &&
(i < WM8350_CLOCK_CONTROL_1 || i > WM8350_AIF_TEST)) {
value = be16_to_cpu(wm8350->reg_cache[i]);
value &= wm8350_reg_io_map[i].readable; value &= wm8350_reg_io_map[i].readable;
value &= ~wm8350_reg_io_map[i].vol; value &= ~wm8350_reg_io_map[i].vol;
wm8350->reg_cache[i] = value; wm8350->reg_cache[i] = value;
...@@ -1435,7 +1438,21 @@ int wm8350_device_init(struct wm8350 *wm8350, int irq, ...@@ -1435,7 +1438,21 @@ int wm8350_device_init(struct wm8350 *wm8350, int irq,
mutex_init(&wm8350->irq_mutex); mutex_init(&wm8350->irq_mutex);
INIT_WORK(&wm8350->irq_work, wm8350_irq_worker); INIT_WORK(&wm8350->irq_work, wm8350_irq_worker);
if (irq) { 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); "wm8350", wm8350);
if (ret != 0) { if (ret != 0) {
dev_err(wm8350->dev, "Failed to request IRQ: %d\n", dev_err(wm8350->dev, "Failed to request IRQ: %d\n",
......
...@@ -16,10 +16,10 @@ ...@@ -16,10 +16,10 @@
#include <linux/irq.h> #include <linux/irq.h>
#include <linux/pm.h> #include <linux/pm.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/clk.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/ds1wm.h> #include <linux/mfd/core.h>
#include <linux/mfd/ds1wm.h>
#include <asm/io.h> #include <asm/io.h>
...@@ -89,10 +89,9 @@ struct ds1wm_data { ...@@ -89,10 +89,9 @@ struct ds1wm_data {
void __iomem *map; void __iomem *map;
int bus_shift; /* # of shifts to calc register offsets */ int bus_shift; /* # of shifts to calc register offsets */
struct platform_device *pdev; struct platform_device *pdev;
struct ds1wm_platform_data *pdata; struct mfd_cell *cell;
int irq; int irq;
int active_high; int active_high;
struct clk *clk;
int slave_present; int slave_present;
void *reset_complete; void *reset_complete;
void *read_complete; void *read_complete;
...@@ -215,17 +214,17 @@ static int ds1wm_find_divisor(int gclk) ...@@ -215,17 +214,17 @@ static int ds1wm_find_divisor(int gclk)
static void ds1wm_up(struct ds1wm_data *ds1wm_data) static void ds1wm_up(struct ds1wm_data *ds1wm_data)
{ {
int gclk, divisor; int divisor;
struct ds1wm_driver_data *plat = ds1wm_data->cell->driver_data;
if (ds1wm_data->pdata->enable) if (ds1wm_data->cell->enable)
ds1wm_data->pdata->enable(ds1wm_data->pdev); ds1wm_data->cell->enable(ds1wm_data->pdev);
gclk = clk_get_rate(ds1wm_data->clk); divisor = ds1wm_find_divisor(plat->clock_rate);
clk_enable(ds1wm_data->clk);
divisor = ds1wm_find_divisor(gclk);
if (divisor == 0) { if (divisor == 0) {
dev_err(&ds1wm_data->pdev->dev, dev_err(&ds1wm_data->pdev->dev,
"no suitable divisor for %dHz clock\n", gclk); "no suitable divisor for %dHz clock\n",
plat->clock_rate);
return; return;
} }
ds1wm_write_register(ds1wm_data, DS1WM_CLKDIV, divisor); ds1wm_write_register(ds1wm_data, DS1WM_CLKDIV, divisor);
...@@ -244,10 +243,8 @@ static void ds1wm_down(struct ds1wm_data *ds1wm_data) ...@@ -244,10 +243,8 @@ static void ds1wm_down(struct ds1wm_data *ds1wm_data)
ds1wm_write_register(ds1wm_data, DS1WM_INT_EN, ds1wm_write_register(ds1wm_data, DS1WM_INT_EN,
ds1wm_data->active_high ? DS1WM_INTEN_IAS : 0); ds1wm_data->active_high ? DS1WM_INTEN_IAS : 0);
if (ds1wm_data->pdata->disable) if (ds1wm_data->cell->disable)
ds1wm_data->pdata->disable(ds1wm_data->pdev); ds1wm_data->cell->disable(ds1wm_data->pdev);
clk_disable(ds1wm_data->clk);
} }
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
...@@ -330,13 +327,18 @@ static struct w1_bus_master ds1wm_master = { ...@@ -330,13 +327,18 @@ static struct w1_bus_master ds1wm_master = {
static int ds1wm_probe(struct platform_device *pdev) static int ds1wm_probe(struct platform_device *pdev)
{ {
struct ds1wm_data *ds1wm_data; struct ds1wm_data *ds1wm_data;
struct ds1wm_platform_data *plat; struct ds1wm_driver_data *plat;
struct resource *res; struct resource *res;
struct mfd_cell *cell;
int ret; int ret;
if (!pdev) if (!pdev)
return -ENODEV; return -ENODEV;
cell = pdev->dev.platform_data;
if (!cell)
return -ENODEV;
ds1wm_data = kzalloc(sizeof(*ds1wm_data), GFP_KERNEL); ds1wm_data = kzalloc(sizeof(*ds1wm_data), GFP_KERNEL);
if (!ds1wm_data) if (!ds1wm_data)
return -ENOMEM; return -ENOMEM;
...@@ -348,15 +350,18 @@ static int ds1wm_probe(struct platform_device *pdev) ...@@ -348,15 +350,18 @@ static int ds1wm_probe(struct platform_device *pdev)
ret = -ENXIO; ret = -ENXIO;
goto err0; goto err0;
} }
ds1wm_data->map = ioremap(res->start, res->end - res->start + 1); ds1wm_data->map = ioremap(res->start, resource_size(res));
if (!ds1wm_data->map) { if (!ds1wm_data->map) {
ret = -ENOMEM; ret = -ENOMEM;
goto err0; goto err0;
} }
plat = pdev->dev.platform_data; plat = cell->driver_data;
ds1wm_data->bus_shift = plat->bus_shift;
/* calculate bus shift from mem resource */
ds1wm_data->bus_shift = resource_size(res) >> 3;
ds1wm_data->pdev = pdev; ds1wm_data->pdev = pdev;
ds1wm_data->pdata = plat; ds1wm_data->cell = cell;
res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
if (!res) { if (!res) {
...@@ -376,26 +381,18 @@ static int ds1wm_probe(struct platform_device *pdev) ...@@ -376,26 +381,18 @@ static int ds1wm_probe(struct platform_device *pdev)
if (ret) if (ret)
goto err1; goto err1;
ds1wm_data->clk = clk_get(&pdev->dev, "ds1wm");
if (IS_ERR(ds1wm_data->clk)) {
ret = PTR_ERR(ds1wm_data->clk);
goto err2;
}
ds1wm_up(ds1wm_data); ds1wm_up(ds1wm_data);
ds1wm_master.data = (void *)ds1wm_data; ds1wm_master.data = (void *)ds1wm_data;
ret = w1_add_master_device(&ds1wm_master); ret = w1_add_master_device(&ds1wm_master);
if (ret) if (ret)
goto err3; goto err2;
return 0; return 0;
err3:
ds1wm_down(ds1wm_data);
clk_put(ds1wm_data->clk);
err2: err2:
ds1wm_down(ds1wm_data);
free_irq(ds1wm_data->irq, ds1wm_data); free_irq(ds1wm_data->irq, ds1wm_data);
err1: err1:
iounmap(ds1wm_data->map); iounmap(ds1wm_data->map);
...@@ -434,7 +431,6 @@ static int ds1wm_remove(struct platform_device *pdev) ...@@ -434,7 +431,6 @@ static int ds1wm_remove(struct platform_device *pdev)
w1_remove_master_device(&ds1wm_master); w1_remove_master_device(&ds1wm_master);
ds1wm_down(ds1wm_data); ds1wm_down(ds1wm_data);
clk_put(ds1wm_data->clk);
free_irq(ds1wm_data->irq, ds1wm_data); free_irq(ds1wm_data->irq, ds1wm_data);
iounmap(ds1wm_data->map); iounmap(ds1wm_data->map);
kfree(ds1wm_data); kfree(ds1wm_data);
......
/* platform data for the DS1WM driver */
struct ds1wm_platform_data {
int bus_shift; /* number of shifts needed to calculate the
* offset between DS1WM registers;
* e.g. on h5xxx and h2200 this is 2
* (registers aligned to 4-byte boundaries),
* while on hx4700 this is 1 */
int active_high;
void (*enable)(struct platform_device *pdev);
void (*disable)(struct platform_device *pdev);
};
/* MFD cell driver data for the DS1WM driver */
struct ds1wm_driver_data {
int active_high;
int clock_rate;
};
...@@ -48,7 +48,6 @@ struct pasic3_leds_machinfo { ...@@ -48,7 +48,6 @@ struct pasic3_leds_machinfo {
struct pasic3_platform_data { struct pasic3_platform_data {
struct pasic3_leds_machinfo *led_pdata; struct pasic3_leds_machinfo *led_pdata;
unsigned int bus_shift;
unsigned int clock_rate; unsigned int clock_rate;
}; };
......
...@@ -640,9 +640,11 @@ struct wm8350 { ...@@ -640,9 +640,11 @@ struct wm8350 {
* *
* @init: Function called during driver initialisation. Should be * @init: Function called during driver initialisation. Should be
* used by the platform to configure GPIO functions and similar. * used by the platform to configure GPIO functions and similar.
* @irq_high: Set if WM8350 IRQ is active high.
*/ */
struct wm8350_platform_data { struct wm8350_platform_data {
int (*init)(struct wm8350 *wm8350); int (*init)(struct wm8350 *wm8350);
int irq_high;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment