blob: 31074d0e21a7bd648ec7d51c3ae7a4737f90685d [file] [log] [blame]
Albin Tonnerre2dc851e2009-08-20 16:04:49 +02001/*
2 * (C) Copyright 2007-2008
Stelian Popc9e798d2011-11-01 00:00:39 +01003 * Stelian Pop <stelian@popies.net>
Albin Tonnerre2dc851e2009-08-20 16:04:49 +02004 * Lead Tech Design <www.leadtechdesign.com>
5 *
6 * Copyright (C) 2009
7 * Albin Tonnerre, Free Electrons <albin.tonnerre@free-electrons.com>
8 *
9 * See file CREDITS for list of people who contributed to this
10 * project.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License as
14 * published by the Free Software Foundation; either version 2 of
15 * the License, or (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
25 * MA 02111-1307 USA
26 */
27
28#include <common.h>
Albin Tonnerre2dc851e2009-08-20 16:04:49 +020029#include <asm/arch/at91sam9_matrix.h>
30#include <asm/arch/at91sam9_smc.h>
31#include <asm/arch/at91_common.h>
32#include <asm/arch/at91_pmc.h>
33#include <asm/arch/at91_rstc.h>
34#include <asm/arch/gpio.h>
Albin Tonnerre2dc851e2009-08-20 16:04:49 +020035#include <asm/arch/hardware.h>
36
37DECLARE_GLOBAL_DATA_PTR;
38
39/* ------------------------------------------------------------------------- */
40/*
41 * Miscelaneous platform dependent initialisations
42 */
43
44static void tny_a9260_nand_hw_init(void)
45{
Thomas Petazzoni65b0f872011-08-04 02:48:56 +000046 struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
47 struct at91_smc *smc = (struct at91_smc *)ATMEL_BASE_SMC;
48 struct at91_matrix *matrix = (struct at91_matrix *)ATMEL_BASE_MATRIX;
Albin Tonnerre2dc851e2009-08-20 16:04:49 +020049 unsigned long csa;
50
Thomas Petazzoni65b0f872011-08-04 02:48:56 +000051 /* Assign CS3 to NAND/SmartMedia Interface */
52 csa = readl(&matrix->ebicsa);
53 csa |= AT91_MATRIX_CS3A_SMC_SMARTMEDIA;
54 writel(csa, &matrix->ebicsa);
Albin Tonnerre2dc851e2009-08-20 16:04:49 +020055
56 /* Configure SMC CS3 for NAND/SmartMedia */
Thomas Petazzoni65b0f872011-08-04 02:48:56 +000057 writel(AT91_SMC_SETUP_NWE(1) | AT91_SMC_SETUP_NCS_WR(0) |
58 AT91_SMC_SETUP_NRD(1) | AT91_SMC_SETUP_NCS_RD(0),
59 &smc->cs[3].setup);
60 writel(AT91_SMC_PULSE_NWE(3) | AT91_SMC_PULSE_NCS_WR(3) |
61 AT91_SMC_PULSE_NRD(3) | AT91_SMC_PULSE_NCS_RD(3),
62 &smc->cs[3].pulse);
63 writel(AT91_SMC_CYCLE_NWE(5) | AT91_SMC_CYCLE_NRD(5),
64 &smc->cs[3].cycle);
65 writel(AT91_SMC_MODE_RM_NRD | AT91_SMC_MODE_WM_NWE |
66 AT91_SMC_MODE_EXNW_DISABLE |
Albin Tonnerre2dc851e2009-08-20 16:04:49 +020067#ifdef CONFIG_SYS_NAND_DBW_16
Thomas Petazzoni65b0f872011-08-04 02:48:56 +000068 AT91_SMC_MODE_DBW_16 |
Albin Tonnerre2dc851e2009-08-20 16:04:49 +020069#else /* CONFIG_SYS_NAND_DBW_8 */
Thomas Petazzoni65b0f872011-08-04 02:48:56 +000070 AT91_SMC_MODE_DBW_8 |
Albin Tonnerre2dc851e2009-08-20 16:04:49 +020071#endif
Thomas Petazzoni65b0f872011-08-04 02:48:56 +000072 AT91_SMC_MODE_TDF_CYCLE(2),
73 &smc->cs[3].mode);
Albin Tonnerre2dc851e2009-08-20 16:04:49 +020074
Thomas Petazzoni65b0f872011-08-04 02:48:56 +000075 writel(1 << ATMEL_ID_PIOC, &pmc->pcer);
Albin Tonnerre2dc851e2009-08-20 16:04:49 +020076
77 /* Configure RDY/BSY */
78 at91_set_gpio_input(CONFIG_SYS_NAND_READY_PIN, 1);
79
80 /* Enable NandFlash */
81 at91_set_gpio_output(CONFIG_SYS_NAND_ENABLE_PIN, 1);
82}
83
84int board_init(void)
85{
86 /* Enable Ctrlc */
87 console_init_f();
88
Albin Tonnerre2dc851e2009-08-20 16:04:49 +020089 /* adress of boot parameters */
Thomas Petazzoni65b0f872011-08-04 02:48:56 +000090 gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
Albin Tonnerre2dc851e2009-08-20 16:04:49 +020091
Thomas Petazzoni65b0f872011-08-04 02:48:56 +000092 at91_seriald_hw_init();
Albin Tonnerre2dc851e2009-08-20 16:04:49 +020093 tny_a9260_nand_hw_init();
94 at91_spi0_hw_init(1 << 5);
95 return 0;
96}
97
98int dram_init(void)
99{
Thomas Petazzoni65b0f872011-08-04 02:48:56 +0000100 gd->ram_size = get_ram_size(
101 (void *)CONFIG_SYS_SDRAM_BASE,
102 CONFIG_SYS_SDRAM_SIZE);
Albin Tonnerre2dc851e2009-08-20 16:04:49 +0200103 return 0;
104}