Jassi Brar | 070c808 | 2010-05-18 16:02:50 +0900 | [diff] [blame] | 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> |
| 13 | |
| 14 | #include <plat/gpio-cfg.h> |
| 15 | #include <plat/audio.h> |
| 16 | |
| 17 | #include <mach/gpio.h> |
| 18 | #include <mach/map.h> |
| 19 | #include <mach/dma.h> |
| 20 | #include <mach/irqs.h> |
| 21 | |
| 22 | static int s5p6442_cfg_i2s(struct platform_device *pdev) |
| 23 | { |
| 24 | /* configure GPIO for i2s port */ |
| 25 | switch (pdev->id) { |
| 26 | case 1: |
| 27 | s3c_gpio_cfgpin(S5P6442_GPC1(0), S3C_GPIO_SFN(2)); |
| 28 | s3c_gpio_cfgpin(S5P6442_GPC1(1), S3C_GPIO_SFN(2)); |
| 29 | s3c_gpio_cfgpin(S5P6442_GPC1(2), S3C_GPIO_SFN(2)); |
| 30 | s3c_gpio_cfgpin(S5P6442_GPC1(3), S3C_GPIO_SFN(2)); |
| 31 | s3c_gpio_cfgpin(S5P6442_GPC1(4), S3C_GPIO_SFN(2)); |
| 32 | break; |
| 33 | |
| 34 | case -1: |
| 35 | s3c_gpio_cfgpin(S5P6442_GPC0(0), S3C_GPIO_SFN(2)); |
| 36 | s3c_gpio_cfgpin(S5P6442_GPC0(1), S3C_GPIO_SFN(2)); |
| 37 | s3c_gpio_cfgpin(S5P6442_GPC0(2), S3C_GPIO_SFN(2)); |
| 38 | s3c_gpio_cfgpin(S5P6442_GPC0(3), S3C_GPIO_SFN(2)); |
| 39 | s3c_gpio_cfgpin(S5P6442_GPC0(4), S3C_GPIO_SFN(2)); |
| 40 | break; |
| 41 | |
| 42 | default: |
| 43 | printk(KERN_ERR "Invalid Device %d\n", pdev->id); |
| 44 | return -EINVAL; |
| 45 | } |
| 46 | |
| 47 | return 0; |
| 48 | } |
| 49 | |
| 50 | static struct s3c_audio_pdata s3c_i2s_pdata = { |
| 51 | .cfg_gpio = s5p6442_cfg_i2s, |
| 52 | }; |
| 53 | |
| 54 | static struct resource s5p6442_iis0_resource[] = { |
| 55 | [0] = { |
| 56 | .start = S5P6442_PA_I2S0, |
| 57 | .end = S5P6442_PA_I2S0 + 0x100 - 1, |
| 58 | .flags = IORESOURCE_MEM, |
| 59 | }, |
| 60 | [1] = { |
| 61 | .start = DMACH_I2S0_TX, |
| 62 | .end = DMACH_I2S0_TX, |
| 63 | .flags = IORESOURCE_DMA, |
| 64 | }, |
| 65 | [2] = { |
| 66 | .start = DMACH_I2S0_RX, |
| 67 | .end = DMACH_I2S0_RX, |
| 68 | .flags = IORESOURCE_DMA, |
| 69 | }, |
| 70 | }; |
| 71 | |
| 72 | struct platform_device s5p6442_device_iis0 = { |
| 73 | .name = "s3c64xx-iis-v4", |
| 74 | .id = -1, |
| 75 | .num_resources = ARRAY_SIZE(s5p6442_iis0_resource), |
| 76 | .resource = s5p6442_iis0_resource, |
| 77 | .dev = { |
| 78 | .platform_data = &s3c_i2s_pdata, |
| 79 | }, |
| 80 | }; |
| 81 | |
| 82 | static struct resource s5p6442_iis1_resource[] = { |
| 83 | [0] = { |
| 84 | .start = S5P6442_PA_I2S1, |
| 85 | .end = S5P6442_PA_I2S1 + 0x100 - 1, |
| 86 | .flags = IORESOURCE_MEM, |
| 87 | }, |
| 88 | [1] = { |
| 89 | .start = DMACH_I2S1_TX, |
| 90 | .end = DMACH_I2S1_TX, |
| 91 | .flags = IORESOURCE_DMA, |
| 92 | }, |
| 93 | [2] = { |
| 94 | .start = DMACH_I2S1_RX, |
| 95 | .end = DMACH_I2S1_RX, |
| 96 | .flags = IORESOURCE_DMA, |
| 97 | }, |
| 98 | }; |
| 99 | |
| 100 | struct platform_device s5p6442_device_iis1 = { |
| 101 | .name = "s3c64xx-iis", |
| 102 | .id = 1, |
| 103 | .num_resources = ARRAY_SIZE(s5p6442_iis1_resource), |
| 104 | .resource = s5p6442_iis1_resource, |
| 105 | .dev = { |
| 106 | .platform_data = &s3c_i2s_pdata, |
| 107 | }, |
| 108 | }; |
| 109 | |
| 110 | /* PCM Controller platform_devices */ |
| 111 | |
| 112 | static int s5p6442_pcm_cfg_gpio(struct platform_device *pdev) |
| 113 | { |
| 114 | switch (pdev->id) { |
| 115 | case 0: |
| 116 | s3c_gpio_cfgpin(S5P6442_GPC0(0), S3C_GPIO_SFN(3)); |
| 117 | s3c_gpio_cfgpin(S5P6442_GPC0(1), S3C_GPIO_SFN(3)); |
| 118 | s3c_gpio_cfgpin(S5P6442_GPC0(2), S3C_GPIO_SFN(3)); |
| 119 | s3c_gpio_cfgpin(S5P6442_GPC0(3), S3C_GPIO_SFN(3)); |
| 120 | s3c_gpio_cfgpin(S5P6442_GPC0(4), S3C_GPIO_SFN(3)); |
| 121 | break; |
| 122 | |
| 123 | case 1: |
| 124 | s3c_gpio_cfgpin(S5P6442_GPC1(0), S3C_GPIO_SFN(3)); |
| 125 | s3c_gpio_cfgpin(S5P6442_GPC1(1), S3C_GPIO_SFN(3)); |
| 126 | s3c_gpio_cfgpin(S5P6442_GPC1(2), S3C_GPIO_SFN(3)); |
| 127 | s3c_gpio_cfgpin(S5P6442_GPC1(3), S3C_GPIO_SFN(3)); |
| 128 | s3c_gpio_cfgpin(S5P6442_GPC1(4), S3C_GPIO_SFN(3)); |
| 129 | break; |
| 130 | |
| 131 | default: |
| 132 | printk(KERN_DEBUG "Invalid PCM Controller number!"); |
| 133 | return -EINVAL; |
| 134 | } |
| 135 | |
| 136 | return 0; |
| 137 | } |
| 138 | |
| 139 | static struct s3c_audio_pdata s3c_pcm_pdata = { |
| 140 | .cfg_gpio = s5p6442_pcm_cfg_gpio, |
| 141 | }; |
| 142 | |
| 143 | static struct resource s5p6442_pcm0_resource[] = { |
| 144 | [0] = { |
| 145 | .start = S5P6442_PA_PCM0, |
| 146 | .end = S5P6442_PA_PCM0 + 0x100 - 1, |
| 147 | .flags = IORESOURCE_MEM, |
| 148 | }, |
| 149 | [1] = { |
| 150 | .start = DMACH_PCM0_TX, |
| 151 | .end = DMACH_PCM0_TX, |
| 152 | .flags = IORESOURCE_DMA, |
| 153 | }, |
| 154 | [2] = { |
| 155 | .start = DMACH_PCM0_RX, |
| 156 | .end = DMACH_PCM0_RX, |
| 157 | .flags = IORESOURCE_DMA, |
| 158 | }, |
| 159 | }; |
| 160 | |
| 161 | struct platform_device s5p6442_device_pcm0 = { |
| 162 | .name = "samsung-pcm", |
| 163 | .id = 0, |
| 164 | .num_resources = ARRAY_SIZE(s5p6442_pcm0_resource), |
| 165 | .resource = s5p6442_pcm0_resource, |
| 166 | .dev = { |
| 167 | .platform_data = &s3c_pcm_pdata, |
| 168 | }, |
| 169 | }; |
| 170 | |
| 171 | static struct resource s5p6442_pcm1_resource[] = { |
| 172 | [0] = { |
| 173 | .start = S5P6442_PA_PCM1, |
| 174 | .end = S5P6442_PA_PCM1 + 0x100 - 1, |
| 175 | .flags = IORESOURCE_MEM, |
| 176 | }, |
| 177 | [1] = { |
| 178 | .start = DMACH_PCM1_TX, |
| 179 | .end = DMACH_PCM1_TX, |
| 180 | .flags = IORESOURCE_DMA, |
| 181 | }, |
| 182 | [2] = { |
| 183 | .start = DMACH_PCM1_RX, |
| 184 | .end = DMACH_PCM1_RX, |
| 185 | .flags = IORESOURCE_DMA, |
| 186 | }, |
| 187 | }; |
| 188 | |
| 189 | struct platform_device s5p6442_device_pcm1 = { |
| 190 | .name = "samsung-pcm", |
| 191 | .id = 1, |
| 192 | .num_resources = ARRAY_SIZE(s5p6442_pcm1_resource), |
| 193 | .resource = s5p6442_pcm1_resource, |
| 194 | .dev = { |
| 195 | .platform_data = &s3c_pcm_pdata, |
| 196 | }, |
| 197 | }; |