]> bbs.cooldavid.org Git - net-next-2.6.git/blame - arch/arm/mach-s5p6442/dev-audio.c
Merge branch 'devel' of master.kernel.org:/home/rmk/linux-2.6-arm
[net-next-2.6.git] / arch / arm / mach-s5p6442 / dev-audio.c
CommitLineData
070c8085
JB
1/* linux/arch/arm/mach-s5p6442/dev-audio.c
2 *
3 * Copyright (c) 2010 Samsung Electronics Co. Ltd
4 * Jaswinder Singh <jassi.brar@samsung.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#include <linux/platform_device.h>
12#include <linux/dma-mapping.h>
1c739c7f 13#include <linux/gpio.h>
070c8085
JB
14
15#include <plat/gpio-cfg.h>
16#include <plat/audio.h>
17
070c8085
JB
18#include <mach/map.h>
19#include <mach/dma.h>
20#include <mach/irqs.h>
21
22static int s5p6442_cfg_i2s(struct platform_device *pdev)
23{
699afb75
BD
24 unsigned int base;
25
070c8085
JB
26 /* configure GPIO for i2s port */
27 switch (pdev->id) {
28 case 1:
699afb75 29 base = S5P6442_GPC1(0);
070c8085
JB
30 break;
31
32 case -1:
699afb75 33 base = S5P6442_GPC0(0);
070c8085
JB
34 break;
35
36 default:
37 printk(KERN_ERR "Invalid Device %d\n", pdev->id);
38 return -EINVAL;
39 }
40
699afb75 41 s3c_gpio_cfgpin_range(base, 5, S3C_GPIO_SFN(2));
070c8085
JB
42 return 0;
43}
44
45static struct s3c_audio_pdata s3c_i2s_pdata = {
46 .cfg_gpio = s5p6442_cfg_i2s,
47};
48
49static struct resource s5p6442_iis0_resource[] = {
50 [0] = {
51 .start = S5P6442_PA_I2S0,
52 .end = S5P6442_PA_I2S0 + 0x100 - 1,
53 .flags = IORESOURCE_MEM,
54 },
55 [1] = {
56 .start = DMACH_I2S0_TX,
57 .end = DMACH_I2S0_TX,
58 .flags = IORESOURCE_DMA,
59 },
60 [2] = {
61 .start = DMACH_I2S0_RX,
62 .end = DMACH_I2S0_RX,
63 .flags = IORESOURCE_DMA,
64 },
65};
66
67struct platform_device s5p6442_device_iis0 = {
68 .name = "s3c64xx-iis-v4",
69 .id = -1,
70 .num_resources = ARRAY_SIZE(s5p6442_iis0_resource),
71 .resource = s5p6442_iis0_resource,
72 .dev = {
73 .platform_data = &s3c_i2s_pdata,
74 },
75};
76
77static struct resource s5p6442_iis1_resource[] = {
78 [0] = {
79 .start = S5P6442_PA_I2S1,
80 .end = S5P6442_PA_I2S1 + 0x100 - 1,
81 .flags = IORESOURCE_MEM,
82 },
83 [1] = {
84 .start = DMACH_I2S1_TX,
85 .end = DMACH_I2S1_TX,
86 .flags = IORESOURCE_DMA,
87 },
88 [2] = {
89 .start = DMACH_I2S1_RX,
90 .end = DMACH_I2S1_RX,
91 .flags = IORESOURCE_DMA,
92 },
93};
94
95struct platform_device s5p6442_device_iis1 = {
96 .name = "s3c64xx-iis",
97 .id = 1,
98 .num_resources = ARRAY_SIZE(s5p6442_iis1_resource),
99 .resource = s5p6442_iis1_resource,
100 .dev = {
101 .platform_data = &s3c_i2s_pdata,
102 },
103};
104
105/* PCM Controller platform_devices */
106
107static int s5p6442_pcm_cfg_gpio(struct platform_device *pdev)
108{
699afb75
BD
109 unsigned int base;
110
070c8085
JB
111 switch (pdev->id) {
112 case 0:
699afb75 113 base = S5P6442_GPC0(0);
070c8085
JB
114 break;
115
116 case 1:
699afb75 117 base = S5P6442_GPC1(0);
070c8085
JB
118 break;
119
120 default:
121 printk(KERN_DEBUG "Invalid PCM Controller number!");
122 return -EINVAL;
123 }
124
699afb75 125 s3c_gpio_cfgpin_range(base, 5, S3C_GPIO_SFN(3));
070c8085
JB
126 return 0;
127}
128
129static struct s3c_audio_pdata s3c_pcm_pdata = {
130 .cfg_gpio = s5p6442_pcm_cfg_gpio,
131};
132
133static struct resource s5p6442_pcm0_resource[] = {
134 [0] = {
135 .start = S5P6442_PA_PCM0,
136 .end = S5P6442_PA_PCM0 + 0x100 - 1,
137 .flags = IORESOURCE_MEM,
138 },
139 [1] = {
140 .start = DMACH_PCM0_TX,
141 .end = DMACH_PCM0_TX,
142 .flags = IORESOURCE_DMA,
143 },
144 [2] = {
145 .start = DMACH_PCM0_RX,
146 .end = DMACH_PCM0_RX,
147 .flags = IORESOURCE_DMA,
148 },
149};
150
151struct platform_device s5p6442_device_pcm0 = {
152 .name = "samsung-pcm",
153 .id = 0,
154 .num_resources = ARRAY_SIZE(s5p6442_pcm0_resource),
155 .resource = s5p6442_pcm0_resource,
156 .dev = {
157 .platform_data = &s3c_pcm_pdata,
158 },
159};
160
161static struct resource s5p6442_pcm1_resource[] = {
162 [0] = {
163 .start = S5P6442_PA_PCM1,
164 .end = S5P6442_PA_PCM1 + 0x100 - 1,
165 .flags = IORESOURCE_MEM,
166 },
167 [1] = {
168 .start = DMACH_PCM1_TX,
169 .end = DMACH_PCM1_TX,
170 .flags = IORESOURCE_DMA,
171 },
172 [2] = {
173 .start = DMACH_PCM1_RX,
174 .end = DMACH_PCM1_RX,
175 .flags = IORESOURCE_DMA,
176 },
177};
178
179struct platform_device s5p6442_device_pcm1 = {
180 .name = "samsung-pcm",
181 .id = 1,
182 .num_resources = ARRAY_SIZE(s5p6442_pcm1_resource),
183 .resource = s5p6442_pcm1_resource,
184 .dev = {
185 .platform_data = &s3c_pcm_pdata,
186 },
187};