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 | |
Rajeshwari Shinde | e0b9c88 | 2010-12-21 09:44:42 +0900 | [diff] [blame] | 22 | static int s5p6440_cfg_i2s(struct platform_device *pdev) |
Kukjin Kim | e661faa | 2010-09-08 19:21:23 +0900 | [diff] [blame] | 23 | { |
Kukjin Kim | e661faa | 2010-09-08 19:21:23 +0900 | [diff] [blame] | 24 | switch (pdev->id) { |
Jassi Brar | d9a93c3 | 2010-11-19 08:49:44 +0900 | [diff] [blame] | 25 | case 0: |
Rajeshwari Shinde | e0b9c88 | 2010-12-21 09:44:42 +0900 | [diff] [blame] | 26 | 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 Kim | e661faa | 2010-09-08 19:21:23 +0900 | [diff] [blame] | 29 | break; |
Kukjin Kim | e661faa | 2010-09-08 19:21:23 +0900 | [diff] [blame] | 30 | default: |
| 31 | printk(KERN_ERR "Invalid Device %d\n", pdev->id); |
| 32 | return -EINVAL; |
| 33 | } |
| 34 | |
| 35 | return 0; |
| 36 | } |
| 37 | |
Rajeshwari Shinde | e0b9c88 | 2010-12-21 09:44:42 +0900 | [diff] [blame] | 38 | static struct s3c_audio_pdata s5p6440_i2s_pdata = { |
| 39 | .cfg_gpio = s5p6440_cfg_i2s, |
Jassi Brar | d9a93c3 | 2010-11-19 08:49:44 +0900 | [diff] [blame] | 40 | .type = { |
| 41 | .i2s = { |
| 42 | .quirks = QUIRK_PRI_6CHAN, |
Jassi Brar | d9a93c3 | 2010-11-19 08:49:44 +0900 | [diff] [blame] | 43 | }, |
| 44 | }, |
Kukjin Kim | e661faa | 2010-09-08 19:21:23 +0900 | [diff] [blame] | 45 | }; |
| 46 | |
Rajeshwari Shinde | e0b9c88 | 2010-12-21 09:44:42 +0900 | [diff] [blame] | 47 | static struct resource s5p64x0_i2s0_resource[] = { |
Tushar Behera | 5e9cf65 | 2012-05-12 16:12:30 +0900 | [diff] [blame] | 48 | [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 Kim | e661faa | 2010-09-08 19:21:23 +0900 | [diff] [blame] | 51 | }; |
| 52 | |
| 53 | struct platform_device s5p6440_device_iis = { |
Jassi Brar | d9a93c3 | 2010-11-19 08:49:44 +0900 | [diff] [blame] | 54 | .name = "samsung-i2s", |
| 55 | .id = 0, |
Rajeshwari Shinde | e0b9c88 | 2010-12-21 09:44:42 +0900 | [diff] [blame] | 56 | .num_resources = ARRAY_SIZE(s5p64x0_i2s0_resource), |
| 57 | .resource = s5p64x0_i2s0_resource, |
Kukjin Kim | e661faa | 2010-09-08 19:21:23 +0900 | [diff] [blame] | 58 | .dev = { |
Rajeshwari Shinde | e0b9c88 | 2010-12-21 09:44:42 +0900 | [diff] [blame] | 59 | .platform_data = &s5p6440_i2s_pdata, |
| 60 | }, |
| 61 | }; |
| 62 | |
| 63 | static 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 | |
| 85 | static struct s3c_audio_pdata s5p6450_i2s0_pdata = { |
| 86 | .cfg_gpio = s5p6450_cfg_i2s, |
| 87 | .type = { |
| 88 | .i2s = { |
| 89 | .quirks = QUIRK_PRI_6CHAN, |
Rajeshwari Shinde | e0b9c88 | 2010-12-21 09:44:42 +0900 | [diff] [blame] | 90 | }, |
Kukjin Kim | e661faa | 2010-09-08 19:21:23 +0900 | [diff] [blame] | 91 | }, |
| 92 | }; |
| 93 | |
| 94 | struct platform_device s5p6450_device_iis0 = { |
Jassi Brar | d9a93c3 | 2010-11-19 08:49:44 +0900 | [diff] [blame] | 95 | .name = "samsung-i2s", |
| 96 | .id = 0, |
Rajeshwari Shinde | e0b9c88 | 2010-12-21 09:44:42 +0900 | [diff] [blame] | 97 | .num_resources = ARRAY_SIZE(s5p64x0_i2s0_resource), |
| 98 | .resource = s5p64x0_i2s0_resource, |
Kukjin Kim | e661faa | 2010-09-08 19:21:23 +0900 | [diff] [blame] | 99 | .dev = { |
Rajeshwari Shinde | e0b9c88 | 2010-12-21 09:44:42 +0900 | [diff] [blame] | 100 | .platform_data = &s5p6450_i2s0_pdata, |
| 101 | }, |
| 102 | }; |
| 103 | |
| 104 | static struct s3c_audio_pdata s5p6450_i2s_pdata = { |
| 105 | .cfg_gpio = s5p6450_cfg_i2s, |
Rajeshwari Shinde | e0b9c88 | 2010-12-21 09:44:42 +0900 | [diff] [blame] | 106 | }; |
| 107 | |
| 108 | static struct resource s5p6450_i2s1_resource[] = { |
Tushar Behera | 5e9cf65 | 2012-05-12 16:12:30 +0900 | [diff] [blame] | 109 | [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 Shinde | e0b9c88 | 2010-12-21 09:44:42 +0900 | [diff] [blame] | 112 | }; |
| 113 | |
| 114 | struct 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 | |
| 124 | static struct resource s5p6450_i2s2_resource[] = { |
Tushar Behera | 5e9cf65 | 2012-05-12 16:12:30 +0900 | [diff] [blame] | 125 | [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 Shinde | e0b9c88 | 2010-12-21 09:44:42 +0900 | [diff] [blame] | 128 | }; |
| 129 | |
| 130 | struct 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 Kim | e661faa | 2010-09-08 19:21:23 +0900 | [diff] [blame] | 137 | }, |
| 138 | }; |
| 139 | |
| 140 | /* PCM Controller platform_devices */ |
| 141 | |
| 142 | static int s5p6440_pcm_cfg_gpio(struct platform_device *pdev) |
| 143 | { |
| 144 | switch (pdev->id) { |
| 145 | case 0: |
Ben Dooks | af94e57 | 2010-10-01 13:45:54 +0900 | [diff] [blame] | 146 | 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 Kim | e661faa | 2010-09-08 19:21:23 +0900 | [diff] [blame] | 148 | break; |
| 149 | |
| 150 | default: |
| 151 | printk(KERN_DEBUG "Invalid PCM Controller number!"); |
| 152 | return -EINVAL; |
| 153 | } |
| 154 | |
| 155 | return 0; |
| 156 | } |
| 157 | |
| 158 | static struct s3c_audio_pdata s5p6440_pcm_pdata = { |
| 159 | .cfg_gpio = s5p6440_pcm_cfg_gpio, |
| 160 | }; |
| 161 | |
| 162 | static struct resource s5p6440_pcm0_resource[] = { |
Tushar Behera | 5e9cf65 | 2012-05-12 16:12:30 +0900 | [diff] [blame] | 163 | [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 Kim | e661faa | 2010-09-08 19:21:23 +0900 | [diff] [blame] | 166 | }; |
| 167 | |
| 168 | struct 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 | }; |