xref: /freebsd/sys/dev/bhnd/nvram/bhnd_nvram_data_bcmreg.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
177cb4d3eSLandon J. Fuller /*-
277cb4d3eSLandon J. Fuller  * Copyright (c) 2015-2016 Landon Fuller <landonf@FreeBSD.org>
377cb4d3eSLandon J. Fuller  * All rights reserved.
477cb4d3eSLandon J. Fuller  *
577cb4d3eSLandon J. Fuller  * Redistribution and use in source and binary forms, with or without
677cb4d3eSLandon J. Fuller  * modification, are permitted provided that the following conditions
777cb4d3eSLandon J. Fuller  * are met:
877cb4d3eSLandon J. Fuller  * 1. Redistributions of source code must retain the above copyright
977cb4d3eSLandon J. Fuller  *    notice, this list of conditions and the following disclaimer,
1077cb4d3eSLandon J. Fuller  *    without modification.
1177cb4d3eSLandon J. Fuller  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
1277cb4d3eSLandon J. Fuller  *    similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
1377cb4d3eSLandon J. Fuller  *    redistribution must be conditioned upon including a substantially
1477cb4d3eSLandon J. Fuller  *    similar Disclaimer requirement for further binary redistribution.
1577cb4d3eSLandon J. Fuller  *
1677cb4d3eSLandon J. Fuller  * NO WARRANTY
1777cb4d3eSLandon J. Fuller  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1877cb4d3eSLandon J. Fuller  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1977cb4d3eSLandon J. Fuller  * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
2077cb4d3eSLandon J. Fuller  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
2177cb4d3eSLandon J. Fuller  * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
2277cb4d3eSLandon J. Fuller  * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2377cb4d3eSLandon J. Fuller  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2477cb4d3eSLandon J. Fuller  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
2577cb4d3eSLandon J. Fuller  * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2677cb4d3eSLandon J. Fuller  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
2777cb4d3eSLandon J. Fuller  * THE POSSIBILITY OF SUCH DAMAGES.
2877cb4d3eSLandon J. Fuller  */
2977cb4d3eSLandon J. Fuller 
3077cb4d3eSLandon J. Fuller #ifndef _BHND_NVRAM_BHND_NVRAM_BCMREG_H_
3177cb4d3eSLandon J. Fuller #define _BHND_NVRAM_BHND_NVRAM_BCMREG_H_
3277cb4d3eSLandon J. Fuller 
3377cb4d3eSLandon J. Fuller #define BCM_NVRAM_GET_BITS(_value, _field)			\
3477cb4d3eSLandon J. Fuller 	((_value & _field ## _MASK) >> _field ## _SHIFT)
3577cb4d3eSLandon J. Fuller 
36*c283839dSLandon J. Fuller #define BCM_NVRAM_SET_BITS(_value, _field, _bits)		\
37*c283839dSLandon J. Fuller 	((_value & ~(_field ## _MASK)) |			\
38*c283839dSLandon J. Fuller 	    (((_bits) << _field ## _SHIFT) & _field ## _MASK))
39*c283839dSLandon J. Fuller 
4077cb4d3eSLandon J. Fuller /* BCM NVRAM header fields */
4177cb4d3eSLandon J. Fuller #define	BCM_NVRAM_MAGIC				0x48534C46	/* 'FLSH' */
4277cb4d3eSLandon J. Fuller #define	BCM_NVRAM_VERSION			1
4377cb4d3eSLandon J. Fuller 
4477cb4d3eSLandon J. Fuller #define	BCM_NVRAM_CRC_SKIP			9		/* skip magic, size, and crc8 */
4577cb4d3eSLandon J. Fuller 
4677cb4d3eSLandon J. Fuller #define	BCM_NVRAM_CFG0_CRC_MASK			0x000000FF
4777cb4d3eSLandon J. Fuller #define	BCM_NVRAM_CFG0_CRC_SHIFT		0
4877cb4d3eSLandon J. Fuller #define	BCM_NVRAM_CFG0_VER_MASK			0x0000FF00
4977cb4d3eSLandon J. Fuller #define	BCM_NVRAM_CFG0_VER_SHIFT		8
50*c283839dSLandon J. Fuller #define	BCM_NVRAM_CFG0_VER_DEFAULT		1		/* default version */
5177cb4d3eSLandon J. Fuller 
5277cb4d3eSLandon J. Fuller #define	BCM_NVRAM_CFG0_SDRAM_INIT_FIELD		cfg0
5377cb4d3eSLandon J. Fuller #define	BCM_NVRAM_CFG0_SDRAM_INIT_MASK		0xFFFF0000
5477cb4d3eSLandon J. Fuller #define	BCM_NVRAM_CFG0_SDRAM_INIT_SHIFT		16
5577cb4d3eSLandon J. Fuller #define	BCM_NVRAM_CFG0_SDRAM_INIT_VAR		"sdram_init"
5677cb4d3eSLandon J. Fuller #define	BCM_NVRAM_CFG0_SDRAM_INIT_FMT		"0x%04x"
5777cb4d3eSLandon J. Fuller 
5877cb4d3eSLandon J. Fuller #define	BCM_NVRAM_CFG1_SDRAM_CFG_FIELD		cfg1
5977cb4d3eSLandon J. Fuller #define	BCM_NVRAM_CFG1_SDRAM_CFG_MASK		0x0000FFFF
6077cb4d3eSLandon J. Fuller #define	BCM_NVRAM_CFG1_SDRAM_CFG_SHIFT		0
6177cb4d3eSLandon J. Fuller #define	BCM_NVRAM_CFG1_SDRAM_CFG_VAR		"sdram_config"
6277cb4d3eSLandon J. Fuller #define	BCM_NVRAM_CFG1_SDRAM_CFG_FMT		"0x%04x"
6377cb4d3eSLandon J. Fuller 
6477cb4d3eSLandon J. Fuller #define	BCM_NVRAM_CFG1_SDRAM_REFRESH_FIELD	cfg1
6577cb4d3eSLandon J. Fuller #define	BCM_NVRAM_CFG1_SDRAM_REFRESH_MASK	0xFFFF0000
6677cb4d3eSLandon J. Fuller #define	BCM_NVRAM_CFG1_SDRAM_REFRESH_SHIFT	16
6777cb4d3eSLandon J. Fuller #define	BCM_NVRAM_CFG1_SDRAM_REFRESH_VAR	"sdram_refresh"
6877cb4d3eSLandon J. Fuller #define	BCM_NVRAM_CFG1_SDRAM_REFRESH_FMT	"0x%04x"
6977cb4d3eSLandon J. Fuller 
7077cb4d3eSLandon J. Fuller #define	BCM_NVRAM_SDRAM_NCDL_FIELD		sdram_ncdl
7177cb4d3eSLandon J. Fuller #define	BCM_NVRAM_SDRAM_NCDL_MASK		UINT32_MAX
7277cb4d3eSLandon J. Fuller #define	BCM_NVRAM_SDRAM_NCDL_SHIFT		0
7377cb4d3eSLandon J. Fuller #define	BCM_NVRAM_SDRAM_NCDL_VAR		"sdram_ncdl"
7477cb4d3eSLandon J. Fuller #define	BCM_NVRAM_SDRAM_NCDL_FMT		"0x%08x"
7577cb4d3eSLandon J. Fuller 
7677cb4d3eSLandon J. Fuller #endif /* _BHND_NVRAM_BHND_NVRAM_BCMREG_H_ */
77