xref: /freebsd/sys/dev/powermac_nvram/powermac_nvramvar.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
1718cf2ccSPedro F. Giffuni /*-
2*4d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
3718cf2ccSPedro F. Giffuni  *
4e5d34218SMaxim Sobolev  * Copyright (c) 2006 Maxim Sobolev <sobomax@FreeBSD.org>
5e5d34218SMaxim Sobolev  * All rights reserved.
6e5d34218SMaxim Sobolev  *
7e5d34218SMaxim Sobolev  * Redistribution and use in source and binary forms, with or without
8e5d34218SMaxim Sobolev  * modification, are permitted provided that the following conditions
9e5d34218SMaxim Sobolev  * are met:
10e5d34218SMaxim Sobolev  * 1. Redistributions of source code must retain the above copyright
11e5d34218SMaxim Sobolev  *    notice, this list of conditions and the following disclaimer.
12e5d34218SMaxim Sobolev  * 2. Redistributions in binary form must reproduce the above copyright
13e5d34218SMaxim Sobolev  *    notice, this list of conditions and the following disclaimer in the
14e5d34218SMaxim Sobolev  *    documentation and/or other materials provided with the distribution.
15e5d34218SMaxim Sobolev  *
16e5d34218SMaxim Sobolev  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17e5d34218SMaxim Sobolev  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18e5d34218SMaxim Sobolev  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19e5d34218SMaxim Sobolev  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
20e5d34218SMaxim Sobolev  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21e5d34218SMaxim Sobolev  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22e5d34218SMaxim Sobolev  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23e5d34218SMaxim Sobolev  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
24e5d34218SMaxim Sobolev  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
25e5d34218SMaxim Sobolev  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26e5d34218SMaxim Sobolev  * POSSIBILITY OF SUCH DAMAGE.
27e5d34218SMaxim Sobolev  */
28e5d34218SMaxim Sobolev 
29e5d34218SMaxim Sobolev #ifndef	_POWERPC_POWERMAC_POWERMAC_NVRAMVAR_H_
30e5d34218SMaxim Sobolev #define	_POWERPC_POWERMAC_POWERMAC_NVRAMVAR_H_
31e5d34218SMaxim Sobolev 
32e5d34218SMaxim Sobolev #define	NVRAM_SIZE		0x2000
33e5d34218SMaxim Sobolev 
34e5d34218SMaxim Sobolev #define	CORE99_SIGNATURE	0x5a
35e5d34218SMaxim Sobolev 
36af82b9a9SAlexander Motin #define SM_FLASH_CMD_ERASE_CONFIRM	0xd0
37af82b9a9SAlexander Motin #define SM_FLASH_CMD_ERASE_SETUP	0x20
38af82b9a9SAlexander Motin #define SM_FLASH_CMD_RESET		0xff
39af82b9a9SAlexander Motin #define SM_FLASH_CMD_WRITE_SETUP	0x40
40af82b9a9SAlexander Motin #define SM_FLASH_CMD_CLEAR_STATUS	0x50
41af82b9a9SAlexander Motin #define SM_FLASH_CMD_READ_STATUS	0x70
42af82b9a9SAlexander Motin 
43af82b9a9SAlexander Motin #define SM_FLASH_STATUS_DONE	0x80
44af82b9a9SAlexander Motin #define SM_FLASH_STATUS_ERR	0x38
45af82b9a9SAlexander Motin 
46e5d34218SMaxim Sobolev #ifdef _KERNEL
47e5d34218SMaxim Sobolev 
48e5d34218SMaxim Sobolev struct powermac_nvram_softc {
49e5d34218SMaxim Sobolev 	device_t		sc_dev;
5037f53058SBrandon Bergren 	struct sx		sc_lock;
51e5d34218SMaxim Sobolev 	phandle_t		sc_node;
527ae99f80SJohn Baldwin 	void *			sc_bank;
537ae99f80SJohn Baldwin 	void *			sc_bank0;
547ae99f80SJohn Baldwin 	void *			sc_bank1;
55e5d34218SMaxim Sobolev 	uint8_t			sc_data[NVRAM_SIZE];
56e5d34218SMaxim Sobolev 
57e5d34218SMaxim Sobolev 	struct cdev *		sc_cdev;
58af82b9a9SAlexander Motin 	int			sc_type;
59af82b9a9SAlexander Motin #define FLASH_TYPE_SM	0
60af82b9a9SAlexander Motin #define FLASH_TYPE_AMD	1
61e5d34218SMaxim Sobolev 	int			sc_isopen;
62e5d34218SMaxim Sobolev 	int			sc_rpos;
63e5d34218SMaxim Sobolev 	int			sc_wpos;
64e5d34218SMaxim Sobolev };
65e5d34218SMaxim Sobolev 
66e5d34218SMaxim Sobolev #endif /* _KERNEL */
67e5d34218SMaxim Sobolev 
68e5d34218SMaxim Sobolev struct chrp_header {
69e5d34218SMaxim Sobolev 	uint8_t			signature;
70e5d34218SMaxim Sobolev 	uint8_t			chrp_checksum;
71e5d34218SMaxim Sobolev 	uint16_t		length;
72e5d34218SMaxim Sobolev 	char			name[12];
73e5d34218SMaxim Sobolev };
74e5d34218SMaxim Sobolev 
75e5d34218SMaxim Sobolev struct core99_header {
76e5d34218SMaxim Sobolev 	struct chrp_header	chrp_header;
77e5d34218SMaxim Sobolev 	uint32_t		adler_checksum;
78e5d34218SMaxim Sobolev 	uint32_t		generation;
79e5d34218SMaxim Sobolev 	uint32_t		reserved[2];
80e5d34218SMaxim Sobolev };
81e5d34218SMaxim Sobolev 
82e5d34218SMaxim Sobolev #endif  /* _POWERPC_POWERMAC_POWERMAC_NVRAMVAR_H_ */
83