blob: 40e01c6f24f7cc46b6963c72a60bdaf0d8a17abe [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
TsiChungLiew5b8943a2008-01-15 14:02:49 -06002/*
3 * (C) Copyright 2000-2003
4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 *
Alison Wang027f76f2012-03-26 21:49:07 +00006 * Copyright (C) 2004-2007, 2012 Freescale Semiconductor, Inc.
TsiChungLiew5b8943a2008-01-15 14:02:49 -06007 * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
TsiChungLiew5b8943a2008-01-15 14:02:49 -06008 */
9
10#include <config.h>
11#include <common.h>
Simon Glass18afe102019-11-14 12:57:47 -070012#include <init.h>
TsiChungLiew5b8943a2008-01-15 14:02:49 -060013#include <pci.h>
14#include <asm/immap.h>
Alison Wang027f76f2012-03-26 21:49:07 +000015#include <asm/io.h>
TsiChungLiew5b8943a2008-01-15 14:02:49 -060016
17DECLARE_GLOBAL_DATA_PTR;
18
19int checkboard(void)
20{
21 puts("Board: ");
22 puts("Freescale FireEngine 5485 EVB\n");
23 return 0;
24};
25
Simon Glassd35f3382017-04-06 12:47:05 -060026int dram_init(void)
TsiChungLiew5b8943a2008-01-15 14:02:49 -060027{
Alison Wang027f76f2012-03-26 21:49:07 +000028 siu_t *siu = (siu_t *) (MMAP_SIU);
29 sdram_t *sdram = (sdram_t *)(MMAP_SDRAM);
TsiChungLiew5b8943a2008-01-15 14:02:49 -060030 u32 dramsize, i;
stany MARCELfba93142011-10-14 04:38:06 +000031#ifdef CONFIG_SYS_DRAMSZ1
32 u32 temp;
33#endif
TsiChungLiew5b8943a2008-01-15 14:02:49 -060034
Alison Wang027f76f2012-03-26 21:49:07 +000035 out_be32(&siu->drv, CONFIG_SYS_SDRAM_DRVSTRENGTH);
TsiChungLiew5b8943a2008-01-15 14:02:49 -060036
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020037 dramsize = CONFIG_SYS_DRAMSZ * 0x100000;
TsiChungLiew5b8943a2008-01-15 14:02:49 -060038 for (i = 0x13; i < 0x20; i++) {
39 if (dramsize == (1 << i))
40 break;
41 }
42 i--;
Alison Wang027f76f2012-03-26 21:49:07 +000043 out_be32(&siu->cs0cfg, CONFIG_SYS_SDRAM_BASE | i);
TsiChungLiew5b8943a2008-01-15 14:02:49 -060044
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020045#ifdef CONFIG_SYS_DRAMSZ1
46 temp = CONFIG_SYS_DRAMSZ1 * 0x100000;
TsiChungLiew5b8943a2008-01-15 14:02:49 -060047 for (i = 0x13; i < 0x20; i++) {
48 if (temp == (1 << i))
49 break;
50 }
51 i--;
52 dramsize += temp;
Alison Wang027f76f2012-03-26 21:49:07 +000053 out_be32(&siu->cs1cfg, (CONFIG_SYS_SDRAM_BASE + temp) | i);
TsiChungLiew5b8943a2008-01-15 14:02:49 -060054#endif
55
Alison Wang027f76f2012-03-26 21:49:07 +000056 out_be32(&sdram->cfg1, CONFIG_SYS_SDRAM_CFG1);
57 out_be32(&sdram->cfg2, CONFIG_SYS_SDRAM_CFG2);
TsiChungLiew5b8943a2008-01-15 14:02:49 -060058
59 /* Issue PALL */
Alison Wang027f76f2012-03-26 21:49:07 +000060 out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 2);
TsiChungLiew5b8943a2008-01-15 14:02:49 -060061
62 /* Issue LEMR */
Alison Wang027f76f2012-03-26 21:49:07 +000063 out_be32(&sdram->mode, CONFIG_SYS_SDRAM_EMOD);
64 out_be32(&sdram->mode, CONFIG_SYS_SDRAM_MODE | 0x04000000);
TsiChungLiew5b8943a2008-01-15 14:02:49 -060065
66 udelay(500);
67
68 /* Issue PALL */
Alison Wang027f76f2012-03-26 21:49:07 +000069 out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 2);
TsiChungLiew5b8943a2008-01-15 14:02:49 -060070
71 /* Perform two refresh cycles */
Alison Wang027f76f2012-03-26 21:49:07 +000072 out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 4);
73 out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 4);
TsiChungLiew5b8943a2008-01-15 14:02:49 -060074
Alison Wang027f76f2012-03-26 21:49:07 +000075 out_be32(&sdram->mode, CONFIG_SYS_SDRAM_MODE);
TsiChungLiew5b8943a2008-01-15 14:02:49 -060076
Alison Wang027f76f2012-03-26 21:49:07 +000077 out_be32(&sdram->ctrl,
78 (CONFIG_SYS_SDRAM_CTRL & ~0x80000000) | 0x10000F00);
TsiChungLiew5b8943a2008-01-15 14:02:49 -060079
80 udelay(100);
81
Simon Glass39f90ba2017-03-31 08:40:25 -060082 gd->ram_size = dramsize;
83
84 return 0;
TsiChungLiew5b8943a2008-01-15 14:02:49 -060085};
86
87int testdram(void)
88{
89 /* TODO: XXX XXX XXX */
90 printf("DRAM test not implemented!\n");
91
92 return (0);
93}
94
95#if defined(CONFIG_PCI)
96/*
97 * Initialize PCI devices, report devices found.
98 */
99static struct pci_controller hose;
100extern void pci_mcf547x_8x_init(struct pci_controller *hose);
101
102void pci_init_board(void)
103{
104 pci_mcf547x_8x_init(&hose);
105}
106#endif /* CONFIG_PCI */