^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * NVRAM definitions and access functions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #ifndef _ASM_POWERPC_NVRAM_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #define _ASM_POWERPC_NVRAM_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/list.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <uapi/asm/nvram.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * Set oops header version to distinguish between old and new format header.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * lnx,oops-log partition max size is 4000, header version > 4000 will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * help in identifying new header.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #define OOPS_HDR_VERSION 5000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) struct err_log_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) __be32 error_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) __be32 seq_num;
^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 nvram_os_partition {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) const char *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) int req_size; /* desired size, in bytes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) int min_size; /* minimum acceptable size (0 means req_size) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) long size; /* size of data portion (excluding err_log_info) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) long index; /* offset of data portion of partition */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) bool os_partition; /* partition initialized by OS, not FW */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) struct oops_log_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) __be16 version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) __be16 report_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) __be64 timestamp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) } __attribute__((packed));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) extern struct nvram_os_partition oops_log_partition;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) #ifdef CONFIG_PPC_PSERIES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) extern struct nvram_os_partition rtas_log_partition;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) extern int nvram_write_error_log(char * buff, int length,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) unsigned int err_type, unsigned int err_seq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) extern int nvram_read_error_log(char * buff, int length,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) unsigned int * err_type, unsigned int *err_seq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) extern int nvram_clear_error_log(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) extern int pSeries_nvram_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) #endif /* CONFIG_PPC_PSERIES */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) #ifdef CONFIG_MMIO_NVRAM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) extern int mmio_nvram_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) static inline int mmio_nvram_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) extern int __init nvram_scan_partitions(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) extern loff_t nvram_create_partition(const char *name, int sig,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) int req_size, int min_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) extern int nvram_remove_partition(const char *name, int sig,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) const char *exceptions[]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) extern int nvram_get_partition_size(loff_t data_index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) extern loff_t nvram_find_partition(const char *name, int sig, int *out_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) /* Return partition offset in nvram */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) extern int pmac_get_partition(int partition);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) /* Direct access to XPRAM on PowerMacs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) extern u8 pmac_xpram_read(int xpaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) extern void pmac_xpram_write(int xpaddr, u8 data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) /* Initialize NVRAM OS partition */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) extern int __init nvram_init_os_partition(struct nvram_os_partition *part);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) /* Initialize NVRAM oops partition */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) extern void __init nvram_init_oops_partition(int rtas_partition_exists);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) /* Read a NVRAM partition */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) extern int nvram_read_partition(struct nvram_os_partition *part, char *buff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) int length, unsigned int *err_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) unsigned int *error_log_cnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) /* Write to NVRAM OS partition */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) extern int nvram_write_os_partition(struct nvram_os_partition *part,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) char *buff, int length,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) unsigned int err_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) unsigned int error_log_cnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) #endif /* _ASM_POWERPC_NVRAM_H */