Add Nuvoton NPCM7XX BSP support

Add as follow :

    1. NPCM7XX Kernel Linux
    2. NPCM7XX U-boot

Change-Id: I84ae09c16725fcf9d23f8daf3c9eadac09cb605f
Signed-off-by: Tomer Maimon <tmaimon77@gmail.com>
diff --git a/meta-openbmc-bsp/meta-nuvoton/COPYING.MIT b/meta-openbmc-bsp/meta-nuvoton/COPYING.MIT
new file mode 100644
index 0000000..fb950dc
--- /dev/null
+++ b/meta-openbmc-bsp/meta-nuvoton/COPYING.MIT
@@ -0,0 +1,17 @@
+Permission is hereby granted, free of charge, to any person obtaining a copy 
+of this software and associated documentation files (the "Software"), to deal 
+in the Software without restriction, including without limitation the rights 
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
+copies of the Software, and to permit persons to whom the Software is 
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in 
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
+THE SOFTWARE.
diff --git a/meta-openbmc-bsp/meta-nuvoton/LICENSE b/meta-openbmc-bsp/meta-nuvoton/LICENSE
new file mode 100644
index 0000000..1ed34d7
--- /dev/null
+++ b/meta-openbmc-bsp/meta-nuvoton/LICENSE
@@ -0,0 +1,8 @@
+Different components of Phosphor OpenBMC are under different licenses (a mix
+Please see:
+
+COPYING.MIT (MIT)
+
+All metadata is MIT licensed unless otherwise stated. Source code
+included in tree for individual recipes is under the LICENSE stated in
+the associated recipe (.bb file) unless otherwise stated.
diff --git a/meta-openbmc-bsp/meta-nuvoton/conf/layer.conf b/meta-openbmc-bsp/meta-nuvoton/conf/layer.conf
new file mode 100644
index 0000000..62d1a53
--- /dev/null
+++ b/meta-openbmc-bsp/meta-nuvoton/conf/layer.conf
@@ -0,0 +1,9 @@
+# We have a conf and classes directory, add to BBPATH
+BBPATH .= ":${LAYERDIR}"
+
+BBFILES += "${LAYERDIR}/common/recipes-*/*/*.bb \
+            ${LAYERDIR}/common/recipes-*/*/*.bbappend"
+
+BBFILE_COLLECTIONS += "nuvoton"
+BBFILE_PATTERN_nuvoton = ""
+LAYERVERSION_nuvoton = "1"
diff --git a/meta-openbmc-bsp/meta-nuvoton/meta-npcm7xx/README.md b/meta-openbmc-bsp/meta-nuvoton/meta-npcm7xx/README.md
new file mode 100644
index 0000000..a93a03c
--- /dev/null
+++ b/meta-openbmc-bsp/meta-nuvoton/meta-npcm7xx/README.md
@@ -0,0 +1,8 @@
+Nuvoton NPCM7XX
+================
+
+This is the Nuvoton NPCM7XX Board Support Package (BSP) layer.
+The NPCM7XX is an ARM based SoC with external DDR RAM and 
+supports a large set of peripherals made by Nuvoton. 
+More information about the NPCM7XX can be found
+[here](http://www.nuvoton.com/hq/products/cloud-computing/ibmc/?__locale=en).
diff --git a/meta-openbmc-bsp/meta-nuvoton/meta-npcm7xx/conf/layer.conf b/meta-openbmc-bsp/meta-nuvoton/meta-npcm7xx/conf/layer.conf
new file mode 100644
index 0000000..1bc7e6a
--- /dev/null
+++ b/meta-openbmc-bsp/meta-nuvoton/meta-npcm7xx/conf/layer.conf
@@ -0,0 +1,10 @@
+# We have a conf and classes directory, add to BBPATH
+BBPATH .= ":${LAYERDIR}"
+
+# We have recipes-* directories, add to BBFILES
+BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \
+            ${LAYERDIR}/recipes-*/*/*.bbappend"
+
+BBFILE_PATTERN_npcm7xx = "^${LAYERDIR}/"
+BBFILE_COLLECTIONS += "npcm7xx"
+LAYERVERSION_npcm7xx = "1"
diff --git a/meta-openbmc-bsp/meta-nuvoton/meta-npcm7xx/conf/machine/include/npcm7xx.inc b/meta-openbmc-bsp/meta-nuvoton/meta-npcm7xx/conf/machine/include/npcm7xx.inc
new file mode 100644
index 0000000..c48b308
--- /dev/null
+++ b/meta-openbmc-bsp/meta-nuvoton/meta-npcm7xx/conf/machine/include/npcm7xx.inc
@@ -0,0 +1,24 @@
+#@TYPE: Machine
+#@NAME: Nuvoton NPCM7XX
+#@DESCRIPTION: Common machine configuration for Nuvoton NPCM7XX Chip
+
+PREFERRED_PROVIDER_virtual/kernel ?= "linux-obmc"
+
+KERNEL_IMAGETYPE ?= "uImage"
+KERNEL_EXTRA_ARGS ?= "UIMAGE_LOADADDR=0x00008000"
+
+PREFERRED_PROVIDER_u-boot ?= "u-boot-nuvoton"
+PREFERRED_PROVIDER_u-boot-fw-utils ?= "u-boot-fw-utils-nuvoton"
+UBOOT_MACHINE ?= "PolegSVB_config"
+UBOOT_ENTRYPOINT ?= "0x00008000"
+UBOOT_LOADADDRESS ?= "0x00008000"
+
+DEFAULTTUNE ?= "arm7a-novfp"
+
+SERIAL_CONSOLES = "115200;ttyS3"
+
+SOC_FAMILY = "npcm7xx"
+include conf/machine/include/soc-family.inc
+MACHINEOVERRIDES .= ":npcm7xx"
+
+require conf/machine/include/tune-arm7a-novfp.inc
diff --git a/meta-openbmc-bsp/meta-nuvoton/meta-npcm7xx/conf/machine/include/tune-arm7a-novfp.inc b/meta-openbmc-bsp/meta-nuvoton/meta-npcm7xx/conf/machine/include/tune-arm7a-novfp.inc
new file mode 100644
index 0000000..18730db
--- /dev/null
+++ b/meta-openbmc-bsp/meta-nuvoton/meta-npcm7xx/conf/machine/include/tune-arm7a-novfp.inc
@@ -0,0 +1,11 @@
+DEFAULTTUNE ?= "arm7a-novfp"
+
+require conf/machine/include/arm/arch-armv7a.inc
+
+TUNEVALID[arm7a-novfp] = "Enable arm7a-novfp specific processor optimizations"
+
+AVAILTUNES += "arm7a-novfp"
+ARMPKGARCH_tune-arm7a-novfp = "armv7a"
+TUNE_FEATURES_tune-armv7a = "arm armv7a"
+TUNE_FEATURES_tune-arm7a-novfp = "${TUNE_FEATURES_tune-armv7a} arm7a-novfp"
+PACKAGE_EXTRA_ARCHS_tune-arm7a-novfp = "${PACKAGE_EXTRA_ARCHS_tune-armv7a}"
diff --git a/meta-openbmc-bsp/meta-nuvoton/meta-npcm7xx/recipes-bsp/u-boot/u-boot-fw-utils-nuvoton_git.bb b/meta-openbmc-bsp/meta-nuvoton/meta-npcm7xx/recipes-bsp/u-boot/u-boot-fw-utils-nuvoton_git.bb
new file mode 100644
index 0000000..cefdea8
--- /dev/null
+++ b/meta-openbmc-bsp/meta-nuvoton/meta-npcm7xx/recipes-bsp/u-boot/u-boot-fw-utils-nuvoton_git.bb
@@ -0,0 +1,49 @@
+SUMMARY = "U-Boot bootloader fw_printenv/setenv utilities"
+LICENSE = "GPLv2+"
+LIC_FILES_CHKSUM = "file://Licenses/README;md5=a2c678cfd4a4d97135585cad908541c6"
+SECTION = "bootloader"
+DEPENDS = "mtd-utils"
+
+PROVIDES += "u-boot-fw-utils"
+
+UBRANCH = "npcm7xx"
+SRC_URI = "git://github.com/Nuvoton-Israel/u-boot.git;branch=${UBRANCH}"
+SRCREV = "196461383f7d043f18cab3bb34dded89fba4712a"
+
+PV .= "+${UBRANCH}+"
+
+S = "${WORKDIR}/git"
+
+INSANE_SKIP_${PN} = "already-stripped"
+
+EXTRA_OEMAKE_class-target = 'CROSS_COMPILE="${TARGET_PREFIX}" HOSTCC="${BUILD_CC} ${BUILD_FLAGS} ${BUILD_LDFLAGS}" CC="${CC} ${CFLAGS} ${LDFLAGS}" STRIP=true V=1'
+EXTRA_OEMAKE_class-cross = 'ARCH=${TARGET_ARCH} CC="${CC} ${CFLAGS} ${LDFLAGS}" V=1'
+
+inherit uboot-config
+
+do_compile () {
+  oe_runmake ${UBOOT_MACHINE}
+  oe_runmake env
+}
+
+do_install () {
+  install -d ${D}${base_sbindir}
+  install -d ${D}${sysconfdir}
+  install -m 755 ${S}/tools/env/fw_printenv ${D}${base_sbindir}/fw_printenv
+  install -m 755 ${S}/tools/env/fw_printenv ${D}${base_sbindir}/fw_setenv
+  install -m 0644 ${S}/tools/env/fw_env.config ${D}${sysconfdir}/fw_env.config
+}
+
+do_install_class-cross () {
+  install -d ${D}${bindir_cross}
+  install -m 755 ${S}/tools/env/fw_printenv ${D}${bindir_cross}/fw_printenv
+  install -m 755 ${S}/tools/env/fw_printenv ${D}${bindir_cross}/fw_setenv
+}
+
+SYSROOT_PREPROCESS_FUNCS_class-cross = "uboot_fw_utils_cross"
+uboot_fw_utils_cross() {
+	sysroot_stage_dir ${D}${bindir_cross} ${SYSROOT_DESTDIR}${bindir_cross}
+}
+
+PACKAGE_ARCH = "${MACHINE_ARCH}"
+BBCLASSEXTEND = "cross"
diff --git a/meta-openbmc-bsp/meta-nuvoton/meta-npcm7xx/recipes-bsp/u-boot/u-boot-nuvoton_git.bb b/meta-openbmc-bsp/meta-nuvoton/meta-npcm7xx/recipes-bsp/u-boot/u-boot-nuvoton_git.bb
new file mode 100644
index 0000000..ea1fdbe
--- /dev/null
+++ b/meta-openbmc-bsp/meta-nuvoton/meta-npcm7xx/recipes-bsp/u-boot/u-boot-nuvoton_git.bb
@@ -0,0 +1,19 @@
+DESCRIPTION = "U-boot for Nuvoton NPCM7xx Baseboard Management Controller"
+
+require recipes-bsp/u-boot/u-boot.inc
+
+PROVIDES += "u-boot"
+
+DEPENDS += "dtc-native"
+
+LICENSE = "GPLv2+"
+LIC_FILES_CHKSUM = "file://Licenses/README;md5=a2c678cfd4a4d97135585cad908541c6"
+
+S = "${WORKDIR}/git"
+
+UBRANCH = "npcm7xx"
+SRC_URI = "git://github.com/Nuvoton-Israel/u-boot.git;branch=${UBRANCH}"
+SRCREV = "196461383f7d043f18cab3bb34dded89fba4712a"
+
+PV .= "+${UBRANCH}+"
+
diff --git a/meta-openbmc-bsp/meta-nuvoton/meta-npcm7xx/recipes-kernel/linux/linux-obmc/defconfig b/meta-openbmc-bsp/meta-nuvoton/meta-npcm7xx/recipes-kernel/linux/linux-obmc/defconfig
new file mode 100644
index 0000000..07e0f4a
--- /dev/null
+++ b/meta-openbmc-bsp/meta-nuvoton/meta-npcm7xx/recipes-kernel/linux/linux-obmc/defconfig
@@ -0,0 +1,114 @@
+CONFIG_SYSVIPC=y
+CONFIG_BSD_PROCESS_ACCT=y
+CONFIG_LOG_BUF_SHIFT=21
+CONFIG_CGROUPS=y
+CONFIG_SYSFS_DEPRECATED=y
+CONFIG_SYSFS_DEPRECATED_V2=y
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_KERNEL_XZ=y
+CONFIG_SYSCTL_SYSCALL=y
+CONFIG_EMBEDDED=y
+CONFIG_SLAB=y
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+CONFIG_MODVERSIONS=y
+CONFIG_PARTITION_ADVANCED=y
+CONFIG_DEFAULT_DEADLINE=y
+CONFIG_ARCH_NPCM=y
+CONFIG_ARCH_NPCM7XX=y
+CONFIG_SMP=y
+CONFIG_AEABI=y
+CONFIG_ZBOOT_ROM_BSS=0x0
+CONFIG_BINFMT_MISC=y
+CONFIG_NET=y
+CONFIG_PACKET=y
+CONFIG_UNIX=y
+CONFIG_INET=y
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+CONFIG_IP_PNP_BOOTP=y
+CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
+CONFIG_DEVTMPFS=y
+CONFIG_MTD=y
+CONFIG_MTD_BLOCK=y
+CONFIG_MTD_RAM=y
+CONFIG_MTD_COMPLEX_MAPPINGS=y
+CONFIG_MTD_SPI_NOR=y
+CONFIG_SPI_NPCM=y
+CONFIG_OF_OVERLAY=y
+CONFIG_BLK_DEV_LOOP=y
+CONFIG_BLK_DEV_NBD=y
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_COUNT=1
+CONFIG_BLK_DEV_RAM_SIZE=8192
+CONFIG_SCSI=y
+CONFIG_BLK_DEV_SD=y
+CONFIG_NETDEVICES=y
+CONFIG_NPCM7XX_EMC_ETH=y
+CONFIG_STMMAC_ETH=y
+CONFIG_BROADCOM_PHY=y
+CONFIG_SERIAL_8250=y
+CONFIG_SERIAL_8250_CONSOLE=y
+CONFIG_SERIAL_OF_PLATFORM=y
+CONFIG_NPCM750_OTP=y
+CONFIG_NPCM750_OTP_WRITE_ENABLE=y
+CONFIG_NPCM7XX_KCS_IPMI_BMC=y
+CONFIG_HW_RANDOM=y
+CONFIG_I2C=y
+CONFIG_I2C_CHARDEV=y
+CONFIG_I2C_NPCM7XX=y
+CONFIG_GPIO_SYSFS=y
+CONFIG_GPIO_GENERIC_PLATFORM=y
+CONFIG_SENSORS_LM75=y
+CONFIG_SENSORS_TMP102=y
+CONFIG_SENSORS_NPCM7XX=y
+CONFIG_WATCHDOG=y
+CONFIG_USB_HIDDEV=y
+CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
+CONFIG_USB_STORAGE=y
+CONFIG_USB_CHIPIDEA=y
+CONFIG_USB_CHIPIDEA_UDC=y
+CONFIG_USB_GADGET=y
+CONFIG_USB_GADGET_NPCMX50_USB2=y
+CONFIG_USB_EHCI_ROOT_HUB_TT=y
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB_ARCH_HAS_EHCI=y
+CONFIG_USB_EHCI_HCD=y
+CONFIG_USB_ARCH_HAS_OHCI=y
+CONFIG_USB_OHCI_HCD=y
+CONFIG_USB=y
+#CONFIG_USB_MASS_STORAGE=m
+#CONFIG_USB_EDM_KBD_MOUSE=m
+CONFIG_MMC=y
+CONFIG_MMC_SDHCI=y
+CONFIG_MMC_SDHCI_NPCM750=y
+CONFIG_IIO=y
+CONFIG_NPCM7XX_ADC=y
+CONFIG_MSDOS_FS=y
+CONFIG_VFAT_FS=y
+CONFIG_TMPFS=y
+CONFIG_ROMFS_FS=y
+CONFIG_NFS_FS=y
+CONFIG_ROOT_NFS=y
+CONFIG_CIFS=y
+CONFIG_CIFS_XATTR=y
+CONFIG_NLS_CODEPAGE_437=y
+CONFIG_NLS_ASCII=y
+CONFIG_NLS_ISO8859_1=y
+CONFIG_DYNAMIC_DEBUG=y
+CONFIG_DEBUG_INFO=y
+CONFIG_DEBUG_INFO_REDUCED=y
+CONFIG_READABLE_ASM=y
+CONFIG_DEBUG_SECTION_MISMATCH=y
+CONFIG_MAGIC_SYSRQ=y
+CONFIG_FUNCTION_TRACER=y
+CONFIG_EARLY_PRINTK=y
+CONFIG_CRYPTO_CBC=y
+CONFIG_CRYPTO_CTR=y
+CONFIG_CRYPTO_CMAC=y
+CONFIG_CRYPTO_CRC32C=y
+CONFIG_CRYPTO_DEFLATE=y
+CONFIG_CRYPTO_LZO=y
+CONFIG_CRYPTO_USER_API_SKCIPHER=y
+CONFIG_CRYPTO_DEV_NPCMX50=y
+CONFIG_ARM_CRYPTO=y
diff --git a/meta-openbmc-bsp/meta-nuvoton/meta-npcm7xx/recipes-kernel/linux/linux-obmc_%.bbappend b/meta-openbmc-bsp/meta-nuvoton/meta-npcm7xx/recipes-kernel/linux/linux-obmc_%.bbappend
new file mode 100644
index 0000000..e59c109
--- /dev/null
+++ b/meta-openbmc-bsp/meta-nuvoton/meta-npcm7xx/recipes-kernel/linux/linux-obmc_%.bbappend
@@ -0,0 +1,2 @@
+FILESEXTRAPATHS_prepend_npcm7xx := "${THISDIR}/${PN}:"
+SRC_URI_append_npcm7xx = " file://defconfig"
diff --git a/meta-openbmc-bsp/meta-nuvoton/meta-npcm7xx/recipes.txt b/meta-openbmc-bsp/meta-nuvoton/meta-npcm7xx/recipes.txt
new file mode 100644
index 0000000..149509f
--- /dev/null
+++ b/meta-openbmc-bsp/meta-nuvoton/meta-npcm7xx/recipes.txt
@@ -0,0 +1,2 @@
+recipes-bsp          - Anything with links to specific hardware or hardware configuration information
+recipes-kernel       - The kernel and generic applications/libraries with strong kernel dependencies