blob: 09a518bb7c03c681a776e708f78642446b4ecbb4 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Paul Mackerrasc55377e2005-11-14 17:22:01 +11002 * NVRAM definitions and access functions.
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
8 */
Paul Mackerrasc55377e2005-11-14 17:22:01 +11009#ifndef _ASM_POWERPC_NVRAM_H
10#define _ASM_POWERPC_NVRAM_H
Linus Torvalds1da177e2005-04-16 15:20:36 -070011
Hari Bathini78989f02015-02-06 01:06:04 +053012#include <linux/types.h>
Benjamin Herrenschmidt74d51d02010-07-29 14:45:24 +100013#include <linux/errno.h>
Andrew Morton134d4952008-02-04 22:27:31 -080014#include <linux/list.h>
David Howellsc3617f72012-10-09 09:47:26 +010015#include <uapi/asm/nvram.h>
Andrew Morton134d4952008-02-04 22:27:31 -080016
Hari Bathini78989f02015-02-06 01:06:04 +053017/*
18 * Set oops header version to distinguish between old and new format header.
19 * lnx,oops-log partition max size is 4000, header version > 4000 will
20 * help in identifying new header.
21 */
22#define OOPS_HDR_VERSION 5000
23
24struct err_log_info {
25 __be32 error_type;
26 __be32 seq_num;
27};
28
29struct nvram_os_partition {
30 const char *name;
31 int req_size; /* desired size, in bytes */
32 int min_size; /* minimum acceptable size (0 means req_size) */
33 long size; /* size of data portion (excluding err_log_info) */
34 long index; /* offset of data portion of partition */
35 bool os_partition; /* partition initialized by OS, not FW */
36};
37
38struct oops_log_info {
39 __be16 version;
40 __be16 report_length;
41 __be64 timestamp;
42} __attribute__((packed));
43
44extern struct nvram_os_partition oops_log_partition;
45
Benjamin Herrenschmidtedc79a22010-08-02 11:18:09 +100046#ifdef CONFIG_PPC_PSERIES
Hari Bathini78989f02015-02-06 01:06:04 +053047extern struct nvram_os_partition rtas_log_partition;
48
Linas Vepstas0f2342c2007-08-10 06:56:41 +100049extern int nvram_write_error_log(char * buff, int length,
50 unsigned int err_type, unsigned int err_seq);
51extern int nvram_read_error_log(char * buff, int length,
52 unsigned int * err_type, unsigned int *err_seq);
Linus Torvalds1da177e2005-04-16 15:20:36 -070053extern int nvram_clear_error_log(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070054extern int pSeries_nvram_init(void);
Benjamin Herrenschmidtedc79a22010-08-02 11:18:09 +100055#endif /* CONFIG_PPC_PSERIES */
Ishizaki Kou47515052007-12-13 21:11:36 +110056
57#ifdef CONFIG_MMIO_NVRAM
Arnd Bergmannf3f66f52005-10-31 20:08:37 -050058extern int mmio_nvram_init(void);
Ishizaki Kou47515052007-12-13 21:11:36 +110059#else
60static inline int mmio_nvram_init(void)
61{
62 return -ENODEV;
63}
64#endif
65
Benjamin Herrenschmidtedc79a22010-08-02 11:18:09 +100066extern int __init nvram_scan_partitions(void);
67extern loff_t nvram_create_partition(const char *name, int sig,
68 int req_size, int min_size);
Jim Keniston0f4ac132011-02-09 12:43:13 +000069extern int nvram_remove_partition(const char *name, int sig,
70 const char *exceptions[]);
Benjamin Herrenschmidtedc79a22010-08-02 11:18:09 +100071extern int nvram_get_partition_size(loff_t data_index);
72extern loff_t nvram_find_partition(const char *name, int sig, int *out_size);
73
Linus Torvalds1da177e2005-04-16 15:20:36 -070074/* Return partition offset in nvram */
75extern int pmac_get_partition(int partition);
76
77/* Direct access to XPRAM on PowerMacs */
78extern u8 pmac_xpram_read(int xpaddr);
79extern void pmac_xpram_write(int xpaddr, u8 data);
80
81/* Synchronize NVRAM */
Paul Mackerrasc55377e2005-11-14 17:22:01 +110082extern void nvram_sync(void);
83
Hari Bathini78989f02015-02-06 01:06:04 +053084/* Initialize NVRAM OS partition */
85extern int __init nvram_init_os_partition(struct nvram_os_partition *part);
86
87/* Initialize NVRAM oops partition */
88extern void __init nvram_init_oops_partition(int rtas_partition_exists);
89
90/* Read a NVRAM partition */
91extern int nvram_read_partition(struct nvram_os_partition *part, char *buff,
92 int length, unsigned int *err_type,
93 unsigned int *error_log_cnt);
94
95/* Write to NVRAM OS partition */
96extern int nvram_write_os_partition(struct nvram_os_partition *part,
97 char *buff, int length,
98 unsigned int err_type,
99 unsigned int error_log_cnt);
100
Martyn Welchd331d832009-08-13 09:03:02 +0100101/* Determine NVRAM size */
102extern ssize_t nvram_get_size(void);
103
Paul Mackerrasc55377e2005-11-14 17:22:01 +1100104/* Normal access to NVRAM */
105extern unsigned char nvram_read_byte(int i);
106extern void nvram_write_byte(unsigned char c, int i);
Paul Mackerrasc55377e2005-11-14 17:22:01 +1100107#endif /* _ASM_POWERPC_NVRAM_H */