blob: 25387cf47530442bedca12fe93ef267f2e707a21 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/arch/arm/mach-sa1100/sa1111.c
3 *
4 * SA1111 support
5 *
6 * Original code by John Dorsey
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12 * This file contains all generic SA1111 support.
13 *
14 * All initialization functions provided here are intended to be called
15 * from machine specific code with proper arguments when required.
16 */
17#include <linux/config.h>
18#include <linux/module.h>
19#include <linux/init.h>
20#include <linux/kernel.h>
21#include <linux/delay.h>
22#include <linux/ptrace.h>
23#include <linux/errno.h>
24#include <linux/ioport.h>
Russell Kingd052d1b2005-10-29 19:07:23 +010025#include <linux/platform_device.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <linux/slab.h>
27#include <linux/spinlock.h>
28#include <linux/dma-mapping.h>
29
30#include <asm/hardware.h>
31#include <asm/mach-types.h>
32#include <asm/io.h>
33#include <asm/irq.h>
34#include <asm/mach/irq.h>
35
36#include <asm/hardware/sa1111.h>
37
38#ifdef CONFIG_ARCH_PXA
39#include <asm/arch/pxa-regs.h>
40#endif
41
42extern void __init sa1110_mb_enable(void);
43
44/*
45 * We keep the following data for the overall SA1111. Note that the
46 * struct device and struct resource are "fake"; they should be supplied
47 * by the bus above us. However, in the interests of getting all SA1111
48 * drivers converted over to the device model, we provide this as an
49 * anchor point for all the other drivers.
50 */
51struct sa1111 {
52 struct device *dev;
53 unsigned long phys;
54 int irq;
55 spinlock_t lock;
56 void __iomem *base;
57};
58
59/*
60 * We _really_ need to eliminate this. Its only users
61 * are the PWM and DMA checking code.
62 */
63static struct sa1111 *g_sa1111;
64
65struct sa1111_dev_info {
66 unsigned long offset;
67 unsigned long skpcr_mask;
68 unsigned int devid;
69 unsigned int irq[6];
70};
71
72static struct sa1111_dev_info sa1111_devices[] = {
73 {
74 .offset = SA1111_USB,
75 .skpcr_mask = SKPCR_UCLKEN,
76 .devid = SA1111_DEVID_USB,
77 .irq = {
78 IRQ_USBPWR,
79 IRQ_HCIM,
80 IRQ_HCIBUFFACC,
81 IRQ_HCIRMTWKP,
82 IRQ_NHCIMFCIR,
83 IRQ_USB_PORT_RESUME
84 },
85 },
86 {
87 .offset = 0x0600,
88 .skpcr_mask = SKPCR_I2SCLKEN | SKPCR_L3CLKEN,
89 .devid = SA1111_DEVID_SAC,
90 .irq = {
91 AUDXMTDMADONEA,
92 AUDXMTDMADONEB,
93 AUDRCVDMADONEA,
94 AUDRCVDMADONEB
95 },
96 },
97 {
98 .offset = 0x0800,
99 .skpcr_mask = SKPCR_SCLKEN,
100 .devid = SA1111_DEVID_SSP,
101 },
102 {
103 .offset = SA1111_KBD,
104 .skpcr_mask = SKPCR_PTCLKEN,
105 .devid = SA1111_DEVID_PS2,
106 .irq = {
107 IRQ_TPRXINT,
108 IRQ_TPTXINT
109 },
110 },
111 {
112 .offset = SA1111_MSE,
113 .skpcr_mask = SKPCR_PMCLKEN,
114 .devid = SA1111_DEVID_PS2,
115 .irq = {
116 IRQ_MSRXINT,
117 IRQ_MSTXINT
118 },
119 },
120 {
121 .offset = 0x1800,
122 .skpcr_mask = 0,
123 .devid = SA1111_DEVID_PCMCIA,
124 .irq = {
125 IRQ_S0_READY_NINT,
126 IRQ_S0_CD_VALID,
127 IRQ_S0_BVD1_STSCHG,
128 IRQ_S1_READY_NINT,
129 IRQ_S1_CD_VALID,
130 IRQ_S1_BVD1_STSCHG,
131 },
132 },
133};
134
Russell King1b120502005-11-16 17:38:40 +0000135void __init sa1111_adjust_zones(int node, unsigned long *size, unsigned long *holes)
136{
137 unsigned int sz = SZ_1M >> PAGE_SHIFT;
138
139 if (node != 0)
140 sz = 0;
141
142 size[1] = size[0] - sz;
143 size[0] = sz;
144}
145
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146/*
147 * SA1111 interrupt support. Since clearing an IRQ while there are
148 * active IRQs causes the interrupt output to pulse, the upper levels
149 * will call us again if there are more interrupts to process.
150 */
151static void
152sa1111_irq_handler(unsigned int irq, struct irqdesc *desc, struct pt_regs *regs)
153{
154 unsigned int stat0, stat1, i;
155 void __iomem *base = desc->data;
156
157 stat0 = sa1111_readl(base + SA1111_INTSTATCLR0);
158 stat1 = sa1111_readl(base + SA1111_INTSTATCLR1);
159
160 sa1111_writel(stat0, base + SA1111_INTSTATCLR0);
161
162 desc->chip->ack(irq);
163
164 sa1111_writel(stat1, base + SA1111_INTSTATCLR1);
165
166 if (stat0 == 0 && stat1 == 0) {
167 do_bad_IRQ(irq, desc, regs);
168 return;
169 }
170
171 for (i = IRQ_SA1111_START; stat0; i++, stat0 >>= 1)
172 if (stat0 & 1)
173 do_edge_IRQ(i, irq_desc + i, regs);
174
175 for (i = IRQ_SA1111_START + 32; stat1; i++, stat1 >>= 1)
176 if (stat1 & 1)
177 do_edge_IRQ(i, irq_desc + i, regs);
178
179 /* For level-based interrupts */
180 desc->chip->unmask(irq);
181}
182
183#define SA1111_IRQMASK_LO(x) (1 << (x - IRQ_SA1111_START))
184#define SA1111_IRQMASK_HI(x) (1 << (x - IRQ_SA1111_START - 32))
185
186static void sa1111_ack_irq(unsigned int irq)
187{
188}
189
190static void sa1111_mask_lowirq(unsigned int irq)
191{
192 void __iomem *mapbase = get_irq_chipdata(irq);
193 unsigned long ie0;
194
195 ie0 = sa1111_readl(mapbase + SA1111_INTEN0);
196 ie0 &= ~SA1111_IRQMASK_LO(irq);
197 writel(ie0, mapbase + SA1111_INTEN0);
198}
199
200static void sa1111_unmask_lowirq(unsigned int irq)
201{
202 void __iomem *mapbase = get_irq_chipdata(irq);
203 unsigned long ie0;
204
205 ie0 = sa1111_readl(mapbase + SA1111_INTEN0);
206 ie0 |= SA1111_IRQMASK_LO(irq);
207 sa1111_writel(ie0, mapbase + SA1111_INTEN0);
208}
209
210/*
211 * Attempt to re-trigger the interrupt. The SA1111 contains a register
212 * (INTSET) which claims to do this. However, in practice no amount of
213 * manipulation of INTEN and INTSET guarantees that the interrupt will
214 * be triggered. In fact, its very difficult, if not impossible to get
215 * INTSET to re-trigger the interrupt.
216 */
217static int sa1111_retrigger_lowirq(unsigned int irq)
218{
219 unsigned int mask = SA1111_IRQMASK_LO(irq);
220 void __iomem *mapbase = get_irq_chipdata(irq);
221 unsigned long ip0;
222 int i;
223
224 ip0 = sa1111_readl(mapbase + SA1111_INTPOL0);
225 for (i = 0; i < 8; i++) {
226 sa1111_writel(ip0 ^ mask, mapbase + SA1111_INTPOL0);
227 sa1111_writel(ip0, mapbase + SA1111_INTPOL0);
228 if (sa1111_readl(mapbase + SA1111_INTSTATCLR1) & mask)
229 break;
230 }
231
232 if (i == 8)
233 printk(KERN_ERR "Danger Will Robinson: failed to "
234 "re-trigger IRQ%d\n", irq);
235 return i == 8 ? -1 : 0;
236}
237
238static int sa1111_type_lowirq(unsigned int irq, unsigned int flags)
239{
240 unsigned int mask = SA1111_IRQMASK_LO(irq);
241 void __iomem *mapbase = get_irq_chipdata(irq);
242 unsigned long ip0;
243
244 if (flags == IRQT_PROBE)
245 return 0;
246
247 if ((!(flags & __IRQT_RISEDGE) ^ !(flags & __IRQT_FALEDGE)) == 0)
248 return -EINVAL;
249
250 ip0 = sa1111_readl(mapbase + SA1111_INTPOL0);
251 if (flags & __IRQT_RISEDGE)
252 ip0 &= ~mask;
253 else
254 ip0 |= mask;
255 sa1111_writel(ip0, mapbase + SA1111_INTPOL0);
256 sa1111_writel(ip0, mapbase + SA1111_WAKEPOL0);
257
258 return 0;
259}
260
261static int sa1111_wake_lowirq(unsigned int irq, unsigned int on)
262{
263 unsigned int mask = SA1111_IRQMASK_LO(irq);
264 void __iomem *mapbase = get_irq_chipdata(irq);
265 unsigned long we0;
266
267 we0 = sa1111_readl(mapbase + SA1111_WAKEEN0);
268 if (on)
269 we0 |= mask;
270 else
271 we0 &= ~mask;
272 sa1111_writel(we0, mapbase + SA1111_WAKEEN0);
273
274 return 0;
275}
276
277static struct irqchip sa1111_low_chip = {
278 .ack = sa1111_ack_irq,
279 .mask = sa1111_mask_lowirq,
280 .unmask = sa1111_unmask_lowirq,
281 .retrigger = sa1111_retrigger_lowirq,
Russell King78019072005-09-04 19:43:13 +0100282 .set_type = sa1111_type_lowirq,
283 .set_wake = sa1111_wake_lowirq,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700284};
285
286static void sa1111_mask_highirq(unsigned int irq)
287{
288 void __iomem *mapbase = get_irq_chipdata(irq);
289 unsigned long ie1;
290
291 ie1 = sa1111_readl(mapbase + SA1111_INTEN1);
292 ie1 &= ~SA1111_IRQMASK_HI(irq);
293 sa1111_writel(ie1, mapbase + SA1111_INTEN1);
294}
295
296static void sa1111_unmask_highirq(unsigned int irq)
297{
298 void __iomem *mapbase = get_irq_chipdata(irq);
299 unsigned long ie1;
300
301 ie1 = sa1111_readl(mapbase + SA1111_INTEN1);
302 ie1 |= SA1111_IRQMASK_HI(irq);
303 sa1111_writel(ie1, mapbase + SA1111_INTEN1);
304}
305
306/*
307 * Attempt to re-trigger the interrupt. The SA1111 contains a register
308 * (INTSET) which claims to do this. However, in practice no amount of
309 * manipulation of INTEN and INTSET guarantees that the interrupt will
310 * be triggered. In fact, its very difficult, if not impossible to get
311 * INTSET to re-trigger the interrupt.
312 */
313static int sa1111_retrigger_highirq(unsigned int irq)
314{
315 unsigned int mask = SA1111_IRQMASK_HI(irq);
316 void __iomem *mapbase = get_irq_chipdata(irq);
317 unsigned long ip1;
318 int i;
319
320 ip1 = sa1111_readl(mapbase + SA1111_INTPOL1);
321 for (i = 0; i < 8; i++) {
322 sa1111_writel(ip1 ^ mask, mapbase + SA1111_INTPOL1);
323 sa1111_writel(ip1, mapbase + SA1111_INTPOL1);
324 if (sa1111_readl(mapbase + SA1111_INTSTATCLR1) & mask)
325 break;
326 }
327
328 if (i == 8)
329 printk(KERN_ERR "Danger Will Robinson: failed to "
330 "re-trigger IRQ%d\n", irq);
331 return i == 8 ? -1 : 0;
332}
333
334static int sa1111_type_highirq(unsigned int irq, unsigned int flags)
335{
336 unsigned int mask = SA1111_IRQMASK_HI(irq);
337 void __iomem *mapbase = get_irq_chipdata(irq);
338 unsigned long ip1;
339
340 if (flags == IRQT_PROBE)
341 return 0;
342
343 if ((!(flags & __IRQT_RISEDGE) ^ !(flags & __IRQT_FALEDGE)) == 0)
344 return -EINVAL;
345
346 ip1 = sa1111_readl(mapbase + SA1111_INTPOL1);
347 if (flags & __IRQT_RISEDGE)
348 ip1 &= ~mask;
349 else
350 ip1 |= mask;
351 sa1111_writel(ip1, mapbase + SA1111_INTPOL1);
352 sa1111_writel(ip1, mapbase + SA1111_WAKEPOL1);
353
354 return 0;
355}
356
357static int sa1111_wake_highirq(unsigned int irq, unsigned int on)
358{
359 unsigned int mask = SA1111_IRQMASK_HI(irq);
360 void __iomem *mapbase = get_irq_chipdata(irq);
361 unsigned long we1;
362
363 we1 = sa1111_readl(mapbase + SA1111_WAKEEN1);
364 if (on)
365 we1 |= mask;
366 else
367 we1 &= ~mask;
368 sa1111_writel(we1, mapbase + SA1111_WAKEEN1);
369
370 return 0;
371}
372
373static struct irqchip sa1111_high_chip = {
374 .ack = sa1111_ack_irq,
375 .mask = sa1111_mask_highirq,
376 .unmask = sa1111_unmask_highirq,
377 .retrigger = sa1111_retrigger_highirq,
Russell King78019072005-09-04 19:43:13 +0100378 .set_type = sa1111_type_highirq,
379 .set_wake = sa1111_wake_highirq,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700380};
381
382static void sa1111_setup_irq(struct sa1111 *sachip)
383{
384 void __iomem *irqbase = sachip->base + SA1111_INTC;
385 unsigned int irq;
386
387 /*
388 * We're guaranteed that this region hasn't been taken.
389 */
390 request_mem_region(sachip->phys + SA1111_INTC, 512, "irq");
391
392 /* disable all IRQs */
393 sa1111_writel(0, irqbase + SA1111_INTEN0);
394 sa1111_writel(0, irqbase + SA1111_INTEN1);
395 sa1111_writel(0, irqbase + SA1111_WAKEEN0);
396 sa1111_writel(0, irqbase + SA1111_WAKEEN1);
397
398 /*
399 * detect on rising edge. Note: Feb 2001 Errata for SA1111
400 * specifies that S0ReadyInt and S1ReadyInt should be '1'.
401 */
402 sa1111_writel(0, irqbase + SA1111_INTPOL0);
403 sa1111_writel(SA1111_IRQMASK_HI(IRQ_S0_READY_NINT) |
404 SA1111_IRQMASK_HI(IRQ_S1_READY_NINT),
405 irqbase + SA1111_INTPOL1);
406
407 /* clear all IRQs */
408 sa1111_writel(~0, irqbase + SA1111_INTSTATCLR0);
409 sa1111_writel(~0, irqbase + SA1111_INTSTATCLR1);
410
411 for (irq = IRQ_GPAIN0; irq <= SSPROR; irq++) {
412 set_irq_chip(irq, &sa1111_low_chip);
413 set_irq_chipdata(irq, irqbase);
414 set_irq_handler(irq, do_edge_IRQ);
415 set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
416 }
417
418 for (irq = AUDXMTDMADONEA; irq <= IRQ_S1_BVD1_STSCHG; irq++) {
419 set_irq_chip(irq, &sa1111_high_chip);
420 set_irq_chipdata(irq, irqbase);
421 set_irq_handler(irq, do_edge_IRQ);
422 set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
423 }
424
425 /*
426 * Register SA1111 interrupt
427 */
428 set_irq_type(sachip->irq, IRQT_RISING);
429 set_irq_data(sachip->irq, irqbase);
430 set_irq_chained_handler(sachip->irq, sa1111_irq_handler);
431}
432
433/*
434 * Bring the SA1111 out of reset. This requires a set procedure:
435 * 1. nRESET asserted (by hardware)
436 * 2. CLK turned on from SA1110
437 * 3. nRESET deasserted
438 * 4. VCO turned on, PLL_BYPASS turned off
439 * 5. Wait lock time, then assert RCLKEn
440 * 7. PCR set to allow clocking of individual functions
441 *
442 * Until we've done this, the only registers we can access are:
443 * SBI_SKCR
444 * SBI_SMCR
445 * SBI_SKID
446 */
447static void sa1111_wake(struct sa1111 *sachip)
448{
449 unsigned long flags, r;
450
451 spin_lock_irqsave(&sachip->lock, flags);
452
453#ifdef CONFIG_ARCH_SA1100
454 /*
455 * First, set up the 3.6864MHz clock on GPIO 27 for the SA-1111:
456 * (SA-1110 Developer's Manual, section 9.1.2.1)
457 */
458 GAFR |= GPIO_32_768kHz;
459 GPDR |= GPIO_32_768kHz;
460 TUCR = TUCR_3_6864MHz;
461#elif CONFIG_ARCH_PXA
462 pxa_gpio_mode(GPIO11_3_6MHz_MD);
463#else
464#error missing clock setup
465#endif
466
467 /*
468 * Turn VCO on, and disable PLL Bypass.
469 */
470 r = sa1111_readl(sachip->base + SA1111_SKCR);
471 r &= ~SKCR_VCO_OFF;
472 sa1111_writel(r, sachip->base + SA1111_SKCR);
473 r |= SKCR_PLL_BYPASS | SKCR_OE_EN;
474 sa1111_writel(r, sachip->base + SA1111_SKCR);
475
476 /*
477 * Wait lock time. SA1111 manual _doesn't_
478 * specify a figure for this! We choose 100us.
479 */
480 udelay(100);
481
482 /*
483 * Enable RCLK. We also ensure that RDYEN is set.
484 */
485 r |= SKCR_RCLKEN | SKCR_RDYEN;
486 sa1111_writel(r, sachip->base + SA1111_SKCR);
487
488 /*
489 * Wait 14 RCLK cycles for the chip to finish coming out
490 * of reset. (RCLK=24MHz). This is 590ns.
491 */
492 udelay(1);
493
494 /*
495 * Ensure all clocks are initially off.
496 */
497 sa1111_writel(0, sachip->base + SA1111_SKPCR);
498
499 spin_unlock_irqrestore(&sachip->lock, flags);
500}
501
502#ifdef CONFIG_ARCH_SA1100
503
504static u32 sa1111_dma_mask[] = {
505 ~0,
506 ~(1 << 20),
507 ~(1 << 23),
508 ~(1 << 24),
509 ~(1 << 25),
510 ~(1 << 20),
511 ~(1 << 20),
512 0,
513};
514
515/*
516 * Configure the SA1111 shared memory controller.
517 */
518void
519sa1111_configure_smc(struct sa1111 *sachip, int sdram, unsigned int drac,
520 unsigned int cas_latency)
521{
522 unsigned int smcr = SMCR_DTIM | SMCR_MBGE | FInsrt(drac, SMCR_DRAC);
523
524 if (cas_latency == 3)
525 smcr |= SMCR_CLAT;
526
527 sa1111_writel(smcr, sachip->base + SA1111_SMCR);
528
529 /*
530 * Now clear the bits in the DMA mask to work around the SA1111
531 * DMA erratum (Intel StrongARM SA-1111 Microprocessor Companion
532 * Chip Specification Update, June 2000, Erratum #7).
533 */
534 if (sachip->dev->dma_mask)
535 *sachip->dev->dma_mask &= sa1111_dma_mask[drac >> 2];
536
537 sachip->dev->coherent_dma_mask &= sa1111_dma_mask[drac >> 2];
538}
539
540#endif
541
542static void sa1111_dev_release(struct device *_dev)
543{
544 struct sa1111_dev *dev = SA1111_DEV(_dev);
545
546 release_resource(&dev->res);
547 kfree(dev);
548}
549
550static int
551sa1111_init_one_child(struct sa1111 *sachip, struct resource *parent,
552 struct sa1111_dev_info *info)
553{
554 struct sa1111_dev *dev;
555 int ret;
556
557 dev = kmalloc(sizeof(struct sa1111_dev), GFP_KERNEL);
558 if (!dev) {
559 ret = -ENOMEM;
560 goto out;
561 }
562 memset(dev, 0, sizeof(struct sa1111_dev));
563
564 snprintf(dev->dev.bus_id, sizeof(dev->dev.bus_id),
565 "%4.4lx", info->offset);
566
567 dev->devid = info->devid;
568 dev->dev.parent = sachip->dev;
569 dev->dev.bus = &sa1111_bus_type;
570 dev->dev.release = sa1111_dev_release;
571 dev->dev.coherent_dma_mask = sachip->dev->coherent_dma_mask;
572 dev->res.start = sachip->phys + info->offset;
573 dev->res.end = dev->res.start + 511;
574 dev->res.name = dev->dev.bus_id;
575 dev->res.flags = IORESOURCE_MEM;
576 dev->mapbase = sachip->base + info->offset;
577 dev->skpcr_mask = info->skpcr_mask;
578 memmove(dev->irq, info->irq, sizeof(dev->irq));
579
580 ret = request_resource(parent, &dev->res);
581 if (ret) {
582 printk("SA1111: failed to allocate resource for %s\n",
583 dev->res.name);
584 kfree(dev);
585 goto out;
586 }
587
588
589 ret = device_register(&dev->dev);
590 if (ret) {
591 release_resource(&dev->res);
592 kfree(dev);
593 goto out;
594 }
595
596 /*
597 * If the parent device has a DMA mask associated with it,
598 * propagate it down to the children.
599 */
600 if (sachip->dev->dma_mask) {
601 dev->dma_mask = *sachip->dev->dma_mask;
602 dev->dev.dma_mask = &dev->dma_mask;
603
604 if (dev->dma_mask != 0xffffffffUL) {
605 ret = dmabounce_register_dev(&dev->dev, 1024, 4096);
606 if (ret) {
607 printk("SA1111: Failed to register %s with dmabounce", dev->dev.bus_id);
608 device_unregister(&dev->dev);
609 }
610 }
611 }
612
613out:
614 return ret;
615}
616
617/**
618 * sa1111_probe - probe for a single SA1111 chip.
619 * @phys_addr: physical address of device.
620 *
621 * Probe for a SA1111 chip. This must be called
622 * before any other SA1111-specific code.
623 *
624 * Returns:
625 * %-ENODEV device not found.
626 * %-EBUSY physical address already marked in-use.
627 * %0 successful.
628 */
629static int
630__sa1111_probe(struct device *me, struct resource *mem, int irq)
631{
632 struct sa1111 *sachip;
633 unsigned long id;
634 unsigned int has_devs, val;
635 int i, ret = -ENODEV;
636
637 sachip = kmalloc(sizeof(struct sa1111), GFP_KERNEL);
638 if (!sachip)
639 return -ENOMEM;
640
641 memset(sachip, 0, sizeof(struct sa1111));
642
643 spin_lock_init(&sachip->lock);
644
645 sachip->dev = me;
646 dev_set_drvdata(sachip->dev, sachip);
647
648 sachip->phys = mem->start;
649 sachip->irq = irq;
650
651 /*
652 * Map the whole region. This also maps the
653 * registers for our children.
654 */
655 sachip->base = ioremap(mem->start, PAGE_SIZE * 2);
656 if (!sachip->base) {
657 ret = -ENOMEM;
658 goto out;
659 }
660
661 /*
662 * Probe for the chip. Only touch the SBI registers.
663 */
664 id = sa1111_readl(sachip->base + SA1111_SKID);
665 if ((id & SKID_ID_MASK) != SKID_SA1111_ID) {
666 printk(KERN_DEBUG "SA1111 not detected: ID = %08lx\n", id);
667 ret = -ENODEV;
668 goto unmap;
669 }
670
671 printk(KERN_INFO "SA1111 Microprocessor Companion Chip: "
672 "silicon revision %lx, metal revision %lx\n",
673 (id & SKID_SIREV_MASK)>>4, (id & SKID_MTREV_MASK));
674
675 /*
676 * We found it. Wake the chip up, and initialise.
677 */
678 sa1111_wake(sachip);
679
680#ifdef CONFIG_ARCH_SA1100
681 /*
682 * The SDRAM configuration of the SA1110 and the SA1111 must
683 * match. This is very important to ensure that SA1111 accesses
684 * don't corrupt the SDRAM. Note that this ungates the SA1111's
685 * MBGNT signal, so we must have called sa1110_mb_disable()
686 * beforehand.
687 */
688 sa1111_configure_smc(sachip, 1,
689 FExtr(MDCNFG, MDCNFG_SA1110_DRAC0),
690 FExtr(MDCNFG, MDCNFG_SA1110_TDL0));
691
692 /*
693 * We only need to turn on DCLK whenever we want to use the
694 * DMA. It can otherwise be held firmly in the off position.
695 * (currently, we always enable it.)
696 */
697 val = sa1111_readl(sachip->base + SA1111_SKPCR);
698 sa1111_writel(val | SKPCR_DCLKEN, sachip->base + SA1111_SKPCR);
699
700 /*
701 * Enable the SA1110 memory bus request and grant signals.
702 */
703 sa1110_mb_enable();
704#endif
705
706 /*
707 * The interrupt controller must be initialised before any
708 * other device to ensure that the interrupts are available.
709 */
710 if (sachip->irq != NO_IRQ)
711 sa1111_setup_irq(sachip);
712
713 g_sa1111 = sachip;
714
715 has_devs = ~0;
716 if (machine_is_assabet() || machine_is_jornada720() ||
717 machine_is_badge4())
718 has_devs &= ~(1 << 4);
719 else
720 has_devs &= ~(1 << 1);
721
722 for (i = 0; i < ARRAY_SIZE(sa1111_devices); i++)
723 if (has_devs & (1 << i))
724 sa1111_init_one_child(sachip, mem, &sa1111_devices[i]);
725
726 return 0;
727
728 unmap:
729 iounmap(sachip->base);
730 out:
731 kfree(sachip);
732 return ret;
733}
734
Russell King522c37b2005-06-22 09:52:26 +0100735static int sa1111_remove_one(struct device *dev, void *data)
736{
737 device_unregister(dev);
738 return 0;
739}
740
Linus Torvalds1da177e2005-04-16 15:20:36 -0700741static void __sa1111_remove(struct sa1111 *sachip)
742{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700743 void __iomem *irqbase = sachip->base + SA1111_INTC;
744
Russell King522c37b2005-06-22 09:52:26 +0100745 device_for_each_child(sachip->dev, NULL, sa1111_remove_one);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700746
747 /* disable all IRQs */
748 sa1111_writel(0, irqbase + SA1111_INTEN0);
749 sa1111_writel(0, irqbase + SA1111_INTEN1);
750 sa1111_writel(0, irqbase + SA1111_WAKEEN0);
751 sa1111_writel(0, irqbase + SA1111_WAKEEN1);
752
753 if (sachip->irq != NO_IRQ) {
754 set_irq_chained_handler(sachip->irq, NULL);
755 set_irq_data(sachip->irq, NULL);
756
757 release_mem_region(sachip->phys + SA1111_INTC, 512);
758 }
759
760 iounmap(sachip->base);
761 kfree(sachip);
762}
763
764/*
765 * According to the "Intel StrongARM SA-1111 Microprocessor Companion
766 * Chip Specification Update" (June 2000), erratum #7, there is a
767 * significant bug in the SA1111 SDRAM shared memory controller. If
768 * an access to a region of memory above 1MB relative to the bank base,
769 * it is important that address bit 10 _NOT_ be asserted. Depending
770 * on the configuration of the RAM, bit 10 may correspond to one
771 * of several different (processor-relative) address bits.
772 *
773 * This routine only identifies whether or not a given DMA address
774 * is susceptible to the bug.
775 *
776 * This should only get called for sa1111_device types due to the
777 * way we configure our device dma_masks.
778 */
779int dma_needs_bounce(struct device *dev, dma_addr_t addr, size_t size)
780{
781 /*
782 * Section 4.6 of the "Intel StrongARM SA-1111 Development Module
783 * User's Guide" mentions that jumpers R51 and R52 control the
784 * target of SA-1111 DMA (either SDRAM bank 0 on Assabet, or
785 * SDRAM bank 1 on Neponset). The default configuration selects
786 * Assabet, so any address in bank 1 is necessarily invalid.
787 */
788 return ((machine_is_assabet() || machine_is_pfs168()) &&
789 (addr >= 0xc8000000 || (addr + size) >= 0xc8000000));
790}
791
792struct sa1111_save_data {
793 unsigned int skcr;
794 unsigned int skpcr;
795 unsigned int skcdr;
796 unsigned char skaud;
797 unsigned char skpwm0;
798 unsigned char skpwm1;
799
800 /*
801 * Interrupt controller
802 */
803 unsigned int intpol0;
804 unsigned int intpol1;
805 unsigned int inten0;
806 unsigned int inten1;
807 unsigned int wakepol0;
808 unsigned int wakepol1;
809 unsigned int wakeen0;
810 unsigned int wakeen1;
811};
812
813#ifdef CONFIG_PM
814
Russell King3ae5eae2005-11-09 22:32:44 +0000815static int sa1111_suspend(struct platform_device *dev, pm_message_t state)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700816{
Russell King3ae5eae2005-11-09 22:32:44 +0000817 struct sa1111 *sachip = platform_get_drvdata(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700818 struct sa1111_save_data *save;
819 unsigned long flags;
820 unsigned int val;
821 void __iomem *base;
822
Linus Torvalds1da177e2005-04-16 15:20:36 -0700823 save = kmalloc(sizeof(struct sa1111_save_data), GFP_KERNEL);
824 if (!save)
825 return -ENOMEM;
Russell King3ae5eae2005-11-09 22:32:44 +0000826 dev->dev.power.saved_state = save;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700827
828 spin_lock_irqsave(&sachip->lock, flags);
829
830 /*
831 * Save state.
832 */
833 base = sachip->base;
834 save->skcr = sa1111_readl(base + SA1111_SKCR);
835 save->skpcr = sa1111_readl(base + SA1111_SKPCR);
836 save->skcdr = sa1111_readl(base + SA1111_SKCDR);
837 save->skaud = sa1111_readl(base + SA1111_SKAUD);
838 save->skpwm0 = sa1111_readl(base + SA1111_SKPWM0);
839 save->skpwm1 = sa1111_readl(base + SA1111_SKPWM1);
840
841 base = sachip->base + SA1111_INTC;
842 save->intpol0 = sa1111_readl(base + SA1111_INTPOL0);
843 save->intpol1 = sa1111_readl(base + SA1111_INTPOL1);
844 save->inten0 = sa1111_readl(base + SA1111_INTEN0);
845 save->inten1 = sa1111_readl(base + SA1111_INTEN1);
846 save->wakepol0 = sa1111_readl(base + SA1111_WAKEPOL0);
847 save->wakepol1 = sa1111_readl(base + SA1111_WAKEPOL1);
848 save->wakeen0 = sa1111_readl(base + SA1111_WAKEEN0);
849 save->wakeen1 = sa1111_readl(base + SA1111_WAKEEN1);
850
851 /*
852 * Disable.
853 */
854 val = sa1111_readl(sachip->base + SA1111_SKCR);
855 sa1111_writel(val | SKCR_SLEEP, sachip->base + SA1111_SKCR);
856 sa1111_writel(0, sachip->base + SA1111_SKPWM0);
857 sa1111_writel(0, sachip->base + SA1111_SKPWM1);
858
859 spin_unlock_irqrestore(&sachip->lock, flags);
860
861 return 0;
862}
863
864/*
865 * sa1111_resume - Restore the SA1111 device state.
866 * @dev: device to restore
Linus Torvalds1da177e2005-04-16 15:20:36 -0700867 *
868 * Restore the general state of the SA1111; clock control and
869 * interrupt controller. Other parts of the SA1111 must be
870 * restored by their respective drivers, and must be called
871 * via LDM after this function.
872 */
Russell King3ae5eae2005-11-09 22:32:44 +0000873static int sa1111_resume(struct platform_device *dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700874{
Russell King3ae5eae2005-11-09 22:32:44 +0000875 struct sa1111 *sachip = platform_get_drvdata(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700876 struct sa1111_save_data *save;
877 unsigned long flags, id;
878 void __iomem *base;
879
Russell King3ae5eae2005-11-09 22:32:44 +0000880 save = (struct sa1111_save_data *)dev->dev.power.saved_state;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700881 if (!save)
882 return 0;
883
884 spin_lock_irqsave(&sachip->lock, flags);
885
886 /*
887 * Ensure that the SA1111 is still here.
888 * FIXME: shouldn't do this here.
889 */
890 id = sa1111_readl(sachip->base + SA1111_SKID);
891 if ((id & SKID_ID_MASK) != SKID_SA1111_ID) {
892 __sa1111_remove(sachip);
Russell King3ae5eae2005-11-09 22:32:44 +0000893 platform_set_drvdata(dev, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700894 kfree(save);
895 return 0;
896 }
897
898 /*
899 * First of all, wake up the chip.
900 */
901 sa1111_wake(sachip);
902 sa1111_writel(0, sachip->base + SA1111_INTC + SA1111_INTEN0);
903 sa1111_writel(0, sachip->base + SA1111_INTC + SA1111_INTEN1);
904
905 base = sachip->base;
906 sa1111_writel(save->skcr, base + SA1111_SKCR);
907 sa1111_writel(save->skpcr, base + SA1111_SKPCR);
908 sa1111_writel(save->skcdr, base + SA1111_SKCDR);
909 sa1111_writel(save->skaud, base + SA1111_SKAUD);
910 sa1111_writel(save->skpwm0, base + SA1111_SKPWM0);
911 sa1111_writel(save->skpwm1, base + SA1111_SKPWM1);
912
913 base = sachip->base + SA1111_INTC;
914 sa1111_writel(save->intpol0, base + SA1111_INTPOL0);
915 sa1111_writel(save->intpol1, base + SA1111_INTPOL1);
916 sa1111_writel(save->inten0, base + SA1111_INTEN0);
917 sa1111_writel(save->inten1, base + SA1111_INTEN1);
918 sa1111_writel(save->wakepol0, base + SA1111_WAKEPOL0);
919 sa1111_writel(save->wakepol1, base + SA1111_WAKEPOL1);
920 sa1111_writel(save->wakeen0, base + SA1111_WAKEEN0);
921 sa1111_writel(save->wakeen1, base + SA1111_WAKEEN1);
922
923 spin_unlock_irqrestore(&sachip->lock, flags);
924
Russell King3ae5eae2005-11-09 22:32:44 +0000925 dev->dev.power.saved_state = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700926 kfree(save);
927
928 return 0;
929}
930
931#else
932#define sa1111_suspend NULL
933#define sa1111_resume NULL
934#endif
935
Russell King3ae5eae2005-11-09 22:32:44 +0000936static int sa1111_probe(struct platform_device *pdev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700937{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700938 struct resource *mem;
939 int irq;
940
941 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
942 if (!mem)
943 return -EINVAL;
944 irq = platform_get_irq(pdev, 0);
945
Russell King3ae5eae2005-11-09 22:32:44 +0000946 return __sa1111_probe(&pdev->dev, mem, irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700947}
948
Russell King3ae5eae2005-11-09 22:32:44 +0000949static int sa1111_remove(struct platform_device *pdev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700950{
Russell King3ae5eae2005-11-09 22:32:44 +0000951 struct sa1111 *sachip = platform_get_drvdata(pdev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700952
953 if (sachip) {
954 __sa1111_remove(sachip);
Russell King3ae5eae2005-11-09 22:32:44 +0000955 platform_set_drvdata(pdev, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700956
957#ifdef CONFIG_PM
Russell King3ae5eae2005-11-09 22:32:44 +0000958 kfree(pdev->dev.power.saved_state);
959 pdev->dev.power.saved_state = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700960#endif
961 }
962
963 return 0;
964}
965
966/*
967 * Not sure if this should be on the system bus or not yet.
968 * We really want some way to register a system device at
969 * the per-machine level, and then have this driver pick
970 * up the registered devices.
971 *
972 * We also need to handle the SDRAM configuration for
973 * PXA250/SA1110 machine classes.
974 */
Russell King3ae5eae2005-11-09 22:32:44 +0000975static struct platform_driver sa1111_device_driver = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700976 .probe = sa1111_probe,
977 .remove = sa1111_remove,
978 .suspend = sa1111_suspend,
979 .resume = sa1111_resume,
Russell King3ae5eae2005-11-09 22:32:44 +0000980 .driver = {
981 .name = "sa1111",
982 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700983};
984
985/*
986 * Get the parent device driver (us) structure
987 * from a child function device
988 */
989static inline struct sa1111 *sa1111_chip_driver(struct sa1111_dev *sadev)
990{
991 return (struct sa1111 *)dev_get_drvdata(sadev->dev.parent);
992}
993
994/*
995 * The bits in the opdiv field are non-linear.
996 */
997static unsigned char opdiv_table[] = { 1, 4, 2, 8 };
998
999static unsigned int __sa1111_pll_clock(struct sa1111 *sachip)
1000{
1001 unsigned int skcdr, fbdiv, ipdiv, opdiv;
1002
1003 skcdr = sa1111_readl(sachip->base + SA1111_SKCDR);
1004
1005 fbdiv = (skcdr & 0x007f) + 2;
1006 ipdiv = ((skcdr & 0x0f80) >> 7) + 2;
1007 opdiv = opdiv_table[(skcdr & 0x3000) >> 12];
1008
1009 return 3686400 * fbdiv / (ipdiv * opdiv);
1010}
1011
1012/**
1013 * sa1111_pll_clock - return the current PLL clock frequency.
1014 * @sadev: SA1111 function block
1015 *
1016 * BUG: we should look at SKCR. We also blindly believe that
1017 * the chip is being fed with the 3.6864MHz clock.
1018 *
1019 * Returns the PLL clock in Hz.
1020 */
1021unsigned int sa1111_pll_clock(struct sa1111_dev *sadev)
1022{
1023 struct sa1111 *sachip = sa1111_chip_driver(sadev);
1024
1025 return __sa1111_pll_clock(sachip);
1026}
1027
1028/**
1029 * sa1111_select_audio_mode - select I2S or AC link mode
1030 * @sadev: SA1111 function block
1031 * @mode: One of %SA1111_AUDIO_ACLINK or %SA1111_AUDIO_I2S
1032 *
1033 * Frob the SKCR to select AC Link mode or I2S mode for
1034 * the audio block.
1035 */
1036void sa1111_select_audio_mode(struct sa1111_dev *sadev, int mode)
1037{
1038 struct sa1111 *sachip = sa1111_chip_driver(sadev);
1039 unsigned long flags;
1040 unsigned int val;
1041
1042 spin_lock_irqsave(&sachip->lock, flags);
1043
1044 val = sa1111_readl(sachip->base + SA1111_SKCR);
1045 if (mode == SA1111_AUDIO_I2S) {
1046 val &= ~SKCR_SELAC;
1047 } else {
1048 val |= SKCR_SELAC;
1049 }
1050 sa1111_writel(val, sachip->base + SA1111_SKCR);
1051
1052 spin_unlock_irqrestore(&sachip->lock, flags);
1053}
1054
1055/**
1056 * sa1111_set_audio_rate - set the audio sample rate
1057 * @sadev: SA1111 SAC function block
1058 * @rate: sample rate to select
1059 */
1060int sa1111_set_audio_rate(struct sa1111_dev *sadev, int rate)
1061{
1062 struct sa1111 *sachip = sa1111_chip_driver(sadev);
1063 unsigned int div;
1064
1065 if (sadev->devid != SA1111_DEVID_SAC)
1066 return -EINVAL;
1067
1068 div = (__sa1111_pll_clock(sachip) / 256 + rate / 2) / rate;
1069 if (div == 0)
1070 div = 1;
1071 if (div > 128)
1072 div = 128;
1073
1074 sa1111_writel(div - 1, sachip->base + SA1111_SKAUD);
1075
1076 return 0;
1077}
1078
1079/**
1080 * sa1111_get_audio_rate - get the audio sample rate
1081 * @sadev: SA1111 SAC function block device
1082 */
1083int sa1111_get_audio_rate(struct sa1111_dev *sadev)
1084{
1085 struct sa1111 *sachip = sa1111_chip_driver(sadev);
1086 unsigned long div;
1087
1088 if (sadev->devid != SA1111_DEVID_SAC)
1089 return -EINVAL;
1090
1091 div = sa1111_readl(sachip->base + SA1111_SKAUD) + 1;
1092
1093 return __sa1111_pll_clock(sachip) / (256 * div);
1094}
1095
1096void sa1111_set_io_dir(struct sa1111_dev *sadev,
1097 unsigned int bits, unsigned int dir,
1098 unsigned int sleep_dir)
1099{
1100 struct sa1111 *sachip = sa1111_chip_driver(sadev);
1101 unsigned long flags;
1102 unsigned int val;
1103 void __iomem *gpio = sachip->base + SA1111_GPIO;
1104
1105#define MODIFY_BITS(port, mask, dir) \
1106 if (mask) { \
1107 val = sa1111_readl(port); \
1108 val &= ~(mask); \
1109 val |= (dir) & (mask); \
1110 sa1111_writel(val, port); \
1111 }
1112
1113 spin_lock_irqsave(&sachip->lock, flags);
1114 MODIFY_BITS(gpio + SA1111_GPIO_PADDR, bits & 15, dir);
1115 MODIFY_BITS(gpio + SA1111_GPIO_PBDDR, (bits >> 8) & 255, dir >> 8);
1116 MODIFY_BITS(gpio + SA1111_GPIO_PCDDR, (bits >> 16) & 255, dir >> 16);
1117
1118 MODIFY_BITS(gpio + SA1111_GPIO_PASDR, bits & 15, sleep_dir);
1119 MODIFY_BITS(gpio + SA1111_GPIO_PBSDR, (bits >> 8) & 255, sleep_dir >> 8);
1120 MODIFY_BITS(gpio + SA1111_GPIO_PCSDR, (bits >> 16) & 255, sleep_dir >> 16);
1121 spin_unlock_irqrestore(&sachip->lock, flags);
1122}
1123
1124void sa1111_set_io(struct sa1111_dev *sadev, unsigned int bits, unsigned int v)
1125{
1126 struct sa1111 *sachip = sa1111_chip_driver(sadev);
1127 unsigned long flags;
1128 unsigned int val;
1129 void __iomem *gpio = sachip->base + SA1111_GPIO;
1130
1131 spin_lock_irqsave(&sachip->lock, flags);
1132 MODIFY_BITS(gpio + SA1111_GPIO_PADWR, bits & 15, v);
1133 MODIFY_BITS(gpio + SA1111_GPIO_PBDWR, (bits >> 8) & 255, v >> 8);
1134 MODIFY_BITS(gpio + SA1111_GPIO_PCDWR, (bits >> 16) & 255, v >> 16);
1135 spin_unlock_irqrestore(&sachip->lock, flags);
1136}
1137
1138void sa1111_set_sleep_io(struct sa1111_dev *sadev, unsigned int bits, unsigned int v)
1139{
1140 struct sa1111 *sachip = sa1111_chip_driver(sadev);
1141 unsigned long flags;
1142 unsigned int val;
1143 void __iomem *gpio = sachip->base + SA1111_GPIO;
1144
1145 spin_lock_irqsave(&sachip->lock, flags);
1146 MODIFY_BITS(gpio + SA1111_GPIO_PASSR, bits & 15, v);
1147 MODIFY_BITS(gpio + SA1111_GPIO_PBSSR, (bits >> 8) & 255, v >> 8);
1148 MODIFY_BITS(gpio + SA1111_GPIO_PCSSR, (bits >> 16) & 255, v >> 16);
1149 spin_unlock_irqrestore(&sachip->lock, flags);
1150}
1151
1152/*
1153 * Individual device operations.
1154 */
1155
1156/**
1157 * sa1111_enable_device - enable an on-chip SA1111 function block
1158 * @sadev: SA1111 function block device to enable
1159 */
1160void sa1111_enable_device(struct sa1111_dev *sadev)
1161{
1162 struct sa1111 *sachip = sa1111_chip_driver(sadev);
1163 unsigned long flags;
1164 unsigned int val;
1165
1166 spin_lock_irqsave(&sachip->lock, flags);
1167 val = sa1111_readl(sachip->base + SA1111_SKPCR);
1168 sa1111_writel(val | sadev->skpcr_mask, sachip->base + SA1111_SKPCR);
1169 spin_unlock_irqrestore(&sachip->lock, flags);
1170}
1171
1172/**
1173 * sa1111_disable_device - disable an on-chip SA1111 function block
1174 * @sadev: SA1111 function block device to disable
1175 */
1176void sa1111_disable_device(struct sa1111_dev *sadev)
1177{
1178 struct sa1111 *sachip = sa1111_chip_driver(sadev);
1179 unsigned long flags;
1180 unsigned int val;
1181
1182 spin_lock_irqsave(&sachip->lock, flags);
1183 val = sa1111_readl(sachip->base + SA1111_SKPCR);
1184 sa1111_writel(val & ~sadev->skpcr_mask, sachip->base + SA1111_SKPCR);
1185 spin_unlock_irqrestore(&sachip->lock, flags);
1186}
1187
1188/*
1189 * SA1111 "Register Access Bus."
1190 *
1191 * We model this as a regular bus type, and hang devices directly
1192 * off this.
1193 */
1194static int sa1111_match(struct device *_dev, struct device_driver *_drv)
1195{
1196 struct sa1111_dev *dev = SA1111_DEV(_dev);
1197 struct sa1111_driver *drv = SA1111_DRV(_drv);
1198
1199 return dev->devid == drv->devid;
1200}
1201
1202static int sa1111_bus_suspend(struct device *dev, pm_message_t state)
1203{
1204 struct sa1111_dev *sadev = SA1111_DEV(dev);
1205 struct sa1111_driver *drv = SA1111_DRV(dev->driver);
1206 int ret = 0;
1207
1208 if (drv && drv->suspend)
1209 ret = drv->suspend(sadev, state);
1210 return ret;
1211}
1212
1213static int sa1111_bus_resume(struct device *dev)
1214{
1215 struct sa1111_dev *sadev = SA1111_DEV(dev);
1216 struct sa1111_driver *drv = SA1111_DRV(dev->driver);
1217 int ret = 0;
1218
1219 if (drv && drv->resume)
1220 ret = drv->resume(sadev);
1221 return ret;
1222}
1223
1224static int sa1111_bus_probe(struct device *dev)
1225{
1226 struct sa1111_dev *sadev = SA1111_DEV(dev);
1227 struct sa1111_driver *drv = SA1111_DRV(dev->driver);
1228 int ret = -ENODEV;
1229
1230 if (drv->probe)
1231 ret = drv->probe(sadev);
1232 return ret;
1233}
1234
1235static int sa1111_bus_remove(struct device *dev)
1236{
1237 struct sa1111_dev *sadev = SA1111_DEV(dev);
1238 struct sa1111_driver *drv = SA1111_DRV(dev->driver);
1239 int ret = 0;
1240
1241 if (drv->remove)
1242 ret = drv->remove(sadev);
1243 return ret;
1244}
1245
1246struct bus_type sa1111_bus_type = {
1247 .name = "sa1111-rab",
1248 .match = sa1111_match,
1249 .suspend = sa1111_bus_suspend,
1250 .resume = sa1111_bus_resume,
1251};
1252
1253int sa1111_driver_register(struct sa1111_driver *driver)
1254{
1255 driver->drv.probe = sa1111_bus_probe;
1256 driver->drv.remove = sa1111_bus_remove;
1257 driver->drv.bus = &sa1111_bus_type;
1258 return driver_register(&driver->drv);
1259}
1260
1261void sa1111_driver_unregister(struct sa1111_driver *driver)
1262{
1263 driver_unregister(&driver->drv);
1264}
1265
1266static int __init sa1111_init(void)
1267{
1268 int ret = bus_register(&sa1111_bus_type);
1269 if (ret == 0)
Russell King3ae5eae2005-11-09 22:32:44 +00001270 platform_driver_register(&sa1111_device_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001271 return ret;
1272}
1273
1274static void __exit sa1111_exit(void)
1275{
Russell King3ae5eae2005-11-09 22:32:44 +00001276 platform_driver_unregister(&sa1111_device_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001277 bus_unregister(&sa1111_bus_type);
1278}
1279
Russell King72724382005-11-15 19:04:22 +00001280subsys_initcall(sa1111_init);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001281module_exit(sa1111_exit);
1282
1283MODULE_DESCRIPTION("Intel Corporation SA1111 core driver");
1284MODULE_LICENSE("GPL");
1285
1286EXPORT_SYMBOL(sa1111_select_audio_mode);
1287EXPORT_SYMBOL(sa1111_set_audio_rate);
1288EXPORT_SYMBOL(sa1111_get_audio_rate);
1289EXPORT_SYMBOL(sa1111_set_io_dir);
1290EXPORT_SYMBOL(sa1111_set_io);
1291EXPORT_SYMBOL(sa1111_set_sleep_io);
1292EXPORT_SYMBOL(sa1111_enable_device);
1293EXPORT_SYMBOL(sa1111_disable_device);
1294EXPORT_SYMBOL(sa1111_pll_clock);
1295EXPORT_SYMBOL(sa1111_bus_type);
1296EXPORT_SYMBOL(sa1111_driver_register);
1297EXPORT_SYMBOL(sa1111_driver_unregister);