blob: 34bdc053fc9498a30d623cf0dcf34448ea1cf988 [file] [log] [blame]
wdenkfe8c2802002-11-03 00:38:21 +00001/*
2 * (C) Copyright 2001
3 * Stefan Roese, esd gmbh germany, stefan.roese@esd-electronics.com
4 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
wdenkfe8c2802002-11-03 00:38:21 +00006 */
7
8#include <common.h>
Stefan Roeseb36df562010-09-09 19:18:00 +02009#include <asm/ppc4xx.h>
wdenkfe8c2802002-11-03 00:38:21 +000010#include <asm/processor.h>
11
12/*
13 * include common flash code (for esd boards)
14 */
15#include "../common/flash.c"
16
17/*-----------------------------------------------------------------------
18 * Functions
19 */
20static ulong flash_get_size (vu_long *addr, flash_info_t *info);
21static void flash_get_offsets (ulong base, flash_info_t *info);
22
23/*-----------------------------------------------------------------------
24 */
25
26unsigned long flash_init (void)
27{
28 unsigned long size_b0;
29 int i;
wdenk8bde7f72003-06-27 21:31:46 +000030 uint pbcr;
31 unsigned long base_b0;
wdenkfe8c2802002-11-03 00:38:21 +000032
33 /* Init: no FLASHes known */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020034 for (i=0; i<CONFIG_SYS_MAX_FLASH_BANKS; ++i) {
wdenkfe8c2802002-11-03 00:38:21 +000035 flash_info[i].flash_id = FLASH_UNKNOWN;
36 }
37
38 /* Static FLASH Bank configuration here - FIXME XXX */
39
40 size_b0 = flash_get_size((vu_long *)FLASH_BASE0_PRELIM, &flash_info[0]);
41
42 if (flash_info[0].flash_id == FLASH_UNKNOWN) {
43 printf ("## Unknown FLASH on Bank 0 - Size = 0x%08lx = %ld MB\n",
44 size_b0, size_b0<<20);
45 }
46
wdenk8bde7f72003-06-27 21:31:46 +000047 /* Setup offsets */
48 flash_get_offsets (-size_b0, &flash_info[0]);
wdenkfe8c2802002-11-03 00:38:21 +000049
wdenk8bde7f72003-06-27 21:31:46 +000050 /* Re-do sizing to get full correct info */
Stefan Roesed1c3b272009-09-09 16:25:29 +020051 mtdcr(EBC0_CFGADDR, PB0CR);
52 pbcr = mfdcr(EBC0_CFGDATA);
53 mtdcr(EBC0_CFGADDR, PB0CR);
wdenk8bde7f72003-06-27 21:31:46 +000054 base_b0 = -size_b0;
55 pbcr = (pbcr & 0x0001ffff) | base_b0 | (((size_b0/1024/1024)-1)<<17);
Stefan Roesed1c3b272009-09-09 16:25:29 +020056 mtdcr(EBC0_CFGDATA, pbcr);
57 /* printf("PB1CR = %x\n", pbcr); */
wdenkfe8c2802002-11-03 00:38:21 +000058
wdenk8bde7f72003-06-27 21:31:46 +000059 /* Monitor protection ON by default */
60 (void)flash_protect(FLAG_PROTECT_SET,
61 -monitor_flash_len,
62 0xffffffff,
63 &flash_info[0]);
wdenkfe8c2802002-11-03 00:38:21 +000064
wdenk8bde7f72003-06-27 21:31:46 +000065 flash_info[0].size = size_b0;
wdenkfe8c2802002-11-03 00:38:21 +000066
67 return (size_b0);
68}