2 * Board functions for Siemens TAURUS (AT91SAM9G20) based boards
3 * (C) Copyright Siemens AG
6 * U-Boot file: board/atmel/at91sam9260ek/at91sam9260ek.c
8 * (C) Copyright 2007-2008
9 * Stelian Pop <stelian@popies.net>
10 * Lead Tech Design <www.leadtechdesign.com>
12 * SPDX-License-Identifier: GPL-2.0+
17 #include <asm/arch/at91sam9260_matrix.h>
18 #include <asm/arch/at91sam9_smc.h>
19 #include <asm/arch/at91_common.h>
20 #include <asm/arch/at91_pmc.h>
21 #include <asm/arch/at91_rstc.h>
22 #include <asm/arch/gpio.h>
23 #include <asm/arch/at91sam9_sdramc.h>
24 #include <asm/arch/clk.h>
25 #include <linux/mtd/nand.h>
26 #include <atmel_mci.h>
27 #include <asm/arch/at91_spi.h>
33 DECLARE_GLOBAL_DATA_PTR;
35 static void taurus_nand_hw_init(void)
37 struct at91_smc *smc = (struct at91_smc *)ATMEL_BASE_SMC;
38 struct at91_matrix *matrix = (struct at91_matrix *)ATMEL_BASE_MATRIX;
41 /* Assign CS3 to NAND/SmartMedia Interface */
42 csa = readl(&matrix->ebicsa);
43 csa |= AT91_MATRIX_CS3A_SMC_SMARTMEDIA;
44 writel(csa, &matrix->ebicsa);
46 /* Configure SMC CS3 for NAND/SmartMedia */
47 writel(AT91_SMC_SETUP_NWE(2) | AT91_SMC_SETUP_NCS_WR(0) |
48 AT91_SMC_SETUP_NRD(2) | AT91_SMC_SETUP_NCS_RD(0),
50 writel(AT91_SMC_PULSE_NWE(4) | AT91_SMC_PULSE_NCS_WR(3) |
51 AT91_SMC_PULSE_NRD(4) | AT91_SMC_PULSE_NCS_RD(3),
53 writel(AT91_SMC_CYCLE_NWE(7) | AT91_SMC_CYCLE_NRD(7),
55 writel(AT91_SMC_MODE_RM_NRD | AT91_SMC_MODE_WM_NWE |
56 AT91_SMC_MODE_EXNW_DISABLE |
58 AT91_SMC_MODE_TDF_CYCLE(3),
61 /* Configure RDY/BSY */
62 at91_set_gpio_input(CONFIG_SYS_NAND_READY_PIN, 1);
64 /* Enable NandFlash */
65 at91_set_gpio_output(CONFIG_SYS_NAND_ENABLE_PIN, 1);
68 #if defined(CONFIG_SPL_BUILD)
72 void matrix_init(void)
74 struct at91_matrix *mat = (struct at91_matrix *)ATMEL_BASE_MATRIX;
76 writel((readl(&mat->scfg[3]) & (~AT91_MATRIX_SLOT_CYCLE))
77 | AT91_MATRIX_SLOT_CYCLE_(0x40),
81 void at91_spl_board_init(void)
83 taurus_nand_hw_init();
85 /* Configure recovery button PINs */
86 at91_set_gpio_input(AT91_PIN_PA31, 1);
88 /* check if button is pressed */
89 if (at91_get_gpio_value(AT91_PIN_PA31) == 0) {
92 debug("Recovery button pressed\n");
93 boot_device = spl_boot_device();
94 switch (boot_device) {
95 #ifdef CONFIG_SPL_NAND_SUPPORT
96 case BOOT_DEVICE_NAND:
98 spl_nand_erase_one(0, 0);
107 struct at91_matrix *ma = (struct at91_matrix *)ATMEL_BASE_MATRIX;
108 struct sdramc_reg setting;
110 at91_sdram_hw_init();
111 setting.cr = (AT91_SDRAMC_NC_9 |
116 AT91_SDRAMC_TWR_VAL(3) |
117 AT91_SDRAMC_TRC_VAL(9) |
118 AT91_SDRAMC_TRP_VAL(3) |
119 AT91_SDRAMC_TRCD_VAL(3) |
120 AT91_SDRAMC_TRAS_VAL(6) |
121 AT91_SDRAMC_TXSR_VAL(10));
122 setting.mdr = AT91_SDRAMC_MD_SDRAM;
123 setting.tr = (CONFIG_SYS_MASTER_CLOCK * 7) / 1000000;
126 writel(readl(&ma->ebicsa) | AT91_MATRIX_CS1A_SDRAMC |
127 AT91_MATRIX_VDDIOMSEL_3_3V | AT91_MATRIX_EBI_IOSR_SEL,
129 sdramc_initialize(ATMEL_BASE_CS1, &setting);
134 static void taurus_macb_hw_init(void)
136 /* Enable EMAC clock */
137 at91_periph_clk_enable(ATMEL_ID_EMAC0);
140 * Disable pull-up on:
141 * RXDV (PA17) => PHY normal mode (not Test mode)
142 * ERX0 (PA14) => PHY ADDR0
143 * ERX1 (PA15) => PHY ADDR1
144 * ERX2 (PA25) => PHY ADDR2
145 * ERX3 (PA26) => PHY ADDR3
146 * ECRS (PA28) => PHY ADDR4 => PHYADDR = 0x0
148 * PHY has internal pull-down
150 at91_set_pio_pullup(AT91_PIO_PORTA, 14, 0);
151 at91_set_pio_pullup(AT91_PIO_PORTA, 15, 0);
152 at91_set_pio_pullup(AT91_PIO_PORTA, 17, 0);
153 at91_set_pio_pullup(AT91_PIO_PORTA, 25, 0);
154 at91_set_pio_pullup(AT91_PIO_PORTA, 26, 0);
155 at91_set_pio_pullup(AT91_PIO_PORTA, 28, 0);
159 at91_set_gpio_input(AT91_PIN_PA25, 1); /* ERST tri-state */
161 /* Re-enable pull-up */
162 at91_set_pio_pullup(AT91_PIO_PORTA, 14, 1);
163 at91_set_pio_pullup(AT91_PIO_PORTA, 15, 1);
164 at91_set_pio_pullup(AT91_PIO_PORTA, 17, 1);
165 at91_set_pio_pullup(AT91_PIO_PORTA, 25, 1);
166 at91_set_pio_pullup(AT91_PIO_PORTA, 26, 1);
167 at91_set_pio_pullup(AT91_PIO_PORTA, 28, 1);
169 /* Initialize EMAC=MACB hardware */
174 #ifdef CONFIG_GENERIC_ATMEL_MCI
175 int board_mmc_init(bd_t *bd)
179 return atmel_mci_init((void *)ATMEL_BASE_MCI);
183 int board_early_init_f(void)
185 /* Enable clocks for all PIOs */
186 at91_periph_clk_enable(ATMEL_ID_PIOA);
187 at91_periph_clk_enable(ATMEL_ID_PIOB);
188 at91_periph_clk_enable(ATMEL_ID_PIOC);
190 at91_seriald_hw_init();
195 int spi_cs_is_valid(unsigned int bus, unsigned int cs)
197 return bus == 0 && cs == 0;
200 void spi_cs_activate(struct spi_slave *slave)
202 at91_set_gpio_value(TAURUS_SPI_CS_PIN, 0);
205 void spi_cs_deactivate(struct spi_slave *slave)
207 at91_set_gpio_value(TAURUS_SPI_CS_PIN, 1);
212 /* adress of boot parameters */
213 gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
215 #ifdef CONFIG_CMD_NAND
216 taurus_nand_hw_init();
219 taurus_macb_hw_init();
221 at91_spi0_hw_init(TAURUS_SPI_MASK);
228 gd->ram_size = get_ram_size((void *)CONFIG_SYS_SDRAM_BASE,
229 CONFIG_SYS_SDRAM_SIZE);
233 int board_eth_init(bd_t *bis)
237 rc = macb_eth_initialize(0, (void *)ATMEL_BASE_EMAC0, 0x00);