]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - board/prodrive/pdnb3/flash.c
Merge branch 'u-boot/master' into u-boot-arm/master
[karo-tx-uboot.git] / board / prodrive / pdnb3 / flash.c
1 /*
2  * (C) Copyright 2006
3  * Stefan Roese, DENX Software Engineering, sr@denx.de.
4  *
5  * SPDX-License-Identifier:     GPL-2.0+
6  */
7
8 #include <common.h>
9 #include <asm/arch/ixp425.h>
10
11 #if !defined(CONFIG_FLASH_CFI_DRIVER)
12
13 /*
14  * include common flash code (for esd boards)
15  */
16 #include "../common/flash.c"
17
18 /*
19  * Prototypes
20  */
21 static ulong flash_get_size (vu_long * addr, flash_info_t * info);
22
23 static inline ulong ld(ulong x)
24 {
25         ulong k = 0;
26
27         while (x >>= 1)
28                 ++k;
29
30         return k;
31 }
32
33 unsigned long flash_init(void)
34 {
35         unsigned long size;
36         int i;
37
38         /* Init: no FLASHes known */
39         for (i=0; i<CONFIG_SYS_MAX_FLASH_BANKS; i++)
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,
53                       CONFIG_SYS_MONITOR_BASE, CONFIG_SYS_MONITOR_BASE + monitor_flash_len - 1,
54                       &flash_info[CONFIG_SYS_MAX_FLASH_BANKS - 1]);
55
56         /* Environment protection ON by default */
57         flash_protect(FLAG_PROTECT_SET,
58                       CONFIG_ENV_ADDR,
59                       CONFIG_ENV_ADDR + CONFIG_ENV_SECT_SIZE - 1,
60                       &flash_info[CONFIG_SYS_MAX_FLASH_BANKS - 1]);
61
62         /* Redundant environment protection ON by default */
63         flash_protect(FLAG_PROTECT_SET,
64                       CONFIG_ENV_ADDR_REDUND,
65                       CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SECT_SIZE - 1,
66                       &flash_info[CONFIG_SYS_MAX_FLASH_BANKS - 1]);
67
68         flash_info[0].size = size;
69
70         return size;
71 }
72
73 #endif /* CONFIG_FLASH_CFI_DRIVER */