blob: b62355a7ae7bcaeac059ec1981da71a7c0b0b9ab [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>
Simon Glass3ba929a2020-10-30 21:38:53 -060014#include <asm/global_data.h>
TsiChungLiew5b8943a2008-01-15 14:02:49 -060015#include <asm/immap.h>
Alison Wang027f76f2012-03-26 21:49:07 +000016#include <asm/io.h>
Simon Glassdbd79542020-05-10 11:40:11 -060017#include <linux/delay.h>
TsiChungLiew5b8943a2008-01-15 14:02:49 -060018
19DECLARE_GLOBAL_DATA_PTR;
20
21int checkboard(void)
22{
23 puts("Board: ");
24 puts("Freescale FireEngine 5485 EVB\n");
25 return 0;
26};
27
Simon Glassd35f3382017-04-06 12:47:05 -060028int dram_init(void)
TsiChungLiew5b8943a2008-01-15 14:02:49 -060029{
Alison Wang027f76f2012-03-26 21:49:07 +000030 siu_t *siu = (siu_t *) (MMAP_SIU);
31 sdram_t *sdram = (sdram_t *)(MMAP_SDRAM);
TsiChungLiew5b8943a2008-01-15 14:02:49 -060032 u32 dramsize, i;
stany MARCELfba93142011-10-14 04:38:06 +000033#ifdef CONFIG_SYS_DRAMSZ1
34 u32 temp;
35#endif
TsiChungLiew5b8943a2008-01-15 14:02:49 -060036
Alison Wang027f76f2012-03-26 21:49:07 +000037 out_be32(&siu->drv, CONFIG_SYS_SDRAM_DRVSTRENGTH);
TsiChungLiew5b8943a2008-01-15 14:02:49 -060038
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020039 dramsize = CONFIG_SYS_DRAMSZ * 0x100000;
TsiChungLiew5b8943a2008-01-15 14:02:49 -060040 for (i = 0x13; i < 0x20; i++) {
41 if (dramsize == (1 << i))
42 break;
43 }
44 i--;
Alison Wang027f76f2012-03-26 21:49:07 +000045 out_be32(&siu->cs0cfg, CONFIG_SYS_SDRAM_BASE | i);
TsiChungLiew5b8943a2008-01-15 14:02:49 -060046
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020047#ifdef CONFIG_SYS_DRAMSZ1
48 temp = CONFIG_SYS_DRAMSZ1 * 0x100000;
TsiChungLiew5b8943a2008-01-15 14:02:49 -060049 for (i = 0x13; i < 0x20; i++) {
50 if (temp == (1 << i))
51 break;
52 }
53 i--;
54 dramsize += temp;
Alison Wang027f76f2012-03-26 21:49:07 +000055 out_be32(&siu->cs1cfg, (CONFIG_SYS_SDRAM_BASE + temp) | i);
TsiChungLiew5b8943a2008-01-15 14:02:49 -060056#endif
57
Alison Wang027f76f2012-03-26 21:49:07 +000058 out_be32(&sdram->cfg1, CONFIG_SYS_SDRAM_CFG1);
59 out_be32(&sdram->cfg2, CONFIG_SYS_SDRAM_CFG2);
TsiChungLiew5b8943a2008-01-15 14:02:49 -060060
61 /* Issue PALL */
Alison Wang027f76f2012-03-26 21:49:07 +000062 out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 2);
TsiChungLiew5b8943a2008-01-15 14:02:49 -060063
64 /* Issue LEMR */
Alison Wang027f76f2012-03-26 21:49:07 +000065 out_be32(&sdram->mode, CONFIG_SYS_SDRAM_EMOD);
66 out_be32(&sdram->mode, CONFIG_SYS_SDRAM_MODE | 0x04000000);
TsiChungLiew5b8943a2008-01-15 14:02:49 -060067
68 udelay(500);
69
70 /* Issue PALL */
Alison Wang027f76f2012-03-26 21:49:07 +000071 out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 2);
TsiChungLiew5b8943a2008-01-15 14:02:49 -060072
73 /* Perform two refresh cycles */
Alison Wang027f76f2012-03-26 21:49:07 +000074 out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 4);
75 out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 4);
TsiChungLiew5b8943a2008-01-15 14:02:49 -060076
Alison Wang027f76f2012-03-26 21:49:07 +000077 out_be32(&sdram->mode, CONFIG_SYS_SDRAM_MODE);
TsiChungLiew5b8943a2008-01-15 14:02:49 -060078
Alison Wang027f76f2012-03-26 21:49:07 +000079 out_be32(&sdram->ctrl,
80 (CONFIG_SYS_SDRAM_CTRL & ~0x80000000) | 0x10000F00);
TsiChungLiew5b8943a2008-01-15 14:02:49 -060081
82 udelay(100);
83
Simon Glass39f90ba2017-03-31 08:40:25 -060084 gd->ram_size = dramsize;
85
86 return 0;
TsiChungLiew5b8943a2008-01-15 14:02:49 -060087};
88
89int testdram(void)
90{
91 /* TODO: XXX XXX XXX */
92 printf("DRAM test not implemented!\n");
93
94 return (0);
95}
96
97#if defined(CONFIG_PCI)
98/*
99 * Initialize PCI devices, report devices found.
100 */
101static struct pci_controller hose;
102extern void pci_mcf547x_8x_init(struct pci_controller *hose);
103
104void pci_init_board(void)
105{
106 pci_mcf547x_8x_init(&hose);
107}
108#endif /* CONFIG_PCI */