178673bc8SEduardo Valentin /* 278673bc8SEduardo Valentin * linux/arch/arm/mach-omap2/mcbsp.c 378673bc8SEduardo Valentin * 478673bc8SEduardo Valentin * Copyright (C) 2008 Instituto Nokia de Tecnologia 578673bc8SEduardo Valentin * Contact: Eduardo Valentin <eduardo.valentin@indt.org.br> 678673bc8SEduardo Valentin * 778673bc8SEduardo Valentin * This program is free software; you can redistribute it and/or modify 878673bc8SEduardo Valentin * it under the terms of the GNU General Public License version 2 as 978673bc8SEduardo Valentin * published by the Free Software Foundation. 1078673bc8SEduardo Valentin * 1178673bc8SEduardo Valentin * Multichannel mode not supported. 1278673bc8SEduardo Valentin */ 1378673bc8SEduardo Valentin #include <linux/module.h> 1478673bc8SEduardo Valentin #include <linux/init.h> 1578673bc8SEduardo Valentin #include <linux/clk.h> 1678673bc8SEduardo Valentin #include <linux/err.h> 1778673bc8SEduardo Valentin #include <linux/io.h> 1878673bc8SEduardo Valentin #include <linux/platform_device.h> 1978673bc8SEduardo Valentin 20dd7667aaSTony Lindgren #include <mach/irqs.h> 21*ce491cf8STony Lindgren #include <plat/dma.h> 22*ce491cf8STony Lindgren #include <plat/mux.h> 23*ce491cf8STony Lindgren #include <plat/cpu.h> 24*ce491cf8STony Lindgren #include <plat/mcbsp.h> 2578673bc8SEduardo Valentin 2678673bc8SEduardo Valentin static void omap2_mcbsp2_mux_setup(void) 2778673bc8SEduardo Valentin { 2878673bc8SEduardo Valentin omap_cfg_reg(Y15_24XX_MCBSP2_CLKX); 2978673bc8SEduardo Valentin omap_cfg_reg(R14_24XX_MCBSP2_FSX); 3078673bc8SEduardo Valentin omap_cfg_reg(W15_24XX_MCBSP2_DR); 3178673bc8SEduardo Valentin omap_cfg_reg(V15_24XX_MCBSP2_DX); 3278673bc8SEduardo Valentin omap_cfg_reg(V14_24XX_GPIO117); 3378673bc8SEduardo Valentin /* 3478673bc8SEduardo Valentin * TODO: Need to add MUX settings for OMAP 2430 SDP 3578673bc8SEduardo Valentin */ 3678673bc8SEduardo Valentin } 3778673bc8SEduardo Valentin 3878673bc8SEduardo Valentin static void omap2_mcbsp_request(unsigned int id) 3978673bc8SEduardo Valentin { 4078673bc8SEduardo Valentin if (cpu_is_omap2420() && (id == OMAP_MCBSP2)) 4178673bc8SEduardo Valentin omap2_mcbsp2_mux_setup(); 4278673bc8SEduardo Valentin } 4378673bc8SEduardo Valentin 4478673bc8SEduardo Valentin static struct omap_mcbsp_ops omap2_mcbsp_ops = { 4578673bc8SEduardo Valentin .request = omap2_mcbsp_request, 4678673bc8SEduardo Valentin }; 4778673bc8SEduardo Valentin 4805228c35SJarkko Nikula #ifdef CONFIG_ARCH_OMAP2420 4905228c35SJarkko Nikula static struct omap_mcbsp_platform_data omap2420_mcbsp_pdata[] = { 5078673bc8SEduardo Valentin { 5165846909SRussell King .phys_base = OMAP24XX_MCBSP1_BASE, 5278673bc8SEduardo Valentin .dma_rx_sync = OMAP24XX_DMA_MCBSP1_RX, 5378673bc8SEduardo Valentin .dma_tx_sync = OMAP24XX_DMA_MCBSP1_TX, 5478673bc8SEduardo Valentin .rx_irq = INT_24XX_MCBSP1_IRQ_RX, 5578673bc8SEduardo Valentin .tx_irq = INT_24XX_MCBSP1_IRQ_TX, 5678673bc8SEduardo Valentin .ops = &omap2_mcbsp_ops, 5778673bc8SEduardo Valentin }, 5878673bc8SEduardo Valentin { 5965846909SRussell King .phys_base = OMAP24XX_MCBSP2_BASE, 6078673bc8SEduardo Valentin .dma_rx_sync = OMAP24XX_DMA_MCBSP2_RX, 6178673bc8SEduardo Valentin .dma_tx_sync = OMAP24XX_DMA_MCBSP2_TX, 6278673bc8SEduardo Valentin .rx_irq = INT_24XX_MCBSP2_IRQ_RX, 6378673bc8SEduardo Valentin .tx_irq = INT_24XX_MCBSP2_IRQ_TX, 6478673bc8SEduardo Valentin .ops = &omap2_mcbsp_ops, 6578673bc8SEduardo Valentin }, 6678673bc8SEduardo Valentin }; 6705228c35SJarkko Nikula #define OMAP2420_MCBSP_PDATA_SZ ARRAY_SIZE(omap2420_mcbsp_pdata) 6878673bc8SEduardo Valentin #else 6905228c35SJarkko Nikula #define omap2420_mcbsp_pdata NULL 7005228c35SJarkko Nikula #define OMAP2420_MCBSP_PDATA_SZ 0 7105228c35SJarkko Nikula #endif 7205228c35SJarkko Nikula 7305228c35SJarkko Nikula #ifdef CONFIG_ARCH_OMAP2430 7405228c35SJarkko Nikula static struct omap_mcbsp_platform_data omap2430_mcbsp_pdata[] = { 7505228c35SJarkko Nikula { 7605228c35SJarkko Nikula .phys_base = OMAP24XX_MCBSP1_BASE, 7705228c35SJarkko Nikula .dma_rx_sync = OMAP24XX_DMA_MCBSP1_RX, 7805228c35SJarkko Nikula .dma_tx_sync = OMAP24XX_DMA_MCBSP1_TX, 7905228c35SJarkko Nikula .rx_irq = INT_24XX_MCBSP1_IRQ_RX, 8005228c35SJarkko Nikula .tx_irq = INT_24XX_MCBSP1_IRQ_TX, 8105228c35SJarkko Nikula .ops = &omap2_mcbsp_ops, 8205228c35SJarkko Nikula }, 8305228c35SJarkko Nikula { 8405228c35SJarkko Nikula .phys_base = OMAP24XX_MCBSP2_BASE, 8505228c35SJarkko Nikula .dma_rx_sync = OMAP24XX_DMA_MCBSP2_RX, 8605228c35SJarkko Nikula .dma_tx_sync = OMAP24XX_DMA_MCBSP2_TX, 8705228c35SJarkko Nikula .rx_irq = INT_24XX_MCBSP2_IRQ_RX, 8805228c35SJarkko Nikula .tx_irq = INT_24XX_MCBSP2_IRQ_TX, 8905228c35SJarkko Nikula .ops = &omap2_mcbsp_ops, 9005228c35SJarkko Nikula }, 9105228c35SJarkko Nikula { 9205228c35SJarkko Nikula .phys_base = OMAP2430_MCBSP3_BASE, 9305228c35SJarkko Nikula .dma_rx_sync = OMAP24XX_DMA_MCBSP3_RX, 9405228c35SJarkko Nikula .dma_tx_sync = OMAP24XX_DMA_MCBSP3_TX, 9505228c35SJarkko Nikula .rx_irq = INT_24XX_MCBSP3_IRQ_RX, 9605228c35SJarkko Nikula .tx_irq = INT_24XX_MCBSP3_IRQ_TX, 9705228c35SJarkko Nikula .ops = &omap2_mcbsp_ops, 9805228c35SJarkko Nikula }, 9905228c35SJarkko Nikula { 10005228c35SJarkko Nikula .phys_base = OMAP2430_MCBSP4_BASE, 10105228c35SJarkko Nikula .dma_rx_sync = OMAP24XX_DMA_MCBSP4_RX, 10205228c35SJarkko Nikula .dma_tx_sync = OMAP24XX_DMA_MCBSP4_TX, 10305228c35SJarkko Nikula .rx_irq = INT_24XX_MCBSP4_IRQ_RX, 10405228c35SJarkko Nikula .tx_irq = INT_24XX_MCBSP4_IRQ_TX, 10505228c35SJarkko Nikula .ops = &omap2_mcbsp_ops, 10605228c35SJarkko Nikula }, 10705228c35SJarkko Nikula { 10805228c35SJarkko Nikula .phys_base = OMAP2430_MCBSP5_BASE, 10905228c35SJarkko Nikula .dma_rx_sync = OMAP24XX_DMA_MCBSP5_RX, 11005228c35SJarkko Nikula .dma_tx_sync = OMAP24XX_DMA_MCBSP5_TX, 11105228c35SJarkko Nikula .rx_irq = INT_24XX_MCBSP5_IRQ_RX, 11205228c35SJarkko Nikula .tx_irq = INT_24XX_MCBSP5_IRQ_TX, 11305228c35SJarkko Nikula .ops = &omap2_mcbsp_ops, 11405228c35SJarkko Nikula }, 11505228c35SJarkko Nikula }; 11605228c35SJarkko Nikula #define OMAP2430_MCBSP_PDATA_SZ ARRAY_SIZE(omap2430_mcbsp_pdata) 11705228c35SJarkko Nikula #else 11805228c35SJarkko Nikula #define omap2430_mcbsp_pdata NULL 11905228c35SJarkko Nikula #define OMAP2430_MCBSP_PDATA_SZ 0 12078673bc8SEduardo Valentin #endif 12178673bc8SEduardo Valentin 12278673bc8SEduardo Valentin #ifdef CONFIG_ARCH_OMAP34XX 12378673bc8SEduardo Valentin static struct omap_mcbsp_platform_data omap34xx_mcbsp_pdata[] = { 12478673bc8SEduardo Valentin { 12565846909SRussell King .phys_base = OMAP34XX_MCBSP1_BASE, 12678673bc8SEduardo Valentin .dma_rx_sync = OMAP24XX_DMA_MCBSP1_RX, 12778673bc8SEduardo Valentin .dma_tx_sync = OMAP24XX_DMA_MCBSP1_TX, 12878673bc8SEduardo Valentin .rx_irq = INT_24XX_MCBSP1_IRQ_RX, 12978673bc8SEduardo Valentin .tx_irq = INT_24XX_MCBSP1_IRQ_TX, 13078673bc8SEduardo Valentin .ops = &omap2_mcbsp_ops, 1317e4f943bSPeter Ujfalusi .buffer_size = 0x6F, 13278673bc8SEduardo Valentin }, 13378673bc8SEduardo Valentin { 13465846909SRussell King .phys_base = OMAP34XX_MCBSP2_BASE, 13578673bc8SEduardo Valentin .dma_rx_sync = OMAP24XX_DMA_MCBSP2_RX, 13678673bc8SEduardo Valentin .dma_tx_sync = OMAP24XX_DMA_MCBSP2_TX, 13778673bc8SEduardo Valentin .rx_irq = INT_24XX_MCBSP2_IRQ_RX, 13878673bc8SEduardo Valentin .tx_irq = INT_24XX_MCBSP2_IRQ_TX, 13978673bc8SEduardo Valentin .ops = &omap2_mcbsp_ops, 140a1a56f5fSEduardo Valentin .buffer_size = 0x3FF, 14178673bc8SEduardo Valentin }, 1429c8e3a0fSChandra Shekhar { 1439c8e3a0fSChandra Shekhar .phys_base = OMAP34XX_MCBSP3_BASE, 1449c8e3a0fSChandra Shekhar .dma_rx_sync = OMAP24XX_DMA_MCBSP3_RX, 1459c8e3a0fSChandra Shekhar .dma_tx_sync = OMAP24XX_DMA_MCBSP3_TX, 1469c8e3a0fSChandra Shekhar .rx_irq = INT_24XX_MCBSP3_IRQ_RX, 1479c8e3a0fSChandra Shekhar .tx_irq = INT_24XX_MCBSP3_IRQ_TX, 1489c8e3a0fSChandra Shekhar .ops = &omap2_mcbsp_ops, 1497e4f943bSPeter Ujfalusi .buffer_size = 0x6F, 1509c8e3a0fSChandra Shekhar }, 1519c8e3a0fSChandra Shekhar { 1529c8e3a0fSChandra Shekhar .phys_base = OMAP34XX_MCBSP4_BASE, 1539c8e3a0fSChandra Shekhar .dma_rx_sync = OMAP24XX_DMA_MCBSP4_RX, 1549c8e3a0fSChandra Shekhar .dma_tx_sync = OMAP24XX_DMA_MCBSP4_TX, 1559c8e3a0fSChandra Shekhar .rx_irq = INT_24XX_MCBSP4_IRQ_RX, 1569c8e3a0fSChandra Shekhar .tx_irq = INT_24XX_MCBSP4_IRQ_TX, 1579c8e3a0fSChandra Shekhar .ops = &omap2_mcbsp_ops, 1587e4f943bSPeter Ujfalusi .buffer_size = 0x6F, 1599c8e3a0fSChandra Shekhar }, 1609c8e3a0fSChandra Shekhar { 1619c8e3a0fSChandra Shekhar .phys_base = OMAP34XX_MCBSP5_BASE, 1629c8e3a0fSChandra Shekhar .dma_rx_sync = OMAP24XX_DMA_MCBSP5_RX, 1639c8e3a0fSChandra Shekhar .dma_tx_sync = OMAP24XX_DMA_MCBSP5_TX, 1649c8e3a0fSChandra Shekhar .rx_irq = INT_24XX_MCBSP5_IRQ_RX, 1659c8e3a0fSChandra Shekhar .tx_irq = INT_24XX_MCBSP5_IRQ_TX, 1669c8e3a0fSChandra Shekhar .ops = &omap2_mcbsp_ops, 1677e4f943bSPeter Ujfalusi .buffer_size = 0x6F, 1689c8e3a0fSChandra Shekhar }, 16978673bc8SEduardo Valentin }; 17078673bc8SEduardo Valentin #define OMAP34XX_MCBSP_PDATA_SZ ARRAY_SIZE(omap34xx_mcbsp_pdata) 17178673bc8SEduardo Valentin #else 17278673bc8SEduardo Valentin #define omap34xx_mcbsp_pdata NULL 17378673bc8SEduardo Valentin #define OMAP34XX_MCBSP_PDATA_SZ 0 17478673bc8SEduardo Valentin #endif 17578673bc8SEduardo Valentin 176a5b92cc3SSyed Rafiuddin static struct omap_mcbsp_platform_data omap44xx_mcbsp_pdata[] = { 177a5b92cc3SSyed Rafiuddin { 178a5b92cc3SSyed Rafiuddin .phys_base = OMAP44XX_MCBSP1_BASE, 179a5b92cc3SSyed Rafiuddin .dma_rx_sync = OMAP44XX_DMA_MCBSP1_RX, 180a5b92cc3SSyed Rafiuddin .dma_tx_sync = OMAP44XX_DMA_MCBSP1_TX, 181a5b92cc3SSyed Rafiuddin .rx_irq = INT_24XX_MCBSP1_IRQ_RX, 182a5b92cc3SSyed Rafiuddin .tx_irq = INT_24XX_MCBSP1_IRQ_TX, 183a5b92cc3SSyed Rafiuddin .ops = &omap2_mcbsp_ops, 184a5b92cc3SSyed Rafiuddin }, 185a5b92cc3SSyed Rafiuddin { 186a5b92cc3SSyed Rafiuddin .phys_base = OMAP44XX_MCBSP2_BASE, 187a5b92cc3SSyed Rafiuddin .dma_rx_sync = OMAP44XX_DMA_MCBSP2_RX, 188a5b92cc3SSyed Rafiuddin .dma_tx_sync = OMAP44XX_DMA_MCBSP2_TX, 189a5b92cc3SSyed Rafiuddin .rx_irq = INT_24XX_MCBSP2_IRQ_RX, 190a5b92cc3SSyed Rafiuddin .tx_irq = INT_24XX_MCBSP2_IRQ_TX, 191a5b92cc3SSyed Rafiuddin .ops = &omap2_mcbsp_ops, 192a5b92cc3SSyed Rafiuddin }, 193a5b92cc3SSyed Rafiuddin { 194a5b92cc3SSyed Rafiuddin .phys_base = OMAP44XX_MCBSP3_BASE, 195a5b92cc3SSyed Rafiuddin .dma_rx_sync = OMAP44XX_DMA_MCBSP3_RX, 196a5b92cc3SSyed Rafiuddin .dma_tx_sync = OMAP44XX_DMA_MCBSP3_TX, 197a5b92cc3SSyed Rafiuddin .rx_irq = INT_24XX_MCBSP3_IRQ_RX, 198a5b92cc3SSyed Rafiuddin .tx_irq = INT_24XX_MCBSP3_IRQ_TX, 199a5b92cc3SSyed Rafiuddin .ops = &omap2_mcbsp_ops, 200a5b92cc3SSyed Rafiuddin }, 201a5b92cc3SSyed Rafiuddin { 202a5b92cc3SSyed Rafiuddin .phys_base = OMAP44XX_MCBSP4_BASE, 203a5b92cc3SSyed Rafiuddin .dma_rx_sync = OMAP44XX_DMA_MCBSP4_RX, 204a5b92cc3SSyed Rafiuddin .dma_tx_sync = OMAP44XX_DMA_MCBSP4_TX, 205a5b92cc3SSyed Rafiuddin .rx_irq = INT_24XX_MCBSP4_IRQ_RX, 206a5b92cc3SSyed Rafiuddin .tx_irq = INT_24XX_MCBSP4_IRQ_TX, 207a5b92cc3SSyed Rafiuddin .ops = &omap2_mcbsp_ops, 208a5b92cc3SSyed Rafiuddin }, 209a5b92cc3SSyed Rafiuddin }; 210a5b92cc3SSyed Rafiuddin #define OMAP44XX_MCBSP_PDATA_SZ ARRAY_SIZE(omap44xx_mcbsp_pdata) 211a5b92cc3SSyed Rafiuddin 212b4b58f58SChandra Shekhar static int __init omap2_mcbsp_init(void) 21378673bc8SEduardo Valentin { 21405228c35SJarkko Nikula if (cpu_is_omap2420()) 21505228c35SJarkko Nikula omap_mcbsp_count = OMAP2420_MCBSP_PDATA_SZ; 21605228c35SJarkko Nikula if (cpu_is_omap2430()) 21705228c35SJarkko Nikula omap_mcbsp_count = OMAP2430_MCBSP_PDATA_SZ; 218b4b58f58SChandra Shekhar if (cpu_is_omap34xx()) 219b4b58f58SChandra Shekhar omap_mcbsp_count = OMAP34XX_MCBSP_PDATA_SZ; 220a5b92cc3SSyed Rafiuddin if (cpu_is_omap44xx()) 221a5b92cc3SSyed Rafiuddin omap_mcbsp_count = OMAP44XX_MCBSP_PDATA_SZ; 222b4b58f58SChandra Shekhar 223b4b58f58SChandra Shekhar mcbsp_ptr = kzalloc(omap_mcbsp_count * sizeof(struct omap_mcbsp *), 224b4b58f58SChandra Shekhar GFP_KERNEL); 225b4b58f58SChandra Shekhar if (!mcbsp_ptr) 226b4b58f58SChandra Shekhar return -ENOMEM; 227b4b58f58SChandra Shekhar 22805228c35SJarkko Nikula if (cpu_is_omap2420()) 22905228c35SJarkko Nikula omap_mcbsp_register_board_cfg(omap2420_mcbsp_pdata, 23005228c35SJarkko Nikula OMAP2420_MCBSP_PDATA_SZ); 23105228c35SJarkko Nikula if (cpu_is_omap2430()) 23205228c35SJarkko Nikula omap_mcbsp_register_board_cfg(omap2430_mcbsp_pdata, 23305228c35SJarkko Nikula OMAP2430_MCBSP_PDATA_SZ); 2349c8e3a0fSChandra Shekhar if (cpu_is_omap34xx()) 2359c8e3a0fSChandra Shekhar omap_mcbsp_register_board_cfg(omap34xx_mcbsp_pdata, 2369c8e3a0fSChandra Shekhar OMAP34XX_MCBSP_PDATA_SZ); 237a5b92cc3SSyed Rafiuddin if (cpu_is_omap44xx()) 238a5b92cc3SSyed Rafiuddin omap_mcbsp_register_board_cfg(omap44xx_mcbsp_pdata, 239a5b92cc3SSyed Rafiuddin OMAP44XX_MCBSP_PDATA_SZ); 24078673bc8SEduardo Valentin 24178673bc8SEduardo Valentin return omap_mcbsp_init(); 24278673bc8SEduardo Valentin } 24378673bc8SEduardo Valentin arch_initcall(omap2_mcbsp_init); 244