]> rtime.felk.cvut.cz Git - can-eth-gw-linux.git/blob - arch/arm/mach-ux500/board-mop500-audio.c
Merge tag 'multiplatform' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc
[can-eth-gw-linux.git] / arch / arm / mach-ux500 / board-mop500-audio.c
1 /*
2  * Copyright (C) ST-Ericsson SA 2010
3  *
4  * License terms: GNU General Public License (GPL), version 2
5  */
6
7 #include <linux/platform_device.h>
8 #include <linux/init.h>
9 #include <linux/gpio.h>
10 #include <linux/platform_data/pinctrl-nomadik.h>
11 #include <linux/platform_data/dma-ste-dma40.h>
12
13 #include <mach/devices.h>
14 #include <mach/hardware.h>
15 #include <mach/irqs.h>
16 #include <mach/msp.h>
17
18 #include "ste-dma40-db8500.h"
19 #include "board-mop500.h"
20 #include "devices-db8500.h"
21 #include "pins-db8500.h"
22
23 static struct stedma40_chan_cfg msp0_dma_rx = {
24         .high_priority = true,
25         .dir = STEDMA40_PERIPH_TO_MEM,
26
27         .src_dev_type = DB8500_DMA_DEV31_MSP0_RX_SLIM0_CH0_RX,
28         .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
29
30         .src_info.psize = STEDMA40_PSIZE_LOG_4,
31         .dst_info.psize = STEDMA40_PSIZE_LOG_4,
32
33         /* data_width is set during configuration */
34 };
35
36 static struct stedma40_chan_cfg msp0_dma_tx = {
37         .high_priority = true,
38         .dir = STEDMA40_MEM_TO_PERIPH,
39
40         .src_dev_type = STEDMA40_DEV_DST_MEMORY,
41         .dst_dev_type = DB8500_DMA_DEV31_MSP0_TX_SLIM0_CH0_TX,
42
43         .src_info.psize = STEDMA40_PSIZE_LOG_4,
44         .dst_info.psize = STEDMA40_PSIZE_LOG_4,
45
46         /* data_width is set during configuration */
47 };
48
49 struct msp_i2s_platform_data msp0_platform_data = {
50         .id = MSP_I2S_0,
51         .msp_i2s_dma_rx = &msp0_dma_rx,
52         .msp_i2s_dma_tx = &msp0_dma_tx,
53 };
54
55 static struct stedma40_chan_cfg msp1_dma_rx = {
56         .high_priority = true,
57         .dir = STEDMA40_PERIPH_TO_MEM,
58
59         .src_dev_type = DB8500_DMA_DEV30_MSP3_RX,
60         .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
61
62         .src_info.psize = STEDMA40_PSIZE_LOG_4,
63         .dst_info.psize = STEDMA40_PSIZE_LOG_4,
64
65         /* data_width is set during configuration */
66 };
67
68 static struct stedma40_chan_cfg msp1_dma_tx = {
69         .high_priority = true,
70         .dir = STEDMA40_MEM_TO_PERIPH,
71
72         .src_dev_type = STEDMA40_DEV_DST_MEMORY,
73         .dst_dev_type = DB8500_DMA_DEV30_MSP1_TX,
74
75         .src_info.psize = STEDMA40_PSIZE_LOG_4,
76         .dst_info.psize = STEDMA40_PSIZE_LOG_4,
77
78         /* data_width is set during configuration */
79 };
80
81 struct msp_i2s_platform_data msp1_platform_data = {
82         .id = MSP_I2S_1,
83         .msp_i2s_dma_rx = NULL,
84         .msp_i2s_dma_tx = &msp1_dma_tx,
85 };
86
87 static struct stedma40_chan_cfg msp2_dma_rx = {
88         .high_priority = true,
89         .dir = STEDMA40_PERIPH_TO_MEM,
90
91         .src_dev_type = DB8500_DMA_DEV14_MSP2_RX,
92         .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
93
94         /* MSP2 DMA doesn't work with PSIZE == 4 on DB8500v2 */
95         .src_info.psize = STEDMA40_PSIZE_LOG_1,
96         .dst_info.psize = STEDMA40_PSIZE_LOG_1,
97
98         /* data_width is set during configuration */
99 };
100
101 static struct stedma40_chan_cfg msp2_dma_tx = {
102         .high_priority = true,
103         .dir = STEDMA40_MEM_TO_PERIPH,
104
105         .src_dev_type = STEDMA40_DEV_DST_MEMORY,
106         .dst_dev_type = DB8500_DMA_DEV14_MSP2_TX,
107
108         .src_info.psize = STEDMA40_PSIZE_LOG_4,
109         .dst_info.psize = STEDMA40_PSIZE_LOG_4,
110
111         .use_fixed_channel = true,
112         .phy_channel = 1,
113
114         /* data_width is set during configuration */
115 };
116
117 static struct platform_device *db8500_add_msp_i2s(struct device *parent,
118                         int id,
119                         resource_size_t base, int irq,
120                         struct msp_i2s_platform_data *pdata)
121 {
122         struct platform_device *pdev;
123         struct resource res[] = {
124                 DEFINE_RES_MEM(base, SZ_4K),
125                 DEFINE_RES_IRQ(irq),
126         };
127
128         pr_info("Register platform-device 'ux500-msp-i2s', id %d, irq %d\n",
129                 id, irq);
130         pdev = platform_device_register_resndata(parent, "ux500-msp-i2s", id,
131                                                 res, ARRAY_SIZE(res),
132                                                 pdata, sizeof(*pdata));
133         if (!pdev) {
134                 pr_err("Failed to register platform-device 'ux500-msp-i2s.%d'!\n",
135                         id);
136                 return NULL;
137         }
138
139         return pdev;
140 }
141
142 /* Platform device for ASoC MOP500 machine */
143 static struct platform_device snd_soc_mop500 = {
144         .name = "snd-soc-mop500",
145         .id = 0,
146         .dev = {
147                 .platform_data = NULL,
148         },
149 };
150
151 struct msp_i2s_platform_data msp2_platform_data = {
152         .id = MSP_I2S_2,
153         .msp_i2s_dma_rx = &msp2_dma_rx,
154         .msp_i2s_dma_tx = &msp2_dma_tx,
155 };
156
157 struct msp_i2s_platform_data msp3_platform_data = {
158         .id             = MSP_I2S_3,
159         .msp_i2s_dma_rx = &msp1_dma_rx,
160         .msp_i2s_dma_tx = NULL,
161 };
162
163 void mop500_audio_init(struct device *parent)
164 {
165         pr_info("%s: Register platform-device 'snd-soc-mop500'.\n", __func__);
166         platform_device_register(&snd_soc_mop500);
167
168         pr_info("Initialize MSP I2S-devices.\n");
169         db8500_add_msp_i2s(parent, 0, U8500_MSP0_BASE, IRQ_DB8500_MSP0,
170                            &msp0_platform_data);
171         db8500_add_msp_i2s(parent, 1, U8500_MSP1_BASE, IRQ_DB8500_MSP1,
172                            &msp1_platform_data);
173         db8500_add_msp_i2s(parent, 2, U8500_MSP2_BASE, IRQ_DB8500_MSP2,
174                            &msp2_platform_data);
175         db8500_add_msp_i2s(parent, 3, U8500_MSP3_BASE, IRQ_DB8500_MSP1,
176                            &msp3_platform_data);
177 }