Linux Audio

Check our new training course

Loading...
v6.9.4
 1/* SPDX-License-Identifier: GPL-2.0-or-later */
 2/*
 3 * NVRAM definitions and access functions.
 
 
 
 
 
 4 */
 
 5#ifndef _ASM_POWERPC_NVRAM_H
 6#define _ASM_POWERPC_NVRAM_H
 7
 8#include <linux/types.h>
 9#include <linux/errno.h>
10#include <linux/list.h>
11#include <uapi/asm/nvram.h>
 
 
 
 
 
 
 
 
 
 
12
13/*
14 * Set oops header version to distinguish between old and new format header.
15 * lnx,oops-log partition max size is 4000, header version > 4000 will
16 * help in identifying new header.
17 */
18#define OOPS_HDR_VERSION 5000
19
20struct err_log_info {
21	__be32 error_type;
22	__be32 seq_num;
23};
24
25struct nvram_os_partition {
26	const char *name;
27	int req_size;	/* desired size, in bytes */
28	int min_size;	/* minimum acceptable size (0 means req_size) */
29	long size;	/* size of data portion (excluding err_log_info) */
30	long index;	/* offset of data portion of partition */
31	bool os_partition; /* partition initialized by OS, not FW */
32};
33
34struct oops_log_info {
35	__be16 version;
36	__be16 report_length;
37	__be64 timestamp;
38} __attribute__((packed));
39
40extern struct nvram_os_partition oops_log_partition;
41
42#ifdef CONFIG_PPC_PSERIES
43extern struct nvram_os_partition rtas_log_partition;
44
45extern int nvram_write_error_log(char * buff, int length,
46					 unsigned int err_type, unsigned int err_seq);
47extern int nvram_read_error_log(char * buff, int length,
48					 unsigned int * err_type, unsigned int *err_seq);
49extern int nvram_clear_error_log(void);
50extern int pSeries_nvram_init(void);
51#endif /* CONFIG_PPC_PSERIES */
52
53#ifdef CONFIG_MMIO_NVRAM
54extern int mmio_nvram_init(void);
55#else
56static inline int mmio_nvram_init(void)
57{
58	return -ENODEV;
59}
60#endif
61
62extern int __init nvram_scan_partitions(void);
63extern loff_t nvram_create_partition(const char *name, int sig,
64				     int req_size, int min_size);
65extern int nvram_remove_partition(const char *name, int sig,
66					const char *exceptions[]);
67extern int nvram_get_partition_size(loff_t data_index);
68extern loff_t nvram_find_partition(const char *name, int sig, int *out_size);
69
 
 
 
 
 
 
 
 
 
 
 
70/* Return partition offset in nvram */
71extern int	pmac_get_partition(int partition);
72
73/* Direct access to XPRAM on PowerMacs */
74extern u8	pmac_xpram_read(int xpaddr);
75extern void	pmac_xpram_write(int xpaddr, u8 data);
76
77/* Initialize NVRAM OS partition */
78extern int __init nvram_init_os_partition(struct nvram_os_partition *part);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
80/* Initialize NVRAM oops partition */
81extern void __init nvram_init_oops_partition(int rtas_partition_exists);
82
83/* Read a NVRAM partition */
84extern int nvram_read_partition(struct nvram_os_partition *part, char *buff,
85				int length, unsigned int *err_type,
86				unsigned int *error_log_cnt);
87
88/* Write to NVRAM OS partition */
89extern int nvram_write_os_partition(struct nvram_os_partition *part,
90				    char *buff, int length,
91				    unsigned int err_type,
92				    unsigned int error_log_cnt);
93
94#endif /* _ASM_POWERPC_NVRAM_H */
v3.1
 
  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
 
 
 34extern int nvram_write_error_log(char * buff, int length,
 35					 unsigned int err_type, unsigned int err_seq);
 36extern int nvram_read_error_log(char * buff, int length,
 37					 unsigned int * err_type, unsigned int *err_seq);
 38extern int nvram_clear_error_log(void);
 39extern int pSeries_nvram_init(void);
 40#endif /* CONFIG_PPC_PSERIES */
 41
 42#ifdef CONFIG_MMIO_NVRAM
 43extern int mmio_nvram_init(void);
 44#else
 45static inline int mmio_nvram_init(void)
 46{
 47	return -ENODEV;
 48}
 49#endif
 50
 51extern int __init nvram_scan_partitions(void);
 52extern loff_t nvram_create_partition(const char *name, int sig,
 53				     int req_size, int min_size);
 54extern int nvram_remove_partition(const char *name, int sig,
 55					const char *exceptions[]);
 56extern int nvram_get_partition_size(loff_t data_index);
 57extern loff_t nvram_find_partition(const char *name, int sig, int *out_size);
 58
 59#endif /* __KERNEL__ */
 60
 61/* PowerMac specific nvram stuffs */
 62
 63enum {
 64	pmac_nvram_OF,		/* Open Firmware partition */
 65	pmac_nvram_XPRAM,	/* MacOS XPRAM partition */
 66	pmac_nvram_NR		/* MacOS Name Registry partition */
 67};
 68
 69#ifdef __KERNEL__
 70/* Return partition offset in nvram */
 71extern int	pmac_get_partition(int partition);
 72
 73/* Direct access to XPRAM on PowerMacs */
 74extern u8	pmac_xpram_read(int xpaddr);
 75extern void	pmac_xpram_write(int xpaddr, u8 data);
 76
 77/* Synchronize NVRAM */
 78extern void	nvram_sync(void);
 79
 80/* Determine NVRAM size */
 81extern ssize_t nvram_get_size(void);
 82
 83/* Normal access to NVRAM */
 84extern unsigned char nvram_read_byte(int i);
 85extern void nvram_write_byte(unsigned char c, int i);
 86#endif
 87
 88/* Some offsets in XPRAM */
 89#define PMAC_XPRAM_MACHINE_LOC	0xe4
 90#define PMAC_XPRAM_SOUND_VOLUME	0x08
 91
 92/* Machine location structure in PowerMac XPRAM */
 93struct pmac_machine_location {
 94	unsigned int	latitude;	/* 2+30 bit Fractional number */
 95	unsigned int	longitude;	/* 2+30 bit Fractional number */
 96	unsigned int	delta;		/* mix of GMT delta and DLS */
 97};
 98
 99/*
100 * /dev/nvram ioctls
101 *
102 * Note that PMAC_NVRAM_GET_OFFSET is still supported, but is
103 * definitely obsolete. Do not use it if you can avoid it
104 */
105
106#define OBSOLETE_PMAC_NVRAM_GET_OFFSET \
107				_IOWR('p', 0x40, int)
108
109#define IOC_NVRAM_GET_OFFSET	_IOWR('p', 0x42, int)	/* Get NVRAM partition offset */
110#define IOC_NVRAM_SYNC		_IO('p', 0x43)		/* Sync NVRAM image */
 
 
 
 
 
 
 
 
111
112#endif /* _ASM_POWERPC_NVRAM_H */