diff options
author | Jacob Stiffler <j-stiffler@ti.com> | 2016-09-14 00:21:17 +0000 |
---|---|---|
committer | Denys Dmytriyenko <denys@ti.com> | 2016-09-16 12:18:01 -0400 |
commit | 0623707d8084b2856b74a1b40aa2dee361f6b933 (patch) | |
tree | 173e5ad77e57c61adcaedeedc8c7b349cd4b62b8 | |
parent | f0ae7e1c366d6e20e0ad228aa965fc294ec35ccd (diff) | |
download | meta-ti-0623707d8084b2856b74a1b40aa2dee361f6b933.tar.gz |
linux: add new method for cmem injection
* Add new method to perform CMEM DT injection as it is required to
customize at a finer level than machine.
* Now CMEM injection can be performed per DT.
Signed-off-by: Jacob Stiffler <j-stiffler@ti.com>
Signed-off-by: Denys Dmytriyenko <denys@ti.com>
-rw-r--r-- | recipes-kernel/linux/cmem.inc | 78 | ||||
-rw-r--r-- | recipes-kernel/linux/files/dra7xx/cmem-am571x.dtsi | 29 |
2 files changed, 95 insertions, 12 deletions
diff --git a/recipes-kernel/linux/cmem.inc b/recipes-kernel/linux/cmem.inc index fc0bf48d..b60909cc 100644 --- a/recipes-kernel/linux/cmem.inc +++ b/recipes-kernel/linux/cmem.inc | |||
@@ -1,18 +1,72 @@ | |||
1 | SRC_URI += "file://cmem.dtsi" | 1 | # Add concept of machine variants to split DTBs into subsets |
2 | # | ||
3 | # Use these for temporary overrides | ||
4 | CMEM_MACHINE = "${MACHINE}" | ||
5 | CMEM_MACHINE_am57xx-evm = "am571x am572x" | ||
6 | CMEM_MACHINE_am57xx-hs-evm = "am571x am572x" | ||
2 | 7 | ||
8 | # Set cmem.dtsi per machine or machine variant | ||
9 | CMEM_DTSI = "cmem.dtsi" | ||
10 | CMEM_DTSI_am571x = "cmem-am571x.dtsi" | ||
11 | |||
12 | # Split device trees between variants | ||
13 | CMEM_DEVICETREE = "${KERNEL_DEVICETREE}" | ||
14 | CMEM_DEVICETREE_am571x = "am571x-idk.dtb am571x-idk-lcd-osd.dtb am571x-idk-lcd-osd101t2587.dtb" | ||
15 | CMEM_DEVICETREE_am572x = "am57xx-beagle-x15.dtb am57xx-beagle-x15-revb1.dtb am57xx-evm.dtb am57xx-evm-reva3.dtb am572x-idk.dtb \ | ||
16 | am572x-idk-lcd-osd.dtb am572x-idk-lcd-osd101t2587.dtb" | ||
17 | |||
18 | |||
19 | # Flag to enable CMEM injection | ||
3 | RESERVE_CMEM ?= "0" | 20 | RESERVE_CMEM ?= "0" |
4 | 21 | ||
5 | do_setup_cmem() { | 22 | # Add correct cmem.dtsi to SRC_URI for each variant for a given machine |
6 | if [ "${RESERVE_CMEM}" == "1" ] | 23 | python() { |
7 | then | 24 | old_overrides = d.getVar('OVERRIDES', False) |
8 | cp ${WORKDIR}/cmem.dtsi ${S}/arch/arm/boot/dts/${MACHINE}-cmem.dtsi | 25 | |
9 | 26 | # Initialize with empty string to simplify logic to append to SRC_URI | |
10 | for dtb in ${KERNEL_DEVICETREE} | 27 | cmem_dtsi = set(['']) |
11 | do | 28 | |
12 | dts=`echo $dtb | sed -e 's|dtb$|dts|'` | 29 | for cmem_machine in (d.getVar('CMEM_MACHINE', True) or '').split(): |
13 | echo "#include \"${MACHINE}-cmem.dtsi\"" >> ${S}/arch/arm/boot/dts/$dts | 30 | # Create copy of data for additional override |
14 | done | 31 | localdata = bb.data.createCopy(d) |
15 | fi | 32 | localdata.setVar('OVERRIDES', '%s:%s' % (cmem_machine, old_overrides)) |
33 | bb.data.update_data(localdata) | ||
34 | |||
35 | cmem_dtsi.add(localdata.getVar('CMEM_DTSI', True)) | ||
36 | |||
37 | d.appendVar('SRC_URI', ' file://'.join(cmem_dtsi)) | ||
38 | } | ||
39 | |||
40 | python do_setup_cmem() { | ||
41 | import shutil | ||
42 | |||
43 | old_overrides = d.getVar('OVERRIDES', False) | ||
44 | |||
45 | if d.getVar('RESERVE_CMEM', True) is '1': | ||
46 | for cmem_machine in (d.getVar('CMEM_MACHINE', True) or '').split(): | ||
47 | # Create copy of data for additional override | ||
48 | localdata = bb.data.createCopy(d) | ||
49 | localdata.setVar('OVERRIDES', '%s:%s' % (cmem_machine, old_overrides)) | ||
50 | bb.data.update_data(localdata) | ||
51 | |||
52 | # Get source directory and dtsi filename | ||
53 | src_dir = localdata.getVar('WORKDIR', True) | ||
54 | src_dtsi = localdata.getVar('CMEM_DTSI', True) | ||
55 | |||
56 | # Get destination directory and destination dtsi filename which adds | ||
57 | # the MACHINE prefix. | ||
58 | dst_dir = os.path.join(localdata.getVar('S', True), 'arch/arm/boot/dts') | ||
59 | dst_dtsi = localdata.expand('${MACHINE}-${CMEM_DTSI}') | ||
60 | |||
61 | # Copy cmem.dtsi into source tree | ||
62 | shutil.copy(os.path.join(src_dir,src_dtsi), os.path.join(dst_dir,dst_dtsi)) | ||
63 | |||
64 | # Inject dtsi into each dts in list | ||
65 | for dtb in (localdata.getVar('CMEM_DEVICETREE', True) or '').split(): | ||
66 | dts = dtb[:-4] + '.dts' | ||
67 | |||
68 | with open(os.path.join(dst_dir,dts), 'a') as dts_file: | ||
69 | dts_file.write('\n#include "%s"\n' % dst_dtsi) | ||
16 | } | 70 | } |
17 | 71 | ||
18 | do_patch[postfuncs] += "do_setup_cmem" | 72 | do_patch[postfuncs] += "do_setup_cmem" |
diff --git a/recipes-kernel/linux/files/dra7xx/cmem-am571x.dtsi b/recipes-kernel/linux/files/dra7xx/cmem-am571x.dtsi new file mode 100644 index 00000000..ebd61296 --- /dev/null +++ b/recipes-kernel/linux/files/dra7xx/cmem-am571x.dtsi | |||
@@ -0,0 +1,29 @@ | |||
1 | / { | ||
2 | reserved-memory { | ||
3 | #address-cells = <2>; | ||
4 | #size-cells = <2>; | ||
5 | ranges; | ||
6 | |||
7 | cmem_block_mem_0: cmem_block_mem@a0000000 { | ||
8 | reg = <0x0 0xa0000000 0x0 0x0c000000>; | ||
9 | no-map; | ||
10 | status = "okay"; | ||
11 | }; | ||
12 | }; | ||
13 | |||
14 | cmem { | ||
15 | compatible = "ti,cmem"; | ||
16 | #address-cells = <1>; | ||
17 | #size-cells = <0>; | ||
18 | |||
19 | #pool-size-cells = <2>; | ||
20 | |||
21 | status = "okay"; | ||
22 | |||
23 | cmem_block_0: cmem_block@0 { | ||
24 | reg = <0>; | ||
25 | memory-region = <&cmem_block_mem_0>; | ||
26 | cmem-buf-pools = <1 0x0 0x0c000000>; | ||
27 | }; | ||
28 | }; | ||
29 | }; | ||