]> git.ipfire.org Git - people/ms/u-boot.git/blame - board/esd/cpciiser4/flash.c
Add GPL-2.0+ SPDX-License-Identifier to source files
[people/ms/u-boot.git] / board / esd / cpciiser4 / flash.c
CommitLineData
fe8c2806
WD
1/*
2 * (C) Copyright 2001
3 * Stefan Roese, esd gmbh germany, stefan.roese@esd-electronics.com
4 *
1a459660 5 * SPDX-License-Identifier: GPL-2.0+
fe8c2806
WD
6 */
7
8#include <common.h>
b36df561 9#include <asm/ppc4xx.h>
fe8c2806
WD
10#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;
8bde7f77
WD
30 uint pbcr;
31 unsigned long base_b0;
fe8c2806
WD
32
33 /* Init: no FLASHes known */
6d0f6bcf 34 for (i=0; i<CONFIG_SYS_MAX_FLASH_BANKS; ++i) {
fe8c2806
WD
35 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
8bde7f77
WD
47 /* Setup offsets */
48 flash_get_offsets (-size_b0, &flash_info[0]);
fe8c2806 49
8bde7f77 50 /* Re-do sizing to get full correct info */
d1c3b275
SR
51 mtdcr(EBC0_CFGADDR, PB0CR);
52 pbcr = mfdcr(EBC0_CFGDATA);
53 mtdcr(EBC0_CFGADDR, PB0CR);
8bde7f77
WD
54 base_b0 = -size_b0;
55 pbcr = (pbcr & 0x0001ffff) | base_b0 | (((size_b0/1024/1024)-1)<<17);
d1c3b275
SR
56 mtdcr(EBC0_CFGDATA, pbcr);
57 /* printf("PB1CR = %x\n", pbcr); */
fe8c2806 58
8bde7f77
WD
59 /* Monitor protection ON by default */
60 (void)flash_protect(FLAG_PROTECT_SET,
61 -monitor_flash_len,
62 0xffffffff,
63 &flash_info[0]);
fe8c2806 64
8bde7f77 65 flash_info[0].size = size_b0;
fe8c2806
WD
66
67 return (size_b0);
68}