Initial commit
authorPaul Kocialkowski <contact@paulk.fr>
Sun, 21 Sep 2014 13:14:08 +0000 (15:14 +0200)
committerPaul Kocialkowski <contact@paulk.fr>
Sun, 21 Sep 2014 13:14:08 +0000 (15:14 +0200)
43 files changed:
sunxi-common/Android.mk [new file with mode: 0644]
sunxi-common/BoardConfigCommon.mk [new file with mode: 0644]
sunxi-common/bootable/boot.txt [new file with mode: 0644]
sunxi-common/bootable/uEnv.txt [new file with mode: 0644]
sunxi-common/bootimg.mk [new file with mode: 0644]
sunxi-common/build/device.mk [new file with mode: 0644]
sunxi-common/build/kernel-modules.sh [new file with mode: 0755]
sunxi-common/build/kernel.mk [new file with mode: 0644]
sunxi-common/build/tools.mk [new file with mode: 0644]
sunxi-common/build/uboot.mk [new file with mode: 0644]
sunxi-common/recovery/init.recovery.sunxi-common.rc [new file with mode: 0644]
sunxi-common/recovery/recovery.fstab [new file with mode: 0644]
sunxi-common/replicant_sunxi_install.sh [new file with mode: 0755]
sunxi-common/sunxi-common.mk [new file with mode: 0644]
sunxi-common/tools/Android.mk [new file with mode: 0644]
sunxi-common/tools/common.h [new file with mode: 0644]
sunxi-common/tools/fexc.c [new file with mode: 0644]
sunxi-common/tools/fexc.h [new file with mode: 0644]
sunxi-common/tools/script.c [new file with mode: 0644]
sunxi-common/tools/script.h [new file with mode: 0644]
sunxi-common/tools/script_bin.c [new file with mode: 0644]
sunxi-common/tools/script_bin.h [new file with mode: 0644]
sunxi-common/tools/script_fex.c [new file with mode: 0644]
sunxi-common/tools/script_fex.h [new file with mode: 0644]
sunxi-common/tools/script_uboot.c [new file with mode: 0644]
sunxi-common/tools/script_uboot.h [new file with mode: 0644]
sunxi-devices/ainol_aw1/Android.mk [new file with mode: 0644]
sunxi-devices/ainol_aw1/script.fex [new file with mode: 0644]
sunxi-devices/ainol_aw1/sunxi.prop [new file with mode: 0644]
sunxi-devices/icou_fatty_i/Android.mk [new file with mode: 0644]
sunxi-devices/icou_fatty_i/script.fex [new file with mode: 0644]
sunxi-devices/icou_fatty_i/sunxi.prop [new file with mode: 0644]
sunxi-devices/tzx-q8-713b/Android.mk [new file with mode: 0644]
sunxi-devices/tzx-q8-713b/script.fex [new file with mode: 0644]
sunxi-devices/tzx-q8-713b/sunxi.prop [new file with mode: 0644]
sunxi/Android.mk [new file with mode: 0644]
sunxi/AndroidProducts.mk [new file with mode: 0644]
sunxi/BoardConfig.mk [new file with mode: 0644]
sunxi/CleanSpec.mk [new file with mode: 0644]
sunxi/cm.mk [new file with mode: 0644]
sunxi/full_sunxi.mk [new file with mode: 0644]
sunxi/recovery/init.recovery.sunxi.rc [new file with mode: 0644]
sunxi/sunxi.mk [new file with mode: 0644]

