This source file includes following definitions.
- sii164GetVendorID
- sii164GetDeviceID
- sii164InitChip
- sii164ResetChip
- sii164GetChipString
- sii164SetPower
- sii164SelectHotPlugDetectionMode
- sii164EnableHotPlugDetection
- sii164IsConnected
- sii164CheckInterrupt
- sii164ClearInterrupt
1
2 #define USE_DVICHIP
3 #ifdef USE_DVICHIP
4
5 #include "ddk750_sii164.h"
6 #include "ddk750_hwi2c.h"
7
8
9 #define SII164_I2C_ADDRESS 0x70
10
11
12 #define USE_HW_I2C
13
14 #ifdef USE_HW_I2C
15 #define i2cWriteReg sm750_hw_i2c_write_reg
16 #define i2cReadReg sm750_hw_i2c_read_reg
17 #else
18 #define i2cWriteReg sm750_sw_i2c_write_reg
19 #define i2cReadReg sm750_sw_i2c_read_reg
20 #endif
21
22
23 #define SII164_VENDOR_ID 0x0001
24 #define SII164_DEVICE_ID 0x0006
25
26 #ifdef SII164_FULL_FUNCTIONS
27
28 static char *gDviCtrlChipName = "Silicon Image SiI 164";
29 #endif
30
31
32
33
34
35
36
37
38 unsigned short sii164GetVendorID(void)
39 {
40 unsigned short vendorID;
41
42 vendorID = ((unsigned short)i2cReadReg(SII164_I2C_ADDRESS, SII164_VENDOR_ID_HIGH) << 8) |
43 (unsigned short)i2cReadReg(SII164_I2C_ADDRESS, SII164_VENDOR_ID_LOW);
44
45 return vendorID;
46 }
47
48
49
50
51
52
53
54
55 unsigned short sii164GetDeviceID(void)
56 {
57 unsigned short deviceID;
58
59 deviceID = ((unsigned short)i2cReadReg(SII164_I2C_ADDRESS, SII164_DEVICE_ID_HIGH) << 8) |
60 (unsigned short)i2cReadReg(SII164_I2C_ADDRESS, SII164_DEVICE_ID_LOW);
61
62 return deviceID;
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 long sii164InitChip(unsigned char edge_select,
115 unsigned char bus_select,
116 unsigned char dual_edge_clk_select,
117 unsigned char hsync_enable,
118 unsigned char vsync_enable,
119 unsigned char deskew_enable,
120 unsigned char deskew_setting,
121 unsigned char continuous_sync_enable,
122 unsigned char pll_filter_enable,
123 unsigned char pll_filter_value)
124 {
125 unsigned char config;
126
127
128 #ifdef USE_HW_I2C
129
130 sm750_hw_i2c_init(1);
131 #else
132 sm750_sw_i2c_init(DEFAULT_I2C_SCL, DEFAULT_I2C_SDA);
133 #endif
134
135
136 if ((sii164GetVendorID() == SII164_VENDOR_ID) && (sii164GetDeviceID() == SII164_DEVICE_ID)) {
137
138
139
140
141
142 if (edge_select == 0)
143 config = SII164_CONFIGURATION_LATCH_FALLING;
144 else
145 config = SII164_CONFIGURATION_LATCH_RISING;
146
147
148 if (bus_select == 0)
149 config |= SII164_CONFIGURATION_BUS_12BITS;
150 else
151 config |= SII164_CONFIGURATION_BUS_24BITS;
152
153
154 if (dual_edge_clk_select == 0)
155 config |= SII164_CONFIGURATION_CLOCK_SINGLE;
156 else
157 config |= SII164_CONFIGURATION_CLOCK_DUAL;
158
159
160 if (hsync_enable == 0)
161 config |= SII164_CONFIGURATION_HSYNC_FORCE_LOW;
162 else
163 config |= SII164_CONFIGURATION_HSYNC_AS_IS;
164
165
166 if (vsync_enable == 0)
167 config |= SII164_CONFIGURATION_VSYNC_FORCE_LOW;
168 else
169 config |= SII164_CONFIGURATION_VSYNC_AS_IS;
170
171 i2cWriteReg(SII164_I2C_ADDRESS, SII164_CONFIGURATION, config);
172
173
174
175
176
177
178 if (deskew_enable == 0)
179 config = SII164_DESKEW_DISABLE;
180 else
181 config = SII164_DESKEW_ENABLE;
182
183 switch (deskew_setting) {
184 case 0:
185 config |= SII164_DESKEW_1_STEP;
186 break;
187 case 1:
188 config |= SII164_DESKEW_2_STEP;
189 break;
190 case 2:
191 config |= SII164_DESKEW_3_STEP;
192 break;
193 case 3:
194 config |= SII164_DESKEW_4_STEP;
195 break;
196 case 4:
197 config |= SII164_DESKEW_5_STEP;
198 break;
199 case 5:
200 config |= SII164_DESKEW_6_STEP;
201 break;
202 case 6:
203 config |= SII164_DESKEW_7_STEP;
204 break;
205 case 7:
206 config |= SII164_DESKEW_8_STEP;
207 break;
208 }
209 i2cWriteReg(SII164_I2C_ADDRESS, SII164_DESKEW, config);
210
211
212 if (continuous_sync_enable == 0)
213 config = SII164_PLL_FILTER_SYNC_CONTINUOUS_DISABLE;
214 else
215 config = SII164_PLL_FILTER_SYNC_CONTINUOUS_ENABLE;
216
217
218 if (pll_filter_enable == 0)
219 config |= SII164_PLL_FILTER_DISABLE;
220 else
221 config |= SII164_PLL_FILTER_ENABLE;
222
223
224 config |= ((pll_filter_value & 0x07) << 1);
225
226 i2cWriteReg(SII164_I2C_ADDRESS, SII164_PLL, config);
227
228
229 config = i2cReadReg(SII164_I2C_ADDRESS, SII164_CONFIGURATION);
230 config |= SII164_CONFIGURATION_POWER_NORMAL;
231 i2cWriteReg(SII164_I2C_ADDRESS, SII164_CONFIGURATION, config);
232
233 return 0;
234 }
235
236
237 return -1;
238 }
239
240
241
242 #ifdef SII164_FULL_FUNCTIONS
243
244
245
246
247
248 void sii164ResetChip(void)
249 {
250
251 sii164SetPower(0);
252 sii164SetPower(1);
253 }
254
255
256
257
258
259
260 char *sii164GetChipString(void)
261 {
262 return gDviCtrlChipName;
263 }
264
265
266
267
268
269
270
271
272 void sii164SetPower(unsigned char powerUp)
273 {
274 unsigned char config;
275
276 config = i2cReadReg(SII164_I2C_ADDRESS, SII164_CONFIGURATION);
277 if (powerUp == 1) {
278
279 config &= ~SII164_CONFIGURATION_POWER_MASK;
280 config |= SII164_CONFIGURATION_POWER_NORMAL;
281 i2cWriteReg(SII164_I2C_ADDRESS, SII164_CONFIGURATION, config);
282 } else {
283
284 config &= ~SII164_CONFIGURATION_POWER_MASK;
285 config |= SII164_CONFIGURATION_POWER_DOWN;
286 i2cWriteReg(SII164_I2C_ADDRESS, SII164_CONFIGURATION, config);
287 }
288 }
289
290
291
292
293
294 static
295 void sii164SelectHotPlugDetectionMode(enum sii164_hot_plug_mode hotPlugMode)
296 {
297 unsigned char detectReg;
298
299 detectReg = i2cReadReg(SII164_I2C_ADDRESS, SII164_DETECT) &
300 ~SII164_DETECT_MONITOR_SENSE_OUTPUT_FLAG;
301 switch (hotPlugMode) {
302 case SII164_HOTPLUG_DISABLE:
303 detectReg |= SII164_DETECT_MONITOR_SENSE_OUTPUT_HIGH;
304 break;
305 case SII164_HOTPLUG_USE_MDI:
306 detectReg &= ~SII164_DETECT_INTERRUPT_MASK;
307 detectReg |= SII164_DETECT_INTERRUPT_BY_HTPLG_PIN;
308 detectReg |= SII164_DETECT_MONITOR_SENSE_OUTPUT_MDI;
309 break;
310 case SII164_HOTPLUG_USE_RSEN:
311 detectReg |= SII164_DETECT_MONITOR_SENSE_OUTPUT_RSEN;
312 break;
313 case SII164_HOTPLUG_USE_HTPLG:
314 detectReg |= SII164_DETECT_MONITOR_SENSE_OUTPUT_HTPLG;
315 break;
316 }
317
318 i2cWriteReg(SII164_I2C_ADDRESS, SII164_DETECT, detectReg);
319 }
320
321
322
323
324
325
326
327 void sii164EnableHotPlugDetection(unsigned char enableHotPlug)
328 {
329 unsigned char detectReg;
330
331 detectReg = i2cReadReg(SII164_I2C_ADDRESS, SII164_DETECT);
332
333
334
335
336 if (enableHotPlug != 0)
337 sii164SelectHotPlugDetectionMode(SII164_HOTPLUG_USE_MDI);
338 else
339 sii164SelectHotPlugDetectionMode(SII164_HOTPLUG_DISABLE);
340 }
341
342
343
344
345
346
347
348
349
350 unsigned char sii164IsConnected(void)
351 {
352 unsigned char hotPlugValue;
353
354 hotPlugValue = i2cReadReg(SII164_I2C_ADDRESS, SII164_DETECT) &
355 SII164_DETECT_HOT_PLUG_STATUS_MASK;
356 if (hotPlugValue == SII164_DETECT_HOT_PLUG_STATUS_ON)
357 return 1;
358 else
359 return 0;
360 }
361
362
363
364
365
366
367
368
369
370 unsigned char sii164CheckInterrupt(void)
371 {
372 unsigned char detectReg;
373
374 detectReg = i2cReadReg(SII164_I2C_ADDRESS, SII164_DETECT) &
375 SII164_DETECT_MONITOR_STATE_MASK;
376 if (detectReg == SII164_DETECT_MONITOR_STATE_CHANGE)
377 return 1;
378 else
379 return 0;
380 }
381
382
383
384
385
386 void sii164ClearInterrupt(void)
387 {
388 unsigned char detectReg;
389
390
391 detectReg = i2cReadReg(SII164_I2C_ADDRESS, SII164_DETECT);
392 i2cWriteReg(SII164_I2C_ADDRESS, SII164_DETECT,
393 detectReg | SII164_DETECT_MONITOR_STATE_CLEAR);
394 }
395
396 #endif
397
398 #endif