summaryrefslogtreecommitdiff
path: root/recipes-kernel/linux/linux-at91_5.4.81.bb
blob: de29088cd9c260f1b85901c19af3e9a51c735f39 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
SECTION = "kernel"
DESCRIPTION = "Linux kernel for Microchip ARM SoCs (aka AT91)"
SUMMARY = "Linux kernel for Microchip ARM SoCs (aka AT91)"
LICENSE = "GPLv2"
LIC_FILES_CHKSUM = "file://COPYING;md5=bbea815ee2795b2f4230826c0c6b8814"

inherit kernel
# mts class to build dtb and append to kernel image
inherit linux-append-dtb

KERNEL_EXTRA_ARGS ="LOADADDR=0x20008000"

RDEPENDS_${KERNEL_PACKAGE_NAME}-base = ""
RDEPENDS_kernel-modules_remove = "kernel-module-softdog"
FILESEXTRAPATHS_prepend := "${THISDIR}/${P}:"

SRCREV = "6cb5b8839e5f8b9bdd69273bd396ded4f0edd09e"
SRCREV_sama7g5ek = "d67f0979dcc377863060e803a2280b7a7e1a22c0"

PR = "r2"
KERNEL_VERSION = "${PV}"
KERNEL_REVISION = "${PR}"
EXTRAVERSION = ""

S = "${WORKDIR}/git"

KBRANCH = "linux-5.4-at91"
KBRANCH_sama7g5ek-sd = "sama7g5_early"
KBRANCH_sama7g5ek-emmc = "sama7g5_early"
SRC_URI = "git://github.com/linux4sam/linux-at91.git;protocol=git;branch=${KBRANCH}"
SRC_URI += "file://defconfig"
SRC_URI_remove_sama7g5ek = "file://defconfig"

KERNEL_MODULE_PACKAGE_SUFFIX=""

COMMON_PATCHES = " \
		  file://defconfig \
		  file://linux-5.4-at91sam9_wdt-10second-timeout.patch \
		  file://linux-5.4-export-mmc_pwrseq_alloc.patch \
		  file://linux-5.4-spidev_squack.patch \
		  file://linux-5.4-add-num_accessory_ports-config-option.patch \
		  file://linux-5.4-cdc-acm-ignore-exar-devices.patch \
		  file://EXTRAVERSION.patch \
		  file://linux-5.4-addl-time-for-pmeccerrloc.patch \
		  file://linux-5.4-OF-DT-Overlay-configfs-interface.patch \
		  file://linux-5.4-revert-net-macb-Properly-handle-phylink-on-at91rm9200.patch \
		  file://linux-5.4-bring-back-PAE-bit-and-fix-NCFGR-values-applicable-f.patch \
		  file://linux-5.4-quiet-overlay.patch \
		  file://mt-at91.h \
"

SRC_URI_append_mtcdt = "\
            ${COMMON_PATCHES} \
            file://linux-5.4-reserve-5-bit-serial-for-multidrop.patch \
            file://linux-5.4-rs485-atmel-crtscts.patch \
            "
SRC_URI_append_mtrv1 = "\
            ${COMMON_PATCHES} \
            "
SRC_URI_append_mtcap = "\
            ${COMMON_PATCHES} \
            "
SRC_URI_append_mtr = "\
            ${COMMON_PATCHES} \
            file://linux-5.4-fix-atmel-mci-reg-overloading.patch \
            file://linux-5.4-wl12xx_enable_disable.patch \
            "
SRC_URI_append_mtre = "\
            ${COMMON_PATCHES} \
            "

KERNEL_MODULE_AUTOLOAD_mtcap_append += "i2c-dev"
KERNEL_MODULE_AUTOLOAD_mtcdt_append += "i2c-dev"

python __anonymous () {
    if d.getVar('UBOOT_FIT_IMAGE', True) == 'xyes':
        d.appendVar('DEPENDS', ' u-boot-mkimage-native dtc-native')
}

copy_mts_dts_files () {
    # Install MTS device tree files
    cp -f ${THISDIR}/linux-at91-5.4.81/mts-dts/${MACHINE}.dts ${S}/arch/${ARCH}/boot/dts/
    cp -f ${THISDIR}/linux-at91-5.4.81/mt-at91.h ${S}/include/dt-bindings/gpio
}

python do_unpack_append () {
    bb.build.exec_func('copy_mts_dts_files', d)
}

# Files needed to build external kernel modules.
do_shared_workdir_append() {
    install -d -m 755 ${STAGING_KERNEL_BUILDDIR}/include/config
    cp -a ${B}/include/config ${STAGING_KERNEL_BUILDDIR}/include/
    cp -a ${B}/scripts ${STAGING_KERNEL_BUILDDIR}
    echo ${PR} > ${STAGING_KERNEL_BUILDDIR}/mlinux_pr
}

do_configure_prepend() {
	if [ ! -f "${WORKDIR}/defconfig" ] && [ -n "${KBUILD_DEFCONFIG}" ]; then
		if [ -f "${S}/arch/${ARCH}/configs/${KBUILD_DEFCONFIG}" ]; then
			cp -f ${S}/arch/${ARCH}/configs/${KBUILD_DEFCONFIG} ${WORKDIR}/defconfig
                else
                        bbfatal "A KBUILD_DEFCONFIG '${KBUILD_DEFCONFIG}' was specified, but not present in the source tree"
                fi
        fi
}

