Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 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> |
Linus Walleij | bb16bd9 | 2012-10-10 14:27:58 +0200 | [diff] [blame] | 10 | #include <linux/platform_data/pinctrl-nomadik.h> |
Linus Walleij | 865fab6 | 2012-10-18 14:20:16 +0200 | [diff] [blame] | 11 | #include <linux/platform_data/dma-ste-dma40.h> |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 12 | |
| 13 | #include <mach/devices.h> |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 14 | #include <mach/hardware.h> |
| 15 | #include <mach/irqs.h> |
| 16 | #include <mach/msp.h> |
| 17 | |
Linus Walleij | 08d98fe | 2012-05-07 10:34:16 +0200 | [diff] [blame] | 18 | #include "ste-dma40-db8500.h" |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 19 | #include "board-mop500.h" |
| 20 | #include "devices-db8500.h" |
| 21 | #include "pins-db8500.h" |
| 22 | |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 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 | |
Lee Jones | 724ebbf | 2012-07-25 13:58:36 +0100 | [diff] [blame] | 49 | struct msp_i2s_platform_data msp0_platform_data = { |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 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 | |
Lee Jones | 724ebbf | 2012-07-25 13:58:36 +0100 | [diff] [blame] | 81 | struct msp_i2s_platform_data msp1_platform_data = { |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 82 | .id = MSP_I2S_1, |
| 83 | .msp_i2s_dma_rx = NULL, |
| 84 | .msp_i2s_dma_tx = &msp1_dma_tx, |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 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 | |
Linus Walleij | 09486cb | 2012-05-07 10:29:38 +0200 | [diff] [blame] | 117 | static struct platform_device *db8500_add_msp_i2s(struct device *parent, |
| 118 | int id, |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 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); |
Linus Walleij | 09486cb | 2012-05-07 10:29:38 +0200 | [diff] [blame] | 136 | return NULL; |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 137 | } |
| 138 | |
Linus Walleij | 09486cb | 2012-05-07 10:29:38 +0200 | [diff] [blame] | 139 | return pdev; |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 140 | } |
| 141 | |
Lee Jones | 97f50c6 | 2012-08-09 16:47:27 +0100 | [diff] [blame] | 142 | /* Platform device for ASoC MOP500 machine */ |
| 143 | static struct platform_device snd_soc_mop500 = { |
Lee Jones | 65b67d3 | 2012-09-14 15:43:52 +0100 | [diff] [blame] | 144 | .name = "snd-soc-mop500", |
| 145 | .id = 0, |
| 146 | .dev = { |
| 147 | .platform_data = NULL, |
| 148 | }, |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 149 | }; |
| 150 | |
Lee Jones | 724ebbf | 2012-07-25 13:58:36 +0100 | [diff] [blame] | 151 | struct msp_i2s_platform_data msp2_platform_data = { |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 152 | .id = MSP_I2S_2, |
| 153 | .msp_i2s_dma_rx = &msp2_dma_rx, |
| 154 | .msp_i2s_dma_tx = &msp2_dma_tx, |
| 155 | }; |
| 156 | |
Lee Jones | 724ebbf | 2012-07-25 13:58:36 +0100 | [diff] [blame] | 157 | struct msp_i2s_platform_data msp3_platform_data = { |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 158 | .id = MSP_I2S_3, |
| 159 | .msp_i2s_dma_rx = &msp1_dma_rx, |
| 160 | .msp_i2s_dma_tx = NULL, |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 161 | }; |
| 162 | |
Lee Jones | 39b740b | 2012-09-14 15:46:29 +0100 | [diff] [blame] | 163 | void mop500_audio_init(struct device *parent) |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 164 | { |
Lee Jones | 97f50c6 | 2012-08-09 16:47:27 +0100 | [diff] [blame] | 165 | pr_info("%s: Register platform-device 'snd-soc-mop500'.\n", __func__); |
| 166 | platform_device_register(&snd_soc_mop500); |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 167 | |
| 168 | pr_info("Initialize MSP I2S-devices.\n"); |
Linus Walleij | 09486cb | 2012-05-07 10:29:38 +0200 | [diff] [blame] | 169 | db8500_add_msp_i2s(parent, 0, U8500_MSP0_BASE, IRQ_DB8500_MSP0, |
| 170 | &msp0_platform_data); |
Lee Jones | 5ca032e | 2012-09-14 16:16:08 +0100 | [diff] [blame] | 171 | db8500_add_msp_i2s(parent, 1, U8500_MSP1_BASE, IRQ_DB8500_MSP1, |
Linus Walleij | 09486cb | 2012-05-07 10:29:38 +0200 | [diff] [blame] | 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); |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 177 | } |