1227569Sphilip/*-
2227569Sphilip * Copyright 2007-2009 Solarflare Communications Inc.  All rights reserved.
3227569Sphilip *
4227569Sphilip * Redistribution and use in source and binary forms, with or without
5227569Sphilip * modification, are permitted provided that the following conditions
6227569Sphilip * are met:
7227569Sphilip * 1. Redistributions of source code must retain the above copyright
8227569Sphilip *    notice, this list of conditions and the following disclaimer.
9227569Sphilip * 2. Redistributions in binary form must reproduce the above copyright
10227569Sphilip *    notice, this list of conditions and the following disclaimer in the
11227569Sphilip *    documentation and/or other materials provided with the distribution.
12227569Sphilip *
13227569Sphilip * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS AND
14227569Sphilip * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15227569Sphilip * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16227569Sphilip * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17227569Sphilip * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18227569Sphilip * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19227569Sphilip * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20227569Sphilip * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21227569Sphilip * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22227569Sphilip * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23227569Sphilip * SUCH DAMAGE.
24228100Sphilip *
25228100Sphilip * $FreeBSD$
26227569Sphilip */
27227569Sphilip
28227569Sphilip#ifndef	_SYS_SIENA_FLASH_H
29227569Sphilip#define	_SYS_SIENA_FLASH_H
30227569Sphilip
31227569Sphilip#pragma pack(1)
32227569Sphilip
33227569Sphilip/* Fixed locations near the start of flash (which may be in the internal PHY
34227569Sphilip * firmware header) point to the boot header.
35227569Sphilip *
36227569Sphilip * - parsed by MC boot ROM and firmware
37227569Sphilip * - reserved (but not parsed) by PHY firmware
38227569Sphilip * - opaque to driver
39227569Sphilip */
40227569Sphilip
41227569Sphilip#define	SIENA_MC_BOOT_PHY_FW_HDR_LEN (0x20)
42227569Sphilip
43227569Sphilip#define	SIENA_MC_BOOT_PTR_LOCATION (0x18)      /* First thing we try to boot */
44227569Sphilip#define	SIENA_MC_BOOT_ALT_PTR_LOCATION (0x1c)  /* Alternative if that fails */
45227569Sphilip
46227569Sphilip#define	SIENA_MC_BOOT_HDR_LEN (0x200)
47227569Sphilip
48227569Sphilip#define	SIENA_MC_BOOT_MAGIC (0x51E4A001)
49227569Sphilip#define	SIENA_MC_BOOT_VERSION (1)
50227569Sphilip
51227569Sphiliptypedef struct siena_mc_boot_hdr_s {		/* GENERATED BY scripts/genfwdef */
52227569Sphilip	efx_dword_t	magic;			/* = SIENA_MC_BOOT_MAGIC */
53227569Sphilip	efx_word_t	hdr_version;		/* this structure definition is version 1 */
54227569Sphilip	efx_byte_t	board_type;
55227569Sphilip	efx_byte_t	firmware_version_a;
56227569Sphilip	efx_byte_t	firmware_version_b;
57227569Sphilip	efx_byte_t	firmware_version_c;
58227569Sphilip	efx_word_t	checksum;		/* of whole header area + firmware image */
59227569Sphilip	efx_word_t	firmware_version_d;
60227569Sphilip	efx_word_t	reserved_a[1];		/* (set to 0) */
61227569Sphilip	efx_dword_t	firmware_text_offset;	/* offset to firmware .text */
62227569Sphilip	efx_dword_t	firmware_text_size;	/* length of firmware .text, in bytes */
63227569Sphilip	efx_dword_t	firmware_data_offset;	/* offset to firmware .data */
64227569Sphilip	efx_dword_t	firmware_data_size;	/* length of firmware .data, in bytes */
65227569Sphilip	efx_dword_t	reserved_b[8];		/* (set to 0) */
66227569Sphilip} siena_mc_boot_hdr_t;
67227569Sphilip
68227569Sphilip#define	SIENA_MC_STATIC_CONFIG_MAGIC (0xBDCF5555)
69227569Sphilip#define	SIENA_MC_STATIC_CONFIG_VERSION (0)
70227569Sphilip
71227569Sphiliptypedef struct siena_mc_static_config_hdr_s {	/* GENERATED BY scripts/genfwdef */
72227569Sphilip	efx_dword_t	magic;			/* = SIENA_MC_STATIC_CONFIG_MAGIC */
73227569Sphilip	efx_word_t	length;			/* of header area (i.e. not including VPD) */
74227569Sphilip	efx_byte_t	version;
75227569Sphilip	efx_byte_t	csum;			/* over header area (i.e. not including VPD) */
76227569Sphilip	efx_dword_t	static_vpd_offset;
77227569Sphilip	efx_dword_t	static_vpd_length;
78227569Sphilip	efx_dword_t	capabilities;
79227569Sphilip	efx_byte_t	mac_addr_base[6];
80227569Sphilip	efx_byte_t	green_mode_cal;		/* Green mode calibration result */
81227569Sphilip	efx_byte_t	green_mode_valid;	/* Whether cal holds a valid value */
82227569Sphilip	efx_word_t	mac_addr_count;
83227569Sphilip	efx_word_t	mac_addr_stride;
84227569Sphilip	efx_dword_t	reserved2[2];		/* (write as zero) */
85227569Sphilip	efx_dword_t	num_dbi_items;
86227569Sphilip	struct {
87227569Sphilip		efx_word_t	addr;
88227569Sphilip		efx_word_t	byte_enables;
89227569Sphilip		efx_dword_t	value;
90227569Sphilip	} dbi[];
91227569Sphilip} siena_mc_static_config_hdr_t;
92227569Sphilip
93227569Sphilip#define	SIENA_MC_DYNAMIC_CONFIG_MAGIC (0xBDCFDDDD)
94227569Sphilip#define	SIENA_MC_DYNAMIC_CONFIG_VERSION (0)
95227569Sphilip
96227569Sphiliptypedef struct siena_mc_fw_version_s {		/* GENERATED BY scripts/genfwdef */
97227569Sphilip	efx_dword_t	fw_subtype;
98227569Sphilip	efx_word_t	version_w;
99227569Sphilip	efx_word_t	version_x;
100227569Sphilip	efx_word_t	version_y;
101227569Sphilip	efx_word_t	version_z;
102227569Sphilip} siena_mc_fw_version_t;
103227569Sphilip
104227569Sphiliptypedef struct siena_mc_dynamic_config_hdr_s {	/* GENERATED BY scripts/genfwdef */
105227569Sphilip	efx_dword_t	magic;			/* = SIENA_MC_DYNAMIC_CONFIG_MAGIC */
106227569Sphilip	efx_word_t	length;			/* of header area (i.e. not including VPD) */
107227569Sphilip	efx_byte_t	version;
108227569Sphilip	efx_byte_t	csum;			/* over header area (i.e. not including VPD) */
109227569Sphilip	efx_dword_t	dynamic_vpd_offset;
110227569Sphilip	efx_dword_t	dynamic_vpd_length;
111227569Sphilip	efx_dword_t	num_fw_version_items;
112227569Sphilip	siena_mc_fw_version_t	fw_version[];
113227569Sphilip} siena_mc_dynamic_config_hdr_t;
114227569Sphilip
115227569Sphilip#define	SIENA_MC_EXPROM_SINGLE_MAGIC (0xAA55)  /* little-endian uint16_t */
116227569Sphilip
117227569Sphilip#define	SIENA_MC_EXPROM_COMBO_MAGIC (0xB0070102)  /* little-endian uint32_t */
118227569Sphilip
119227569Sphiliptypedef struct siena_mc_combo_rom_hdr_s {	/* GENERATED BY scripts/genfwdef */
120227569Sphilip	efx_dword_t	magic;			/* = SIENA_MC_EXPROM_COMBO_MAGIC */
121227569Sphilip	efx_dword_t	len1;			/* length of first image */
122227569Sphilip	efx_dword_t	len2;			/* length of second image */
123227569Sphilip	efx_dword_t	off1;			/* offset of first byte to edit to combine images */
124227569Sphilip	efx_dword_t	off2;			/* offset of second byte to edit to combine images */
125227569Sphilip	efx_word_t	infoblk0_off;		/* infoblk offset */
126227569Sphilip	efx_word_t	infoblk1_off;		/* infoblk offset */
127227569Sphilip	efx_byte_t	infoblk_len;		/* length of space reserved for infoblk structures */
128227569Sphilip	efx_byte_t	reserved[7];		/* (set to 0) */
129227569Sphilip} siena_mc_combo_rom_hdr_t;
130227569Sphilip
131227569Sphilip#pragma pack()
132227569Sphilip
133227569Sphilip#endif	/* _SYS_SIENA_FLASH_H */
134