blob: 723d4773c3238050467b4f2defbb15d283ee731d [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
Rajeshwari Shindee0b9c882010-12-21 09:44:42 +090022static int s5p6440_cfg_i2s(struct platform_device *pdev)
Kukjin Kime661faa2010-09-08 19:21:23 +090023{
Kukjin Kime661faa2010-09-08 19:21:23 +090024 switch (pdev->id) {
Jassi Brard9a93c32010-11-19 08:49:44 +090025 case 0:
Rajeshwari Shindee0b9c882010-12-21 09:44:42 +090026 s3c_gpio_cfgpin_range(S5P6440_GPC(4), 2, S3C_GPIO_SFN(5));
27 s3c_gpio_cfgpin(S5P6440_GPC(7), S3C_GPIO_SFN(5));
28 s3c_gpio_cfgpin_range(S5P6440_GPH(6), 4, S3C_GPIO_SFN(5));
Kukjin Kime661faa2010-09-08 19:21:23 +090029 break;
Kukjin Kime661faa2010-09-08 19:21:23 +090030 default:
31 printk(KERN_ERR "Invalid Device %d\n", pdev->id);
32 return -EINVAL;
33 }
34
35 return 0;
36}
37
Rajeshwari Shindee0b9c882010-12-21 09:44:42 +090038static struct s3c_audio_pdata s5p6440_i2s_pdata = {
39 .cfg_gpio = s5p6440_cfg_i2s,
Jassi Brard9a93c32010-11-19 08:49:44 +090040 .type = {
41 .i2s = {
42 .quirks = QUIRK_PRI_6CHAN,
Jassi Brard9a93c32010-11-19 08:49:44 +090043 },
44 },
Kukjin Kime661faa2010-09-08 19:21:23 +090045};
46
Rajeshwari Shindee0b9c882010-12-21 09:44:42 +090047static struct resource s5p64x0_i2s0_resource[] = {
Tushar Behera5e9cf652012-05-12 16:12:30 +090048 [0] = DEFINE_RES_MEM(S5P64X0_PA_I2S, SZ_256),
49 [1] = DEFINE_RES_DMA(DMACH_I2S0_TX),
50 [2] = DEFINE_RES_DMA(DMACH_I2S0_RX),
Kukjin Kime661faa2010-09-08 19:21:23 +090051};
52
53struct platform_device s5p6440_device_iis = {
Jassi Brard9a93c32010-11-19 08:49:44 +090054 .name = "samsung-i2s",
55 .id = 0,
Rajeshwari Shindee0b9c882010-12-21 09:44:42 +090056 .num_resources = ARRAY_SIZE(s5p64x0_i2s0_resource),
57 .resource = s5p64x0_i2s0_resource,
Kukjin Kime661faa2010-09-08 19:21:23 +090058 .dev = {
Rajeshwari Shindee0b9c882010-12-21 09:44:42 +090059 .platform_data = &s5p6440_i2s_pdata,
60 },
61};
62
63static int s5p6450_cfg_i2s(struct platform_device *pdev)
64{
65 switch (pdev->id) {
66 case 0:
67 s3c_gpio_cfgpin_range(S5P6450_GPR(4), 5, S3C_GPIO_SFN(5));
68 s3c_gpio_cfgpin_range(S5P6450_GPR(13), 2, S3C_GPIO_SFN(5));
69 break;
70 case 1:
71 s3c_gpio_cfgpin(S5P6440_GPB(4), S3C_GPIO_SFN(5));
72 s3c_gpio_cfgpin_range(S5P6450_GPC(0), 4, S3C_GPIO_SFN(5));
73 break;
74 case 2:
75 s3c_gpio_cfgpin_range(S5P6450_GPK(0), 5, S3C_GPIO_SFN(5));
76 break;
77 default:
78 printk(KERN_ERR "Invalid Device %d\n", pdev->id);
79 return -EINVAL;
80 }
81
82 return 0;
83}
84
85static struct s3c_audio_pdata s5p6450_i2s0_pdata = {
86 .cfg_gpio = s5p6450_cfg_i2s,
87 .type = {
88 .i2s = {
89 .quirks = QUIRK_PRI_6CHAN,
Rajeshwari Shindee0b9c882010-12-21 09:44:42 +090090 },
Kukjin Kime661faa2010-09-08 19:21:23 +090091 },
92};
93
94struct platform_device s5p6450_device_iis0 = {
Jassi Brard9a93c32010-11-19 08:49:44 +090095 .name = "samsung-i2s",
96 .id = 0,
Rajeshwari Shindee0b9c882010-12-21 09:44:42 +090097 .num_resources = ARRAY_SIZE(s5p64x0_i2s0_resource),
98 .resource = s5p64x0_i2s0_resource,
Kukjin Kime661faa2010-09-08 19:21:23 +090099 .dev = {
Rajeshwari Shindee0b9c882010-12-21 09:44:42 +0900100 .platform_data = &s5p6450_i2s0_pdata,
101 },
102};
103
104static struct s3c_audio_pdata s5p6450_i2s_pdata = {
105 .cfg_gpio = s5p6450_cfg_i2s,
Rajeshwari Shindee0b9c882010-12-21 09:44:42 +0900106};
107
108static struct resource s5p6450_i2s1_resource[] = {
Tushar Behera5e9cf652012-05-12 16:12:30 +0900109 [0] = DEFINE_RES_MEM(S5P6450_PA_I2S1, SZ_256),
110 [1] = DEFINE_RES_DMA(DMACH_I2S1_TX),
111 [2] = DEFINE_RES_DMA(DMACH_I2S1_RX),
Rajeshwari Shindee0b9c882010-12-21 09:44:42 +0900112};
113
114struct platform_device s5p6450_device_iis1 = {
115 .name = "samsung-i2s",
116 .id = 1,
117 .num_resources = ARRAY_SIZE(s5p6450_i2s1_resource),
118 .resource = s5p6450_i2s1_resource,
119 .dev = {
120 .platform_data = &s5p6450_i2s_pdata,
121 },
122};
123
124static struct resource s5p6450_i2s2_resource[] = {
Tushar Behera5e9cf652012-05-12 16:12:30 +0900125 [0] = DEFINE_RES_MEM(S5P6450_PA_I2S2, SZ_256),
126 [1] = DEFINE_RES_DMA(DMACH_I2S2_TX),
127 [2] = DEFINE_RES_DMA(DMACH_I2S2_RX),
Rajeshwari Shindee0b9c882010-12-21 09:44:42 +0900128};
129
130struct platform_device s5p6450_device_iis2 = {
131 .name = "samsung-i2s",
132 .id = 2,
133 .num_resources = ARRAY_SIZE(s5p6450_i2s2_resource),
134 .resource = s5p6450_i2s2_resource,
135 .dev = {
136 .platform_data = &s5p6450_i2s_pdata,
Kukjin Kime661faa2010-09-08 19:21:23 +0900137 },
138};
139
140/* PCM Controller platform_devices */
141
142static int s5p6440_pcm_cfg_gpio(struct platform_device *pdev)
143{
144 switch (pdev->id) {
145 case 0:
Ben Dooksaf94e572010-10-01 13:45:54 +0900146 s3c_gpio_cfgpin_range(S5P6440_GPR(6), 3, S3C_GPIO_SFN(2));
147 s3c_gpio_cfgpin_range(S5P6440_GPR(13), 2, S3C_GPIO_SFN(2));
Kukjin Kime661faa2010-09-08 19:21:23 +0900148 break;
149
150 default:
151 printk(KERN_DEBUG "Invalid PCM Controller number!");
152 return -EINVAL;
153 }
154
155 return 0;
156}
157
158static struct s3c_audio_pdata s5p6440_pcm_pdata = {
159 .cfg_gpio = s5p6440_pcm_cfg_gpio,
160};
161
162static struct resource s5p6440_pcm0_resource[] = {
Tushar Behera5e9cf652012-05-12 16:12:30 +0900163 [0] = DEFINE_RES_MEM(S5P64X0_PA_PCM, SZ_256),
164 [1] = DEFINE_RES_DMA(DMACH_PCM0_TX),
165 [2] = DEFINE_RES_DMA(DMACH_PCM0_RX),
Kukjin Kime661faa2010-09-08 19:21:23 +0900166};
167
168struct platform_device s5p6440_device_pcm = {
169 .name = "samsung-pcm",
170 .id = 0,
171 .num_resources = ARRAY_SIZE(s5p6440_pcm0_resource),
172 .resource = s5p6440_pcm0_resource,
173 .dev = {
174 .platform_data = &s5p6440_pcm_pdata,
175 },
176};