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> |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 10 | |
Linus Walleij | 08d98fe | 2012-05-07 10:34:16 +0200 | [diff] [blame] | 11 | #include <plat/gpio-nomadik.h> |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 12 | #include <plat/pincfg.h> |
| 13 | #include <plat/ste_dma40.h> |
| 14 | |
| 15 | #include <mach/devices.h> |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 16 | #include <mach/hardware.h> |
| 17 | #include <mach/irqs.h> |
| 18 | #include <mach/msp.h> |
| 19 | |
Linus Walleij | 08d98fe | 2012-05-07 10:34:16 +0200 | [diff] [blame] | 20 | #include "ste-dma40-db8500.h" |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 21 | #include "board-mop500.h" |
| 22 | #include "devices-db8500.h" |
| 23 | #include "pins-db8500.h" |
| 24 | |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 25 | static 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 | |
| 38 | static 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 | |
Lee Jones | 724ebbf | 2012-07-25 13:58:36 +0100 | [diff] [blame] | 51 | struct msp_i2s_platform_data msp0_platform_data = { |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 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, |
| 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 | |
| 70 | static 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 | |
Lee Jones | 724ebbf | 2012-07-25 13:58:36 +0100 | [diff] [blame] | 83 | struct msp_i2s_platform_data msp1_platform_data = { |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 84 | .id = MSP_I2S_1, |
| 85 | .msp_i2s_dma_rx = NULL, |
| 86 | .msp_i2s_dma_tx = &msp1_dma_tx, |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 87 | }; |
| 88 | |
| 89 | static 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 | |
| 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 | |
Linus Walleij | 09486cb | 2012-05-07 10:29:38 +0200 | [diff] [blame] | 119 | static struct platform_device *db8500_add_msp_i2s(struct device *parent, |
| 120 | int id, |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 121 | 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 Walleij | 09486cb | 2012-05-07 10:29:38 +0200 | [diff] [blame] | 138 | return NULL; |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 139 | } |
| 140 | |
Linus Walleij | 09486cb | 2012-05-07 10:29:38 +0200 | [diff] [blame] | 141 | return pdev; |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 142 | } |
| 143 | |
Lee Jones | 97f50c6 | 2012-08-09 16:47:27 +0100 | [diff] [blame] | 144 | /* Platform device for ASoC MOP500 machine */ |
| 145 | static struct platform_device snd_soc_mop500 = { |
Lee Jones | 65b67d3 | 2012-09-14 15:43:52 +0100 | [diff] [blame] | 146 | .name = "snd-soc-mop500", |
| 147 | .id = 0, |
| 148 | .dev = { |
| 149 | .platform_data = NULL, |
| 150 | }, |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 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 | |
Lee Jones | 724ebbf | 2012-07-25 13:58:36 +0100 | [diff] [blame] | 162 | struct msp_i2s_platform_data msp2_platform_data = { |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 163 | .id = MSP_I2S_2, |
| 164 | .msp_i2s_dma_rx = &msp2_dma_rx, |
| 165 | .msp_i2s_dma_tx = &msp2_dma_tx, |
| 166 | }; |
| 167 | |
Lee Jones | 724ebbf | 2012-07-25 13:58:36 +0100 | [diff] [blame] | 168 | struct msp_i2s_platform_data msp3_platform_data = { |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 169 | .id = MSP_I2S_3, |
| 170 | .msp_i2s_dma_rx = &msp1_dma_rx, |
| 171 | .msp_i2s_dma_tx = NULL, |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 172 | }; |
| 173 | |
Lee Jones | 39b740b | 2012-09-14 15:46:29 +0100 | [diff] [blame] | 174 | void mop500_audio_init(struct device *parent) |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 175 | { |
Lee Jones | 97f50c6 | 2012-08-09 16:47:27 +0100 | [diff] [blame] | 176 | pr_info("%s: Register platform-device 'snd-soc-mop500'.\n", __func__); |
| 177 | platform_device_register(&snd_soc_mop500); |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 178 | |
| 179 | pr_info("Initialize MSP I2S-devices.\n"); |
Linus Walleij | 09486cb | 2012-05-07 10:29:38 +0200 | [diff] [blame] | 180 | db8500_add_msp_i2s(parent, 0, U8500_MSP0_BASE, IRQ_DB8500_MSP0, |
| 181 | &msp0_platform_data); |
Lee Jones | 5ca032e | 2012-09-14 16:16:08 +0100 | [diff] [blame] | 182 | db8500_add_msp_i2s(parent, 1, U8500_MSP1_BASE, IRQ_DB8500_MSP1, |
Linus Walleij | 09486cb | 2012-05-07 10:29:38 +0200 | [diff] [blame] | 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); |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 188 | } |
Lee Jones | 39b740b | 2012-09-14 15:46:29 +0100 | [diff] [blame] | 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 | } |