blob: 05691d0b86b46d1c097a4e656e170df8de47d275 [file] [log] [blame]
wdenkaffae2b2002-08-17 09:36:01 +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+
wdenkaffae2b2002-08-17 09:36:01 +00006 */
7
8#include <common.h>
Stefan Roeseb36df562010-09-09 19:18:00 +02009#include <asm/ppc4xx.h>
wdenkaffae2b2002-08-17 09:36:01 +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 */
26
27unsigned long flash_init (void)
28{
29 unsigned long size_b0;
wdenk8bde7f72003-06-27 21:31:46 +000030 int i;
wdenkaffae2b2002-08-17 09:36:01 +000031
32 /* Init: no FLASHes known */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020033 for (i=0; i<CONFIG_SYS_MAX_FLASH_BANKS; ++i) {
wdenkaffae2b2002-08-17 09:36:01 +000034 flash_info[i].flash_id = FLASH_UNKNOWN;
35 }
36
37 /* Static FLASH Bank configuration here - FIXME XXX */
38
39 size_b0 = flash_get_size((vu_long *)FLASH_BASE0_PRELIM, &flash_info[0]);
40
41 if (flash_info[0].flash_id == FLASH_UNKNOWN) {
42 printf ("## Unknown FLASH on Bank 0 - Size = 0x%08lx = %ld MB\n",
43 size_b0, size_b0<<20);
44 }
45
wdenk8bde7f72003-06-27 21:31:46 +000046 /* Setup offsets */
47 flash_get_offsets (-size_b0, &flash_info[0]);
wdenkaffae2b2002-08-17 09:36:01 +000048
wdenk8bde7f72003-06-27 21:31:46 +000049 /* Monitor protection ON by default */
50 (void)flash_protect(FLAG_PROTECT_SET,
51 -monitor_flash_len,
52 0xffffffff,
53 &flash_info[0]);
wdenkaffae2b2002-08-17 09:36:01 +000054
wdenk8bde7f72003-06-27 21:31:46 +000055 flash_info[0].size = size_b0;
wdenkaffae2b2002-08-17 09:36:01 +000056
57 return (size_b0);
58}