blob: 459dc09ecbd8cc81a5933246adef8695188cedbe [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 */
9
Paul Mackerrasc55377e2005-11-14 17:22:01 +110010#ifndef _ASM_POWERPC_NVRAM_H
11#define _ASM_POWERPC_NVRAM_H
Linus Torvalds1da177e2005-04-16 15:20:36 -070012
Benjamin Herrenschmidt74d51d02010-07-29 14:45:24 +100013/* Signatures for nvram partitions */
Linus Torvalds1da177e2005-04-16 15:20:36 -070014#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
Arnd Bergmann88ced032005-12-16 22:43:46 +010028#ifdef __KERNEL__
Andrew Morton134d4952008-02-04 22:27:31 -080029
Benjamin Herrenschmidt74d51d02010-07-29 14:45:24 +100030#include <linux/errno.h>
Andrew Morton134d4952008-02-04 22:27:31 -080031#include <linux/list.h>
32
Linas Vepstas0f2342c2007-08-10 06:56:41 +100033extern int nvram_write_error_log(char * buff, int length,
34 unsigned int err_type, unsigned int err_seq);
35extern int nvram_read_error_log(char * buff, int length,
36 unsigned int * err_type, unsigned int *err_seq);
Linus Torvalds1da177e2005-04-16 15:20:36 -070037extern int nvram_clear_error_log(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070038
39extern int pSeries_nvram_init(void);
Ishizaki Kou47515052007-12-13 21:11:36 +110040
41#ifdef CONFIG_MMIO_NVRAM
Arnd Bergmannf3f66f52005-10-31 20:08:37 -050042extern int mmio_nvram_init(void);
Ishizaki Kou47515052007-12-13 21:11:36 +110043#else
44static inline int mmio_nvram_init(void)
45{
46 return -ENODEV;
47}
48#endif
49
Arnd Bergmann88ced032005-12-16 22:43:46 +010050#endif /* __KERNEL__ */
Linus Torvalds1da177e2005-04-16 15:20:36 -070051
52/* PowerMac specific nvram stuffs */
53
54enum {
55 pmac_nvram_OF, /* Open Firmware partition */
56 pmac_nvram_XPRAM, /* MacOS XPRAM partition */
57 pmac_nvram_NR /* MacOS Name Registry partition */
58};
59
Arnd Bergmann88ced032005-12-16 22:43:46 +010060#ifdef __KERNEL__
Linus Torvalds1da177e2005-04-16 15:20:36 -070061/* Return partition offset in nvram */
62extern int pmac_get_partition(int partition);
63
64/* Direct access to XPRAM on PowerMacs */
65extern u8 pmac_xpram_read(int xpaddr);
66extern void pmac_xpram_write(int xpaddr, u8 data);
67
68/* Synchronize NVRAM */
Paul Mackerrasc55377e2005-11-14 17:22:01 +110069extern void nvram_sync(void);
70
Martyn Welchd331d832009-08-13 09:03:02 +010071/* Determine NVRAM size */
72extern ssize_t nvram_get_size(void);
73
Paul Mackerrasc55377e2005-11-14 17:22:01 +110074/* Normal access to NVRAM */
75extern unsigned char nvram_read_byte(int i);
76extern void nvram_write_byte(unsigned char c, int i);
Arnd Bergmann88ced032005-12-16 22:43:46 +010077#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070078
79/* Some offsets in XPRAM */
80#define PMAC_XPRAM_MACHINE_LOC 0xe4
81#define PMAC_XPRAM_SOUND_VOLUME 0x08
82
83/* Machine location structure in PowerMac XPRAM */
84struct pmac_machine_location {
85 unsigned int latitude; /* 2+30 bit Fractional number */
86 unsigned int longitude; /* 2+30 bit Fractional number */
87 unsigned int delta; /* mix of GMT delta and DLS */
88};
89
90/*
91 * /dev/nvram ioctls
92 *
93 * Note that PMAC_NVRAM_GET_OFFSET is still supported, but is
94 * definitely obsolete. Do not use it if you can avoid it
95 */
96
97#define OBSOLETE_PMAC_NVRAM_GET_OFFSET \
98 _IOWR('p', 0x40, int)
99
100#define IOC_NVRAM_GET_OFFSET _IOWR('p', 0x42, int) /* Get NVRAM partition offset */
Paul Mackerrasc55377e2005-11-14 17:22:01 +1100101#define IOC_NVRAM_SYNC _IO('p', 0x43) /* Sync NVRAM image */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102
Paul Mackerrasc55377e2005-11-14 17:22:01 +1100103#endif /* _ASM_POWERPC_NVRAM_H */