blob: b087fce9b8767c24ff239efc5f0fc5487b9de499 [file] [log] [blame]
Stelian Pop0176d432008-03-26 18:52:33 +01001/*
2 * (C) Copyright 2007-2008
Stelian Popc9e798d2011-11-01 00:00:39 +01003 * Stelian Pop <stelian@popies.net>
Stelian Pop0176d432008-03-26 18:52:33 +01004 * Lead Tech Design <www.leadtechdesign.com>
5 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02006 * SPDX-License-Identifier: GPL-2.0+
Stelian Pop0176d432008-03-26 18:52:33 +01007 */
8
9#include <common.h>
Wenyou Yang2510be12017-04-18 15:18:49 +080010#include <debug_uart.h>
Reinhard Meyer8c6407f2011-06-06 00:13:10 +000011#include <asm/io.h>
Stelian Pop0176d432008-03-26 18:52:33 +010012#include <asm/arch/at91sam9260_matrix.h>
Stelian Pop9606b3c2008-05-08 22:52:10 +020013#include <asm/arch/at91sam9_smc.h>
Jean-Christophe PLAGNIOL-VILLARD1332a2a2009-03-21 21:07:59 +010014#include <asm/arch/at91_common.h>
Wenyou Yang70341e22016-02-03 10:16:50 +080015#include <asm/arch/clk.h>
Stelian Pop0176d432008-03-26 18:52:33 +010016#include <asm/arch/gpio.h>
Stelian Pop0176d432008-03-26 18:52:33 +010017
18DECLARE_GLOBAL_DATA_PTR;
19
20/* ------------------------------------------------------------------------- */
21/*
22 * Miscelaneous platform dependent initialisations
23 */
24
Stelian Pop0176d432008-03-26 18:52:33 +010025#ifdef CONFIG_CMD_NAND
26static void at91sam9260ek_nand_hw_init(void)
27{
Reinhard Meyer8c6407f2011-06-06 00:13:10 +000028 struct at91_smc *smc = (struct at91_smc *)ATMEL_BASE_SMC;
29 struct at91_matrix *matrix = (struct at91_matrix *)ATMEL_BASE_MATRIX;
Stelian Pop0176d432008-03-26 18:52:33 +010030 unsigned long csa;
31
Reinhard Meyer8c6407f2011-06-06 00:13:10 +000032 /* Assign CS3 to NAND/SmartMedia Interface */
33 csa = readl(&matrix->ebicsa);
34 csa |= AT91_MATRIX_CS3A_SMC_SMARTMEDIA;
35 writel(csa, &matrix->ebicsa);
Stelian Pop0176d432008-03-26 18:52:33 +010036
37 /* Configure SMC CS3 for NAND/SmartMedia */
Reinhard Meyer8c6407f2011-06-06 00:13:10 +000038 writel(AT91_SMC_SETUP_NWE(1) | AT91_SMC_SETUP_NCS_WR(0) |
39 AT91_SMC_SETUP_NRD(1) | AT91_SMC_SETUP_NCS_RD(0),
40 &smc->cs[3].setup);
41 writel(AT91_SMC_PULSE_NWE(3) | AT91_SMC_PULSE_NCS_WR(3) |
42 AT91_SMC_PULSE_NRD(3) | AT91_SMC_PULSE_NCS_RD(3),
43 &smc->cs[3].pulse);
44 writel(AT91_SMC_CYCLE_NWE(5) | AT91_SMC_CYCLE_NRD(5),
45 &smc->cs[3].cycle);
46 writel(AT91_SMC_MODE_RM_NRD | AT91_SMC_MODE_WM_NWE |
47 AT91_SMC_MODE_EXNW_DISABLE |
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020048#ifdef CONFIG_SYS_NAND_DBW_16
Reinhard Meyer8c6407f2011-06-06 00:13:10 +000049 AT91_SMC_MODE_DBW_16 |
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020050#else /* CONFIG_SYS_NAND_DBW_8 */
Reinhard Meyer8c6407f2011-06-06 00:13:10 +000051 AT91_SMC_MODE_DBW_8 |
Stelian Popc1212b22008-05-08 20:52:18 +020052#endif
Reinhard Meyer8c6407f2011-06-06 00:13:10 +000053 AT91_SMC_MODE_TDF_CYCLE(2),
54 &smc->cs[3].mode);
Stelian Pop0176d432008-03-26 18:52:33 +010055
56 /* Configure RDY/BSY */
Jean-Christophe PLAGNIOL-VILLARD74c076d2009-03-22 10:22:34 +010057 at91_set_gpio_input(CONFIG_SYS_NAND_READY_PIN, 1);
Stelian Pop0176d432008-03-26 18:52:33 +010058
59 /* Enable NandFlash */
Jean-Christophe PLAGNIOL-VILLARD74c076d2009-03-22 10:22:34 +010060 at91_set_gpio_output(CONFIG_SYS_NAND_ENABLE_PIN, 1);
Reinhard Meyer8c6407f2011-06-06 00:13:10 +000061
Stelian Pop0176d432008-03-26 18:52:33 +010062}
63#endif
64
Wenyou Yang2510be12017-04-18 15:18:49 +080065#ifdef CONFIG_DEBUG_UART_BOARD_INIT
66void board_debug_uart_init(void)
67{
68 at91_seriald_hw_init();
69}
70#endif
71
72#ifdef CONFIG_BOARD_EARLY_INIT_F
Reinhard Meyer8c6407f2011-06-06 00:13:10 +000073int board_early_init_f(void)
74{
Wenyou Yang2510be12017-04-18 15:18:49 +080075#ifdef CONFIG_DEBUG_UART
76 debug_uart_init();
77#endif
Reinhard Meyer8c6407f2011-06-06 00:13:10 +000078 return 0;
79}
Wenyou Yang2510be12017-04-18 15:18:49 +080080#endif
Reinhard Meyer8c6407f2011-06-06 00:13:10 +000081
Stelian Pop0176d432008-03-26 18:52:33 +010082int board_init(void)
83{
Stelian Pop0176d432008-03-26 18:52:33 +010084 /* adress of boot parameters */
Reinhard Meyer8c6407f2011-06-06 00:13:10 +000085 gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
Stelian Pop0176d432008-03-26 18:52:33 +010086
Stelian Pop0176d432008-03-26 18:52:33 +010087#ifdef CONFIG_CMD_NAND
88 at91sam9260ek_nand_hw_init();
89#endif
90#ifdef CONFIG_HAS_DATAFLASH
Albin Tonnerre50b5fff2009-09-01 11:26:20 +020091 at91_spi0_hw_init((1 << 0) | (1 << 1));
Stelian Pop0176d432008-03-26 18:52:33 +010092#endif
Stelian Pop0176d432008-03-26 18:52:33 +010093
94 return 0;
95}
96
97int dram_init(void)
98{
Reinhard Meyer8c6407f2011-06-06 00:13:10 +000099 gd->ram_size = get_ram_size(
100 (void *)CONFIG_SYS_SDRAM_BASE,
101 CONFIG_SYS_SDRAM_SIZE);
Stelian Pop0176d432008-03-26 18:52:33 +0100102 return 0;
103}
104
105#ifdef CONFIG_RESET_PHY_R
106void reset_phy(void)
107{
Stelian Pop0176d432008-03-26 18:52:33 +0100108}
109#endif