3 * File name: drivers/media/tdmb/mtv318/src/raontv_port.h
5 * Description : RAONTECH TV configuration header file.
7 * Copyright (C) (2011, RAONTECH)
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 version 2.
13 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
14 * kind, whether express or implied; without even the implied warranty
15 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
20 #ifndef __RAONTV_PORT_H__
21 #define __RAONTV_PORT_H__
23 /*==============================================================================
24 * Includes the user header files if neccessry.
25 *============================================================================*/
26 #if defined(__KERNEL__) /* Linux kernel */
28 #include <linux/kernel.h>
29 #include <linux/delay.h>
31 #include <linux/mutex.h>
42 /*##############################################################################
44 # COMMON configurations
46 #############################################################################*/
47 /*==============================================================================
48 * The slave address for I2C and SPI, the base address for EBI2.
49 *============================================================================*/
50 #define RAONTV_CHIP_ADDR 0x86
52 /*==============================================================================
53 * Modifies the basic data types if neccessry.
54 *============================================================================*/
64 #define UINT unsigned int
66 #define ULONG unsigned long
70 /*==============================================================================
71 * Selects the TV mode(s) to target product.
72 *============================================================================*/
73 /*#define RTV_ISDBT_ENABLE*/
74 #define RTV_TDMB_ENABLE
75 /*#define RTV_FM_ENABLE*/
76 /*#define RTV_DAB_ENABLE*/
78 /*==============================================================================
79 * Defines the package type of chip to target product.
80 *============================================================================*/
81 #define RAONTV_CHIP_PKG_WLCSP /* MTV220/318*/
82 /*#define RAONTV_CHIP_PKG_QFN // MTV818*/
83 /* #define RAONTV_CHIP_PKG_LGA MTV250/350 */
84 /*==============================================================================
85 * Defines the external source freqenecy in KHz.
86 * Ex> #define RTV_SRC_CLK_FREQ_KHz 36000 // 36MHz
87 *==============================================================================
88 * MTV250 : #define RTV_SRC_CLK_FREQ_KHz 32000 //must be defined
89 * MTV350 : #define RTV_SRC_CLK_FREQ_KHz 24576 //must be defined
90 *============================================================================*/
91 #define RTV_SRC_CLK_FREQ_KHz 24576
93 /*==============================================================================
94 * Define the power type.
95 *============================================================================*/
96 /*#define RTV_PWR_EXTERNAL*/
98 /* #define RTV_PWR_DCDC */
100 /*==============================================================================
101 * Defines the I/O voltage.
102 *============================================================================*/
104 /*#define RTV_IO_2_5V*/
105 /*#define RTV_IO_3_3V*/
107 #if defined(RTV_IO_2_5V) || defined(RTV_IO_3_3V)
108 #error "If VDDIO pin is connected with IO voltage,"
109 " RTV_IO_1_8V must be defined,please check the HW pin connection"
110 #error "If VDDIO pin is connected with GND,"
111 " IO voltage must be defined same as AP IO voltage"
114 /*==============================================================================
115 * Defines the Host interface.
116 *============================================================================*/
117 /*#define RTV_IF_MPEG2_SERIAL_TSIF*/ /* I2C + TSIF Master Mode. */
118 /*#define RTV_IF_MPEG2_PARALLEL_TSIF*/ /* I2C + TSIF Master Mode.
119 Support only 1seg &TDMB Application!*/
120 /*#define RTV_IF_QUALCOMM_TSIF*/ /* I2C + TSIF Master Mode */
121 #define RTV_IF_SPI /* AP: SPI Master Mode */
122 /*#define RTV_IF_SPI_SLAVE*/ /* AP: SPI Slave Mode */
123 /*#define RTV_IF_EBI2*/ /* External Bus Interface Slave Mode */
125 /*==============================================================================
126 * Defines the clear mode of interrupts for EBI/SPI in Individual mode .
127 *============================================================================*/
128 #define RTV_MSC_INTR_ISTAUS_ACC_CLR_MODE /* for Nested ISR and TSIF. */
129 /* #define RTV_MSC_INTR_MEM_ACC_CLR_MODE */ /* for NOT nested ISR.*/
131 /*==============================================================================
132 * Defines the delay macro in milliseconds.
133 *============================================================================*/
134 #if defined(__KERNEL__)/* Linux kernel */
135 #define RTV_DELAY_MS(ms) mdelay(ms)
138 #define RTV_DELAY_MS(ms) Sleep(ms)
141 extern void mtv818_delay_ms(int ms);
142 #define RTV_DELAY_MS(ms) mtv818_delay_ms(ms) /* TODO */
145 /*==============================================================================
146 * Defines the debug message macro.
147 *============================================================================*/
149 #define RTV_DBGMSG0(fmt) printk(fmt)
150 #define RTV_DBGMSG1(fmt, arg1) printk(fmt, arg1)
151 #define RTV_DBGMSG2(fmt, arg1, arg2) printk(fmt, arg1, arg2)
152 #define RTV_DBGMSG3(fmt, arg1, arg2, arg3) printk(fmt, arg1, arg2, arg3)
154 /* To eliminates the debug messages. */
155 #define RTV_DBGMSG0(fmt) ((void)0)
156 #define RTV_DBGMSG1(fmt, arg1) ((void)0)
157 #define RTV_DBGMSG2(fmt, arg1, arg2) ((void)0)
158 #define RTV_DBGMSG3(fmt, arg1, arg2, arg3) ((void)0)
160 /*#### End of Common ###########*/
162 /*##############################################################################
164 # ISDB-T specific configurations
166 #############################################################################*/
167 /*==============================================================================
168 * Defines the NOTCH FILTER setting Enable.
169 * In order to reject GSM/CDMA blocker, NOTCH FILTER must be defined.
170 * This feature used for module company in the JAPAN.
171 *============================================================================*/
173 //#if defined(RTV_ISDBT_ENABLE) //Do not use
174 // #ifdef RAONTV_CHIP_PKG_WLCSP
175 // #define RTV_NOTCH_FILTER_ENABLE
179 /*##############################################################################
181 # T-DMB/DAB specific configurations
183 #############################################################################*/
184 #if defined(RTV_TDMB_ENABLE) || defined(RTV_DAB_ENABLE)
185 #define RTV_FIC_POLLING_MODE
187 /* Defines the maximum number of Sub Channel to be open simultaneously. */
188 #define RTV_MAX_NUM_SUB_CHANNEL_USED 1
190 /* Defines CIF or Individual Mode for T-DMB/DAB BY RAONTECH. */
191 /*#define RTV_CIF_MODE_ENABLED*/
192 /*#define RTV_CIF_HEADER_INSERTED*/
193 /* Select the copying method of CIF decoded data(FIC and MSC)
194 which copy_to_user() or memcpy() to fast operation for LINUX Kernel. */
195 /*#define RTV_CIF_LINUX_USER_SPACE_COPY_USED*/
196 #endif /* #if defined(RTV_TDMB_ENABLE) || defined(RTV_DAB_ENABLE) */
198 /*##############################################################################
200 # FM specific configurations
202 #############################################################################*/
203 #define RTV_FM_CH_MIN_FREQ_KHz 76000
204 #define RTV_FM_CH_MAX_FREQ_KHz 108000
205 #define RTV_FM_CH_STEP_FREQ_KHz 100 /* in KHz */
206 /*##############################################################################
208 # Host Interface specific configurations
210 #############################################################################*/
211 #if defined(RTV_IF_MPEG2_SERIAL_TSIF) || defined(RTV_IF_QUALCOMM_TSIF) \
212 || defined(RTV_IF_MPEG2_PARALLEL_TSIF)
216 #if defined(RTV_IF_MPEG2_SERIAL_TSIF) || defined(RTV_IF_QUALCOMM_TSIF)
217 #define RTV_IF_SERIAL_TSIF
221 #if defined(RTV_IF_TSIF) || defined(RTV_IF_SPI_SLAVE)
222 /*==============================================================================
223 * Defines the TSIF interface for MPEG2 or QUALCOMM TSIF.
224 *============================================================================*/
225 /*#define RTV_TSIF_FORMAT_1*/
226 /*#define RTV_TSIF_FORMAT_2*/
227 #define RTV_TSIF_FORMAT_3
228 /*#define RTV_TSIF_FORMAT_4*/
229 /*#define RTV_TSIF_FORMAT_5*/
231 /*#define RTV_TSIF_CLK_SPEED_DIV_2 // Host Clk/2*/
232 #define RTV_TSIF_CLK_SPEED_DIV_4 /* Host Clk/4 */
233 /*#define RTV_TSIF_CLK_SPEED_DIV_6 // Host Clk/6*/
234 /*#define RTV_TSIF_CLK_SPEED_DIV_8 // Host Clk/8*/
236 /*==========================================================================
237 * Defines the register I/O macros.
238 *========================================================================*/
239 unsigned char mtv818_i2c_read(U8 reg);
240 void mtv818_i2c_read_burst(U8 reg, U8 *buf, int size);
241 void mtv818_i2c_write(U8 reg, U8 val);
242 #define RTV_REG_GET(reg) \
243 mtv818_i2c_read((U8)(reg))
244 #define RTV_REG_BURST_GET(reg, buf, size) \
245 mtv818_i2c_read_burst((U8)(reg), buf, size)
246 #define RTV_REG_SET(reg, val) \
247 mtv818_i2c_write((U8)(reg), (U8)(val))
248 #define RTV_REG_MASK_SET(reg, mask, val)\
251 tmp = (RTV_REG_GET(reg)|(U8)(mask)) & (U8)((~(mask))|(val)); \
252 RTV_REG_SET(reg, tmp); \
255 #elif defined(RTV_IF_SPI)
256 /*=========================================================================
257 * Defines the register I/O macros.
258 *========================================================================*/
259 unsigned char mtv_spi_read(unsigned char reg);
260 void mtv_spi_read_burst(unsigned char reg, unsigned char *buf, int size);
261 void mtv_spi_write(unsigned char reg, unsigned char val);
263 #define RTV_REG_GET(reg) \
264 (U8)mtv_spi_read((U8)(reg))
265 #define RTV_REG_BURST_GET(reg, buf, size) \
266 mtv_spi_read_burst((U8)(reg), buf, size)
267 #define RTV_REG_SET(reg, val) \
268 mtv_spi_write((U8)(reg), (U8)(val))
269 #define RTV_REG_MASK_SET(reg, mask, val) \
272 tmp = (RTV_REG_GET(reg)|(U8)(mask)) & (U8)((~(mask))|(val)); \
273 RTV_REG_SET(reg, tmp); \
279 #error "Must define the interface definition !"
282 #if defined(RTV_IF_SPI) \
283 || ((defined(RTV_TDMB_ENABLE) || defined(RTV_DAB_ENABLE)) \
284 && !defined(RTV_FIC_POLLING_MODE))
285 #if defined(__KERNEL__)
286 extern struct mutex raontv_guard;
287 #define RTV_GUARD_INIT mutex_init(&raontv_guard)
288 #define RTV_GUARD_LOCK mutex_lock(&raontv_guard)
289 #define RTV_GUARD_FREE mutex_unlock(&raontv_guard)
290 #define RTV_GUARD_DEINIT ((void)0)
293 extern CRITICAL_SECTION raontv_guard;
294 #define RTV_GUARD_INIT InitializeCriticalSection(&raontv_guard)
295 #define RTV_GUARD_LOCK EnterCriticalSection(&raontv_guard)
296 #define RTV_GUARD_FREE LeaveCriticalSection(&raontv_guard)
297 #define RTV_GUARD_DEINIT DeleteCriticalSection(&raontv_guard)
300 #define RTV_GUARD_INIT ((void)0)
301 #define RTV_GUARD_LOCK ((void)0)
302 #define RTV_GUARD_FREE ((void)0)
303 #define RTV_GUARD_DEINIT ((void)0)
307 #define RTV_GUARD_INIT ((void)0)
308 #define RTV_GUARD_LOCK ((void)0)
309 #define RTV_GUARD_FREE ((void)0)
310 #define RTV_GUARD_DEINIT ((void)0)
313 #if defined(RTV_IF_TSIF) || defined(RTV_IF_SPI_SLAVE)\
314 || defined(__KERNEL__) || defined(WINCE)
315 #ifdef RTV_MSC_INTR_MEM_ACC_CLR_MODE
316 #undef RTV_MSC_INTR_MEM_ACC_CLR_MODE
319 #ifndef RTV_MSC_INTR_ISTAUS_ACC_CLR_MODE
320 #define RTV_MSC_INTR_ISTAUS_ACC_CLR_MODE
325 /*==============================================================================
327 *============================================================================*/
328 #if !defined(RAONTV_CHIP_PKG_WLCSP) \
329 && !defined(RAONTV_CHIP_PKG_QFN) \
330 && !defined(RAONTV_CHIP_PKG_LGA)
331 #error "Must define the package type !"
334 #if !defined(RTV_PWR_EXTERNAL) \
335 && !defined(RTV_PWR_LDO) \
336 && !defined(RTV_PWR_DCDC)
337 #error "Must define the power type !"
340 #if !defined(RTV_IO_1_8V) \
341 && !defined(RTV_IO_2_5V) \
342 && !defined(RTV_IO_3_3V)
343 #error "Must define I/O voltage!"
346 #if defined(RTV_IF_MPEG2_SERIAL_TSIF) \
347 || defined(RTV_IF_SPI_SLAVE) \
348 || defined(RTV_IF_MPEG2_PARALLEL_TSIF) \
349 || defined(RTV_IF_QUALCOMM_TSIF) \
350 || defined(RTV_IF_SPI)
351 #if (RAONTV_CHIP_ADDR >= 0xFF)
352 #error "Invalid chip address"
354 #elif defined(RTV_IF_EBI2)
355 #if (RAONTV_CHIP_ADDR <= 0xFF)
356 #error "Invalid chip address"
360 #error "Must define the interface definition !"
363 #if defined(RTV_TDMB_ENABLE) || defined(RTV_DAB_ENABLE)
364 #ifndef RTV_MAX_NUM_SUB_CHANNEL_USED
365 #error "Should be define!"
368 #if defined(RTV_IF_SPI) || defined(RTV_IF_EBI2)
369 #if (RTV_MAX_NUM_SUB_CHANNEL_USED < 0) || (RTV_MAX_NUM_SUB_CHANNEL_USED > 5)
370 #error "Must from 1 to 5"
373 #if (RTV_MAX_NUM_SUB_CHANNEL_USED < 0) || (RTV_MAX_NUM_SUB_CHANNEL_USED > 4)
374 #error "Must from 1 to 4"
378 #ifdef RTV_MAX_NUM_SUB_CHANNEL_USED
379 #undef RTV_MAX_NUM_SUB_CHANNEL_USED
380 #define RTV_MAX_NUM_SUB_CHANNEL_USED 1 /* To not make error. */
382 #define RTV_MAX_NUM_SUB_CHANNEL_USED 1
386 #ifdef RTV_IF_MPEG2_PARALLEL_TSIF
387 #if defined(RTV_FM_ENABLE) \
388 || defined(RTV_DAB_ENABLE) \
389 || defined(RAONTV_CHIP_PKG_WLCSP) \
390 || defined(RAONTV_CHIP_PKG_LGA)
391 #error "Not support parallel TSIF!"
394 #if defined(RTV_TDMB_ENABLE) && (RTV_MAX_NUM_SUB_CHANNEL_USED > 1)
395 #error "Not support T-DMB multi sub channel mode!"
398 #if defined(RTV_DAB_ENABLE) && (RTV_MAX_NUM_SUB_CHANNEL_USED > 1)
399 #error "Not support DAB multi sub channel mode!"
403 #if defined(RTV_IF_SPI) || defined(RTV_IF_EBI2)
404 #if !defined(RTV_MSC_INTR_MEM_ACC_CLR_MODE) \
405 && !defined(RTV_MSC_INTR_ISTAUS_ACC_CLR_MODE)
406 #error " Should selects an interrupt clear mode"
409 #if defined(RTV_MSC_INTR_MEM_ACC_CLR_MODE) \
410 && defined(RTV_MSC_INTR_ISTAUS_ACC_CLR_MODE)
411 #error " Should selects an interrupt clear mode"
415 #if defined(RTV_DAB_ENABLE) && defined(RTV_TDMB_ENABLE)
416 #error "Should select RTV_DAB_ENABLE(B3, L-BAND, B3-Korea) "
417 "or RTV_TDMB_ENABLE(B3-Korea)"
420 #if defined(RTV_CIF_HEADER_INSERTED) && !defined(RTV_CIF_MODE_ENABLED)
421 #error "Should defines RTV_CIF_MODE_ENABLED"
424 void rtvOEM_ConfigureInterrupt(void);
425 void rtvOEM_PowerOn(int on);
431 #endif /* __RAONTV_PORT_H__ */