1 /* SPDX-License-Identifier: GPL-2.0+ */ 2 /* 3 * (C) Copyright 2019 Rockchip Electronics Co., Ltd 4 */ 5 6 #ifndef _BIDRAM_H 7 #define _BIDRAM_H 8 9 #include <memblk.h> 10 11 typedef struct memblock *(*parse_fn_t)(int *); 12 13 struct bidram { 14 struct lmb lmb; 15 struct list_head reserved_head; 16 bool has_init; 17 }; 18 19 /** 20 * bidram_initr() - Initial bidram after relocation. 21 * 22 * @return 0 on success, otherwise error 23 */ 24 int bidram_initr(void); 25 26 /** 27 * bidram_get_ram_size() - Initial bidram and get ram size. 28 * 29 * @parse_fn: function to parse ddr memory regions 30 * 31 * @return ram size, 0 on success, otherwise the effect ram size. 32 */ 33 phys_size_t bidram_get_ram_size(void); 34 35 /** 36 * bidram_gen_gd_bi_dram() - Update gd->bd->bi_dram[] according to bidram state. 37 */ 38 void bidram_gen_gd_bi_dram(void); 39 40 /** 41 * bidram_reserve() - Reserve bidram region 42 * 43 * @id: memblk id 44 * @base: region base address 45 * @size: region size 46 * 47 * @return 0 on success, otherwise error 48 */ 49 int bidram_reserve(enum memblk_id id, phys_addr_t base, phys_size_t size); 50 51 /** 52 * bidram_reserve_by_name() - Reserve bidram region by name 53 * 54 * @name: region name 55 * @base: region base address 56 * @size: region size 57 * 58 * @return 0 on success, otherwise error 59 */ 60 int bidram_reserve_by_name(const char *name, phys_addr_t base, phys_size_t size); 61 62 /** 63 * bidram_dump_all() - Dump all bidram stat 64 */ 65 void bidram_dump(void); 66 67 /** 68 * board_bidram_parse_fn() - Weak function for board to implement 69 */ 70 parse_fn_t board_bidram_parse_fn(void); 71 72 /** 73 * board_bidram_reserve() - Weak function for board to implement 74 * 75 * @bidram: global bidram point, ignored 76 * 77 * @return 0 on success, otherwise error 78 */ 79 int board_bidram_reserve(struct bidram *bidram); 80 81 #endif /* _BIDRAM_H */ 82