1 /* 2 * dump registers head file 3 * 4 * (C) Copyright 2015-2018 5 * Reuuimlla Technology Co., Ltd. <www.reuuimllatech.com> 6 * Liugang <liugang@reuuimllatech.com> 7 * Xiafeng <xiafeng@allwinnertech.com> 8 * Martin <wuyan@allwinnertech.com> 9 * 10 * This program is free software; you can redistribute it and/or 11 * modify it under the terms of the GNU General Public License as 12 * published by the Free Software Foundation; either version 2 of 13 * the License, or (at your option) any later version. 14 * 15 */ 16 #ifndef _DUMP_REG_H_ 17 #define _DUMP_REG_H_ 18 19 /* BROM/SRAM/peripheral-registers space */ 20 #define SUNXI_IO_PHYS_START (0x00000000UL) 21 #define SUNXI_IO_PHYS_END (0x09020FFFUL) 22 23 /* DRAM space (Only map the first 1GB) */ 24 #define SUNXI_PLAT_PHYS_START (0x40000000UL) 25 #define SUNXI_PLAT_PHYS_END (SUNXI_PLAT_PHYS_START + SZ_1G - 1) 26 27 #if IS_ENABLED(CONFIG_ARM64) || IS_ENABLED(CONFIG_RISCV) 28 /* Virtual address space 1 */ 29 #define SUNXI_IOMEM_START (0xffffff8000000000UL) 30 #define SUNXI_IOMEM_END (SUNXI_IOMEM_START + SZ_2G - 1) 31 /* Virtual address space 2 */ 32 #define SUNXI_MEM_PHYS_START (0xffffffc000000000UL) 33 #define SUNXI_MEM_PHYS_END (SUNXI_MEM_PHYS_START + SZ_2G - 1) 34 /* Print format */ 35 #define PRINT_ADDR_FMT "0x%016lx" 36 #define CMP_PRINT_FMT "reg expect actual mask result\n" 37 #define WR_PRINT_FMT "reg to_write after_write\n" 38 #elif IS_ENABLED(CONFIG_ARM) 39 /* Virtual address space 2 */ 40 #define SUNXI_MEM_PHYS_START PAGE_OFFSET 41 #define SUNXI_MEM_PHYS_END (SUNXI_MEM_PHYS_START + SZ_1G - 1) 42 /* Print format */ 43 #define PRINT_ADDR_FMT "0x%08lx" 44 #define CMP_PRINT_FMT "reg expect actual mask result\n" 45 #define WR_PRINT_FMT "reg to_write after_write\n" 46 #endif 47 48 /* Item count */ 49 #define MAX_COMPARE_ITEM 64 50 #define MAX_WRITE_ITEM 64 51 52 struct dump_addr { 53 /* User specified address. Maybe physical or virtual address */ 54 unsigned long uaddr_start; 55 unsigned long uaddr_end; 56 /* Virtual address */ 57 void __iomem *vaddr_start; 58 }; 59 60 struct dump_struct { 61 unsigned long addr_start; 62 unsigned long addr_end; 63 /* some registers' operate method maybe different */ 64 void __iomem *(*remap)(unsigned long paddr, size_t size); 65 void (*unmap)(void __iomem *vaddr); 66 void __iomem *(*get_vaddr)(struct dump_addr *dump_addr, unsigned long uaddr); 67 u32 (*read)(void __iomem *vaddr); 68 void (*write)(u32 val, void __iomem *vaddr); 69 }; 70 71 /** 72 * compare_item - reg compare item struct 73 * @reg_addr: reg address. 74 * @val_expect: expected value, provided by caller. 75 * @val_mask: mask value, provided by caller. only mask bits will be compared. 76 */ 77 struct compare_item { 78 unsigned long reg_addr; 79 u32 val_expect; 80 u32 val_mask; 81 }; 82 83 /** 84 * compare_group - reg compare group struct 85 * @num: pitem element count. cannot exceed MAX_COMPARE_ITEM. 86 * @pitem: items that will be compared, provided by caller. 87 */ 88 struct compare_group { 89 u32 num; 90 u32 reserve; 91 struct compare_item *pitem; 92 }; 93 94 /** 95 * write_item - reg write item struct 96 * @reg_addr: reg address. 97 * @val: value to write 98 */ 99 struct write_item { 100 unsigned long reg_addr; 101 u32 val; 102 u32 reserve; 103 }; 104 105 /** 106 * write_group - reg write group struct 107 * @num: pitem element count. cannot exceed MAX_WRITE_ITEM. 108 * @pitem: items that will be write, provided by caller. 109 */ 110 struct write_group { 111 u32 num; 112 u32 reserve; 113 struct write_item *pitem; 114 }; 115 116 const struct dump_struct dump_table[4]; 117 #endif /* _DUMP_REG_H_ */ 118