]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - arch/powerpc/cpu/mpc8xx/commproc.c
Add GPL-2.0+ SPDX-License-Identifier to source files
[karo-tx-uboot.git] / arch / powerpc / cpu / mpc8xx / commproc.c
1 /*
2  * (C) Copyright 2000-2002
3  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4  *
5  * SPDX-License-Identifier:     GPL-2.0+
6  */
7
8 #include <common.h>
9 #include <commproc.h>
10
11 DECLARE_GLOBAL_DATA_PTR;
12
13 #ifdef CONFIG_SYS_ALLOC_DPRAM
14
15 int dpram_init (void)
16 {
17         /* Reclaim the DP memory for our use. */
18         gd->arch.dp_alloc_base = CPM_DATAONLY_BASE;
19         gd->arch.dp_alloc_top  = CPM_DATAONLY_BASE + CPM_DATAONLY_SIZE;
20
21         return (0);
22 }
23
24 /* Allocate some memory from the dual ported ram.  We may want to
25  * enforce alignment restrictions, but right now everyone is a good
26  * citizen.
27  */
28 uint dpram_alloc (uint size)
29 {
30         uint addr = gd->arch.dp_alloc_base;
31
32         if ((gd->arch.dp_alloc_base + size) >= gd->arch.dp_alloc_top)
33                 return (CPM_DP_NOSPACE);
34
35         gd->arch.dp_alloc_base += size;
36
37         return addr;
38 }
39
40 uint dpram_base (void)
41 {
42         return gd->arch.dp_alloc_base;
43 }
44
45 /* Allocate some memory from the dual ported ram.  We may want to
46  * enforce alignment restrictions, but right now everyone is a good
47  * citizen.
48  */
49 uint dpram_alloc_align (uint size, uint align)
50 {
51         uint addr, mask = align - 1;
52
53         addr = (gd->arch.dp_alloc_base + mask) & ~mask;
54
55         if ((addr + size) >= gd->arch.dp_alloc_top)
56                 return (CPM_DP_NOSPACE);
57
58         gd->arch.dp_alloc_base = addr + size;
59
60         return addr;
61 }
62
63 uint dpram_base_align (uint align)
64 {
65         uint mask = align - 1;
66
67         return (gd->arch.dp_alloc_base + mask) & ~mask;
68 }
69 #endif  /* CONFIG_SYS_ALLOC_DPRAM */