blob: 908a500f4b9f38438d0022e8a87dd8ca40784ab4 [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>
Simon Glassdbd79542020-05-10 11:40:11 -060016#include <linux/delay.h>
TsiChungLiew5b8943a2008-01-15 14:02:49 -060017
18DECLARE_GLOBAL_DATA_PTR;
19
20int checkboard(void)
21{
22 puts("Board: ");
23 puts("Freescale FireEngine 5475 EVB\n");
24 return 0;
25};
26
Simon Glassd35f3382017-04-06 12:47:05 -060027int dram_init(void)
TsiChungLiew5b8943a2008-01-15 14:02:49 -060028{
Alison Wang027f76f2012-03-26 21:49:07 +000029 siu_t *siu = (siu_t *) (MMAP_SIU);
30 sdram_t *sdram = (sdram_t *)(MMAP_SDRAM);
TsiChungLiew5b8943a2008-01-15 14:02:49 -060031 u32 dramsize, i;
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020032#ifdef CONFIG_SYS_DRAMSZ1
TsiChung Liew4e376142008-03-17 12:09:07 -050033 u32 temp;
34#endif
TsiChungLiew5b8943a2008-01-15 14:02:49 -060035
Alison Wang027f76f2012-03-26 21:49:07 +000036 out_be32(&siu->drv, CONFIG_SYS_SDRAM_DRVSTRENGTH);
TsiChungLiew5b8943a2008-01-15 14:02:49 -060037
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020038 dramsize = CONFIG_SYS_DRAMSZ * 0x100000;
TsiChungLiew5b8943a2008-01-15 14:02:49 -060039 for (i = 0x13; i < 0x20; i++) {
40 if (dramsize == (1 << i))
41 break;
42 }
43 i--;
Alison Wang027f76f2012-03-26 21:49:07 +000044 out_be32(&siu->cs0cfg, CONFIG_SYS_SDRAM_BASE | i);
TsiChungLiew5b8943a2008-01-15 14:02:49 -060045
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020046#ifdef CONFIG_SYS_DRAMSZ1
47 temp = CONFIG_SYS_DRAMSZ1 * 0x100000;
TsiChungLiew5b8943a2008-01-15 14:02:49 -060048 for (i = 0x13; i < 0x20; i++) {
49 if (temp == (1 << i))
50 break;
51 }
52 i--;
53 dramsize += temp;
Alison Wang027f76f2012-03-26 21:49:07 +000054 out_be32(&siu->cs1cfg, (CONFIG_SYS_SDRAM_BASE + temp) | i);
TsiChungLiew5b8943a2008-01-15 14:02:49 -060055#endif
56
Alison Wang027f76f2012-03-26 21:49:07 +000057 out_be32(&sdram->cfg1, CONFIG_SYS_SDRAM_CFG1);
58 out_be32(&sdram->cfg2, CONFIG_SYS_SDRAM_CFG2);
TsiChungLiew5b8943a2008-01-15 14:02:49 -060059
60 /* Issue PALL */
Alison Wang027f76f2012-03-26 21:49:07 +000061 out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 2);
TsiChungLiew5b8943a2008-01-15 14:02:49 -060062
63 /* Issue LEMR */
Alison Wang027f76f2012-03-26 21:49:07 +000064 out_be32(&sdram->mode, CONFIG_SYS_SDRAM_EMOD);
65 out_be32(&sdram->mode, CONFIG_SYS_SDRAM_MODE | 0x04000000);
TsiChungLiew5b8943a2008-01-15 14:02:49 -060066
67 udelay(500);
68
69 /* Issue PALL */
Alison Wang027f76f2012-03-26 21:49:07 +000070 out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 2);
TsiChungLiew5b8943a2008-01-15 14:02:49 -060071
72 /* Perform two refresh cycles */
Alison Wang027f76f2012-03-26 21:49:07 +000073 out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 4);
74 out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 4);
TsiChungLiew5b8943a2008-01-15 14:02:49 -060075
Alison Wang027f76f2012-03-26 21:49:07 +000076 out_be32(&sdram->mode, CONFIG_SYS_SDRAM_MODE);
TsiChungLiew5b8943a2008-01-15 14:02:49 -060077
Alison Wang027f76f2012-03-26 21:49:07 +000078 out_be32(&sdram->ctrl,
79 (CONFIG_SYS_SDRAM_CTRL & ~0x80000000) | 0x10000F00);
TsiChungLiew5b8943a2008-01-15 14:02:49 -060080
81 udelay(100);
82
Simon Glass39f90ba2017-03-31 08:40:25 -060083 gd->ram_size = dramsize;
84
85 return 0;
TsiChungLiew5b8943a2008-01-15 14:02:49 -060086};
87
88int testdram(void)
89{
90 /* TODO: XXX XXX XXX */
91 printf("DRAM test not implemented!\n");
92
93 return (0);
94}
95
96#if defined(CONFIG_PCI)
97/*
98 * Initialize PCI devices, report devices found.
99 */
100static struct pci_controller hose;
101extern void pci_mcf547x_8x_init(struct pci_controller *hose);
102
103void pci_init_board(void)
104{
105 pci_mcf547x_8x_init(&hose);
106}
107#endif /* CONFIG_PCI */