]> git.ipfire.org Git - people/ms/u-boot.git/blame - board/prodrive/pdnb3/flash.c
Add GPL-2.0+ SPDX-License-Identifier to source files
[people/ms/u-boot.git] / board / prodrive / pdnb3 / flash.c
CommitLineData
ba94a1bb
WD
1/*
2 * (C) Copyright 2006
3 * Stefan Roese, DENX Software Engineering, sr@denx.de.
4 *
1a459660 5 * SPDX-License-Identifier: GPL-2.0+
ba94a1bb
WD
6 */
7
8#include <common.h>
9#include <asm/arch/ixp425.h>
10
00b1883a 11#if !defined(CONFIG_FLASH_CFI_DRIVER)
9d8d5a5b 12
ba94a1bb
WD
13/*
14 * include common flash code (for esd boards)
15 */
16#include "../common/flash.c"
17
18/*
19 * Prototypes
20 */
21static ulong flash_get_size (vu_long * addr, flash_info_t * info);
22
23static inline ulong ld(ulong x)
24{
25 ulong k = 0;
26
27 while (x >>= 1)
28 ++k;
29
30 return k;
31}
32
33unsigned long flash_init(void)
34{
35 unsigned long size;
36 int i;
37
38 /* Init: no FLASHes known */
6d0f6bcf 39 for (i=0; i<CONFIG_SYS_MAX_FLASH_BANKS; i++)
ba94a1bb
WD
40 flash_info[i].flash_id = FLASH_UNKNOWN;
41
42 size = flash_get_size((vu_long *)FLASH_BASE0_PRELIM, &flash_info[0]);
43
44 if (flash_info[0].flash_id == FLASH_UNKNOWN)
45 printf ("## Unknown FLASH on Bank 0 - Size = 0x%08lx = %ld MB\n",
46 size, size<<20);
47
48 /* Reconfigure CS0 to actual FLASH size */
49 *IXP425_EXP_CS0 = (*IXP425_EXP_CS0 & ~0x00003C00) | ((ld(size) - 9) << 10);
50
51 /* Monitor protection ON by default */
52 flash_protect(FLAG_PROTECT_SET,
6d0f6bcf
JCPV
53 CONFIG_SYS_MONITOR_BASE, CONFIG_SYS_MONITOR_BASE + monitor_flash_len - 1,
54 &flash_info[CONFIG_SYS_MAX_FLASH_BANKS - 1]);
ba94a1bb
WD
55
56 /* Environment protection ON by default */
57 flash_protect(FLAG_PROTECT_SET,
0e8d1586
JCPV
58 CONFIG_ENV_ADDR,
59 CONFIG_ENV_ADDR + CONFIG_ENV_SECT_SIZE - 1,
6d0f6bcf 60 &flash_info[CONFIG_SYS_MAX_FLASH_BANKS - 1]);
ba94a1bb
WD
61
62 /* Redundant environment protection ON by default */
63 flash_protect(FLAG_PROTECT_SET,
0e8d1586 64 CONFIG_ENV_ADDR_REDUND,
dfcd7f21 65 CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SECT_SIZE - 1,
6d0f6bcf 66 &flash_info[CONFIG_SYS_MAX_FLASH_BANKS - 1]);
ba94a1bb
WD
67
68 flash_info[0].size = size;
69
70 return size;
71}
9d8d5a5b 72
00b1883a 73#endif /* CONFIG_FLASH_CFI_DRIVER */