]> git.ipfire.org Git - thirdparty/u-boot.git/blame - board/esd/adciop/flash.c
Add GPL-2.0+ SPDX-License-Identifier to source files
[thirdparty/u-boot.git] / board / esd / adciop / flash.c
CommitLineData
affae2bf
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+
affae2bf
WD
6 */
7
8#include <common.h>
b36df561 9#include <asm/ppc4xx.h>
affae2bf
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, size_b1;
29 int i;
30
31 /* Init: no FLASHes known */
6d0f6bcf 32 for (i=0; i<CONFIG_SYS_MAX_FLASH_BANKS; ++i) {
affae2bf
WD
33 flash_info[i].flash_id = FLASH_UNKNOWN;
34 }
35
36 size_b0 = flash_get_size((vu_long *)FLASH_BASE0_PRELIM, &flash_info[0]);
37
38 if (flash_info[0].flash_id == FLASH_UNKNOWN) {
39 printf ("## Unknown FLASH on Bank 0 - Size = 0x%08lx = %ld MB\n",
40 size_b0, size_b0<<20);
41 }
42
43 size_b1 = flash_get_size((vu_long *)FLASH_BASE1_PRELIM, &flash_info[1]);
44
45 if (size_b1 > size_b0) {
46 printf ("## ERROR: "
47 "Bank 1 (0x%08lx = %ld MB) > Bank 0 (0x%08lx = %ld MB)\n",
48 size_b1, size_b1<<20,
49 size_b0, size_b0<<20
50 );
51 flash_info[0].flash_id = FLASH_UNKNOWN;
52 flash_info[1].flash_id = FLASH_UNKNOWN;
53 flash_info[0].sector_count = -1;
54 flash_info[1].sector_count = -1;
55 flash_info[0].size = 0;
56 flash_info[1].size = 0;
57 return (0);
58 }
59
60 /* Re-do sizing to get full correct info */
61 size_b0 = flash_get_size((vu_long *)FLASH_BASE0_PRELIM, &flash_info[0]);
62
63 flash_get_offsets (FLASH_BASE0_PRELIM, &flash_info[0]);
64
65 /* monitor protection ON by default */
66 flash_protect(FLAG_PROTECT_SET,
3b57fe0a 67 FLASH_BASE0_PRELIM+size_b0-monitor_flash_len,
affae2bf
WD
68 FLASH_BASE0_PRELIM+size_b0-1,
69 &flash_info[0]);
70
71 if (size_b1) {
72 /* Re-do sizing to get full correct info */
73 size_b1 = flash_get_size((vu_long *)(FLASH_BASE0_PRELIM + size_b0),
74 &flash_info[1]);
75
76 flash_get_offsets (FLASH_BASE0_PRELIM + size_b0, &flash_info[1]);
77
78 /* monitor protection ON by default */
79 flash_protect(FLAG_PROTECT_SET,
3b57fe0a 80 FLASH_BASE0_PRELIM+size_b0+size_b1-monitor_flash_len,
affae2bf
WD
81 FLASH_BASE0_PRELIM+size_b0+size_b1-1,
82 &flash_info[1]);
8bde7f77
WD
83 /* monitor protection OFF by default (one is enough) */
84 flash_protect(FLAG_PROTECT_CLEAR,
3b57fe0a 85 FLASH_BASE0_PRELIM+size_b0-monitor_flash_len,
affae2bf
WD
86 FLASH_BASE0_PRELIM+size_b0-1,
87 &flash_info[0]);
88 } else {
89 flash_info[1].flash_id = FLASH_UNKNOWN;
90 flash_info[1].sector_count = -1;
91 }
92
93 flash_info[0].size = size_b0;
94 flash_info[1].size = size_b1;
95
96 return (size_b0 + size_b1);
97}