xref: /openbmc/linux/arch/powerpc/include/asm/nvram.h (revision 4800cd83)
1 /*
2  * NVRAM definitions and access functions.
3  *
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  */
9 
10 #ifndef _ASM_POWERPC_NVRAM_H
11 #define _ASM_POWERPC_NVRAM_H
12 
13 /* Signatures for nvram partitions */
14 #define NVRAM_SIG_SP	0x02	/* support processor */
15 #define NVRAM_SIG_OF	0x50	/* open firmware config */
16 #define NVRAM_SIG_FW	0x51	/* general firmware */
17 #define NVRAM_SIG_HW	0x52	/* hardware (VPD) */
18 #define NVRAM_SIG_FLIP	0x5a	/* Apple flip/flop header */
19 #define NVRAM_SIG_APPL	0x5f	/* Apple "system" (???) */
20 #define NVRAM_SIG_SYS	0x70	/* system env vars */
21 #define NVRAM_SIG_CFG	0x71	/* config data */
22 #define NVRAM_SIG_ELOG	0x72	/* error log */
23 #define NVRAM_SIG_VEND	0x7e	/* vendor defined */
24 #define NVRAM_SIG_FREE	0x7f	/* Free space */
25 #define NVRAM_SIG_OS	0xa0	/* OS defined */
26 #define NVRAM_SIG_PANIC	0xa1	/* Apple OSX "panic" */
27 
28 #ifdef __KERNEL__
29 
30 #include <linux/errno.h>
31 #include <linux/list.h>
32 
33 #ifdef CONFIG_PPC_PSERIES
34 extern int nvram_write_error_log(char * buff, int length,
35 					 unsigned int err_type, unsigned int err_seq);
36 extern int nvram_read_error_log(char * buff, int length,
37 					 unsigned int * err_type, unsigned int *err_seq);
38 extern int nvram_clear_error_log(void);
39 extern int pSeries_nvram_init(void);
40 #endif /* CONFIG_PPC_PSERIES */
41 
42 #ifdef CONFIG_MMIO_NVRAM
43 extern int mmio_nvram_init(void);
44 #else
45 static inline int mmio_nvram_init(void)
46 {
47 	return -ENODEV;
48 }
49 #endif
50 
51 extern int __init nvram_scan_partitions(void);
52 extern loff_t nvram_create_partition(const char *name, int sig,
53 				     int req_size, int min_size);
54 extern int nvram_remove_partition(const char *name, int sig);
55 extern int nvram_get_partition_size(loff_t data_index);
56 extern loff_t nvram_find_partition(const char *name, int sig, int *out_size);
57 
58 #endif /* __KERNEL__ */
59 
60 /* PowerMac specific nvram stuffs */
61 
62 enum {
63 	pmac_nvram_OF,		/* Open Firmware partition */
64 	pmac_nvram_XPRAM,	/* MacOS XPRAM partition */
65 	pmac_nvram_NR		/* MacOS Name Registry partition */
66 };
67 
68 #ifdef __KERNEL__
69 /* Return partition offset in nvram */
70 extern int	pmac_get_partition(int partition);
71 
72 /* Direct access to XPRAM on PowerMacs */
73 extern u8	pmac_xpram_read(int xpaddr);
74 extern void	pmac_xpram_write(int xpaddr, u8 data);
75 
76 /* Synchronize NVRAM */
77 extern void	nvram_sync(void);
78 
79 /* Determine NVRAM size */
80 extern ssize_t nvram_get_size(void);
81 
82 /* Normal access to NVRAM */
83 extern unsigned char nvram_read_byte(int i);
84 extern void nvram_write_byte(unsigned char c, int i);
85 #endif
86 
87 /* Some offsets in XPRAM */
88 #define PMAC_XPRAM_MACHINE_LOC	0xe4
89 #define PMAC_XPRAM_SOUND_VOLUME	0x08
90 
91 /* Machine location structure in PowerMac XPRAM */
92 struct pmac_machine_location {
93 	unsigned int	latitude;	/* 2+30 bit Fractional number */
94 	unsigned int	longitude;	/* 2+30 bit Fractional number */
95 	unsigned int	delta;		/* mix of GMT delta and DLS */
96 };
97 
98 /*
99  * /dev/nvram ioctls
100  *
101  * Note that PMAC_NVRAM_GET_OFFSET is still supported, but is
102  * definitely obsolete. Do not use it if you can avoid it
103  */
104 
105 #define OBSOLETE_PMAC_NVRAM_GET_OFFSET \
106 				_IOWR('p', 0x40, int)
107 
108 #define IOC_NVRAM_GET_OFFSET	_IOWR('p', 0x42, int)	/* Get NVRAM partition offset */
109 #define IOC_NVRAM_SYNC		_IO('p', 0x43)		/* Sync NVRAM image */
110 
111 #endif /* _ASM_POWERPC_NVRAM_H */
112