Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * apei-internal.h - ACPI Platform Error Interface internal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * definitions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #ifndef APEI_INTERNAL_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #define APEI_INTERNAL_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/cper.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/acpi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) struct apei_exec_context;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 				    struct acpi_whea_header *entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #define APEI_EXEC_INS_ACCESS_REGISTER	0x0001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) struct apei_exec_ins_type {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 	u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 	apei_exec_ins_func_t run;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) struct apei_exec_context {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	u32 ip;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	u64 value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	u64 var1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	u64 var2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	u64 src_base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	u64 dst_base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	struct apei_exec_ins_type *ins_table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	u32 instructions;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	struct acpi_whea_header *action_table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	u32 entries;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) void apei_exec_ctx_init(struct apei_exec_context *ctx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 			struct apei_exec_ins_type *ins_table,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 			u32 instructions,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 			struct acpi_whea_header *action_table,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 			u32 entries);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) static inline void apei_exec_ctx_set_input(struct apei_exec_context *ctx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 					   u64 input)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	ctx->value = input;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) static inline u64 apei_exec_ctx_get_output(struct apei_exec_context *ctx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	return ctx->value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) int __apei_exec_run(struct apei_exec_context *ctx, u8 action, bool optional);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) static inline int apei_exec_run(struct apei_exec_context *ctx, u8 action)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	return __apei_exec_run(ctx, action, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) /* It is optional whether the firmware provides the action */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) static inline int apei_exec_run_optional(struct apei_exec_context *ctx, u8 action)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	return __apei_exec_run(ctx, action, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) /* Common instruction implementation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) /* IP has been set in instruction function */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) #define APEI_EXEC_SET_IP	1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) int apei_map_generic_address(struct acpi_generic_address *reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) static inline void apei_unmap_generic_address(struct acpi_generic_address *reg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	acpi_os_unmap_generic_address(reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) int apei_read(u64 *val, struct acpi_generic_address *reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) int apei_write(u64 val, struct acpi_generic_address *reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) int __apei_exec_read_register(struct acpi_whea_header *entry, u64 *val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) int __apei_exec_write_register(struct acpi_whea_header *entry, u64 val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) int apei_exec_read_register(struct apei_exec_context *ctx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 			    struct acpi_whea_header *entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) int apei_exec_read_register_value(struct apei_exec_context *ctx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 				  struct acpi_whea_header *entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) int apei_exec_write_register(struct apei_exec_context *ctx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 			     struct acpi_whea_header *entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) int apei_exec_write_register_value(struct apei_exec_context *ctx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 				   struct acpi_whea_header *entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) int apei_exec_noop(struct apei_exec_context *ctx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 		   struct acpi_whea_header *entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) int apei_exec_pre_map_gars(struct apei_exec_context *ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) int apei_exec_post_unmap_gars(struct apei_exec_context *ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) struct apei_resources {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	struct list_head iomem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	struct list_head ioport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) static inline void apei_resources_init(struct apei_resources *resources)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	INIT_LIST_HEAD(&resources->iomem);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	INIT_LIST_HEAD(&resources->ioport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) void apei_resources_fini(struct apei_resources *resources);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) int apei_resources_add(struct apei_resources *resources,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 		       unsigned long start, unsigned long size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 		       bool iomem);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) int apei_resources_sub(struct apei_resources *resources1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 		       struct apei_resources *resources2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) int apei_resources_request(struct apei_resources *resources,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 			   const char *desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) void apei_resources_release(struct apei_resources *resources);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) int apei_exec_collect_resources(struct apei_exec_context *ctx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 				struct apei_resources *resources);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) struct dentry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) struct dentry *apei_get_debugfs_dir(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) static inline u32 cper_estatus_len(struct acpi_hest_generic_status *estatus)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	if (estatus->raw_data_length)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 		return estatus->raw_data_offset + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 			estatus->raw_data_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 		return sizeof(*estatus) + estatus->data_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) void cper_estatus_print(const char *pfx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 			const struct acpi_hest_generic_status *estatus);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) int cper_estatus_check_header(const struct acpi_hest_generic_status *estatus);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) int cper_estatus_check(const struct acpi_hest_generic_status *estatus);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) int apei_osc_setup(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) #endif