aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/isdbt/fc8100/fci_hal.c
blob: 952f44ef63b6ffc19a68fffe9a6264756da7a760 (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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
/*****************************************************************************
 Copyright(c) 2009 FCI Inc. All Rights Reserved

 File name : fc8100_hal.c

 Description : fc8100 host interface

 History :
 ----------------------------------------------------------------------
 2009/08/29	jason		initial
*******************************************************************************/

#include "fci_types.h"
#include "fci_oal.h"
#include "bbm.h"
#include "fci_hal.h"
#include "fc8100_i2c.h"

typedef struct {
	int (*init)(HANDLE hDevice, u16 param1, u16 param2);

	int (*byteread)(HANDLE hDevice, u16 addr, u8  *data);
	int (*wordread)(HANDLE hDevice, u16 addr, u16 *data);
	int (*longread)(HANDLE hDevice, u16 addr, u32 *data);
	int (*bulkread)(HANDLE hDevice, u16 addr, u8  *data, u16 size);

	int (*bytewrite)(HANDLE hDevice, u16 addr, u8  data);
	int (*wordwrite)(HANDLE hDevice, u16 addr, u16 data);
	int (*longwrite)(HANDLE hDevice, u16 addr, u32 data);
	int (*bulkwrite)(HANDLE hDevice, u16 addr, u8 *data, u16 size);
	int (*dataread)(HANDLE hDevice, u16 addr, u8 *data, u16 size);

	int (*deinit)(HANDLE hDevice);
} IF_PORT;

static IF_PORT i2cif = {
	&fc8100_i2c_init,

	&fc8100_i2c_byteread,
	&fc8100_i2c_wordread,
	&fc8100_i2c_longread,
	&fc8100_i2c_bulkread,

	&fc8100_i2c_bytewrite,
	&fc8100_i2c_wordwrite,
	&fc8100_i2c_longwrite,
	&fc8100_i2c_bulkwrite,
	&fc8100_spi_dataread,

	&fc8100_i2c_deinit
};

static IF_PORT *ifport = &i2cif;
static u8 hostif_type = BBM_I2C;

int bbm_hostif_get(HANDLE hDevice, u8 *hostif)
{
	*hostif = hostif_type;

	return BBM_OK;
}

int bbm_hostif_select(HANDLE hDevice, u8 hostif)
{
	int  res = BBM_OK;

	hostif_type = hostif;

	switch (hostif) {
#if 0
		case BBM_HPI:
			ifport = &hpiif;
			break;
		case BBM_SPI:
			ifport = &spiif;
			break;
#endif
		case BBM_I2C:
			ifport = &i2cif;
			break;
		default:
			res = BBM_NOK;
			break;
	}

	if (res == BBM_OK)
		ifport->init(hDevice, 0, 0);

	return res;
}

int bbm_hostif_deselect(HANDLE hDevice)
{
	int  res = BBM_OK;

	ifport->deinit(hDevice);

	hostif_type = 0;
	ifport = NULL;

	return res;
}

int bbm_read(HANDLE hDevice, u16 addr, u8 *data)
{
	int res;

	res  = ifport->byteread(hDevice, addr, data);

	return res;
}

int bbm_byte_read(HANDLE hDevice, u16 addr, u8 *data)
{
	int res;

	res  = ifport->byteread(hDevice, addr, data);

	return res;
}

int bbm_word_read(HANDLE hDevice, u16 addr, u16 *data)
{
	int res;

	res  = ifport->wordread(hDevice, addr, data);

	return res;
}

int bbm_long_read(HANDLE hDevice, u16 addr, u32 *data)
{
	int res;

	res  = ifport->longread(hDevice, addr, data);

	return res;
}

int bbm_bulk_read(HANDLE hDevice, u16 addr, u8 *data, u16 length)
{
	int res;

	res  = ifport->bulkread(hDevice, addr, data, length);

	return res;
}

int bbm_write(HANDLE hDevice, u16 addr, u8 data)
{
	int res;

	res  = ifport->bytewrite(hDevice, addr, data);

	return res;
}

int bbm_byte_write(HANDLE hDevice, u16 addr, u8 data)
{
	int res;

	res  = ifport->bytewrite(hDevice, addr, data);

	return res;
}

int bbm_word_write(HANDLE hDevice, u16 addr, u16 data)
{
	int res;

	res  = ifport->wordwrite(hDevice, addr, data);

	return res;
}

int bbm_long_write(HANDLE hDevice, u16 addr, u32 data)
{
	int res;

	res  = ifport->longwrite(hDevice, addr, data);

	return res;
}

int bbm_bulk_write(HANDLE hDevice, u16 addr, u8 *data, u16 length)
{
	int res;

	res  = ifport->bulkwrite(hDevice, addr, data, length);

	return res;
}

int bbm_data(HANDLE hDevice, u16 addr, u8 *data, u16 length)
{
	int res = BBM_NOK;
	res = ifport->dataread(hDevice, addr, data, length);
	return res;
}