blob: 1a9e98ff6c8dea43fe6fbf4f454cf083f7dc5190 [file] [log] [blame]
Russell Kinga09e64f2008-08-05 16:14:15 +01001/*
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 Kinga09e64f2008-08-05 16:14:15 +010027#include <linux/spinlock.h>
Jarkko Nikula51672552011-09-26 10:45:46 +030028#include <linux/clk.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010029
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000030/* macro for building platform_device for McBSP ports */
31#define OMAP_MCBSP_PLATFORM_DEVICE(port_nr) \
32static struct platform_device omap_mcbsp##port_nr = { \
33 .name = "omap-mcbsp-dai", \
Jarkko Nikulafd1ee392011-07-01 08:52:27 +000034 .id = port_nr - 1, \
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000035}
36
Charulatha V37801b32011-02-24 12:51:46 -080037#define MCBSP_CONFIG_TYPE2 0x2
Charulatha Vdc48e5f2011-02-24 15:16:49 +053038#define MCBSP_CONFIG_TYPE3 0x3
Kishon Vijay Abraham Icb7e9de2011-02-24 15:16:50 +053039#define MCBSP_CONFIG_TYPE4 0x4
Charulatha V37801b32011-02-24 12:51:46 -080040
Paul Walmsleycf4c87a2010-10-08 11:40:19 -060041/* 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 Walmsleyd1358652010-10-08 11:40:19 -060049/* McBSP functional clock sources */
Jarkko Nikulae4cc41d2010-10-08 11:40:21 -060050#define MCBSP_CLKS_PRCM_SRC 0
51#define MCBSP_CLKS_PAD_SRC 1
Paul Walmsleyd1358652010-10-08 11:40:19 -060052
Russell Kinga09e64f2008-08-05 16:14:15 +010053/* Platform specific configuration */
54struct omap_mcbsp_ops {
55 void (*request)(unsigned int);
56 void (*free)(unsigned int);
Russell Kinga09e64f2008-08-05 16:14:15 +010057};
58
59struct omap_mcbsp_platform_data {
Russell Kinga09e64f2008-08-05 16:14:15 +010060 struct omap_mcbsp_ops *ops;
Kishon Vijay Abraham I64bcbd32011-02-24 15:16:52 +053061 u16 buffer_size;
Jarkko Nikulacdc715142011-09-26 10:45:39 +030062 u8 reg_size;
63 u8 reg_step;
Jarkko Nikula1a645882011-09-26 10:45:40 +030064
65 /* McBSP platform and instance specific features */
66 bool has_wakeup; /* Wakeup capability */
Jarkko Nikula88408232011-09-26 10:45:41 +030067 bool has_ccr; /* Transceiver has configuration control registers */
Jarkko Nikula1743d142011-09-26 10:45:44 +030068 int (*enable_st_clock)(unsigned int, bool);
Jarkko Nikula09d28d22011-09-26 10:45:48 +030069 int (*set_clk_src)(struct device *dev, struct clk *clk, const char *src);
Jarkko Nikula7bc0c4b2011-09-26 10:45:49 +030070 int (*mux_signal)(struct device *dev, const char *signal, const char *src);
Russell Kinga09e64f2008-08-05 16:14:15 +010071};
72
Eero Nurkkalad912fa92010-02-22 12:21:11 +000073struct 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 Kinga09e64f2008-08-05 16:14:15 +010083struct omap_mcbsp {
84 struct device *dev;
Russell King65846902008-09-03 23:46:18 +010085 unsigned long phys_base;
Kishon Vijay Abraham I3cf32bb2011-02-24 12:51:45 -080086 unsigned long phys_dma_base;
Russell Kingd592dd12008-09-04 14:25:42 +010087 void __iomem *io_base;
Russell Kinga09e64f2008-08-05 16:14:15 +010088 u8 id;
89 u8 free;
Russell Kinga09e64f2008-08-05 16:14:15 +010090
Russell Kinga09e64f2008-08-05 16:14:15 +010091 int rx_irq;
92 int tx_irq;
93
94 /* DMA stuff */
95 u8 dma_rx_sync;
Russell Kinga09e64f2008-08-05 16:14:15 +010096 u8 dma_tx_sync;
Russell Kinga09e64f2008-08-05 16:14:15 +010097
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 Kingb820ce42009-01-23 10:26:46 +0000101 struct clk *fclk;
Eero Nurkkalad912fa92010-02-22 12:21:11 +0000102 struct omap_mcbsp_st_data *st_data;
Peter Ujfalusi98cb20e2009-08-20 16:18:14 +0300103 int dma_op_mode;
Eduardo Valentina1a56f5f2009-08-20 16:18:11 +0300104 u16 max_tx_thres;
105 u16 max_rx_thres;
Janusz Krzysztofikc8c99692010-02-15 10:03:33 -0800106 void *reg_cache;
Jarkko Nikulaac6747ca2011-09-26 10:45:43 +0300107 int reg_cache_size;
Russell Kinga09e64f2008-08-05 16:14:15 +0100108};
Kishon Vijay Abraham I8b1906f2011-02-24 15:16:51 +0530109
110/**
111 * omap_mcbsp_dev_attr - OMAP McBSP device attributes for omap_hwmod
112 * @sidetone: name of the sidetone device
113 */
114struct omap_mcbsp_dev_attr {
115 const char *sidetone;
116};
117
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300118extern struct omap_mcbsp **mcbsp_ptr;
Jarkko Nikulaac6747ca2011-09-26 10:45:43 +0300119extern int omap_mcbsp_count;
Russell Kinga09e64f2008-08-05 16:14:15 +0100120
Russell Kinga09e64f2008-08-05 16:14:15 +0100121#endif