blob: 89c1abd23361e8d72252959ea0a9718b458813c5 [file] [log] [blame]
wdenk983fda82004-10-28 00:09:35 +00001/*
2 * (C) Copyright 2004, Freescale Inc.
3 * TsiChung Liew, Tsi-Chung.Liew@freescale.com
4 *
5 * See file CREDITS for list of people who contributed to this
6 * project.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA
22 */
23
24#include <common.h>
25#include <mpc8220.h>
26#include <asm/processor.h>
27#include <asm/mmu.h>
28
29void setupBat (ulong size)
30{
31 ulong batu, batl;
32 int blocksize = 0;
33
34 /* Flash 0 */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020035#if defined (CONFIG_SYS_AMD_BOOT)
Becky Bruced35ae5a2009-02-03 18:10:51 -060036 batu = CONFIG_SYS_FLASH0_BASE | BATU_BL_512K | BPP_RW | BPP_RX;
wdenk983fda82004-10-28 00:09:35 +000037#else
Becky Bruced35ae5a2009-02-03 18:10:51 -060038 batu = CONFIG_SYS_FLASH0_BASE | BATU_BL_16M | BPP_RW | BPP_RX;
wdenk983fda82004-10-28 00:09:35 +000039#endif
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020040 batl = CONFIG_SYS_FLASH0_BASE | 0x22;
wdenk983fda82004-10-28 00:09:35 +000041 write_bat (IBAT0, batu, batl);
42 write_bat (DBAT0, batu, batl);
43
44 /* Flash 1 */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020045#if defined (CONFIG_SYS_AMD_BOOT)
Becky Bruced35ae5a2009-02-03 18:10:51 -060046 batu = CONFIG_SYS_FLASH1_BASE | BATU_BL_16M | BPP_RW | BPP_RX;
wdenk983fda82004-10-28 00:09:35 +000047#else
Becky Bruced35ae5a2009-02-03 18:10:51 -060048 batu = CONFIG_SYS_FLASH1_BASE | BATU_BL_512K | BPP_RW | BPP_RX;
wdenk983fda82004-10-28 00:09:35 +000049#endif
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020050 batl = CONFIG_SYS_FLASH1_BASE | 0x22;
wdenk983fda82004-10-28 00:09:35 +000051 write_bat (IBAT1, batu, batl);
52 write_bat (DBAT1, batu, batl);
53
54 /* CPLD */
Becky Bruced35ae5a2009-02-03 18:10:51 -060055 batu = CONFIG_SYS_CPLD_BASE | BATU_BL_512K | BPP_RW | BPP_RX;
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020056 batl = CONFIG_SYS_CPLD_BASE | 0x22;
wdenk983fda82004-10-28 00:09:35 +000057 write_bat (IBAT2, 0, 0);
58 write_bat (DBAT2, batu, batl);
59
60 /* FPGA */
Becky Bruced35ae5a2009-02-03 18:10:51 -060061 batu = CONFIG_SYS_FPGA_BASE | BATU_BL_512K | BPP_RW | BPP_RX;
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020062 batl = CONFIG_SYS_FPGA_BASE | 0x22;
wdenk983fda82004-10-28 00:09:35 +000063 write_bat (IBAT3, 0, 0);
64 write_bat (DBAT3, batu, batl);
65
66 /* MBAR - Data only */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020067 batu = CONFIG_SYS_MBAR | BPP_RW | BPP_RX;
68 batl = CONFIG_SYS_MBAR | 0x22;
wdenk983fda82004-10-28 00:09:35 +000069 mtspr (IBAT4L, 0);
70 mtspr (IBAT4U, 0);
71 mtspr (DBAT4L, batl);
72 mtspr (DBAT4U, batu);
73
74 /* MBAR - SRAM */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020075 batu = CONFIG_SYS_SRAM_BASE | BPP_RW | BPP_RX;
76 batl = CONFIG_SYS_SRAM_BASE | 0x42;
wdenk983fda82004-10-28 00:09:35 +000077 mtspr (IBAT5L, batl);
78 mtspr (IBAT5U, batu);
79 mtspr (DBAT5L, batl);
80 mtspr (DBAT5U, batu);
81
82 if (size <= 0x800000) /* 8MB */
Becky Bruced35ae5a2009-02-03 18:10:51 -060083 blocksize = BATU_BL_8M;
wdenk983fda82004-10-28 00:09:35 +000084 else if (size <= 0x1000000) /* 16MB */
Becky Bruced35ae5a2009-02-03 18:10:51 -060085 blocksize = BATU_BL_16M;
wdenk983fda82004-10-28 00:09:35 +000086 else if (size <= 0x2000000) /* 32MB */
Becky Bruced35ae5a2009-02-03 18:10:51 -060087 blocksize = BATU_BL_32M;
wdenk983fda82004-10-28 00:09:35 +000088 else if (size <= 0x4000000) /* 64MB */
Becky Bruced35ae5a2009-02-03 18:10:51 -060089 blocksize = BATU_BL_64M;
wdenk983fda82004-10-28 00:09:35 +000090 else if (size <= 0x8000000) /* 128MB */
Becky Bruced35ae5a2009-02-03 18:10:51 -060091 blocksize = BATU_BL_128M;
wdenk983fda82004-10-28 00:09:35 +000092 else if (size <= 0x10000000) /* 256MB */
Becky Bruced35ae5a2009-02-03 18:10:51 -060093 blocksize = BATU_BL_256M;
wdenk983fda82004-10-28 00:09:35 +000094
95 /* Memory */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020096 batu = CONFIG_SYS_SDRAM_BASE | blocksize | BPP_RW | BPP_RX;
97 batl = CONFIG_SYS_SDRAM_BASE | 0x42;
wdenk983fda82004-10-28 00:09:35 +000098 mtspr (IBAT6L, batl);
99 mtspr (IBAT6U, batu);
100 mtspr (DBAT6L, batl);
101 mtspr (DBAT6U, batu);
102
103 /* memory size is less than 256MB */
104 if (size <= 0x10000000) {
105 /* Nothing */
106 batu = 0;
107 batl = 0;
108 } else {
109 size -= 0x10000000;
110 if (size <= 0x800000) /* 8MB */
Becky Bruced35ae5a2009-02-03 18:10:51 -0600111 blocksize = BATU_BL_8M;
wdenk983fda82004-10-28 00:09:35 +0000112 else if (size <= 0x1000000) /* 16MB */
Becky Bruced35ae5a2009-02-03 18:10:51 -0600113 blocksize = BATU_BL_16M;
wdenk983fda82004-10-28 00:09:35 +0000114 else if (size <= 0x2000000) /* 32MB */
Becky Bruced35ae5a2009-02-03 18:10:51 -0600115 blocksize = BATU_BL_32M;
wdenk983fda82004-10-28 00:09:35 +0000116 else if (size <= 0x4000000) /* 64MB */
Becky Bruced35ae5a2009-02-03 18:10:51 -0600117 blocksize = BATU_BL_64M;
wdenk983fda82004-10-28 00:09:35 +0000118 else if (size <= 0x8000000) /* 128MB */
Becky Bruced35ae5a2009-02-03 18:10:51 -0600119 blocksize = BATU_BL_128M;
wdenk983fda82004-10-28 00:09:35 +0000120 else if (size <= 0x10000000) /* 256MB */
Becky Bruced35ae5a2009-02-03 18:10:51 -0600121 blocksize = BATU_BL_256M;
wdenk983fda82004-10-28 00:09:35 +0000122
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200123 batu = (CONFIG_SYS_SDRAM_BASE +
wdenk983fda82004-10-28 00:09:35 +0000124 0x10000000) | blocksize | BPP_RW | BPP_RX;
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200125 batl = (CONFIG_SYS_SDRAM_BASE + 0x10000000) | 0x42;
wdenk983fda82004-10-28 00:09:35 +0000126 }
127
128 mtspr (IBAT7L, batl);
129 mtspr (IBAT7U, batu);
130 mtspr (DBAT7L, batl);
131 mtspr (DBAT7U, batu);
132}
133
Becky Bruce9973e3c2008-06-09 16:03:40 -0500134phys_size_t initdram (int board_type)
wdenk983fda82004-10-28 00:09:35 +0000135{
136 ulong size;
137
138 size = dramSetup ();
139
140/* if iCache ad dCache is defined */
Jon Loeligerfcec2eb2007-07-09 18:19:09 -0500141#if defined(CONFIG_CMD_CACHE)
wdenk983fda82004-10-28 00:09:35 +0000142/* setupBat(size);*/
143#endif
144
145 return size;
146}
147
148int checkboard (void)
149{
150 puts ("Board: Alaska MPC8220 Evaluation Board\n");
151
152 return 0;
153}