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 | |
Arnd Bergmann | e657bcf | 2013-03-21 22:51:12 +0100 | [diff] [blame] | 13 | #include "devices.h" |
Arnd Bergmann | eba5274 | 2013-03-21 22:51:08 +0100 | [diff] [blame] | 14 | #include "irqs.h" |
Arnd Bergmann | ab0fc6c | 2013-03-21 22:51:06 +0100 | [diff] [blame] | 15 | #include <linux/platform_data/asoc-ux500-msp.h> |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 16 | |
Linus Walleij | 08d98fe | 2012-05-07 10:34:16 +0200 | [diff] [blame] | 17 | #include "ste-dma40-db8500.h" |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 18 | #include "board-mop500.h" |
| 19 | #include "devices-db8500.h" |
| 20 | #include "pins-db8500.h" |
| 21 | |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 22 | static struct stedma40_chan_cfg msp0_dma_rx = { |
| 23 | .high_priority = true, |
Lee Jones | 98b68ab | 2013-05-15 10:51:53 +0100 | [diff] [blame] | 24 | .dir = DMA_DEV_TO_MEM, |
Lee Jones | 26955c07d | 2013-05-03 15:31:56 +0100 | [diff] [blame] | 25 | .dev_type = DB8500_DMA_DEV31_MSP0_SLIM0_CH0, |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 26 | }; |
| 27 | |
| 28 | static struct stedma40_chan_cfg msp0_dma_tx = { |
| 29 | .high_priority = true, |
Lee Jones | 98b68ab | 2013-05-15 10:51:53 +0100 | [diff] [blame] | 30 | .dir = DMA_MEM_TO_DEV, |
Lee Jones | 26955c07d | 2013-05-03 15:31:56 +0100 | [diff] [blame] | 31 | .dev_type = DB8500_DMA_DEV31_MSP0_SLIM0_CH0, |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 32 | }; |
| 33 | |
Lee Jones | 724ebbf | 2012-07-25 13:58:36 +0100 | [diff] [blame] | 34 | struct msp_i2s_platform_data msp0_platform_data = { |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 35 | .id = MSP_I2S_0, |
| 36 | .msp_i2s_dma_rx = &msp0_dma_rx, |
| 37 | .msp_i2s_dma_tx = &msp0_dma_tx, |
| 38 | }; |
| 39 | |
| 40 | static struct stedma40_chan_cfg msp1_dma_rx = { |
| 41 | .high_priority = true, |
Lee Jones | 98b68ab | 2013-05-15 10:51:53 +0100 | [diff] [blame] | 42 | .dir = DMA_DEV_TO_MEM, |
Lee Jones | 26955c07d | 2013-05-03 15:31:56 +0100 | [diff] [blame] | 43 | .dev_type = DB8500_DMA_DEV30_MSP3, |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 44 | }; |
| 45 | |
| 46 | static struct stedma40_chan_cfg msp1_dma_tx = { |
| 47 | .high_priority = true, |
Lee Jones | 98b68ab | 2013-05-15 10:51:53 +0100 | [diff] [blame] | 48 | .dir = DMA_MEM_TO_DEV, |
Lee Jones | 26955c07d | 2013-05-03 15:31:56 +0100 | [diff] [blame] | 49 | .dev_type = DB8500_DMA_DEV30_MSP1, |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 50 | }; |
| 51 | |
Lee Jones | 724ebbf | 2012-07-25 13:58:36 +0100 | [diff] [blame] | 52 | struct msp_i2s_platform_data msp1_platform_data = { |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 53 | .id = MSP_I2S_1, |
| 54 | .msp_i2s_dma_rx = NULL, |
| 55 | .msp_i2s_dma_tx = &msp1_dma_tx, |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 56 | }; |
| 57 | |
| 58 | static struct stedma40_chan_cfg msp2_dma_rx = { |
| 59 | .high_priority = true, |
Lee Jones | 98b68ab | 2013-05-15 10:51:53 +0100 | [diff] [blame] | 60 | .dir = DMA_DEV_TO_MEM, |
Lee Jones | 26955c07d | 2013-05-03 15:31:56 +0100 | [diff] [blame] | 61 | .dev_type = DB8500_DMA_DEV14_MSP2, |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 62 | }; |
| 63 | |
| 64 | static struct stedma40_chan_cfg msp2_dma_tx = { |
| 65 | .high_priority = true, |
Lee Jones | 98b68ab | 2013-05-15 10:51:53 +0100 | [diff] [blame] | 66 | .dir = DMA_MEM_TO_DEV, |
Lee Jones | 26955c07d | 2013-05-03 15:31:56 +0100 | [diff] [blame] | 67 | .dev_type = DB8500_DMA_DEV14_MSP2, |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 68 | .use_fixed_channel = true, |
| 69 | .phy_channel = 1, |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 70 | }; |
| 71 | |
Linus Walleij | 09486cb | 2012-05-07 10:29:38 +0200 | [diff] [blame] | 72 | static struct platform_device *db8500_add_msp_i2s(struct device *parent, |
| 73 | int id, |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 74 | resource_size_t base, int irq, |
| 75 | struct msp_i2s_platform_data *pdata) |
| 76 | { |
| 77 | struct platform_device *pdev; |
| 78 | struct resource res[] = { |
| 79 | DEFINE_RES_MEM(base, SZ_4K), |
| 80 | DEFINE_RES_IRQ(irq), |
| 81 | }; |
| 82 | |
| 83 | pr_info("Register platform-device 'ux500-msp-i2s', id %d, irq %d\n", |
| 84 | id, irq); |
| 85 | pdev = platform_device_register_resndata(parent, "ux500-msp-i2s", id, |
| 86 | res, ARRAY_SIZE(res), |
| 87 | pdata, sizeof(*pdata)); |
| 88 | if (!pdev) { |
| 89 | pr_err("Failed to register platform-device 'ux500-msp-i2s.%d'!\n", |
| 90 | id); |
Linus Walleij | 09486cb | 2012-05-07 10:29:38 +0200 | [diff] [blame] | 91 | return NULL; |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 92 | } |
| 93 | |
Linus Walleij | 09486cb | 2012-05-07 10:29:38 +0200 | [diff] [blame] | 94 | return pdev; |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 95 | } |
| 96 | |
Lee Jones | 97f50c6 | 2012-08-09 16:47:27 +0100 | [diff] [blame] | 97 | /* Platform device for ASoC MOP500 machine */ |
| 98 | static struct platform_device snd_soc_mop500 = { |
Lee Jones | 65b67d3 | 2012-09-14 15:43:52 +0100 | [diff] [blame] | 99 | .name = "snd-soc-mop500", |
| 100 | .id = 0, |
| 101 | .dev = { |
| 102 | .platform_data = NULL, |
| 103 | }, |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 104 | }; |
| 105 | |
Lee Jones | 724ebbf | 2012-07-25 13:58:36 +0100 | [diff] [blame] | 106 | struct msp_i2s_platform_data msp2_platform_data = { |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 107 | .id = MSP_I2S_2, |
| 108 | .msp_i2s_dma_rx = &msp2_dma_rx, |
| 109 | .msp_i2s_dma_tx = &msp2_dma_tx, |
| 110 | }; |
| 111 | |
Lee Jones | 724ebbf | 2012-07-25 13:58:36 +0100 | [diff] [blame] | 112 | struct msp_i2s_platform_data msp3_platform_data = { |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 113 | .id = MSP_I2S_3, |
| 114 | .msp_i2s_dma_rx = &msp1_dma_rx, |
| 115 | .msp_i2s_dma_tx = NULL, |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 116 | }; |
| 117 | |
Lee Jones | 39b740b | 2012-09-14 15:46:29 +0100 | [diff] [blame] | 118 | void mop500_audio_init(struct device *parent) |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 119 | { |
Lee Jones | 97f50c6 | 2012-08-09 16:47:27 +0100 | [diff] [blame] | 120 | pr_info("%s: Register platform-device 'snd-soc-mop500'.\n", __func__); |
| 121 | platform_device_register(&snd_soc_mop500); |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 122 | |
| 123 | pr_info("Initialize MSP I2S-devices.\n"); |
Linus Walleij | 09486cb | 2012-05-07 10:29:38 +0200 | [diff] [blame] | 124 | db8500_add_msp_i2s(parent, 0, U8500_MSP0_BASE, IRQ_DB8500_MSP0, |
| 125 | &msp0_platform_data); |
Lee Jones | 5ca032e | 2012-09-14 16:16:08 +0100 | [diff] [blame] | 126 | db8500_add_msp_i2s(parent, 1, U8500_MSP1_BASE, IRQ_DB8500_MSP1, |
Linus Walleij | 09486cb | 2012-05-07 10:29:38 +0200 | [diff] [blame] | 127 | &msp1_platform_data); |
| 128 | db8500_add_msp_i2s(parent, 2, U8500_MSP2_BASE, IRQ_DB8500_MSP2, |
| 129 | &msp2_platform_data); |
| 130 | db8500_add_msp_i2s(parent, 3, U8500_MSP3_BASE, IRQ_DB8500_MSP1, |
| 131 | &msp3_platform_data); |
Ola Lilja | c0af14d | 2012-04-20 11:32:59 +0200 | [diff] [blame] | 132 | } |