2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2007-08-16 20:05:11 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2000-2003
|
|
|
|
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
|
|
|
*
|
2012-03-26 21:49:08 +00:00
|
|
|
* Copyright (C) 2004-2007, 2012 Freescale Semiconductor, Inc.
|
2007-08-16 20:05:11 +00:00
|
|
|
* TsiChung Liew (Tsi-Chung.Liew@freescale.com)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2019-11-14 19:57:47 +00:00
|
|
|
#include <init.h>
|
2007-08-16 20:05:11 +00:00
|
|
|
#include <pci.h>
|
|
|
|
#include <asm/immap.h>
|
2012-03-26 21:49:08 +00:00
|
|
|
#include <asm/io.h>
|
2007-08-16 20:05:11 +00:00
|
|
|
|
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
|
|
|
int checkboard(void)
|
|
|
|
{
|
|
|
|
puts("Board: ");
|
|
|
|
puts("Freescale M54455 EVB\n");
|
|
|
|
return 0;
|
|
|
|
};
|
|
|
|
|
2017-04-06 18:47:05 +00:00
|
|
|
int dram_init(void)
|
2007-08-16 20:05:11 +00:00
|
|
|
{
|
2008-07-24 01:38:53 +00:00
|
|
|
u32 dramsize;
|
|
|
|
#ifdef CONFIG_CF_SBF
|
|
|
|
/*
|
|
|
|
* Serial Boot: The dram is already initialized in start.S
|
|
|
|
* only require to return DRAM size
|
|
|
|
*/
|
2008-10-16 13:01:15 +00:00
|
|
|
dramsize = CONFIG_SYS_SDRAM_SIZE * 0x100000 >> 1;
|
2008-07-24 01:38:53 +00:00
|
|
|
#else
|
2012-03-26 21:49:08 +00:00
|
|
|
sdramc_t *sdram = (sdramc_t *)(MMAP_SDRAM);
|
|
|
|
gpio_t *gpio = (gpio_t *)(MMAP_GPIO);
|
2008-07-24 01:38:53 +00:00
|
|
|
u32 i;
|
2007-08-16 20:05:11 +00:00
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
dramsize = CONFIG_SYS_SDRAM_SIZE * 0x100000 >> 1;
|
2007-08-16 20:05:11 +00:00
|
|
|
|
|
|
|
for (i = 0x13; i < 0x20; i++) {
|
|
|
|
if (dramsize == (1 << i))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
i--;
|
|
|
|
|
2012-03-26 21:49:08 +00:00
|
|
|
out_8(&gpio->mscr_sdram, CONFIG_SYS_SDRAM_DRV_STRENGTH);
|
2007-08-16 20:05:11 +00:00
|
|
|
|
2012-03-26 21:49:08 +00:00
|
|
|
out_be32(&sdram->sdcs0, CONFIG_SYS_SDRAM_BASE | i);
|
|
|
|
out_be32(&sdram->sdcs1, CONFIG_SYS_SDRAM_BASE1 | i);
|
2007-08-16 20:05:11 +00:00
|
|
|
|
2012-03-26 21:49:08 +00:00
|
|
|
out_be32(&sdram->sdcfg1, CONFIG_SYS_SDRAM_CFG1);
|
|
|
|
out_be32(&sdram->sdcfg2, CONFIG_SYS_SDRAM_CFG2);
|
2007-08-16 20:05:11 +00:00
|
|
|
|
|
|
|
/* Issue PALL */
|
2012-03-26 21:49:08 +00:00
|
|
|
out_be32(&sdram->sdcr, CONFIG_SYS_SDRAM_CTRL | 2);
|
2007-08-16 20:05:11 +00:00
|
|
|
|
|
|
|
/* Issue LEMR */
|
2012-03-26 21:49:08 +00:00
|
|
|
out_be32(&sdram->sdmr, CONFIG_SYS_SDRAM_EMOD | 0x408);
|
|
|
|
out_be32(&sdram->sdmr, CONFIG_SYS_SDRAM_MODE | 0x300);
|
2007-08-16 20:05:11 +00:00
|
|
|
|
|
|
|
udelay(500);
|
|
|
|
|
|
|
|
/* Issue PALL */
|
2012-03-26 21:49:08 +00:00
|
|
|
out_be32(&sdram->sdcr, CONFIG_SYS_SDRAM_CTRL | 2);
|
2007-08-16 20:05:11 +00:00
|
|
|
|
|
|
|
/* Perform two refresh cycles */
|
2012-03-26 21:49:08 +00:00
|
|
|
out_be32(&sdram->sdcr, CONFIG_SYS_SDRAM_CTRL | 4);
|
|
|
|
out_be32(&sdram->sdcr, CONFIG_SYS_SDRAM_CTRL | 4);
|
2007-08-16 20:05:11 +00:00
|
|
|
|
2012-03-26 21:49:08 +00:00
|
|
|
out_be32(&sdram->sdmr, CONFIG_SYS_SDRAM_MODE | 0x200);
|
2007-08-16 20:05:11 +00:00
|
|
|
|
2012-03-26 21:49:08 +00:00
|
|
|
out_be32(&sdram->sdcr,
|
|
|
|
(CONFIG_SYS_SDRAM_CTRL & ~0x80000000) | 0x10000c00);
|
2007-08-16 20:05:11 +00:00
|
|
|
|
|
|
|
udelay(100);
|
2008-07-24 01:38:53 +00:00
|
|
|
#endif
|
2017-03-31 14:40:25 +00:00
|
|
|
gd->ram_size = dramsize << 1;
|
|
|
|
|
|
|
|
return 0;
|
2007-08-16 20:05:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
int testdram(void)
|
|
|
|
{
|
|
|
|
/* TODO: XXX XXX XXX */
|
|
|
|
printf("DRAM test not implemented!\n");
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2017-05-17 09:25:30 +00:00
|
|
|
#if defined(CONFIG_IDE)
|
2007-08-16 20:05:11 +00:00
|
|
|
#include <ata.h>
|
|
|
|
|
|
|
|
int ide_preinit(void)
|
|
|
|
{
|
2012-03-26 21:49:08 +00:00
|
|
|
gpio_t *gpio = (gpio_t *) MMAP_GPIO;
|
|
|
|
u32 tmp;
|
|
|
|
|
|
|
|
tmp = (in_8(&gpio->par_fec) & GPIO_PAR_FEC_FEC1_UNMASK) | 0x10;
|
|
|
|
setbits_8(&gpio->par_fec, tmp);
|
|
|
|
tmp = ((in_be16(&gpio->par_feci2c) & 0xf0ff) |
|
|
|
|
(GPIO_PAR_FECI2C_MDC1_ATA_DIOR | GPIO_PAR_FECI2C_MDIO1_ATA_DIOW));
|
|
|
|
setbits_be16(&gpio->par_feci2c, tmp);
|
|
|
|
|
|
|
|
setbits_be16(&gpio->par_ata,
|
|
|
|
GPIO_PAR_ATA_BUFEN | GPIO_PAR_ATA_CS1 | GPIO_PAR_ATA_CS0 |
|
|
|
|
GPIO_PAR_ATA_DA2 | GPIO_PAR_ATA_DA1 | GPIO_PAR_ATA_DA0 |
|
|
|
|
GPIO_PAR_ATA_RESET_RESET | GPIO_PAR_ATA_DMARQ_DMARQ |
|
|
|
|
GPIO_PAR_ATA_IORDY_IORDY);
|
|
|
|
setbits_be16(&gpio->par_pci,
|
|
|
|
GPIO_PAR_PCI_GNT3_ATA_DMACK | GPIO_PAR_PCI_REQ3_ATA_INTRQ);
|
2007-08-16 20:05:11 +00:00
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ide_set_reset(int idereset)
|
|
|
|
{
|
2012-03-26 21:49:08 +00:00
|
|
|
atac_t *ata = (atac_t *) MMAP_ATA;
|
2007-08-16 20:05:11 +00:00
|
|
|
long period;
|
|
|
|
/* t1, t2, t3, t4, t5, t6, t9, tRD, tA */
|
|
|
|
int piotms[5][9] = {
|
|
|
|
{70, 165, 60, 30, 50, 5, 20, 0, 35}, /* PIO 0 */
|
|
|
|
{50, 125, 45, 20, 35, 5, 15, 0, 35}, /* PIO 1 */
|
|
|
|
{30, 100, 30, 15, 20, 5, 10, 0, 35}, /* PIO 2 */
|
|
|
|
{30, 80, 30, 10, 20, 5, 10, 0, 35}, /* PIO 3 */
|
|
|
|
{25, 70, 20, 10, 20, 5, 10, 0, 35}
|
|
|
|
}; /* PIO 4 */
|
|
|
|
|
|
|
|
if (idereset) {
|
2012-03-26 21:49:08 +00:00
|
|
|
/* control reset */
|
|
|
|
out_8(&ata->cr, 0);
|
2007-08-16 20:05:11 +00:00
|
|
|
udelay(10000);
|
|
|
|
} else {
|
|
|
|
#define CALC_TIMING(t) (t + period - 1) / period
|
|
|
|
period = 1000000000 / gd->bus_clk; /* period in ns */
|
|
|
|
|
|
|
|
/*ata->ton = CALC_TIMING (180); */
|
2012-03-26 21:49:08 +00:00
|
|
|
out_8(&ata->t1, CALC_TIMING(piotms[2][0]));
|
|
|
|
out_8(&ata->t2w, CALC_TIMING(piotms[2][1]));
|
|
|
|
out_8(&ata->t2r, CALC_TIMING(piotms[2][1]));
|
|
|
|
out_8(&ata->ta, CALC_TIMING(piotms[2][8]));
|
|
|
|
out_8(&ata->trd, CALC_TIMING(piotms[2][7]));
|
|
|
|
out_8(&ata->t4, CALC_TIMING(piotms[2][3]));
|
|
|
|
out_8(&ata->t9, CALC_TIMING(piotms[2][6]));
|
|
|
|
|
|
|
|
/* IORDY enable */
|
|
|
|
out_8(&ata->cr, 0x40);
|
2007-08-16 20:05:11 +00:00
|
|
|
udelay(200000);
|
2012-03-26 21:49:08 +00:00
|
|
|
/* IORDY enable */
|
|
|
|
setbits_8(&ata->cr, 0x01);
|
2007-08-16 20:05:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(CONFIG_PCI)
|
|
|
|
/*
|
|
|
|
* Initialize PCI devices, report devices found.
|
|
|
|
*/
|
|
|
|
static struct pci_controller hose;
|
|
|
|
extern void pci_mcf5445x_init(struct pci_controller *hose);
|
|
|
|
|
|
|
|
void pci_init_board(void)
|
|
|
|
{
|
|
|
|
pci_mcf5445x_init(&hose);
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_PCI */
|
2008-07-23 22:37:10 +00:00
|
|
|
|
2008-08-18 18:26:25 +00:00
|
|
|
#if defined(CONFIG_FLASH_CFI_LEGACY)
|
2008-07-23 22:37:10 +00:00
|
|
|
#include <flash.h>
|
|
|
|
ulong board_flash_get_legacy (ulong base, int banknum, flash_info_t * info)
|
|
|
|
{
|
2008-10-16 13:01:15 +00:00
|
|
|
int sect[] = CONFIG_SYS_ATMEL_SECT;
|
|
|
|
int sectsz[] = CONFIG_SYS_ATMEL_SECTSZ;
|
2008-07-23 22:37:10 +00:00
|
|
|
int i, j, k;
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
if (base != CONFIG_SYS_ATMEL_BASE)
|
2008-07-23 22:37:10 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
info->flash_id = 0x01000000;
|
|
|
|
info->portwidth = 1;
|
|
|
|
info->chipwidth = 1;
|
2010-03-16 17:39:36 +00:00
|
|
|
info->buffer_size = 1;
|
2008-07-23 22:37:10 +00:00
|
|
|
info->erase_blk_tout = 16384;
|
|
|
|
info->write_tout = 2;
|
|
|
|
info->buffer_write_tout = 5;
|
2008-08-18 18:26:25 +00:00
|
|
|
info->vendor = 0xFFF0; /* CFI_CMDSET_AMD_LEGACY */
|
2008-07-23 22:37:10 +00:00
|
|
|
info->cmd_reset = 0x00F0;
|
|
|
|
info->interface = FLASH_CFI_X8;
|
|
|
|
info->legacy_unlock = 0;
|
|
|
|
info->manufacturer_id = (u16) ATM_MANUFACT;
|
|
|
|
info->device_id = ATM_ID_LV040;
|
|
|
|
info->device_id2 = 0;
|
|
|
|
|
|
|
|
info->ext_addr = 0;
|
|
|
|
info->cfi_version = 0x3133;
|
2008-08-18 18:26:25 +00:00
|
|
|
info->cfi_offset = 0x0000;
|
2008-07-23 22:37:10 +00:00
|
|
|
info->addr_unlock1 = 0x00000555;
|
|
|
|
info->addr_unlock2 = 0x000002AA;
|
|
|
|
info->name = "CFI conformant";
|
|
|
|
|
|
|
|
info->size = 0;
|
2008-10-16 13:01:15 +00:00
|
|
|
info->sector_count = CONFIG_SYS_ATMEL_TOTALSECT;
|
2008-07-23 22:37:10 +00:00
|
|
|
info->start[0] = base;
|
2008-10-16 13:01:15 +00:00
|
|
|
for (k = 0, i = 0; i < CONFIG_SYS_ATMEL_REGION; i++) {
|
2008-07-23 22:37:10 +00:00
|
|
|
info->size += sect[i] * sectsz[i];
|
|
|
|
|
|
|
|
for (j = 0; j < sect[i]; j++, k++) {
|
|
|
|
info->start[k + 1] = info->start[k] + sectsz[i];
|
|
|
|
info->protect[k] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
2008-10-16 13:01:15 +00:00
|
|
|
#endif /* CONFIG_SYS_FLASH_CFI */
|