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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
|
/*****************************************************************************
Copyright(c) 2013 FCI Inc. All Rights Reserved
File name : fci_hal.c
Description : fc8080 host interface source file
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; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
History :
----------------------------------------------------------------------
*******************************************************************************/
#include "fci_types.h"
#include "fci_hal.h"
#include "fc8080_i2c.h"
#if defined(CONFIG_TDMB_SPI)
#include "fc8080_spi.h"
#endif
#if defined(CONFIG_TDMB_EBI)
#include "fc8080_ppi.h"
#endif
struct interface_port {
s32 (*init)(HANDLE handle, unsigned long param);
s32 (*byteread)(HANDLE handle, u16 addr, u8 *data);
s32 (*wordread)(HANDLE handle, u16 addr, u16 *data);
s32 (*longread)(HANDLE handle, u16 addr, u32 *data);
s32 (*bulkread)(HANDLE handle, u16 addr, u8 *data, u16 size);
s32 (*bytewrite)(HANDLE handle, u16 addr, u8 data);
s32 (*wordwrite)(HANDLE handle, u16 addr, u16 data);
s32 (*longwrite)(HANDLE handle, u16 addr, u32 data);
s32 (*bulkwrite)(HANDLE handle, u16 addr, u8 *data, u16 size);
s32 (*dataread)(HANDLE handle, u16 addr, u8 *data, u32 size);
s32 (*deinit)(HANDLE handle);
} ;
#if defined(CONFIG_TDMB_SPI)
static struct interface_port spiif = {
&fc8080_spi_init,
&fc8080_spi_byteread,
&fc8080_spi_wordread,
&fc8080_spi_longread,
&fc8080_spi_bulkread,
&fc8080_spi_bytewrite,
&fc8080_spi_wordwrite,
&fc8080_spi_longwrite,
&fc8080_spi_bulkwrite,
&fc8080_spi_dataread,
&fc8080_spi_deinit
};
#endif
#if defined(CONFIG_TDMB_EBI)
static struct interface_port ppiif = {
&fc8080_ppi_init,
&fc8080_ppi_byteread,
&fc8080_ppi_wordread,
&fc8080_ppi_longread,
&fc8080_ppi_bulkread,
&fc8080_ppi_bytewrite,
&fc8080_ppi_wordwrite,
&fc8080_ppi_longwrite,
&fc8080_ppi_bulkwrite,
&fc8080_ppi_dataread,
&fc8080_ppi_deinit
};
#endif
#if defined(CONFIG_TDMB_I2C)
static struct interface_port i2cif = {
&fc8080_i2c_init,
&fc8080_i2c_byteread,
&fc8080_i2c_wordread,
&fc8080_i2c_longread,
&fc8080_i2c_bulkread,
&fc8080_i2c_bytewrite,
&fc8080_i2c_wordwrite,
&fc8080_i2c_longwrite,
&fc8080_i2c_bulkwrite,
&fc8080_i2c_dataread,
&fc8080_i2c_deinit
};
#endif
static struct interface_port *ifport;
static u8 hostif_type;
s32 bbm_hostif_select(HANDLE handle, u8 hostif, unsigned long param)
{
hostif_type = hostif;
switch (hostif){
#if defined(CONFIG_TDMB_SPI)
case BBM_SPI:
ifport = &spiif;
break;
#endif
#if defined(CONFIG_TDMB_I2C)
case BBM_I2C:
ifport = &i2cif;
break;
#endif
#if defined(CONFIG_TDMB_EBI)
case BBM_PPI:
ifport = &ppiif;
break;
#endif
default:
return BBM_E_HOSTIF_SELECT;
}
if (ifport->init(handle, param))
return BBM_E_HOSTIF_INIT;
return BBM_OK;
}
s32 bbm_hostif_deselect(HANDLE handle)
{
if (ifport->deinit(handle))
return BBM_NOK;
hostif_type = 0;
return BBM_OK;
}
s32 bbm_read(HANDLE handle, u16 addr, u8 *data)
{
if (ifport->byteread(handle, addr, data))
return BBM_E_BB_READ;
return BBM_OK;
}
s32 bbm_byte_read(HANDLE handle, u16 addr, u8 *data)
{
if (ifport->byteread(handle, addr, data))
return BBM_E_BB_READ;
return BBM_OK;
}
s32 bbm_word_read(HANDLE handle, u16 addr, u16 *data)
{
if (ifport->wordread(handle, addr, data))
return BBM_E_BB_READ;
return BBM_OK;
}
s32 bbm_long_read(HANDLE handle, u16 addr, u32 *data)
{
if (ifport->longread(handle, addr, data))
return BBM_E_BB_READ;
return BBM_OK;
}
s32 bbm_bulk_read(HANDLE handle, u16 addr, u8 *data, u16 length)
{
if (ifport->bulkread(handle, addr, data, length))
return BBM_E_BB_READ;
return BBM_OK;
}
s32 bbm_write(HANDLE handle, u16 addr, u8 data)
{
if (ifport->bytewrite(handle, addr, data))
return BBM_E_BB_WRITE;
return BBM_OK;
}
s32 bbm_byte_write(HANDLE handle, u16 addr, u8 data)
{
if (ifport->bytewrite(handle, addr, data))
return BBM_E_BB_WRITE;
return BBM_OK;
}
s32 bbm_word_write(HANDLE handle, u16 addr, u16 data)
{
if (ifport->wordwrite(handle, addr, data))
return BBM_E_BB_WRITE;
return BBM_OK;
}
s32 bbm_long_write(HANDLE handle, u16 addr, u32 data)
{
if (ifport->longwrite(handle, addr, data))
return BBM_E_BB_WRITE;
return BBM_OK;
}
s32 bbm_bulk_write(HANDLE handle, u16 addr, u8 *data, u16 length)
{
if (ifport->bulkwrite(handle, addr, data, length))
return BBM_E_BB_WRITE;
return BBM_OK;
}
s32 bbm_data(HANDLE handle, u16 addr, u8 *data, u32 length)
{
if (ifport->dataread(handle, addr, data, length))
return BBM_E_BB_WRITE;
return BBM_OK;
}
|