Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
board-mop500-audio.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) ST-Ericsson SA 2010
3  *
4  * License terms: GNU General Public License (GPL), version 2
5  */
6 
8 #include <linux/init.h>
9 #include <linux/gpio.h>
10 
11 #include <plat/gpio-nomadik.h>
12 #include <plat/pincfg.h>
13 #include <plat/ste_dma40.h>
14 
15 #include <mach/devices.h>
16 #include <mach/hardware.h>
17 #include <mach/irqs.h>
18 #include <mach/msp.h>
19 
20 #include "ste-dma40-db8500.h"
21 #include "board-mop500.h"
22 #include "devices-db8500.h"
23 #include "pins-db8500.h"
24 
25 static struct stedma40_chan_cfg msp0_dma_rx = {
26  .high_priority = true,
28 
30  .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
31 
32  .src_info.psize = STEDMA40_PSIZE_LOG_4,
33  .dst_info.psize = STEDMA40_PSIZE_LOG_4,
34 
35  /* data_width is set during configuration */
36 };
37 
38 static struct stedma40_chan_cfg msp0_dma_tx = {
39  .high_priority = true,
41 
42  .src_dev_type = STEDMA40_DEV_DST_MEMORY,
44 
45  .src_info.psize = STEDMA40_PSIZE_LOG_4,
46  .dst_info.psize = STEDMA40_PSIZE_LOG_4,
47 
48  /* data_width is set during configuration */
49 };
50 
52  .id = MSP_I2S_0,
53  .msp_i2s_dma_rx = &msp0_dma_rx,
54  .msp_i2s_dma_tx = &msp0_dma_tx,
55 };
56 
57 static struct stedma40_chan_cfg msp1_dma_rx = {
58  .high_priority = true,
60 
61  .src_dev_type = DB8500_DMA_DEV30_MSP3_RX,
62  .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
63 
64  .src_info.psize = STEDMA40_PSIZE_LOG_4,
65  .dst_info.psize = STEDMA40_PSIZE_LOG_4,
66 
67  /* data_width is set during configuration */
68 };
69 
70 static struct stedma40_chan_cfg msp1_dma_tx = {
71  .high_priority = true,
73 
74  .src_dev_type = STEDMA40_DEV_DST_MEMORY,
75  .dst_dev_type = DB8500_DMA_DEV30_MSP1_TX,
76 
77  .src_info.psize = STEDMA40_PSIZE_LOG_4,
78  .dst_info.psize = STEDMA40_PSIZE_LOG_4,
79 
80  /* data_width is set during configuration */
81 };
82 
84  .id = MSP_I2S_1,
85  .msp_i2s_dma_rx = NULL,
86  .msp_i2s_dma_tx = &msp1_dma_tx,
87 };
88 
89 static struct stedma40_chan_cfg msp2_dma_rx = {
90  .high_priority = true,
92 
93  .src_dev_type = DB8500_DMA_DEV14_MSP2_RX,
94  .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
95 
96  /* MSP2 DMA doesn't work with PSIZE == 4 on DB8500v2 */
97  .src_info.psize = STEDMA40_PSIZE_LOG_1,
98  .dst_info.psize = STEDMA40_PSIZE_LOG_1,
99 
100  /* data_width is set during configuration */
101 };
102 
103 static struct stedma40_chan_cfg msp2_dma_tx = {
104  .high_priority = true,
105  .dir = STEDMA40_MEM_TO_PERIPH,
106 
107  .src_dev_type = STEDMA40_DEV_DST_MEMORY,
108  .dst_dev_type = DB8500_DMA_DEV14_MSP2_TX,
109 
110  .src_info.psize = STEDMA40_PSIZE_LOG_4,
111  .dst_info.psize = STEDMA40_PSIZE_LOG_4,
112 
113  .use_fixed_channel = true,
114  .phy_channel = 1,
115 
116  /* data_width is set during configuration */
117 };
118 
119 static struct platform_device *db8500_add_msp_i2s(struct device *parent,
120  int id,
121  resource_size_t base, int irq,
123 {
124  struct platform_device *pdev;
125  struct resource res[] = {
126  DEFINE_RES_MEM(base, SZ_4K),
127  DEFINE_RES_IRQ(irq),
128  };
129 
130  pr_info("Register platform-device 'ux500-msp-i2s', id %d, irq %d\n",
131  id, irq);
132  pdev = platform_device_register_resndata(parent, "ux500-msp-i2s", id,
133  res, ARRAY_SIZE(res),
134  pdata, sizeof(*pdata));
135  if (!pdev) {
136  pr_err("Failed to register platform-device 'ux500-msp-i2s.%d'!\n",
137  id);
138  return NULL;
139  }
140 
141  return pdev;
142 }
143 
144 /* Platform device for ASoC MOP500 machine */
145 static struct platform_device snd_soc_mop500 = {
146  .name = "snd-soc-mop500",
147  .id = 0,
148  .dev = {
149  .platform_data = NULL,
150  },
151 };
152 
153 /* Platform device for Ux500-PCM */
154 static struct platform_device ux500_pcm = {
155  .name = "ux500-pcm",
156  .id = 0,
157  .dev = {
158  .platform_data = NULL,
159  },
160 };
161 
163  .id = MSP_I2S_2,
164  .msp_i2s_dma_rx = &msp2_dma_rx,
165  .msp_i2s_dma_tx = &msp2_dma_tx,
166 };
167 
169  .id = MSP_I2S_3,
170  .msp_i2s_dma_rx = &msp1_dma_rx,
171  .msp_i2s_dma_tx = NULL,
172 };
173 
174 void mop500_audio_init(struct device *parent)
175 {
176  pr_info("%s: Register platform-device 'snd-soc-mop500'.\n", __func__);
177  platform_device_register(&snd_soc_mop500);
178 
179  pr_info("Initialize MSP I2S-devices.\n");
180  db8500_add_msp_i2s(parent, 0, U8500_MSP0_BASE, IRQ_DB8500_MSP0,
181  &msp0_platform_data);
182  db8500_add_msp_i2s(parent, 1, U8500_MSP1_BASE, IRQ_DB8500_MSP1,
183  &msp1_platform_data);
184  db8500_add_msp_i2s(parent, 2, U8500_MSP2_BASE, IRQ_DB8500_MSP2,
185  &msp2_platform_data);
186  db8500_add_msp_i2s(parent, 3, U8500_MSP3_BASE, IRQ_DB8500_MSP1,
187  &msp3_platform_data);
188 }
189 
190 /* Due for removal once the MSP driver has been fully DT:ed. */
191 void mop500_of_audio_init(struct device *parent)
192 {
193  pr_info("%s: Register platform-device 'ux500-pcm'\n", __func__);
194  platform_device_register(&ux500_pcm);
195 }