From 91f7784cfd26ca7d26e1006d78c067e74c7dc92a Mon Sep 17 00:00:00 2001
From: Tadao Tanikawa <tanikawa.tadao@jp.panasonic.com>
Date: Fri, 15 Jan 2016 22:12:18 +0900
Subject: [PATCH] Support MinnowBoard MAX

To configure for MinnowBoard MAX, use 'intel-corei7-64' as MACHINE.

E.g. set up build environment by meta-agl's script:
  $ source meta-agl/script/envsetup.sh intel-corei7-64 [build-dir]

There are instructions to write image into SD card and boot system
at "http://elinux.org/Minnowboard:MinnowMaxYoctoProject".

Change-Id: I19062482848bb6157791ab698bf92984e24a6d9a
Signed-off-by: Tadao Tanikawa <tanikawa.tadao@jp.panasonic.com>
---
 meta-agl-bsp/recipes-graphics/mesa/mesa_10.%.bbappend    |  2 ++
 meta-agl-bsp/recipes-graphics/wayland/weston_%.bbappend  |  2 ++
 meta-agl-bsp/recipes-kernel/linux/linux-yocto/hid.cfg    |  1 +
 meta-agl-bsp/recipes-kernel/linux/linux-yocto_%.bbappend |  1 +
 meta-agl/conf/bblayers.conf.sample                       |  1 +
 meta-agl/recipes-core/systemd/systemd/e2fsck.conf        |  3 +++
 meta-agl/recipes-core/systemd/systemd_%.bbappend         | 10 ++++++++++
 scripts/envsetup.sh                                      |  4 ++++
 8 files changed, 24 insertions(+)
 create mode 100644 meta-agl-bsp/recipes-kernel/linux/linux-yocto/hid.cfg
 create mode 100644 meta-agl/recipes-core/systemd/systemd/e2fsck.conf

diff --git a/meta-agl-bsp/recipes-graphics/mesa/mesa_10.%.bbappend b/meta-agl-bsp/recipes-graphics/mesa/mesa_10.%.bbappend
index fca193e36..5280a262a 100644
--- a/meta-agl-bsp/recipes-graphics/mesa/mesa_10.%.bbappend
+++ b/meta-agl-bsp/recipes-graphics/mesa/mesa_10.%.bbappend
@@ -2,3 +2,5 @@
 RPROVIDES_${PN}_append = "libegl-gallium"
 
 PACKAGECONFIG_append = " gallium gallium-egl gallium-llvm"
+
+DRIDRIVERS_append_intel-corei7-64 = ",i965"
diff --git a/meta-agl-bsp/recipes-graphics/wayland/weston_%.bbappend b/meta-agl-bsp/recipes-graphics/wayland/weston_%.bbappend
index a527fcf7e..53c58b53a 100644
--- a/meta-agl-bsp/recipes-graphics/wayland/weston_%.bbappend
+++ b/meta-agl-bsp/recipes-graphics/wayland/weston_%.bbappend
@@ -1,4 +1,6 @@
 RRECOMMENDS_${PN}_append = " libegl-gallium llvm3.3 "
+RRECOMMENDS_${PN}_remove_intel-corei7-64 = "libegl-gallium llvm3.3"
+RDEPENDS_${PN}_append_intel-corei7-64 = " mesa-megadriver "
 
 EXTRA_OECONF_append_vexpressa9 = "\
     --enable-simple-egl-clients  \
diff --git a/meta-agl-bsp/recipes-kernel/linux/linux-yocto/hid.cfg b/meta-agl-bsp/recipes-kernel/linux/linux-yocto/hid.cfg
new file mode 100644
index 000000000..327c753ae
--- /dev/null
+++ b/meta-agl-bsp/recipes-kernel/linux/linux-yocto/hid.cfg
@@ -0,0 +1 @@
+CONFIG_HID_MULTITOUCH=y
diff --git a/meta-agl-bsp/recipes-kernel/linux/linux-yocto_%.bbappend b/meta-agl-bsp/recipes-kernel/linux/linux-yocto_%.bbappend
index 00270faef..6b8483e63 100644
--- a/meta-agl-bsp/recipes-kernel/linux/linux-yocto_%.bbappend
+++ b/meta-agl-bsp/recipes-kernel/linux/linux-yocto_%.bbappend
@@ -4,4 +4,5 @@ FILESEXTRAPATHS_prepend := "${THISDIR}/linux-yocto:"
 SRC_URI += "file://0001-fanotify-fix-notification-of-groups-with-inode-mount.patch \
             file://fanotify.cfg \
             file://uinput.cfg \
+            file://hid.cfg \
             "
diff --git a/meta-agl/conf/bblayers.conf.sample b/meta-agl/conf/bblayers.conf.sample
index e5e54431c..668f0fe98 100644
--- a/meta-agl/conf/bblayers.conf.sample
+++ b/meta-agl/conf/bblayers.conf.sample
@@ -14,6 +14,7 @@ BBLAYERS ?= " \
   ##OEROOT##/../meta-agl/meta-agl-bsp \
   ##OEROOT##/../meta-openembedded/meta-oe \
   ##OEROOT##/../meta-openembedded/meta-multimedia \
+  ##OEROOT##/../meta-intel \
   "
 BBLAYERS_NON_REMOVABLE ?= " \
   ##OEROOT##/meta \
diff --git a/meta-agl/recipes-core/systemd/systemd/e2fsck.conf b/meta-agl/recipes-core/systemd/systemd/e2fsck.conf
new file mode 100644
index 000000000..b774f9ebf
--- /dev/null
+++ b/meta-agl/recipes-core/systemd/systemd/e2fsck.conf
@@ -0,0 +1,3 @@
+[options]
+# This will prevent e2fsck from stopping boot just because the clock is wrong
+broken_system_clock = 1
diff --git a/meta-agl/recipes-core/systemd/systemd_%.bbappend b/meta-agl/recipes-core/systemd/systemd_%.bbappend
index 29b7d1d7e..ef926953c 100644
--- a/meta-agl/recipes-core/systemd/systemd_%.bbappend
+++ b/meta-agl/recipes-core/systemd/systemd_%.bbappend
@@ -1,3 +1,13 @@
+FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
+
+SRC_URI += " file://e2fsck.conf "
+
 # enable networkd support
 PACKAGECONFIG_append_pn-systemd = " networkd"
 
+do_install_append() {
+    # Install /etc/e2fsck.conf to avoid boot stuck by wrong clock time
+    install -p -D ${WORKDIR}/e2fsck.conf ${D}/etc/e2fsck.conf
+}
+
+FILES_${PN} += " /etc/e2fsck.conf "
diff --git a/scripts/envsetup.sh b/scripts/envsetup.sh
index d00330128..adde54010 100644
--- a/scripts/envsetup.sh
+++ b/scripts/envsetup.sh
@@ -21,6 +21,10 @@ case "$1" in
                 # template conf for R-Car2 M2 Porter board
                 TEMPLATECONF=$PWD/meta-renesas/meta-rcar-gen2/conf
                 ;;
+        "intel-corei7-64")
+                # template conf for MinnowBoard MAX
+                TEMPLATECONF=$PWD/meta-agl-demo/conf
+                ;;
         "qemux86-64")
                 # template conf for QEMU x86-64
                 TEMPLATECONF=$PWD/meta-agl-demo/conf
-- 
2.16.6