Kukjin Kim | e661faa | 2010-09-08 19:21:23 +0900 | [diff] [blame] | 1 | /* 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 Bergmann | 436d42c | 2012-08-24 15:22:12 +0200 | [diff] [blame^] | 16 | #include <linux/platform_data/asoc-s3c.h> |
Kukjin Kim | e661faa | 2010-09-08 19:21:23 +0900 | [diff] [blame] | 17 | |
| 18 | #include <mach/map.h> |
| 19 | #include <mach/dma.h> |
| 20 | #include <mach/irqs.h> |
| 21 | |
Jassi Brar | d9a93c3 | 2010-11-19 08:49:44 +0900 | [diff] [blame] | 22 | static const char *rclksrc[] = { |
| 23 | [0] = "iis", |
| 24 | [1] = "sclk_audio2", |
| 25 | }; |
| 26 | |
Rajeshwari Shinde | e0b9c88 | 2010-12-21 09:44:42 +0900 | [diff] [blame] | 27 | static int s5p6440_cfg_i2s(struct platform_device *pdev) |
Kukjin Kim | e661faa | 2010-09-08 19:21:23 +0900 | [diff] [blame] | 28 | { |
Kukjin Kim | e661faa | 2010-09-08 19:21:23 +0900 | [diff] [blame] | 29 | switch (pdev->id) { |
Jassi Brar | d9a93c3 | 2010-11-19 08:49:44 +0900 | [diff] [blame] | 30 | case 0: |
Rajeshwari Shinde | e0b9c88 | 2010-12-21 09:44:42 +0900 | [diff] [blame] | 31 | 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 Kim | e661faa | 2010-09-08 19:21:23 +0900 | [diff] [blame] | 34 | break; |
Kukjin Kim | e661faa | 2010-09-08 19:21:23 +0900 | [diff] [blame] | 35 | default: |
| 36 | printk(KERN_ERR "Invalid Device %d\n", pdev->id); |
| 37 | return -EINVAL; |
| 38 | } |
| 39 | |
| 40 | return 0; |
| 41 | } |
| 42 | |
Rajeshwari Shinde | e0b9c88 | 2010-12-21 09:44:42 +0900 | [diff] [blame] | 43 | static struct s3c_audio_pdata s5p6440_i2s_pdata = { |
| 44 | .cfg_gpio = s5p6440_cfg_i2s, |
Jassi Brar | d9a93c3 | 2010-11-19 08:49:44 +0900 | [diff] [blame] | 45 | .type = { |
| 46 | .i2s = { |
| 47 | .quirks = QUIRK_PRI_6CHAN, |
| 48 | .src_clk = rclksrc, |
| 49 | }, |
| 50 | }, |
Kukjin Kim | e661faa | 2010-09-08 19:21:23 +0900 | [diff] [blame] | 51 | }; |
| 52 | |
Rajeshwari Shinde | e0b9c88 | 2010-12-21 09:44:42 +0900 | [diff] [blame] | 53 | static struct resource s5p64x0_i2s0_resource[] = { |
Tushar Behera | 5e9cf65 | 2012-05-12 16:12:30 +0900 | [diff] [blame] | 54 | [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 Kim | e661faa | 2010-09-08 19:21:23 +0900 | [diff] [blame] | 57 | }; |
| 58 | |
| 59 | struct platform_device s5p6440_device_iis = { |
Jassi Brar | d9a93c3 | 2010-11-19 08:49:44 +0900 | [diff] [blame] | 60 | .name = "samsung-i2s", |
| 61 | .id = 0, |
Rajeshwari Shinde | e0b9c88 | 2010-12-21 09:44:42 +0900 | [diff] [blame] | 62 | .num_resources = ARRAY_SIZE(s5p64x0_i2s0_resource), |
| 63 | .resource = s5p64x0_i2s0_resource, |
Kukjin Kim | e661faa | 2010-09-08 19:21:23 +0900 | [diff] [blame] | 64 | .dev = { |
Rajeshwari Shinde | e0b9c88 | 2010-12-21 09:44:42 +0900 | [diff] [blame] | 65 | .platform_data = &s5p6440_i2s_pdata, |
| 66 | }, |
| 67 | }; |
| 68 | |
| 69 | static 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 | |
| 91 | static 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 Kim | e661faa | 2010-09-08 19:21:23 +0900 | [diff] [blame] | 98 | }, |
| 99 | }; |
| 100 | |
| 101 | struct platform_device s5p6450_device_iis0 = { |
Jassi Brar | d9a93c3 | 2010-11-19 08:49:44 +0900 | [diff] [blame] | 102 | .name = "samsung-i2s", |
| 103 | .id = 0, |
Rajeshwari Shinde | e0b9c88 | 2010-12-21 09:44:42 +0900 | [diff] [blame] | 104 | .num_resources = ARRAY_SIZE(s5p64x0_i2s0_resource), |
| 105 | .resource = s5p64x0_i2s0_resource, |
Kukjin Kim | e661faa | 2010-09-08 19:21:23 +0900 | [diff] [blame] | 106 | .dev = { |
Rajeshwari Shinde | e0b9c88 | 2010-12-21 09:44:42 +0900 | [diff] [blame] | 107 | .platform_data = &s5p6450_i2s0_pdata, |
| 108 | }, |
| 109 | }; |
| 110 | |
| 111 | static 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 | |
| 120 | static struct resource s5p6450_i2s1_resource[] = { |
Tushar Behera | 5e9cf65 | 2012-05-12 16:12:30 +0900 | [diff] [blame] | 121 | [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 Shinde | e0b9c88 | 2010-12-21 09:44:42 +0900 | [diff] [blame] | 124 | }; |
| 125 | |
| 126 | struct 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 | |
| 136 | static struct resource s5p6450_i2s2_resource[] = { |
Tushar Behera | 5e9cf65 | 2012-05-12 16:12:30 +0900 | [diff] [blame] | 137 | [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 Shinde | e0b9c88 | 2010-12-21 09:44:42 +0900 | [diff] [blame] | 140 | }; |
| 141 | |
| 142 | struct 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 Kim | e661faa | 2010-09-08 19:21:23 +0900 | [diff] [blame] | 149 | }, |
| 150 | }; |
| 151 | |
| 152 | /* PCM Controller platform_devices */ |
| 153 | |
| 154 | static int s5p6440_pcm_cfg_gpio(struct platform_device *pdev) |
| 155 | { |
| 156 | switch (pdev->id) { |
| 157 | case 0: |
Ben Dooks | af94e57 | 2010-10-01 13:45:54 +0900 | [diff] [blame] | 158 | 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 Kim | e661faa | 2010-09-08 19:21:23 +0900 | [diff] [blame] | 160 | break; |
| 161 | |
| 162 | default: |
| 163 | printk(KERN_DEBUG "Invalid PCM Controller number!"); |
| 164 | return -EINVAL; |
| 165 | } |
| 166 | |
| 167 | return 0; |
| 168 | } |
| 169 | |
| 170 | static struct s3c_audio_pdata s5p6440_pcm_pdata = { |
| 171 | .cfg_gpio = s5p6440_pcm_cfg_gpio, |
| 172 | }; |
| 173 | |
| 174 | static struct resource s5p6440_pcm0_resource[] = { |
Tushar Behera | 5e9cf65 | 2012-05-12 16:12:30 +0900 | [diff] [blame] | 175 | [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 Kim | e661faa | 2010-09-08 19:21:23 +0900 | [diff] [blame] | 178 | }; |
| 179 | |
| 180 | struct 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 | }; |