ALSA: provide a more useful get_unmapped_area handler for pcm
[sfrench/cifs-2.6.git] / arch / arm / plat-s3c64xx / dev-audio.c
1 /* linux/arch/arm/plat-s3c/dev-audio.c
2  *
3  * Copyright 2009 Wolfson Microelectronics
4  *      Mark Brown <broonie@opensource.wolfsonmicro.com>
5  *
6
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License version 2 as
9  * published by the Free Software Foundation.
10  */
11
12 #include <linux/kernel.h>
13 #include <linux/string.h>
14 #include <linux/platform_device.h>
15
16 #include <mach/irqs.h>
17 #include <mach/map.h>
18 #include <mach/dma.h>
19 #include <mach/gpio.h>
20
21 #include <plat/devs.h>
22 #include <plat/audio.h>
23 #include <plat/gpio-bank-d.h>
24 #include <plat/gpio-bank-e.h>
25 #include <plat/gpio-cfg.h>
26
27 static struct resource s3c64xx_iis0_resource[] = {
28         [0] = {
29                 .start = S3C64XX_PA_IIS0,
30                 .end   = S3C64XX_PA_IIS0 + 0x100 - 1,
31                 .flags = IORESOURCE_MEM,
32         },
33 };
34
35 struct platform_device s3c64xx_device_iis0 = {
36         .name             = "s3c64xx-iis",
37         .id               = 0,
38         .num_resources    = ARRAY_SIZE(s3c64xx_iis0_resource),
39         .resource         = s3c64xx_iis0_resource,
40 };
41 EXPORT_SYMBOL(s3c64xx_device_iis0);
42
43 static struct resource s3c64xx_iis1_resource[] = {
44         [0] = {
45                 .start = S3C64XX_PA_IIS1,
46                 .end   = S3C64XX_PA_IIS1 + 0x100 - 1,
47                 .flags = IORESOURCE_MEM,
48         },
49 };
50
51 struct platform_device s3c64xx_device_iis1 = {
52         .name             = "s3c64xx-iis",
53         .id               = 1,
54         .num_resources    = ARRAY_SIZE(s3c64xx_iis1_resource),
55         .resource         = s3c64xx_iis1_resource,
56 };
57 EXPORT_SYMBOL(s3c64xx_device_iis1);
58
59 static struct resource s3c64xx_iisv4_resource[] = {
60         [0] = {
61                 .start = S3C64XX_PA_IISV4,
62                 .end   = S3C64XX_PA_IISV4 + 0x100 - 1,
63                 .flags = IORESOURCE_MEM,
64         },
65 };
66
67 struct platform_device s3c64xx_device_iisv4 = {
68         .name             = "s3c64xx-iis-v4",
69         .id               = -1,
70         .num_resources    = ARRAY_SIZE(s3c64xx_iisv4_resource),
71         .resource         = s3c64xx_iisv4_resource,
72 };
73 EXPORT_SYMBOL(s3c64xx_device_iisv4);
74
75
76 /* PCM Controller platform_devices */
77
78 static int s3c64xx_pcm_cfg_gpio(struct platform_device *pdev)
79 {
80         switch (pdev->id) {
81         case 0:
82                 s3c_gpio_cfgpin(S3C64XX_GPD(0), S3C64XX_GPD0_PCM0_SCLK);
83                 s3c_gpio_cfgpin(S3C64XX_GPD(1), S3C64XX_GPD1_PCM0_EXTCLK);
84                 s3c_gpio_cfgpin(S3C64XX_GPD(2), S3C64XX_GPD2_PCM0_FSYNC);
85                 s3c_gpio_cfgpin(S3C64XX_GPD(3), S3C64XX_GPD3_PCM0_SIN);
86                 s3c_gpio_cfgpin(S3C64XX_GPD(4), S3C64XX_GPD4_PCM0_SOUT);
87                 break;
88         case 1:
89                 s3c_gpio_cfgpin(S3C64XX_GPE(0), S3C64XX_GPE0_PCM1_SCLK);
90                 s3c_gpio_cfgpin(S3C64XX_GPE(1), S3C64XX_GPE1_PCM1_EXTCLK);
91                 s3c_gpio_cfgpin(S3C64XX_GPE(2), S3C64XX_GPE2_PCM1_FSYNC);
92                 s3c_gpio_cfgpin(S3C64XX_GPE(3), S3C64XX_GPE3_PCM1_SIN);
93                 s3c_gpio_cfgpin(S3C64XX_GPE(4), S3C64XX_GPE4_PCM1_SOUT);
94                 break;
95         default:
96                 printk(KERN_DEBUG "Invalid PCM Controller number!");
97                 return -EINVAL;
98         }
99
100         return 0;
101 }
102
103 static struct resource s3c64xx_pcm0_resource[] = {
104         [0] = {
105                 .start = S3C64XX_PA_PCM0,
106                 .end   = S3C64XX_PA_PCM0 + 0x100 - 1,
107                 .flags = IORESOURCE_MEM,
108         },
109         [1] = {
110                 .start = DMACH_PCM0_TX,
111                 .end   = DMACH_PCM0_TX,
112                 .flags = IORESOURCE_DMA,
113         },
114         [2] = {
115                 .start = DMACH_PCM0_RX,
116                 .end   = DMACH_PCM0_RX,
117                 .flags = IORESOURCE_DMA,
118         },
119 };
120
121 static struct s3c_audio_pdata s3c_pcm0_pdata = {
122         .cfg_gpio = s3c64xx_pcm_cfg_gpio,
123 };
124
125 struct platform_device s3c64xx_device_pcm0 = {
126         .name             = "samsung-pcm",
127         .id               = 0,
128         .num_resources    = ARRAY_SIZE(s3c64xx_pcm0_resource),
129         .resource         = s3c64xx_pcm0_resource,
130         .dev = {
131                 .platform_data = &s3c_pcm0_pdata,
132         },
133 };
134 EXPORT_SYMBOL(s3c64xx_device_pcm0);
135
136 static struct resource s3c64xx_pcm1_resource[] = {
137         [0] = {
138                 .start = S3C64XX_PA_PCM1,
139                 .end   = S3C64XX_PA_PCM1 + 0x100 - 1,
140                 .flags = IORESOURCE_MEM,
141         },
142         [1] = {
143                 .start = DMACH_PCM1_TX,
144                 .end   = DMACH_PCM1_TX,
145                 .flags = IORESOURCE_DMA,
146         },
147         [2] = {
148                 .start = DMACH_PCM1_RX,
149                 .end   = DMACH_PCM1_RX,
150                 .flags = IORESOURCE_DMA,
151         },
152 };
153
154 static struct s3c_audio_pdata s3c_pcm1_pdata = {
155         .cfg_gpio = s3c64xx_pcm_cfg_gpio,
156 };
157
158 struct platform_device s3c64xx_device_pcm1 = {
159         .name             = "samsung-pcm",
160         .id               = 1,
161         .num_resources    = ARRAY_SIZE(s3c64xx_pcm1_resource),
162         .resource         = s3c64xx_pcm1_resource,
163         .dev = {
164                 .platform_data = &s3c_pcm1_pdata,
165         },
166 };
167 EXPORT_SYMBOL(s3c64xx_device_pcm1);