~ubuntu-branches/debian/wheezy/linux-2.6/wheezy

« back to all changes in this revision

Viewing changes to drivers/mfd/t7l66xb.c

  • Committer: Bazaar Package Importer
  • Author(s): Ben Hutchings, Ben Hutchings, Aurelien Jarno, Martin Michlmayr
  • Date: 2011-04-06 13:53:30 UTC
  • mfrom: (43.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20110406135330-wjufxhd0tvn3zx4z
Tags: 2.6.38-3
[ Ben Hutchings ]
* [ppc64] Add to linux-tools package architectures (Closes: #620124)
* [amd64] Save cr4 to mmu_cr4_features at boot time (Closes: #620284)
* appletalk: Fix bugs introduced when removing use of BKL
* ALSA: Fix yet another race in disconnection
* cciss: Fix lost command issue
* ath9k: Fix kernel panic in AR2427
* ses: Avoid kernel panic when lun 0 is not mapped
* PCI/ACPI: Report ASPM support to BIOS if not disabled from command line

[ Aurelien Jarno ]
* rtlwifi: fix build when PCI is not enabled.

[ Martin Michlmayr ]
* rtlwifi: Eliminate udelay calls with too large values (Closes: #620204)

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
#include <linux/module.h>
27
27
#include <linux/err.h>
28
28
#include <linux/io.h>
 
29
#include <linux/slab.h>
29
30
#include <linux/irq.h>
30
31
#include <linux/clk.h>
31
32
#include <linux/platform_device.h>
38
39
        T7L66XB_CELL_MMC,
39
40
};
40
41
 
 
42
static const struct resource t7l66xb_mmc_resources[] = {
 
43
        {
 
44
                .start = 0x800,
 
45
                .end    = 0x9ff,
 
46
                .flags = IORESOURCE_MEM,
 
47
        },
 
48
        {
 
49
                .start = IRQ_T7L66XB_MMC,
 
50
                .end    = IRQ_T7L66XB_MMC,
 
51
                .flags = IORESOURCE_IRQ,
 
52
        },
 
53
};
 
54
 
41
55
#define SCR_REVID       0x08            /* b Revision ID        */
42
56
#define SCR_IMR         0x42            /* b Interrupt Mask     */
43
57
#define SCR_DEV_CTL     0xe0            /* b Device control     */
83
97
 
84
98
        spin_unlock_irqrestore(&t7l66xb->lock, flags);
85
99
 
 
100
        tmio_core_mmc_enable(t7l66xb->scr + 0x200, 0,
 
101
                t7l66xb_mmc_resources[0].start & 0xfffe);
 
102
 
86
103
        return 0;
87
104
}
88
105
 
106
123
        return 0;
107
124
}
108
125
 
 
126
static void t7l66xb_mmc_pwr(struct platform_device *mmc, int state)
 
127
{
 
128
        struct platform_device *dev = to_platform_device(mmc->dev.parent);
 
129
        struct t7l66xb *t7l66xb = platform_get_drvdata(dev);
 
130
 
 
131
        tmio_core_mmc_pwr(t7l66xb->scr + 0x200, 0, state);
 
132
}
 
133
 
 
134
static void t7l66xb_mmc_clk_div(struct platform_device *mmc, int state)
 
135
{
 
136
        struct platform_device *dev = to_platform_device(mmc->dev.parent);
 
137
        struct t7l66xb *t7l66xb = platform_get_drvdata(dev);
 
138
 
 
139
        tmio_core_mmc_clk_div(t7l66xb->scr + 0x200, 0, state);
 
140
}
 
141
 
109
142
/*--------------------------------------------------------------------------*/
110
143
 
111
144
static struct tmio_mmc_data t7166xb_mmc_data = {
112
145
        .hclk = 24000000,
113
 
};
114
 
 
115
 
static const struct resource t7l66xb_mmc_resources[] = {
116
 
        {
117
 
                .start = 0x800,
118
 
                .end    = 0x9ff,
119
 
                .flags = IORESOURCE_MEM,
120
 
        },
121
 
        {
122
 
                .start = 0x200,
123
 
                .end    = 0x2ff,
124
 
                .flags = IORESOURCE_MEM,
125
 
        },
126
 
        {
127
 
                .start = IRQ_T7L66XB_MMC,
128
 
                .end    = IRQ_T7L66XB_MMC,
129
 
                .flags = IORESOURCE_IRQ,
130
 
        },
 
146
        .set_pwr = t7l66xb_mmc_pwr,
 
147
        .set_clk_div = t7l66xb_mmc_clk_div,
131
148
};
132
149
 
133
150
static const struct resource t7l66xb_nand_resources[] = {
182
199
                                generic_handle_irq(irq_base + i);
183
200
}
184
201
 
185
 
static void t7l66xb_irq_mask(unsigned int irq)
 
202
static void t7l66xb_irq_mask(struct irq_data *data)
186
203
{
187
 
        struct t7l66xb *t7l66xb = get_irq_chip_data(irq);
 
204
        struct t7l66xb *t7l66xb = irq_data_get_irq_chip_data(data);
188
205
        unsigned long                   flags;
189
206
        u8 imr;
190
207
 
191
208
        spin_lock_irqsave(&t7l66xb->lock, flags);
192
209
        imr = tmio_ioread8(t7l66xb->scr + SCR_IMR);
193
 
        imr |= 1 << (irq - t7l66xb->irq_base);
 
210
        imr |= 1 << (data->irq - t7l66xb->irq_base);
194
211
        tmio_iowrite8(imr, t7l66xb->scr + SCR_IMR);
195
212
        spin_unlock_irqrestore(&t7l66xb->lock, flags);
196
213
}
197
214
 
198
 
static void t7l66xb_irq_unmask(unsigned int irq)
 
215
static void t7l66xb_irq_unmask(struct irq_data *data)
199
216
{
200
 
        struct t7l66xb *t7l66xb = get_irq_chip_data(irq);
 
217
        struct t7l66xb *t7l66xb = irq_data_get_irq_chip_data(data);
201
218
        unsigned long flags;
202
219
        u8 imr;
203
220
 
204
221
        spin_lock_irqsave(&t7l66xb->lock, flags);
205
222
        imr = tmio_ioread8(t7l66xb->scr + SCR_IMR);
206
 
        imr &= ~(1 << (irq - t7l66xb->irq_base));
 
223
        imr &= ~(1 << (data->irq - t7l66xb->irq_base));
207
224
        tmio_iowrite8(imr, t7l66xb->scr + SCR_IMR);
208
225
        spin_unlock_irqrestore(&t7l66xb->lock, flags);
209
226
}
210
227
 
211
228
static struct irq_chip t7l66xb_chip = {
212
 
        .name   = "t7l66xb",
213
 
        .ack    = t7l66xb_irq_mask,
214
 
        .mask   = t7l66xb_irq_mask,
215
 
        .unmask = t7l66xb_irq_unmask,
 
229
        .name           = "t7l66xb",
 
230
        .irq_ack        = t7l66xb_irq_mask,
 
231
        .irq_mask       = t7l66xb_irq_mask,
 
232
        .irq_unmask     = t7l66xb_irq_unmask,
216
233
};
217
234
 
218
235
/*--------------------------------------------------------------------------*/
282
299
        if (pdata && pdata->resume)
283
300
                pdata->resume(dev);
284
301
 
 
302
        tmio_core_mmc_enable(t7l66xb->scr + 0x200, 0,
 
303
                t7l66xb_mmc_resources[0].start & 0xfffe);
 
304
 
285
305
        return 0;
286
306
}
287
307
#else
298
318
        struct resource *iomem, *rscr;
