xref: /freebsd/sys/dev/iwm/if_iwm_fw.h (revision 2e3f49888ec8851bafb22011533217487764fdb0)
1 /*-
2  * Based on BSD-licensed source modules in the Linux iwlwifi driver,
3  * which were used as the reference documentation for this implementation.
4  *
5  * Driver version we are currently based off of is
6  * Linux 4.7.3 (tag id d7f6728f57e3ecbb7ef34eb7d9f564d514775d75)
7  *
8  ***********************************************************************
9  *
10  * This file is provided under a dual BSD/GPLv2 license.  When using or
11  * redistributing this file, you may do so under either license.
12  *
13  * GPL LICENSE SUMMARY
14  *
15  * Copyright(c) 2008 - 2014 Intel Corporation. All rights reserved.
16  * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
17  * Copyright(c) 2016        Intel Deutschland GmbH
18  *
19  * This program is free software; you can redistribute it and/or modify
20  * it under the terms of version 2 of the GNU General Public License as
21  * published by the Free Software Foundation.
22  *
23  * This program is distributed in the hope that it will be useful, but
24  * WITHOUT ANY WARRANTY; without even the implied warranty of
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
26  * General Public License for more details.
27  *
28  * You should have received a copy of the GNU General Public License
29  * along with this program; if not, write to the Free Software
30  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
31  * USA
32  *
33  * The full GNU General Public License is included in this distribution
34  * in the file called COPYING.
35  *
36  * Contact Information:
37  *  Intel Linux Wireless <linuxwifi@intel.com>
38  * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
39  *
40  * BSD LICENSE
41  *
42  * Copyright(c) 2005 - 2014 Intel Corporation. All rights reserved.
43  * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
44  * Copyright(c) 2016        Intel Deutschland GmbH
45  * All rights reserved.
46  *
47  * Redistribution and use in source and binary forms, with or without
48  * modification, are permitted provided that the following conditions
49  * are met:
50  *
51  *  * Redistributions of source code must retain the above copyright
52  *    notice, this list of conditions and the following disclaimer.
53  *  * Redistributions in binary form must reproduce the above copyright
54  *    notice, this list of conditions and the following disclaimer in
55  *    the documentation and/or other materials provided with the
56  *    distribution.
57  *  * Neither the name Intel Corporation nor the names of its
58  *    contributors may be used to endorse or promote products derived
59  *    from this software without specific prior written permission.
60  *
61  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
62  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
63  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
64  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
65  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
66  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
67  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
68  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
69  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
70  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
71  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
72  */
73 /*
74  */
75 #ifndef	__IF_IWM_FW_H__
76 #define	__IF_IWM_FW_H__
77 
78 /*
79  * Block paging calculations
80  */
81 #define IWM_PAGE_2_EXP_SIZE 12 /* 4K == 2^12 */
82 #define IWM_FW_PAGING_SIZE (1 << IWM_PAGE_2_EXP_SIZE) /* page size is 4KB */
83 #define IWM_PAGE_PER_GROUP_2_EXP_SIZE 3
84 /* 8 pages per group */
85 #define IWM_NUM_OF_PAGE_PER_GROUP (1 << IWM_PAGE_PER_GROUP_2_EXP_SIZE)
86 /* don't change, support only 32KB size */
87 #define IWM_PAGING_BLOCK_SIZE (IWM_NUM_OF_PAGE_PER_GROUP * IWM_FW_PAGING_SIZE)
88 /* 32K == 2^15 */
89 #define IWM_BLOCK_2_EXP_SIZE (IWM_PAGE_2_EXP_SIZE + IWM_PAGE_PER_GROUP_2_EXP_SIZE)
90 
91 /*
92  * Image paging calculations
93  */
94 #define IWM_BLOCK_PER_IMAGE_2_EXP_SIZE 5
95 /* 2^5 == 32 blocks per image */
96 #define IWM_NUM_OF_BLOCK_PER_IMAGE (1 << IWM_BLOCK_PER_IMAGE_2_EXP_SIZE)
97 /* maximum image size 1024KB */
98 #define IWM_MAX_PAGING_IMAGE_SIZE (IWM_NUM_OF_BLOCK_PER_IMAGE * IWM_PAGING_BLOCK_SIZE)
99 
100 /* Virtual address signature */
101 #define IWM_PAGING_ADDR_SIG 0xAA000000
102 
103 #define IWM_PAGING_CMD_IS_SECURED (1 << 9)
104 #define IWM_PAGING_CMD_IS_ENABLED (1 << 8)
105 #define IWM_PAGING_CMD_NUM_OF_PAGES_IN_LAST_GRP_POS 0
106 #define IWM_PAGING_TLV_SECURE_MASK 1
107 
108 extern	void iwm_free_fw_paging(struct iwm_softc *);
109 extern	int iwm_save_fw_paging(struct iwm_softc *, const struct iwm_fw_img *);
110 extern	int iwm_send_paging_cmd(struct iwm_softc *, const struct iwm_fw_img *);
111 
112 #endif	/* __IF_IWM_FW_H__ */
113