blob: 76b4322a1976a8cb9ada409297db9b06104a9297 [file] [log] [blame]
TsiChungLiew8ae158c2007-08-16 15:05:11 -05001/*
2 * (C) Copyright 2000-2003
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 *
Alison Wang198cafb2012-03-26 21:49:08 +00005 * Copyright (C) 2004-2007, 2012 Freescale Semiconductor, Inc.
TsiChungLiew8ae158c2007-08-16 15:05:11 -05006 * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
7 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02008 * SPDX-License-Identifier: GPL-2.0+
TsiChungLiew8ae158c2007-08-16 15:05:11 -05009 */
10
11#include <common.h>
12#include <pci.h>
13#include <asm/immap.h>
Alison Wang198cafb2012-03-26 21:49:08 +000014#include <asm/io.h>
TsiChungLiew8ae158c2007-08-16 15:05:11 -050015
16DECLARE_GLOBAL_DATA_PTR;
17
18int checkboard(void)
19{
20 puts("Board: ");
21 puts("Freescale M54455 EVB\n");
22 return 0;
23};
24
Becky Bruce9973e3c2008-06-09 16:03:40 -050025phys_size_t initdram(int board_type)
TsiChungLiew8ae158c2007-08-16 15:05:11 -050026{
TsiChung Liew9f751552008-07-23 20:38:53 -050027 u32 dramsize;
28#ifdef CONFIG_CF_SBF
29 /*
30 * Serial Boot: The dram is already initialized in start.S
31 * only require to return DRAM size
32 */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020033 dramsize = CONFIG_SYS_SDRAM_SIZE * 0x100000 >> 1;
TsiChung Liew9f751552008-07-23 20:38:53 -050034#else
Alison Wang198cafb2012-03-26 21:49:08 +000035 sdramc_t *sdram = (sdramc_t *)(MMAP_SDRAM);
36 gpio_t *gpio = (gpio_t *)(MMAP_GPIO);
TsiChung Liew9f751552008-07-23 20:38:53 -050037 u32 i;
TsiChungLiew8ae158c2007-08-16 15:05:11 -050038
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020039 dramsize = CONFIG_SYS_SDRAM_SIZE * 0x100000 >> 1;
TsiChungLiew8ae158c2007-08-16 15:05:11 -050040
41 for (i = 0x13; i < 0x20; i++) {
42 if (dramsize == (1 << i))
43 break;
44 }
45 i--;
46
Alison Wang198cafb2012-03-26 21:49:08 +000047 out_8(&gpio->mscr_sdram, CONFIG_SYS_SDRAM_DRV_STRENGTH);
TsiChungLiew8ae158c2007-08-16 15:05:11 -050048
Alison Wang198cafb2012-03-26 21:49:08 +000049 out_be32(&sdram->sdcs0, CONFIG_SYS_SDRAM_BASE | i);
50 out_be32(&sdram->sdcs1, CONFIG_SYS_SDRAM_BASE1 | i);
TsiChungLiew8ae158c2007-08-16 15:05:11 -050051
Alison Wang198cafb2012-03-26 21:49:08 +000052 out_be32(&sdram->sdcfg1, CONFIG_SYS_SDRAM_CFG1);
53 out_be32(&sdram->sdcfg2, CONFIG_SYS_SDRAM_CFG2);
TsiChungLiew8ae158c2007-08-16 15:05:11 -050054
55 /* Issue PALL */
Alison Wang198cafb2012-03-26 21:49:08 +000056 out_be32(&sdram->sdcr, CONFIG_SYS_SDRAM_CTRL | 2);
TsiChungLiew8ae158c2007-08-16 15:05:11 -050057
58 /* Issue LEMR */
Alison Wang198cafb2012-03-26 21:49:08 +000059 out_be32(&sdram->sdmr, CONFIG_SYS_SDRAM_EMOD | 0x408);
60 out_be32(&sdram->sdmr, CONFIG_SYS_SDRAM_MODE | 0x300);
TsiChungLiew8ae158c2007-08-16 15:05:11 -050061
62 udelay(500);
63
64 /* Issue PALL */
Alison Wang198cafb2012-03-26 21:49:08 +000065 out_be32(&sdram->sdcr, CONFIG_SYS_SDRAM_CTRL | 2);
TsiChungLiew8ae158c2007-08-16 15:05:11 -050066
67 /* Perform two refresh cycles */
Alison Wang198cafb2012-03-26 21:49:08 +000068 out_be32(&sdram->sdcr, CONFIG_SYS_SDRAM_CTRL | 4);
69 out_be32(&sdram->sdcr, CONFIG_SYS_SDRAM_CTRL | 4);
TsiChungLiew8ae158c2007-08-16 15:05:11 -050070
Alison Wang198cafb2012-03-26 21:49:08 +000071 out_be32(&sdram->sdmr, CONFIG_SYS_SDRAM_MODE | 0x200);
TsiChungLiew8ae158c2007-08-16 15:05:11 -050072
Alison Wang198cafb2012-03-26 21:49:08 +000073 out_be32(&sdram->sdcr,
74 (CONFIG_SYS_SDRAM_CTRL & ~0x80000000) | 0x10000c00);
TsiChungLiew8ae158c2007-08-16 15:05:11 -050075
76 udelay(100);
TsiChung Liew9f751552008-07-23 20:38:53 -050077#endif
TsiChungLiew8ae158c2007-08-16 15:05:11 -050078 return (dramsize << 1);
79};
80
81int testdram(void)
82{
83 /* TODO: XXX XXX XXX */
84 printf("DRAM test not implemented!\n");
85
86 return (0);
87}
88
89#if defined(CONFIG_CMD_IDE)
90#include <ata.h>
91
92int ide_preinit(void)
93{
Alison Wang198cafb2012-03-26 21:49:08 +000094 gpio_t *gpio = (gpio_t *) MMAP_GPIO;
95 u32 tmp;
TsiChungLiew8ae158c2007-08-16 15:05:11 -050096
Alison Wang198cafb2012-03-26 21:49:08 +000097 tmp = (in_8(&gpio->par_fec) & GPIO_PAR_FEC_FEC1_UNMASK) | 0x10;
98 setbits_8(&gpio->par_fec, tmp);
99 tmp = ((in_be16(&gpio->par_feci2c) & 0xf0ff) |
100 (GPIO_PAR_FECI2C_MDC1_ATA_DIOR | GPIO_PAR_FECI2C_MDIO1_ATA_DIOW));
101 setbits_be16(&gpio->par_feci2c, tmp);
102
103 setbits_be16(&gpio->par_ata,
104 GPIO_PAR_ATA_BUFEN | GPIO_PAR_ATA_CS1 | GPIO_PAR_ATA_CS0 |
105 GPIO_PAR_ATA_DA2 | GPIO_PAR_ATA_DA1 | GPIO_PAR_ATA_DA0 |
106 GPIO_PAR_ATA_RESET_RESET | GPIO_PAR_ATA_DMARQ_DMARQ |
107 GPIO_PAR_ATA_IORDY_IORDY);
108 setbits_be16(&gpio->par_pci,
109 GPIO_PAR_PCI_GNT3_ATA_DMACK | GPIO_PAR_PCI_REQ3_ATA_INTRQ);
TsiChungLiew8ae158c2007-08-16 15:05:11 -0500110
111 return (0);
112}
113
114void ide_set_reset(int idereset)
115{
Alison Wang198cafb2012-03-26 21:49:08 +0000116 atac_t *ata = (atac_t *) MMAP_ATA;
TsiChungLiew8ae158c2007-08-16 15:05:11 -0500117 long period;
118 /* t1, t2, t3, t4, t5, t6, t9, tRD, tA */
119 int piotms[5][9] = {
120 {70, 165, 60, 30, 50, 5, 20, 0, 35}, /* PIO 0 */
121 {50, 125, 45, 20, 35, 5, 15, 0, 35}, /* PIO 1 */
122 {30, 100, 30, 15, 20, 5, 10, 0, 35}, /* PIO 2 */
123 {30, 80, 30, 10, 20, 5, 10, 0, 35}, /* PIO 3 */
124 {25, 70, 20, 10, 20, 5, 10, 0, 35}
125 }; /* PIO 4 */
126
127 if (idereset) {
Alison Wang198cafb2012-03-26 21:49:08 +0000128 /* control reset */
129 out_8(&ata->cr, 0);
TsiChungLiew8ae158c2007-08-16 15:05:11 -0500130 udelay(10000);
131 } else {
132#define CALC_TIMING(t) (t + period - 1) / period
133 period = 1000000000 / gd->bus_clk; /* period in ns */
134
135 /*ata->ton = CALC_TIMING (180); */
Alison Wang198cafb2012-03-26 21:49:08 +0000136 out_8(&ata->t1, CALC_TIMING(piotms[2][0]));
137 out_8(&ata->t2w, CALC_TIMING(piotms[2][1]));
138 out_8(&ata->t2r, CALC_TIMING(piotms[2][1]));
139 out_8(&ata->ta, CALC_TIMING(piotms[2][8]));
140 out_8(&ata->trd, CALC_TIMING(piotms[2][7]));
141 out_8(&ata->t4, CALC_TIMING(piotms[2][3]));
142 out_8(&ata->t9, CALC_TIMING(piotms[2][6]));
TsiChungLiew8ae158c2007-08-16 15:05:11 -0500143
Alison Wang198cafb2012-03-26 21:49:08 +0000144 /* IORDY enable */
145 out_8(&ata->cr, 0x40);
TsiChungLiew8ae158c2007-08-16 15:05:11 -0500146 udelay(200000);
Alison Wang198cafb2012-03-26 21:49:08 +0000147 /* IORDY enable */
148 setbits_8(&ata->cr, 0x01);
TsiChungLiew8ae158c2007-08-16 15:05:11 -0500149 }
150}
151#endif
152
153#if defined(CONFIG_PCI)
154/*
155 * Initialize PCI devices, report devices found.
156 */
157static struct pci_controller hose;
158extern void pci_mcf5445x_init(struct pci_controller *hose);
159
160void pci_init_board(void)
161{
162 pci_mcf5445x_init(&hose);
163}
164#endif /* CONFIG_PCI */
TsiChung Liewb2d022d2008-07-23 17:37:10 -0500165
TsiChung Liewf78ced32008-08-19 00:26:25 +0600166#if defined(CONFIG_FLASH_CFI_LEGACY)
TsiChung Liewb2d022d2008-07-23 17:37:10 -0500167#include <flash.h>
168ulong board_flash_get_legacy (ulong base, int banknum, flash_info_t * info)
169{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200170 int sect[] = CONFIG_SYS_ATMEL_SECT;
171 int sectsz[] = CONFIG_SYS_ATMEL_SECTSZ;
TsiChung Liewb2d022d2008-07-23 17:37:10 -0500172 int i, j, k;
173
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200174 if (base != CONFIG_SYS_ATMEL_BASE)
TsiChung Liewb2d022d2008-07-23 17:37:10 -0500175 return 0;
176
177 info->flash_id = 0x01000000;
178 info->portwidth = 1;
179 info->chipwidth = 1;
TsiChung Liew9d3a86a2010-03-16 12:39:36 -0500180 info->buffer_size = 1;
TsiChung Liewb2d022d2008-07-23 17:37:10 -0500181 info->erase_blk_tout = 16384;
182 info->write_tout = 2;
183 info->buffer_write_tout = 5;
TsiChung Liewf78ced32008-08-19 00:26:25 +0600184 info->vendor = 0xFFF0; /* CFI_CMDSET_AMD_LEGACY */
TsiChung Liewb2d022d2008-07-23 17:37:10 -0500185 info->cmd_reset = 0x00F0;
186 info->interface = FLASH_CFI_X8;
187 info->legacy_unlock = 0;
188 info->manufacturer_id = (u16) ATM_MANUFACT;
189 info->device_id = ATM_ID_LV040;
190 info->device_id2 = 0;
191
192 info->ext_addr = 0;
193 info->cfi_version = 0x3133;
TsiChung Liewf78ced32008-08-19 00:26:25 +0600194 info->cfi_offset = 0x0000;
TsiChung Liewb2d022d2008-07-23 17:37:10 -0500195 info->addr_unlock1 = 0x00000555;
196 info->addr_unlock2 = 0x000002AA;
197 info->name = "CFI conformant";
198
TsiChung Liewb2d022d2008-07-23 17:37:10 -0500199 info->size = 0;
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200200 info->sector_count = CONFIG_SYS_ATMEL_TOTALSECT;
TsiChung Liewb2d022d2008-07-23 17:37:10 -0500201 info->start[0] = base;
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200202 for (k = 0, i = 0; i < CONFIG_SYS_ATMEL_REGION; i++) {
TsiChung Liewb2d022d2008-07-23 17:37:10 -0500203 info->size += sect[i] * sectsz[i];
204
205 for (j = 0; j < sect[i]; j++, k++) {
206 info->start[k + 1] = info->start[k] + sectsz[i];
207 info->protect[k] = 0;
208 }
209 }
210
211 return 1;
212}
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200213#endif /* CONFIG_SYS_FLASH_CFI */