Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 1 | /* |
| 2 | * arch/arm/plat-omap/include/mach/mcbsp.h |
| 3 | * |
| 4 | * Defines for Multi-Channel Buffered Serial Port |
| 5 | * |
| 6 | * Copyright (C) 2002 RidgeRun, Inc. |
| 7 | * Author: Steve Johnson |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License as published by |
| 11 | * the Free Software Foundation; either version 2 of the License, or |
| 12 | * (at your option) any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with this program; if not, write to the Free Software |
| 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 22 | * |
| 23 | */ |
| 24 | #ifndef __ASM_ARCH_OMAP_MCBSP_H |
| 25 | #define __ASM_ARCH_OMAP_MCBSP_H |
| 26 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 27 | #include <linux/spinlock.h> |
Jarkko Nikula | 5167255 | 2011-09-26 10:45:46 +0300 | [diff] [blame] | 28 | #include <linux/clk.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 29 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 30 | /* macro for building platform_device for McBSP ports */ |
| 31 | #define OMAP_MCBSP_PLATFORM_DEVICE(port_nr) \ |
| 32 | static struct platform_device omap_mcbsp##port_nr = { \ |
| 33 | .name = "omap-mcbsp-dai", \ |
Jarkko Nikula | fd1ee39 | 2011-07-01 08:52:27 +0000 | [diff] [blame] | 34 | .id = port_nr - 1, \ |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 35 | } |
| 36 | |
Charulatha V | 37801b3 | 2011-02-24 12:51:46 -0800 | [diff] [blame] | 37 | #define MCBSP_CONFIG_TYPE2 0x2 |
Charulatha V | dc48e5f | 2011-02-24 15:16:49 +0530 | [diff] [blame] | 38 | #define MCBSP_CONFIG_TYPE3 0x3 |
Kishon Vijay Abraham I | cb7e9de | 2011-02-24 15:16:50 +0530 | [diff] [blame] | 39 | #define MCBSP_CONFIG_TYPE4 0x4 |
Charulatha V | 37801b3 | 2011-02-24 12:51:46 -0800 | [diff] [blame] | 40 | |
Paul Walmsley | cf4c87a | 2010-10-08 11:40:19 -0600 | [diff] [blame] | 41 | /* CLKR signal muxing options */ |
| 42 | #define CLKR_SRC_CLKR 0 |
| 43 | #define CLKR_SRC_CLKX 1 |
| 44 | |
| 45 | /* FSR signal muxing options */ |
| 46 | #define FSR_SRC_FSR 0 |
| 47 | #define FSR_SRC_FSX 1 |
| 48 | |
Paul Walmsley | d135865 | 2010-10-08 11:40:19 -0600 | [diff] [blame] | 49 | /* McBSP functional clock sources */ |
Jarkko Nikula | e4cc41d | 2010-10-08 11:40:21 -0600 | [diff] [blame] | 50 | #define MCBSP_CLKS_PRCM_SRC 0 |
| 51 | #define MCBSP_CLKS_PAD_SRC 1 |
Paul Walmsley | d135865 | 2010-10-08 11:40:19 -0600 | [diff] [blame] | 52 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 53 | /* Platform specific configuration */ |
| 54 | struct omap_mcbsp_ops { |
| 55 | void (*request)(unsigned int); |
| 56 | void (*free)(unsigned int); |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 57 | }; |
| 58 | |
| 59 | struct omap_mcbsp_platform_data { |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 60 | struct omap_mcbsp_ops *ops; |
Kishon Vijay Abraham I | 64bcbd3 | 2011-02-24 15:16:52 +0530 | [diff] [blame] | 61 | u16 buffer_size; |
Jarkko Nikula | cdc71514 | 2011-09-26 10:45:39 +0300 | [diff] [blame] | 62 | u8 reg_size; |
| 63 | u8 reg_step; |
Jarkko Nikula | 1a64588 | 2011-09-26 10:45:40 +0300 | [diff] [blame] | 64 | |
| 65 | /* McBSP platform and instance specific features */ |
| 66 | bool has_wakeup; /* Wakeup capability */ |
Jarkko Nikula | 8840823 | 2011-09-26 10:45:41 +0300 | [diff] [blame] | 67 | bool has_ccr; /* Transceiver has configuration control registers */ |
Jarkko Nikula | 1743d14 | 2011-09-26 10:45:44 +0300 | [diff] [blame] | 68 | int (*enable_st_clock)(unsigned int, bool); |
Jarkko Nikula | 09d28d2 | 2011-09-26 10:45:48 +0300 | [diff] [blame] | 69 | int (*set_clk_src)(struct device *dev, struct clk *clk, const char *src); |
Jarkko Nikula | 7bc0c4b | 2011-09-26 10:45:49 +0300 | [diff] [blame] | 70 | int (*mux_signal)(struct device *dev, const char *signal, const char *src); |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 71 | }; |
| 72 | |
Eero Nurkkala | d912fa9 | 2010-02-22 12:21:11 +0000 | [diff] [blame] | 73 | struct omap_mcbsp_st_data { |
| 74 | void __iomem *io_base_st; |
| 75 | bool running; |
| 76 | bool enabled; |
| 77 | s16 taps[128]; /* Sidetone filter coefficients */ |
| 78 | int nr_taps; /* Number of filter coefficients in use */ |
| 79 | s16 ch0gain; |
| 80 | s16 ch1gain; |
| 81 | }; |
| 82 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 83 | struct omap_mcbsp { |
| 84 | struct device *dev; |
Russell King | 6584690 | 2008-09-03 23:46:18 +0100 | [diff] [blame] | 85 | unsigned long phys_base; |
Kishon Vijay Abraham I | 3cf32bb | 2011-02-24 12:51:45 -0800 | [diff] [blame] | 86 | unsigned long phys_dma_base; |
Russell King | d592dd1 | 2008-09-04 14:25:42 +0100 | [diff] [blame] | 87 | void __iomem *io_base; |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 88 | u8 id; |
| 89 | u8 free; |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 90 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 91 | int rx_irq; |
| 92 | int tx_irq; |
| 93 | |
| 94 | /* DMA stuff */ |
| 95 | u8 dma_rx_sync; |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 96 | u8 dma_tx_sync; |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 97 | |
| 98 | /* Protect the field .free, while checking if the mcbsp is in use */ |
| 99 | spinlock_t lock; |
| 100 | struct omap_mcbsp_platform_data *pdata; |
Russell King | b820ce4 | 2009-01-23 10:26:46 +0000 | [diff] [blame] | 101 | struct clk *fclk; |
Eero Nurkkala | d912fa9 | 2010-02-22 12:21:11 +0000 | [diff] [blame] | 102 | struct omap_mcbsp_st_data *st_data; |
Peter Ujfalusi | 98cb20e | 2009-08-20 16:18:14 +0300 | [diff] [blame] | 103 | int dma_op_mode; |
Eduardo Valentin | a1a56f5f | 2009-08-20 16:18:11 +0300 | [diff] [blame] | 104 | u16 max_tx_thres; |
| 105 | u16 max_rx_thres; |
Janusz Krzysztofik | c8c9969 | 2010-02-15 10:03:33 -0800 | [diff] [blame] | 106 | void *reg_cache; |
Jarkko Nikula | ac6747ca | 2011-09-26 10:45:43 +0300 | [diff] [blame] | 107 | int reg_cache_size; |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 108 | }; |
Kishon Vijay Abraham I | 8b1906f | 2011-02-24 15:16:51 +0530 | [diff] [blame] | 109 | |
| 110 | /** |
| 111 | * omap_mcbsp_dev_attr - OMAP McBSP device attributes for omap_hwmod |
| 112 | * @sidetone: name of the sidetone device |
| 113 | */ |
| 114 | struct omap_mcbsp_dev_attr { |
| 115 | const char *sidetone; |
| 116 | }; |
| 117 | |
Chandra Shekhar | b4b58f5 | 2008-10-08 10:01:39 +0300 | [diff] [blame] | 118 | extern struct omap_mcbsp **mcbsp_ptr; |
Jarkko Nikula | ac6747ca | 2011-09-26 10:45:43 +0300 | [diff] [blame] | 119 | extern int omap_mcbsp_count; |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 120 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 121 | #endif |