blob: dcf5ea9884f85422a73e8a8511609832aa5719f7 [file] [log] [blame]
Ola Liljac0af14d2012-04-20 11:32:59 +02001/*
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>
Ola Liljac0af14d2012-04-20 11:32:59 +020010
Linus Walleij08d98fe2012-05-07 10:34:16 +020011#include <plat/gpio-nomadik.h>
Ola Liljac0af14d2012-04-20 11:32:59 +020012#include <plat/pincfg.h>
13#include <plat/ste_dma40.h>
14
15#include <mach/devices.h>
Ola Liljac0af14d2012-04-20 11:32:59 +020016#include <mach/hardware.h>
17#include <mach/irqs.h>
18#include <mach/msp.h>
19
Linus Walleij08d98fe2012-05-07 10:34:16 +020020#include "ste-dma40-db8500.h"
Ola Liljac0af14d2012-04-20 11:32:59 +020021#include "board-mop500.h"
22#include "devices-db8500.h"
23#include "pins-db8500.h"
24
Ola Liljac0af14d2012-04-20 11:32:59 +020025static struct stedma40_chan_cfg msp0_dma_rx = {
26 .high_priority = true,
27 .dir = STEDMA40_PERIPH_TO_MEM,
28
29 .src_dev_type = DB8500_DMA_DEV31_MSP0_RX_SLIM0_CH0_RX,
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
38static struct stedma40_chan_cfg msp0_dma_tx = {
39 .high_priority = true,
40 .dir = STEDMA40_MEM_TO_PERIPH,
41
42 .src_dev_type = STEDMA40_DEV_DST_MEMORY,
43 .dst_dev_type = DB8500_DMA_DEV31_MSP0_TX_SLIM0_CH0_TX,
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
51static struct msp_i2s_platform_data msp0_platform_data = {
52 .id = MSP_I2S_0,
53 .msp_i2s_dma_rx = &msp0_dma_rx,
54 .msp_i2s_dma_tx = &msp0_dma_tx,
55};
56
57static struct stedma40_chan_cfg msp1_dma_rx = {
58 .high_priority = true,
59 .dir = STEDMA40_PERIPH_TO_MEM,
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
70static struct stedma40_chan_cfg msp1_dma_tx = {
71 .high_priority = true,
72 .dir = STEDMA40_MEM_TO_PERIPH,
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
83static struct msp_i2s_platform_data msp1_platform_data = {
84 .id = MSP_I2S_1,
85 .msp_i2s_dma_rx = NULL,
86 .msp_i2s_dma_tx = &msp1_dma_tx,
Ola Liljac0af14d2012-04-20 11:32:59 +020087};
88
89static struct stedma40_chan_cfg msp2_dma_rx = {
90 .high_priority = true,
91 .dir = STEDMA40_PERIPH_TO_MEM,
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
103static 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
Linus Walleij09486cb2012-05-07 10:29:38 +0200119static struct platform_device *db8500_add_msp_i2s(struct device *parent,
120 int id,
Ola Liljac0af14d2012-04-20 11:32:59 +0200121 resource_size_t base, int irq,
122 struct msp_i2s_platform_data *pdata)
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);
Linus Walleij09486cb2012-05-07 10:29:38 +0200138 return NULL;
Ola Liljac0af14d2012-04-20 11:32:59 +0200139 }
140
Linus Walleij09486cb2012-05-07 10:29:38 +0200141 return pdev;
Ola Liljac0af14d2012-04-20 11:32:59 +0200142}
143
Lee Jones97f50c62012-08-09 16:47:27 +0100144/* Platform device for ASoC MOP500 machine */
145static struct platform_device snd_soc_mop500 = {
Lee Jones65b67d32012-09-14 15:43:52 +0100146 .name = "snd-soc-mop500",
147 .id = 0,
148 .dev = {
149 .platform_data = NULL,
150 },
Ola Liljac0af14d2012-04-20 11:32:59 +0200151};
152
153/* Platform device for Ux500-PCM */
154static struct platform_device ux500_pcm = {
155 .name = "ux500-pcm",
156 .id = 0,
157 .dev = {
158 .platform_data = NULL,
159 },
160};
161
162static struct msp_i2s_platform_data msp2_platform_data = {
163 .id = MSP_I2S_2,
164 .msp_i2s_dma_rx = &msp2_dma_rx,
165 .msp_i2s_dma_tx = &msp2_dma_tx,
166};
167
168static struct msp_i2s_platform_data msp3_platform_data = {
169 .id = MSP_I2S_3,
170 .msp_i2s_dma_rx = &msp1_dma_rx,
171 .msp_i2s_dma_tx = NULL,
Ola Liljac0af14d2012-04-20 11:32:59 +0200172};
173
Lee Jones65b67d32012-09-14 15:43:52 +0100174void mop500_msp_init(struct device *parent)
Ola Liljac0af14d2012-04-20 11:32:59 +0200175{
Lee Jones97f50c62012-08-09 16:47:27 +0100176 pr_info("%s: Register platform-device 'snd-soc-mop500'.\n", __func__);
177 platform_device_register(&snd_soc_mop500);
Ola Liljac0af14d2012-04-20 11:32:59 +0200178
179 pr_info("Initialize MSP I2S-devices.\n");
Linus Walleij09486cb2012-05-07 10:29:38 +0200180 db8500_add_msp_i2s(parent, 0, U8500_MSP0_BASE, IRQ_DB8500_MSP0,
181 &msp0_platform_data);
Lee Jones5ca032e2012-09-14 16:16:08 +0100182 db8500_add_msp_i2s(parent, 1, U8500_MSP1_BASE, IRQ_DB8500_MSP1,
Linus Walleij09486cb2012-05-07 10:29:38 +0200183 &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);
Ola Liljac0af14d2012-04-20 11:32:59 +0200188}