db845c: make build pg_agnostic and support 16k page size kernels

To support booting with 16k page size kernels, add a new 16k page size
option. This also uses 16k block size for the filesystems in use.

Also add page agnostic support so that 4k and 16k page size kernels
can be booted with 16K aligned userspace.

Change-Id: I318b416791419bd7d8b1e5261a2c5cc2907eb388
Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>
diff --git a/db845c.mk b/db845c.mk
index 43b5bc5..fe7547f 100644
--- a/db845c.mk
+++ b/db845c.mk
@@ -1,6 +1,14 @@
 # Target defaults to 64- and 32-bit
 TARGET_64BIT_ONLY ?= false
 
+# Target can boot 16K kernels - defaults to false
+# If 16K_PAGESIZE is set, enable 64BIT_ONLY as well
+# since that's a prerequisite
+TARGET_16K_PAGESIZE ?= false
+ifeq ($(TARGET_16K_PAGESIZE), true)
+  TARGET_64BIT_ONLY := true
+endif
+
 $(call inherit-product, device/linaro/dragonboard/full.mk)
 ifeq ($(TARGET_64BIT_ONLY), true)
   $(call inherit-product, $(SRC_TARGET_DIR)/product/core_64_bit_only.mk)
diff --git a/db845c/BoardConfig.mk b/db845c/BoardConfig.mk
index 3ee2321..da4db20 100644
--- a/db845c/BoardConfig.mk
+++ b/db845c/BoardConfig.mk
@@ -51,7 +51,8 @@
 endif
 BOARD_MKBOOTIMG_ARGS := --header_version $(BOARD_BOOT_HEADER_VERSION)
 BOARD_KERNEL_BASE := 0x80000000
-BOARD_KERNEL_PAGESIZE := 4096
+BOARD_MKBOOTIMG_ARGS += --pagesize 4096
+INTERNAL_VENDOR_BOOTIMAGE_ARGS += --pagesize 4096
 BOARD_KERNEL_CMDLINE += earlycon firmware_class.path=/vendor/firmware/
 BOARD_KERNEL_CMDLINE += init=/init printk.devkmsg=on
 BOARD_KERNEL_CMDLINE += deferred_probe_timeout=30
@@ -59,6 +60,11 @@
 BOARD_KERNEL_CMDLINE += qcom_geni_serial.con_enabled=1
 BOARD_KERNEL_CMDLINE += console=ttyMSM0,115200n8
 
+ifeq ($(TARGET_16K_PAGESIZE), true)
+  BOARD_EROFS_BLOCKSIZE := 16384
+  BOARD_F2FS_BLOCKSIZE := 16384
+endif
+
 # Image Configuration
 BOARD_BOOTIMAGE_PARTITION_SIZE := 100663296 #96M
 BOARD_FLASH_BLOCK_SIZE := 4096
diff --git a/db845c/device.mk b/db845c/device.mk
index fb1b719..bfc728c 100644
--- a/db845c/device.mk
+++ b/db845c/device.mk
@@ -69,4 +69,9 @@
 TARGET_HARDWARE := db845c
 TARGET_KERNEL_USE ?= 6.6
 
+# Page agnostic support - will build ELF files 16K aligned,
+# which will allow 4k/16k page size aligned kernels
+PRODUCT_MAX_PAGE_SIZE_SUPPORTED := 16384
+PRODUCT_NO_BIONIC_PAGE_SIZE_MACRO := true
+
 include device/linaro/dragonboard/device-common.mk