blob: 713888114f06637f558566e2361530c2c7738404 [file] [log] [blame]
stroese8d8f8942004-12-16 18:24:06 +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+
stroese8d8f8942004-12-16 18:24:06 +00006 */
7
8#include <common.h>
Stefan Roeseb36df562010-09-09 19:18:00 +02009/*#include <asm/ppc4xx.h>*/
stroese8d8f8942004-12-16 18:24:06 +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;
30
31 /* Init: no FLASHes known */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020032 for (i=0; i<CONFIG_SYS_MAX_FLASH_BANKS; ++i) {
stroese8d8f8942004-12-16 18:24:06 +000033 flash_info[i].flash_id = FLASH_UNKNOWN;
34 }
35
36 /* Static FLASH Bank configuration here - FIXME XXX */
37
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020038 size_b0 = flash_get_size((vu_long *)CONFIG_SYS_FLASH_BASE, &flash_info[0]);
stroese8d8f8942004-12-16 18:24:06 +000039
40 if (flash_info[0].flash_id == FLASH_UNKNOWN) {
41 printf ("## Unknown FLASH on Bank 0 - Size = 0x%08lx = %ld MB\n",
42 size_b0, size_b0<<20);
43 }
44
45 /* Setup offsets */
46 flash_get_offsets (-size_b0, &flash_info[0]);
47
48 /* test-only: todo: Re-do sizing to get full correct info */
49
50 /* Monitor protection ON by default */
51 (void)flash_protect(FLAG_PROTECT_SET,
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020052 CONFIG_SYS_FLASH_BASE,
53 CONFIG_SYS_FLASH_BASE+CONFIG_SYS_MONITOR_LEN-1,
stroese8d8f8942004-12-16 18:24:06 +000054 &flash_info[0]);
55
56 flash_info[0].size = size_b0;
57
58 return (size_b0);
59}