]> Git Repo - J-u-boot.git/blame - board/atmel/at91sam9m10g45ek/at91sam9m10g45ek.c
at91: rename mem_init() to at91_mem_init()
[J-u-boot.git] / board / atmel / at91sam9m10g45ek / at91sam9m10g45ek.c
CommitLineData
83d290c5 1// SPDX-License-Identifier: GPL-2.0+
22ee6473
SG
2/*
3 * (C) Copyright 2007-2008
c9e798d3 4 * Stelian Pop <[email protected]>
22ee6473 5 * Lead Tech Design <www.leadtechdesign.com>
22ee6473
SG
6 */
7
03de305e 8#include <config.h>
6a991af2 9#include <debug_uart.h>
9b4a205f 10#include <init.h>
5e6267af 11#include <net.h>
2189d5f1 12#include <vsprintf.h>
401d1c4f 13#include <asm/global_data.h>
5cfeec51 14#include <asm/io.h>
41d41a93 15#include <asm/arch/clk.h>
5cfeec51 16#include <asm/arch/at91sam9g45_matrix.h>
22ee6473
SG
17#include <asm/arch/at91sam9_smc.h>
18#include <asm/arch/at91_common.h>
22ee6473 19#include <asm/arch/gpio.h>
5cfeec51 20#include <asm/arch/clk.h>
6ae3900a 21#include <linux/mtd/rawnand.h>
22ee6473 22#include <atmel_lcdc.h>
c62db35d 23#include <asm/mach-types.h>
22ee6473
SG
24
25DECLARE_GLOBAL_DATA_PTR;
26
27/* ------------------------------------------------------------------------- */
28/*
29 * Miscelaneous platform dependent initialisations
30 */
31
32#ifdef CONFIG_CMD_NAND
5cfeec51 33void at91sam9m10g45ek_nand_hw_init(void)
22ee6473 34{
5cfeec51
TP
35 struct at91_smc *smc = (struct at91_smc *)ATMEL_BASE_SMC;
36 struct at91_matrix *matrix = (struct at91_matrix *)ATMEL_BASE_MATRIX;
22ee6473
SG
37 unsigned long csa;
38
39 /* Enable CS3 */
5cfeec51
TP
40 csa = readl(&matrix->ebicsa);
41 csa |= AT91_MATRIX_EBI_CS3A_SMC_SMARTMEDIA;
42 writel(csa, &matrix->ebicsa);
22ee6473
SG
43
44 /* Configure SMC CS3 for NAND/SmartMedia */
5cfeec51
TP
45 writel(AT91_SMC_SETUP_NWE(1) | AT91_SMC_SETUP_NCS_WR(0) |
46 AT91_SMC_SETUP_NRD(1) | AT91_SMC_SETUP_NCS_RD(0),
47 &smc->cs[3].setup);
48 writel(AT91_SMC_PULSE_NWE(4) | AT91_SMC_PULSE_NCS_WR(3) |
49 AT91_SMC_PULSE_NRD(3) | AT91_SMC_PULSE_NCS_RD(2),
50 &smc->cs[3].pulse);
51 writel(AT91_SMC_CYCLE_NWE(7) | AT91_SMC_CYCLE_NRD(4),
52 &smc->cs[3].cycle);
53 writel(AT91_SMC_MODE_RM_NRD | AT91_SMC_MODE_WM_NWE |
54 AT91_SMC_MODE_EXNW_DISABLE |
22ee6473 55#ifdef CONFIG_SYS_NAND_DBW_16
5cfeec51 56 AT91_SMC_MODE_DBW_16 |
22ee6473 57#else /* CONFIG_SYS_NAND_DBW_8 */
5cfeec51 58 AT91_SMC_MODE_DBW_8 |
22ee6473 59#endif
5cfeec51
TP
60 AT91_SMC_MODE_TDF_CYCLE(3),
61 &smc->cs[3].mode);
22ee6473 62
70341e2e 63 at91_periph_clk_enable(ATMEL_ID_PIOC);
22ee6473
SG
64
65 /* Configure RDY/BSY */
4e590945 66 at91_set_gpio_input(CFG_SYS_NAND_READY_PIN, 1);
22ee6473
SG
67
68 /* Enable NandFlash */
4e590945 69 at91_set_gpio_output(CFG_SYS_NAND_ENABLE_PIN, 1);
22ee6473
SG
70}
71#endif
72
41d41a93
BS
73#if defined(CONFIG_SPL_BUILD)
74#include <spl.h>
75#include <nand.h>
76
77void at91_spl_board_init(void)
78{
79 /*
80 * On the at91sam9m10g45ek board, the chip wm9711 stays in the
81 * test mode, so it needs do some action to exit test mode.
82 */
83 at91_periph_clk_enable(ATMEL_ID_PIODE);
84 at91_set_gpio_output(AT91_PIN_PD7, 0);
85 at91_set_gpio_output(AT91_PIN_PD8, 0);
86 at91_set_pio_pullup(AT91_PIO_PORTD, 7, 1);
87 at91_set_pio_pullup(AT91_PIO_PORTD, 8, 1);
88
5541543f 89#ifdef CONFIG_SD_BOOT
41d41a93 90 at91_mci_hw_init();
5541543f 91#elif CONFIG_NAND_BOOT
41d41a93
BS
92 at91sam9m10g45ek_nand_hw_init();
93#endif
94}
95
96#include <asm/arch/atmel_mpddrc.h>
7e8702a0 97static void ddr2_conf(struct atmel_mpddrc_config *ddr2)
41d41a93
BS
98{
99 ddr2->md = (ATMEL_MPDDRC_MD_DBW_16_BITS | ATMEL_MPDDRC_MD_DDR2_SDRAM);
100
101 ddr2->cr = (ATMEL_MPDDRC_CR_NC_COL_10 |
102 ATMEL_MPDDRC_CR_NR_ROW_14 |
103 ATMEL_MPDDRC_CR_DQMS_SHARED |
104 ATMEL_MPDDRC_CR_CAS_DDR_CAS3);
105
106 ddr2->rtr = 0x24b;
107
108 ddr2->tpr0 = (6 << ATMEL_MPDDRC_TPR0_TRAS_OFFSET |/* 6*7.5 = 45 ns */
109 2 << ATMEL_MPDDRC_TPR0_TRCD_OFFSET |/* 2*7.5 = 15 ns */
110 2 << ATMEL_MPDDRC_TPR0_TWR_OFFSET | /* 2*7.5 = 15 ns */
111 8 << ATMEL_MPDDRC_TPR0_TRC_OFFSET | /* 8*7.5 = 60 ns */
112 2 << ATMEL_MPDDRC_TPR0_TRP_OFFSET | /* 2*7.5 = 15 ns */
113 1 << ATMEL_MPDDRC_TPR0_TRRD_OFFSET | /* 1*7.5= 7.5 ns*/
114 1 << ATMEL_MPDDRC_TPR0_TWTR_OFFSET | /* 1 clk cycle */
115 2 << ATMEL_MPDDRC_TPR0_TMRD_OFFSET); /* 2 clk cycles */
116
117 ddr2->tpr1 = (2 << ATMEL_MPDDRC_TPR1_TXP_OFFSET | /* 2*7.5 = 15 ns */
118 200 << ATMEL_MPDDRC_TPR1_TXSRD_OFFSET |
119 16 << ATMEL_MPDDRC_TPR1_TXSNR_OFFSET |
120 14 << ATMEL_MPDDRC_TPR1_TRFC_OFFSET);
121
122 ddr2->tpr2 = (1 << ATMEL_MPDDRC_TPR2_TRTP_OFFSET |
123 0 << ATMEL_MPDDRC_TPR2_TRPA_OFFSET |
124 7 << ATMEL_MPDDRC_TPR2_TXARDS_OFFSET |
125 2 << ATMEL_MPDDRC_TPR2_TXARD_OFFSET);
126}
127
effe97d4 128void at91_mem_init(void)
41d41a93 129{
7e8702a0 130 struct atmel_mpddrc_config ddr2;
41d41a93
BS
131
132 ddr2_conf(&ddr2);
133
70341e2e 134 at91_system_clk_enable(AT91_PMC_DDR);
41d41a93 135
41d41a93 136 /* DDRAM2 Controller initialize */
0c01c3e8 137 ddr2_init(ATMEL_BASE_DDRSDRC0, ATMEL_BASE_CS6, &ddr2);
41d41a93
BS
138}
139#endif
140
64203c7b
SM
141#ifdef CONFIG_CMD_USB
142static void at91sam9m10g45ek_usb_hw_init(void)
143{
70341e2e 144 at91_periph_clk_enable(ATMEL_ID_PIODE);
64203c7b
SM
145
146 at91_set_gpio_output(AT91_PIN_PD1, 0);
147 at91_set_gpio_output(AT91_PIN_PD3, 0);
148}
149#endif
150
6a991af2
WY
151#ifdef CONFIG_DEBUG_UART_BOARD_INIT
152void board_debug_uart_init(void)
153{
154 at91_seriald_hw_init();
155}
156#endif
157
158#ifdef CONFIG_BOARD_EARLY_INIT_F
5cfeec51
TP
159int board_early_init_f(void)
160{
5cfeec51
TP
161 return 0;
162}
6a991af2 163#endif
5cfeec51 164
22ee6473
SG
165int board_init(void)
166{
22ee6473 167 /* arch number of AT91SAM9M10G45EK-Board */
22ee6473 168 gd->bd->bi_arch_number = MACH_TYPE_AT91SAM9M10G45EK;
5cfeec51 169
22ee6473 170 /* adress of boot parameters */
aa6e94de 171 gd->bd->bi_boot_params = CFG_SYS_SDRAM_BASE + 0x100;
22ee6473 172
22ee6473
SG
173#ifdef CONFIG_CMD_NAND
174 at91sam9m10g45ek_nand_hw_init();
175#endif
64203c7b
SM
176#ifdef CONFIG_CMD_USB
177 at91sam9m10g45ek_usb_hw_init();
22ee6473
SG
178#endif
179 return 0;
180}
181
182int dram_init(void)
183{
aa6e94de
TR
184 gd->ram_size = get_ram_size((void *) CFG_SYS_SDRAM_BASE,
185 CFG_SYS_SDRAM_SIZE);
22ee6473
SG
186 return 0;
187}
188
189#ifdef CONFIG_RESET_PHY_R
190void reset_phy(void)
191{
22ee6473
SG
192}
193#endif
This page took 0.542821 seconds and 4 git commands to generate.