blob: 7209db7cdc721b520c81fdb093c7b697a362c214 [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>
Linus Walleijbb16bd92012-10-10 14:27:58 +020010#include <linux/platform_data/pinctrl-nomadik.h>
Linus Walleij865fab62012-10-18 14:20:16 +020011#include <linux/platform_data/dma-ste-dma40.h>
Ola Liljac0af14d2012-04-20 11:32:59 +020012
13#include <mach/devices.h>
Ola Liljac0af14d2012-04-20 11:32:59 +020014#include <mach/hardware.h>
15#include <mach/irqs.h>
16#include <mach/msp.h>
17
Linus Walleij08d98fe2012-05-07 10:34:16 +020018#include "ste-dma40-db8500.h"
Ola Liljac0af14d2012-04-20 11:32:59 +020019#include "board-mop500.h"
20#include "devices-db8500.h"
21#include "pins-db8500.h"
22
Ola Liljac0af14d2012-04-20 11:32:59 +020023static 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
36static 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
Lee Jones724ebbf2012-07-25 13:58:36 +010049struct msp_i2s_platform_data msp0_platform_data = {
Ola Liljac0af14d2012-04-20 11:32:59 +020050 .id = MSP_I2S_0,
51 .msp_i2s_dma_rx = &msp0_dma_rx,
52 .msp_i2s_dma_tx = &msp0_dma_tx,
53};
54
55static 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
68static 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
Lee Jones724ebbf2012-07-25 13:58:36 +010081struct msp_i2s_platform_data msp1_platform_data = {
Ola Liljac0af14d2012-04-20 11:32:59 +020082 .id = MSP_I2S_1,
83 .msp_i2s_dma_rx = NULL,
84 .msp_i2s_dma_tx = &msp1_dma_tx,
Ola Liljac0af14d2012-04-20 11:32:59 +020085};
86
87static 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
101static 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
Linus Walleij09486cb2012-05-07 10:29:38 +0200117static struct platform_device *db8500_add_msp_i2s(struct device *parent,
118 int id,
Ola Liljac0af14d2012-04-20 11:32:59 +0200119 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);
Linus Walleij09486cb2012-05-07 10:29:38 +0200136 return NULL;
Ola Liljac0af14d2012-04-20 11:32:59 +0200137 }
138
Linus Walleij09486cb2012-05-07 10:29:38 +0200139 return pdev;
Ola Liljac0af14d2012-04-20 11:32:59 +0200140}
141
Lee Jones97f50c62012-08-09 16:47:27 +0100142/* Platform device for ASoC MOP500 machine */
143static struct platform_device snd_soc_mop500 = {
Lee Jones65b67d32012-09-14 15:43:52 +0100144 .name = "snd-soc-mop500",
145 .id = 0,
146 .dev = {
147 .platform_data = NULL,
148 },
Ola Liljac0af14d2012-04-20 11:32:59 +0200149};
150
Lee Jones724ebbf2012-07-25 13:58:36 +0100151struct msp_i2s_platform_data msp2_platform_data = {
Ola Liljac0af14d2012-04-20 11:32:59 +0200152 .id = MSP_I2S_2,
153 .msp_i2s_dma_rx = &msp2_dma_rx,
154 .msp_i2s_dma_tx = &msp2_dma_tx,
155};
156
Lee Jones724ebbf2012-07-25 13:58:36 +0100157struct msp_i2s_platform_data msp3_platform_data = {
Ola Liljac0af14d2012-04-20 11:32:59 +0200158 .id = MSP_I2S_3,
159 .msp_i2s_dma_rx = &msp1_dma_rx,
160 .msp_i2s_dma_tx = NULL,
Ola Liljac0af14d2012-04-20 11:32:59 +0200161};
162
Lee Jones39b740b2012-09-14 15:46:29 +0100163void mop500_audio_init(struct device *parent)
Ola Liljac0af14d2012-04-20 11:32:59 +0200164{
Lee Jones97f50c62012-08-09 16:47:27 +0100165 pr_info("%s: Register platform-device 'snd-soc-mop500'.\n", __func__);
166 platform_device_register(&snd_soc_mop500);
Ola Liljac0af14d2012-04-20 11:32:59 +0200167
168 pr_info("Initialize MSP I2S-devices.\n");
Linus Walleij09486cb2012-05-07 10:29:38 +0200169 db8500_add_msp_i2s(parent, 0, U8500_MSP0_BASE, IRQ_DB8500_MSP0,
170 &msp0_platform_data);
Lee Jones5ca032e2012-09-14 16:16:08 +0100171 db8500_add_msp_i2s(parent, 1, U8500_MSP1_BASE, IRQ_DB8500_MSP1,
Linus Walleij09486cb2012-05-07 10:29:38 +0200172 &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);
Ola Liljac0af14d2012-04-20 11:32:59 +0200177}