do_configure_append() {
	frags=""
	for fragment in ${WORKDIR}/*.cfg
	do
		if [ -f ${fragment} ]; then
			cp -v ${fragment} ${B}
			frags=$frags" `basename ${fragment}`"
		fi
	done

	if [ ! -z "${frags}" ]; then
		echo "Fragments are: ${frags}"
		PATH=${S}/scripts/kconfig:${PATH}
		CFLAGS="${CFLAGS} ${TOOLCHAIN_OPTIONS}" HOSTCC="${BUILD_CC} ${BUILD_CFLAGS} ${BUILD_LDFLAGS}" HOSTCPP="${BUILD_CPP}" CC="${KERNEL_CC}" ARCH=${ARCH} merge_config.sh -n .config ${frags}  2>&1
		if [ $? -ne 0 ]; then
			bbfatal_log "Could not configure kernel fragments: ${frags}"
		fi
	fi
}

do_deploy_append() {
	if [ "${UBOOT_FIT_IMAGE}" = "xyes" ]; then
		DTB_PATH="${B}/arch/${ARCH}/boot/dts/"
		if [ ! -e "${DTB_PATH}" ]; then
			DTB_PATH="${B}/arch/${ARCH}/boot/"
		fi

		if [ -e ${S}/arch/${ARCH}/boot/dts/${MACHINE}.its ]; then
			cp ${S}/arch/${ARCH}/boot/dts/${MACHINE}*.its ${DTB_PATH}
			cd ${DTB_PATH}
			mkimage -f ${MACHINE}.its ${MACHINE}.itb
			install -m 0644 ${MACHINE}.itb ${DEPLOYDIR}/${MACHINE}.itb
			cd -
		fi
	fi
}

DTB_APPEND_mtcdt = "mtcdt"
DTB_APPEND_mtrv1 = "mtrv1"
DTB_APPEND_mtcap = "mtcap"
DTB_APPEND_mtr = "mtr"
DTB_APPEND_mtre = "mtre"

COMPATIBLE_MACHINE = "(mtcdt|mtrv1|mtr|mtcap|mths|mtre)"

NET_LOAD_ALL_MACHINES += " \
	8021q \
	bnep \
	br_netfilter \
	dns_resolver \
	garp \
	ip6_gre \
	ip6table_filter \
	ip6table_mangle \
	ip6table_nat \
	ip6table_raw \
	ip6t_ah \
	ip6t_eui64 \
	ip6t_frag \
	ip6t_hbh \
	ip6t_ipv6header \
	ip6t_MASQUERADE \
	ip6t_mh \
	ip6t_NPT \
	ip6t_REJECT \
	ip6t_rpfilter \
	ip6t_rt \
	ip6t_SYNPROXY \
	ip6_vti \
	ipip \
	iptable_mangle \
	iptable_nat \
	iptable_netfilter \
	iptable_raw \
	ip_tables \
	ipt_ah \
	ip_vs \
	l2tp_ppp \
	mac80211 \
	mrp \
	nf_conntrack_ipv4 \
	nf_conntrack_ipv6 \
	nf_conntrack_netbios_ns \
	nf_conntrack_netlink \
	nf_log_ipv4 \
	nf_log_ipv6 \
	nf_nat_ftp \
	nf_nat_h323 \
	nf_nat_pptp \
	nf_nat_sip \
	nf_nat_snmp_basic \
	nfnetlink_cttimeout \
	nf_tables_inet \
	nf_tables_netdev \
	nft_exthdr \
	nft_meta \
	p8022 \
	psnap \
	rfcomm \
	rfkill-gpio \
	rfkill-regulator \
	sit \
	tun \
	xfrm6_mode_tunnel \
	xt_CLASSIFY \
	xt_connmark \
	xt_conntrack \
	xt_CT \
	xt_ecn \
	xt_esp \
	xt_hashlimit \
	xt_hl \
	xt_HL \
	xt_iprange \
	xt_l2tp \
	xt_LED \
	xt_limit \
	xt_LOG \
	xt_mac \
	xt_mark \
	xt_multiport \
	xt_nat \
	xt_NETMAP \
	xt_NFLOG \
	xt_NFQUEUE \
	xt_policy \
	xt_recent \
	xt_REDIRECT \
	xt_set \
	xt_state \
	xt_tcpudp \
	xt_TEE \
	xt_time \
	xt_TPROXY \
	ledtrig-netdev \
"

DRIVER_LOAD_ALL_MACHINES =  " \
	atmel_usba_udc \
	ledtrig-default-on \
	ledtrig-heartbeat \
	ledtrig-timer \
"

KERNEL_MODULE_AUTOLOAD_mtcdt += " \
	g_serial \
	softdog \
"

KERNEL_MODULE_AUTOLOAD_mtcdt += " \
	${NET_LOAD_ALL_MACHINES} \
	${DRIVER_LOAD_ALL_MACHINES} \
"
KERNEL_MODULE_AUTOLOAD_mtrv1 += " \
	${NET_LOAD_ALL_MACHINES} \
	${DRIVER_LOAD_ALL_MACHINES} \
"
KERNEL_MODULE_AUTOLOAD_mtr += " \
	${NET_LOAD_ALL_MACHINES} \
	${DRIVER_LOAD_ALL_MACHINES} \
"
KERNEL_MODULE_AUTOLOAD_mtcap += " \
	${NET_LOAD_ALL_MACHINES} \
	${DRIVER_LOAD_ALL_MACHINES} \
"
KERNEL_MODULE_AUTOLOAD_mtre += " \
	${NET_LOAD_ALL_MACHINES} \
	${DRIVER_LOAD_ALL_MACHINES} \
"