]>
git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/blob - arch/powerpc/include/asm/drmem.h
2 * drmem.h: Power specific logical memory block representation
4 * Copyright 2017 IBM Corporation
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
12 #ifndef _ASM_POWERPC_LMB_H
13 #define _ASM_POWERPC_LMB_H
22 struct drmem_lmb_info
{
23 struct drmem_lmb
*lmbs
;
28 extern struct drmem_lmb_info
*drmem_info
;
30 #define for_each_drmem_lmb_in_range(lmb, start, end) \
31 for ((lmb) = (start); (lmb) <= (end); (lmb)++)
33 #define for_each_drmem_lmb(lmb) \
34 for_each_drmem_lmb_in_range((lmb), \
35 &drmem_info->lmbs[0], \
36 &drmem_info->lmbs[drmem_info->n_lmbs - 1])
39 * The of_drconf_cell_v1 struct defines the layout of the LMB data
40 * specified in the ibm,dynamic-memory device tree property.
41 * The property itself is a 32-bit value specifying the number of
42 * LMBs followed by an array of of_drconf_cell_v1 entries, one
45 struct of_drconf_cell_v1
{
54 * Version 2 of the ibm,dynamic-memory property is defined as a
55 * 32-bit value specifying the number of LMB sets followed by an
56 * array of of_drconf_cell_v2 entries, one per LMB set.
58 struct of_drconf_cell_v2
{
66 #define DRCONF_MEM_ASSIGNED 0x00000008
67 #define DRCONF_MEM_AI_INVALID 0x00000040
68 #define DRCONF_MEM_RESERVED 0x00000080
70 static inline u32
drmem_lmb_size(void)
72 return drmem_info
->lmb_size
;
75 #define DRMEM_LMB_RESERVED 0x80000000
77 static inline void drmem_mark_lmb_reserved(struct drmem_lmb
*lmb
)
79 lmb
->flags
|= DRMEM_LMB_RESERVED
;
82 static inline void drmem_remove_lmb_reservation(struct drmem_lmb
*lmb
)
84 lmb
->flags
&= ~DRMEM_LMB_RESERVED
;
87 static inline bool drmem_lmb_reserved(struct drmem_lmb
*lmb
)
89 return lmb
->flags
& DRMEM_LMB_RESERVED
;
92 u64
drmem_lmb_memory_max(void);
93 void __init
walk_drmem_lmbs(struct device_node
*dn
,
94 void (*func
)(struct drmem_lmb
*, const __be32
**));
95 int drmem_update_dt(void);
97 #ifdef CONFIG_PPC_PSERIES
98 void __init
walk_drmem_lmbs_early(unsigned long node
,
99 void (*func
)(struct drmem_lmb
*, const __be32
**));
102 static inline void invalidate_lmb_associativity_index(struct drmem_lmb
*lmb
)
104 lmb
->aa_index
= 0xffffffff;
107 #endif /* _ASM_POWERPC_LMB_H */