OSDN Git Service

8ad87ca8a97da62f7d6c9d5475e60f3eff2143a3
[kozos-expbrd/kozos_expbrd.git] / firm / simple_mp3_player / bootload / spreg.c
1
2 #include "spreg.h"
3 #include "defines.h"
4 #include "portconf.h"
5
6 /*
7  * DRAM
8  */
9 #define SPREG_DRAM_ABWCR  ((volatile uint8 *)0xfee020)
10 #define SPREG_DRAM_ASTCR  ((volatile uint8 *)0xfee021)
11 #define SPREG_DRAM_RTCOR  ((volatile uint8 *)0xfee02a)
12 #define SPREG_DRAM_RTMCSR ((volatile uint8 *)0xfee028)
13 #define SPREG_DRAM_DRCRB  ((volatile uint8 *)0xfee027)
14 #define SPREG_DRAM_DRCRA  ((volatile uint8 *)0xfee026)
15 #define SPREG_DRAM_WCRH   ((volatile uint8 *)0xfee022)
16 #define SPREG_DRAM_WCRL   ((volatile uint8 *)0xfee023)
17
18 /*
19  * ITU
20  */
21 #define SPREG_ITU_TMDR       ((volatile uint8 *)0xFFFF62)
22 #define SPREG_ITU_TSTR       ((volatile uint8 *)0xFFFF60)
23 #define SPREG_ITU_16TCNT2H   ((volatile uint8 *)0xFFFF7A)
24 #define SPREG_ITU_16TCNT2L   ((volatile uint8 *)0xFFFF7B)
25
26 #define SPREG_ITU_TSTR_BIT_STR2   (1 << 2)
27 #define SPREG_ITU_TMDR_BIT_MDF    (1 << 6)
28
29 /*
30  * Chip Select Control Register
31  */
32 #define SPREG_CSCR       ((volatile uint8 *)0xFEE01F)
33
34 void spreg_itu_init(void)
35 {
36   *SPREG_ITU_TMDR = SPREG_ITU_TMDR_BIT_MDF;
37   *SPREG_ITU_TSTR = SPREG_ITU_TSTR_BIT_STR2;
38 }
39
40 void spreg_itu_counter(uint16 *value)
41 {
42   *value = ((*SPREG_ITU_16TCNT2H) << 8) | (*SPREG_ITU_16TCNT2L << 0);
43 }
44
45 void spreg_dram_init(void)
46 {
47   /*
48    * dram_check2()でチェックしたら,値をうまく保持できないビットが存在した
49    * ので,リフレッシュレートを上げたら解消された.(ウエイトを多めにしても
50    * 効果は無かった)
51    * とりあえず,リフレッシュレート高めの設定にしておく.
52    */
53
54   *SPREG_DRAM_ABWCR  = 0xff;
55 #if 0
56   *SPREG_DRAM_RTCOR  = 0x07;
57 #else
58   *SPREG_DRAM_RTCOR  = 0x03; /* リフレッシュ周期を短めに設定 */
59 #endif
60 #if 1
61   *SPREG_DRAM_RTMCSR = 0x37;
62 #else
63   *SPREG_DRAM_RTMCSR = 0x2f; /* リフレッシュ周波数UP */
64 #endif
65 #if 1
66   *SPREG_DRAM_DRCRB  = 0x98;
67 #else
68   *SPREG_DRAM_DRCRB  = 0x9f; /* ウエイト挿入 */
69 #endif
70   *SPREG_DRAM_DRCRA  = 0x30;
71
72   *PORTCONF_P1DDR  = 0xff;
73   *PORTCONF_P2DDR  = 0x07;
74   *PORTCONF_P8DDR  = 0xee;
75   *PORTCONF_PBDDR  = 0x6c;
76
77   /* SPREG_DRAM_WCRH = ...; */
78 #if 1
79   *SPREG_DRAM_WCRL = 0xcf;
80 #else
81   *SPREG_DRAM_WCRL = 0xff; /* ウエイト挿入 */
82 #endif
83
84 #if 1
85   *SPREG_DRAM_ASTCR = 0xfb; /* 2ステートアクセス */
86 #else
87   *SPREG_DRAM_ASTCR = 0xff; /* 3ステートアクセス */
88 #endif
89
90   /*
91    * チップセレクトコントロールレジスタもここで設定する。
92    */
93   *SPREG_CSCR = 0x3F;
94 }
95