ath9k_htc: Update to upstream's commit d19607454d656cb14d8c16dfbf161eebb542e8fe dated...
[linux-libre-firmware.git] / ath9k_htc / target_firmware / CMakeLists.txt
1 ##
2  # Copyright (c) 2013 Qualcomm Atheros, Inc.
3  #
4  # All rights reserved.
5  #
6  # Redistribution and use in source and binary forms, with or without
7  # modification, are permitted (subject to the limitations in the
8  # disclaimer below) provided that the following conditions are met:
9  #
10  #  * Redistributions of source code must retain the above copyright
11  #    notice, this list of conditions and the following disclaimer.
12  #
13  #  * Redistributions in binary form must reproduce the above copyright
14  #    notice, this list of conditions and the following disclaimer in the
15  #    documentation and/or other materials provided with the
16  #    distribution.
17  #
18  #  * Neither the name of Qualcomm Atheros nor the names of its
19  #    contributors may be used to endorse or promote products derived
20  #    from this software without specific prior written permission.
21  #
22  # NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
23  # GRANTED BY THIS LICENSE.  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
24  # HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
25  # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
26  # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27  # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
28  # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29  # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30  # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
31  # BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
32  # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
33  # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
34  # IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35  ##
36
37 SET(CMAKE_C_COMPILER_WORKS 1)
38
39 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
40 PROJECT(ath9k_firmware NONE)
41 ENABLE_LANGUAGE(C)
42
43 ADD_DEFINITIONS(
44         -g -Os
45         -Wunused-label
46         -Wunused-variable
47         -Wunused-value
48         -Wpointer-arith
49         -nostdlib
50         -Wundef
51         -Wunused-but-set-variable
52         -Wmaybe-uninitialized
53 )
54 ADD_DEFINITIONS(
55         -D_RAM_
56         -DBIG_ENDIAN -D_BYTE_ORDER=_BIG_ENDIAN
57         -D__XTENSA__
58         -DFUSION_USB_FW -DRX_SCATTER
59         -DFUSION_USB_ENABLE_TX_STREAM -DFUSION_USB_ENABLE_RX_STREAM
60         -DATH_ENABLE_CABQ
61 )
62
63 SET(SOURCES
64         magpie_fw_dev/target/init/app_start.c
65         magpie_fw_dev/target/init/init.c
66         magpie_fw_dev/target/init/magpie.c
67         magpie_fw_dev/target/adf/adf_nbuf.c
68         magpie_fw_dev/target/adf/adf_net.c
69         magpie_fw_dev/target/adf/adf_os_defer_pvt.c
70         magpie_fw_dev/target/adf/adf_os_dma.c
71         magpie_fw_dev/target/adf/adf_os_irq_pvt.c
72         magpie_fw_dev/target/adf/adf_os_timer.c
73         magpie_fw_dev/target/buf_pool/buf_pool_static.c
74         magpie_fw_dev/target/cmnos/dbg_api.c
75         magpie_fw_dev/target/cmnos/cmnos_sflash.c
76         magpie_fw_dev/target/hif/usb_api_main_patch.c
77         wlan/ah.c
78         wlan/ah_osdep.c
79         wlan/ar5416Phy.c
80         wlan/ar5416_hw.c
81         wlan/ar5416_phy.c
82         wlan/ratectrl_11n_ln.c
83         wlan/if_owl.c
84         wlan/if_ath.c
85         wlan/if_ath_pci.c
86         magpie_fw_dev/target/wlan/wlan_pci.c
87         wlan/ieee80211_output.c
88         magpie_fw_dev/target/htc/htc.c
89         magpie_fw_dev/target/wmi/wmi_svc.c
90 )
91
92 IF(TARGET_K2)
93         SET(SOURCES ${SOURCES}
94                 magpie_fw_dev/target/hif/k2_HIF_usb_patch.c
95                 magpie_fw_dev/target/hif/usb_api_k2_patch.c
96         )
97         SET(LIBS ${LIBS} hif)
98         ADD_DEFINITIONS(-DPROJECT_K2)
99         SET(PLATFORM_NAME k2)
100         SET(SOURCES ${SOURCES}
101                 magpie_fw_dev/target/cmnos/k2_cmnos_clock_patch.c
102                 magpie_fw_dev/target/cmnos/k2_fw_cmnos_printf.c
103         )
104         SET(FIRMWARE_NAME htc_9271.fw)
105 ELSEIF(TARGET_MAGPIE)
106         ADD_DEFINITIONS(
107                 -DROM_VER_1_1 -D_ROM_1_1_
108                 -DPROJECT_MAGPIE
109                 -DMAGPIE_MERLIN
110         )
111         SET(SOURCES ${SOURCES}
112                 magpie_fw_dev/target/hif/usb_api_magpie_patch.c
113                 magpie_fw_dev/target/rompatch/cmnos_clock_patch.c
114                 magpie_fw_dev/target/rompatch/HIF_usb_patch.c
115         )
116         INCLUDE_DIRECTORIES(
117                 ${CMAKE_SOURCE_DIR}/magpie_fw_dev/target/adf
118         )
119         SET(PLATFORM_NAME magpie)
120         SET(FIRMWARE_NAME htc_7010.fw)
121 ELSE()
122         MESSAGE(FATAL_ERROR "Unknown target name")
123 ENDIF()
124
125 INCLUDE_DIRECTORIES(
126         ${CMAKE_SOURCE_DIR}/include
127         ${CMAKE_SOURCE_DIR}/magpie_fw_dev/target/
128         ${CMAKE_SOURCE_DIR}/magpie_fw_dev/target/inc
129         ${CMAKE_SOURCE_DIR}/magpie_fw_dev/target/inc/xtensa-elf
130         ${CMAKE_SOURCE_DIR}/magpie_fw_dev/target/inc/${PLATFORM_NAME}
131         ${CMAKE_SOURCE_DIR}/magpie_fw_dev/target/inc/${PLATFORM_NAME}/${PLATFORM_NAME}
132         ${CMAKE_SOURCE_DIR}/wlan
133         ${CMAKE_SOURCE_DIR}/wlan/include
134         ${CMAKE_SOURCE_DIR}/wlan/include/${PLATFORM_NAME}
135         ${CMAKE_SOURCE_DIR}/magpie_fw_dev/target/wlan
136         ${CMAKE_SOURCE_DIR}/magpie_fw_dev/target/cmnos
137         ${CMAKE_SOURCE_DIR}/magpie_fw_dev/target/wmi
138         ${CMAKE_SOURCE_DIR}/magpie_fw_dev/target/adf
139         ${CMAKE_SOURCE_DIR}/magpie_fw_dev/target/buf_pool
140         ${CMAKE_SOURCE_DIR}/magpie_fw_dev/target/htc
141 )
142
143 ADD_LIBRARY(firmware ${SOURCES})
144
145 ADD_CUSTOM_COMMAND(
146         OUTPUT fw.elf
147         DEPENDS firmware
148         COMMAND ${CMAKE_C_COMPILER}
149                 -nostdlib
150                 -fno-lto
151                 -Wl,--start-group
152                 ${CMAKE_BINARY_DIR}/libfirmware.a
153                 -Wl,--end-group
154                 -Wl,-T,${CMAKE_SOURCE_DIR}/ram-${PLATFORM_NAME}.ld
155                 -Wl,-T,${CMAKE_SOURCE_DIR}/rom-addrs-${PLATFORM_NAME}.ld
156                 -o fw.elf
157 )
158 ADD_CUSTOM_COMMAND(
159         OUTPUT fw.bin
160         DEPENDS fw.elf
161         COMMAND ${CMAKE_OBJCOPY}
162                 --change-section-lma .boot-0x400000
163                 --change-section-vma .boot-0x400000
164                 --change-section-lma .text-0x400000
165                 --change-section-vma .text-0x400000
166                 -O binary fw.elf fw.bin
167 )
168 ADD_CUSTOM_COMMAND(
169         OUTPUT ${FIRMWARE_NAME}
170         DEPENDS fw.bin
171         COMMAND ${CMAKE_SOURCE_DIR}/firmware-crc.pl < fw.bin > ${FIRMWARE_NAME}
172 )
173 ADD_CUSTOM_TARGET(gen-firmware ALL DEPENDS ${FIRMWARE_NAME})