31
31
32
32
DECLARE_GLOBAL_DATA_PTR ;
33
33
34
- #ifdef CONFIG_CMD_NAND
35
34
static void corvus_nand_hw_init (void )
36
35
{
37
36
struct at91_smc * smc = (struct at91_smc * )ATMEL_BASE_SMC ;
38
37
struct at91_matrix * matrix = (struct at91_matrix * )ATMEL_BASE_MATRIX ;
39
- struct at91_pmc * pmc = (struct at91_pmc * )ATMEL_BASE_PMC ;
40
38
unsigned long csa ;
41
39
42
40
/* Enable CS3 */
@@ -63,22 +61,111 @@ static void corvus_nand_hw_init(void)
63
61
AT91_SMC_MODE_TDF_CYCLE (3 ),
64
62
& smc -> cs [3 ].mode );
65
63
66
- writel (1 << ATMEL_ID_PIOC , & pmc -> pcer );
67
-
68
- /* Configure RDY/BSY */
69
- at91_set_gpio_input (CONFIG_SYS_NAND_READY_PIN , 1 );
64
+ at91_periph_clk_enable (ATMEL_ID_PIOC );
70
65
71
66
/* Enable NandFlash */
72
67
at91_set_gpio_output (CONFIG_SYS_NAND_ENABLE_PIN , 1 );
73
68
}
69
+
70
+ #if defined(CONFIG_SPL_BUILD )
71
+ #include <spl.h>
72
+ #include <nand.h>
73
+
74
+ void at91_spl_board_init (void )
75
+ {
76
+ /*
77
+ * For on the sam9m10g45ek board, the chip wm9711 stay in the test
78
+ * mode, so it need do some action to exit mode.
79
+ */
80
+ at91_set_gpio_output (AT91_PIN_PD7 , 0 );
81
+ at91_set_gpio_output (AT91_PIN_PD8 , 0 );
82
+ at91_set_pio_pullup (AT91_PIO_PORTD , 7 , 1 );
83
+ at91_set_pio_pullup (AT91_PIO_PORTD , 8 , 1 );
84
+ at91_set_pio_pullup (AT91_PIO_PORTA , 12 , 1 );
85
+ at91_set_pio_pullup (AT91_PIO_PORTA , 13 , 1 );
86
+ at91_set_pio_pullup (AT91_PIO_PORTA , 15 , 1 );
87
+
88
+ corvus_nand_hw_init ();
89
+
90
+ /* Configure recovery button PINs */
91
+ at91_set_gpio_input (AT91_PIN_PB7 , 1 );
92
+
93
+ /* check if button is pressed */
94
+ if (at91_get_gpio_value (AT91_PIN_PB7 ) == 0 ) {
95
+ u32 boot_device ;
96
+
97
+ debug ("Recovery button pressed\n" );
98
+ boot_device = spl_boot_device ();
99
+ switch (boot_device ) {
100
+ #ifdef CONFIG_SPL_NAND_SUPPORT
101
+ case BOOT_DEVICE_NAND :
102
+ nand_init ();
103
+ spl_nand_erase_one (0 , 0 );
104
+ break ;
74
105
#endif
106
+ }
107
+ }
108
+ }
75
109
76
- #ifdef CONFIG_CMD_USB
77
- static void taurus_usb_hw_init (void )
110
+ #include <asm/arch/atmel_mpddrc.h>
111
+ static void ddr2_conf (struct atmel_mpddr * ddr2 )
112
+ {
113
+ ddr2 -> md = (ATMEL_MPDDRC_MD_DBW_16_BITS | ATMEL_MPDDRC_MD_DDR2_SDRAM );
114
+
115
+ ddr2 -> cr = (ATMEL_MPDDRC_CR_NC_COL_10 |
116
+ ATMEL_MPDDRC_CR_NR_ROW_14 |
117
+ ATMEL_MPDDRC_CR_DIC_DS |
118
+ ATMEL_MPDDRC_CR_DQMS_SHARED |
119
+ ATMEL_MPDDRC_CR_CAS_DDR_CAS3 );
120
+ ddr2 -> rtr = 0x24b ;
121
+
122
+ ddr2 -> tpr0 = (6 << ATMEL_MPDDRC_TPR0_TRAS_OFFSET |/* 6*7.5 = 45 ns */
123
+ 2 << ATMEL_MPDDRC_TPR0_TRCD_OFFSET |/* 2*7.5 = 15 ns */
124
+ 2 << ATMEL_MPDDRC_TPR0_TWR_OFFSET | /* 2*7.5 = 15 ns */
125
+ 8 << ATMEL_MPDDRC_TPR0_TRC_OFFSET | /* 8*7.5 = 75 ns */
126
+ 2 << ATMEL_MPDDRC_TPR0_TRP_OFFSET | /* 2*7.5 = 15 ns */
127
+ 1 << ATMEL_MPDDRC_TPR0_TRRD_OFFSET | /* 1*7.5= 7.5 ns*/
128
+ 1 << ATMEL_MPDDRC_TPR0_TWTR_OFFSET | /* 1 clk cycle */
129
+ 2 << ATMEL_MPDDRC_TPR0_TMRD_OFFSET ); /* 2 clk cycles */
130
+
131
+ ddr2 -> tpr1 = (2 << ATMEL_MPDDRC_TPR1_TXP_OFFSET | /* 2*7.5 = 15 ns */
132
+ 200 << ATMEL_MPDDRC_TPR1_TXSRD_OFFSET |
133
+ 16 << ATMEL_MPDDRC_TPR1_TXSNR_OFFSET |
134
+ 14 << ATMEL_MPDDRC_TPR1_TRFC_OFFSET );
135
+
136
+ ddr2 -> tpr2 = (1 << ATMEL_MPDDRC_TPR2_TRTP_OFFSET |
137
+ 0 << ATMEL_MPDDRC_TPR2_TRPA_OFFSET |
138
+ 7 << ATMEL_MPDDRC_TPR2_TXARDS_OFFSET |
139
+ 2 << ATMEL_MPDDRC_TPR2_TXARD_OFFSET );
140
+ }
141
+
142
+ void mem_init (void )
78
143
{
79
144
struct at91_pmc * pmc = (struct at91_pmc * )ATMEL_BASE_PMC ;
145
+ struct at91_matrix * mat = (struct at91_matrix * )ATMEL_BASE_MATRIX ;
146
+ struct atmel_mpddr ddr2 ;
147
+ unsigned long csa ;
148
+
149
+ ddr2_conf (& ddr2 );
80
150
81
- writel (1 << ATMEL_ID_PIODE , & pmc -> pcer );
151
+ /* enable DDR2 clock */
152
+ writel (0x4 , & pmc -> scer );
153
+
154
+ /* Chip select 1 is for DDR2/SDRAM */
155
+ csa = readl (& mat -> ebicsa );
156
+ csa |= AT91_MATRIX_EBI_CS1A_SDRAMC ;
157
+ csa &= ~AT91_MATRIX_EBI_VDDIOMSEL_3_3V ;
158
+ writel (csa , & mat -> ebicsa );
159
+
160
+ /* DDRAM2 Controller initialize */
161
+ ddr2_init (ATMEL_BASE_CS6 , & ddr2 );
162
+ }
163
+ #endif
164
+
165
+ #ifdef CONFIG_CMD_USB
166
+ static void taurus_usb_hw_init (void )
167
+ {
168
+ at91_periph_clk_enable (ATMEL_ID_PIODE );
82
169
83
170
at91_set_gpio_output (AT91_PIN_PD1 , 0 );
84
171
at91_set_gpio_output (AT91_PIN_PD3 , 0 );
@@ -88,10 +175,8 @@ static void taurus_usb_hw_init(void)
88
175
#ifdef CONFIG_MACB
89
176
static void corvus_macb_hw_init (void )
90
177
{
91
- struct at91_pmc * pmc = (struct at91_pmc * )ATMEL_BASE_PMC ;
92
-
93
178
/* Enable clock */
94
- writel ( 1 << ATMEL_ID_EMAC , & pmc -> pcer );
179
+ at91_periph_clk_enable ( ATMEL_ID_EMAC );
95
180
96
181
/*
97
182
* Disable pull-up on:
0 commit comments