aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/tdmb/mtv318/raontv.c
blob: d450aa9dfb52e046b459cd1116e52bda45f7e012 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*
 *
 * File name: drivers/media/tdmb/mtv318/src/raontv.c
 *
 * Description : RAONTECH TV device driver.
 *
 * Copyright (C) (2011, RAONTECH)
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation version 2.
 *
 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
 * kind, whether express or implied; without even the implied warranty
 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 */

#include "raontv_rf.h"

BOOL g_fRtvChannelChange;

enum E_RTV_ADC_CLK_FREQ_TYPE g_eRtvAdcClkFreqType;
BOOL g_fRtvStreamEnabled;

#if defined(RTV_TDMB_ENABLE) || defined(RTV_ISDBT_ENABLE)
enum E_RTV_COUNTRY_BAND_TYPE g_eRtvCountryBandType;
#endif

#ifdef RTV_DAB_ENABLE
enum E_RTV_TV_MODE_TYPE g_curDabSetType;
#endif

#ifdef RTV_IF_EBI2
VU8 g_bRtvEbiMapSelData = 0x7;
#endif

UINT g_nRtvMscThresholdSize;

#if defined(RTV_IF_SPI) || defined(RTV_IF_EBI2)
U8 g_bRtvIntrMaskRegL;

#else
#if !defined(RTV_CIF_MODE_ENABLED) || !defined(RTV_FIC_POLLING_MODE)
U8 g_bRtvIntrMaskRegL;
#endif
#endif

void rtv_ConfigureHostIF(void)
{
#if defined(RTV_IF_TSIF) || defined(RTV_IF_SPI_SLAVE)
	RTV_REG_MAP_SEL(HOST_PAGE);
	RTV_REG_SET(0x77, 0x15); /* TSIF Enable */
	RTV_REG_SET(0x22, 0x48);

#if defined(RTV_IF_MPEG2_PARALLEL_TSIF)
	RTV_REG_SET(0x04, 0x01); /* I2C + TSIF Mode Enable*/
#else
	RTV_REG_SET(0x04, 0x29); /* I2C + TSIF Mode Enable*/
#endif

	RTV_REG_SET(0x0C, 0xF4); /* TSIF Enable*/

#elif defined(RTV_IF_SPI) || defined(RTV_IF_EBI2)
	RTV_REG_MAP_SEL(HOST_PAGE);
	RTV_REG_SET(0x77, 0x14); /*SPI Mode Enable*/
	RTV_REG_SET(0x04, 0x28); /* SPI Mode Enable*/
	RTV_REG_SET(0x0C, 0xF5);

#else
#error "Code not present"
#endif
}

INT rtv_InitSystem(enum E_RTV_TV_MODE_TYPE eTvMode,
		enum E_RTV_ADC_CLK_FREQ_TYPE eAdcClkFreqType)
{
	INT nRet;
	int i;

	g_fRtvChannelChange = FALSE;

	g_fRtvStreamEnabled = FALSE;

#if defined(RTV_IF_SPI) || defined(RTV_IF_EBI2)
	g_bRtvIntrMaskRegL = 0xFF;
#else
#ifndef RTV_CIF_MODE_ENABLED /* Individual Mode */
	g_bRtvIntrMaskRegL = 0xFF;
#endif
#endif

	for (i = 1; i <= 100; i++) {
		RTV_REG_MAP_SEL(HOST_PAGE);
		RTV_REG_SET(0x7D, 0x06);
		if (RTV_REG_GET(0x7D) == 0x06)
			goto RTV_POWER_ON_SUCCESS;

		RTV_DBGMSG1("[rtv_InitSystem] Power On wait: %d\n", i);

		RTV_DELAY_MS(5);
	}

	RTV_DBGMSG1("rtv_InitSystem: Power On Check error: %d\n", i);
	return RTV_POWER_ON_CHECK_ERROR;

RTV_POWER_ON_SUCCESS:

	rtvRF_ConfigurePowerType(eTvMode);
	nRet = rtvRF_ConfigureAdcClock(eTvMode, eAdcClkFreqType);

	if (nRet != RTV_SUCCESS)
		return nRet;

	return RTV_SUCCESS;
}