xref: /rk3399_rockchip-uboot/board/freescale/m548xevb/m548xevb.c (revision f1683aa73c31db0a025e0254e6ce1ee7e56aad3e)
11aee1111STsiChungLiew /*
21aee1111STsiChungLiew  * (C) Copyright 2000-2003
31aee1111STsiChungLiew  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
41aee1111STsiChungLiew  *
5a4110eecSAlison Wang  * Copyright (C) 2004-2007, 2012 Freescale Semiconductor, Inc.
61aee1111STsiChungLiew  * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
71aee1111STsiChungLiew  *
81a459660SWolfgang Denk  * SPDX-License-Identifier:	GPL-2.0+
91aee1111STsiChungLiew  */
101aee1111STsiChungLiew 
111aee1111STsiChungLiew #include <config.h>
121aee1111STsiChungLiew #include <common.h>
131aee1111STsiChungLiew #include <pci.h>
141aee1111STsiChungLiew #include <asm/immap.h>
15a4110eecSAlison Wang #include <asm/io.h>
161aee1111STsiChungLiew 
171aee1111STsiChungLiew DECLARE_GLOBAL_DATA_PTR;
181aee1111STsiChungLiew 
checkboard(void)191aee1111STsiChungLiew int checkboard(void)
201aee1111STsiChungLiew {
211aee1111STsiChungLiew 	puts("Board: ");
221aee1111STsiChungLiew 	puts("Freescale FireEngine 5485 EVB\n");
231aee1111STsiChungLiew 	return 0;
241aee1111STsiChungLiew };
251aee1111STsiChungLiew 
dram_init(void)26*f1683aa7SSimon Glass int dram_init(void)
271aee1111STsiChungLiew {
28a4110eecSAlison Wang 	siu_t *siu = (siu_t *) (MMAP_SIU);
29a4110eecSAlison Wang 	sdram_t *sdram = (sdram_t *)(MMAP_SDRAM);
301aee1111STsiChungLiew 	u32 dramsize, i;
31606667d2Sstany MARCEL #ifdef CONFIG_SYS_DRAMSZ1
32606667d2Sstany MARCEL 	u32 temp;
33606667d2Sstany MARCEL #endif
341aee1111STsiChungLiew 
35a4110eecSAlison Wang 	out_be32(&siu->drv, CONFIG_SYS_SDRAM_DRVSTRENGTH);
361aee1111STsiChungLiew 
376d0f6bcfSJean-Christophe PLAGNIOL-VILLARD 	dramsize = CONFIG_SYS_DRAMSZ * 0x100000;
381aee1111STsiChungLiew 	for (i = 0x13; i < 0x20; i++) {
391aee1111STsiChungLiew 		if (dramsize == (1 << i))
401aee1111STsiChungLiew 			break;
411aee1111STsiChungLiew 	}
421aee1111STsiChungLiew 	i--;
43a4110eecSAlison Wang 	out_be32(&siu->cs0cfg, CONFIG_SYS_SDRAM_BASE | i);
441aee1111STsiChungLiew 
456d0f6bcfSJean-Christophe PLAGNIOL-VILLARD #ifdef CONFIG_SYS_DRAMSZ1
466d0f6bcfSJean-Christophe PLAGNIOL-VILLARD 	temp = CONFIG_SYS_DRAMSZ1 * 0x100000;
471aee1111STsiChungLiew 	for (i = 0x13; i < 0x20; i++) {
481aee1111STsiChungLiew 		if (temp == (1 << i))
491aee1111STsiChungLiew 			break;
501aee1111STsiChungLiew 	}
511aee1111STsiChungLiew 	i--;
521aee1111STsiChungLiew 	dramsize += temp;
53a4110eecSAlison Wang 	out_be32(&siu->cs1cfg, (CONFIG_SYS_SDRAM_BASE + temp) | i);
541aee1111STsiChungLiew #endif
551aee1111STsiChungLiew 
56a4110eecSAlison Wang 	out_be32(&sdram->cfg1, CONFIG_SYS_SDRAM_CFG1);
57a4110eecSAlison Wang 	out_be32(&sdram->cfg2, CONFIG_SYS_SDRAM_CFG2);
581aee1111STsiChungLiew 
591aee1111STsiChungLiew 	/* Issue PALL */
60a4110eecSAlison Wang 	out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 2);
611aee1111STsiChungLiew 
621aee1111STsiChungLiew 	/* Issue LEMR */
63a4110eecSAlison Wang 	out_be32(&sdram->mode, CONFIG_SYS_SDRAM_EMOD);
64a4110eecSAlison Wang 	out_be32(&sdram->mode, CONFIG_SYS_SDRAM_MODE | 0x04000000);
651aee1111STsiChungLiew 
661aee1111STsiChungLiew 	udelay(500);
671aee1111STsiChungLiew 
681aee1111STsiChungLiew 	/* Issue PALL */
69a4110eecSAlison Wang 	out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 2);
701aee1111STsiChungLiew 
711aee1111STsiChungLiew 	/* Perform two refresh cycles */
72a4110eecSAlison Wang 	out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 4);
73a4110eecSAlison Wang 	out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 4);
741aee1111STsiChungLiew 
75a4110eecSAlison Wang 	out_be32(&sdram->mode, CONFIG_SYS_SDRAM_MODE);
761aee1111STsiChungLiew 
77a4110eecSAlison Wang 	out_be32(&sdram->ctrl,
78a4110eecSAlison Wang 		(CONFIG_SYS_SDRAM_CTRL & ~0x80000000) | 0x10000F00);
791aee1111STsiChungLiew 
801aee1111STsiChungLiew 	udelay(100);
811aee1111STsiChungLiew 
82088454cdSSimon Glass 	gd->ram_size = dramsize;
83088454cdSSimon Glass 
84088454cdSSimon Glass 	return 0;
851aee1111STsiChungLiew };
861aee1111STsiChungLiew 
testdram(void)871aee1111STsiChungLiew int testdram(void)
881aee1111STsiChungLiew {
891aee1111STsiChungLiew 	/* TODO: XXX XXX XXX */
901aee1111STsiChungLiew 	printf("DRAM test not implemented!\n");
911aee1111STsiChungLiew 
921aee1111STsiChungLiew 	return (0);
931aee1111STsiChungLiew }
941aee1111STsiChungLiew 
951aee1111STsiChungLiew #if defined(CONFIG_PCI)
961aee1111STsiChungLiew /*
971aee1111STsiChungLiew  * Initialize PCI devices, report devices found.
981aee1111STsiChungLiew  */
991aee1111STsiChungLiew static struct pci_controller hose;
1001aee1111STsiChungLiew extern void pci_mcf547x_8x_init(struct pci_controller *hose);
1011aee1111STsiChungLiew 
pci_init_board(void)1021aee1111STsiChungLiew void pci_init_board(void)
1031aee1111STsiChungLiew {
1041aee1111STsiChungLiew 	pci_mcf547x_8x_init(&hose);
1051aee1111STsiChungLiew }
1061aee1111STsiChungLiew #endif				/* CONFIG_PCI */
107