Merge branch 'v2021.07-rc1' of https://github.com/lftan/u-boot
[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 PLUGIN = board/$(BOARDDIR)/plugin
72
73 ifeq ($(CONFIG_USE_IMXIMG_PLUGIN),y)
74
75 $(PLUGIN).o: $(PLUGIN).S FORCE
76         $(Q)mkdir -p $(dir $@)
77         $(call if_changed_dep,as_o_S)
78
79 $(PLUGIN).bin: $(PLUGIN).o FORCE
80         $(Q)mkdir -p $(dir $@)
81         $(OBJCOPY) -O binary --gap-fill 0xff $< $@
82 else
83
84 $(PLUGIN).bin:
85
86 endif
87
88 quiet_cmd_cpp_cfg = CFGS    $@
89       cmd_cpp_cfg = $(CPP) $(cpp_flags) -x c -o $@ $<
90
91 # mkimage source config file
92 IMX_CONFIG = $(CONFIG_IMX_CONFIG:"%"=%)
93
94 # How to create a cpp processed config file, they all use the same source
95 %.cfgout: $(IMX_CONFIG) FORCE
96         $(Q)mkdir -p $(dir $@)
97         $(call if_changed_dep,cpp_cfg)
98
99 IMX_CONTAINER_CFG = $(CONFIG_IMX_CONTAINER_CFG:"%"=%)
100 container.cfg: $(IMX_CONTAINER_CFG) FORCE
101         $(Q)mkdir -p $(dir $@)
102         $(call if_changed_dep,cpp_cfg)
103
104 ifeq ($(CONFIG_ARCH_IMX8), y)
105 CNTR_DEPFILES := $(srctree)/tools/imx_cntr_image.sh
106 IMAGE_TYPE := imx8image
107 ifeq ($(CONFIG_SPL_BUILD),y)
108 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)
109 endif
110 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)
111 else ifeq ($(CONFIG_ARCH_IMX8M), y)
112 IMAGE_TYPE := imx8mimage
113 IMX8M_DEPFILES := $(srctree)/tools/imx8m_image.sh
114 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)
115 else
116 IMAGE_TYPE := imximage
117 DEPFILE_EXISTS := 0
118 endif
119
120 MKIMAGEFLAGS_u-boot.imx = -n $(filter-out $(PLUGIN).bin $< $(PHONY),$^) \
121         -T $(IMAGE_TYPE) -e $(CONFIG_SYS_TEXT_BASE)
122 u-boot.imx: MKIMAGEOUTPUT = u-boot.imx.log
123
124 u-boot.imx: u-boot.bin u-boot.cfgout $(PLUGIN).bin FORCE
125         $(call if_changed,mkimage)
126
127 ifeq ($(CONFIG_MULTI_DTB_FIT),y)
128 MKIMAGEFLAGS_u-boot-dtb.imx = -n $(filter-out $(PLUGIN).bin $< $(PHONY),$^) \
129         -T $(IMAGE_TYPE) -e $(CONFIG_SYS_TEXT_BASE)
130 u-boot-dtb.imx: MKIMAGEOUTPUT = u-boot-dtb.imx.log
131
132 u-boot-dtb.imx: u-boot-fit-dtb.bin u-boot-dtb.cfgout $(PLUGIN).bin FORCE
133 ifeq ($(DEPFILE_EXISTS),0)
134         $(call if_changed,mkimage)
135 endif
136 else ifeq ($(CONFIG_OF_SEPARATE),y)
137 MKIMAGEFLAGS_u-boot-dtb.imx = -n $(filter-out $(PLUGIN).bin $< $(PHONY),$^) \
138         -T $(IMAGE_TYPE) -e $(CONFIG_SYS_TEXT_BASE)
139 u-boot-dtb.imx: MKIMAGEOUTPUT = u-boot-dtb.imx.log
140
141 u-boot-dtb.imx: u-boot-dtb.bin u-boot-dtb.cfgout $(PLUGIN).bin FORCE
142 ifeq ($(DEPFILE_EXISTS),0)
143         $(call if_changed,mkimage)
144 endif
145 endif
146
147 ifdef CONFIG_ARM64
148 ifeq ($(CONFIG_ARCH_IMX8M), y)
149 SPL:
150
151 MKIMAGEFLAGS_flash.bin = -n spl/u-boot-spl.cfgout \
152                    -T $(IMAGE_TYPE) -e $(CONFIG_SPL_TEXT_BASE)
153 flash.bin: MKIMAGEOUTPUT = flash.log
154
155 spl/u-boot-spl-ddr.bin: spl/u-boot-spl.bin spl/u-boot-spl.cfgout FORCE
156 ifeq ($(DEPFILE_EXISTS),0)
157         $(IMX8M_DEPFILES) spl/u-boot-spl.cfgout 1
158 endif
159
160 flash.bin: spl/u-boot-spl-ddr.bin u-boot.itb FORCE
161         $(call if_changed,mkimage)
162 endif
163
164 ifeq ($(CONFIG_ARCH_IMX8), y)
165 SPL:
166
167 MKIMAGEFLAGS_flash.bin = -n spl/u-boot-spl.cfgout -T $(IMAGE_TYPE) -e 0x100000
168 flash.bin: MKIMAGEOUTPUT = flash.log
169
170 MKIMAGEFLAGS_u-boot.cnt = -n container.cfg -T $(IMAGE_TYPE) -e 0x100000
171 u-boot.cnt: MKIMAGEOUTPUT = u-boot.cnt.log
172
173 ifeq ($(CONFIG_SPL_LOAD_IMX_CONTAINER), y)
174 u-boot.cnt: u-boot.bin container.cfg FORCE
175         $(call if_changed,mkimage)
176 flash.bin: spl/u-boot-spl.bin FORCE
177         $(call if_changed,mkimage)
178         @flashbin_size=`wc -c flash.bin | awk '{print $$1}'`; \
179                    pad_cnt=$$(((flashbin_size + 0x400 - 1) / 0x400)); \
180                    echo "append u-boot.cnt at $$pad_cnt KB"; \
181                    dd if=u-boot.cnt of=flash.bin bs=1K seek=$$pad_cnt;
182 else
183 flash.bin: spl/u-boot-spl.bin FORCE
184         $(call if_changed,mkimage)
185 endif
186 endif
187
188 else
189 MKIMAGEFLAGS_SPL = -n $(filter-out $(PLUGIN).bin $< $(PHONY),$^) \
190                    -T $(IMAGE_TYPE) -e $(CONFIG_SPL_TEXT_BASE)
191 SPL: MKIMAGEOUTPUT = SPL.log
192
193 SPL: spl/u-boot-spl.bin spl/u-boot-spl.cfgout $(PLUGIN).bin FORCE
194         $(call if_changed,mkimage)
195
196 MKIMAGEFLAGS_u-boot.uim = -A arm -O U-Boot -a $(CONFIG_SYS_TEXT_BASE) \
197                 -e $(CONFIG_SYS_TEXT_BASE) -C none -T firmware
198
199 u-boot.uim: u-boot.bin FORCE
200         $(call if_changed,mkimage)
201
202 OBJCOPYFLAGS += -I binary -O binary --pad-to=$(CONFIG_SPL_PAD_TO)
203 append = cat $(filter-out $< $(PHONY), $^) >> $@
204
205 quiet_cmd_pad_cat = CAT     $@
206 cmd_pad_cat = $(cmd_objcopy) && $(append) || rm -f $@
207
208 u-boot-with-spl.imx: SPL $(if $(CONFIG_OF_SEPARATE),u-boot.img,u-boot.uim) FORCE
209         $(call if_changed,pad_cat)
210
211 u-boot-with-nand-spl.imx: spl/u-boot-nand-spl.imx $(if $(CONFIG_OF_SEPARATE),u-boot.img,u-boot.uim) FORCE
212         $(call if_changed,pad_cat)
213
214 quiet_cmd_u-boot-nand-spl_imx = GEN     $@
215 cmd_u-boot-nand-spl_imx = (printf '\000\000\000\000\106\103\102\040\001' && \
216         dd bs=1015 count=1 if=/dev/zero 2>/dev/null) | cat - $< > $@
217
218 spl/u-boot-nand-spl.imx: SPL FORCE
219         $(call if_changed,u-boot-nand-spl_imx)
220 endif
221
222 targets += $(addprefix ../../../,SPL spl/u-boot-spl.cfgout u-boot-dtb.cfgout u-boot.cfgout u-boot.uim spl/u-boot-nand-spl.imx)
223
224 obj-$(CONFIG_ARM64) += lowlevel.o
225
226 obj-$(CONFIG_MX5) += mx5/
227 obj-$(CONFIG_MX6) += mx6/
228 obj-$(CONFIG_MX7) += mx7/
229 obj-$(CONFIG_ARCH_MX7ULP) += mx7ulp/
230 obj-$(CONFIG_IMX8M) += imx8m/
231 obj-$(CONFIG_ARCH_IMX8) += imx8/
232 obj-$(CONFIG_ARCH_IMXRT) += imxrt/
233
234 obj-$(CONFIG_SPL_BOOTROM_SUPPORT) += spl_imx_romapi.o