blob: a0d6edfd23a07f39ed5a28cfdadeba918fafeebb [file] [log] [blame]
Kukjin Kime661faa2010-09-08 19:21:23 +09001/* linux/arch/arm/mach-s5p64x0/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>
13#include <linux/gpio.h>
14
15#include <plat/gpio-cfg.h>
Arnd Bergmann436d42c2012-08-24 15:22:12 +020016#include <linux/platform_data/asoc-s3c.h>
Kukjin Kime661faa2010-09-08 19:21:23 +090017
18#include <mach/map.h>
19#include <mach/dma.h>
20#include <mach/irqs.h>
21
Jassi Brard9a93c32010-11-19 08:49:44 +090022static const char *rclksrc[] = {
23 [0] = "iis",
24 [1] = "sclk_audio2",
25};
26
Rajeshwari Shindee0b9c882010-12-21 09:44:42 +090027static int s5p6440_cfg_i2s(struct platform_device *pdev)
Kukjin Kime661faa2010-09-08 19:21:23 +090028{
Kukjin Kime661faa2010-09-08 19:21:23 +090029 switch (pdev->id) {
Jassi Brard9a93c32010-11-19 08:49:44 +090030 case 0:
Rajeshwari Shindee0b9c882010-12-21 09:44:42 +090031 s3c_gpio_cfgpin_range(S5P6440_GPC(4), 2, S3C_GPIO_SFN(5));
32 s3c_gpio_cfgpin(S5P6440_GPC(7), S3C_GPIO_SFN(5));
33 s3c_gpio_cfgpin_range(S5P6440_GPH(6), 4, S3C_GPIO_SFN(5));
Kukjin Kime661faa2010-09-08 19:21:23 +090034 break;
Kukjin Kime661faa2010-09-08 19:21:23 +090035 default:
36 printk(KERN_ERR "Invalid Device %d\n", pdev->id);
37 return -EINVAL;
38 }
39
40 return 0;
41}
42
Rajeshwari Shindee0b9c882010-12-21 09:44:42 +090043static struct s3c_audio_pdata s5p6440_i2s_pdata = {
44 .cfg_gpio = s5p6440_cfg_i2s,
Jassi Brard9a93c32010-11-19 08:49:44 +090045 .type = {
46 .i2s = {
47 .quirks = QUIRK_PRI_6CHAN,
48 .src_clk = rclksrc,
49 },
50 },
Kukjin Kime661faa2010-09-08 19:21:23 +090051};
52
Rajeshwari Shindee0b9c882010-12-21 09:44:42 +090053static struct resource s5p64x0_i2s0_resource[] = {
Tushar Behera5e9cf652012-05-12 16:12:30 +090054 [0] = DEFINE_RES_MEM(S5P64X0_PA_I2S, SZ_256),
55 [1] = DEFINE_RES_DMA(DMACH_I2S0_TX),
56 [2] = DEFINE_RES_DMA(DMACH_I2S0_RX),
Kukjin Kime661faa2010-09-08 19:21:23 +090057};
58
59struct platform_device s5p6440_device_iis = {
Jassi Brard9a93c32010-11-19 08:49:44 +090060 .name = "samsung-i2s",
61 .id = 0,
Rajeshwari Shindee0b9c882010-12-21 09:44:42 +090062 .num_resources = ARRAY_SIZE(s5p64x0_i2s0_resource),
63 .resource = s5p64x0_i2s0_resource,
Kukjin Kime661faa2010-09-08 19:21:23 +090064 .dev = {
Rajeshwari Shindee0b9c882010-12-21 09:44:42 +090065 .platform_data = &s5p6440_i2s_pdata,
66 },
67};
68
69static int s5p6450_cfg_i2s(struct platform_device *pdev)
70{
71 switch (pdev->id) {
72 case 0:
73 s3c_gpio_cfgpin_range(S5P6450_GPR(4), 5, S3C_GPIO_SFN(5));
74 s3c_gpio_cfgpin_range(S5P6450_GPR(13), 2, S3C_GPIO_SFN(5));
75 break;
76 case 1:
77 s3c_gpio_cfgpin(S5P6440_GPB(4), S3C_GPIO_SFN(5));
78 s3c_gpio_cfgpin_range(S5P6450_GPC(0), 4, S3C_GPIO_SFN(5));
79 break;
80 case 2:
81 s3c_gpio_cfgpin_range(S5P6450_GPK(0), 5, S3C_GPIO_SFN(5));
82 break;
83 default:
84 printk(KERN_ERR "Invalid Device %d\n", pdev->id);
85 return -EINVAL;
86 }
87
88 return 0;
89}
90
91static struct s3c_audio_pdata s5p6450_i2s0_pdata = {
92 .cfg_gpio = s5p6450_cfg_i2s,
93 .type = {
94 .i2s = {
95 .quirks = QUIRK_PRI_6CHAN,
96 .src_clk = rclksrc,
97 },
Kukjin Kime661faa2010-09-08 19:21:23 +090098 },
99};
100
101struct platform_device s5p6450_device_iis0 = {
Jassi Brard9a93c32010-11-19 08:49:44 +0900102 .name = "samsung-i2s",
103 .id = 0,
Rajeshwari Shindee0b9c882010-12-21 09:44:42 +0900104 .num_resources = ARRAY_SIZE(s5p64x0_i2s0_resource),
105 .resource = s5p64x0_i2s0_resource,
Kukjin Kime661faa2010-09-08 19:21:23 +0900106 .dev = {
Rajeshwari Shindee0b9c882010-12-21 09:44:42 +0900107 .platform_data = &s5p6450_i2s0_pdata,
108 },
109};
110
111static struct s3c_audio_pdata s5p6450_i2s_pdata = {
112 .cfg_gpio = s5p6450_cfg_i2s,
113 .type = {
114 .i2s = {
115 .src_clk = rclksrc,
116 },
117 },
118};
119
120static struct resource s5p6450_i2s1_resource[] = {
Tushar Behera5e9cf652012-05-12 16:12:30 +0900121 [0] = DEFINE_RES_MEM(S5P6450_PA_I2S1, SZ_256),
122 [1] = DEFINE_RES_DMA(DMACH_I2S1_TX),
123 [2] = DEFINE_RES_DMA(DMACH_I2S1_RX),
Rajeshwari Shindee0b9c882010-12-21 09:44:42 +0900124};
125
126struct platform_device s5p6450_device_iis1 = {
127 .name = "samsung-i2s",
128 .id = 1,
129 .num_resources = ARRAY_SIZE(s5p6450_i2s1_resource),
130 .resource = s5p6450_i2s1_resource,
131 .dev = {
132 .platform_data = &s5p6450_i2s_pdata,
133 },
134};
135
136static struct resource s5p6450_i2s2_resource[] = {
Tushar Behera5e9cf652012-05-12 16:12:30 +0900137 [0] = DEFINE_RES_MEM(S5P6450_PA_I2S2, SZ_256),
138 [1] = DEFINE_RES_DMA(DMACH_I2S2_TX),
139 [2] = DEFINE_RES_DMA(DMACH_I2S2_RX),
Rajeshwari Shindee0b9c882010-12-21 09:44:42 +0900140};
141
142struct platform_device s5p6450_device_iis2 = {
143 .name = "samsung-i2s",
144 .id = 2,
145 .num_resources = ARRAY_SIZE(s5p6450_i2s2_resource),
146 .resource = s5p6450_i2s2_resource,
147 .dev = {
148 .platform_data = &s5p6450_i2s_pdata,
Kukjin Kime661faa2010-09-08 19:21:23 +0900149 },
150};
151
152/* PCM Controller platform_devices */
153
154static int s5p6440_pcm_cfg_gpio(struct platform_device *pdev)
155{
156 switch (pdev->id) {
157 case 0:
Ben Dooksaf94e572010-10-01 13:45:54 +0900158 s3c_gpio_cfgpin_range(S5P6440_GPR(6), 3, S3C_GPIO_SFN(2));
159 s3c_gpio_cfgpin_range(S5P6440_GPR(13), 2, S3C_GPIO_SFN(2));
Kukjin Kime661faa2010-09-08 19:21:23 +0900160 break;
161
162 default:
163 printk(KERN_DEBUG "Invalid PCM Controller number!");
164 return -EINVAL;
165 }
166
167 return 0;
168}
169
170static struct s3c_audio_pdata s5p6440_pcm_pdata = {
171 .cfg_gpio = s5p6440_pcm_cfg_gpio,
172};
173
174static struct resource s5p6440_pcm0_resource[] = {
Tushar Behera5e9cf652012-05-12 16:12:30 +0900175 [0] = DEFINE_RES_MEM(S5P64X0_PA_PCM, SZ_256),
176 [1] = DEFINE_RES_DMA(DMACH_PCM0_TX),
177 [2] = DEFINE_RES_DMA(DMACH_PCM0_RX),
Kukjin Kime661faa2010-09-08 19:21:23 +0900178};
179
180struct platform_device s5p6440_device_pcm = {
181 .name = "samsung-pcm",
182 .id = 0,
183 .num_resources = ARRAY_SIZE(s5p6440_pcm0_resource),
184 .resource = s5p6440_pcm0_resource,
185 .dev = {
186 .platform_data = &s5p6440_pcm_pdata,
187 },
188};