vpllinit.c
2.14 KB
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
#include <os.h>
#include <bbint.h>
#include <bcp.h>
#include <os_internal_reg.h>
void __osBbVideoPllInit(s32 tvType)
{
u32 avctrl;
u32 mask;
mask = __osDisableInt();
/* Stop the VI and AI - in case we are running */
IO_WRITE(VI_CONTROL_REG, 0x0);
IO_WRITE(AI_CONTROL_REG, 0x0);
__osBbDelay(50);
/* Reset the VI and AI, but leave PLL running */
avctrl = IO_READ(MI_AVCTRL_REG);
avctrl &= ~MI_AVCTRL_AV_RESET;
IO_WRITE(MI_AVCTRL_REG, avctrl);
__osBbDelay(50);
/* Put the PLL in standby mode -- it should already be if we are powering up */
IO_WRITE(MI_AVCTRL_REG, avctrl | MI_AVCTRL_VPLL_STANDBY);
__osBbDelay(50);
/* Initialize the AVPLL */
if (tvType == OS_TV_PAL) {
avctrl = MI_AVCTRL_DAC_POWER |
(1<<MI_AVCTRL_VPLL_PDIV_SHIFT) |
(27<<MI_AVCTRL_VPLL_NDIV_SHIFT) |
(4<<MI_AVCTRL_VPLL_MDIV_SHIFT) |
(1<<MI_AVCTRL_VPLL_FRANGE_SHIFT);
} else if (tvType == OS_TV_MPAL) {
avctrl = MI_AVCTRL_VENC_VMPAL |
MI_AVCTRL_DAC_POWER |
(1<<MI_AVCTRL_VPLL_PDIV_SHIFT) |
(33<<MI_AVCTRL_VPLL_NDIV_SHIFT) |
(4<<MI_AVCTRL_VPLL_MDIV_SHIFT) |
(1<<MI_AVCTRL_VPLL_FRANGE_SHIFT);
} else { /* assume that it's NTSC */
avctrl = MI_AVCTRL_VENC_VNTPL |
MI_AVCTRL_DAC_POWER |
(1<<MI_AVCTRL_VPLL_PDIV_SHIFT) |
(33<<MI_AVCTRL_VPLL_NDIV_SHIFT) |
(4<<MI_AVCTRL_VPLL_MDIV_SHIFT) |
(1<<MI_AVCTRL_VPLL_FRANGE_SHIFT);
}
IO_WRITE(MI_AVCTRL_REG, avctrl |
MI_AVCTRL_VENC_TEST |
MI_AVCTRL_VPLL_STANDBY);
IO_READ(MI_AVCTRL_REG);
/* Wait 1 uSec -- according to PLL spec, wait longer to be sure */
__osBbDelay(2);
/* Take PLL out of standby */
IO_WRITE(MI_AVCTRL_REG, avctrl);
IO_READ(MI_AVCTRL_REG);
/* Wait 500 uSec for PLL output to be stable, wait longer to be sure */
__osBbDelay(1000);
/* Take the AI/VI out of reset */
IO_WRITE(MI_AVCTRL_REG, avctrl |
MI_AVCTRL_AV_RESET);
IO_READ(MI_AVCTRL_REG);
__osRestoreInt(mask);
}