2008-03-26 17:52:33 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2007-2008
|
2008-05-08 20:52:09 +00:00
|
|
|
* Stelian Pop <stelian.pop@leadtechdesign.com>
|
2008-03-26 17:52:33 +00:00
|
|
|
* Lead Tech Design <www.leadtechdesign.com>
|
|
|
|
*
|
|
|
|
* See file CREDITS for list of people who contributed to this
|
|
|
|
* project.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 of
|
|
|
|
* the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <asm/arch/at91sam9260.h>
|
|
|
|
#include <asm/arch/at91sam9260_matrix.h>
|
2008-05-08 20:52:10 +00:00
|
|
|
#include <asm/arch/at91sam9_smc.h>
|
2009-03-21 20:07:59 +00:00
|
|
|
#include <asm/arch/at91_common.h>
|
2008-03-26 17:52:33 +00:00
|
|
|
#include <asm/arch/at91_pmc.h>
|
|
|
|
#include <asm/arch/at91_rstc.h>
|
|
|
|
#include <asm/arch/gpio.h>
|
|
|
|
#include <asm/arch/io.h>
|
2008-08-13 05:11:53 +00:00
|
|
|
#include <asm/arch/hardware.h>
|
2008-03-26 17:52:33 +00:00
|
|
|
#if defined(CONFIG_RESET_PHY_R) && defined(CONFIG_MACB)
|
|
|
|
#include <net.h>
|
|
|
|
#endif
|
2008-08-13 05:11:53 +00:00
|
|
|
#include <netdev.h>
|
2008-03-26 17:52:33 +00:00
|
|
|
|
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
/*
|
|
|
|
* Miscelaneous platform dependent initialisations
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef CONFIG_CMD_NAND
|
|
|
|
static void at91sam9260ek_nand_hw_init(void)
|
|
|
|
{
|
|
|
|
unsigned long csa;
|
|
|
|
|
|
|
|
/* Enable CS3 */
|
|
|
|
csa = at91_sys_read(AT91_MATRIX_EBICSA);
|
|
|
|
at91_sys_write(AT91_MATRIX_EBICSA,
|
|
|
|
csa | AT91_MATRIX_CS3A_SMC_SMARTMEDIA);
|
|
|
|
|
|
|
|
/* Configure SMC CS3 for NAND/SmartMedia */
|
|
|
|
at91_sys_write(AT91_SMC_SETUP(3),
|
2008-05-27 09:15:29 +00:00
|
|
|
AT91_SMC_NWESETUP_(1) | AT91_SMC_NCS_WRSETUP_(0) |
|
|
|
|
AT91_SMC_NRDSETUP_(1) | AT91_SMC_NCS_RDSETUP_(0));
|
2008-03-26 17:52:33 +00:00
|
|
|
at91_sys_write(AT91_SMC_PULSE(3),
|
|
|
|
AT91_SMC_NWEPULSE_(3) | AT91_SMC_NCS_WRPULSE_(3) |
|
|
|
|
AT91_SMC_NRDPULSE_(3) | AT91_SMC_NCS_RDPULSE_(3));
|
|
|
|
at91_sys_write(AT91_SMC_CYCLE(3),
|
|
|
|
AT91_SMC_NWECYCLE_(5) | AT91_SMC_NRDCYCLE_(5));
|
|
|
|
at91_sys_write(AT91_SMC_MODE(3),
|
|
|
|
AT91_SMC_READMODE | AT91_SMC_WRITEMODE |
|
|
|
|
AT91_SMC_EXNWMODE_DISABLE |
|
2008-10-16 13:01:15 +00:00
|
|
|
#ifdef CONFIG_SYS_NAND_DBW_16
|
2008-05-08 18:52:18 +00:00
|
|
|
AT91_SMC_DBW_16 |
|
2008-10-16 13:01:15 +00:00
|
|
|
#else /* CONFIG_SYS_NAND_DBW_8 */
|
2008-05-08 18:52:18 +00:00
|
|
|
AT91_SMC_DBW_8 |
|
|
|
|
#endif
|
|
|
|
AT91_SMC_TDF_(2));
|
2008-03-26 17:52:33 +00:00
|
|
|
|
|
|
|
at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9260_ID_PIOC);
|
|
|
|
|
|
|
|
/* Configure RDY/BSY */
|
2009-03-22 09:22:34 +00:00
|
|
|
at91_set_gpio_input(CONFIG_SYS_NAND_READY_PIN, 1);
|
2008-03-26 17:52:33 +00:00
|
|
|
|
|
|
|
/* Enable NandFlash */
|
2009-03-22 09:22:34 +00:00
|
|
|
at91_set_gpio_output(CONFIG_SYS_NAND_ENABLE_PIN, 1);
|
2008-03-26 17:52:33 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_MACB
|
|
|
|
static void at91sam9260ek_macb_hw_init(void)
|
|
|
|
{
|
|
|
|
/* Enable clock */
|
|
|
|
at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9260_ID_EMAC);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Disable pull-up on:
|
|
|
|
* RXDV (PA17) => PHY normal mode (not Test mode)
|
2008-05-20 14:00:29 +00:00
|
|
|
* ERX0 (PA14) => PHY ADDR0
|
2008-03-26 17:52:33 +00:00
|
|
|
* ERX1 (PA15) => PHY ADDR1
|
|
|
|
* ERX2 (PA25) => PHY ADDR2
|
|
|
|
* ERX3 (PA26) => PHY ADDR3
|
|
|
|
* ECRS (PA28) => PHY ADDR4 => PHYADDR = 0x0
|
|
|
|
*
|
|
|
|
* PHY has internal pull-down
|
|
|
|
*/
|
|
|
|
writel(pin_to_mask(AT91_PIN_PA14) |
|
|
|
|
pin_to_mask(AT91_PIN_PA15) |
|
|
|
|
pin_to_mask(AT91_PIN_PA17) |
|
|
|
|
pin_to_mask(AT91_PIN_PA25) |
|
|
|
|
pin_to_mask(AT91_PIN_PA26) |
|
|
|
|
pin_to_mask(AT91_PIN_PA28),
|
|
|
|
pin_to_controller(AT91_PIN_PA0) + PIO_PUDR);
|
|
|
|
|
|
|
|
/* Need to reset PHY -> 500ms reset */
|
|
|
|
at91_sys_write(AT91_RSTC_MR, AT91_RSTC_KEY |
|
2008-05-21 22:15:40 +00:00
|
|
|
(AT91_RSTC_ERSTL & (0x0D << 8)) |
|
2008-03-26 17:52:33 +00:00
|
|
|
AT91_RSTC_URSTEN);
|
|
|
|
|
|
|
|
at91_sys_write(AT91_RSTC_CR, AT91_RSTC_KEY | AT91_RSTC_EXTRST);
|
|
|
|
|
|
|
|
/* Wait for end hardware reset */
|
|
|
|
while (!(at91_sys_read(AT91_RSTC_SR) & AT91_RSTC_NRSTL));
|
|
|
|
|
|
|
|
/* Restore NRST value */
|
|
|
|
at91_sys_write(AT91_RSTC_MR, AT91_RSTC_KEY |
|
2008-05-21 22:15:40 +00:00
|
|
|
(AT91_RSTC_ERSTL & (0x0 << 8)) |
|
2008-03-26 17:52:33 +00:00
|
|
|
AT91_RSTC_URSTEN);
|
|
|
|
|
|
|
|
/* Re-enable pull-up */
|
|
|
|
writel(pin_to_mask(AT91_PIN_PA14) |
|
|
|
|
pin_to_mask(AT91_PIN_PA15) |
|
|
|
|
pin_to_mask(AT91_PIN_PA17) |
|
|
|
|
pin_to_mask(AT91_PIN_PA25) |
|
|
|
|
pin_to_mask(AT91_PIN_PA26) |
|
|
|
|
pin_to_mask(AT91_PIN_PA28),
|
|
|
|
pin_to_controller(AT91_PIN_PA0) + PIO_PUER);
|
|
|
|
|
2009-03-21 20:08:00 +00:00
|
|
|
at91_macb_hw_init();
|
2008-03-26 17:52:33 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int board_init(void)
|
|
|
|
{
|
|
|
|
/* Enable Ctrlc */
|
|
|
|
console_init_f();
|
|
|
|
|
2009-03-22 13:48:16 +00:00
|
|
|
#ifdef CONFIG_AT91SAM9G20EK
|
|
|
|
/* arch number of AT91SAM9260EK-Board */
|
|
|
|
gd->bd->bi_arch_number = MACH_TYPE_AT91SAM9G20EK;
|
|
|
|
#else
|
2008-03-26 17:52:33 +00:00
|
|
|
/* arch number of AT91SAM9260EK-Board */
|
|
|
|
gd->bd->bi_arch_number = MACH_TYPE_AT91SAM9260EK;
|
2009-03-22 13:48:16 +00:00
|
|
|
#endif
|
2008-03-26 17:52:33 +00:00
|
|
|
/* adress of boot parameters */
|
|
|
|
gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
|
|
|
|
|
2009-03-21 20:07:59 +00:00
|
|
|
at91_serial_hw_init();
|
2008-03-26 17:52:33 +00:00
|
|
|
#ifdef CONFIG_CMD_NAND
|
|
|
|
at91sam9260ek_nand_hw_init();
|
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_HAS_DATAFLASH
|
2009-03-21 20:07:59 +00:00
|
|
|
at91_spi0_hw_init((1 << 0) || (1 << 1));
|
2008-03-26 17:52:33 +00:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_MACB
|
|
|
|
at91sam9260ek_macb_hw_init();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int dram_init(void)
|
|
|
|
{
|
|
|
|
gd->bd->bi_dram[0].start = PHYS_SDRAM;
|
|
|
|
gd->bd->bi_dram[0].size = PHYS_SDRAM_SIZE;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_RESET_PHY_R
|
|
|
|
void reset_phy(void)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_MACB
|
|
|
|
/*
|
|
|
|
* Initialize ethernet HW addr prior to starting Linux,
|
|
|
|
* needed for nfsroot
|
|
|
|
*/
|
|
|
|
eth_init(gd->bd);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#endif
|
2008-08-13 05:11:53 +00:00
|
|
|
|
|
|
|
int board_eth_init(bd_t *bis)
|
|
|
|
{
|
|
|
|
int rc = 0;
|
|
|
|
#ifdef CONFIG_MACB
|
2008-11-07 12:54:31 +00:00
|
|
|
rc = macb_eth_initialize(0, (void *)AT91SAM9260_BASE_EMAC, 0x00);
|
2008-08-13 05:11:53 +00:00
|
|
|
#endif
|
|
|
|
return rc;
|
|
|
|
}
|