6351abb18518d5ed87c62554cc7a3bbd588b069f
[oweals/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 obj-$(CONFIG_IMX_BOOTAUX) += imx_bootaux.o
14 obj-$(CONFIG_ENV_IS_IN_MMC) += mmc_env.o
15 obj-$(CONFIG_FEC_MXC) += mac.o
16 obj-$(CONFIG_SYS_I2C_MXC) += i2c-mxv7.o
17 obj-y += cpu.o
18 endif
19
20 ifeq ($(SOC),$(filter $(SOC),mx5 mx6))
21 obj-y   += cpu.o speed.o
22 obj-$(CONFIG_GPT_TIMER) += timer.o
23 obj-$(CONFIG_SYS_I2C_MXC) += i2c-mxv7.o
24 endif
25 ifeq ($(SOC),$(filter $(SOC),mx7 mx6 mxs imx8m))
26 obj-y   += misc.o
27 obj-$(CONFIG_SPL_BUILD) += spl.o
28 endif
29 ifeq ($(SOC),$(filter $(SOC),mx7))
30 obj-y   += cpu.o
31 obj-$(CONFIG_SYS_I2C_MXC) += i2c-mxv7.o
32 obj-$(CONFIG_ENV_IS_IN_MMC) += mmc_env.o
33 endif
34 ifeq ($(SOC),$(filter $(SOC),mx5 mx6 mx7))
35 obj-$(CONFIG_IMX_VIDEO_SKIP) += video.o
36 endif
37 ifeq ($(SOC),$(filter $(SOC),mx6 mx7))
38 obj-y   += cache.o init.o
39 obj-$(CONFIG_FEC_MXC) += mac.o
40 obj-$(CONFIG_IMX_RDC) += rdc-sema.o
41 ifneq ($(CONFIG_SPL_BUILD),y)
42 obj-$(CONFIG_IMX_BOOTAUX) += imx_bootaux.o
43 endif
44 obj-$(CONFIG_SATA) += sata.o
45 obj-$(CONFIG_SECURE_BOOT)    += hab.o
46 obj-$(CONFIG_SYSCOUNTER_TIMER) += syscounter.o
47 endif
48 ifeq ($(SOC),$(filter $(SOC),mx7ulp))
49 obj-y  += cache.o
50 obj-$(CONFIG_SECURE_BOOT) += hab.o
51 endif
52 ifeq ($(SOC),$(filter $(SOC),vf610))
53 obj-y += ddrmc-vf610.o
54 endif
55 ifneq ($(CONFIG_SPL_BUILD),y)
56 obj-$(CONFIG_CMD_BMODE) += cmd_bmode.o
57 obj-$(CONFIG_CMD_HDMIDETECT) += cmd_hdmidet.o
58 obj-$(CONFIG_CMD_DEKBLOB) += cmd_dek.o
59 endif
60
61 ifneq ($(CONFIG_BOARD_SIZE_LIMIT),)
62 BOARD_SIZE_CHECK = \
63         @actual=`wc -c $@ | awk '{print $$1}'`; \
64         limit=`printf "%d" $(CONFIG_BOARD_SIZE_LIMIT)`; \
65         if test $$actual -gt $$limit; then \
66                 echo "$@ exceeds file size limit:" >&2 ; \
67                 echo "  limit:  $$limit bytes" >&2 ; \
68                 echo "  actual: $$actual bytes" >&2 ; \
69                 echo "  excess: $$((actual - limit)) bytes" >&2; \
70                 exit 1; \
71         fi
72 else
73 BOARD_SIZE_CHECK =
74 endif
75
76 PLUGIN = board/$(BOARDDIR)/plugin
77
78 ifeq ($(CONFIG_USE_IMXIMG_PLUGIN),y)
79
80 $(PLUGIN).o: $(PLUGIN).S FORCE
81         $(Q)mkdir -p $(dir $@)
82         $(call if_changed_dep,as_o_S)
83
84 $(PLUGIN).bin: $(PLUGIN).o FORCE
85         $(Q)mkdir -p $(dir $@)
86         $(OBJCOPY) -O binary --gap-fill 0xff $< $@
87 else
88
89 $(PLUGIN).bin:
90
91 endif
92
93 quiet_cmd_cpp_cfg = CFGS    $@
94       cmd_cpp_cfg = $(CPP) $(cpp_flags) -x c -o $@ $<
95
96 # mkimage source config file
97 IMX_CONFIG = $(CONFIG_IMX_CONFIG:"%"=%)
98
99 # How to create a cpp processed config file, they all use the same source
100 %.cfgout: $(IMX_CONFIG) 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 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)
108 else ifeq ($(CONFIG_ARCH_IMX8M), y)
109 IMAGE_TYPE := imx8mimage
110 IMX8M_DEPFILES := $(srctree)/tools/imx8m_image.sh
111 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)
112 else
113 IMAGE_TYPE := imximage
114 DEPFILE_EXISTS := 0
115 endif
116
117 MKIMAGEFLAGS_u-boot.imx = -n $(filter-out $(PLUGIN).bin $< $(PHONY),$^) \
118         -T $(IMAGE_TYPE) -e $(CONFIG_SYS_TEXT_BASE)
119 u-boot.imx: MKIMAGEOUTPUT = u-boot.imx.log
120
121 u-boot.imx: u-boot.bin u-boot.cfgout $(PLUGIN).bin FORCE
122         $(call if_changed,mkimage)
123         $(BOARD_SIZE_CHECK)
124
125 ifeq ($(CONFIG_OF_SEPARATE),y)
126 MKIMAGEFLAGS_u-boot-dtb.imx = -n $(filter-out $(PLUGIN).bin $< $(PHONY),$^) \
127         -T $(IMAGE_TYPE) -e $(CONFIG_SYS_TEXT_BASE)
128 u-boot-dtb.imx: MKIMAGEOUTPUT = u-boot-dtb.imx.log
129
130 u-boot-dtb.imx: u-boot-dtb.bin u-boot-dtb.cfgout $(PLUGIN).bin FORCE
131 ifeq ($(DEPFILE_EXISTS),0)
132         $(call if_changed,mkimage)
133 endif
134 endif
135
136 ifdef CONFIG_ARM64
137 ifeq ($(CONFIG_ARCH_IMX8M), y)
138 SPL:
139
140 MKIMAGEFLAGS_flash.bin = -n spl/u-boot-spl.cfgout \
141                    -T $(IMAGE_TYPE) -e $(CONFIG_SPL_TEXT_BASE)
142 flash.bin: MKIMAGEOUTPUT = flash.log
143
144 spl/u-boot-spl-ddr.bin: spl/u-boot-spl.bin spl/u-boot-spl.cfgout FORCE
145 ifeq ($(DEPFILE_EXISTS),0)
146         $(IMX8M_DEPFILES) spl/u-boot-spl.cfgout 1
147 endif
148
149 flash.bin: spl/u-boot-spl-ddr.bin u-boot.itb FORCE
150 ifeq ($(DEPFILE_EXISTS),0)
151         $(call if_changed,mkimage)
152 endif
153 endif
154
155 else
156 MKIMAGEFLAGS_SPL = -n $(filter-out $(PLUGIN).bin $< $(PHONY),$^) \
157                    -T $(IMAGE_TYPE) -e $(CONFIG_SPL_TEXT_BASE)
158 SPL: MKIMAGEOUTPUT = SPL.log
159
160 SPL: spl/u-boot-spl.bin spl/u-boot-spl.cfgout $(PLUGIN).bin FORCE
161         $(call if_changed,mkimage)
162
163 MKIMAGEFLAGS_u-boot.uim = -A arm -O U-Boot -a $(CONFIG_SYS_TEXT_BASE) \
164                 -e $(CONFIG_SYS_TEXT_BASE) -C none -T firmware
165
166 u-boot.uim: u-boot.bin FORCE
167         $(call if_changed,mkimage)
168
169 OBJCOPYFLAGS += -I binary -O binary --pad-to=$(CONFIG_SPL_PAD_TO)
170 append = cat $(filter-out $< $(PHONY), $^) >> $@
171
172 quiet_cmd_pad_cat = CAT     $@
173 cmd_pad_cat = $(cmd_objcopy) && $(append) || rm -f $@
174
175 u-boot-with-spl.imx: SPL u-boot.uim FORCE
176         $(call if_changed,pad_cat)
177
178 u-boot-with-nand-spl.imx: spl/u-boot-nand-spl.imx u-boot.uim FORCE
179         $(call if_changed,pad_cat)
180
181 quiet_cmd_u-boot-nand-spl_imx = GEN     $@
182 cmd_u-boot-nand-spl_imx = (printf '\000\000\000\000\106\103\102\040\001' && \
183         dd bs=1015 count=1 if=/dev/zero 2>/dev/null) | cat - $< > $@
184
185 spl/u-boot-nand-spl.imx: SPL FORCE
186         $(call if_changed,u-boot-nand-spl_imx)
187 endif
188
189 targets += $(addprefix ../../../,SPL spl/u-boot-spl.cfgout u-boot-dtb.cfgout u-boot.cfgout u-boot.uim spl/u-boot-nand-spl.imx)
190
191 obj-$(CONFIG_ARM64) += sip.o
192
193 obj-$(CONFIG_MX5) += mx5/
194 obj-$(CONFIG_MX6) += mx6/
195 obj-$(CONFIG_MX7) += mx7/
196 obj-$(CONFIG_ARCH_MX7ULP) += mx7ulp/
197 obj-$(CONFIG_IMX8M) += imx8m/
198 obj-$(CONFIG_ARCH_IMX8) += imx8/