299
319
        int ret;
300
320
 
 
321
        if (pdata == NULL)
 
322
                return -EINVAL;
 
323
 
301
324
        iomem = platform_get_resource(dev, IORESOURCE_MEM, 0);
302
325
        if (!iomem)
303
326
                return -EINVAL;
327
350
        t7l66xb->clk48m = clk_get(&dev->dev, "CLK_CK48M");
328
351
        if (IS_ERR(t7l66xb->clk48m)) {
329
352
                ret = PTR_ERR(t7l66xb->clk48m);
330
 
                clk_put(t7l66xb->clk32k);
331
353
                goto err_clk48m_get;
332
354
        }
333
355
 
341
363
        if (ret)
342
364
                goto err_request_scr;
343
365
 
344
 
        t7l66xb->scr = ioremap(rscr->start, rscr->end - rscr->start + 1);
 
366
        t7l66xb->scr = ioremap(rscr->start, resource_size(rscr));
345
367
        if (!t7l66xb->scr) {
346
368
                ret = -ENOMEM;
347
369
                goto err_ioremap;
384
406
err_ioremap:
385
407
        release_resource(&t7l66xb->rscr);
386
408
err_request_scr:
387
 
        kfree(t7l66xb);
388
409
        clk_put(t7l66xb->clk48m);
389
410
err_clk48m_get:
390
411
        clk_put(t7l66xb->clk32k);
391
412
err_clk32k_get:
392
413
err_noirq:
 
414
        kfree(t7l66xb);
393
415
        return ret;
394
416
}
395
417
 
402
424
        ret = pdata->disable(dev);
403
425
        clk_disable(t7l66xb->clk48m);
404
426
        clk_put(t7l66xb->clk48m);
 
427
        clk_disable(t7l66xb->clk32k);
 
428
        clk_put(t7l66xb->clk32k);
405
429
        t7l66xb_detach_irq(dev);
406
430
        iounmap(t7l66xb->scr);
407
431
        release_resource(&t7l66xb->rscr);