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> |
| 16 | #include <plat/audio.h> |
| 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 | |
| 27 | static int s5p64x0_cfg_i2s(struct platform_device *pdev) |
Kukjin Kim | e661faa | 2010-09-08 19:21:23 +0900 | [diff] [blame] | 28 | { |
| 29 | /* configure GPIO for i2s port */ |
| 30 | switch (pdev->id) { |
Jassi Brar | d9a93c3 | 2010-11-19 08:49:44 +0900 | [diff] [blame^] | 31 | case 0: |
Ben Dooks | af94e57 | 2010-10-01 13:45:54 +0900 | [diff] [blame] | 32 | s3c_gpio_cfgpin_range(S5P6440_GPR(4), 5, S3C_GPIO_SFN(5)); |
| 33 | s3c_gpio_cfgpin_range(S5P6440_GPR(13), 2, 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 | |
Jassi Brar | d9a93c3 | 2010-11-19 08:49:44 +0900 | [diff] [blame^] | 43 | static struct s3c_audio_pdata s5p64x0_i2s_pdata = { |
| 44 | .cfg_gpio = s5p64x0_cfg_i2s, |
| 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 | |
| 53 | static struct resource s5p64x0_iis0_resource[] = { |
| 54 | [0] = { |
| 55 | .start = S5P64X0_PA_I2S, |
| 56 | .end = S5P64X0_PA_I2S + 0x100 - 1, |
| 57 | .flags = IORESOURCE_MEM, |
| 58 | }, |
| 59 | [1] = { |
| 60 | .start = DMACH_I2S0_TX, |
| 61 | .end = DMACH_I2S0_TX, |
| 62 | .flags = IORESOURCE_DMA, |
| 63 | }, |
| 64 | [2] = { |
| 65 | .start = DMACH_I2S0_RX, |
| 66 | .end = DMACH_I2S0_RX, |
| 67 | .flags = IORESOURCE_DMA, |
| 68 | }, |
| 69 | }; |
| 70 | |
| 71 | struct platform_device s5p6440_device_iis = { |
Jassi Brar | d9a93c3 | 2010-11-19 08:49:44 +0900 | [diff] [blame^] | 72 | .name = "samsung-i2s", |
| 73 | .id = 0, |
Kukjin Kim | e661faa | 2010-09-08 19:21:23 +0900 | [diff] [blame] | 74 | .num_resources = ARRAY_SIZE(s5p64x0_iis0_resource), |
| 75 | .resource = s5p64x0_iis0_resource, |
| 76 | .dev = { |
Jassi Brar | d9a93c3 | 2010-11-19 08:49:44 +0900 | [diff] [blame^] | 77 | .platform_data = &s5p64x0_i2s_pdata, |
Kukjin Kim | e661faa | 2010-09-08 19:21:23 +0900 | [diff] [blame] | 78 | }, |
| 79 | }; |
| 80 | |
| 81 | struct platform_device s5p6450_device_iis0 = { |
Jassi Brar | d9a93c3 | 2010-11-19 08:49:44 +0900 | [diff] [blame^] | 82 | .name = "samsung-i2s", |
| 83 | .id = 0, |
Kukjin Kim | e661faa | 2010-09-08 19:21:23 +0900 | [diff] [blame] | 84 | .num_resources = ARRAY_SIZE(s5p64x0_iis0_resource), |
| 85 | .resource = s5p64x0_iis0_resource, |
| 86 | .dev = { |
Jassi Brar | d9a93c3 | 2010-11-19 08:49:44 +0900 | [diff] [blame^] | 87 | .platform_data = &s5p64x0_i2s_pdata, |
Kukjin Kim | e661faa | 2010-09-08 19:21:23 +0900 | [diff] [blame] | 88 | }, |
| 89 | }; |
| 90 | |
| 91 | /* PCM Controller platform_devices */ |
| 92 | |
| 93 | static int s5p6440_pcm_cfg_gpio(struct platform_device *pdev) |
| 94 | { |
| 95 | switch (pdev->id) { |
| 96 | case 0: |
Ben Dooks | af94e57 | 2010-10-01 13:45:54 +0900 | [diff] [blame] | 97 | s3c_gpio_cfgpin_range(S5P6440_GPR(6), 3, S3C_GPIO_SFN(2)); |
| 98 | s3c_gpio_cfgpin_range(S5P6440_GPR(13), 2, S3C_GPIO_SFN(2)); |
Kukjin Kim | e661faa | 2010-09-08 19:21:23 +0900 | [diff] [blame] | 99 | break; |
| 100 | |
| 101 | default: |
| 102 | printk(KERN_DEBUG "Invalid PCM Controller number!"); |
| 103 | return -EINVAL; |
| 104 | } |
| 105 | |
| 106 | return 0; |
| 107 | } |
| 108 | |
| 109 | static struct s3c_audio_pdata s5p6440_pcm_pdata = { |
| 110 | .cfg_gpio = s5p6440_pcm_cfg_gpio, |
| 111 | }; |
| 112 | |
| 113 | static struct resource s5p6440_pcm0_resource[] = { |
| 114 | [0] = { |
| 115 | .start = S5P64X0_PA_PCM, |
| 116 | .end = S5P64X0_PA_PCM + 0x100 - 1, |
| 117 | .flags = IORESOURCE_MEM, |
| 118 | }, |
| 119 | [1] = { |
| 120 | .start = DMACH_PCM0_TX, |
| 121 | .end = DMACH_PCM0_TX, |
| 122 | .flags = IORESOURCE_DMA, |
| 123 | }, |
| 124 | [2] = { |
| 125 | .start = DMACH_PCM0_RX, |
| 126 | .end = DMACH_PCM0_RX, |
| 127 | .flags = IORESOURCE_DMA, |
| 128 | }, |
| 129 | }; |
| 130 | |
| 131 | struct platform_device s5p6440_device_pcm = { |
| 132 | .name = "samsung-pcm", |
| 133 | .id = 0, |
| 134 | .num_resources = ARRAY_SIZE(s5p6440_pcm0_resource), |
| 135 | .resource = s5p6440_pcm0_resource, |
| 136 | .dev = { |
| 137 | .platform_data = &s5p6440_pcm_pdata, |
| 138 | }, |
| 139 | }; |