0ef269563da2b109094a8312581ebd47deb84500
[platform/kernel/u-boot.git] / arch / arm / mach-imx / Makefile
1 # SPDX-License-Identifier: GPL-2.0+
2 #
3 # (C) Copyright 2000-2006
4 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 #
6 # (C) Copyright 2011 Freescale Semiconductor, Inc.
7
8 ifeq ($(SOC),$(filter $(SOC),mx25 mx35 mx5 mx6 mx7 imx8m vf610))
9 obj-y   = iomux-v3.o
10 endif
11
12 ifeq ($(SOC),$(filter $(SOC),imx8m))
13 ifneq ($(CONFIG_SPL_BUILD),y)
14 obj-$(CONFIG_IMX_BOOTAUX) += imx_bootaux.o
15 endif
16 obj-$(CONFIG_ENV_IS_IN_MMC) += mmc_env.o
17 obj-$(CONFIG_FEC_MXC) += mac.o
18 obj-$(CONFIG_SYS_I2C_MXC) += i2c-mxv7.o
19 obj-$(CONFIG_IMX_HAB) += hab.o
20 obj-y += cpu.o
21 endif
22
23 ifeq ($(SOC),$(filter $(SOC),mx5 mx6))
24 obj-y   += cpu.o speed.o
25 ifneq ($(CONFIG_MX51),y)
26 obj-y   += mmdc_size.o
27 endif
28 obj-$(CONFIG_GPT_TIMER) += timer.o
29 obj-$(CONFIG_SYS_I2C_MXC) += i2c-mxv7.o
30 endif
31 ifeq ($(SOC),$(filter $(SOC),mx7 mx6 mxs imx8m imx8 imxrt))
32 obj-y   += misc.o
33 obj-$(CONFIG_CMD_PRIBLOB) += priblob.o
34 obj-$(CONFIG_SPL_BUILD) += spl.o
35 endif
36 ifeq ($(SOC),$(filter $(SOC),mx7))
37 obj-y   += cpu.o
38 obj-$(CONFIG_SYS_I2C_MXC) += i2c-mxv7.o
39 obj-$(CONFIG_ENV_IS_IN_MMC) += mmc_env.o
40 obj-$(CONFIG_FSL_MFGPROT) += cmd_mfgprot.o
41 endif
42 ifeq ($(SOC),$(filter $(SOC),mx5 mx6 mx7))
43 obj-$(CONFIG_IMX_VIDEO_SKIP) += video.o
44 endif
45 ifeq ($(SOC),$(filter $(SOC),mx6 mx7))
46 obj-y   += cache.o init.o
47 obj-$(CONFIG_FEC_MXC) += mac.o
48 obj-$(CONFIG_IMX_RDC) += rdc-sema.o
49 ifneq ($(CONFIG_SPL_BUILD),y)
50 obj-$(CONFIG_IMX_BOOTAUX) += imx_bootaux.o
51 endif
52 obj-$(CONFIG_SATA) += sata.o
53 obj-$(CONFIG_IMX_HAB)    += hab.o
54 obj-$(CONFIG_SYSCOUNTER_TIMER) += syscounter.o
55 endif
56 ifeq ($(SOC),$(filter $(SOC),mx7ulp))
57 obj-y  += cache.o mmdc_size.o
58 obj-$(CONFIG_IMX_HAB) += hab.o
59 endif
60 ifeq ($(SOC),$(filter $(SOC),vf610))
61 obj-y += ddrmc-vf610.o
62 obj-$(CONFIG_DDRMC_VF610_CALIBRATION) += ddrmc-vf610-calibration.o
63 endif
64 ifneq ($(CONFIG_SPL_BUILD),y)
65 obj-$(CONFIG_CMD_BMODE) += cmd_bmode.o
66 obj-$(CONFIG_CMD_HDMIDETECT) += cmd_hdmidet.o
67 obj-$(CONFIG_CMD_DEKBLOB) += cmd_dek.o
68 obj-$(CONFIG_CMD_NANDBCB) += cmd_nandbcb.o
69 endif
70
71 ifeq ($(CONFIG_SPL_BUILD),y)
72 obj-$(CONFIG_SPL_LOAD_IMX_CONTAINER) += image-container.o parse-container.o
73 endif
74
75 PLUGIN = board/$(BOARDDIR)/plugin
76
77 ifeq ($(CONFIG_USE_IMXIMG_PLUGIN),y)
78
79 $(PLUGIN).o: $(PLUGIN).S FORCE
80         $(Q)mkdir -p $(dir $@)
81         $(call if_changed_dep,as_o_S)
82
83 $(PLUGIN).bin: $(PLUGIN).o FORCE
84         $(Q)mkdir -p $(dir $@)
85         $(OBJCOPY) -O binary --gap-fill 0xff $< $@
86 else
87
88 $(PLUGIN).bin:
89
90 endif
91
92 quiet_cmd_cpp_cfg = CFGS    $@
93       cmd_cpp_cfg = $(CPP) $(cpp_flags) -x c -o $@ $<
94
95 # mkimage source config file
96 IMX_CONFIG = $(CONFIG_IMX_CONFIG:"%"=%)
97
98 # How to create a cpp processed config file, they all use the same source
99 %.cfgout: $(IMX_CONFIG) FORCE
100         $(Q)mkdir -p $(dir $@)
101         $(call if_changed_dep,cpp_cfg)
102
103 IMX_CONTAINER_CFG = $(CONFIG_IMX_CONTAINER_CFG:"%"=%)
104 container.cfg: $(IMX_CONTAINER_CFG) FORCE
105         $(Q)mkdir -p $(dir $@)
106         $(call if_changed_dep,cpp_cfg)
107
108 ifeq ($(CONFIG_ARCH_IMX8), y)
109 CNTR_DEPFILES := $(srctree)/tools/imx_cntr_image.sh
110 IMAGE_TYPE := imx8image
111 ifeq ($(CONFIG_SPL_BUILD),y)
112 SPL_DEPFILE_EXISTS := $(shell $(CPP) $(cpp_flags) -x c -o spl/u-boot-spl.cfgout $(srctree)/$(IMX_CONFIG); if [ -f spl/u-boot-spl.cfgout ]; then $(CNTR_DEPFILES) spl/u-boot-spl.cfgout; echo $$?; fi)
113 endif
114 DEPFILE_EXISTS := $(shell $(CPP) $(cpp_flags) -x c -o u-boot-dtb.cfgout $(srctree)/$(IMX_CONFIG); if [ -f u-boot-dtb.cfgout ]; then $(CNTR_DEPFILES) u-boot-dtb.cfgout; echo $$?; fi)
115 else ifeq ($(CONFIG_ARCH_IMX8M), y)
116 IMAGE_TYPE := imx8mimage
117 IMX8M_DEPFILES := $(srctree)/tools/imx8m_image.sh
118 DEPFILE_EXISTS := $(shell $(CPP) $(cpp_flags) -x c -o spl/u-boot-spl.cfgout $(srctree)/$(IMX_CONFIG);if [ -f spl/u-boot-spl.cfgout ]; then $(IMX8M_DEPFILES) spl/u-boot-spl.cfgout 0; echo $$?; fi)
119 else
120 IMAGE_TYPE := imximage
121 DEPFILE_EXISTS := 0
122 endif
123
124 MKIMAGEFLAGS_u-boot.imx = -n $(filter-out $(PLUGIN).bin $< $(PHONY),$^) \
125         -T $(IMAGE_TYPE) -e $(CONFIG_SYS_TEXT_BASE)
126 u-boot.imx: MKIMAGEOUTPUT = u-boot.imx.log
127
128 u-boot.imx: u-boot.bin u-boot.cfgout $(PLUGIN).bin FORCE
129         $(call if_changed,mkimage)
130
131 ifeq ($(CONFIG_MULTI_DTB_FIT),y)
132 MKIMAGEFLAGS_u-boot-dtb.imx = -n $(filter-out $(PLUGIN).bin $< $(PHONY),$^) \
133         -T $(IMAGE_TYPE) -e $(CONFIG_SYS_TEXT_BASE)
134 u-boot-dtb.imx: MKIMAGEOUTPUT = u-boot-dtb.imx.log
135
136 u-boot-dtb.imx: u-boot-fit-dtb.bin u-boot-dtb.cfgout $(PLUGIN).bin FORCE
137 ifeq ($(DEPFILE_EXISTS),0)
138         $(call if_changed,mkimage)
139 endif
140 else ifeq ($(CONFIG_OF_SEPARATE),y)
141 MKIMAGEFLAGS_u-boot-dtb.imx = -n $(filter-out $(PLUGIN).bin $< $(PHONY),$^) \
142         -T $(IMAGE_TYPE) -e $(CONFIG_SYS_TEXT_BASE)
143 u-boot-dtb.imx: MKIMAGEOUTPUT = u-boot-dtb.imx.log
144
145 u-boot-dtb.imx: u-boot-dtb.bin u-boot-dtb.cfgout $(PLUGIN).bin FORCE
146 ifeq ($(DEPFILE_EXISTS),0)
147         $(call if_changed,mkimage)
148 endif
149 endif
150
151 ifdef CONFIG_ARM64
152 ifeq ($(CONFIG_ARCH_IMX8M), y)
153 SPL:
154
155 MKIMAGEFLAGS_flash.bin = -n spl/u-boot-spl.cfgout \
156                    -T $(IMAGE_TYPE) -e $(CONFIG_SPL_TEXT_BASE)
157 flash.bin: MKIMAGEOUTPUT = flash.log
158
159 spl/u-boot-spl-ddr.bin: spl/u-boot-spl.bin spl/u-boot-spl.cfgout FORCE
160 ifeq ($(DEPFILE_EXISTS),0)
161         $(IMX8M_DEPFILES) spl/u-boot-spl.cfgout 1
162 endif
163
164 flash.bin: spl/u-boot-spl-ddr.bin u-boot.itb FORCE
165         $(call if_changed,mkimage)
166 endif
167
168 ifeq ($(CONFIG_ARCH_IMX8), y)
169 SPL:
170
171 MKIMAGEFLAGS_flash.bin = -n spl/u-boot-spl.cfgout -T $(IMAGE_TYPE) -e 0x100000
172 flash.bin: MKIMAGEOUTPUT = flash.log
173
174 MKIMAGEFLAGS_u-boot.cnt = -n container.cfg -T $(IMAGE_TYPE) -e 0x100000
175 u-boot.cnt: MKIMAGEOUTPUT = u-boot.cnt.log
176
177 ifeq ($(CONFIG_SPL_LOAD_IMX_CONTAINER), y)
178 u-boot.cnt: u-boot.bin container.cfg FORCE
179         $(call if_changed,mkimage)
180 flash.bin: spl/u-boot-spl.bin FORCE
181         $(call if_changed,mkimage)
182         @flashbin_size=`wc -c flash.bin | awk '{print $$1}'`; \
183                    pad_cnt=$$(((flashbin_size + 0x400 - 1) / 0x400)); \
184                    echo "append u-boot.cnt at $$pad_cnt KB"; \
185                    dd if=u-boot.cnt of=flash.bin bs=1K seek=$$pad_cnt;
186 else
187 flash.bin: spl/u-boot-spl.bin FORCE
188         $(call if_changed,mkimage)
189 endif
190 endif
191
192 else
193 MKIMAGEFLAGS_SPL = -n $(filter-out $(PLUGIN).bin $< $(PHONY),$^) \
194                    -T $(IMAGE_TYPE) -e $(CONFIG_SPL_TEXT_BASE)
195 SPL: MKIMAGEOUTPUT = SPL.log
196
197 SPL: spl/u-boot-spl.bin spl/u-boot-spl.cfgout $(PLUGIN).bin FORCE
198         $(call if_changed,mkimage)
199
200 MKIMAGEFLAGS_u-boot.uim = -A arm -O U-Boot -a $(CONFIG_SYS_TEXT_BASE) \
201                 -e $(CONFIG_SYS_TEXT_BASE) -C none -T firmware
202
203 u-boot.uim: u-boot.bin FORCE
204         $(call if_changed,mkimage)
205
206 OBJCOPYFLAGS += -I binary -O binary --pad-to=$(CONFIG_SPL_PAD_TO)
207 append = cat $(filter-out $< $(PHONY), $^) >> $@
208
209 quiet_cmd_pad_cat = CAT     $@
210 cmd_pad_cat = $(cmd_objcopy) && $(append) || rm -f $@
211
212 u-boot-with-spl.imx: SPL $(if $(CONFIG_OF_SEPARATE),u-boot.img,u-boot.uim) FORCE
213         $(call if_changed,pad_cat)
214
215 u-boot-with-nand-spl.imx: spl/u-boot-nand-spl.imx $(if $(CONFIG_OF_SEPARATE),u-boot.img,u-boot.uim) FORCE
216         $(call if_changed,pad_cat)
217
218 quiet_cmd_u-boot-nand-spl_imx = GEN     $@
219 cmd_u-boot-nand-spl_imx = (printf '\000\000\000\000\106\103\102\040\001' && \
220         dd bs=1015 count=1 if=/dev/zero 2>/dev/null) | cat - $< > $@
221
222 spl/u-boot-nand-spl.imx: SPL FORCE
223         $(call if_changed,u-boot-nand-spl_imx)
224 endif
225
226 targets += $(addprefix ../../../,SPL spl/u-boot-spl.cfgout u-boot-dtb.cfgout u-boot.cfgout u-boot.uim spl/u-boot-nand-spl.imx)
227
228 obj-$(CONFIG_ARM64) += lowlevel.o
229
230 obj-$(CONFIG_MX5) += mx5/
231 obj-$(CONFIG_MX6) += mx6/
232 obj-$(CONFIG_MX7) += mx7/
233 obj-$(CONFIG_ARCH_MX7ULP) += mx7ulp/
234 obj-$(CONFIG_ARCH_IMX8ULP) += imx8ulp/
235 obj-$(CONFIG_IMX8M) += imx8m/
236 obj-$(CONFIG_ARCH_IMX8) += imx8/
237 obj-$(CONFIG_ARCH_IMXRT) += imxrt/
238
239 obj-$(CONFIG_SPL_BOOTROM_SUPPORT) += spl_imx_romapi.o