diff --git a/sunxi-common/Android.mk b/sunxi-common/Android.mk
new file mode 100644 (file)
index 0000000..19f8478
--- /dev/null
@@ -0,0 +1,18 @@
+# Copyright (C) 2014 Paul Kocialkowski <contact@paulk.fr>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+LOCAL_PATH := $(call my-dir)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/sunxi-common/BoardConfigCommon.mk b/sunxi-common/BoardConfigCommon.mk
new file mode 100644 (file)
index 0000000..356e7d7
--- /dev/null
@@ -0,0 +1,45 @@
+# Copyright (C) 2014 Paul Kocialkowski <contact@paulk.fr>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# CPU
+TARGET_CPU_ABI := armeabi-v7a
+TARGET_CPU_ABI2 := armeabi
+TARGET_ARCH := arm
+TARGET_ARCH_VARIANT := armv7-a-neon
+TARGET_GLOBAL_CFLAGS += -mtune=cortex-a8 -mfpu=neon -mfloat-abi=softfp
+TARGET_GLOBAL_CPPFLAGS += -mtune=cortex-a8 -mfpu=neon -mfloat-abi=softfp
+ARCH_ARM_HAVE_TLS_REGISTER := true
+
+# Platform
+TARGET_BOARD_PLATFORM := sunxi
+TARGET_BOOTLOADER_BOARD_NAME := sunxi
+
+# Images
+TARGET_NO_RADIOIMAGE := true
+TARGET_NO_BOOTLOADER := true
+TARGET_NO_KERNEL := false
+BOARD_USES_UBOOT := true
+BOARD_CUSTOM_BOOTIMG_MK := device/allwinner/sunxi-common/bootimg.mk
+
+# Bootloader
+TARGET_UBOOT_SOURCE := bootable/bootloader/allwinner/sunxi
+
+# Kernel
+TARGET_KERNEL_SOURCE := kernel/allwinner/sunxi
+TARGET_KERNEL_CONFIG := sunxi_defconfig
+
+# Recovery
+TARGET_RECOVERY_FSTAB := device/allwinner/sunxi-common/recovery/recovery.fstab
+TARGET_RECOVERY_PRE_COMMAND := "echo 1 > /cache/.startrecovery"
diff --git a/sunxi-common/bootable/boot.txt b/sunxi-common/bootable/boot.txt
new file mode 100644 (file)
index 0000000..5dfc9e6
--- /dev/null
@@ -0,0 +1,41 @@
+setenv kerneladdr 0x48000000
+setenv scriptaddr 0x43000000
+setenv bootargs console=${console} loglevel=${loglevel} ${bootargsextra}
+
+echo "Replicant Sunxi"
+
+if fatload mmc 0 ${scriptaddr} script.bin
+then
+       if ext4load mmc 0:3 ${kerneladdr} .startrecovery
+       then
+               if fatload mmc 0 ${kerneladdr} recovery.img
+               then
+                       bootm ${kerneladdr}
+               else
+                       echo "Loading recovery kernel failed"
+
+                       if fatload mmc 0 ${kerneladdr} boot.img
+                       then
+                               bootm ${kerneladdr}
+                       else
+                               echo "Loading kernel failed"
+                       fi
+               fi
+       fi
+
+       if fatload mmc 0 ${kerneladdr} boot.img
+       then
+               bootm ${kerneladdr}
+       else
+               echo "Loading kernel failed"
+
+               if fatload mmc 0 ${kerneladdr} recovery.img
+               then
+                       bootm ${kerneladdr}
+               else
+                       echo "Loading recovery kernel failed"
+               fi
+       fi
+else
+       echo "Loading script.bin failed"
+fi
diff --git a/sunxi-common/bootable/uEnv.txt b/sunxi-common/bootable/uEnv.txt
new file mode 100644 (file)
index 0000000..645cffb
--- /dev/null
@@ -0,0 +1,3 @@
+console=ttyS0,115200
+loglevel=5
+bootargsextra=sunxi_g2d_mem_reserve=0 sunxi_ve_mem_reserve=0 sunxi_fb_mem_reserve=20 sunxi_no_mali_mem_reserve
diff --git a/sunxi-common/bootimg.mk b/sunxi-common/bootimg.mk
new file mode 100644 (file)
index 0000000..4dff648
--- /dev/null
@@ -0,0 +1,58 @@
+# Copyright (C) 2014 Paul Kocialkowski <contact@paulk.fr>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+LOCAL_PATH := $(call my-dir)
+
+INSTALLED_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk.cpio
+INSTALLED_BOOTIMAGE_TARGETS :=  $(foreach target,$(SUNXI_KERNELS),$(PRODUCT_OUT)/boot.$(target).img)
+INSTALLED_RECOVERYIMAGE_TARGETS :=  $(foreach target,$(SUNXI_KERNELS),$(PRODUCT_OUT)/recovery.$(target).img)
+INSTALLED_BOOTABLE_TARGET := $(PRODUCT_OUT)/bootable.zip
+INSTALLED_UBOOT_SCRIPT_MODULE := $(PRODUCT_OUT)/boot.scr
+INSTALLED_UBOOT_ENV_MODULE := $(PRODUCT_OUT)/uEnv.txt
+
+BUILT_RAMDISK_TARGET := $(INSTALLED_RAMDISK_TARGET)
+
+SUNXI_KERNELS_TARGETS := $(foreach target,$(SUNXI_KERNELS),sunxi_kernel_$(target))
+SUNXI_RECOVERY_KERNELS_TARGETS := $(foreach target,$(SUNXI_KERNELS),sunxi_kernel_$(target)_recovery)
+SUNXI_DEVICES_TARGETS := $(foreach target,$(SUNXI_DEVICES),sunxi_device_$(target))
+
+include $(LOCAL_PATH)/build/tools.mk
+include $(LOCAL_PATH)/build/kernel.mk
+include $(LOCAL_PATH)/build/uboot.mk
+include $(LOCAL_PATH)/build/device.mk
+
+.PHONY: bootable
+bootable: $(INSTALLED_BOOTABLE_TARGET)
+
+$(INSTALLED_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_RAMDISK_FILES)
+       $(call pretty,"Target ram disk: $@")
+       $(hide) $(MKBOOTFS) $(TARGET_ROOT_OUT) > $@
+
+$(INSTALLED_BOOTIMAGE_TARGET): $(SUNXI_KERNELS_TARGETS)
+       @echo -e ${CL_CYN}"Made boot images: $(INSTALLED_BOOTIMAGE_TARGETS)"${CL_RST}
+
+$(INSTALLED_RECOVERYIMAGE_TARGET): $(SUNXI_RECOVERY_KERNELS_TARGETS)
+       @echo -e ${CL_CYN}"Made recovery images: $(INSTALLED_RECOVERYIMAGE_TARGETS)"${CL_RST}
+
+$(INSTALLED_BOOTLOADERIMAGE_TARGET): $(SUNXI_DEVICES_TARGETS) $(MKIMAGE)
+       @echo -e ${CL_CYN}"Made devices: $(SUNXI_DEVICES)"${CL_RST}
+       @$(MKIMAGE) -A arm -T script -C none -n "boot.scr" -d "$(LOCAL_PATH)/bootable/boot.txt" $(INSTALLED_UBOOT_SCRIPT_MODULE)
+       @echo -e ${CL_CYN}"Made U-Boot script: $(INSTALLED_UBOOT_SCRIPT_MODULE)"${CL_RST}
+       @cp "$(LOCAL_PATH)/bootable/uEnv.txt" $(INSTALLED_UBOOT_ENV_MODULE)
+       @echo -e ${CL_CYN}"Made U-Boot env: $(INSTALLED_UBOOT_ENV_MODULE)"${CL_RST}
+
+$(INSTALLED_BOOTABLE_TARGET): $(INSTALLED_RECOVERYIMAGE_TARGET) $(INSTALLED_BOOTLOADERIMAGE_TARGET) $(PRODUCT_OUT)/replicant_sunxi_install.sh
+       @(cd $(PRODUCT_OUT) && zip -rq $@ "sunxi-devices" $(notdir $(INSTALLED_UBOOT_SCRIPT_MODULE)) $(notdir $(INSTALLED_UBOOT_ENV_MODULE)) $(foreach target,$(SUNXI_KERNELS),recovery.$(target).img))
+       @echo -e ${CL_CYN}"Made bootable: $@"${CL_RST}
diff --git a/sunxi-common/build/device.mk b/sunxi-common/build/device.mk
new file mode 100644 (file)
index 0000000..5d44365
--- /dev/null
@@ -0,0 +1,23 @@
+# Copyright (C) 2014 Paul Kocialkowski <contact@paulk.fr>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+SUNXI_DEVICES_OUT := $(PRODUCT_OUT)/sunxi-devices
+SUNXI_DEVICES_PATH := device/allwinner/sunxi-devices
+
+include $(call all-makefiles-under,$(SUNXI_DEVICES_PATH))
+
+sunxi_device_%: "$(SUNXI_DEVICES_OUT)/%" $(FEX2BIN)
+       $(hide) $(FEX2BIN) < "$(SUNXI_DEVICES_PATH)/$*/script.fex" > "$(SUNXI_DEVICES_OUT)/$*/script.bin"
+       $(hide) cp "$(SUNXI_DEVICES_PATH)/$*/sunxi.prop" "$(SUNXI_DEVICES_OUT)/$*/"
diff --git a/sunxi-common/build/kernel-modules.sh b/sunxi-common/build/kernel-modules.sh
new file mode 100755 (executable)
index 0000000..fd7eb8b
--- /dev/null
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+# Copyright (C) 2014 Paul Kocialkowski <contact@paulk.fr>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+modules_out=$1
+modules_install=$2
+
+if [ $# -lt 2 ]
+then
+       exit 1
+fi
+
+version=$( ls $modules_out | head -n 1 )
+if [ -z "$version" ]
+then
+       exit 1
+fi
+
+rm -rf "$modules_install"
+mkdir -p "$modules_install"
+mv $modules_out/$version/kernel/* "$modules_install"
diff --git a/sunxi-common/build/kernel.mk b/sunxi-common/build/kernel.mk
new file mode 100644 (file)
index 0000000..e535aae
--- /dev/null
@@ -0,0 +1,53 @@
+# Copyright (C) 2014 Paul Kocialkowski <contact@paulk.fr>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+SUNXI_KERNEL_SRC := $(TARGET_KERNEL_SOURCE)
+SUNXI_KERNEL_OUT := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ
+
+ifneq ($(TARGET_KERNEL_CUSTOM_TOOLCHAIN),)
+       ifeq ($(HOST_OS),darwin)
+               ARM_CROSS_COMPILE := CROSS_COMPILE="$(ANDROID_BUILD_TOP)/prebuilt/darwin-x86/toolchain/$(TARGET_KERNEL_CUSTOM_TOOLCHAIN)/bin/arm-eabi-"
+       else
+               ARM_CROSS_COMPILE := CROSS_COMPILE="$(ANDROID_BUILD_TOP)/prebuilt/linux-x86/toolchain/$(TARGET_KERNEL_CUSTOM_TOOLCHAIN)/bin/arm-eabi-"
+       endif
+else
+       ARM_CROSS_COMPILE := CROSS_COMPILE="$(ARM_EABI_TOOLCHAIN)/arm-eabi-"
+endif
+
+sunxi_kernel_%_recovery_ramdisk: $(recovery_ramdisk)
+       @true
+
+sunxi_kernel_%_ramdisk: $(BUILT_RAMDISK_TARGET)
+       @true
+
+sunxi_kernel_%_out:
+       @mkdir -p "$(SUNXI_KERNEL_OUT)/$*"
+
+sunxi_kernel_%_config: sunxi_kernel_%_out
+       $(MAKE) -C $(SUNXI_KERNEL_SRC) O="$(SUNXI_KERNEL_OUT)/$*" ARCH=$(TARGET_ARCH) $(ARM_CROSS_COMPILE) $*_defconfig
+
+sunxi_kernel_%_image: sunxi_kernel_%_ramdisk sunxi_kernel_%_config
+       $(MAKE) -C $(SUNXI_KERNEL_SRC) O="$(SUNXI_KERNEL_OUT)/$*" ARCH=$(TARGET_ARCH) $(ARM_CROSS_COMPILE) uImage
+
+sunxi_kernel_%_modules: sunxi_kernel_%_image
+       $(MAKE) -C $(SUNXI_KERNEL_SRC) O="$(SUNXI_KERNEL_OUT)/$*" ARCH=$(TARGET_ARCH) $(ARM_CROSS_COMPILE) modules
+       $(MAKE) -C $(SUNXI_KERNEL_SRC) O="$(SUNXI_KERNEL_OUT)/$*" INSTALL_MOD_PATH="$(SUNXI_KERNEL_OUT)/$*/usr" ARCH=$(TARGET_ARCH) $(ARM_CROSS_COMPILE) modules_install
+       @device/allwinner/sunxi-common/build/kernel-modules.sh "$(SUNXI_KERNEL_OUT)/$*/usr/lib/modules" "$(TARGET_OUT)/lib/modules/$*"
+
+sunxi_kernel_%_recovery: sunxi_kernel_%_recovery_image
+       @cp "$(SUNXI_KERNEL_OUT)/$*_recovery/arch/$(TARGET_ARCH)/boot/uImage" "$(PRODUCT_OUT)/recovery.$*.img"
+
+sunxi_kernel_%: sunxi_kernel_%_modules
+       @cp "$(SUNXI_KERNEL_OUT)/$*/arch/$(TARGET_ARCH)/boot/uImage" "$(PRODUCT_OUT)/boot.$*.img"
diff --git a/sunxi-common/build/tools.mk b/sunxi-common/build/tools.mk
new file mode 100644 (file)
index 0000000..fb46e8a
--- /dev/null
@@ -0,0 +1,16 @@
+# Copyright (C) 2014 Paul Kocialkowski <contact@paulk.fr>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+FEX2BIN := $(HOST_OUT_EXECUTABLES)/fex2bin$(HOST_EXECUTABLE_SUFFIX)
diff --git a/sunxi-common/build/uboot.mk b/sunxi-common/build/uboot.mk
new file mode 100644 (file)
index 0000000..21122f3
--- /dev/null
@@ -0,0 +1,36 @@
+# Copyright (C) 2014 Paul Kocialkowski <contact@paulk.fr>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+SUNXI_UBOOT_SRC := $(TARGET_UBOOT_SOURCE)
+SUNXI_UBOOT_OUT := $(TARGET_OUT_INTERMEDIATES)/UBOOT_OBJ
+
+ifneq ($(TARGET_KERNEL_CUSTOM_TOOLCHAIN),)
+       ifeq ($(HOST_OS),darwin)
+               ARM_CROSS_COMPILE := CROSS_COMPILE="$(ANDROID_BUILD_TOP)/prebuilt/darwin-x86/toolchain/$(TARGET_KERNEL_CUSTOM_TOOLCHAIN)/bin/arm-eabi-"
+       else
+               ARM_CROSS_COMPILE := CROSS_COMPILE="$(ANDROID_BUILD_TOP)/prebuilt/linux-x86/toolchain/$(TARGET_KERNEL_CUSTOM_TOOLCHAIN)/bin/arm-eabi-"
+       endif
+else
+       ARM_CROSS_COMPILE := CROSS_COMPILE="$(ARM_EABI_TOOLCHAIN)/arm-eabi-"
+endif
+
+sunxi_uboot_%_out:
+       @mkdir -p "$(SUNXI_UBOOT_OUT)/$*"
+
+sunxi_uboot_%_config: sunxi_uboot_%_out
+       $(MAKE) -C $(SUNXI_UBOOT_SRC) O="$(SUNXI_UBOOT_OUT)/$*" ARCH=$(TARGET_ARCH) $(ARM_CROSS_COMPILE) $*_config
+
+sunxi_uboot_%: sunxi_uboot_%_config
+       $(MAKE) -C $(SUNXI_UBOOT_SRC) O="$(SUNXI_UBOOT_OUT)/$*" ARCH=$(TARGET_ARCH) $(ARM_CROSS_COMPILE)
diff --git a/sunxi-common/recovery/init.recovery.sunxi-common.rc b/sunxi-common/recovery/init.recovery.sunxi-common.rc
new file mode 100644 (file)
index 0000000..384d86b
--- /dev/null
@@ -0,0 +1,16 @@
+#on fs
+#      mount vfat /dev/block/mmcblk0p1 /boot wait
+#      mount ext4 /dev/block/mmcblk0p3 /cache wait
+#
+#on post-fs
+#      rm /cache/.startrecovery
+
+service console /sbin/sh
+       class core
+       console
+       disabled
+       user root
+       group root
+
+on property:ro.debuggable=1
+       start console
diff --git a/sunxi-common/recovery/recovery.fstab b/sunxi-common/recovery/recovery.fstab
new file mode 100644 (file)
index 0000000..625dcdf
--- /dev/null
@@ -0,0 +1,6 @@
+/boot  vfat            /dev/block/mmcblk0p1
+/system        ext4            /dev/block/mmcblk0p2
+/cache ext4            /dev/block/mmcblk0p3
+/data  ext4            /dev/block/mmcblk0p4
+
+/sdcard        datamedia       /dev/null
diff --git a/sunxi-common/replicant_sunxi_install.sh b/sunxi-common/replicant_sunxi_install.sh
new file mode 100755 (executable)
index 0000000..8a19dad
--- /dev/null
@@ -0,0 +1,645 @@
+#!/bin/sh
+
+# Replicant Sunxi installer
+#
+# Copyright (C) 2012-2014 Paul Kocialkowski <contact@paulk.fr>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+#
+# Environment
+#
+
+export LC_ALL=C
+
+#
+# Globals
+#
+
+DRIVE=""
+DRIVE_NAME=""
+DRIVE_SIZE=""
+DRIVE_CYLINDERS=""
+DRIVE_PART=""
+
+DEVICE=""
+
+SYSTEM_ZIP="replicant-4.2-sunxi.zip"
+BOOTABLE_ZIP="bootable.zip"
+
+FILES_BASE="."
+MOUNT_BASE="/media"
+
+#
+# Functions
+#
+
+# Display
+
+display_help() {
+       echo "Usage: $0 [COMMAND] [DRIVE]"
+       echo ""
+       echo "It is expected that the following files are located in $FILES_BASE:"
+       echo "  $BOOTABLE_ZIP for setup"
+       echo "  $SYSTEM_ZIP for install"
+       echo ""
+       echo "Commands:"
+       echo "  setup   - setup the drive and copy the base files"
+       echo "  select  - select which device to run for"
+       echo "  install - install the system on the drive"
+       echo ""
+       echo "Optional arguments:"
+       echo "  [DRIVE] - drive node to use"
+}
+
+display_banner() {
+       echo "Replicant Sunxi installer"
+       echo ""
+}
+
+display_complete() {
+       echo ""
+       echo "Process completed, you can now remove the card!"
+}
+
+# Drive
+
+drive_select_list() {
+       drives_dir="/dev/disk/by-id/"
+       count=0
+
+       list=$( ls "$drives_dir" )
+
+       for drive in $list
+       do
+               drive_nopart=$( echo "$drive" | sed "s/-part[0-9]*$//g" )
+               if [ "$drive" = "$drive_nopart" ]
+               then
+                       ls $drives_dir/$drive-part* 2> /dev/null > /dev/null
+
+                       if [ $? -eq 0 ]
+                       then
+                               count=$(( $count + 1 ))
+                               name=$( echo "$drive" | sed "s/^[^-]*-\(.*\)$/\1/g" )
+
+                               case "$1" in
+                                       "show")
+                                               echo "$count - $name"
+                                       ;;
+                                       "store")
+                                               if [ $count -eq $2 ]
+                                               then
+                                                       DRIVE=$( readlink -f "$drives_dir/$drive" )
+                                                       DRIVE_NAME="$name"
+                                               fi
+                                       ;;
+                               esac
+                       fi
+               fi
+       done
+}
+
+drive_select() {
+       echo "Available devices:"
+       drive_select_list "show"
+
+       echo -n "Choice: "
+       read choice
+
+       drive_select_list "store" $choice
+       echo ""
+}
+
+drive_umount() {
+       list=$( mount | grep $DRIVE | sed "s|$DRIVE[0-9]* on \([^ ]*\) .*|\1|g" )
+
+       for mount_point in $list
+       do
+               echo "Unmounting $mount_point"
+
+               umount "$mount_point"
+               if [ $? != 0 ]
+               then
+                       echo "Unmounting $mount_point failed, arborting!"
+                       exit 1
+               fi
+       done
+}
+
+drive_part() {
+       if [ -e "${DRIVE}p1" ]
+       then
+               DRIVE_PART="${DRIVE}p"
+       else
+               DRIVE_PART="${DRIVE}"
+       fi
+}
+
+# Property
+
+property_get() {
+       file=$1
+       property=$2
+
+       if [ $# -lt 2 ] || [ ! -f $file ]
+       then
+               return
+       fi
+
+       cat $file | sed "s/[[:space:]]*$property[[:space:]]*=[[:space:]]*\([^[:space:]]*\).*/\1/g" | head -n 1
+}
+
+# Setup
+
+setup_drive_confirm() {
+       if [ "$DRIVE" = "" ]
+       then
+               echo "Invalid drive block"
+               exit 1
+       fi
+
+       list=$( mount | grep $DRIVE | sed "s|$DRIVE[0-9]* on \([^ ]*\) .*|\1|g" )
+
+       echo "This is going to erase the following drive:"
+
+       if [ "$DRIVE_NAME" != "" ]
+       then
+               echo "- $DRIVE_NAME ($DRIVE)"
+       else
+               echo "- $DRIVE"
+       fi
+
+       for mount_point in $list
+       do
+               mount_point_check=$( dirname $mount_point | grep -P "^/mnt|mount" )
+               if [ "$mount_point_check" != "" ]
+               then
+                       echo ""
+                       echo "Warning: the drive is mounted as $mount_point!"
+                       echo "This is probably not the drive you want to use!"
+               fi
+       done
+
+       echo ""
+       echo -n "Are you sure? [Y/N] "
+       read confirm
+
+       if [ "$confirm" = "y" ] || [ "$confirm" = "Y" ]
+       then
+               echo ""
+               return
+       else
+               exit 0
+       fi
+}
+
+setup_drive_empty() {
+       drive_umount
+
+       # Backup
+       dd if="$DRIVE" of=".drive_start_backup" bs=1024 count=1024
+
+       dd if=/dev/zero of="$DRIVE" bs=1024 count=1024
+       if [ $? != 0 ]
+       then
+               echo "Emptying the drive failed, aborting!"
+               exit 1
+       fi
+}
+
+setup_drive_rescue() {
+       if [ -f ".drive_start_backup" ]
+       then
+               echo -n "Something went wrong, do you want to restore drive start backup? [Y/N] "
+               read confirm
+
+               if [ "$confirm" = "y" ] || [ "$confirm" = "Y" ]
+               then
+                       dd if=".drive_start_backup" of="$DRIVE" bs=1024 count=1024
+               fi
+       fi
+}
+
+setup_drive_infos() {
+       DRIVE_SIZE=$( fdisk -l "$DRIVE" | grep Disk | grep bytes | awk '{print $5}' )
+       # 255 heads, 63 sectors, 512 bytes/sectors
+       DRIVE_CYLINDERS=$( echo "$DRIVE_SIZE / 255 / 63 / 512" | bc )
+}
+
+setup_drive_partition() {
+       boot_size=$( echo "(50 * 1024 * 1024 * $DRIVE_CYLINDERS) / $DRIVE_SIZE" | bc )
+       system_size=$( echo "(350 * 1024 * 1024 * $DRIVE_CYLINDERS) / $DRIVE_SIZE" | bc )
+       cache_size=$( echo "(100 * 1024 * 1024 * $DRIVE_CYLINDERS) / $DRIVE_SIZE" | bc )
+
+       boot_offset=$( echo "(1 * 1024 * 1024) / ($DRIVE_SIZE/$DRIVE_CYLINDERS)" | bc )
+       if [ $boot_offset -lt 1 ]
+       then
+               boot_offset=1
+       fi
+
+       system_offset=$( echo "$boot_offset + $boot_size" | bc )
+       cache_offset=$( echo "$system_offset + $system_size" | bc )
+       data_offset=$( echo "$cache_offset + $cache_size" | bc )
+
+       {
+               echo "$boot_offset,$boot_size,c,*"
+               echo "$system_offset,$system_size,83,-"
+               echo "$cache_offset,$cache_size,83,-"
+               echo "$data_offset,,83,-"
+       } | sfdisk -D -H 255 -S 63 -C "$DRIVE_CYLINDERS" "$DRIVE"
+       if [ $? != 0 ]
+       then
+               setup_drive_rescue
+               exit 1
+       fi
+
+       sleep 1
+
+       drive_part
+
+       mkfs.vfat -F 32 -n "boot" "${DRIVE_PART}1"
+       mkfs.ext4 -L "system" "${DRIVE_PART}2"
+       mkfs.ext4 -L "cache" "${DRIVE_PART}3"
+       mkfs.ext4 -L "data" "${DRIVE_PART}4"
+
+       sleep 1
+}
+
+setup_boot_install() {
+       echo "Installing boot files"
+
+       drive_part
+
+       mkdir -p "$MOUNT_BASE/boot"
+       mount "${DRIVE_PART}1" "$MOUNT_BASE/boot"
+
+       unzip -o "$FILES_BASE/$BOOTABLE_ZIP" "**" -d "$MOUNT_BASE/boot/"
+
+       dir=$( pwd )
+       echo "Syncing boot files"
+       cd "$MOUNT_BASE/boot"
+       sync
+       cd "$dir"
+
+       umount "$MOUNT_BASE/boot"
+       rmdir "$MOUNT_BASE/boot"
+}
+
+setup_drive_eject() {
+       rm -rf ".drive_start_backup"
+       eject "$DRIVE"
+}
+
+# Select
+
+select_device_list() {
+       count=0
+
+       list=$( ls "$MOUNT_BASE/boot/sunxi-devices" )
+
+       for device in $list
+       do
+               count=$(( $count + 1 ))
+
+               case "$1" in
+               "show")
+                       echo "$count - $device"
+               ;;
+               "store")
+                       if [ $count -eq $2 ]
+                       then
+                               DEVICE=$device
+                       fi
+               ;;
+               esac
+       done
+}
+
+select_device() {
+       if [ ! -d "$MOUNT_BASE/boot/sunxi-devices" ]
+       then
+               echo "Sunxi devices are not installed"
+               exit 1
+       fi
+
+       echo "Available Sunxi devices:"
+       select_device_list "show"
+
+       echo -n "Choice: "
+       read choice
+
+       select_device_list "store" $choice
+       echo ""
+
+       dd if="$MOUNT_BASE/boot/sunxi-devices/$DEVICE/sunxi-spl.bin" of=$DRIVE bs=1024 seek=8
+       dd if="$MOUNT_BASE/boot/sunxi-devices/$DEVICE/u-boot.img" of=$DRIVE bs=1024 seek=40
+
+       cp "$MOUNT_BASE/boot/sunxi-devices/$DEVICE/script.bin" "$MOUNT_BASE/boot/"
+       cp "$MOUNT_BASE/boot/sunxi-devices/$DEVICE/sunxi.prop" "$MOUNT_BASE/boot/"
+
+       sunxi_platform=$( property_get "$MOUNT_BASE/boot/sunxi.prop" "sunxi.platform" )
+
+       if [ -f "$MOUNT_BASE/boot/recovery.$sunxi_platform.img" ]
+       then
+               cp "$MOUNT_BASE/boot/recovery.$sunxi_platform.img" "$MOUNT_BASE/boot/recovery.img"
+       fi
+
+       if [ -f "$MOUNT_BASE/boot/boot.$sunxi_platform.img" ]
+       then
+               cp "$MOUNT_BASE/boot/boot.$sunxi_platform.img" "$MOUNT_BASE/boot/boot.img"
+       fi
+}
+
+select_drive_mount() {
+       drive_part
+
+       drive_umount
+
+       mkdir -p "$MOUNT_BASE/boot"
+       mount "${DRIVE_PART}1" "$MOUNT_BASE/boot"
+
+       echo ""
+}
+
+select_drive_umount() {
+       drive_part
+
+       dir=$( pwd )
+       echo "Syncing files"
+
+       cd "$MOUNT_BASE/boot"
+       sync
+       cd "$dir"
+
+       umount "$MOUNT_BASE/boot"
+       rmdir "$MOUNT_BASE/boot"
+}
+
+select_drive_eject() {
+       eject "$DRIVE"
+}
+
+# Install
+
+install_package_extract_dir() {
+       destination="$MOUNT_BASE"$( dirname "$2")
+
+       if [ $# -lt 2 ]
+       then
+               return
+       fi
+
+       unzip -o "$FILES_BASE/$SYSTEM_ZIP" "$1/**" -d "$destination"
+}
+
+install_package_extract_file() {
+       destination="$MOUNT_BASE"$( dirname "$2")
+
+       if [ $# -lt 2 ]
+       then
+               return
+       fi
+
+       unzip -o "$FILES_BASE/$SYSTEM_ZIP" "$1" -d "$destination"
+}
+
+install_symlink() {
+       source=""
+
+       if [ $# -lt 2 ]
+       then
+               return
+       fi
+
+       for path in $@
+       do
+               if [ "$source" = "" ]
+               then
+                       source="$path"
+                       continue
+               fi
+
+               unlink "$MOUNT_BASE$path"
+               ln -s "$source" "$MOUNT_BASE$path"
+       done
+}
+
+install_set_perm() {
+       uid=""
+       gid=""
+       mode=""
+
+       if [ $# -lt 4 ]
+       then
+               return
+       fi
+
+       for value in $@
+       do
+               if [ "$uid" = "" ]
+               then
+                       uid="$value"
+                       continue
+               fi
+
+               if [ "$gid" = "" ]
+               then
+                       gid="$value"
+                       continue
+               fi
+
+               if [ "$mode" = "" ]
+               then
+                       mode="$value"
+                       continue
+               fi
+
+               chown "$uid:$gid" "$MOUNT_BASE$value"
+               chmod "$mode" "$MOUNT_BASE$value"
+       done
+}
+
+install_set_perm_recursive() {
+       uid=""
+       gid=""
+       dir_mode=""
+       file_mode=""
+
+       if [ $# -lt 4 ]
+       then
+               return
+       fi
+
+       for value in $@
+       do
+               if [ "$uid" = "" ]
+               then
+                       uid="$value"
+                       continue
+               fi
+
+               if [ "$gid" = "" ]
+               then
+                       gid="$value"
+                       continue
+               fi
+
+               if [ "$dir_mode" = "" ]
+               then
+                       dir_mode="$value"
+                       continue
+               fi
+
+               if [ "$file_mode" = "" ]
+               then
+                       file_mode="$value"
+                       continue
+               fi
+
+               find "$MOUNT_BASE$value" -type d -exec chown "$uid:$gid" {} \; -exec chmod "$dir_mode" {} \;
+               find "$MOUNT_BASE$value" -type f -exec chown "$uid:$gid" {} \; -exec chmod "$file_mode" {} \;
+       done
+}
+
+install_command() {
+       command=$( echo "$1" | sed "s/[ \t]*\([^(]*\)(.*/\1/g" )
+       arguments=$( echo "$1" | sed -e "s/[^(]*(\([^)]*\));.*/\1/g" -e "s/[ \t]*,[ \t]*/ /g" | tr -d '"')
+
+       case "$command" in
+               "package_extract_dir")
+                       install_package_extract_dir $arguments
+               ;;
+               "package_extract_file")
+                       install_package_extract_file $arguments
+               ;;
+               "symlink")
+                       install_symlink $arguments
+               ;;
+               "set_perm")
+                       install_set_perm $arguments
+               ;;
+               "set_perm_recursive")
+                       install_set_perm_recursive $arguments
+               ;;
+       esac
+}
+
+install_script() {
+       unzip -p "$FILES_BASE/$SYSTEM_ZIP" "META-INF/com/google/android/updater-script" | while read line
+       do
+               end_test=$( echo "$line" | grep -P "\);$" )
+
+               COMMAND="$COMMAND$line"
+
+               if [ "$end_test" != "" ]
+               then
+                       install_command "$COMMAND"
+
+                       COMMAND=""
+               fi
+       done
+}
+
+install_drive_mount() {
+       drive_part
+
+       drive_umount
+
+       mkdir -p "$MOUNT_BASE/boot"
+       mount "${DRIVE_PART}1" "$MOUNT_BASE/boot"
+
+       mkdir -p "$MOUNT_BASE/system"
+       mount "${DRIVE_PART}2" "$MOUNT_BASE/system"
+}
+
+install_drive_umount() {
+       drive_part
+
+       dir=$( pwd )
+       echo "Syncing files"
+
+       cd "$MOUNT_BASE/boot"
+       sync
+       cd "$dir"
+
+       cd "$MOUNT_BASE/system"
+       sync
+       cd "$dir"
+
+       umount "$MOUNT_BASE/boot"
+       rmdir "$MOUNT_BASE/boot"
+
+       umount "$MOUNT_BASE/system"
+       rmdir "$MOUNT_BASE/system"
+}
+
+install_drive_eject() {
+       eject "$DRIVE"
+}
+
+#
+# Main
+#
+
+if [ $# -lt 1 ] || [ $# -gt 2 ]
+then
+       display_help
+       exit 1
+fi
+
+if [ $# -gt 1 ]
+then
+       DRIVE=$2
+fi
+
+display_banner
+
+if [ "$DRIVE" = "" ]
+then
+       drive_select
+fi
+
+case $1 in
+       "setup")
+               setup_drive_confirm
+               drive_umount
+               setup_drive_empty
+               setup_drive_infos
+               setup_drive_partition
+               setup_boot_install
+               setup_drive_eject
+
+               display_complete
+       ;;
+       "select")
+               select_drive_mount
+               select_device
+               select_drive_umount
+               select_drive_eject
+
+               display_complete
+       ;;
+       "install")
+               install_drive_mount
+               install_script
+               install_drive_umount
+               install_drive_eject
+
+               display_complete
+       ;;
+       *)
+               display_help
+               exit 1
+       ;;
+esac
diff --git a/sunxi-common/sunxi-common.mk b/sunxi-common/sunxi-common.mk
new file mode 100644 (file)
index 0000000..495f557
--- /dev/null
@@ -0,0 +1,22 @@
+# Copyright (C) 2014 Paul Kocialkowski <contact@paulk.fr>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Install script
+PRODUCT_COPY_FILES += \
+       device/allwinner/sunxi-common/replicant_sunxi_install.sh:replicant_sunxi_install.sh
+
+# Recovery
+PRODUCT_COPY_FILES += \
+       device/allwinner/sunxi-common/recovery/init.recovery.sunxi-common.rc:root/init.recovery.sunxi-common.rc
diff --git a/sunxi-common/tools/Android.mk b/sunxi-common/tools/Android.mk
new file mode 100644 (file)
index 0000000..30e716f
--- /dev/null
@@ -0,0 +1,28 @@
+# Copyright (C) 2014 Paul Kocialkowski <contact@paulk.fr>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := fexc.c script.c script_uboot.c script_bin.c script_fex.c
+
+LOCAL_C_INCLUDES := $(LOCAL_PATH)
+LOCAL_CFLAGS := -std=c99 -D_GNU_SOURCE
+
+LOCAL_MODULE := fex2bin
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_HOST_EXECUTABLE)
diff --git a/sunxi-common/tools/common.h b/sunxi-common/tools/common.h
new file mode 100644 (file)
index 0000000..90eccff
--- /dev/null
@@ -0,0 +1,107 @@
+/*
+ * Copyright (C) 2012  Alejandro Mery <amery@geeks.cl>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef _SUNXI_TOOLS_COMMON_H
+#define _SUNXI_TOOLS_COMMON_H
+
+#include <stddef.h> /* offsetof */
+
+/** flat function argument as unused */
+#ifdef UNUSED
+#elif defined(__GNUC__)
+#      define UNUSED(x) UNUSED_ ## x __attribute__((unused))
+#else
+#      define UNUSED(x) UNUSED_ ## x
+#endif
+
+/** finds the parent of an struct member */
+#ifndef container_of
+#define container_of(P,T,M)    (T *)((char *)(P) - offsetof(T, M))
+#endif
+
+/** calculate number of elements of an array */
+#ifndef ARRAY_SIZE
+#define ARRAY_SIZE(A)          (sizeof(A)/sizeof((A)[0]))
+#endif
+
+/** shortcut to printf to stderr */
+#define errf(...)      fprintf(stderr, __VA_ARGS__)
+
+/*
+ * list
+ */
+
+/** a list hook */
+struct list_entry {
+       struct list_entry *prev;
+       struct list_entry *next;
+};
+
+/** initialize an empty list hook */
+static inline void list_init(struct list_entry *self)
+{
+       self->prev = self->next = self;
+}
+
+/** puts an entry between two other on a list */
+static inline void list_inject(struct list_entry *l,
+                              struct list_entry *prev,
+                              struct list_entry *next)
+{
+       l->prev = prev;
+       l->next = next;
+
+       next->prev = l;
+       prev->next = l;
+}
+
+#define list_insert(H, E)      list_inject((E), (H), (H)->next)
+#define list_append(H, E)      list_inject((E), (H)->prev, (H))
+
+/** removes an entry for the list where it's contained */
+static inline void list_remove(struct list_entry *l)
+{
+       struct list_entry *prev = l->prev, *next = l->next;
+       next->prev = prev;
+       prev->next = next;
+}
+
+/** returns first element of a list */
+static inline struct list_entry *list_first(struct list_entry *l)
+{
+       return (l->next == l) ? NULL : l->next;
+}
+
+/** returns last element of a list */
+static inline struct list_entry *list_last(struct list_entry *l)
+{
+       return (l->prev == l) ? NULL : l->prev;
+}
+
+/** returns next element on a list */
+static inline struct list_entry *list_next(struct list_entry *l,
+                                          struct list_entry *e)
+{
+       return (e->next == l) ? NULL : e->next;
+}
+
+/** is list empty? */
+static inline int list_empty(struct list_entry *l)
+{
+       return (l->prev == l);
+}
+
+#endif
diff --git a/sunxi-common/tools/fexc.c b/sunxi-common/tools/fexc.c
new file mode 100644 (file)
index 0000000..234b1c9
--- /dev/null
@@ -0,0 +1,329 @@
+/*
+ * Copyright (C) 2012  Alejandro Mery <amery@geeks.cl>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "fexc.h"
+
+#include <errno.h>
+#include <libgen.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+#define pr_info(...)   errf("fexc: " __VA_ARGS__)
+#define pr_err(...)    errf("E: fexc: " __VA_ARGS__)
+
+enum script_format {
+       FEX_SCRIPT_FORMAT,
+       BIN_SCRIPT_FORMAT,
+       UBOOT_HEADER_FORMAT,
+};
+
+/*
+ */
+static inline char *read_all(int fd, const char *filename, size_t *size)
+{
+       size_t buf_size = 4096, count = 0;
+       char *p, *buf = malloc(buf_size);
+       if (!buf) {
+               pr_err("%s: %s\n", "malloc", strerror(errno));
+               return NULL;
+       }
+       p = buf;
+       while (1) {
+               ssize_t rc = read(fd, p, buf_size-count);
+               if (rc == 0)
+                       break;
+               else if (rc > 0) {
+                       count += rc;
+                       p += rc;
+
+                       if (count == buf_size) {
+                               char *new;
+                               buf_size *= 2;
+                               new = realloc(buf, buf_size);
+                               if (!new) {
+                                       pr_err("%s: %s\n", "realloc",
+                                              strerror(errno));
+                                       free(buf);
+                                       return NULL;
+                               } else if (new != buf) {
+                                       buf = new;
+                                       p = buf + count;
+                               }
+                       }
+               } else if (errno != EAGAIN && errno != EINTR) {
+                       pr_err("%s: %s: %s\n", filename,
+                              "read", strerror(errno));
+                       free(buf);
+                       return NULL;
+               }
+       }
+
+       *size = count;
+       return buf;
+}
+
+/*
+ */
+static inline int script_parse(enum script_format format,
+                              const char *filename,
+                              struct script *script)
+{
+       int ret = 0;
+       switch (format) {
+       case FEX_SCRIPT_FORMAT: {
+               FILE *in = stdin;
+               if (!filename)
+                       filename = "<stdin>";
+               else if ((in = fopen(filename, "r")) == NULL) {
+                       pr_err("%s: %s\n", filename, strerror(errno));
+                       break;
+               }
+               ret = script_parse_fex(in, filename, script);
+               fclose(in);
+               }; break;
+       case BIN_SCRIPT_FORMAT: {
+               int in = 0; /* stdin */
+               struct stat sb;
+               void *bin = NULL;
+               size_t bin_size;
+               int allocated = 1;
+
+               if (!filename)
+                       filename = "<stdin>";
+               else if ((in = open(filename, O_RDONLY)) < 0) {
+                       pr_err("%s: %s\n", filename, strerror(errno));
+                       break;
+               }
+
+               if (fstat(in, &sb) == -1) {
+                       pr_err("%s: %s: %s\n", filename,
+                              "fstat", strerror(errno));
+                       goto bin_close;
+               } else if (S_ISREG(sb.st_mode)) {
+                       /* regular file, mmap it */
+                       bin = mmap(0, sb.st_size, PROT_READ, MAP_SHARED, in, 0);
+                       if (bin == MAP_FAILED) {
+                               pr_err("%s: %s: %s\n", filename,
+                                      "mmap", strerror(errno));
+                               goto bin_close;
+                       }
+                       bin_size = sb.st_size;
+                       allocated = 0;
+               } else {
+                       /* something else... just read it all! */
+                       bin = read_all(in, filename, &bin_size);
+                       if (bin == NULL)
+                               goto bin_close;
+                       allocated = 1;
+               }
+
+               ret = script_decompile_bin(bin, bin_size, filename, script);
+               if (allocated)
+                       free(bin);
+               else if (munmap(bin, bin_size) == -1) {
+                       pr_err("%s: %s: %s\n", filename,
+                              "munmap", strerror(errno));
+               }
+bin_close:
+               close(in);
+               }; break;
+       case UBOOT_HEADER_FORMAT: /* not valid input */
+               ;
+       }
+       return ret;
+}
+static inline int script_generate(enum script_format format,
+                                 const char *filename,
+                                 struct script *script)
+{
+       int ret = 0;
+       static int (*text_gen[3]) (FILE *, const char *, struct script *) = {
+               [FEX_SCRIPT_FORMAT] = script_generate_fex,
+               [UBOOT_HEADER_FORMAT] = script_generate_uboot,
+       };
+
+       if (text_gen[format]) {
+               FILE *out = stdout;
+
+               if (!filename)
+                       filename = "<stdout>";
+               else if ((out = fopen(filename, "w")) == NULL) {
+                       pr_err("%s: %s\n", filename, strerror(errno));
+                       goto done;
+               }
+
+               ret = text_gen[format](out, filename, script);
+               fclose(out);
+       } else {
+               int out = 1; /* stdout */
+               size_t sections, entries, bin_size;
+               void *bin;
+
+               if (!filename)
+                       filename = "<stdout>";
+               else if ((out = open(filename, O_WRONLY|O_CREAT|O_TRUNC, 0666)) < 0) {
+                       pr_err("%s: %s\n", filename, strerror(errno));
+                       goto done;
+               }
+
+               bin_size = script_bin_size(script, &sections, &entries);
+               bin = calloc(1, bin_size);
+               if (!bin)
+                       pr_err("%s: %s\n", "malloc", strerror(errno));
+               else if (script_generate_bin(bin, bin_size, script, sections, entries)) {
+                       char *p = bin;
+                       while(bin_size) {
+                               ssize_t wc = write(out, p, bin_size);
+
+                               if (wc>0) {
+                                       p += wc;
+                                       bin_size -= wc;
+                               } else if (wc < 0 && errno != EINTR) {
+                                       pr_err("%s: %s: %s\n", filename,
+                                              "write", strerror(errno));
+                                       break;
+                               }
+                       }
+                       ret = (bin_size == 0);
+               }
+               free(bin);
+               close(out);
+       }
+done:
+       return ret;
+}
+
+/*
+ */
+static inline void app_usage(const char *arg0, int mode)
+{
+       errf("Usage: %s [-vq]%s[<input> [<output>]]\n", arg0,
+            mode ? " " : " [-I <infmt>] [-O <outfmt>] ");
+
+       if (mode == 0)
+               fputs("\ninfmt:  fex, bin  (default:fex)"
+                     "\noutfmt: fex, bin, uboot  (default:bin)\n",
+                     stderr);
+}
+
+static inline int app_choose_mode(char *arg0)
+{
+       const char *name = basename(arg0);
+       if (strcmp(name, "fex2bin") == 0)
+               return 1;
+       else if (strcmp(name, "bin2fex") == 0)
+               return 2;
+       else
+               return 0;
+}
+
+/*
+ */
+int main(int argc, char *argv[])
+{
+       static const char *formats[] = { "fex", "bin", "uboot", NULL };
+       enum script_format infmt=FEX_SCRIPT_FORMAT;
+       enum script_format outfmt=BIN_SCRIPT_FORMAT;
+       const char *filename[] = { NULL /*stdin*/, NULL /*stdout*/};
+       struct script *script;
+
+       int app_mode = app_choose_mode(argv[0]);
+
+       const char *opt_string = "I:O:vq?"+ ((app_mode == 0)? 0: 4);
+       int opt, ret = 1;
+       int verbose = 0;
+
+       if (app_mode == 2) { /* bin2fex */
+               infmt = BIN_SCRIPT_FORMAT;
+               outfmt = FEX_SCRIPT_FORMAT;
+       }
+
+       while ((opt = getopt(argc, argv, opt_string)) != -1) {
+               switch (opt) {
+               case 'I':
+                       infmt=0;
+                       for (const char **f = formats; *f; f++, infmt++) {
+                               if (strcmp(*f, optarg) == 0)
+                                       break;
+                       }
+                       switch (infmt) {
+                       case FEX_SCRIPT_FORMAT:
+                       case BIN_SCRIPT_FORMAT:
+                               break;
+                       default:
+                               errf("%s: invalid format -- \"%s\"\n",
+                                    argv[0], optarg);
+                               goto show_usage;
+                       }
+                       break;
+               case 'O':
+                       outfmt=0;
+                       for (const char **f = formats; *f; f++, outfmt++) {
+                               if (strcmp(*f, optarg) == 0)
+                                       break;
+                       }
+                       if (!formats[outfmt]) {
+                               errf("%s: invalid format -- \"%s\"\n",
+                                    argv[0], optarg);
+                               goto show_usage;
+                       }
+                       break;
+               case 'v':
+                       verbose++;
+                       break;
+               case 'q':
+                       verbose--;
+                       break;
+               default:
+show_usage:
+                       app_usage(argv[0], app_mode);
+                       goto done;
+               }
+       }
+
+       switch (argc - optind) {
+       case 2:
+               filename[1] = argv[optind+1]; /* out */
+       case 1:
+               if (strcmp(argv[optind], "-") != 0)
+                       filename[0] = argv[optind]; /* in */
+       case 0:
+               break;
+       default:
+               goto show_usage;
+       }
+
+       if (verbose>0)
+               errf("%s: from %s:%s to %s:%s\n", argv[0],
+                    formats[infmt], filename[0]?filename[0]:"<stdin>",
+                    formats[outfmt], filename[1]?filename[1]:"<stdout>");
+
+       if ((script = script_new()) == NULL) {
+               perror("malloc");
+               goto done;
+       } else if (script_parse(infmt, filename[0], script) &&
+                  script_generate(outfmt, filename[1], script)) {
+               ret = 0;
+       }
+       script_delete(script);
+done:
+       return ret;
+}
diff --git a/sunxi-common/tools/fexc.h b/sunxi-common/tools/fexc.h
new file mode 100644 (file)
index 0000000..c5b32a9
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2012  Alejandro Mery <amery@geeks.cl>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef _SUNXI_TOOLS_FEXC_H
+#define _SUNXI_TOOLS_FEXC_H
+
+#include "common.h"
+
+#include <stdint.h>
+#include <stdio.h>
+
+#include "script.h"
+#include "script_bin.h"
+#include "script_fex.h"
+#include "script_uboot.h"
+
+#endif
diff --git a/sunxi-common/tools/script.c b/sunxi-common/tools/script.c
new file mode 100644 (file)
index 0000000..3a9c7e7
--- /dev/null
@@ -0,0 +1,268 @@
+/*
+ * Copyright (C) 2012  Alejandro Mery <amery@geeks.cl>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "common.h"
+
+#include <assert.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "script.h"
+
+/*
+ */
+struct script *script_new(void)
+{
+       struct script *script;
+       if ((script = malloc(sizeof(*script))))
+               list_init(&script->sections);
+       return script;
+}
+
+void script_delete(struct script *script)
+{
+       struct list_entry *o;
+
+       assert(script);
+
+       while ((o = list_last(&script->sections))) {
+               struct script_section *section = container_of(o,
+                              struct script_section, sections);
+
+               script_section_delete(section);
+       }
+
+       free(script);
+}
+
+/*
+ */
+struct script_section *script_section_new(struct script *script,
+                                         const char *name)
+{
+       struct script_section *section;
+
+       assert(script);
+       assert(name && *name);
+
+       if ((section = malloc(sizeof(*section)))) {
+               size_t l = strlen(name);
+               if (l>31) /* truncate */
+                       l=31;
+               memcpy(section->name, name, l);
+               section->name[l] = '\0';
+
+               list_init(&section->entries);
+               list_append(&script->sections, &section->sections);
+       }
+       return section;
+}
+
+void script_section_delete(struct script_section *section)
+{
+       struct list_entry *o;
+
+       assert(section);
+
+       while ((o = list_last(&section->entries))) {
+               struct script_entry *entry = container_of(o,
+                              struct script_entry, entries);
+
+               script_entry_delete(entry);
+       }
+
+       if (!list_empty(&section->sections))
+               list_remove(&section->sections);
+}
+
+struct script_section *script_find_section(struct script *script,
+                                          const char *name)
+{
+       struct list_entry *o;
+       struct script_section *section;
+
+       assert(script);
+       assert(name);
+
+       for (o = list_first(&script->sections); o;
+            o = list_next(&script->sections, o)) {
+               section = container_of(o, struct script_section, sections);
+
+               if (strcmp(section->name, name) == 0)
+                       return section;
+       }
+
+       return NULL;
+}
+
+/*
+ */
+static inline void script_entry_append(struct script_section *section,
+                                      struct script_entry *entry,
+                                      enum script_value_type type,
+                                      const char *name)
+{
+       size_t l;
+
+       assert(section);
+       assert(entry);
+       assert(name);
+
+       l = strlen(name);
+       if (l>31) /* truncate */
+               l=31;
+       memcpy(entry->name, name, l);
+       entry->name[l] = '\0';
+
+       entry->type = type;
+
+       list_append(&section->entries, &entry->entries);
+}
+
+void script_entry_delete(struct script_entry *entry)
+{
+       void *container;
+
+       assert(entry);
+       assert(entry->type == SCRIPT_VALUE_TYPE_SINGLE_WORD ||
+              entry->type == SCRIPT_VALUE_TYPE_STRING ||
+              entry->type == SCRIPT_VALUE_TYPE_GPIO ||
+              entry->type == SCRIPT_VALUE_TYPE_NULL);
+
+       if (!list_empty(&entry->entries))
+               list_remove(&entry->entries);
+
+       switch(entry->type) {
+       case SCRIPT_VALUE_TYPE_SINGLE_WORD:
+               container = container_of(entry, struct script_single_entry, entry);
+               break;
+       case SCRIPT_VALUE_TYPE_STRING:
+               container = container_of(entry, struct script_string_entry, entry);
+               break;
+       case SCRIPT_VALUE_TYPE_GPIO:
+               container = container_of(entry, struct script_gpio_entry, entry);
+               break;
+       case SCRIPT_VALUE_TYPE_NULL:
+               container = container_of(entry, struct script_null_entry, entry);
+               break;
+       default:
+               abort();
+       }
+
+       free(container);
+}
+
+struct script_null_entry *script_null_entry_new(struct script_section *section,
+                                               const char *name)
+{
+       struct script_null_entry *entry;
+
+       assert(section);
+       assert(name && *name);
+
+       if ((entry = malloc(sizeof(*entry)))) {
+               script_entry_append(section, &entry->entry,
+                                   SCRIPT_VALUE_TYPE_NULL, name);
+       }
+
+       return entry;
+}
+
+struct script_single_entry *script_single_entry_new(struct script_section *section,
+                                                   const char *name,
+                                                   uint32_t value)
+{
+       struct script_single_entry *entry;
+
+       assert(section);
+       assert(name && *name);
+
+       if ((entry = malloc(sizeof(*entry)))) {
+               entry->value = value;
+
+               script_entry_append(section, &entry->entry,
+                                   SCRIPT_VALUE_TYPE_SINGLE_WORD, name);
+       }
+
+       return entry;
+}
+
+struct script_string_entry *script_string_entry_new(struct script_section *section,
+                                                      const char *name,
+                                                      size_t l, const char *s)
+{
+       struct script_string_entry *entry;
+
+       assert(section);
+       assert(name);
+       assert(s);
+
+       if ((entry = malloc(sizeof(*entry)+l+1))) {
+               entry->l = l;
+               memcpy(entry->string, s, l);
+               entry->string[l] = '\0';
+
+               script_entry_append(section, &entry->entry,
+                                   SCRIPT_VALUE_TYPE_STRING, name);
+       }
+
+       return entry;
+}
+
+struct script_gpio_entry *script_gpio_entry_new(struct script_section *section,
+                                               const char *name,
+                                               unsigned port, unsigned num,
+                                               int32_t data[4])
+{
+       struct script_gpio_entry *entry;
+
+       assert(section);
+       assert(name && *name);
+
+       if ((entry = malloc(sizeof(*entry)))) {
+               entry->port = port;
+               entry->port_num = num;
+               for (int i=0; i<4; i++)
+                       entry->data[i] = data[i];
+
+               script_entry_append(section, &entry->entry,
+                                   SCRIPT_VALUE_TYPE_GPIO, name);
+       }
+
+       return entry;
+}
+
+struct script_entry *script_find_entry(struct script_section *section,
+                                      const char *name)
+{
+       struct list_entry *o;
+       struct script_entry *ep;
+
+       assert(section);
+       assert(name);
+
+       for (o = list_first(&section->entries); o;
+            o = list_next(&section->entries, o)) {
+               ep = container_of(o, struct script_entry, entries);
+
+               if (strcmp(ep->name, name) == 0)
+                       return ep;
+       }
+
+       return NULL;
+}
diff --git a/sunxi-common/tools/script.h b/sunxi-common/tools/script.h
new file mode 100644 (file)
index 0000000..e4c1ada
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+ * Copyright (C) 2012  Alejandro Mery <amery@geeks.cl>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef _SUNXI_TOOLS_SCRIPT_H
+#define _SUNXI_TOOLS_SCRIPT_H
+
+#define GPIO_BANK_MAX  13 /* N */
+
+/** head of the data tree */
+struct script {
+       struct list_entry sections;
+};
+
+/** head of each section */
+struct script_section {
+       char name[32];
+
+       struct list_entry sections;
+       struct list_entry entries;
+};
+
+/** types of values */
+enum script_value_type {
+       SCRIPT_VALUE_TYPE_SINGLE_WORD = 1,
+       SCRIPT_VALUE_TYPE_STRING,
+       SCRIPT_VALUE_TYPE_MULTI_WORD,
+       SCRIPT_VALUE_TYPE_GPIO,
+       SCRIPT_VALUE_TYPE_NULL,
+};
+
+/** generic entry */
+struct script_entry {
+       char name[32];
+       enum script_value_type type;
+
+       struct list_entry entries;
+};
+
+/** null entry */
+struct script_null_entry {
+       struct script_entry entry;
+};
+
+/** entry with 32b value */
+struct script_single_entry {
+       struct script_entry entry;
+
+       uint32_t value;
+};
+
+/** entry with string value */
+struct script_string_entry {
+       struct script_entry entry;
+
+       size_t l;
+       char string[];
+};
+
+/** entry describing a GPIO */
+struct script_gpio_entry {
+       struct script_entry entry;
+
+       unsigned port, port_num;
+       int32_t data[4];
+};
+
+/** create a new script tree */
+struct script *script_new(void);
+/** deletes a tree recursively */
+void script_delete(struct script *);
+
+/** create a new section appended to a given tree */
+struct script_section *script_section_new(struct script *script,
+                                         const char *name);
+/** deletes a section recursvely and removes it from the script */
+void script_section_delete(struct script_section *section);
+
+/** find existing section */
+struct script_section *script_find_section(struct script *script,
+                                          const char *name);
+
+/** deletes an entry and removes it from the section */
+void script_entry_delete(struct script_entry *entry);
+
+/** create a new empty/null entry appended to a section */
+struct script_null_entry *script_null_entry_new(struct script_section *section,
+                                               const char *name);
+/** create a new single word entry appended to a section */
+struct script_single_entry *script_single_entry_new(struct script_section *section,
+                                                   const char *name,
+                                                   uint32_t value);
+/** create a new string entry appended to a section */
+struct script_string_entry *script_string_entry_new(struct script_section *section,
+                                                   const char *name,
+                                                   size_t l, const char *s);
+/** create a new GPIO entry appended to a section */
+struct script_gpio_entry *script_gpio_entry_new(struct script_section *script,
+                                               const char *name,
+                                               unsigned port, unsigned num,
+                                               int32_t data[4]);
+
+/** find existing entry in a giving section */
+struct script_entry *script_find_entry(struct script_section *section,
+                                      const char *name);
+#endif
diff --git a/sunxi-common/tools/script_bin.c b/sunxi-common/tools/script_bin.c
new file mode 100644 (file)
index 0000000..cd71218
--- /dev/null
@@ -0,0 +1,314 @@
+/*
+ * Copyright (C) 2012  Alejandro Mery <amery@geeks.cl>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "common.h"
+
+#include <errno.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "script.h"
+#include "script_bin.h"
+
+#define pr_info(...)   errf("fexc-bin: " __VA_ARGS__)
+#define pr_err(...)    errf("E: fexc-bin: " __VA_ARGS__)
+
+#ifdef DEBUG
+#define pr_debug(...)  errf("D: fexc-bin: " __VA_ARGS__)
+#else
+#define pr_debug(...)
+#endif
+
+#define PTR(B, OFF)    (void*)((char*)(B)+(OFF))
+#define WORDS(S)       (((S)+(sizeof(uint32_t)-1))/(sizeof(uint32_t)))
+
+/*
+ * generator
+ */
+size_t script_bin_size(struct script *script,
+                      size_t *sections, size_t *entries)
+{
+       size_t words = 0, bin_size = 0;
+       struct list_entry *ls, *le;
+       struct script_section *section;
+       struct script_entry *entry;
+       struct script_string_entry *string;
+
+       *sections = *entries = 0;
+
+       /* count */
+       for (ls = list_first(&script->sections); ls;
+            ls = list_next(&script->sections, ls)) {
+               section = container_of(ls, struct script_section, sections);
+               size_t c = 0;
+
+               for (le = list_first(&section->entries); le;
+                    le = list_next(&section->entries, le)) {
+                       size_t size = 0;
+                       entry = container_of(le, struct script_entry, entries);
+                       c++;
+
+                       switch(entry->type) {
+                       case SCRIPT_VALUE_TYPE_NULL:
+                       case SCRIPT_VALUE_TYPE_SINGLE_WORD:
+                               size = sizeof(uint32_t);
+                               break;
+                       case SCRIPT_VALUE_TYPE_STRING:
+                               string = container_of(entry, struct script_string_entry,
+                                                     entry);
+                               size = string->l;
+                               break;
+                       case SCRIPT_VALUE_TYPE_GPIO:
+                               size = sizeof(struct script_bin_gpio_value);
+                               break;
+                       default:
+                               abort();
+                       }
+                       words += WORDS(size);
+               }
+               if (c>0) {
+                       *sections += 1;
+                       *entries += c;
+               }
+       }
+
+       bin_size = sizeof(struct script_bin_head) +
+               (*sections)*sizeof(struct script_bin_section) +
+               (*entries)*sizeof(struct script_bin_entry) +
+               words*sizeof(uint32_t);
+       pr_debug("sections:%zu entries:%zu data:%zu/%zu -> %zu\n",
+                *sections, *entries, words, words*sizeof(uint32_t),
+                bin_size);
+       return bin_size;
+}
+
+int script_generate_bin(void *bin, size_t UNUSED(bin_size),
+                       struct script *script,
+                       size_t sections, size_t entries)
+{
+       struct script_bin_head *head;
+       struct script_bin_section *section;
+       struct script_bin_entry *entry;
+       void *data;
+
+       struct list_entry *ls, *le;
+
+       head = bin;
+       section = head->section;
+       entry = (void*)section+sections*sizeof(*section);
+       data = (void*)entry+entries*sizeof(*entry);
+
+       pr_debug("head....:%p\n", head);
+       pr_debug("section.:%p (offset:%zu, each:%zu)\n", section,
+                (void*)section-bin, sizeof(*section));
+       pr_debug("entry...:%p (offset:%zu, each:%zu)\n", entry,
+                (void*)entry-bin, sizeof(*entry));
+       pr_debug("data....:%p (offset:%zu)\n", data,
+                (void*)data-bin);
+
+       head->sections = sections;
+       head->version[0] = 0;
+       head->version[1] = 1;
+       head->version[2] = 2;
+
+       for (ls = list_first(&script->sections); ls;
+            ls = list_next(&script->sections, ls)) {
+               struct script_section *s;
+               size_t c = 0;
+               s = container_of(ls, struct script_section, sections);
+
+               /* skip empty sections */
+               if (list_empty(&s->entries))
+                       continue;
+               memcpy(section->name, s->name, strlen(s->name));
+               section->offset = ((void*)entry-bin)>>2;
+
+               for (le = list_first(&s->entries); le;
+                    le = list_next(&s->entries, le)) {
+                       struct script_entry *e;
+                       e = container_of(le, struct script_entry, entries);
+                       size_t size = 0;
+
+                       memcpy(entry->name, e->name, strlen(e->name));
+                       entry->offset = ((void*)data-bin)>>2;
+                       entry->pattern = (e->type<<16);
+
+                       switch(e->type) {
+                       case SCRIPT_VALUE_TYPE_SINGLE_WORD: {
+                               struct script_single_entry *single;
+                               int32_t *bdata = data;
+                               single = container_of(e, struct script_single_entry, entry);
+
+                               *bdata = single->value;
+                               size = sizeof(*bdata);
+                               }; break;
+                       case SCRIPT_VALUE_TYPE_STRING: {
+                               struct script_string_entry *string;
+                               string = container_of(e, struct script_string_entry, entry);
+                               size = string->l;
+                               memcpy(data, string->string, size);
+                               /* align */
+                               size += sizeof(uint32_t)-1;
+                               size /= sizeof(uint32_t);
+                               size *= sizeof(uint32_t);
+                               }; break;
+                       case SCRIPT_VALUE_TYPE_MULTI_WORD:
+                               abort();
+                       case SCRIPT_VALUE_TYPE_GPIO: {
+                               struct script_gpio_entry *gpio;
+                               struct script_bin_gpio_value *bdata = data;
+                               gpio = container_of(e, struct script_gpio_entry, entry);
+                               bdata->port = gpio->port;
+                               bdata->port_num = gpio->port_num;
+                               bdata->mul_sel = gpio->data[0];
+                               bdata->pull = gpio->data[1];
+                               bdata->drv_level = gpio->data[2];
+                               bdata->data = gpio->data[3];
+                               size = sizeof(*bdata);
+                               }; break;
+                       case SCRIPT_VALUE_TYPE_NULL:
+                               size = sizeof(uint32_t);
+                               break;
+                       }
+
+                       data += size;
+                       entry->pattern |= (size>>2);
+                       pr_debug("%s.%s <%p> (type:%d, words:%d (%zu), offset:%d)\n",
+                                section->name, entry->name, entry,
+                                (entry->pattern>>16) & 0xffff,
+                                (entry->pattern>>0) & 0xffff, size,
+                                entry->offset);
+                       c++;
+                       entry++;
+               }
+
+               section->length = c;
+               pr_debug("%s <%p> (length:%d, offset:%d)\n",
+                        section->name, section, section->length, section->offset);
+
+               section++;
+       }
+       return 1;
+}
+
+/*
+ * decompiler
+ */
+static int decompile_section(void *bin, size_t UNUSED(bin_size),
+                            const char *filename,
+                            struct script_bin_section *section,
+                            struct script *script)
+{
+       struct script_bin_entry *entry = PTR(bin,  section->offset<<2);
+       struct script_section *s;
+
+       if ((s = script_section_new(script, section->name)) == NULL)
+               goto malloc_error;
+
+       for (int i = section->length; i--; entry++) {
+               void *data = PTR(bin, entry->offset<<2);
+               unsigned type, words;
+               type    = (entry->pattern >> 16) & 0xffff;
+               words   = (entry->pattern >>  0) & 0xffff;
+
+               switch(type) {
+               case SCRIPT_VALUE_TYPE_SINGLE_WORD: {
+                       uint32_t *v = data;
+                       if (words != 1) {
+                               pr_err("%s: %s.%s: invalid length %d (assuming %d)\n",
+                               filename, section->name, entry->name, words, 1);
+                       }
+                       if (!script_single_entry_new(s, entry->name, *v))
+                               goto malloc_error;
+                       }; break;
+               case SCRIPT_VALUE_TYPE_STRING: {
+                       size_t bytes = words << 2;
+                       const char *p, *pe, *v = data;
+
+                       for(p=v, pe=v+bytes; *p && p!=pe; p++)
+                               ; /* seek end-of-string */
+
+                       if (!script_string_entry_new(s, entry->name, p-v, v))
+                               goto malloc_error;
+                       }; break;
+               case SCRIPT_VALUE_TYPE_GPIO: {
+                       struct script_bin_gpio_value *gpio = data;
+                       int32_t v[4];
+                       if (words != 6) {
+                               pr_err("%s: %s.%s: invalid length %d (assuming %d)\n",
+                                      filename, section->name, entry->name, words, 6);
+                       } else if (gpio->port == 0xffff) {
+                               ; /* port:power */
+                       } else if (gpio->port < 1 || gpio->port > GPIO_BANK_MAX) {
+                               pr_err("%s: %s.%s: unknown GPIO port bank %c (%u)\n",
+                                      filename, section->name, entry->name,
+                                      'A'+gpio->port, gpio->port);
+                               goto failure;
+                       }
+                       v[0] = gpio->mul_sel;
+                       v[1] = gpio->pull;
+                       v[2] = gpio->drv_level;
+                       v[3] = gpio->data;
+
+                       if (!script_gpio_entry_new(s, entry->name,
+                                                  gpio->port, gpio->port_num,
+                                                  v))
+                               goto malloc_error;
+                       }; break;
+               case SCRIPT_VALUE_TYPE_NULL:
+                       if (!script_null_entry_new(s, entry->name))
+                               goto malloc_error;
+                       break;
+               default:
+                       pr_err("%s: %s.%s: unknown type %d\n",
+                              filename, section->name, entry->name, type);
+                       goto failure;
+               }
+       }
+       return 1;
+
+malloc_error:
+       pr_err("%s: %s\n", "malloc", strerror(errno));
+failure:
+       return 0;
+}
+
+int script_decompile_bin(void *bin, size_t bin_size,
+                        const char *filename,
+                        struct script *script)
+{
+       int i;
+       struct script_bin_head *head = bin;
+
+       pr_info("%s: version: %d.%d.%d\n", filename,
+               head->version[0], head->version[1],
+               head->version[2]);
+       pr_info("%s: size: %zu (%d sections)\n", filename,
+               bin_size, head->sections);
+
+       /* TODO: SANITY: compare head.sections with bin_size */
+       for (i=0; i < head->sections; i++) {
+               struct script_bin_section *section = &head->section[i];
+
+               if (!decompile_section(bin, bin_size, filename,
+                                      section, script))
+                       return 0;
+       }
+       return 1;
+}
diff --git a/sunxi-common/tools/script_bin.h b/sunxi-common/tools/script_bin.h
new file mode 100644 (file)
index 0000000..0de2867
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2012  Alejandro Mery <amery@geeks.cl>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef _SUNXI_TOOLS_SCRIPT_BIN_H
+#define _SUNXI_TOOLS_SCRIPT_BIN_H
+
+/** binary representation of the head of a section */
+struct script_bin_section {
+       char name[32];
+       int32_t length;
+       int32_t offset;
+};
+
+/** binary representation of the head of the script file */
+struct script_bin_head {
+       int32_t sections;
+       int32_t version[3];
+       struct script_bin_section section[];
+};
+
+/** binary representation of the head of an entry */
+struct script_bin_entry {
+       char name[32];
+       int32_t offset;
+       int32_t pattern;
+};
+
+/** binary representation of a GPIO */
+struct script_bin_gpio_value {
+       int32_t port;
+       int32_t port_num;
+       int32_t mul_sel;
+       int32_t pull;
+       int32_t drv_level;
+       int32_t data;
+};
+
+size_t script_bin_size(struct script *script,
+                      size_t *sections, size_t *entries);
+
+int script_generate_bin(void *bin, size_t bin_size, struct script *script,
+                       size_t sections, size_t entries);
+int script_decompile_bin(void *bin, size_t bin_size,
+                        const char *filename,
+                        struct script *script);
+#endif
diff --git a/sunxi-common/tools/script_fex.c b/sunxi-common/tools/script_fex.c
new file mode 100644 (file)
index 0000000..361e86b
--- /dev/null
@@ -0,0 +1,359 @@
+/*
+ * Copyright (C) 2012  Alejandro Mery <amery@geeks.cl>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+#include "common.h"
+
+#include <ctype.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "script.h"
+#include "script_fex.h"
+
+#define MAX_LINE       255
+
+#define pr_info(...)   errf("fexc-fex: " __VA_ARGS__)
+#define pr_err(...)    errf("E: fexc-fex: " __VA_ARGS__)
+
+#ifdef DEBUG
+#define pr_debug(...)  errf("D: fexc-fex: " __VA_ARGS__)
+#else
+#define pr_debug(...)
+#endif
+
+/*
+ * generator
+ */
+static inline size_t strlen2(const char *s)
+{
+       size_t l = strlen(s);
+       const char *p = &s[l-1];
+       while (l && *p >= '0' && *p <= '9') {
+               l--;
+               p--;
+       }
+       return l;
+}
+
+static int find_full_match(const char *s, size_t l, const char **list)
+{
+       while (*list) {
+               if (memcmp(s, *list, l) == 0)
+                       return 1;
+               list++;
+       }
+
+       return 0;
+}
+
+/**
+ */
+static int decompile_single_mode(const char *name)
+{
+       static const char *hexa_entries[] = {
+               "dram_baseaddr", "dram_zq", "dram_tpr", "dram_emr",
+               "g2d_size",
+               "rtp_press_threshold", "rtp_sensitive_level",
+               "ctp_twi_addr", "csi_twi_addr", "csi_twi_addr_b", "tkey_twi_addr",
+               "lcd_gamma_tbl_",
+               "gsensor_twi_addr",
+               NULL };
+       size_t l = strlen2(name);
+
+       if (find_full_match(name, l, hexa_entries))
+               return 0;
+       else
+               return -1;
+}
+
+int script_generate_fex(FILE *out, const char *UNUSED(filename),
+                       struct script *script)
+{
+       struct list_entry *ls, *le;
+       struct script_section *section;
+       struct script_entry *entry;
+
+       for (ls = list_first(&script->sections); ls;
+            ls = list_next(&script->sections, ls)) {
+               section = container_of(ls, struct script_section, sections);
+
+               fprintf(out, "[%s]\n", section->name);
+               for (le = list_first(&section->entries); le;
+                    le = list_next(&section->entries, le)) {
+                       entry = container_of(le, struct script_entry, entries);
+
+                       switch(entry->type) {
+                       case SCRIPT_VALUE_TYPE_SINGLE_WORD: {
+                               int mode = decompile_single_mode(entry->name);
+                               struct script_single_entry *single;
+                               single = container_of(entry, struct script_single_entry, entry);
+
+                               fprintf(out, "%s = ", entry->name);
+                               if (mode < 0)
+                                       fprintf(out, "%d", single->value);
+                               else if (mode > 0)
+                                       fprintf(out, "0x%0*x", mode, single->value);
+                               else
+                                       fprintf(out, "0x%x", single->value);
+                               fputc('\n', out);
+                               }; break;
+                       case SCRIPT_VALUE_TYPE_STRING: {
+                               struct script_string_entry *string;
+                               string = container_of(entry, struct script_string_entry, entry);
+                               fprintf(out, "%s = \"%.*s\"\n", entry->name,
+                                       (int)string->l, string->string);
+                               }; break;
+                       case SCRIPT_VALUE_TYPE_MULTI_WORD:
+                               abort();
+                       case SCRIPT_VALUE_TYPE_GPIO: {
+                               char port = 'A'-1;
+                               struct script_gpio_entry *gpio;
+                               gpio = container_of(entry, struct script_gpio_entry, entry);
+
+                               if (gpio->port == 0xffff) {
+                                       fprintf(out, "%s = port:power%u", entry->name,
+                                               gpio->port_num);
+                               } else {
+                                       port += gpio->port;
+                                       fprintf(out, "%s = port:P%c%02u", entry->name,
+                                               port, gpio->port_num);
+                               }
+                               for (const int *p = gpio->data, *pe = p+4; p != pe; p++) {
+                                       if (*p == -1)
+                                               fputs("<default>", out);
+                                       else
+                                               fprintf(out, "<%d>", *p);
+                               }
+                               fputc('\n', out);
+                               }; break;
+                       case SCRIPT_VALUE_TYPE_NULL:
+                               fprintf(out, "%s =\n", entry->name);
+                               break;
+                       }
+               }
+               fputc('\n', out);
+       }
+       return 1;
+}
+
+/*
+ * parser
+ */
+
+/** find first not blank char */
+static inline char *skip_blank(char *p)
+{
+       while(isblank(*p))
+               p++;
+       return p;
+}
+
+/** trim out blank chars at the end of a string */
+static inline char *rtrim(const char *s, char *p)
+{
+       if (p>s) {
+               while (p!=s && isblank(*--p))
+                       ;
+               *++p='\0';
+       }
+       return p;
+}
+
+/**
+ */
+int script_parse_fex(FILE *in, const char *filename, struct script *script)
+{
+       char buffer[MAX_LINE+1];
+       int ok = 1;
+       struct script_section *last_section = NULL;
+
+       /* TODO: deal with longer lines correctly (specially in comments) */
+       for(size_t line = 1; ok && fgets(buffer, sizeof(buffer), in); line++) {
+               char *s = skip_blank(buffer); /* beginning */
+               char *pe = s; /* \0... to be found */
+
+               if (*pe) while (*++pe)
+                       ;
+
+               if (pe>s && pe[-1] == '\n') {
+                       if (pe>s+1 && pe[-2] == '\r')
+                               pe -= 2;
+                       else
+                               pe -= 1;
+                       *pe = '\0';
+               }
+
+               pe = rtrim(s, pe);
+
+               if (pe == s || *s == ';' || *s == '#')
+                       continue; /* empty */
+               else if (*s == '[') {
+                       /* section */
+                       char *p = ++s;
+                       while (isalnum(*p) || *p == '_')
+                               p++;
+
+                       if (*p == ']' && *(p+1) == '\0') {
+                               *p = '\0';
+                               if ((last_section = script_section_new(script, s)))
+                                       continue;
+
+                               perror("malloc");
+                       } else if (*p) {
+                               errf("E: %s:%zu: invalid character at %zu.\n",
+                                    filename, line, p-buffer+1);
+                       } else {
+                               errf("E: %s:%zu: incomplete section declaration.\n",
+                                    filename, line);
+                       }
+                       ok = 0;
+               } else {
+                       /* key = value */
+                       const char *key = s;
+                       char *mark, *p = s;
+
+                       if (!last_section) {
+                               errf("E: %s:%zu: data must follow a section.\n",
+                                    filename, line);
+                               goto parse_error;
+                       };
+
+                       while (isalnum(*p) || *p == '_')
+                               p++;
+                       mark = p;
+                       p = skip_blank(p);
+                       if (*p != '=')
+                               goto invalid_char_at_p;
+                       *mark = '\0'; /* truncate key */
+                       p = skip_blank(p+1);
+
+                       if (*p == '\0') {
+                               /* NULL */
+                               if (script_null_entry_new(last_section, key))
+                                       continue;
+                               perror("malloc");
+                       } else if (pe > p+1 && *p == '"' && pe[-1] == '"') {
+                               /* string */
+                               p++; *--pe = '\0';
+                               if (script_string_entry_new(last_section, key, pe-p, p)) {
+                                       pr_debug("%s.%s = \"%.*s\"\n",
+                                                last_section->name, key,
+                                                (int)(pe-p), p);
+                                       continue;
+                               }
+                               perror("malloc");
+                       } else if (memcmp("port:", p, 5) == 0) {
+                               /* GPIO */
+                               p += 5;
+                               if (p[0] == 'P' &&
+                                   (p[1] < 'A' || p[1] > ('A' + GPIO_BANK_MAX)))
+                                       ;
+                               else if (*p != 'P' &&
+                                        memcmp(p, "power", 5) != 0)
+                                       ;
+                               else {
+                                       char *end;
+                                       int port;
+                                       long v;
+
+                                       if (*p == 'P') {
+                                               /* port:PXN */
+                                               port = p[1] - 'A' + 1;
+                                               p += 2;
+                                       } else {
+                                               /* port:powerN */
+                                               port = 0xffff;
+                                               p += 5;
+                                       }
+
+                                       v = strtol(p, &end, 10);
+                                       if (end == p)
+                                               goto invalid_char_at_p;
+                                       else if (v<0 || v>255) {
+                                               errf("E: %s:%zu: port out of range at %zu (%ld).\n",
+                                                    filename, line, p-buffer+1, v);
+                                       } else {
+                                               int data[] = {-1,-1,-1,-1};
+                                               int port_num = v;
+                                               p = end;
+                                               for (int i=0; *p && i<4; i++) {
+                                                       if (memcmp(p, "<default>", 9) == 0) {
+                                                               p += 9;
+                                                               continue;
+                                                       } else if (*p == '<') {
+                                                               v = strtol(++p, &end, 10);
+                                                               if (end == p) {
+                                                                       ;
+                                                               } else if (v<0 || v>INT32_MAX) {
+                                                                       errf("E: %s:%zu: value out of range at %zu (%ld).\n",
+                                                                            filename, line, p-buffer+1, v);
+                                                                       goto parse_error;
+                                                               } else if (*end != '>') {
+                                                                       p = end;
+                                                               } else {
+                                                                       p = end+1;
+                                                                       data[i] = v;
+                                                                       continue;
+                                                               }
+                                                       }
+                                                       break;
+                                               }
+                                               if (*p)
+                                                       goto invalid_char_at_p;
+                                               if (script_gpio_entry_new(last_section, key,
+                                                                         port, port_num, data)) {
+                                                       pr_debug("%s.%s = GPIO %d.%d (%d,%d,%d,%d)\n",
+                                                                last_section->name, key,
+                                                                port, port_num,
+                                                                data[0], data[1], data[2], data[3]);
+                                                       continue;
+                                               }
+                                               perror("malloc");
+                                       }
+                               }
+                       } else if (isdigit(*p) || (*p == '-' && isdigit(*(p+1)))) {
+                               long long v = 0;
+                               char *end;
+                               v = strtoll(p, &end, 0);
+                               p = end;
+                               if (p != pe) {
+                                       goto invalid_char_at_p;
+                               } else if (v > UINT32_MAX) {
+                                       errf("E: %s:%zu: value out of range %lld.\n",
+                                            filename, line, v);
+                               } else if (script_single_entry_new(last_section, key, v)) {
+                                       pr_debug("%s.%s = %lld\n",
+                                                last_section->name, key, v);
+                                       continue;
+                               }
+                       } else {
+                               goto invalid_char_at_p;
+                       }
+                       goto parse_error;
+invalid_char_at_p:
+                       errf("E: %s:%zu: invalid character at %zu.\n",
+                            filename, line, p-buffer+1);
+parse_error:
+                       ok = 0;
+               }
+       };
+
+       if (ferror(in))
+               ok = 0;
+       return ok;
+}
diff --git a/sunxi-common/tools/script_fex.h b/sunxi-common/tools/script_fex.h
new file mode 100644 (file)
index 0000000..0ada86d
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2012  Alejandro Mery <amery@geeks.cl>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef _SUBXI_TOOLS_SCRIPT_FEX_H
+#define _SUBXI_TOOLS_SCRIPT_FEX_H
+
+int script_parse_fex(FILE *in, const char *filename, struct script *script);
+int script_generate_fex(FILE *out, const char *filename, struct script *script);
+
+#endif
diff --git a/sunxi-common/tools/script_uboot.c b/sunxi-common/tools/script_uboot.c
new file mode 100644 (file)
index 0000000..8d5b474
--- /dev/null
@@ -0,0 +1,256 @@
+/*
+ * Copyright (C) 2012 Alejandro Mery <amery@geeks.cl>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+#include "common.h"
+
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "script.h"
+#include "script_uboot.h"
+
+#define pr_info(...)   errf("fexc-uboot: " __VA_ARGS__)
+#define pr_err(...)    errf("E: fexc-uboot: " __VA_ARGS__)
+
+#ifdef DEBUG
+#define pr_debug(...)  errf("D: fexc-uboot: " __VA_ARGS__)
+#else
+#define pr_debug(...)
+#endif
+
+struct members {
+       const char *name;
+       const char *translation;
+       int mode;
+};
+#define foreach_member(I, T) for (const struct members *I = T; \
+            I < T+ARRAY_SIZE(T); I++)
+
+/*
+ */
+static inline void out_u32_member(FILE *out, const char *key, int hexa,
+                                 struct script_single_entry *val)
+{
+       const char *fmt;
+       if (hexa)
+               fmt = "\t.%s = %#x,\n";
+       else
+               fmt = "\t.%s = %u,\n";
+
+       fprintf(out, fmt, key, val->value);
+}
+
+static inline void out_gpio_member(FILE *out, const char *key,
+                                  struct script_gpio_entry *gpio)
+{
+       fprintf(out, "\t.%s = ", key);
+
+       if (gpio->port == 0xffff)
+               fprintf(out, "GPIO_AXP_CFG(%u", gpio->port_num);
+       else
+               fprintf(out, "GPIO_CFG(%u, %u", gpio->port, gpio->port_num);
+
+       for (const int *p = gpio->data, *pe = p+4; p != pe; p++) {
+               if (*p == -1)
+                       fputs(", 0xff", out);
+               else
+                       fprintf(out, ", %u", *p);
+       }
+
+       fputs("),\n", out);
+}
+
+static inline void out_null_member(FILE *out, const char *key)
+{
+       fprintf(out, "\t/* %s is NULL */\n", key);
+}
+
+static inline int out_member(FILE *out, const char *key, int mode,
+                     struct script_entry *ep)
+{
+       switch (ep->type) {
+       case SCRIPT_VALUE_TYPE_SINGLE_WORD:
+               out_u32_member(out, key, mode,
+                      container_of(ep, struct script_single_entry, entry));
+               break;
+       case SCRIPT_VALUE_TYPE_NULL:
+               out_null_member(out, key);
+               break;
+       case SCRIPT_VALUE_TYPE_GPIO:
+               out_gpio_member(out, key,
+                       container_of(ep, struct script_gpio_entry, entry));
+               break;
+       default:
+               return 0;
+       }
+       return 1;
+}
+
+/*
+ * DRAM
+ */
+static struct members dram_members[] = {
+       { .name="dram_clock" },
+       { .name="dram_clk", .translation="clock" },
+       { .name="dram_type" },
+       { .name="dram_rank_num" },
+       { .name="dram_density" },
+       { .name="dram_chip_density", .translation="density" },
+       { .name="dram_io_width" },
+       { .name="dram_bus_width" },
+       { .name="dram_cas" },
+       { .name="dram_zq" },
+       { .name="dram_odt_en" },
+       { .name="dram_size" },
+       { .name="dram_tpr0", .mode=1 },
+       { .name="dram_tpr1", .mode=1 },
+       { .name="dram_tpr2", .mode=1 },
+       { .name="dram_tpr3", .mode=1 },
+       { .name="dram_tpr4", .mode=1 },
+       { .name="dram_tpr5", .mode=1 },
+       { .name="dram_emr1", .mode=1 },
+       { .name="dram_emr2", .mode=1 },
+       { .name="dram_emr3", .mode=1 },
+};
+
+static int generate_dram_struct(FILE *out, struct script_section *sp)
+{
+       struct script_entry *ep;
+       const char *key;
+       int ret = 1;
+
+       fprintf(out, "static struct dram_para dram_para = {\n");
+       foreach_member(mp, dram_members) {
+               ep = script_find_entry(sp, mp->name);
+               if (!ep)
+                       continue;
+
+               key = (mp->translation) ? mp->translation : mp->name+5;
+               if (!out_member(out, key, mp->mode, ep)) {
+                       pr_err("dram_para: %s: invalid field\n", ep->name);
+                       ret = 0;
+               }
+
+       }
+       fprintf(out, "};\n");
+       fputs("\nunsigned long sunxi_dram_init(void)\n"
+             "{\n\treturn dramc_init(&dram_para);\n}\n",
+             out);
+
+       return ret;
+}
+
+#if 0
+/*
+ * PMU
+ */
+static struct members pmu_members[] = {
+       { .name = "pmu_used2" },
+       { .name = "pmu_para" },
+       { .name = "pmu_adpdet" },
+       { .name = "pmu_shutdown_chgcur" },
+       { .name = "pmu_shutdown_chgcur2" },
+       { .name = "pmu_pwroff_vol" },
+       { .name = "pmu_pwron_vol" },
+};
+
+static int generate_pmu_struct(FILE *out, struct script_section *target,
+                              struct script_section *pmu_para)
+{
+       struct list_entry *le;
+       struct script_section *sp;
+       struct script_entry *ep;
+       const char *key;
+       int ret = 1;
+
+       fputs("\nstatic struct pmu_para pmu_para = {\n", out);
+
+       sp = target;
+       for (le = list_first(&sp->entries); le;
+            le = list_next(&sp->entries, le)) {
+               ep = container_of(le, struct script_entry, entries);
+
+               if (!out_member(out, ep->name, 0, ep)) {
+                       pr_err("target: %s: invalid field\n", ep->name);
+                       ret = 0;
+               }
+       }
+
+       foreach_member(mp, pmu_members) {
+               ep = script_find_entry(pmu_para, mp->name);
+               if (!ep)
+                       continue;
+
+               key = (mp->translation) ? mp->translation : mp->name+4;
+               if (!out_member(out, key, mp->mode, ep)) {
+                       pr_err("pmu_para: %s: invalid field\n", mp->name);
+                       ret = 0;
+               }
+       }
+
+       fputs("};\n", out);
+       fputs("\nint sunxi_pmu_init(void)\n"
+             "{\n\treturn PMU_init(&pmu_para);\n}\n",
+             out);
+       return ret;
+
+       (void) pmu_para;
+}
+#endif
+
+int script_generate_uboot(FILE *out, const char *UNUSED(filename),
+                         struct script *script)
+{
+       struct {
+               const char *name;
+               struct script_section *sp;
+       } sections[] = {
+               { "dram_para", NULL },
+#if 0
+               { "target", NULL },
+               { "pmu_para", NULL },
+#endif
+       };
+
+       for (unsigned i=0; i<ARRAY_SIZE(sections); i++) {
+               struct script_section *sp;
+
+               sp = script_find_section(script, sections[i].name);
+               if (sp)
+                       sections[i].sp = sp;
+               else {
+                       pr_err("%s: critical section missing",
+                              sections[i].name);
+                       return 0;
+               }
+       }
+
+       fputs("/* this file is generated, don't edit it yourself */\n\n"
+             "#include <common.h>\n"
+#if 0
+             "#include <asm/arch/pmu.h>\n"
+#endif
+             "#include <asm/arch/dram.h>\n\n",
+             out);
+
+       generate_dram_struct(out, sections[0].sp);
+#if 0
+       generate_pmu_struct(out, sections[1].sp, sections[2].sp);
+#endif
+
+       return 1;
+}
diff --git a/sunxi-common/tools/script_uboot.h b/sunxi-common/tools/script_uboot.h
new file mode 100644 (file)
index 0000000..abfca14
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2012 Alejandro Mery <amery@geeks.cl>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef _SUBXI_TOOLS_SCRIPT_UBOOT_H
+#define _SUBXI_TOOLS_SCRIPT_UBOOT_H
+
+int script_generate_uboot(FILE *out, const char *filename, struct script *script);
+
+#endif
diff --git a/sunxi-devices/ainol_aw1/Android.mk b/sunxi-devices/ainol_aw1/Android.mk
new file mode 100644 (file)
index 0000000..a0c1c38
--- /dev/null
@@ -0,0 +1,20 @@
+# Copyright (C) 2014 Paul Kocialkowski <contact@paulk.fr>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+ainol_aw1 := "$(SUNXI_DEVICES_OUT)/ainol_aw1"
+$(ainol_aw1): sunxi_uboot_Ainol_AW1
+       @mkdir -p "$@"
+       @cp "$(SUNXI_UBOOT_OUT)/Ainol_AW1/u-boot.img" "$@/"
+       @cp "$(SUNXI_UBOOT_OUT)/Ainol_AW1/spl/sunxi-spl.bin" "$@/"
diff --git a/sunxi-devices/ainol_aw1/script.fex b/sunxi-devices/ainol_aw1/script.fex
new file mode 100644 (file)
index 0000000..b6d3a0b
--- /dev/null
@@ -0,0 +1,1044 @@
+[product]
+version = "100"
+machine = "wing-sc3062"
+
+[platform]
+eraseflag = 1
+
+[target]
+boot_clock = 912
+dcdc2_vol = 1400
+dcdc3_vol = 1250
+ldo2_vol = 3000
+ldo3_vol = 2800
+ldo4_vol = 2800
+power_start = 0
+storage_type = 0
+
+[clock]
+pll3 = 297
+pll4 = 300
+pll6 = 600
+pll7 = 297
+pll8 = 336
+
+[card_boot]
+logical_start = 40960
+sprite_gpio0 =
+
+[card0_boot_para]
+card_ctrl = 0
+card_high_speed = 1
+card_line = 4
+sdc_d1 = port:PF00<2><1><default><default>
+sdc_d0 = port:PF01<2><1><default><default>
+sdc_clk = port:PF02<2><1><default><default>
+sdc_cmd = port:PF03<2><1><default><default>
+sdc_d3 = port:PF04<2><1><default><default>
+sdc_d2 = port:PF05<2><1><default><default>
+
+[card2_boot_para]
+card_ctrl = 2
+card_high_speed = 1
+card_line = 4
+sdc_cmd = port:PC06<3><1><default><default>
+sdc_clk = port:PC07<3><1><default><default>
+sdc_d0 = port:PC08<3><1><default><default>
+sdc_d1 = port:PC09<3><1><default><default>
+sdc_d2 = port:PC10<3><1><default><default>
+sdc_d3 = port:PC11<3><1><default><default>
+
+[twi_para]
+twi_port = 0
+twi_scl = port:PB00<2><default><default><default>
+twi_sda = port:PB01<2><default><default><default>
+
+[uart_para]
+uart_debug_port = 0
+uart_debug_tx = port:PB22<2><1><default><default>
+uart_debug_rx = port:PB23<2><1><default><default>
+
+[uart_force_debug]
+uart_debug_port = 0
+uart_debug_tx = port:PF02<4><1><default><default>
+uart_debug_rx = port:PF04<4><1><default><default>
+
+[jtag_para]
+jtag_enable = 1
+jtag_ms = port:PB14<3><default><default><default>
+jtag_ck = port:PB15<3><default><default><default>
+jtag_do = port:PB16<3><default><default><default>
+jtag_di = port:PB17<3><default><default><default>
+
+[pm_para]
+standby_mode = 0
+
+[dram_para]
+dram_baseaddr = 0x40000000
+dram_clk = 432
+dram_type = 3
+dram_rank_num = 1
+dram_chip_density = 2048
+dram_io_width = 16
+dram_bus_width = 32
+dram_cas = 9
+dram_zq = 0x7b
+dram_odt_en = 0
+dram_size = 512
+dram_tpr0 = 0x42d899b7
+dram_tpr1 = 0xa090
+dram_tpr2 = 0x22a00
+dram_tpr3 = 0x0
+dram_tpr4 = 0x1
+dram_tpr5 = 0x0
+dram_emr1 = 0x4
+dram_emr2 = 0x10
+dram_emr3 = 0x0
+
+[mali_para]
+mali_used = 1
+mali_clkdiv = 1
+mali_normal_freq = 192
+mali_min_freq = 192
+
+[emac_para]
+emac_used = 0
+emac_rxd3 = port:PA00<2><default><default><default>
+emac_rxd2 = port:PA01<2><default><default><default>
+emac_rxd1 = port:PA02<2><default><default><default>
+emac_rxd0 = port:PA03<2><default><default><default>
+emac_txd3 = port:PA04<2><default><default><default>
+emac_txd2 = port:PA05<2><default><default><default>
+emac_txd1 = port:PA06<2><default><default><default>
+emac_txd0 = port:PA07<2><default><default><default>
+emac_rxclk = port:PA08<2><default><default><default>
+emac_rxerr = port:PA09<2><default><default><default>
+emac_rxdV = port:PA10<2><default><default><default>
+emac_mdc = port:PA11<2><default><default><default>
+emac_mdio = port:PA12<2><default><default><default>
+emac_txen = port:PA13<2><default><default><default>
+emac_txclk = port:PA14<2><default><default><default>
+emac_crs = port:PA15<2><default><default><default>
+emac_col = port:PA16<2><default><default><default>
+emac_reset = port:PA17<1><default><default><default>
+
+[twi0_para]
+twi0_used = 1
+twi0_scl = port:PB00<2><default><default><default>
+twi0_sda = port:PB01<2><default><default><default>
+
+[twi1_para]
+twi1_used = 1
+twi1_scl = port:PB18<2><default><default><default>
+twi1_sda = port:PB19<2><default><default><default>
+
+[twi2_para]
+twi2_used = 1
+twi2_scl = port:PB20<2><default><default><default>
+twi2_sda = port:PB21<2><default><default><default>
+
+[uart_para0]
+uart_used = 1
+uart_port = 0
+uart_type = 2
+uart_tx = port:PB22<2><1><default><default>
+uart_rx = port:PB23<2><1><default><default>
+
+[uart_para1]
+uart_used = 0
+uart_port = 1
+uart_type = 8
+uart_tx = port:PA10<4><1><default><default>
+uart_rx = port:PA11<4><1><default><default>
+uart_rts = port:PA12<4><1><default><default>
+uart_cts = port:PA13<4><1><default><default>
+uart_dtr = port:PA14<4><1><default><default>
+uart_dsr = port:PA15<4><1><default><default>
+uart_dcd = port:PA16<4><1><default><default>
+uart_ring = port:PA17<4><1><default><default>
+
+[uart_para2]
+uart_used = 1
+uart_port = 2
+uart_type = 4
+uart_tx = port:PI18<3><1><default><default>
+uart_rx = port:PI19<3><1><default><default>
+uart_rts = port:PI16<3><1><default><default>
+uart_cts = port:PI17<3><1><default><default>
+
+[uart_para3]
+uart_used = 0
+uart_port = 3
+uart_type = 4
+uart_tx = port:PH00<4><1><default><default>
+uart_rx = port:PH01<4><1><default><default>
+uart_rts = port:PH02<4><1><default><default>
+uart_cts = port:PH03<4><1><default><default>
+
+[uart_para4]
+uart_used = 0
+uart_port = 4
+uart_type = 2
+uart_tx = port:PH04<4><1><default><default>
+uart_rx = port:PH05<4><1><default><default>
+
+[uart_para5]
+uart_used = 0
+uart_port = 5
+uart_type = 2
+uart_tx = port:PH06<4><1><default><default>
+uart_rx = port:PH07<4><1><default><default>
+
+[uart_para6]
+uart_used = 0
+uart_port = 6
+uart_type = 2
+uart_tx = port:PA12<3><1><default><default>
+uart_rx = port:PA13<3><1><default><default>
+
+[uart_para7]
+uart_used = 0
+uart_port = 7
+uart_type = 2
+uart_tx = port:PA14<3><1><default><default>
+uart_rx = port:PA15<3><1><default><default>
+
+[spi0_para]
+spi_used = 0
+spi_cs_bitmap = 1
+spi_cs0 = port:PI10<2><default><default><default>
+spi_cs1 = port:PI14<2><default><default><default>
+spi_sclk = port:PI11<2><default><default><default>
+spi_mosi = port:PI12<2><default><default><default>
+spi_miso = port:PI13<2><default><default><default>
+
+[spi1_para]
+spi_used = 0
+spi_cs_bitmap = 1
+spi_cs0 = port:PA00<3><default><default><default>
+spi_cs1 = port:PA04<3><default><default><default>
+spi_sclk = port:PA01<3><default><default><default>
+spi_mosi = port:PA02<3><default><default><default>
+spi_miso = port:PA03<3><default><default><default>
+
+[spi2_para]
+spi_used = 0
+spi_cs_bitmap = 1
+spi_cs0 = port:PC19<3><default><default><default>
+spi_cs1 = port:PB13<2><default><default><default>
+spi_sclk = port:PC20<3><default><default><default>
+spi_mosi = port:PC21<3><default><default><default>
+spi_miso = port:PC22<3><default><default><default>
+
+[spi3_para]
+spi_used = 0
+spi_cs_bitmap = 1
+spi_cs0 = port:PA05<3><default><default><default>
+spi_cs1 = port:PA09<3><default><default><default>
+spi_sclk = port:PA06<3><default><default><default>
+spi_mosi = port:PA07<3><default><default><default>
+spi_miso = port:PA08<3><default><default><default>
+
+[ctp_para]
+ctp_used = 1
+ctp_name = "gsl1680_1"
+ctp_twi_id = 2
+ctp_twi_addr = 0x40
+ctp_screen_max_x = 800
+ctp_screen_max_y = 480
+ctp_revert_x_flag = 1
+ctp_revert_y_flag = 0
+ctp_exchange_x_y_flag = 1
+ctp_int_port = port:PH21<6><default><default><default>
+ctp_wakeup = port:PH20<1><default><default><1>
+
+[ctp_list_para]
+ctp_det_used = 1
+ft5x_ts = 1
+gt82x = 1
+gslX680 = 1
+gt9xx_ts = 1
+gt811 = 1
+zet622x = 1
+
+[tkey_para]
+tkey_used = 0
+tkey_twi_id = 2
+tkey_twi_addr = 0x62
+tkey_int = port:PI13<6><default><default><default>
+
+[motor_para]
+motor_used = 0
+motor_shake = port:PB03<1><default><default><1>
+
+[nand_para]
+nand_used = 1
+nand_we = port:PC00<2><default><default><default>
+nand_ale = port:PC01<2><default><default><default>
+nand_cle = port:PC02<2><default><default><default>
+nand_ce1 = port:PC03<2><default><default><default>
+nand_ce0 = port:PC04<2><default><default><default>
+nand_nre = port:PC05<2><default><default><default>
+nand_rb0 = port:PC06<2><default><default><default>
+nand_rb1 = port:PC07<2><default><default><default>
+nand_d0 = port:PC08<2><default><default><default>
+nand_d1 = port:PC09<2><default><default><default>
+nand_d2 = port:PC10<2><default><default><default>
+nand_d3 = port:PC11<2><default><default><default>
+nand_d4 = port:PC12<2><default><default><default>
+nand_d5 = port:PC13<2><default><default><default>
+nand_d6 = port:PC14<2><default><default><default>
+nand_d7 = port:PC15<2><default><default><default>
+nand_wp = port:PC16<2><default><default><default>
+nand_ce2 = port:PC17<2><default><default><default>
+nand_ce3 = port:PC18<2><default><default><default>
+nand_ce4 =
+nand_ce5 =
+nand_ce6 =
+nand_ce7 =
+nand_spi = port:PC23<3><default><default><default>
+nand_ndqs = port:PC24<2><default><default><default>
+good_block_ratio = 840
+
+[disp_init]
+disp_init_enable = 1
+disp_mode = 0
+screen0_output_type = 1
+screen0_output_mode = 4
+screen1_output_type = 1
+screen1_output_mode = 4
+fb0_framebuffer_num = 2
+fb0_format = 10
+fb0_pixel_sequence = 0
+fb0_scaler_mode_enable = 0
+fb0_width = 0
+fb0_height = 0
+fb1_framebuffer_num = 2
+fb1_format = 10
+fb1_pixel_sequence = 0
+fb1_scaler_mode_enable = 0
+fb1_width = 0
+fb1_height = 0
+lcd0_backlight = 197
+lcd1_backlight = 197
+lcd0_bright = 50
+lcd0_contrast = 50
+lcd0_saturation = 57
+lcd0_hue = 50
+lcd1_bright = 50
+lcd1_contrast = 50
+lcd1_saturation = 57
+lcd1_hue = 50
+
+[lcd0_para]
+lcd_used = 1
+lcd_x = 800
+lcd_y = 480
+lcd_width = 155
+lcd_height = 85
+lcd_dclk_freq = 40
+lcd_pwm_not_used = 0
+lcd_pwm_ch = 0
+lcd_pwm_freq = 10000
+lcd_pwm_pol = 1
+lcd_if = 0
+lcd_hbp = 88
+lcd_ht = 1000
+lcd_vbp = 39
+lcd_vt = 1320
+lcd_vspw = 0
+lcd_hspw = 0
+lcd_hv_if = 0
+lcd_hv_smode = 0
+lcd_hv_s888_if = 0
+lcd_hv_syuv_if = 0
+lcd_lvds_ch = 0
+lcd_lvds_mode = 0
+lcd_lvds_bitwidth = 0
+lcd_lvds_io_cross = 0
+lcd_cpu_if = 0
+lcd_frm = 1
+lcd_io_cfg0 = 268435456
+lcd_gamma_correction_en = 0
+lcd_gamma_tbl_0 = 0x0
+lcd_gamma_tbl_1 = 0x10101
+lcd_gamma_tbl_255 = 0xffffff
+lcd_bl_min = 25
+lcd_bl_max = 150
+lcd_bl_en_used = 1
+lcd_bl_en = port:PH07<1><0><default><1>
+lcd_bl_max = 150
+lcd_power_used = 1
+lcd_power = port:PH08<1><0><default><1>
+lcd_pwm_used = 1
+lcd_pwm = port:PB02<2><0><default><default>
+lcdd0 = port:PD00<2><0><default><default>
+lcdd1 = port:PD01<2><0><default><default>
+lcdd2 = port:PD02<2><0><default><default>
+lcdd3 = port:PD03<2><0><default><default>
+lcdd4 = port:PD04<2><0><default><default>
+lcdd5 = port:PD05<2><0><default><default>
+lcdd6 = port:PD06<2><0><default><default>
+lcdd7 = port:PD07<2><0><default><default>
+lcdd8 = port:PD08<2><0><default><default>
+lcdd9 = port:PD09<2><0><default><default>
+lcdd10 = port:PD10<2><0><default><default>
+lcdd11 = port:PD11<2><0><default><default>
+lcdd12 = port:PD12<2><0><default><default>
+lcdd13 = port:PD13<2><0><default><default>
+lcdd14 = port:PD14<2><0><default><default>
+lcdd15 = port:PD15<2><0><default><default>
+lcdd16 = port:PD16<2><0><default><default>
+lcdd17 = port:PD17<2><0><default><default>
+lcdd18 = port:PD18<2><0><default><default>
+lcdd19 = port:PD19<2><0><default><default>
+lcdd20 = port:PD20<2><0><default><default>
+lcdd21 = port:PD21<2><0><default><default>
+lcdd22 = port:PD22<2><0><default><default>
+lcdd23 = port:PD23<2><0><default><default>
+lcdclk = port:PD24<2><0><default><default>
+lcdde = port:PD25<2><0><default><default>
+lcdhsync = port:PD26<2><0><default><default>
+lcdvsync = port:PD27<2><0><default><default>
+
+[lcd1_para]
+lcd_used = 0
+lcd_x = 0
+lcd_y = 0
+lcd_dclk_freq = 0
+lcd_pwm_not_used = 0
+lcd_pwm_ch = 1
+lcd_pwm_freq = 0
+lcd_pwm_pol = 0
+lcd_if = 0
+lcd_hbp = 0
+lcd_ht = 0
+lcd_vbp = 0
+lcd_vt = 0
+lcd_vspw = 0
+lcd_hspw = 0
+lcd_hv_if = 0
+lcd_hv_smode = 0
+lcd_hv_s888_if = 0
+lcd_hv_syuv_if = 0
+lcd_lvds_ch = 0
+lcd_lvds_mode = 0
+lcd_lvds_bitwidth = 0
+lcd_lvds_io_cross = 0
+lcd_cpu_if = 0
+lcd_frm = 0
+lcd_io_cfg0 = 0
+lcd_gamma_correction_en = 0
+lcd_gamma_tbl_0 = 0x0
+lcd_gamma_tbl_1 = 0x10101
+lcd_gamma_tbl_255 = 0xffffff
+lcd_bl_en_used = 0
+lcd_bl_en =
+lcd_power_used = 0
+lcd_power =
+lcd_pwm_used = 1
+lcd_pwm = port:PI03<2><0><default><default>
+lcd_gpio_0 =
+lcd_gpio_1 =
+lcd_gpio_2 =
+lcd_gpio_3 =
+lcdd0 = port:PH00<2><0><default><default>
+lcdd1 = port:PH01<2><0><default><default>
+lcdd2 = port:PH02<2><0><default><default>
+lcdd3 = port:PH03<2><0><default><default>
+lcdd4 = port:PH04<2><0><default><default>
+lcdd5 = port:PH05<2><0><default><default>
+lcdd6 = port:PH06<2><0><default><default>
+lcdd7 = port:PH07<2><0><default><default>
+lcdd8 = port:PH08<2><0><default><default>
+lcdd9 = port:PH09<2><0><default><default>
+lcdd10 = port:PH10<2><0><default><default>
+lcdd11 = port:PH11<2><0><default><default>
+lcdd12 = port:PH12<2><0><default><default>
+lcdd13 = port:PH13<2><0><default><default>
+lcdd14 = port:PH14<2><0><default><default>
+lcdd15 = port:PH15<2><0><default><default>
+lcdd16 = port:PH16<2><0><default><default>
+lcdd17 = port:PH17<2><0><default><default>
+lcdd18 = port:PH18<2><0><default><default>
+lcdd19 = port:PH19<2><0><default><default>
+lcdd20 = port:PH20<2><0><default><default>
+lcdd21 = port:PH21<2><0><default><default>
+lcdd22 = port:PH22<2><0><default><default>
+lcdd23 = port:PH23<2><0><default><default>
+lcdclk = port:PH24<2><0><default><default>
+lcdde = port:PH25<2><0><default><default>
+lcdhsync = port:PH26<2><0><default><default>
+lcdvsync = port:PH27<2><0><default><default>
+
+[tv_out_dac_para]
+dac_used = 1
+dac0_src = 4
+dac1_src = 5
+dac2_src = 6
+dac3_src = 0
+
+[hdmi_para]
+hdmi_used = 1
+hdcp_enable = 0
+
+[i2s2_para]
+i2s_channel = 2
+i2s_master = 4
+i2s_select = 1
+audio_format = 1
+signal_inversion = 1
+over_sample_rate = 256
+sample_resolution = 16
+word_select_size = 32
+pcm_sync_period = 256
+msb_lsb_first = 0
+sign_extend = 0
+slot_index = 0
+slot_width = 16
+frame_width = 1
+tx_data_mode = 0
+rx_data_mode = 0
+
+[camera_list_para]
+camera_list_para_used = 1
+ov7670 = 0
+gc0308 = 0
+gt2005 = 0
+hi704 = 0
+sp0838 = 0
+mt9m112 = 0
+mt9m113 = 0
+gc2035 = 0
+ov2655 = 0
+hi253 = 0
+gc0307 = 0
+mt9d112 = 0
+ov5640 = 0
+gc2015 = 0
+ov2643 = 0
+gc0329 = 1
+gc0328 = 0
+gc0309 = 0
+tvp5150 = 0
+s5k4ec = 0
+ov5650_mv9335 = 0
+siv121d = 0
+
+[csi0_para]
+csi_used = 1
+csi_dev_qty = 1
+csi_stby_mode = 0
+csi_mname = "gc0329"
+csi_twi_id = 1
+csi_twi_addr = 0x62
+csi_if = 0
+csi_vflip = 0
+csi_hflip = 1
+csi_iovdd = "axp20_hdmi"
+csi_avdd = "axp20_pll"
+csi_dvdd = ""
+csi_vol_iovdd = 2800
+csi_vol_dvdd =
+csi_vol_avdd = 2800
+csi_flash_pol = 0
+csi_facing = 0
+csi_mname_b = ""
+csi_twi_id_b = 1
+csi_twi_addr_b = 0x42
+csi_if_b = 0
+csi_vflip_b = 0
+csi_hflip_b = 0
+csi_iovdd_b = "axp20_pll"
+csi_avdd_b = ""
+csi_dvdd_b = ""
+csi_vol_iovdd_b = 2800
+csi_vol_avdd_b =
+csi_vol_dvdd_b =
+csi_flash_pol_b = 0
+csi_pck = port:PE00<3><default><default><default>
+csi_ck = port:PE01<3><default><default><default>
+csi_hsync = port:PE02<3><default><default><default>
+csi_vsync = port:PE03<3><default><default><default>
+csi_d0 = port:PE04<3><default><default><default>
+csi_d1 = port:PE05<3><default><default><default>
+csi_d2 = port:PE06<3><default><default><default>
+csi_d3 = port:PE07<3><default><default><default>
+csi_d4 = port:PE08<3><default><default><default>
+csi_d5 = port:PE09<3><default><default><default>
+csi_d6 = port:PE10<3><default><default><default>
+csi_d7 = port:PE11<3><default><default><default>
+csi_reset = port:PH13<1><default><default><1>
+csi_power_en = port:PH16<1><default><default><1>
+csi_stby = port:PH19<1><default><default><0>
+csi_flash =
+csi_af_en =
+csi_reset_b = port:PH14<1><default><default><0>
+csi_power_en_b = port:PH17<1><default><default><0>
+csi_stby_b = port:PH19<1><default><default><1>
+csi_flash_b =
+csi_af_en_b =
+
+[csi1_para]
+csi_used = 0
+csi_dev_qty = 1
+csi_stby_mode = 0
+csi_mname = "gc0308"
+csi_if = 0
+csi_iovdd = "axp20_pll"
+csi_avdd = "axp20_pll"
+csi_dvdd = ""
+csi_vol_iovdd = 2800
+csi_vol_dvdd =
+csi_vol_avdd =
+csi_vflip = 0
+csi_hflip = 0
+csi_flash_pol = 0
+csi_facing = 1
+csi_twi_id = 1
+csi_twi_addr = 0x42
+csi_pck = port:PG00<3><default><default><default>
+csi_ck = port:PG01<3><default><default><default>
+csi_hsync = port:PG02<3><default><default><default>
+csi_vsync = port:PG03<3><default><default><default>
+csi_d0 = port:PG04<3><default><default><default>
+csi_d1 = port:PG05<3><default><default><default>
+csi_d2 = port:PG06<3><default><default><default>
+csi_d3 = port:PG07<3><default><default><default>
+csi_d4 = port:PG08<3><default><default><default>
+csi_d5 = port:PG09<3><default><default><default>
+csi_d6 = port:PG10<3><default><default><default>
+csi_d7 = port:PG11<3><default><default><default>
+csi_reset = port:PH14<1><default><default><0>
+csi_power_en = port:PH17<1><default><default><0>
+csi_stby = port:PH19<1><default><default><1>
+
+[tvout_para]
+tvout_used = 1
+tvout_channel_num = 1
+
+[tvin_para]
+tvin_used = 0
+tvin_channel_num = 4
+
+[sata_para]
+sata_used = 1
+sata_power_en =
+
+[mmc0_para]
+sdc_used = 1
+sdc_detmode = 1
+sdc_buswidth = 4
+sdc_clk = port:PF02<2><1><2><default>
+sdc_cmd = port:PF03<2><1><2><default>
+sdc_d0 = port:PF01<2><1><2><default>
+sdc_d1 = port:PF00<2><1><2><default>
+sdc_d2 = port:PF05<2><1><2><default>
+sdc_d3 = port:PF04<2><1><2><default>
+sdc_det = port:PH01<0><1><default><default>
+sdc_use_wp = 0
+sdc_wp =
+sdc_isio = 0
+sdc_regulator = "none"
+
+[mmc1_para]
+sdc_used = 0
+sdc_detmode = 4
+sdc_buswidth = 4
+sdc_clk = port:PG00<2><1><2><default>
+sdc_cmd = port:PG01<2><1><2><default>
+sdc_d0 = port:PG02<2><1><2><default>
+sdc_d1 = port:PG03<2><1><2><default>
+sdc_d2 = port:PG04<2><1><2><default>
+sdc_d3 = port:PG05<2><1><2><default>
+sdc_det =
+sdc_use_wp = 0
+sdc_wp =
+sdc_isio = 0
+sdc_regulator = "none"
+
+[mmc2_para]
+sdc_used = 0
+sdc_detmode = 3
+sdc_buswidth = 4
+sdc_cmd = port:PC06<3><1><2><default>
+sdc_clk = port:PC07<3><1><2><default>
+sdc_d0 = port:PC08<3><1><2><default>
+sdc_d1 = port:PC09<3><1><2><default>
+sdc_d2 = port:PC10<3><1><2><default>
+sdc_d3 = port:PC11<3><1><2><default>
+sdc_det =
+sdc_use_wp = 0
+sdc_wp =
+sdc_isio = 0
+sdc_regulator = "none"
+
+[mmc3_para]
+sdc_used = 1
+sdc_detmode = 4
+sdc_buswidth = 4
+sdc_cmd = port:PI04<2><1><2><default>
+sdc_clk = port:PI05<2><1><2><default>
+sdc_d0 = port:PI06<2><1><2><default>
+sdc_d1 = port:PI07<2><1><2><default>
+sdc_d2 = port:PI08<2><1><2><default>
+sdc_d3 = port:PI09<2><1><2><default>
+sdc_det =
+sdc_use_wp = 0
+sdc_wp =
+sdc_isio = 1
+sdc_regulator = "none"
+
+[ms_para]
+ms_used = 0
+ms_bs = port:PH06<5><default><default><default>
+ms_clk = port:PH07<5><default><default><default>
+ms_d0 = port:PH08<5><default><default><default>
+ms_d1 = port:PH09<5><default><default><default>
+ms_d2 = port:PH10<5><default><default><default>
+ms_d3 = port:PH11<5><default><default><default>
+ms_det =
+
+[smc_para]
+smc_used = 0
+smc_rst = port:PH13<5><default><default><default>
+smc_vppen = port:PH14<5><default><default><default>
+smc_vppp = port:PH15<5><default><default><default>
+smc_det = port:PH16<5><default><default><default>
+smc_vccen = port:PH17<5><default><default><default>
+smc_sck = port:PH18<5><default><default><default>
+smc_sda = port:PH19<5><default><default><default>
+
+[ps2_0_para]
+ps2_used = 0
+ps2_scl = port:PI20<2><1><default><default>
+ps2_sda = port:PI21<2><1><default><default>
+
+[ps2_1_para]
+ps2_used = 0
+ps2_scl = port:PI14<3><1><default><default>
+ps2_sda = port:PI15<3><1><default><default>
+
+[can_para]
+can_used = 0
+can_tx = port:PA16<3><default><default><default>
+can_rx = port:PA17<3><default><default><default>
+
+[keypad_para]
+kp_used = 0
+kp_in_size = 8
+kp_out_size = 8
+kp_in0 = port:PH08<4><1><default><default>
+kp_in1 = port:PH09<4><1><default><default>
+kp_in2 = port:PH10<4><1><default><default>
+kp_in3 = port:PH11<4><1><default><default>
+kp_in4 = port:PH14<4><1><default><default>
+kp_in5 = port:PH15<4><1><default><default>
+kp_in6 = port:PH16<4><1><default><default>
+kp_in7 = port:PH17<4><1><default><default>
+kp_out0 = port:PH18<4><1><default><default>
+kp_out1 = port:PH19<4><1><default><default>
+kp_out2 = port:PH22<4><1><default><default>
+kp_out3 = port:PH23<4><1><default><default>
+kp_out4 = port:PH24<4><1><default><default>
+kp_out5 = port:PH25<4><1><default><default>
+kp_out6 = port:PH26<4><1><default><default>
+kp_out7 = port:PH27<4><1><default><default>
+
+[usbc0]
+usb_used = 1
+usb_port_type = 2
+usb_detect_type = 1
+usb_id_gpio = port:PH04<0><1><default><default>
+usb_det_vbus_gpio = "axp_ctrl"
+usb_drv_vbus_gpio = port:PB09<1><0><default><0>
+usb_ac_enable_gpio = port:PH05<1><0><default><0>
+usb_restrict_gpio = 0
+usb_host_init_state = 0
+usb_restric_flag = 0
+usb_restric_voltage = 3550000
+usb_restric_capacity = 5
+
+[usbc1]
+usb_used = 1
+usb_port_type = 1
+usb_detect_type = 0
+usb_drv_vbus_gpio = port:PH06<1><0><default><0>
+usb_restrict_gpio =
+usb_host_init_state = 1
+usb_restric_flag = 0
+
+[usbc2]
+usb_used = 1
+usb_port_type = 1
+usb_detect_type = 0
+usb_drv_vbus_gpio = port:PH03<1><0><default><0>
+usb_restrict_gpio =
+usb_host_init_state = 1
+usb_restric_flag = 0
+
+[usb_feature]
+vendor_id = 6353
+mass_storage_id = 1
+adb_id = 2
+manufacturer_name = "USB Developer"
+product_name = "Android"
+serial_number = "20080411"
+
+[msc_feature]
+vendor_name = "Numy_3G_AW1"
+product_name = ""
+release = 100
+luns = 2
+
+[gsensor_para]
+gsensor_used = 1
+gsensor_twi_id = 1
+gsensor_int1 =
+gsensor_int2 =
+
+[gsensor_list_para]
+gsensor_det_used = 1
+bma250 = 1
+mma8452 = 1
+mma7660 = 1
+mma865x = 1
+afa750 = 1
+lis3de_acc = 1
+lis3dh_acc = 1
+kxtik = 1
+dmard10 = 0
+dmard06 = 1
+mxc622x = 1
+fxos8700 = 1
+lsm303d = 1
+
+[gps_para]
+gps_used = 0
+gps_spi_id = 2
+gps_spi_cs_num = 0
+gps_lradc = 1
+gps_clk = port:PI00<2><default><default><default>
+gps_sign = port:PI01<2><default><default><default>
+gps_mag = port:PI02<2><default><default><default>
+gps_vcc_en = port:PC22<1><default><default><0>
+gps_osc_en = port:PI14<1><default><default><0>
+gps_rx_en = port:PI15<1><default><default><0>
+
+[wifi_para]
+wifi_used = 1
+wifi_sdc_id = 3
+wifi_usbc_id = 2
+wifi_usbc_type = 1
+wifi_mod_sel = 7
+wifi_power = ""
+rtk_rtl8723as_wl_dis = port:PH09<1><default><default><0>
+rtk_rtl8723as_bt_dis = port:PB05<1><default><default><0>
+rtk_rtl8723as_wl_host_wake = port:PH10<0><default><default><0>
+rtk_rtl8723as_bt_host_wake = port:PI21<0><default><default><0>
+ap6xxx_lpo = port:PI12<4><default><default><0>
+ap6xxx_wl_vcc_en = port:PH12<1><default><default><1>
+ap6xxx_wl_regon = port:PH09<1><default><default><0>
+ap6xxx_wl_host_wake = port:PH10<0><default><default><0>
+ap6xxx_bt_regon = port:PB05<1><default><default><1>
+ap6xxx_bt_wake = port:PI20<1><default><default><0>
+ap6xxx_bt_host_wake = port:PI21<0><default><default><0>
+
+[3g_para]
+3g_used = 1
+3g_usbc_num = 2
+3g_usbc_type = 2
+3g_uart_num =
+3g_pwen = port:PA01<1><default><default><0>
+3g_pwr = port:PA06<1><default><default><0>
+3g_wakeup =
+3g_host_wakeup = port:PA03<1><default><default><0>
+3g_bb_wakeup = port:PH02<6><default><default><default>
+3g_bt_pcm_en = port:PA00<1><default><default><0>
+3g_ap_pcm_en = port:PA04<1><default><default><0>
+3g_int =
+
+[gy_para]
+gy_used = 0
+gy_twi_id = 1
+gy_twi_addr = 0
+gy_int1 = port:PH18<6><1><default><default>
+gy_int2 = port:PH19<6><1><default><default>
+
+[ls_para]
+ls_used = 0
+ls_twi_id = 1
+ls_twi_addr = 0
+ls_int = port:PH20<6><1><default><default>
+
+[compass_para]
+compass_used = 0
+compass_twi_id = 1
+compass_twi_addr = 0
+compass_int = port:PI13<6><1><default><default>
+
+[bt_para]
+bt_used = 1
+bt_uart_id = 2
+bt_wakeup = port:PI20<1><default><default><default>
+bt_gpio = port:PI21<1><default><default><default>
+bt_rst = port:PB05<1><default><default><default>
+
+[i2s_para]
+i2s_used = 1
+i2s_channel = 2
+i2s_master = 1
+i2s_select = 0
+audio_format = 4
+signal_inversion = 3
+over_sample_rate = 256
+sample_resolution = 16
+word_select_size = 32
+pcm_sync_period = 256
+msb_lsb_first = 0
+sign_extend = 0
+slot_index = 0
+slot_width = 16
+frame_width = 1
+tx_data_mode = 0
+rx_data_mode = 0
+i2s_mclk = port:PB05<2><1><default><default>
+i2s_bclk = port:PB06<2><1><default><default>
+i2s_lrclk = port:PB07<2><1><default><default>
+i2s_dout0 = port:PB08<2><1><default><default>
+i2s_dout1 =
+i2s_dout2 =
+i2s_dout3 =
+i2s_din = port:PB12<2><1><default><default>
+
+[pcm_para]
+pcm_used = 0
+pcm_channel = 2
+pcm_master = 4
+pcm_select = 1
+audio_format = 4
+signal_inversion = 3
+over_sample_rate = 512
+sample_resolution = 16
+word_select_size = 32
+pcm_sync_period = 64
+msb_lsb_first = 0
+sign_extend = 0
+slot_index = 0
+slot_width = 16
+frame_width = 1
+tx_data_mode = 0
+rx_data_mode = 0
+pcm_mclk = port:PA09<6><1><default><default>
+pcm_bclk = port:PA14<6><1><default><default>
+pcm_lrclk = port:PA15<6><1><default><default>
+pcm_dout0 = port:PA16<6><1><default><default>
+pcm_dout1 =
+pcm_dout2 =
+pcm_dout3 =
+pcm_din = port:PA17<6><1><default><default>
+
+[spdif_para]
+spdif_used = 0
+spdif_mclk =
+spdif_dout = port:PB13<4><1><default><default>
+spdif_din =
+
+[audio_para]
+audio_used = 1
+audio_pa_ctrl = port:PH15<1><default><default><0>
+mic_switch_ctrl = port:PI10<1><default><default><0>
+
+[switch_para]
+switch_used = 1
+
+[ir_para]
+ir_used = 0
+ir_rx = port:PB04<2><default><default><default>
+
+[pmu_para]
+pmu_used = 1
+pmu_twi_addr = 52
+pmu_twi_id = 0
+pmu_irq_id = 32
+pmu_battery_rdc = 100
+pmu_battery_cap = 2400
+pmu_init_chgcur = 800
+pmu_earlysuspend_chgcur = 800
+pmu_suspend_chgcur = 1200
+pmu_resume_chgcur = 800
+pmu_shutdown_chgcur = 1200
+pmu_init_chgvol = 4150
+pmu_init_chgend_rate = 15
+pmu_init_chg_enabled = 1
+pmu_init_adc_freq = 100
+pmu_init_adc_freqc = 100
+pmu_init_chg_pretime = 50
+pmu_init_chg_csttime = 720
+pmu_bat_para1 = 0
+pmu_bat_para2 = 0
+pmu_bat_para3 = 0
+pmu_bat_para4 = 2
+pmu_bat_para5 = 5
+pmu_bat_para6 = 20
+pmu_bat_para7 = 33
+pmu_bat_para8 = 46
+pmu_bat_para9 = 56
+pmu_bat_para10 = 63
+pmu_bat_para11 = 68
+pmu_bat_para12 = 73
+pmu_bat_para13 = 82
+pmu_bat_para14 = 90
+pmu_bat_para15 = 100
+pmu_bat_para16 = 100
+pmu_usbvol_limit = 1
+pmu_usbcur_limit = 0
+pmu_usbvol = 4000
+pmu_usbcur = 0
+pmu_usbvol_pc = 4400
+pmu_usbcur_pc = 600
+pmu_pwroff_vol = 3300
+pmu_pwron_vol = 2900
+pmu_pekoff_time = 6000
+pmu_pekoff_en = 1
+pmu_peklong_time = 1500
+pmu_pekon_time = 1000
+pmu_pwrok_time = 64
+pmu_pwrnoe_time = 2000
+pmu_intotp_en = 1
+pmu_used2 = 0
+pmu_adpdet = port:PH02<0><default><default><default>
+pmu_init_chgcur2 = 400
+pmu_earlysuspend_chgcur2 = 600
+pmu_suspend_chgcur2 = 1200
+pmu_resume_chgcur2 = 400
+pmu_shutdown_chgcur2 = 1200
+pmu_suspendpwroff_vol = 3500
+pmu_batdeten = 1
+
+[recovery_key]
+key_min = 4
+key_max = 40
+
+[dvfs_table]
+max_freq = 912000000
+normal_freq = 720000000
+min_freq = 60000000
+LV_count = 8
+LV1_freq = 1008000000
+LV1_volt = 1450
+LV2_freq = 912000000
+LV2_volt = 1400
+LV3_freq = 864000000
+LV3_volt = 1300
+LV4_freq = 792000000
+LV4_volt = 1250
+LV5_freq = 720000000
+LV5_volt = 1200
+LV6_freq = 624000000
+LV6_volt = 1150
+LV7_freq = 528000000
+LV7_volt = 1100
+LV8_freq = 312000000
+LV8_volt = 1050
+
diff --git a/sunxi-devices/ainol_aw1/sunxi.prop b/sunxi-devices/ainol_aw1/sunxi.prop
new file mode 100644 (file)
index 0000000..98cfca8
--- /dev/null
@@ -0,0 +1 @@
+sunxi.platform = sun7i
diff --git a/sunxi-devices/icou_fatty_i/Android.mk b/sunxi-devices/icou_fatty_i/Android.mk
new file mode 100644 (file)
index 0000000..902ed80
--- /dev/null
@@ -0,0 +1,20 @@
+# Copyright (C) 2014 Paul Kocialkowski <contact@paulk.fr>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+icou_fatty_i := "$(SUNXI_DEVICES_OUT)/icou_fatty_i"
+$(icou_fatty_i): sunxi_uboot_ICOU_Fatty_I
+       @mkdir -p "$@"
+       @cp "$(SUNXI_UBOOT_OUT)/ICOU_Fatty_I/u-boot.img" "$@/"
+       @cp "$(SUNXI_UBOOT_OUT)/ICOU_Fatty_I/spl/sunxi-spl.bin" "$@/"
diff --git a/sunxi-devices/icou_fatty_i/script.fex b/sunxi-devices/icou_fatty_i/script.fex
new file mode 100644 (file)
index 0000000..8e32711
--- /dev/null
@@ -0,0 +1,983 @@
+[product]
+version = "100"
+machine = "s785-v10"
+
+[platform]
+eraseflag = 1
+
+[target]
+boot_clock = 912
+dcdc2_vol = 1400
+dcdc3_vol = 1250
+ldo2_vol = 3000
+ldo3_vol = 2800
+ldo4_vol = 2800
+power_start = 0
+storage_type = 0
+
+[clock]
+pll3 = 297
+pll4 = 300
+pll6 = 600
+pll7 = 297
+pll8 = 336
+
+[card_boot]
+logical_start = 40960
+sprite_gpio0 =
+
+[card0_boot_para]
+card_ctrl = 0
+card_high_speed = 1
+card_line = 4
+sdc_d1 = port:PF00<2><1><default><default>
+sdc_d0 = port:PF01<2><1><default><default>
+sdc_clk = port:PF02<2><1><default><default>
+sdc_cmd = port:PF03<2><1><default><default>
+sdc_d3 = port:PF04<2><1><default><default>
+sdc_d2 = port:PF05<2><1><default><default>
+
+[card2_boot_para]
+card_ctrl = 2
+card_high_speed = 1
+card_line = 4
+sdc_cmd = port:PC06<3><1><default><default>
+sdc_clk = port:PC07<3><1><default><default>
+sdc_d0 = port:PC08<3><1><default><default>
+sdc_d1 = port:PC09<3><1><default><default>
+sdc_d2 = port:PC10<3><1><default><default>
+sdc_d3 = port:PC11<3><1><default><default>
+
+[twi_para]
+twi_port = 0
+twi_scl = port:PB00<2><default><default><default>
+twi_sda = port:PB01<2><default><default><default>
+
+[uart_para]
+uart_debug_port = 0
+uart_debug_tx = port:PB22<2><1><default><default>
+uart_debug_rx = port:PB23<2><1><default><default>
+
+[uart_force_debug]
+uart_debug_port = 0
+uart_debug_tx = port:PF02<4><1><default><default>
+uart_debug_rx = port:PF04<4><1><default><default>
+
+[jtag_para]
+jtag_enable = 1
+jtag_ms = port:PB14<3><default><default><default>
+jtag_ck = port:PB15<3><default><default><default>
+jtag_do = port:PB16<3><default><default><default>
+jtag_di = port:PB17<3><default><default><default>
+
+[pm_para]
+standby_mode = 1
+
+[dram_para]
+dram_baseaddr = 0x40000000
+dram_clk = 384
+dram_type = 3
+dram_rank_num = 1
+dram_chip_density = 4096
+dram_io_width = 16
+dram_bus_width = 32
+dram_cas = 9
+dram_zq = 0x7f
+dram_odt_en = 0
+dram_size = 1024
+dram_tpr0 = 0x42d899b7
+dram_tpr1 = 0xa090
+dram_tpr2 = 0x22a00
+dram_tpr3 = 0x0
+dram_tpr4 = 0x1
+dram_tpr5 = 0x0
+dram_emr1 = 0x4
+dram_emr2 = 0x10
+dram_emr3 = 0x0
+
+[mali_para]
+mali_used = 1
+mali_clkdiv = 1
+
+[emac_para]
+emac_used = 0
+emac_rxd3 = port:PA00<2><default><default><default>
+emac_rxd2 = port:PA01<2><default><default><default>
+emac_rxd1 = port:PA02<2><default><default><default>
+emac_rxd0 = port:PA03<2><default><default><default>
+emac_txd3 = port:PA04<2><default><default><default>
+emac_txd2 = port:PA05<2><default><default><default>
+emac_txd1 = port:PA06<2><default><default><default>
+emac_txd0 = port:PA07<2><default><default><default>
+emac_rxclk = port:PA08<2><default><default><default>
+emac_rxerr = port:PA09<2><default><default><default>
+emac_rxdV = port:PA10<2><default><default><default>
+emac_mdc = port:PA11<2><default><default><default>
+emac_mdio = port:PA12<2><default><default><default>
+emac_txen = port:PA13<2><default><default><default>
+emac_txclk = port:PA14<2><default><default><default>
+emac_crs = port:PA15<2><default><default><default>
+emac_col = port:PA16<2><default><default><default>
+emac_reset = port:PA17<1><default><default><default>
+
+[twi0_para]
+twi0_used = 1
+twi0_scl = port:PB00<2><default><default><default>
+twi0_sda = port:PB01<2><default><default><default>
+
+[twi1_para]
+twi1_used = 1
+twi1_scl = port:PB18<2><default><default><default>
+twi1_sda = port:PB19<2><default><default><default>
+
+[twi2_para]
+twi2_used = 1
+twi2_scl = port:PB20<2><default><default><default>
+twi2_sda = port:PB21<2><default><default><default>
+
+[uart_para0]
+uart_used = 1
+uart_port = 0
+uart_type = 2
+uart_tx = port:PB22<2><1><default><default>
+uart_rx = port:PB23<2><1><default><default>
+
+[uart_para1]
+uart_used = 0
+uart_port = 1
+uart_type = 8
+uart_tx = port:PA10<4><1><default><default>
+uart_rx = port:PA11<4><1><default><default>
+uart_rts = port:PA12<4><1><default><default>
+uart_cts = port:PA13<4><1><default><default>
+uart_dtr = port:PA14<4><1><default><default>
+uart_dsr = port:PA15<4><1><default><default>
+uart_dcd = port:PA16<4><1><default><default>
+uart_ring = port:PA17<4><1><default><default>
+
+[uart_para2]
+uart_used = 0
+uart_port = 2
+uart_type = 4
+uart_tx = port:PI18<3><1><default><default>
+uart_rx = port:PI19<3><1><default><default>
+uart_rts = port:PI16<3><1><default><default>
+uart_cts = port:PI17<3><1><default><default>
+
+[uart_para3]
+uart_used = 0
+uart_port = 3
+uart_type = 4
+uart_tx = port:PH00<4><1><default><default>
+uart_rx = port:PH01<4><1><default><default>
+uart_rts = port:PH02<4><1><default><default>
+uart_cts = port:PH03<4><1><default><default>
+
+[uart_para4]
+uart_used = 0
+uart_port = 4
+uart_type = 2
+uart_tx = port:PH04<4><1><default><default>
+uart_rx = port:PH05<4><1><default><default>
+
+[uart_para5]
+uart_used = 0
+uart_port = 5
+uart_type = 2
+uart_tx = port:PH06<4><1><default><default>
+uart_rx = port:PH07<4><1><default><default>
+
+[uart_para6]
+uart_used = 0
+uart_port = 6
+uart_type = 2
+uart_tx = port:PA12<3><1><default><default>
+uart_rx = port:PA13<3><1><default><default>
+
+[uart_para7]
+uart_used = 0
+uart_port = 7
+uart_type = 2
+uart_tx = port:PA14<3><1><default><default>
+uart_rx = port:PA15<3><1><default><default>
+
+[spi0_para]
+spi_used = 0
+spi_cs_bitmap = 1
+spi_cs0 = port:PI10<2><default><default><default>
+spi_cs1 = port:PI14<2><default><default><default>
+spi_sclk = port:PI11<2><default><default><default>
+spi_mosi = port:PI12<2><default><default><default>
+spi_miso = port:PI13<2><default><default><default>
+
+[spi1_para]
+spi_used = 0
+spi_cs_bitmap = 1
+spi_cs0 = port:PA00<3><default><default><default>
+spi_cs1 = port:PA04<3><default><default><default>
+spi_sclk = port:PA01<3><default><default><default>
+spi_mosi = port:PA02<3><default><default><default>
+spi_miso = port:PA03<3><default><default><default>
+
+[spi2_para]
+spi_used = 0
+spi_cs_bitmap = 1
+spi_cs0 = port:PC19<3><default><default><default>
+spi_cs1 = port:PB13<2><default><default><default>
+spi_sclk = port:PC20<3><default><default><default>
+spi_mosi = port:PC21<3><default><default><default>
+spi_miso = port:PC22<3><default><default><default>
+
+[spi3_para]
+spi_used = 0
+spi_cs_bitmap = 1
+spi_cs0 = port:PA05<3><default><default><default>
+spi_cs1 = port:PA09<3><default><default><default>
+spi_sclk = port:PA06<3><default><default><default>
+spi_mosi = port:PA07<3><default><default><default>
+spi_miso = port:PA08<3><default><default><default>
+
+[ctp_para]
+ctp_used = 1
+ctp_name = "ft5x_ts"
+ctp_twi_id = 2
+ctp_twi_addr = 0x38
+ctp_screen_max_x = 768
+ctp_screen_max_y = 1024
+ctp_revert_x_flag = 0
+ctp_revert_y_flag = 0
+ctp_exchange_x_y_flag = 0
+ctp_int_port = port:PH21<6><default><default><default>
+ctp_wakeup = port:PB13<1><default><default><1>
+
+[ctp18_para]
+ctp_used = 1
+ctp_name = "gslX680"
+ctp_twi_id = 2
+ctp_twi_addr = 0x40
+ctp_screen_max_x = 768
+ctp_screen_max_y = 1024
+ctp_revert_x_flag = 0
+ctp_revert_y_flag = 0
+ctp_exchange_x_y_flag = 0
+ctp_int_port = port:PH21<6><default><default><default>
+ctp_wakeup = port:PB13<1><default><default><1>
+
+[ctp20_para]
+ctp_used = 1
+ctp_name = "gt9xx_ts"
+ctp_twi_id = 2
+ctp_twi_addr = 0x5d
+ctp_screen_max_x = 768
+ctp_screen_max_y = 1024
+ctp_revert_x_flag = 0
+ctp_revert_y_flag = 0
+ctp_exchange_x_y_flag = 0
+ctp_int_port = port:PH21<6><default><default><default>
+ctp_wakeup = port:PB13<1><default><default><1>
+
+[ctp21_para]
+ctp_used = 1
+ctp_name = "ilitek_ts"
+ctp_twi_id = 2
+ctp_twi_addr = 0x41
+ctp_screen_max_x = 768
+ctp_screen_max_y = 1024
+ctp_revert_x_flag = 0
+ctp_revert_y_flag = 0
+ctp_exchange_x_y_flag = 0
+ctp_int_port = port:PH21<6><default><default><default>
+ctp_wakeup = port:PB13<1><default><default><1>
+
+[tkey_para]
+tkey_used = 0
+tkey_twi_id = 2
+tkey_twi_addr = 0x62
+tkey_int = port:PI13<6><default><default><default>
+
+[motor_para]
+motor_used = 0
+motor_shake = port:PB03<1><default><default><1>
+
+[nand_para]
+nand_used = 1
+nand_we = port:PC00<2><default><default><default>
+nand_ale = port:PC01<2><default><default><default>
+nand_cle = port:PC02<2><default><default><default>
+nand_ce1 = port:PC03<2><default><default><default>
+nand_ce0 = port:PC04<2><default><default><default>
+nand_nre = port:PC05<2><default><default><default>
+nand_rb0 = port:PC06<2><default><default><default>
+nand_rb1 = port:PC07<2><default><default><default>
+nand_d0 = port:PC08<2><default><default><default>
+nand_d1 = port:PC09<2><default><default><default>
+nand_d2 = port:PC10<2><default><default><default>
+nand_d3 = port:PC11<2><default><default><default>
+nand_d4 = port:PC12<2><default><default><default>
+nand_d5 = port:PC13<2><default><default><default>
+nand_d6 = port:PC14<2><default><default><default>
+nand_d7 = port:PC15<2><default><default><default>
+nand_wp = port:PC16<2><default><default><default>
+nand_ce2 = port:PC17<2><default><default><default>
+nand_ce3 = port:PC18<2><default><default><default>
+nand_ce4 =
+nand_ce5 =
+nand_ce6 =
+nand_ce7 =
+nand_spi = port:PC23<3><default><default><default>
+nand_ndqs = port:PC24<2><default><default><default>
+good_block_ratio = 912
+
+[disp_init]
+disp_init_enable = 1
+disp_mode = 0
+screen0_output_type = 1
+screen0_output_mode = 4
+screen1_output_type = 1
+screen1_output_mode = 4
+fb0_framebuffer_num = 2
+fb0_format = 10
+fb0_pixel_sequence = 0
+fb0_scaler_mode_enable = 0
+fb1_framebuffer_num = 2
+fb1_format = 10
+fb1_pixel_sequence = 0
+fb1_scaler_mode_enable = 0
+lcd0_backlight = 197
+lcd1_backlight = 197
+lcd0_bright = 50
+lcd0_contrast = 50
+lcd0_saturation = 57
+lcd0_hue = 50
+lcd1_bright = 50
+lcd1_contrast = 50
+lcd1_saturation = 57
+lcd1_hue = 50
+
+[lcd0_para]
+lcd_used = 1
+lcd_x = 768
+lcd_y = 1024
+lcd_dclk_freq = 66
+lcd_pwm_not_used = 0
+lcd_pwm_ch = 0
+lcd_pwm_freq = 10000
+lcd_pwm_pol = 1
+lcd_max_bright = 180
+lcd_min_bright = 64
+lcd_if = 4
+lcd_hbp = 120
+lcd_ht = 948
+lcd_vbp = 80
+lcd_vt = 2280
+lcd_vspw = 50
+lcd_hspw = 64
+lcd_hv_if = 0
+lcd_hv_smode = 0
+lcd_hv_s888_if = 0
+lcd_hv_syuv_if = 0
+lcd_lvds_ch = 0
+lcd_lvds_mode = 0
+lcd_lvds_bitwidth = 0
+lcd_lvds_io_cross = 0
+lcd_cpu_if = 0
+lcd_frm = 1
+lcd_io_cfg0 = 67108864
+lcd_gamma_correction_en = 0
+lcd_gamma_tbl_0 = 0x0
+lcd_gamma_tbl_1 = 0x10101
+lcd_gamma_tbl_255 = 0xffffff
+lcd_gpio_0 = port:PA06<1><0><default><1>
+lcd_gpio_1 = port:PA07<1><0><default><1>
+lcd_gpio_2 = port:PH24<1><0><default><0>
+lcd_gpio_3 = port:PA05<1><0><default><1>
+lcd_gpio_4 = port:PH23<1><0><default><0>
+lcd_gpio_5 = port:PH22<1><0><default><0>
+lcd_bl_en_used = 1
+lcd_bl_en = port:PH07<1><0><default><1>
+lcd_power_used = 1
+lcd_power = port:PH08<1><0><default><1>
+lcd_pwm_used = 1
+lcd_pwm = port:PB02<2><0><default><default>
+lcdd2 = port:PD02<2><0><default><default>
+lcdd3 = port:PD03<2><0><default><default>
+lcdd4 = port:PD04<2><0><default><default>
+lcdd5 = port:PD05<2><0><default><default>
+lcdd6 = port:PD06<2><0><default><default>
+lcdd7 = port:PD07<2><0><default><default>
+lcdd10 = port:PD10<2><0><default><default>
+lcdd11 = port:PD11<2><0><default><default>
+lcdd12 = port:PD12<2><0><default><default>
+lcdd13 = port:PD13<2><0><default><default>
+lcdd14 = port:PD14<2><0><default><default>
+lcdd15 = port:PD15<2><0><default><default>
+lcdd18 = port:PD18<2><0><default><default>
+lcdd19 = port:PD19<2><0><default><default>
+lcdd20 = port:PD20<2><0><default><default>
+lcdd21 = port:PD21<2><0><default><default>
+lcdd22 = port:PD22<2><0><default><default>
+lcdd23 = port:PD23<2><0><default><default>
+lcdclk = port:PD24<2><0><default><default>
+lcdde = port:PD25<2><0><default><default>
+lcdhsync = port:PD26<2><0><default><default>
+lcdvsync = port:PD27<2><0><default><default>
+
+[lcd1_para]
+lcd_used = 0
+lcd_x = 0
+lcd_y = 0
+lcd_dclk_freq = 0
+lcd_pwm_not_used = 0
+lcd_pwm_ch = 1
+lcd_pwm_freq = 0
+lcd_pwm_pol = 0
+lcd_max_bright = 180
+lcd_min_bright = 64
+lcd_if = 0
+lcd_hbp = 0
+lcd_ht = 0
+lcd_vbp = 0
+lcd_vt = 0
+lcd_vspw = 0
+lcd_hspw = 0
+lcd_hv_if = 0
+lcd_hv_smode = 0
+lcd_hv_s888_if = 0
+lcd_hv_syuv_if = 0
+lcd_lvds_ch = 0
+lcd_lvds_mode = 0
+lcd_lvds_bitwidth = 0
+lcd_lvds_io_cross = 0
+lcd_cpu_if = 0
+lcd_frm = 0
+lcd_io_cfg0 = 0
+lcd_gamma_correction_en = 0
+lcd_gamma_tbl_0 = 0x0
+lcd_gamma_tbl_1 = 0x10101
+lcd_gamma_tbl_255 = 0xffffff
+lcd_bl_en_used = 0
+lcd_bl_en =
+lcd_power_used = 0
+lcd_power =
+lcd_pwm_used = 1
+lcd_pwm = port:PI03<2><0><default><default>
+lcd_gpio_0 =
+lcd_gpio_1 =
+lcd_gpio_2 =
+lcd_gpio_3 =
+lcdd0 = port:PH00<2><0><default><default>
+lcdd1 = port:PH01<2><0><default><default>
+lcdd2 = port:PH02<2><0><default><default>
+lcdd3 = port:PH03<2><0><default><default>
+lcdd4 = port:PH04<2><0><default><default>
+lcdd5 = port:PH05<2><0><default><default>
+lcdd6 = port:PH06<2><0><default><default>
+lcdd7 = port:PH07<2><0><default><default>
+lcdd8 = port:PH08<2><0><default><default>
+lcdd9 = port:PH09<2><0><default><default>
+lcdd10 = port:PH10<2><0><default><default>
+lcdd11 = port:PH11<2><0><default><default>
+lcdd12 = port:PH12<2><0><default><default>
+lcdd13 = port:PH13<2><0><default><default>
+lcdd14 = port:PH14<2><0><default><default>
+lcdd15 = port:PH15<2><0><default><default>
+lcdd16 = port:PH16<2><0><default><default>
+lcdd17 = port:PH17<2><0><default><default>
+lcdd18 = port:PH18<2><0><default><default>
+lcdd19 = port:PH19<2><0><default><default>
+lcdd20 = port:PH20<2><0><default><default>
+lcdd21 = port:PH21<2><0><default><default>
+lcdd22 = port:PH22<2><0><default><default>
+lcdd23 = port:PH23<2><0><default><default>
+lcdclk = port:PH24<2><0><default><default>
+lcdde = port:PH25<2><0><default><default>
+lcdhsync = port:PH26<2><0><default><default>
+lcdvsync = port:PH27<2><0><default><default>
+
+[tv_out_dac_para]
+dac_used = 1
+dac0_src = 4
+dac1_src = 5
+dac2_src = 6
+dac3_src = 0
+
+[hdmi_para]
+hdmi_used = 1
+
+[camera_list_para]
+camera_list_para_used = 1
+ov7670 = 0
+gc0308 = 1
+gt2005 = 1
+hi704 = 0
+sp0838 = 0
+mt9m112 = 0
+mt9m113 = 0
+ov2655 = 0
+hi253 = 0
+gc0307 = 0
+mt9d112 = 0
+ov5640 = 0
+gc2015 = 0
+ov2643 = 0
+gc0329 = 0
+gc0309 = 0
+tvp5150 = 0
+s5k4ec = 0
+ov5650_mv9335 = 0
+siv121d = 0
+gc2035 = 1
+
+[csi0_para]
+csi_used = 1
+csi_dev_qty = 2
+csi_stby_mode = 0
+csi_mname = "gt2005"
+csi_twi_id = 1
+csi_twi_addr = 0x78
+csi_if = 0
+csi_vflip = 0
+csi_hflip = 0
+csi_iovdd = "axp20_pll"
+csi_avdd = ""
+csi_dvdd = ""
+csi_vol_iovdd = 2800
+csi_vol_dvdd =
+csi_vol_avdd =
+csi_flash_pol = 0
+csi_mname_b = "gc0308"
+csi_twi_id_b = 1
+csi_twi_addr_b = 0x42
+csi_if_b = 0
+csi_vflip_b = 1
+csi_hflip_b = 1
+csi_iovdd_b = "axp20_pll"
+csi_avdd_b = ""
+csi_dvdd_b = ""
+csi_vol_iovdd_b = 2800
+csi_vol_avdd_b =
+csi_vol_dvdd_b =
+csi_flash_pol_b = 0
+csi_pck = port:PE00<3><default><default><default>
+csi_ck = port:PE01<3><default><default><default>
+csi_hsync = port:PE02<3><default><default><default>
+csi_vsync = port:PE03<3><default><default><default>
+csi_d0 = port:PE04<3><default><default><default>
+csi_d1 = port:PE05<3><default><default><default>
+csi_d2 = port:PE06<3><default><default><default>
+csi_d3 = port:PE07<3><default><default><default>
+csi_d4 = port:PE08<3><default><default><default>
+csi_d5 = port:PE09<3><default><default><default>
+csi_d6 = port:PE10<3><default><default><default>
+csi_d7 = port:PE11<3><default><default><default>
+csi_reset = port:PH14<1><default><default><0>
+csi_power_en = port:PH17<1><default><default><0>
+csi_stby = port:PH18<1><default><default><0>
+csi_flash =
+csi_af_en =
+csi_reset_b = port:PH14<1><default><default><0>
+csi_power_en_b = port:PH17<1><default><default><0>
+csi_stby_b = port:PH19<1><default><default><0>
+csi_flash_b =
+csi_af_en_b =
+
+[csi1_para]
+csi_used = 0
+csi_dev_qty = 1
+csi_stby_mode = 0
+csi_mname = "gc0308"
+csi_if = 0
+csi_iovdd = "axp20_pll"
+csi_avdd = ""
+csi_dvdd = ""
+csi_vol_iovdd = 2800
+csi_vol_dvdd =
+csi_vol_avdd =
+csi_vflip = 0
+csi_hflip = 0
+csi_flash_pol = 0
+csi_facing = 1
+csi_twi_id = 1
+csi_twi_addr = 0x42
+csi_pck = port:PG00<3><default><default><default>
+csi_ck = port:PG01<3><default><default><default>
+csi_hsync = port:PG02<3><default><default><default>
+csi_vsync = port:PG03<3><default><default><default>
+csi_d0 = port:PG04<3><default><default><default>
+csi_d1 = port:PG05<3><default><default><default>
+csi_d2 = port:PG06<3><default><default><default>
+csi_d3 = port:PG07<3><default><default><default>
+csi_d4 = port:PG08<3><default><default><default>
+csi_d5 = port:PG09<3><default><default><default>
+csi_d6 = port:PG10<3><default><default><default>
+csi_d7 = port:PG11<3><default><default><default>
+csi_reset = port:PH13<1><default><default><0>
+csi_power_en = port:PH16<1><default><default><0>
+csi_stby = port:PH19<1><default><default><0>
+
+[tvout_para]
+tvout_used = 1
+tvout_channel_num = 1
+
+[tvin_para]
+tvin_used = 0
+tvin_channel_num = 4
+
+[sata_para]
+sata_used = 1
+sata_power_en =
+
+[mmc0_para]
+sdc_used = 1
+sdc_detmode = 1
+sdc_buswidth = 4
+sdc_clk = port:PF02<2><1><2><default>
+sdc_cmd = port:PF03<2><1><2><default>
+sdc_d0 = port:PF01<2><1><2><default>
+sdc_d1 = port:PF00<2><1><2><default>
+sdc_d2 = port:PF05<2><1><2><default>
+sdc_d3 = port:PF04<2><1><2><default>
+sdc_det = port:PH01<0><1><default><default>
+sdc_use_wp = 0
+sdc_wp =
+sdc_isio = 0
+sdc_regulator = "none"
+
+[mmc1_para]
+sdc_used = 0
+sdc_detmode = 4
+sdc_buswidth = 4
+sdc_clk = port:PG00<2><1><2><default>
+sdc_cmd = port:PG01<2><1><2><default>
+sdc_d0 = port:PG02<2><1><2><default>
+sdc_d1 = port:PG03<2><1><2><default>
+sdc_d2 = port:PG04<2><1><2><default>
+sdc_d3 = port:PG05<2><1><2><default>
+sdc_det =
+sdc_use_wp = 0
+sdc_wp =
+sdc_isio = 0
+sdc_regulator = "none"
+
+[mmc2_para]
+sdc_used = 0
+sdc_detmode = 3
+sdc_buswidth = 4
+sdc_cmd = port:PC06<3><1><2><default>
+sdc_clk = port:PC07<3><1><2><default>
+sdc_d0 = port:PC08<3><1><2><default>
+sdc_d1 = port:PC09<3><1><2><default>
+sdc_d2 = port:PC10<3><1><2><default>
+sdc_d3 = port:PC11<3><1><2><default>
+sdc_det =
+sdc_use_wp = 0
+sdc_wp =
+sdc_isio = 0
+sdc_regulator = "none"
+
+[mmc3_para]
+sdc_used = 0
+sdc_detmode = 4
+sdc_buswidth = 4
+sdc_cmd = port:PI04<2><1><2><default>
+sdc_clk = port:PI05<2><1><2><default>
+sdc_d0 = port:PI06<2><1><2><default>
+sdc_d1 = port:PI07<2><1><2><default>
+sdc_d2 = port:PI08<2><1><2><default>
+sdc_d3 = port:PI09<2><1><2><default>
+sdc_det =
+sdc_use_wp = 0
+sdc_wp =
+sdc_isio = 1
+sdc_regulator = "none"
+
+[ms_para]
+ms_used = 0
+ms_bs = port:PH06<5><default><default><default>
+ms_clk = port:PH07<5><default><default><default>
+ms_d0 = port:PH08<5><default><default><default>
+ms_d1 = port:PH09<5><default><default><default>
+ms_d2 = port:PH10<5><default><default><default>
+ms_d3 = port:PH11<5><default><default><default>
+ms_det =
+
+[smc_para]
+smc_used = 0
+smc_rst = port:PH13<5><default><default><default>
+smc_vppen = port:PH14<5><default><default><default>
+smc_vppp = port:PH15<5><default><default><default>
+smc_det = port:PH16<5><default><default><default>
+smc_vccen = port:PH17<5><default><default><default>
+smc_sck = port:PH18<5><default><default><default>
+smc_sda = port:PH19<5><default><default><default>
+
+[ps2_0_para]
+ps2_used = 0
+ps2_scl = port:PI20<2><1><default><default>
+ps2_sda = port:PI21<2><1><default><default>
+
+[ps2_1_para]
+ps2_used = 0
+ps2_scl = port:PI14<3><1><default><default>
+ps2_sda = port:PI15<3><1><default><default>
+
+[can_para]
+can_used = 0
+can_tx = port:PA16<3><default><default><default>
+can_rx = port:PA17<3><default><default><default>
+
+[keypad_para]
+kp_used = 0
+kp_in_size = 8
+kp_out_size = 8
+kp_in0 = port:PH08<4><1><default><default>
+kp_in1 = port:PH09<4><1><default><default>
+kp_in2 = port:PH10<4><1><default><default>
+kp_in3 = port:PH11<4><1><default><default>
+kp_in4 = port:PH14<4><1><default><default>
+kp_in5 = port:PH15<4><1><default><default>
+kp_in6 = port:PH16<4><1><default><default>
+kp_in7 = port:PH17<4><1><default><default>
+kp_out0 = port:PH18<4><1><default><default>
+kp_out1 = port:PH19<4><1><default><default>
+kp_out2 = port:PH22<4><1><default><default>
+kp_out3 = port:PH23<4><1><default><default>
+kp_out4 = port:PH24<4><1><default><default>
+kp_out5 = port:PH25<4><1><default><default>
+kp_out6 = port:PH26<4><1><default><default>
+kp_out7 = port:PH27<4><1><default><default>
+
+[usbc0]
+usb_used = 1
+usb_port_type = 2
+usb_detect_type = 1
+usb_id_gpio = port:PH04<0><1><default><default>
+usb_det_vbus_gpio = "axp_ctrl"
+usb_drv_vbus_gpio = port:PB09<1><0><default><0>
+usb_ac_enable_gpio = port:PH05<1><0><default><0>
+usb_restrict_gpio = 0
+usb_host_init_state = 0
+usb_restric_flag = 0
+usb_restric_voltage = 3550000
+usb_restric_capacity = 5
+
+[usbc1]
+usb_used = 1
+usb_port_type = 1
+usb_detect_type = 0
+usb_drv_vbus_gpio = port:PH06<1><0><default><0>
+usb_restrict_gpio =
+usb_host_init_state = 1
+usb_restric_flag = 0
+
+[usbc2]
+usb_used = 1
+usb_port_type = 1
+usb_detect_type = 0
+usb_drv_vbus_gpio = port:PH03<1><0><default><0>
+usb_restrict_gpio =
+usb_host_init_state = 0
+usb_restric_flag = 0
+
+[usb_feature]
+vendor_id = 6353
+mass_storage_id = 1
+adb_id = 2
+manufacturer_name = "USB Developer"
+product_name = "Android"
+serial_number = "20080411"
+
+[msc_feature]
+vendor_name = "USB 2.0"
+product_name = "USB Flash Driver"
+release = 100
+luns = 2
+
+[gsensor_para]
+gsensor_used = 1
+gsensor_twi_id = 1
+gsensor_int1 =
+gsensor_int2 =
+gsensor_direct_x = 1
+gsensor_direct_y = 1
+gsensor_direct_z = 0
+gsensor_xy_revert = 0
+
+[gps_para]
+gps_used = 0
+gps_spi_id = 2
+gps_spi_cs_num = 0
+gps_lradc = 1
+gps_clk = port:PI00<2><default><default><default>
+gps_sign = port:PI01<2><default><default><default>
+gps_mag = port:PI02<2><default><default><default>
+gps_vcc_en = port:PC22<1><default><default><0>
+gps_osc_en = port:PI14<1><default><default><0>
+gps_rx_en = port:PI15<1><default><default><0>
+
+[wifi_para]
+wifi_used = 1
+wifi_sdc_id = 3
+wifi_usbc_id = 2
+wifi_usbc_type = 1
+wifi_mod_sel = 6
+wifi_power = ""
+rtk_rtl8723as_wl_dis = port:PH09<1><default><default><0>
+rtk_rtl8723as_bt_dis = port:PB05<1><default><default><0>
+rtk_rtl8723as_wl_host_wake = port:PH10<0><default><default><0>
+rtk_rtl8723as_bt_host_wake = port:PI21<0><default><default><0>
+ap6xxx_wl_regon = port:PH09<1><default><default><0>
+ap6xxx_wl_host_wake = port:PH10<0><default><default><0>
+ap6xxx_bt_regon = port:PB05<1><default><default><0>
+ap6xxx_bt_wake = port:PI20<1><default><default><0>
+ap6xxx_bt_host_wake = port:PI21<0><default><default><0>
+
+[3g_para]
+3g_used = 0
+3g_usbc_num = 2
+3g_uart_num = 0
+3g_pwr =
+3g_wakeup =
+3g_int =
+
+[gy_para]
+gy_used = 0
+gy_twi_id = 1
+gy_twi_addr = 0
+gy_int1 = port:PH18<6><1><default><default>
+gy_int2 = port:PH19<6><1><default><default>
+
+[ls_para]
+ls_used = 0
+ls_twi_id = 1
+ls_twi_addr = 0
+ls_int = port:PH20<6><1><default><default>
+
+[compass_para]
+compass_used = 0
+compass_twi_id = 1
+compass_twi_addr = 0
+compass_int = port:PI13<6><1><default><default>
+
+[bt_para]
+bt_used = 0
+bt_uart_id = 2
+bt_wakeup = port:PI20<1><default><default><default>
+bt_gpio = port:PI21<1><default><default><default>
+bt_rst = port:PB05<1><default><default><default>
+
+[i2s_para]
+i2s_used = 0
+i2s_channel = 2
+i2s_mclk = port:PB05<2><1><default><default>
+i2s_bclk = port:PB06<2><1><default><default>
+i2s_lrclk = port:PB07<2><1><default><default>
+i2s_dout0 = port:PB08<2><1><default><default>
+i2s_dout1 =
+i2s_dout2 =
+i2s_dout3 =
+i2s_din = port:PB12<2><1><default><default>
+
+[spdif_para]
+spdif_used = 0
+spdif_mclk =
+spdif_dout = port:PB13<4><1><default><default>
+spdif_din =
+
+[audio_para]
+audio_used = 1
+audio_pa_ctrl = port:PH15<1><default><default><1>
+audio_hp_ctrl = port:PH16<6><default><default><0>
+
+[switch_para]
+switch_used = 1
+
+[ir_para]
+ir_used = 0
+ir_rx = port:PB04<2><default><default><default>
+
+[pmu_para]
+pmu_used = 1
+pmu_twi_addr = 52
+pmu_twi_id = 0
+pmu_irq_id = 32
+pmu_battery_rdc = 120
+pmu_battery_cap = 3200
+pmu_init_chgcur = 300
+pmu_earlysuspend_chgcur = 600
+pmu_suspend_chgcur = 1000
+pmu_resume_chgcur = 300
+pmu_shutdown_chgcur = 1000
+pmu_init_chgvol = 4200
+pmu_init_chgend_rate = 15
+pmu_init_chg_enabled = 1
+pmu_init_adc_freq = 100
+pmu_init_adc_freqc = 100
+pmu_init_chg_pretime = 50
+pmu_init_chg_csttime = 720
+pmu_bat_para1 = 0
+pmu_bat_para2 = 0
+pmu_bat_para3 = 0
+pmu_bat_para4 = 0
+pmu_bat_para5 = 5
+pmu_bat_para6 = 11
+pmu_bat_para7 = 13
+pmu_bat_para8 = 15
+pmu_bat_para9 = 19
+pmu_bat_para10 = 32
+pmu_bat_para11 = 50
+pmu_bat_para12 = 58
+pmu_bat_para13 = 71
+pmu_bat_para14 = 81
+pmu_bat_para15 = 89
+pmu_bat_para16 = 100
+pmu_usbvol_limit = 1
+pmu_usbcur_limit = 0
+pmu_usbvol = 4700
+pmu_usbcur = 0
+pmu_usbvol_pc = 4700
+pmu_usbcur_pc = 500
+pmu_pwroff_vol = 3300
+pmu_pwron_vol = 2900
+pmu_pekoff_time = 6000
+pmu_pekoff_en = 1
+pmu_peklong_time = 1500
+pmu_pekon_time = 1000
+pmu_pwrok_time = 64
+pmu_pwrnoe_time = 2000
+pmu_intotp_en = 1
+pmu_used2 = 0
+pmu_adpdet = port:PH02<0><default><default><default>
+pmu_init_chgcur2 = 400
+pmu_earlysuspend_chgcur2 = 600
+pmu_suspend_chgcur2 = 1200
+pmu_resume_chgcur2 = 400
+pmu_shutdown_chgcur2 = 1200
+pmu_suspendpwroff_vol = 3500
+pmu_batdeten = 1
+
+[recovery_key]
+key_min = 4
+key_max = 40
+key_map = "158,115,114,0,0,0,0,0,0,0,0,0,0"
+
+[dvfs_table]
+max_freq = 912000000
+normal_freq = 720000000
+min_freq = 60000000
+LV_count = 7
+LV1_freq = 1008000000
+LV1_volt = 1450
+LV2_freq = 912000000
+LV2_volt = 1400
+LV3_freq = 864000000
+LV3_volt = 1300
+LV4_freq = 720000000
+LV4_volt = 1200
+LV5_freq = 528000000
+LV5_volt = 1100
+LV6_freq = 312000000
+LV6_volt = 1050
+LV7_freq = 144000000
+LV7_volt = 1050
+
diff --git a/sunxi-devices/icou_fatty_i/sunxi.prop b/sunxi-devices/icou_fatty_i/sunxi.prop
new file mode 100644 (file)
index 0000000..e0d3db8
--- /dev/null
@@ -0,0 +1 @@
+sunxi.platform = sun5i
diff --git a/sunxi-devices/tzx-q8-713b/Android.mk b/sunxi-devices/tzx-q8-713b/Android.mk
new file mode 100644 (file)
index 0000000..314aba0
--- /dev/null
@@ -0,0 +1,20 @@
+# Copyright (C) 2014 Paul Kocialkowski <contact@paulk.fr>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+tzx-q8-713b := "$(SUNXI_DEVICES_OUT)/tzx-q8-713b"
+$(tzx-q8-713b): sunxi_uboot_A13_MID
+       @mkdir -p "$@"
+       @cp "$(SUNXI_UBOOT_OUT)/A13_MID/u-boot.img" "$@/"
+       @cp "$(SUNXI_UBOOT_OUT)/A13_MID/spl/sunxi-spl.bin" "$@/"
diff --git a/sunxi-devices/tzx-q8-713b/script.fex b/sunxi-devices/tzx-q8-713b/script.fex
new file mode 100644 (file)
index 0000000..33f43e6
--- /dev/null
@@ -0,0 +1,653 @@
+[product]
+version = "1.0"
+machine = "A13-EVB-V1.0"
+
+[target]
+boot_clock = 1008
+dcdc2_vol = 1400
+dcdc3_vol = 1200
+ldo2_vol = 3000
+ldo3_vol = 3300
+ldo4_vol = 3300
+pll4_freq = 960
+pll6_freq = 720
+power_start = 0
+storage_type = 0
+
+[card_boot]
+logical_start = 40960
+sprite_gpio0 =
+
+[pm_para]
+standby_mode = 0
+
+[card_boot0_para]
+card_ctrl = 0
+card_high_speed = 1
+card_line = 4
+sdc_d1 = port:PF00<2><1><default><default>
+sdc_d0 = port:PF01<2><1><default><default>
+sdc_clk = port:PF02<2><1><default><default>
+sdc_cmd = port:PF03<2><1><default><default>
+sdc_d3 = port:PF04<2><1><default><default>
+sdc_d2 = port:PF05<2><1><default><default>
+
+[twi_para]
+twi_port = 0
+twi_scl = port:PB00<2><1><default><default>
+twi_sda = port:PB01<2><1><default><default>
+
+[uart_para]
+uart_debug_port = 0
+uart_debug_tx = port:PB19<2><1><default><default>
+uart_debug_rx = port:PB20<2><1><default><default>
+
+[uart_force_debug]
+uart_debug_port = 0
+uart_debug_tx = port:PF02<4><default><default><default>
+uart_debug_rx = port:PF04<4><default><default><default>
+
+[jtag_para]
+jtag_enable = 0
+jtag_ms = port:PF00<4><1><default><default>
+jtag_ck = port:PF05<4><1><default><default>
+jtag_do = port:PF03<4><1><default><default>
+jtag_di = port:PF01<4><1><default><default>
+
+[dram_para]
+dram_baseaddr = 0x40000000
+dram_clk = 384
+dram_type = 3
+dram_rank_num = 1
+dram_chip_density = 2048
+dram_io_width = 8
+dram_bus_width = 16
+dram_cas = 9
+dram_zq = 0x79
+dram_odt_en = 1
+dram_size = 512
+dram_tpr0 = 0x42d899b7
+dram_tpr1 = 0xa090
+dram_tpr2 = 0x22a00
+dram_tpr3 = 0x0
+dram_tpr4 = 0x0
+dram_tpr5 = 0x0
+dram_emr1 = 0x4
+dram_emr2 = 0x10
+dram_emr3 = 0x0
+
+[nand_para]
+nand_used = 1
+nand_we = port:PC00<2><default><default><default>
+nand_ale = port:PC01<2><default><default><default>
+nand_cle = port:PC02<2><default><default><default>
+nand_ce1 = port:PC03<2><default><default><default>
+nand_ce0 = port:PC04<2><default><default><default>
+nand_nre = port:PC05<2><default><default><default>
+nand_rb0 = port:PC06<2><default><default><default>
+nand_rb1 = port:PC07<2><default><default><default>
+nand_d0 = port:PC08<2><default><default><default>
+nand_d1 = port:PC09<2><default><default><default>
+nand_d2 = port:PC10<2><default><default><default>
+nand_d3 = port:PC11<2><default><default><default>
+nand_d4 = port:PC12<2><default><default><default>
+nand_d5 = port:PC13<2><default><default><default>
+nand_d6 = port:PC14<2><default><default><default>
+nand_d7 = port:PC15<2><default><default><default>
+nand_wp =
+nand_ce2 =
+nand_ce3 =
+nand_ce4 =
+nand_ce5 =
+nand_ce6 =
+nand_ce7 =
+nand_spi =
+nand_ndqs = port:PC19<2><default><default><default>
+
+[mali_para]
+mali_used = 1
+mali_clkdiv = 2
+
+[twi0_para]
+twi0_used = 1
+twi0_scl = port:PB00<2><default><default><default>
+twi0_sda = port:PB01<2><default><default><default>
+
+[twi1_para]
+twi1_used = 1
+twi1_scl = port:PB15<2><default><default><default>
+twi1_sda = port:PB16<2><default><default><default>
+
+[twi2_para]
+twi2_used = 1
+twi2_scl = port:PB17<2><default><default><default>
+twi2_sda = port:PB18<2><default><default><default>
+
+[uart_para0]
+uart_used = 1
+uart_port = 0
+uart_type = 2
+uart_tx = port:PB19<2><1><default><default>
+uart_rx = port:PB20<2><1><default><default>
+
+[uart_para1]
+uart_used = 1
+uart_port = 1
+uart_type = 2
+uart_tx = port:PG03<4><1><default><default>
+uart_rx = port:PG04<4><1><default><default>
+
+[spi1_para]
+spi_used = 0
+spi_cs0 = port:PG09<2><default><default><default>
+spi_cs1 = port:PG13<2><default><default><default>
+spi_sclk = port:PG10<2><default><default><default>
+spi_mosi = port:PG11<2><default><default><default>
+spi_miso = port:PG12<2><default><default><default>
+
+[spi2_para]
+spi_used = 0
+spi_cs0 = port:PE00<4><default><default><default>
+spi_sclk = port:PE01<4><default><default><default>
+spi_mosi = port:PB02<4><default><default><default>
+spi_miso = port:PB03<4><default><default><default>
+
+[rtp_para]
+rtp_used = 0
+rtp_screen_size = 7
+rtp_regidity_level = 7
+rtp_press_threshold_enable = 0
+rtp_press_threshold = 0x1f40
+rtp_sensitive_level = 0xf
+rtp_exchange_x_y_flag = 0
+
+[ctp_para]
+ctp_used = 1
+ctp_name = "ekt3632"
+ctp_twi_id = 1
+ctp_twi_addr = 0x15
+ctp_screen_max_x = 800
+ctp_screen_max_y = 480
+ctp_revert_x_flag = 0
+ctp_revert_y_flag = 0
+ctp_exchange_x_y_flag = 0
+ctp_int_port = port:PG11<6><default><default><default>
+ctp_wakeup = port:PB03<1><default><default><1>
+ctp_reset = port:PB03<1><default><default><1>
+
+[tkey_para]
+tkey_used = 0
+tkey_name = "hv_keypad"
+tkey_twi_id = 2
+tkey_twi_addr = 0x62
+tkey_int =
+
+[motor_para]
+motor_used = 1
+motor_shake = port:PG09<1><default><default><0>
+
+[disp_init]
+disp_init_enable = 1
+disp_mode = 0
+screen0_output_type = 1
+screen0_output_mode = 4
+screen1_output_type = 1
+screen1_output_mode = 4
+fb0_framebuffer_num = 2
+fb0_format = 10
+fb0_pixel_sequence = 0
+fb0_scaler_mode_enable = 0
+fb1_framebuffer_num = 2
+fb1_format = 10
+fb1_pixel_sequence = 0
+fb1_scaler_mode_enable = 0
+
+[lcd0_para]
+lcd_used = 1
+lcd_x = 800
+lcd_y = 480
+lcd_dclk_freq = 33
+lcd_pwm_not_used = 0
+lcd_pwm_ch = 0
+lcd_pwm_freq = 18000
+lcd_pwm_pol = 1
+lcd_if = 0
+lcd_hbp = 88
+lcd_ht = 928
+lcd_vbp = 32
+lcd_vt = 1050
+lcd_hv_if = 0
+lcd_hv_smode = 0
+lcd_hv_s888_if = 0
+lcd_hv_syuv_if = 0
+lcd_hv_vspw = 0
+lcd_hv_hspw = 0
+lcd_lvds_ch = 0
+lcd_lvds_mode = 0
+lcd_lvds_bitwidth = 0
+lcd_lvds_io_cross = 0
+lcd_cpu_if = 0
+lcd_frm = 1
+lcd_io_cfg0 = 268435456
+lcd_gamma_correction_en = 0
+lcd_gamma_tbl_0 = 0x0
+lcd_gamma_tbl_1 = 0x10101
+lcd_gamma_tbl_255 = 0xffffff
+lcd_bl_en_used = 1
+lcd_bl_en = port:power1<1><0><default><1>
+lcd_power_used = 1
+lcd_power = port:power0<1><0><default><1>
+lcd_pwm_used = 1
+lcd_pwm = port:PB02<2><0><default><default>
+lcd_gpio_0 =
+lcd_gpio_1 =
+lcd_gpio_2 =
+lcd_gpio_3 =
+lcdd0 = port:PD00<2><0><default><default>
+lcdd1 = port:PD01<2><0><default><default>
+lcdd2 = port:PD02<2><0><default><default>
+lcdd3 = port:PD03<2><0><default><default>
+lcdd4 = port:PD04<2><0><default><default>
+lcdd5 = port:PD05<2><0><default><default>
+lcdd6 = port:PD06<2><0><default><default>
+lcdd7 = port:PD07<2><0><default><default>
+lcdd8 = port:PD08<2><0><default><default>
+lcdd9 = port:PD09<2><0><default><default>
+lcdd10 = port:PD10<2><0><default><default>
+lcdd11 = port:PD11<2><0><default><default>
+lcdd12 = port:PD12<2><0><default><default>
+lcdd13 = port:PD13<2><0><default><default>
+lcdd14 = port:PD14<2><0><default><default>
+lcdd15 = port:PD15<2><0><default><default>
+lcdd16 = port:PD16<2><0><default><default>
+lcdd17 = port:PD17<2><0><default><default>
+lcdd18 = port:PD18<2><0><default><default>
+lcdd19 = port:PD19<2><0><default><default>
+lcdd20 = port:PD20<2><0><default><default>
+lcdd21 = port:PD21<2><0><default><default>
+lcdd22 = port:PD22<2><0><default><default>
+lcdd23 = port:PD23<2><0><default><default>
+lcdclk = port:PD24<2><0><default><default>
+lcdde = port:PD25<2><0><default><default>
+lcdhsync = port:PD26<2><0><default><default>
+lcdvsync = port:PD27<2><0><default><default>
+lcdgamma4iep = 22
+
+[tv_out_dac_para]
+dac_used = 1
+dac0_src = 0
+
+[hdmi_para]
+hdmi_used = 0
+
+[csi0_para]
+csi_used = 1
+csi_mode = 0
+csi_dev_qty = 1
+csi_stby_mode = 1
+csi_mname = "gc0308"
+csi_twi_addr = 0x42
+csi_twi_id = 2
+csi_if = 0
+csi_vflip = 0
+csi_hflip = 0
+csi_iovdd = ""
+csi_avdd = ""
+csi_dvdd = ""
+csi_flash_pol = 1
+csi_mname_b = ""
+csi_twi_id_b = 2
+csi_twi_addr_b = 0x40
+csi_if_b = 0
+csi_vflip_b = 0
+csi_hflip_b = 0
+csi_iovdd_b = ""
+csi_avdd_b = ""
+csi_dvdd_b = ""
+csi_flash_pol_b = 1
+csi_pck = port:PE00<3><default><default><default>
+csi_ck = port:PE01<3><default><default><default>
+csi_hsync = port:PE02<3><default><default><default>
+csi_vsync = port:PE03<3><default><default><default>
+csi_d0 = port:PE04<3><default><default><default>
+csi_d1 = port:PE05<3><default><default><default>
+csi_d2 = port:PE06<3><default><default><default>
+csi_d3 = port:PE07<3><default><default><default>
+csi_d4 = port:PE08<3><default><default><default>
+csi_d5 = port:PE09<3><default><default><default>
+csi_d6 = port:PE10<3><default><default><default>
+csi_d7 = port:PE11<3><default><default><default>
+csi_reset = port:power3<1><default><default><0>
+csi_power_en =
+csi_stby = port:PB10<1><default><default><1>
+csi_flash =
+csi_af_en =
+csi_reset_b = port:power3<1><default><default><0>
+csi_power_en_b =
+csi_stby_b = port:PB04<1><default><default><1>
+csi_flash_b =
+csi_af_en_b =
+
+[csi1_para]
+csi_used = 0
+csi_mode = 0
+csi_dev_qty = 1
+csi_stby_mode = 1
+csi_mname = ""
+csi_twi_id = 1
+csi_twi_addr = 0xba
+csi_if = 0
+csi_vflip = 0
+csi_hflip = 0
+csi_iovdd = ""
+csi_avdd = ""
+csi_dvdd = ""
+csi_flash_pol = 1
+csi_mname_b = ""
+csi_twi_id_b = 1
+csi_twi_addr_b = 0x78
+csi_if_b = 0
+csi_vflip_b = 1
+csi_hflip_b = 0
+csi_iovdd_b = ""
+csi_avdd_b = ""
+csi_dvdd_b = ""
+csi_flash_pol_b = 1
+csi_reset =
+csi_power_en =
+csi_stby =
+csi_flash =
+csi_af_en =
+csi_reset_b =
+csi_power_en_b =
+csi_stby_b =
+csi_flash_b =
+csi_af_en_b =
+
+[mmc0_para]
+sdc_used = 1
+sdc_detmode = 1
+bus_width = 4
+sdc_d1 = port:PF00<2><1><2><default>
+sdc_d0 = port:PF01<2><1><2><default>
+sdc_clk = port:PF02<2><1><2><default>
+sdc_cmd = port:PF03<2><1><2><default>
+sdc_d3 = port:PF04<2><1><2><default>
+sdc_d2 = port:PF05<2><1><2><default>
+sdc_det = port:PG00<0><1><default><default>
+sdc_use_wp = 0
+sdc_wp =
+
+[mmc1_para]
+sdc_used = 0
+sdc_detmode =
+bus_width =
+sdc_cmd =
+sdc_clk =
+sdc_d0 =
+sdc_d1 =
+sdc_d2 =
+sdc_d3 =
+sdc_det =
+sdc_use_wp =
+sdc_wp =
+
+[mmc2_para]
+sdc_used = 0
+sdc_detmode = 3
+bus_width = 4
+sdc_cmd = port:PE08<4><1><2><default>
+sdc_clk = port:PE09<4><1><2><default>
+sdc_d0 = port:PE04<4><1><2><default>
+sdc_d1 = port:PE05<4><1><2><default>
+sdc_d2 = port:PE06<4><1><2><default>
+sdc_d3 = port:PE07<4><1><2><default>
+sdc_det =
+sdc_use_wp = 0
+sdc_wp =
+
+[ms_para]
+ms_used = 0
+ms_bs =
+ms_clk =
+ms_d0 =
+ms_d1 =
+ms_d2 =
+ms_d3 =
+ms_det =
+
+[keypad_para]
+kp_used = 0
+kp_in_size =
+kp_out_size =
+kp_in0 =
+kp_in1 =
+kp_in2 =
+kp_in3 =
+kp_in4 =
+kp_in5 =
+kp_in6 =
+kp_in7 =
+kp_out0 =
+kp_out1 =
+kp_out2 =
+kp_out3 =
+kp_out4 =
+kp_out5 =
+kp_out6 =
+kp_out7 =
+
+[usbc0]
+usb_used = 1
+usb_port_type = 2
+usb_detect_type = 1
+usb_id_gpio = port:PG02<0><1><default><default>
+usb_det_vbus_gpio = port:PG01<0><0><default><default>
+usb_drv_vbus_gpio = port:PG12<1><0><default><0>
+usb_host_init_state = 0
+
+[usbc1]
+usb_used = 1
+usb_port_type = 1
+usb_detect_type = 0
+usb_controller_type = 0
+usb_id_gpio =
+usb_det_vbus_gpio =
+usb_drv_vbus_gpio = port:PG11<1><0><default><0>
+usb_host_init_state = 1
+
+[usb_feature]
+vendor_id = 6353
+mass_storage_id = 1
+adb_id = 2
+manufacturer_name = "USB Developer"
+product_name = "Android"
+serial_number = "20080411"
+
+[msc_feature]
+vendor_name = "USB 2.0"
+product_name = "USB Flash Driver"
+release = 100
+luns = 2
+
+[gsensor_para]
+gsensor_used = 1
+gsensor_name = "mma7660"
+gsensor_twi_id = 1
+gsensor_twi_addr = 0x4c
+gsensor_int1 =
+gsensor_int2 =
+
+[gps_para]
+gps_used = 0
+gps_spi_id =
+gps_spi_cs_num =
+gps_lradc =
+gps_clk =
+gps_sign =
+gps_mag =
+gps_vcc_en =
+gps_osc_en =
+gps_rx_en =
+
+[sdio_wifi_para]
+sdio_wifi_used = 0
+sdio_wifi_sdc_id =
+sdio_wifi_mod_sel =
+
+[usb_wifi_para]
+usb_wifi_used = 1
+usb_wifi_usbc_num = 1
+
+[3g_para]
+3g_used = 0
+3g_name =
+3g_usbc_num =
+3g_on_off =
+3g_reset =
+3g_poweron =
+3g_wakeup_out =
+3g_wakeup_in =
+
+[gy_para]
+gy_used = 0
+gy_twi_id = 1
+gy_twi_addr = 0
+gy_int1 =
+gy_int2 =
+
+[ls_para]
+ls_used = 1
+ls_name = "ltr501als"
+ls_twi_id = 1
+ls_twi_addr =
+ls_int =
+
+[compass_para]
+compass_used = 0
+compass_twi_id =
+compass_twi_addr =
+compass_int =
+
+[bt_para]
+bt_used = 0
+bt_uart_id =
+bt_mod_type =
+
+[i2s_para]
+i2s_used = 0
+i2s_channel =
+i2s_mclk =
+i2s_bclk =
+i2s_lrclk =
+i2s_dout0 =
+i2s_dout1 =
+i2s_dout2 =
+i2s_dout3 =
+i2s_din =
+
+[spdif_para]
+spdif_used = 0
+spdif_mclk =
+spdif_dout =
+spdif_din =
+
+[audio_para]
+audio_used = 1
+capture_used = 1
+audio_lr_change = 0
+audio_pa_ctrl = port:PG10<1><default><default><0>
+
+[ir_para]
+ir_used = 0
+ir0_rx = port:PB04<2><default><default><default>
+
+[rtc_para]
+rtc_used = 1
+rtc_name = "pcf8563"
+rtc_twi_id = 1
+rtc_twi_addr = 81
+
+[pmu_para]
+pmu_used = 1
+pmu_twi_addr = 52
+pmu_twi_id = 0
+pmu_irq_id = 0
+pmu_battery_rdc = 100
+pmu_battery_cap = 2600
+pmu_init_chgcur = 300
+pmu_earlysuspend_chgcur = 600
+pmu_suspend_chgcur = 1000
+pmu_resume_chgcur = 300
+pmu_shutdown_chgcur = 1000
+pmu_init_chgvol = 4200
+pmu_init_chgend_rate = 15
+pmu_init_chg_enabled = 1
+pmu_init_adc_freq = 100
+pmu_init_adc_freqc = 100
+pmu_init_chg_pretime = 50
+pmu_init_chg_csttime = 720
+pmu_bat_para1 = 0
+pmu_bat_para2 = 0
+pmu_bat_para3 = 0
+pmu_bat_para4 = 0
+pmu_bat_para5 = 5
+pmu_bat_para6 = 13
+pmu_bat_para7 = 16
+pmu_bat_para8 = 26
+pmu_bat_para9 = 36
+pmu_bat_para10 = 46
+pmu_bat_para11 = 53
+pmu_bat_para12 = 61
+pmu_bat_para13 = 73
+pmu_bat_para14 = 84
+pmu_bat_para15 = 92
+pmu_bat_para16 = 100
+pmu_usbvol_limit = 1
+pmu_usbcur_limit = 0
+pmu_usbvol = 4000
+pmu_usbcur = 0
+pmu_usbvol_pc = 4000
+pmu_usbcur_pc = 0
+pmu_pwroff_vol = 3300
+pmu_pwron_vol = 2900
+pmu_pekoff_time = 6000
+pmu_pekoff_en = 1
+pmu_peklong_time = 1500
+pmu_pekon_time = 1000
+pmu_pwrok_time = 64
+pmu_pwrnoe_time = 2000
+pmu_intotp_en = 1
+pmu_used2 = 0
+pmu_adpdet =
+pmu_init_chgcur2 = 400
+pmu_earlysuspend_chgcur2 = 600
+pmu_suspend_chgcur2 = 1200
+pmu_resume_chgcur2 = 400
+pmu_shutdown_chgcur2 = 1200
+pmu_suspendpwroff_vol = 3500
+pmu_batdeten = 1
+
+[recovery_key]
+key_min = 4
+key_max = 6
+
+[dvfs_table]
+max_freq = 1008000000
+min_freq = 60000000
+LV_count = 7
+LV1_freq = 1104000000
+LV1_volt = 1500
+LV2_freq = 1008000000
+LV2_volt = 1400
+LV3_freq = 912000000
+LV3_volt = 1350
+LV4_freq = 864000000
+LV4_volt = 1300
+LV5_freq = 624000000
+LV5_volt = 1200
+LV6_freq = 576000000
+LV6_volt = 1200
+LV7_freq = 432000000
+LV7_volt = 1200
+
diff --git a/sunxi-devices/tzx-q8-713b/sunxi.prop b/sunxi-devices/tzx-q8-713b/sunxi.prop
new file mode 100644 (file)
index 0000000..e0d3db8
--- /dev/null
@@ -0,0 +1 @@
+sunxi.platform = sun5i
diff --git a/sunxi/Android.mk b/sunxi/Android.mk
new file mode 100644 (file)
index 0000000..d0ff954
--- /dev/null
@@ -0,0 +1,22 @@
+# Copyright (C) 2014 Paul Kocialkowski <contact@paulk.fr>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+LOCAL_PATH := $(call my-dir)
+
+ifeq ($(TARGET_DEVICE),sunxi)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
+
+endif
diff --git a/sunxi/AndroidProducts.mk b/sunxi/AndroidProducts.mk
new file mode 100644 (file)
index 0000000..35fa3f1
--- /dev/null
@@ -0,0 +1,17 @@
+# Copyright (C) 2014 Paul Kocialkowski <contact@paulk.fr>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+PRODUCT_MAKEFILES := \
+       $(LOCAL_DIR)/full_sunxi.mk
diff --git a/sunxi/BoardConfig.mk b/sunxi/BoardConfig.mk
new file mode 100644 (file)
index 0000000..4c42221
--- /dev/null
@@ -0,0 +1,24 @@
+# Copyright (C) 2014 Paul Kocialkowski <contact@paulk.fr>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+include device/allwinner/sunxi-common/BoardConfigCommon.mk
+
+# Sunxi
+SUNXI_DEVICES := ainol_aw1 tzx-q8-713b
+SUNXI_KERNELS := sun5i sun7i
+
+# Graphics
+USE_OPENGL_RENDERER := false
+TARGET_DISABLE_TRIPLE_BUFFERING := true
diff --git a/sunxi/CleanSpec.mk b/sunxi/CleanSpec.mk
new file mode 100644 (file)
index 0000000..0c74390
--- /dev/null
@@ -0,0 +1,16 @@
+# Copyright (C) 2014 Paul Kocialkowski <contact@paulk.fr>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+$(call add-clean-step, rm -rf $(TARGET_OUT)/build.prop)
diff --git a/sunxi/cm.mk b/sunxi/cm.mk
new file mode 100644 (file)
index 0000000..1e855de
--- /dev/null
@@ -0,0 +1,28 @@
+# Copyright (C) 2014 Paul Kocialkowski <contact@paulk.fr>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Inherit GSM config
+$(call inherit-product, vendor/replicant/config/gsm.mk)
+
+PRODUCT_RELEASE_NAME := sunxi
+
+# Inherit common phone config
+$(call inherit-product, vendor/replicant/config/common_full_phone.mk)
+
+# Inherit device config
+$(call inherit-product, device/allwinner/sunxi/full_sunxi.mk)
+
+PRODUCT_NAME := replicant_sunxi
+PRODUCT_DEVICE := sunxi
diff --git a/sunxi/full_sunxi.mk b/sunxi/full_sunxi.mk
new file mode 100644 (file)
index 0000000..f9d15f4
--- /dev/null
@@ -0,0 +1,23 @@
+# Copyright (C) 2014 Paul Kocialkowski <contact@paulk.fr>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+$(call inherit-product, $(SRC_TARGET_DIR)/product/full_base_telephony.mk)
+$(call inherit-product, device/allwinner/sunxi/sunxi.mk)
+
+PRODUCT_NAME := full_sunxi
+PRODUCT_DEVICE := sunxi
+PRODUCT_BRAND := Allwinner
+PRODUCT_MODEL := Sunxi
+PRODUCT_MANUFACTURER := Allwinner
diff --git a/sunxi/recovery/init.recovery.sunxi.rc b/sunxi/recovery/init.recovery.sunxi.rc
new file mode 100644 (file)
index 0000000..90cc841
--- /dev/null
@@ -0,0 +1 @@
+import /init.recovery.sunxi-common.rc
diff --git a/sunxi/sunxi.mk b/sunxi/sunxi.mk
new file mode 100644 (file)
index 0000000..a7c7d39
--- /dev/null
@@ -0,0 +1,22 @@
+# Copyright (C) 2014 Paul Kocialkowski <contact@paulk.fr>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+$(call inherit-product, device/allwinner/sunxi-common/sunxi-common.mk)
+
+# Recovery
+PRODUCT_COPY_FILES += \
+       device/allwinner/sunxi/recovery/init.recovery.sunxi.rc:root/init.recovery.sun4i.rc \
+       device/allwinner/sunxi/recovery/init.recovery.sunxi.rc:root/init.recovery.sun5i.rc \
+       device/allwinner/sunxi/recovery/init.recovery.sunxi.rc:root/init.recovery.sun7i.rc