blob: 42fa7627724ee4dd542a1e93fda3a270993fdfb4 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Stelian Pop0176d432008-03-26 18:52:33 +01002/*
3 * (C) Copyright 2007-2008
Stelian Popc9e798d2011-11-01 00:00:39 +01004 * Stelian Pop <stelian@popies.net>
Stelian Pop0176d432008-03-26 18:52:33 +01005 * Lead Tech Design <www.leadtechdesign.com>
Stelian Pop0176d432008-03-26 18:52:33 +01006 */
7
8#include <common.h>
Wenyou Yang2510be12017-04-18 15:18:49 +08009#include <debug_uart.h>
Simon Glass9b4a2052019-12-28 10:45:05 -070010#include <init.h>
Simon Glass5e6267a2019-12-28 10:44:48 -070011#include <net.h>
Reinhard Meyer8c6407f2011-06-06 00:13:10 +000012#include <asm/io.h>
Stelian Pop0176d432008-03-26 18:52:33 +010013#include <asm/arch/at91sam9260_matrix.h>
Stelian Pop9606b3c2008-05-08 22:52:10 +020014#include <asm/arch/at91sam9_smc.h>
Jean-Christophe PLAGNIOL-VILLARD1332a2a2009-03-21 21:07:59 +010015#include <asm/arch/at91_common.h>
Wenyou Yang70341e22016-02-03 10:16:50 +080016#include <asm/arch/clk.h>
Stelian Pop0176d432008-03-26 18:52:33 +010017#include <asm/arch/gpio.h>
Stelian Pop0176d432008-03-26 18:52:33 +010018
19DECLARE_GLOBAL_DATA_PTR;
20
21/* ------------------------------------------------------------------------- */
22/*
23 * Miscelaneous platform dependent initialisations
24 */
25
Stelian Pop0176d432008-03-26 18:52:33 +010026#ifdef CONFIG_CMD_NAND
27static void at91sam9260ek_nand_hw_init(void)
28{
Reinhard Meyer8c6407f2011-06-06 00:13:10 +000029 struct at91_smc *smc = (struct at91_smc *)ATMEL_BASE_SMC;
30 struct at91_matrix *matrix = (struct at91_matrix *)ATMEL_BASE_MATRIX;
Stelian Pop0176d432008-03-26 18:52:33 +010031 unsigned long csa;
32
Reinhard Meyer8c6407f2011-06-06 00:13:10 +000033 /* Assign CS3 to NAND/SmartMedia Interface */
34 csa = readl(&matrix->ebicsa);
35 csa |= AT91_MATRIX_CS3A_SMC_SMARTMEDIA;
36 writel(csa, &matrix->ebicsa);
Stelian Pop0176d432008-03-26 18:52:33 +010037
38 /* Configure SMC CS3 for NAND/SmartMedia */
Reinhard Meyer8c6407f2011-06-06 00:13:10 +000039 writel(AT91_SMC_SETUP_NWE(1) | AT91_SMC_SETUP_NCS_WR(0) |
40 AT91_SMC_SETUP_NRD(1) | AT91_SMC_SETUP_NCS_RD(0),
41 &smc->cs[3].setup);
42 writel(AT91_SMC_PULSE_NWE(3) | AT91_SMC_PULSE_NCS_WR(3) |
43 AT91_SMC_PULSE_NRD(3) | AT91_SMC_PULSE_NCS_RD(3),
44 &smc->cs[3].pulse);
45 writel(AT91_SMC_CYCLE_NWE(5) | AT91_SMC_CYCLE_NRD(5),
46 &smc->cs[3].cycle);
47 writel(AT91_SMC_MODE_RM_NRD | AT91_SMC_MODE_WM_NWE |
48 AT91_SMC_MODE_EXNW_DISABLE |
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020049#ifdef CONFIG_SYS_NAND_DBW_16
Reinhard Meyer8c6407f2011-06-06 00:13:10 +000050 AT91_SMC_MODE_DBW_16 |
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020051#else /* CONFIG_SYS_NAND_DBW_8 */
Reinhard Meyer8c6407f2011-06-06 00:13:10 +000052 AT91_SMC_MODE_DBW_8 |
Stelian Popc1212b22008-05-08 20:52:18 +020053#endif
Reinhard Meyer8c6407f2011-06-06 00:13:10 +000054 AT91_SMC_MODE_TDF_CYCLE(2),
55 &smc->cs[3].mode);
Stelian Pop0176d432008-03-26 18:52:33 +010056
57 /* Configure RDY/BSY */
Jean-Christophe PLAGNIOL-VILLARD74c076d2009-03-22 10:22:34 +010058 at91_set_gpio_input(CONFIG_SYS_NAND_READY_PIN, 1);
Stelian Pop0176d432008-03-26 18:52:33 +010059
60 /* Enable NandFlash */
Jean-Christophe PLAGNIOL-VILLARD74c076d2009-03-22 10:22:34 +010061 at91_set_gpio_output(CONFIG_SYS_NAND_ENABLE_PIN, 1);
Reinhard Meyer8c6407f2011-06-06 00:13:10 +000062
Stelian Pop0176d432008-03-26 18:52:33 +010063}
64#endif
65
Wenyou Yang2510be12017-04-18 15:18:49 +080066#ifdef CONFIG_DEBUG_UART_BOARD_INIT
67void board_debug_uart_init(void)
68{
69 at91_seriald_hw_init();
70}
71#endif
72
73#ifdef CONFIG_BOARD_EARLY_INIT_F
Reinhard Meyer8c6407f2011-06-06 00:13:10 +000074int board_early_init_f(void)
75{
Wenyou Yang2510be12017-04-18 15:18:49 +080076#ifdef CONFIG_DEBUG_UART
77 debug_uart_init();
78#endif
Reinhard Meyer8c6407f2011-06-06 00:13:10 +000079 return 0;
80}
Wenyou Yang2510be12017-04-18 15:18:49 +080081#endif
Reinhard Meyer8c6407f2011-06-06 00:13:10 +000082
Stelian Pop0176d432008-03-26 18:52:33 +010083int board_init(void)
84{
Stelian Pop0176d432008-03-26 18:52:33 +010085 /* adress of boot parameters */
Reinhard Meyer8c6407f2011-06-06 00:13:10 +000086 gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
Stelian Pop0176d432008-03-26 18:52:33 +010087
Stelian Pop0176d432008-03-26 18:52:33 +010088#ifdef CONFIG_CMD_NAND
89 at91sam9260ek_nand_hw_init();
90#endif
Stelian Pop0176d432008-03-26 18:52:33 +010091 return 0;
92}
93
94int dram_init(void)
95{
Reinhard Meyer8c6407f2011-06-06 00:13:10 +000096 gd->ram_size = get_ram_size(
97 (void *)CONFIG_SYS_SDRAM_BASE,
98 CONFIG_SYS_SDRAM_SIZE);
Stelian Pop0176d432008-03-26 18:52:33 +010099 return 0;
100}
101
102#ifdef CONFIG_RESET_PHY_R
103void reset_phy(void)
104{
Stelian Pop0176d432008-03-26 18:52:33 +0100105}
106#endif