Browse Source

Upstream refresh for v1.5.0-rc1 : Upstream 19.07 : 4fb6b8c553f692eeb5bcb203e0f8ee8df099e77e

RISCi_ATOM 4 years ago
parent
commit
e68c492f9e
100 changed files with 1607 additions and 5257 deletions
  1. 0 2
      Config.in
  2. 0 2
      Makefile
  3. 0 15
      README.md
  4. 13 0
      config/Config-build.in
  5. 4 3
      config/Config-images.in
  6. 4 0
      config/Config-kernel.in
  7. 3 2
      include/download.mk
  8. 1 1
      include/feeds.mk
  9. 3 1
      include/image-commands.mk
  10. 10 6
      include/image.mk
  11. 9 8
      include/kernel-version.mk
  12. 5 2
      include/kernel.mk
  13. 2 1
      include/package-ipkg.mk
  14. 7 1
      include/rootfs.mk
  15. 7 23
      include/target.mk
  16. 2 7
      include/unpack.mk
  17. 4 4
      include/version.mk
  18. 6 2
      package/Makefile
  19. 11 2
      package/base-files/Makefile
  20. 4 1
      package/base-files/files/bin/config_generate
  21. 1 1
      package/base-files/files/etc/group
  22. 12 0
      package/base-files/files/etc/rc.button/reboot
  23. 3 0
      package/base-files/files/etc/rc.common
  24. 39 0
      package/base-files/files/lib/functions/migrations.sh
  25. 1 1
      package/base-files/files/lib/functions/system.sh
  26. 14 0
      package/base-files/files/lib/functions/uci-defaults.sh
  27. 19 13
      package/base-files/files/lib/upgrade/common.sh
  28. 8 8
      package/base-files/files/usr/lib/os-release
  29. 1 1
      package/base-files/image-config.in
  30. 6 1
      package/boot/uboot-envtools/files/ath79
  31. 4 0
      package/boot/uboot-envtools/files/imx6
  32. 3 0
      package/boot/uboot-envtools/files/ipq40xx
  33. 16 13
      package/boot/uboot-envtools/files/mvebu
  34. 3 1
      package/boot/uboot-envtools/files/oxnas
  35. 4 2
      package/boot/uboot-envtools/files/ramips
  36. 9 2
      package/boot/uboot-sunxi/Makefile
  37. 2 2
      package/boot/uboot-sunxi/patches/003-add-theobroma-a31-pangolin.patch
  38. 2 2
      package/boot/uboot-sunxi/patches/062-A20-improve-gmac-upload.patch
  39. 44 0
      package/boot/uboot-sunxi/patches/063-fix-lime2-revK-add-micrel-PHY.patch
  40. 1 1
      package/boot/uboot-sunxi/patches/102-sunxi-make_CONS_INDEX-configurable.patch
  41. 2 2
      package/boot/uboot-sunxi/patches/210-sunxi-deactivate-binman.patch
  42. 0 88
      package/boot/uboot-xburst/Makefile
  43. 0 894
      package/boot/uboot-xburst/patches/0001-qi_lb60-add-nand-spl-support.patch
  44. 0 916
      package/boot/uboot-xburst/patches/0002-qi_lb60-add-software-usbboot-support.patch
  45. 0 1664
      package/boot/uboot-xburst/patches/0003-add-mmc-support.patch
  46. 0 200
      package/boot/uboot-xburst/patches/0004-add-more-boot-options-F1-F2-F3-F4-M-S.patch
  47. 0 847
      package/boot/uboot-xburst/patches/0005-add-nanonote-lcd-support.patch
  48. 0 60
      package/boot/uboot-xburst/patches/0006-enable-silent-console.patch
  49. 1 1
      package/devel/perf/Makefile
  50. 2 2
      package/devel/strace/Makefile
  51. 0 91
      package/devel/strace/patches/001-mips-o32-fix-build.patch
  52. 5 5
      package/devel/strace/patches/100-workaround--pt-reg-collisions-ppc.patch
  53. 185 0
      package/devel/valgrind/Makefile
  54. 42 0
      package/devel/valgrind/files/default.supp
  55. 11 0
      package/devel/valgrind/patches/100-fix_configure_check.patch
  56. 17 0
      package/devel/valgrind/patches/130-fix_arm_arch_detection.patch
  57. 1 0
      package/kernel/button-hotplug/src/button-hotplug.c
  58. 59 0
      package/kernel/cryptodev-linux/Makefile
  59. 161 91
      package/kernel/gpio-button-hotplug/src/gpio-button-hotplug.c
  60. 4 4
      package/kernel/kmod-sched-cake/Makefile
  61. 3 3
      package/kernel/linux/modules/block.mk
  62. 14 2
      package/kernel/linux/modules/can.mk
  63. 30 6
      package/kernel/linux/modules/crypto.mk
  64. 1 1
      package/kernel/linux/modules/fs.mk
  65. 1 1
      package/kernel/linux/modules/hwmon.mk
  66. 3 3
      package/kernel/linux/modules/iio.mk
  67. 2 2
      package/kernel/linux/modules/lib.mk
  68. 5 19
      package/kernel/linux/modules/netdevices.mk
  69. 2 2
      package/kernel/linux/modules/netfilter.mk
  70. 76 7
      package/kernel/linux/modules/netsupport.mk
  71. 22 19
      package/kernel/linux/modules/other.mk
  72. 1 0
      package/kernel/linux/modules/sound.mk
  73. 12 4
      package/kernel/linux/modules/usb.mk
  74. 40 7
      package/kernel/linux/modules/video.mk
  75. 1 1
      package/kernel/linux/modules/w1.mk
  76. 14 4
      package/kernel/linux/modules/wpan.mk
  77. 72 6
      package/kernel/mac80211/Makefile
  78. 5 37
      package/kernel/mac80211/ath.mk
  79. 20 4
      package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
  80. 1 1
      package/kernel/mac80211/patches/ath/350-ath9k_hw-reset-AHB-WMAC-interface-on-AR91xx.patch
  81. 2 2
      package/kernel/mac80211/patches/ath/351-ath9k_hw-issue-external-reset-for-QCA955x.patch
  82. 2 2
      package/kernel/mac80211/patches/ath/356-Revert-ath9k-interpret-requested-txpower-in-EIRP-dom.patch
  83. 4 4
      package/kernel/mac80211/patches/ath/365-ath9k-adjust-tx-power-reduction-for-US-regulatory-do.patch
  84. 2 2
      package/kernel/mac80211/patches/ath/404-regd_no_assoc_hints.patch
  85. 1 1
      package/kernel/mac80211/patches/ath/510-ath9k_intr_mitigation_tweak.patch
  86. 1 1
      package/kernel/mac80211/patches/ath/513-ath9k_add_pci_ids.patch
  87. 2 2
      package/kernel/mac80211/patches/ath/542-ath9k_debugfs_diag.patch
  88. 4 4
      package/kernel/mac80211/patches/ath/544-ath9k-ar933x-usb-hang-workaround.patch
  89. 94 0
      package/kernel/mac80211/patches/ath/558-ath9k-dynack-introduce-ath_dynack_set_timeout-routin.patch
  90. 0 73
      package/kernel/mac80211/patches/ath/558-ath9k-only-mask-use_eeprom-on-of-noeeprom.patch
  91. 32 0
      package/kernel/mac80211/patches/ath/559-ath9k-dynack-properly-set-last-timeout-timestamp-in-.patch
  92. 96 0
      package/kernel/mac80211/patches/ath/560-ath9k-dynack-set-max-timeout-according-to-channel-wi.patch
  93. 78 0
      package/kernel/mac80211/patches/ath/561-ath9k-dynack-set-ackto-to-max-timeout-in-ath_dynack_.patch
  94. 7 5
      package/kernel/mac80211/patches/build/001-fix_build.patch
  95. 2 2
      package/kernel/mac80211/patches/rt2x00/004-rt2x00-do-not-check-for-txstatus-timeout-every-time-.patch
  96. 1 1
      package/kernel/mac80211/patches/rt2x00/005-rt2x00-use-different-txstatus-timeouts-when-flushing.patch
  97. 39 0
      package/kernel/mac80211/patches/rt2x00/020-cfg80211-add-ratelimited-variants-of-err-and-warn.patch
  98. 0 33
      package/kernel/mac80211/patches/rt2x00/020-rt2x00-do-not-print-error-when-queue-is-full.patch
  99. 42 0
      package/kernel/mac80211/patches/rt2x00/021-rt2x00-use-ratelimited-variants-dev_warn-dev_err.patch
  100. 96 0
      package/kernel/mac80211/patches/rt2x00/022-rt2x00-check-number-of-EPROTO-errors.patch

+ 0 - 2
Config.in

@@ -31,6 +31,4 @@ source "target/sdk/Config.in"
 
 source "target/toolchain/Config.in"
 
-source "target/ccsdisk/Config.in"
-
 source "tmp/.config-package.in"

+ 0 - 2
Makefile

@@ -89,8 +89,6 @@ prereq: $(target/stamp-prereq) tmp/.prereq_packages
 checksum: FORCE
 	$(call sha256sums,$(BIN_DIR),$(CONFIG_BUILDBOT))
 
-ccsdisk: $(target/ccsdisk/install)
-
 diffconfig: FORCE
 	mkdir -p $(BIN_DIR)
 	$(SCRIPT_DIR)/diffconfig.sh > $(BIN_DIR)/config.seed

+ 0 - 15
README.md

@@ -1,15 +0,0 @@
-# libreCMC : The _libre_ Embedded GNU/Linux Distro.
-
-libreCMC is a set of fully [free](http://www.gnu.org/philosophy/free-sw.en.html) embedded Operating Systems for general purpose computers. It aims to give its users freedom and control over the software that runs on their hardware. Most of the hardware that libreCMC supports includes a wide range of routers and some small single board computers.
-
-## Useful links:
-
-* [Get libreCMC source code](/) : Checkout the latest libreCMC sources.
-
-* [Supported Hardware](/docs/Supported_Hardware.md): Devices officially supported by libreCMC.
-
-* [Router reset instructions](/docs/Router_Reset_Instructions.md) : Generic libreCMC router reset instructions.
-
-* [Report a bug or issue](https://gogs.librecmc.org/libreCMC/libreCMC/issues) : Is something broken? Did you find a non-free component or do you want to make libreCMC better? Submit an issue.
-
-* [Build Documentation](/docs/How_To_Build_libreCMC.md) : Learn how to build libreCMC for your device. 

+ 13 - 0
config/Config-build.in

@@ -34,8 +34,21 @@ menu "Global build settings"
 		bool "Cryptographically signed package lists"
 		default y
 
+	config SIGNATURE_CHECK
+		bool "Enable signature checking in opkg"
+		default SIGNED_PACKAGES
+
 	comment "General build options"
 
+	config TESTING_KERNEL
+		bool "Use the testing kernel version"
+		depends on HAS_TESTING_KERNEL
+		default n
+		help
+		  If the target supports a newer kernel version than the default,
+		  you can use this config option to enable it
+
+
 	config DISPLAY_SUPPORT
 		bool "Show packages that require graphics support (local or remote)"
 		default n

+ 4 - 3
config/Config-images.in

@@ -14,10 +14,11 @@ menu "Target Images"
 
 		choice
 			prompt "Compression"
-			default TARGET_INITRAMFS_COMPRESSION_LZMA if TARGET_ar71xx
-			default TARGET_INITRAMFS_COMPRESSION_LZMA if TARGET_ramips
 			default TARGET_INITRAMFS_COMPRESSION_LZMA if TARGET_apm821xx
+			default TARGET_INITRAMFS_COMPRESSION_LZMA if TARGET_ar71xx
+			default TARGET_INITRAMFS_COMPRESSION_LZMA if TARGET_lantiq
 			default TARGET_INITRAMFS_COMPRESSION_LZMA if TARGET_mpc85xx
+			default TARGET_INITRAMFS_COMPRESSION_LZMA if TARGET_ramips
 			default TARGET_INITRAMFS_COMPRESSION_NONE
 			depends on TARGET_ROOTFS_INITRAMFS
 			help
@@ -272,7 +273,7 @@ menu "Target Images"
 
 	config TARGET_ROOTFS_PARTSIZE
 		int "Root filesystem partition size (in MB)"
-		depends on GRUB_IMAGES || USES_ROOTFS_PART || TARGET_ROOTFS_EXT4FS || TARGET_mvebu || TARGET_omap || TARGET_rb532 || TARGET_sunxi || TARGET_uml
+		depends on GRUB_IMAGES || USES_ROOTFS_PART || TARGET_ROOTFS_EXT4FS || TARGET_omap || TARGET_rb532 || TARGET_sunxi || TARGET_uml
 		default 256
 		help
 		  Select the root filesystem partition size.

+ 4 - 0
config/Config-kernel.in

@@ -192,6 +192,10 @@ config KERNEL_KPROBE_EVENT
 	bool
 	default y if KERNEL_KPROBES
 
+config KERNEL_KPROBE_EVENTS
+	bool
+	default y if KERNEL_KPROBES
+
 config KERNEL_AIO
 	bool "Compile the kernel with asynchronous IO support"
 	default n

+ 3 - 2
include/download.mk

@@ -28,7 +28,7 @@ define dl_method
 $(strip \
   $(if $(filter git,$(2)),$(call dl_method_git,$(1),$(2)),
     $(if $(2),$(2), \
-      $(if $(filter @APACHE/% @GNOME/% @GNU/% @KERNEL_LIBRE/% @KERNEL/% @SF/% @SAVANNAH/% ftp://% http://% https://% file://%,$(1)),default, \
+      $(if $(filter @APACHE/% @GITHUB/% @GNOME/% @GNU/% @KERNEL_LIBRE/% @KERNEL/% @SF/% @SAVANNAH/% ftp://% http://% https://% file://%,$(1)),default, \
         $(if $(filter git://%,$(1)),$(call dl_method_git,$(1),$(2)), \
           $(if $(filter svn://%,$(1)),svn, \
             $(if $(filter cvs://%,$(1)),cvs, \
@@ -55,7 +55,8 @@ define dl_pack
 	$(if $(dl_pack/$(call ext,$(1))),$(dl_pack/$(call ext,$(1))),$(dl_pack/unknown))
 endef
 define dl_tar_pack
-	$(TAR) --numeric-owner --owner=0 --group=0 --sort=name $$$${TAR_TIMESTAMP:+--mtime="$$$$TAR_TIMESTAMP"} -c $(2) | $(call dl_pack,$(1))
+	$(TAR) --numeric-owner --owner=0 --group=0 --mode=a-s --sort=name \
+		$$$${TAR_TIMESTAMP:+--mtime="$$$$TAR_TIMESTAMP"} -c $(2) | $(call dl_pack,$(1))
 endef
 
 ifdef CHECK

+ 1 - 1
include/feeds.mk

@@ -9,7 +9,7 @@
 -include $(TMP_DIR)/.packageauxvars
 
 FEEDS_INSTALLED:=$(notdir $(wildcard $(TOPDIR)/package/feeds/*))
-FEEDS_AVAILABLE:=$(sort $(FEEDS_INSTALLED) $(shell $(SCRIPT_DIR)/feeds list -n))
+FEEDS_AVAILABLE:=$(sort $(FEEDS_INSTALLED) $(shell $(SCRIPT_DIR)/feeds list -n 2>/dev/null))
 
 PACKAGE_SUBDIRS=$(PACKAGE_DIR)
 ifneq ($(CONFIG_PER_FEED_REPO),)

+ 3 - 1
include/image-commands.mk

@@ -355,12 +355,14 @@ json_quote=$(subst ','\'',$(subst ",\",$(1)))
 metadata_devices=$(if $(1),$(subst "$(space)","$(comma)",$(strip $(foreach v,$(1),"$(call json_quote,$(v))"))))
 metadata_json = \
 	'{ $(if $(IMAGE_METADATA),$(IMAGE_METADATA)$(comma)) \
+		"metadata_version": "1.0", \
 		"supported_devices":[$(call metadata_devices,$(1))], \
 		"version": { \
 			"dist": "$(call json_quote,$(VERSION_DIST))", \
 			"version": "$(call json_quote,$(VERSION_NUMBER))", \
 			"revision": "$(call json_quote,$(REVISION))", \
-			"board": "$(call json_quote,$(BOARD))" \
+			"target": "$(call json_quote,$(TARGETID))", \
+			"board": "$(call json_quote,$(if $(BOARD_NAME),$(BOARD_NAME),$(DEVICE_NAME)))" \
 		} \
 	}'
 

+ 10 - 6
include/image.mk

@@ -154,10 +154,10 @@ endif
 
 
 # Disable noisy checks by default as in upstream
-ifeq ($(strip $(call kernel_patchver_ge,4.6.0)),1)
+ifeq ($(strip $(call kernel_patchver_ge,4.7.0)),1)
   DTC_FLAGS += -Wno-unit_address_vs_reg
 endif
-ifeq ($(strip $(call kernel_patchver_ge,4.11.0)),1)
+ifeq ($(strip $(call kernel_patchver_ge,4.12.0)),1)
   DTC_FLAGS += \
 	-Wno-unit_address_vs_reg \
 	-Wno-simple_bus_reg \
@@ -166,12 +166,12 @@ ifeq ($(strip $(call kernel_patchver_ge,4.11.0)),1)
 	-Wno-pci_device_bus_num \
 	-Wno-pci_device_reg
 endif
-ifeq ($(strip $(call kernel_patchver_ge,4.16.0)),1)
+ifeq ($(strip $(call kernel_patchver_ge,4.17.0)),1)
   DTC_FLAGS += \
 	-Wno-avoid_unnecessary_addr_size \
 	-Wno-alias_paths
 endif
-ifeq ($(strip $(call kernel_patchver_ge,4.17.0)),1)
+ifeq ($(strip $(call kernel_patchver_ge,4.18.0)),1)
   DTC_FLAGS += \
 	-Wno-graph_child_address \
 	-Wno-graph_port \
@@ -291,7 +291,7 @@ endef
 
 ifdef CONFIG_TARGET_ROOTFS_TARGZ
   define Image/Build/targz
-	$(TAR) -cp --numeric-owner --owner=0 --group=0 --sort=name \
+	$(TAR) -cp --numeric-owner --owner=0 --group=0 --mode=a-s --sort=name \
 		$(if $(SOURCE_DATE_EPOCH),--mtime="@$(SOURCE_DATE_EPOCH)") \
 		-C $(TARGET_DIR)/ . | gzip -9n > $(BIN_DIR)/$(IMG_PREFIX)$(if $(PROFILE_SANITIZED),-$(PROFILE_SANITIZED))-rootfs.tar.gz
   endef
@@ -383,6 +383,8 @@ define Device/Init
   IMAGE_METADATA :=
 
   FILESYSTEMS := $(TARGET_FILESYSTEMS)
+
+  UBOOT_PATH :=  $(STAGING_DIR_IMAGE)/uboot-$(1)
 endef
 
 DEFAULT_DEVICE_VARS := \
@@ -390,7 +392,7 @@ DEFAULT_DEVICE_VARS := \
   CMDLINE UBOOTENV_IN_UBI KERNEL_IN_UBI BLOCKSIZE PAGESIZE SUBPAGESIZE \
   VID_HDR_OFFSET UBINIZE_OPTS UBINIZE_PARTS MKUBIFS_OPTS DEVICE_DTS \
   DEVICE_DTS_CONFIG DEVICE_DTS_DIR BOARD_NAME UIMAGE_NAME SUPPORTED_DEVICES \
-  IMAGE_METADATA KERNEL_ENTRY KERNEL_LOADADDR
+  IMAGE_METADATA KERNEL_ENTRY KERNEL_LOADADDR UBOOT_PATH
 
 define Device/ExportVar
   $(1) : $(2):=$$($(2))
@@ -557,6 +559,8 @@ define Device/DumpInfo
 Target-Profile: DEVICE_$(1)
 Target-Profile-Name: $(DEVICE_TITLE)
 Target-Profile-Packages: $(DEVICE_PACKAGES)
+Target-Profile-hasImageMetadata: $(if $(foreach image,$(IMAGES),$(findstring append-metadata,$(IMAGE/$(image)))),1,0)
+Target-Profile-SupportedDevices: $(SUPPORTED_DEVICES)
 Target-Profile-Description:
 $(DEVICE_DESCRIPTION)
 @@

+ 9 - 8
include/kernel-version.mk

@@ -2,15 +2,13 @@
 
 LINUX_RELEASE?=1
 
-LINUX_VERSION-3.18 = .136
-LINUX_VERSION-4.9 = .160
-LINUX_VERSION-4.14 = .103
-LINUX_VERSION-4.19 = .25
+ifdef CONFIG_TESTING_KERNEL
+  KERNEL_PATCHVER:=$(KERNEL_TESTING_PATCHVER)
+endif
+
+LINUX_VERSION-4.14 = .141
 
-LINUX_KERNEL_HASH-3.18.136 =
-LINUX_KERNEL_HASH-4.9.160 =
-LINUX_KERNEL_HASH-4.14.103 = efebd67ba78b7c99eb9a1d2e3ceb30997e9c39f70d030d36899619a9e659ec17
-LINUX_KERNEL_HASH-4.19.25 =
+LINUX_KERNEL_HASH-4.14.141 = 0bb9f0812326ec4554de1bea02628840e03b6664b5abfd9d8510049e43203a17
 
 remove_uri_prefix=$(subst git://,,$(subst http://,,$(subst https://,,$(1))))
 sanitize_uri=$(call qstrip,$(subst @,_,$(subst :,_,$(subst .,_,$(subst -,_,$(subst /,_,$(1)))))))
@@ -25,6 +23,9 @@ else
 ifdef KERNEL_PATCHVER
   LINUX_VERSION:=$(KERNEL_PATCHVER)$(strip $(LINUX_VERSION-$(KERNEL_PATCHVER)))
 endif
+ifdef KERNEL_TESTING_PATCHVER
+  LINUX_TESTING_VERSION:=$(KERNEL_TESTING_PATCHVER)$(strip $(LINUX_VERSION-$(KERNEL_TESTING_PATCHVER)))
+endif
 endif
 
 split_version=$(subst ., ,$(1))

+ 5 - 2
include/kernel.mk

@@ -66,7 +66,7 @@ else
   endif
 
   ifneq (,$(findstring -rc,$(LINUX_VERSION)))
-      LINUX_SITE:=https://git.kernel.org/torvalds/t
+      LINUX_SITE:=
   else ifeq ($(call qstrip,$(CONFIG_EXTERNAL_KERNEL_TREE))$(call qstrip,$(CONFIG_KERNEL_GIT_CLONE_URI)),)
       LINUX_SITE:=@KERNEL_LIBRE/$(LINUX_VERSION)-gnu$(TESTING)
   else
@@ -141,7 +141,10 @@ endef
 
 define collect_module_symvers
 	for subdir in $(PKG_EXTMOD_SUBDIRS); do \
-		grep -F $$$$(readlink -f $(PKG_BUILD_DIR)) $(PKG_BUILD_DIR)/$$$$subdir/Module.symvers >> $(PKG_BUILD_DIR)/Module.symvers.tmp; \
+		realdir=$$$$(readlink -f $(PKG_BUILD_DIR)); \
+		grep -F $(PKG_BUILD_DIR) $(PKG_BUILD_DIR)/$$$$subdir/Module.symvers >> $(PKG_BUILD_DIR)/Module.symvers.tmp; \
+		[ "$(PKG_BUILD_DIR)" = "$$$$realdir" ] || \
+			grep -F $$$$realdir $(PKG_BUILD_DIR)/$$$$subdir/Module.symvers >> $(PKG_BUILD_DIR)/Module.symvers.tmp; \
 	done; \
 	sort -u $(PKG_BUILD_DIR)/Module.symvers.tmp > $(PKG_BUILD_DIR)/Module.symvers; \
 	mv $(PKG_BUILD_DIR)/Module.symvers $(PKG_INFO_DIR)/$(PKG_NAME).symvers

+ 2 - 1
include/package-ipkg.mk

@@ -35,7 +35,8 @@ PARENR :=)
 
 dep_split=$(subst :,$(space),$(1))
 dep_rem=$(subst !,,$(subst $(strip $(PARENL)),,$(subst $(strip $(PARENR)),,$(word 1,$(call dep_split,$(1))))))
-dep_confvar=$(strip $(foreach cond,$(subst ||, ,$(call dep_rem,$(1))),$(CONFIG_$(cond))))
+dep_and=dep_and_res:=$$(and $(subst $(space),$(comma),$(foreach cond,$(subst &&, ,$(1)),$$(CONFIG_$(cond)))))
+dep_confvar=$(strip $(foreach cond,$(subst ||, ,$(call dep_rem,$(1))),$(eval $(call dep_and,$(cond)))$(dep_and_res)))
 dep_pos=$(if $(call dep_confvar,$(1)),$(call dep_val,$(1)))
 dep_neg=$(if $(call dep_confvar,$(1)),,$(call dep_val,$(1)))
 dep_if=$(if $(findstring !,$(1)),$(call dep_neg,$(1)),$(call dep_pos,$(1)))

+ 7 - 1
include/rootfs.mk

@@ -78,7 +78,13 @@ define prepare_rootfs
 		done; \
 		for script in ./etc/init.d/*; do \
 			grep '#!/bin/sh /etc/rc.common' $$script >/dev/null || continue; \
-			IPKG_INSTROOT=$(1) $$(which bash) ./etc/rc.common $$script enable; \
+			if ! echo " $(3) " | grep -q " $$(basename $$script) "; then \
+				IPKG_INSTROOT=$(1) $$(which bash) ./etc/rc.common $$script enable; \
+				echo "Enabling" $$(basename $$script); \
+			else \
+				IPKG_INSTROOT=$(1) $$(which bash) ./etc/rc.common $$script disable; \
+				echo "Disabling" $$(basename $$script); \
+			fi; \
 		done || true \
 	)
 	$(if $(SOURCE_DATE_EPOCH),sed -i "s/Installed-Time: .*/Installed-Time: $(SOURCE_DATE_EPOCH)/" $(1)/usr/lib/opkg/status)

+ 7 - 23
include/target.mk

@@ -13,11 +13,11 @@ __target_inc=1
 DEVICE_TYPE?=router
 
 # Default packages - the really basic set
-DEFAULT_PACKAGES:=base-files libc libgcc busybox dropbear mtd uci opkg netifd fstools uclient-fetch logd
+DEFAULT_PACKAGES:=base-files libc libgcc busybox dropbear mtd uci opkg netifd fstools uclient-fetch logd urandom-seed urngd
 # For nas targets
 DEFAULT_PACKAGES.nas:=block-mount fdisk lsblk mdadm
 # For router targets
-DEFAULT_PACKAGES.router:=dnsmasq iptables ip6tables ppp ppp-mod-pppoa ppp-mod-pppoe firewall odhcpd-ipv6only odhcp6c kmod-ipt-offload
+DEFAULT_PACKAGES.router:=dnsmasq iptables ip6tables ppp ppp-mod-pppoe firewall odhcpd-ipv6only odhcp6c kmod-ipt-offload
 DEFAULT_PACKAGES.bootloader:=
 
 ifneq ($(DUMP),)
@@ -51,7 +51,7 @@ else
   endif
 endif
 
-ifneq ($(filter 3.18 4.9,$(KERNEL_PATCHVER)),)
+ifneq ($(filter 4.9,$(KERNEL_PATCHVER)),)
   DEFAULT_PACKAGES.router:=$(filter-out kmod-ipt-offload,$(DEFAULT_PACKAGES.router))
 endif
 
@@ -183,26 +183,6 @@ ifeq ($(DUMP),1)
   endif
   ifneq ($(findstring arm,$(ARCH)),)
     CPU_TYPE ?= xscale
-    CPU_CFLAGS_arm920t = -mcpu=arm920t
-    CPU_CFLAGS_arm926ej-s = -mcpu=arm926ej-s
-    CPU_CFLAGS_arm1136j-s = -mcpu=arm1136j-s
-    CPU_CFLAGS_arm1176jzf-s = -mcpu=arm1176jzf-s
-    CPU_CFLAGS_cortex-a5 = -mcpu=cortex-a5
-    CPU_CFLAGS_cortex-a7 = -mcpu=cortex-a7
-    CPU_CFLAGS_cortex-a8 = -mcpu=cortex-a8
-    CPU_CFLAGS_cortex-a9 = -mcpu=cortex-a9
-    CPU_CFLAGS_cortex-a15 = -mcpu=cortex-a15
-    CPU_CFLAGS_cortex-a53 = -mcpu=cortex-a53
-    CPU_CFLAGS_cortex-a72 = -mcpu=cortex-a72
-    CPU_CFLAGS_fa526 = -mcpu=fa526
-    CPU_CFLAGS_mpcore = -mcpu=mpcore
-    CPU_CFLAGS_xscale = -mcpu=xscale
-    ifeq ($(CONFIG_SOFT_FLOAT),)
-      CPU_CFLAGS_neon = -mfpu=neon
-      CPU_CFLAGS_vfp = -mfpu=vfp
-      CPU_CFLAGS_vfpv3 = -mfpu=vfpv3-d16
-      CPU_CFLAGS_neon-vfpv4 = -mfpu=neon-vfpv4
-    endif
   endif
   ifeq ($(ARCH),powerpc)
     CPU_CFLAGS_603e:=-mcpu=603e
@@ -245,6 +225,9 @@ ifeq ($(DUMP),1)
     .SILENT: $(TMP_CONFIG)
     .PRECIOUS: $(TMP_CONFIG)
 
+    ifdef KERNEL_TESTING_PATCHVER
+      FEATURES += testing-kernel
+    endif
     ifneq ($(CONFIG_OF),)
       FEATURES += dt
     endif
@@ -303,6 +286,7 @@ define BuildTargets/DumpCurrent
 	 echo 'Target-Optimization: $(if $(CFLAGS),$(CFLAGS),$(DEFAULT_CFLAGS))'; \
 	 echo 'CPU-Type: $(CPU_TYPE)$(if $(CPU_SUBTYPE),+$(CPU_SUBTYPE))'; \
 	 echo 'Linux-Version: $(LINUX_VERSION)'; \
+	$(if $(LINUX_TESTING_VERSION),echo 'Linux-Testing-Version: $(LINUX_TESTING_VERSION)';) \
 	 echo 'Linux-Release: $(LINUX_RELEASE)'; \
 	 echo 'Linux-Kernel-Arch: $(LINUX_KARCH)'; \
 	$(if $(SUBTARGET),,$(if $(DEFAULT_SUBTARGET), echo 'Default-Subtarget: $(DEFAULT_SUBTARGET)'; )) \

+ 2 - 7
include/unpack.mk

@@ -58,18 +58,13 @@ ifeq ($(strip $(UNPACK_CMD)),)
       UNPACK_CMD=gzip -dc $(DL_DIR)/$(PKG_SOURCE) | $(TAR_CMD)
     endif
   endif
-  ifneq ($(strip $(CRLF_WORKAROUND)),)
-    CRLF_CMD := && find $(PKG_BUILD_DIR) -type f -print0 | xargs -0 perl -pi -e 's!\r$$$$!!g'
-  else
-    CRLF_CMD :=
-  endif
 endif
 
 ifdef PKG_BUILD_DIR
-  PKG_UNPACK ?= $(SH_FUNC) $(call UNPACK_CMD,$(PKG_BUILD_DIR)) $(call CRLF_CMD,$(PKG_BUILD_DIR))
+  PKG_UNPACK ?= $(SH_FUNC) $(call UNPACK_CMD,$(PKG_BUILD_DIR))
 endif
 ifdef HOST_BUILD_DIR
-  HOST_UNPACK ?= $(SH_FUNC) $(call UNPACK_CMD,$(HOST_BUILD_DIR)) $(call CRLF_CMD,$(HOST_BUILD_DIR))
+  HOST_UNPACK ?= $(SH_FUNC) $(call UNPACK_CMD,$(HOST_BUILD_DIR))
 endif
 
 endif # PKG_SOURCE

+ 4 - 4
include/version.mk

@@ -26,13 +26,13 @@ PKG_CONFIG_DEPENDS += \
 sanitize = $(call tolower,$(subst _,-,$(subst $(space),-,$(1))))
 
 VERSION_NUMBER:=$(call qstrip,$(CONFIG_VERSION_NUMBER))
-VERSION_NUMBER:=$(if $(VERSION_NUMBER),$(VERSION_NUMBER),v1.5)
+VERSION_NUMBER:=$(if $(VERSION_NUMBER),$(VERSION_NUMBER),v1.5.0)
 
 VERSION_CODE:=$(call qstrip,$(CONFIG_VERSION_CODE))
 VERSION_CODE:=$(if $(VERSION_CODE),$(VERSION_CODE),$(REVISION))
 
 VERSION_REPO:=$(call qstrip,$(CONFIG_VERSION_REPO))
-VERSION_REPO:=$(if $(VERSION_REPO),$(VERSION_REPO),https://librecmc.org/librecmc/downloads/snapshots/beta/%v)
+VERSION_REPO:=$(if $(VERSION_REPO),$(VERSION_REPO),https://librecmc.org/librecmc/downloads/snapshots/%v)
 
 VERSION_DIST:=$(call qstrip,$(CONFIG_VERSION_DIST))
 VERSION_DIST:=$(if $(VERSION_DIST),$(VERSION_DIST),libreCMC)
@@ -42,10 +42,10 @@ VERSION_MANUFACTURER:=$(call qstrip,$(CONFIG_VERSION_MANUFACTURER))
 VERSION_MANUFACTURER:=$(if $(VERSION_MANUFACTURER),$(VERSION_MANUFACTURER),libreCMC)
 
 VERSION_MANUFACTURER_URL:=$(call qstrip,$(CONFIG_VERSION_MANUFACTURER_URL))
-VERSION_MANUFACTURER_URL:=$(if $(VERSION_MANUFACTURER_URL),$(VERSION_MANUFACTURER_URL),https://librecmc.org/)
+VERSION_MANUFACTURER_URL:=$(if $(VERSION_MANUFACTURER_URL),$(VERSION_MANUFACTURER_URL),https://openwrt.org/)
 
 VERSION_BUG_URL:=$(call qstrip,$(CONFIG_VERSION_BUG_URL))
-VERSION_BUG_URL:=$(if $(VERSION_BUG_URL),$(VERSION_BUG_URL),https://gogs.librecmc.org/libreCMC/libreCMC/issues)
+VERSION_BUG_URL:=$(if $(VERSION_BUG_URL),$(VERSION_BUG_URL),https://git.gnu.io/librecmc/librecmc/issues/)
 
 VERSION_HOME_URL:=$(call qstrip,$(CONFIG_VERSION_HOME_URL))
 VERSION_HOME_URL:=$(if $(VERSION_HOME_URL),$(VERSION_HOME_URL),https://librecmc.org/)

+ 6 - 2
package/Makefile

@@ -84,8 +84,12 @@ $(curdir)/index: FORCE
 		mkdir -p $$d; \
 		cd $$d || continue; \
 		$(SCRIPT_DIR)/ipkg-make-index.sh . 2>&1 > Packages.manifest; \
-		grep -vE '^(Maintainer|LicenseFiles|Source|SourceName|Require)' Packages.manifest > Packages && \
-			gzip -9nc Packages > Packages.gz; \
+		grep -vE '^(Maintainer|LicenseFiles|Source|SourceName|Require)' Packages.manifest > Packages; \
+		case "$$(((64 + $$(stat -L -c%s Packages)) % 128))" in 110|111) \
+			$(call ERROR_MESSAGE,WARNING: Applying padding in $$d/Packages to workaround usign SHA-512 bug!); \
+			{ echo ""; echo ""; } >> Packages;; \
+		esac; \
+		gzip -9nc Packages > Packages.gz; \
 	); done
 ifdef CONFIG_SIGNED_PACKAGES
 	@echo Signing package index...

+ 11 - 2
package/base-files/Makefile

@@ -12,7 +12,7 @@ include $(INCLUDE_DIR)/version.mk
 include $(INCLUDE_DIR)/feeds.mk
 
 PKG_NAME:=base-files
-PKG_RELEASE:=197
+PKG_RELEASE:=198
 PKG_FLAGS:=nonshared
 
 PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/
@@ -37,12 +37,21 @@ endif
 define Package/base-files
   SECTION:=base
   CATEGORY:=Base system
-  DEPENDS:=+netifd +libc +procd +jsonfilter +SIGNED_PACKAGES:usign +SIGNED_PACKAGES:librecmc-keyring +NAND_SUPPORT:ubi-utils +fstools +fwtool
+  DEPENDS:=+netifd +libc +procd +jsonfilter +SIGNED_PACKAGES:usign +SIGNED_PACKAGES:openwrt-keyring +NAND_SUPPORT:ubi-utils +fstools +fwtool
   TITLE:=Base filesystem for libreCMC
   URL:=http://openwrt.org/
   VERSION:=$(PKG_RELEASE)-$(REVISION)
 endef
 
+define Package/urandom-seed
+  SECTION:=base
+  CATEGORY:=Base system
+  DEPENDS:=+libc +ubox-getrandom
+  TITLE:=/etc/urandom.seed handling for libreCMC
+  URL:=http://openwrt.org/
+  VERSION:=$(PKG_RELEASE)-$(REVISION)
+endef
+
 define Package/base-files/conffiles
 /etc/config/
 /etc/config/network

+ 4 - 1
package/base-files/files/bin/config_generate

@@ -213,7 +213,8 @@ generate_switch() {
 
 	json_select switch
 	json_select "$key"
-	json_get_vars enable reset blinkrate cpu_port
+	json_get_vars enable reset blinkrate cpu_port \
+		ar8xxx_mib_type ar8xxx_mib_poll_interval
 
 	uci -q batch <<-EOF
 		add network switch
@@ -221,6 +222,8 @@ generate_switch() {
 		set network.@switch[-1].reset='$reset'
 		set network.@switch[-1].enable_vlan='$enable'
 		set network.@switch[-1].blinkrate='$blinkrate'
+		set network.@switch[-1].ar8xxx_mib_type='$ar8xxx_mib_type'
+		set network.@switch[-1].ar8xxx_mib_poll_interval='$ar8xxx_mib_poll_interval'
 	EOF
 
 	generate_switch_vlans_ports "$1"

+ 1 - 1
package/base-files/files/etc/group

@@ -1,8 +1,8 @@
 root:x:0:
 daemon:x:1:
 adm:x:4:
-tty:x:5:
 mail:x:8:
+dialout:x:20:
 audio:x:29:
 www-data:x:33:
 ftp:x:55:

+ 12 - 0
package/base-files/files/etc/rc.button/reboot

@@ -0,0 +1,12 @@
+#!/bin/sh
+
+[ "${ACTION}" = "released" ] || exit 0
+
+if [ "$SEEN" -ge 5 ]
+then
+	echo "REBOOT" > /dev/console
+	sync
+	reboot
+fi
+
+return 0

+ 3 - 0
package/base-files/files/etc/rc.common

@@ -131,6 +131,9 @@ ${INIT_TRACE:+set -x}
 		procd_lock
 		stop_service "$@"
 		procd_kill "$(basename ${basescript:-$initscript})" "$1"
+		if eval "type service_stopped" 2>/dev/null >/dev/null; then
+			service_stopped
+		fi
 	}
 
 	reload() {

+ 39 - 0
package/base-files/files/lib/functions/migrations.sh

@@ -0,0 +1,39 @@
+#!/bin/sh
+
+. /lib/functions.sh
+
+migrate_led_sysfs() {
+	local cfg="$1"; shift
+	local tuples="$@"
+	local sysfs
+	local name
+
+	config_get sysfs ${cfg} sysfs
+	config_get name ${cfg} name
+
+	[ -z "${sysfs}" ] && return
+
+	for tuple in ${tuples}; do
+		local old=${tuple%=*}
+		local new=${tuple#*=}
+		local new_sysfs
+
+		new_sysfs=$(echo ${sysfs} | sed "s/${old}/${new}/")
+
+		[ "${new_sysfs}" = "${sysfs}" ] && continue
+
+		uci set system.${cfg}.sysfs="${new_sysfs}"
+
+		logger -t led-migration "sysfs option of LED \"${name}\" updated to ${new_sysfs}"
+	done;
+}
+
+migrate_leds() {
+	config_load system
+	config_foreach migrate_led_sysfs led "$@"
+}
+
+migrations_apply() {
+	local realm="$1"
+	[ -n "$(uci changes ${realm})" ] && uci -q commit ${realm}
+}

+ 1 - 1
package/base-files/files/lib/functions/system.sh

@@ -4,7 +4,7 @@ get_mac_binary() {
 	local path="$1"
 	local offset="$2"
 
-	if [ -z "$path" ]; then
+	if ! [ -e "$path" ]; then
 		echo "get_mac_binary: file $path not found!" >&2
 		return
 	fi

+ 14 - 0
package/base-files/files/lib/functions/uci-defaults.sh

@@ -182,6 +182,19 @@ _ucidef_finish_switch_roles() {
 	done
 }
 
+ucidef_set_ar8xxx_switch_mib() {
+	local name="$1"
+	local type="$2"
+	local interval="$3"
+
+	json_select_object switch
+		json_select_object "$name"
+			json_add_int ar8xxx_mib_type $type
+			json_add_int ar8xxx_mib_poll_interval $interval
+		json_select ..
+	json_select ..
+}
+
 ucidef_add_switch() {
 	local name="$1"; shift
 	local port num role device index need_tag prev_role
@@ -463,6 +476,7 @@ _ucidef_set_led_timer() {
 
 	_ucidef_set_led_common "$1" "$2" "$3"
 
+	json_add_string type "$trigger_name"
 	json_add_string trigger "$trigger_name"
 	json_add_int delayon "$delayon"
 	json_add_int delayoff "$delayoff"

+ 19 - 13
package/base-files/files/lib/upgrade/common.sh

@@ -101,35 +101,41 @@ get_magic_long() {
 }
 
 export_bootdevice() {
-	local cmdline uuid disk uevent line
+	local cmdline bootdisk rootpart uuid blockdev uevent line
 	local MAJOR MINOR DEVNAME DEVTYPE
 
 	if read cmdline < /proc/cmdline; then
 		case "$cmdline" in
 			*block2mtd=*)
-				disk="${cmdline##*block2mtd=}"
-				disk="${disk%%,*}"
+				bootdisk="${cmdline##*block2mtd=}"
+				bootdisk="${bootdisk%%,*}"
 			;;
 			*root=*)
-				disk="${cmdline##*root=}"
-				disk="${disk%% *}"
+				rootpart="${cmdline##*root=}"
+				rootpart="${rootpart%% *}"
 			;;
 		esac
 
-		case "$disk" in
-			PARTUUID=[a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9]-02)
-				uuid="${disk#PARTUUID=}"
-				uuid="${uuid%-02}"
-				for disk in $(find /dev -type b); do
-					set -- $(dd if=$disk bs=1 skip=440 count=4 2>/dev/null | hexdump -v -e '4/1 "%02x "')
+		case "$bootdisk" in
+			/dev/*)
+				uevent="/sys/class/block/${bootdisk##*/}/uevent"
+			;;
+		esac
+
+		case "$rootpart" in
+			PARTUUID=[a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9]-[a-f0-9][a-f0-9])
+				uuid="${rootpart#PARTUUID=}"
+				uuid="${uuid%-[a-f0-9][a-f0-9]}"
+				for blockdev in $(find /dev -type b); do
+					set -- $(dd if=$blockdev bs=1 skip=440 count=4 2>/dev/null | hexdump -v -e '4/1 "%02x "')
 					if [ "$4$3$2$1" = "$uuid" ]; then
-						uevent="/sys/class/block/${disk##*/}/uevent"
+						uevent="/sys/class/block/${blockdev##*/}/uevent"
 						break
 					fi
 				done
 			;;
 			/dev/*)
-				uevent="/sys/class/block/${disk##*/}/uevent"
+				uevent="/sys/class/block/${rootpart##*/}/../uevent"
 			;;
 		esac
 

+ 8 - 8
package/base-files/files/usr/lib/os-release

@@ -8,11 +8,11 @@ HOME_URL="%u"
 BUG_URL="%b"
 SUPPORT_URL="%s"
 BUILD_ID="%R"
-LEDE_BOARD="%S"
-LEDE_ARCH="%A"
-LEDE_TAINTS="%t"
-LEDE_DEVICE_MANUFACTURER="%M"
-LEDE_DEVICE_MANUFACTURER_URL="%m"
-LEDE_DEVICE_PRODUCT="%P"
-LEDE_DEVICE_REVISION="%h"
-LEDE_RELEASE="%D %V %C"
+LIBRECMC_BOARD="%S"
+LIBRECMC_ARCH="%A"
+LIBRECMC_TAINTS="%t"
+LIBRECMC_DEVICE_MANUFACTURER="%M"
+LIBRECMC_DEVICE_MANUFACTURER_URL="%m"
+LIBRECMC_DEVICE_PRODUCT="%P"
+LIBRECMC_DEVICE_REVISION="%h"
+LIBRECMC_RELEASE="%D %V %C"

+ 1 - 1
package/base-files/image-config.in

@@ -183,7 +183,7 @@ if VERSIONOPT
 	config VERSION_REPO
 		string
 		prompt "Release repository"
-		default "http://downloads.lede-project.org/snapshots"
+		default "http://downloads.openwrt.org/releases/19.07-SNAPSHOT"
 		help
 			This is the repository address embedded in the image, it defaults
 			to the trunk snapshot repo; the url may contain the following placeholders:

+ 6 - 1
package/boot/uboot-envtools/files/ath79

@@ -17,11 +17,16 @@ buffalo,wzr-hp-ag300h)
         ubootenv_add_uci_config "/dev/mtd3" "0x0" "0x10000" "0x10000"
         ;;
 buffalo,bhr-4grv2|\
+engenius,ecb1750|\
 glinet,gl-ar300m-nand|\
 glinet,gl-ar300m-nor|\
+librerouter,librerouter-v1|\
+netgear,ex6400|\
+netgear,ex7300|\
 ocedo,koala|\
 ocedo,raccoon|\
-openmesh,om5p-ac-v2)
+openmesh,om5p-ac-v2|\
+yuncore,a770)
 	ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x10000" "0x10000"
 	;;
 esac

+ 4 - 0
package/boot/uboot-envtools/files/imx6

@@ -7,12 +7,16 @@
 
 touch /etc/config/ubootenv
 
+. /lib/imx6.sh
 . /lib/uboot-envtools.sh
 . /lib/functions.sh
 
 board=$(board_name)
 
 case "$board" in
+apalis*)
+	ubootenv_add_uci_config $(bootdev_from_uuid)boot0 -0x2200 0x2000 0x200 10
+	;;
 *gw5*)
 	if [ -c /dev/mtd1 ]; then
 		# board boots from NAND

+ 3 - 0
package/boot/uboot-envtools/files/ipq40xx

@@ -40,6 +40,9 @@ openmesh,a62)
 linksys,ea6350v3)
 	ubootenv_add_uci_config "/dev/mtd7" "0x0" "0x20000" "0x20000"
 	;;
+linksys,ea8300)
+	ubootenv_add_uci_config "/dev/mtd7" "0x0" "0x40000" "0x20000"
+	;;
 zyxel,nbg6617)
 	ubootenv_add_uci_config "/dev/mtd6" "0x0" "0x10000" "0x10000"
 	;;

+ 16 - 13
package/boot/uboot-envtools/files/mvebu

@@ -14,25 +14,28 @@ touch /etc/config/ubootenv
 board=$(board_name)
 
 case "$board" in
-armada-385-linksys-caiman|\
-armada-385-linksys-cobra|\
-armada-385-linksys-shelby)
-	ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x20000" "0x40000"
-	;;
-armada-385-linksys-rango|\
-armada-385-linksys-venom)
-	ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x20000" "0x20000"
-	;;
-armada-385-turris-omnia)
+cznic,turris-omnia)
 	ubootenv_add_uci_config "/dev/mtd0" "0xC0000" "0x10000" "0x40000"
 	;;
-armada-xp-linksys-mamba)
-	ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x40000" "0x20000"
-	;;
 globalscale,espressobin|\
+globalscale,espressobin-emmc|\
+globalscale,espressobin-v7|\
+globalscale,espressobin-v7-emmc|\
 marvell,armada8040-mcbin)
 	ubootenv_add_uci_config "/dev/mtd0" "0x3f0000" "0x10000" "0x10000" "1"
 	;;
+linksys,caiman|\
+linksys,cobra|\
+linksys,shelby)
+	ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x20000" "0x40000"
+	;;
+linksys,mamba)
+	ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x40000" "0x20000"
+	;;
+linksys,rango|\
+linksys,venom)
+	ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x20000" "0x20000"
+	;;
 esac
 
 config_load ubootenv

+ 3 - 1
package/boot/uboot-envtools/files/oxnas

@@ -14,10 +14,12 @@ board=$(board_name)
 
 case "$board" in
 "cloudengines,pogoplug"* | \
-"mitrastar,stg-212" | \
 "shuttle,kd20")
 	ubootenv_add_uci_config "/dev/mtd2" "0x0" "0x2000" "0x2000" "1"
 	;;
+"mitrastar,stg-212")
+	ubootenv_add_uci_config "/dev/mtd2" "0x0" "0x20000" "0x20000" "1"
+	;;
 esac
 
 config_load ubootenv

+ 4 - 2
package/boot/uboot-envtools/files/ramips

@@ -14,7 +14,8 @@ board=$(board_name)
 
 case "$board" in
 alfa-network,ac1200rm|\
-alfa-network,awusfree1)
+alfa-network,awusfree1|\
+alfa-network,tube-e4g)
 	ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x1000" "0x1000"
 	;;
 all0256n-4M|\
@@ -30,7 +31,8 @@ wsr-600|\
 zbt-wg2626)
 	ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x1000" "0x10000"
 	;;
-mir3g)
+xiaomi,mir3p|\
+xiaomi,mir3g)
 	ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x1000" "0x20000"
 	;;
 esac

+ 9 - 2
package/boot/uboot-sunxi/Makefile

@@ -9,9 +9,9 @@
 include $(TOPDIR)/rules.mk
 include $(INCLUDE_DIR)/kernel.mk
 
-PKG_VERSION:=2018.11
+PKG_VERSION:=2019.01
 
-PKG_HASH:=737c93f2ea03fec669e840dbee32bcf6238e6924ff5f20e4f1c472ee24e5d37e
+PKG_HASH:=50bd7e5a466ab828914d080d5f6a432345b500e8fba1ad3b7b61e95e60d51c22
 
 PKG_MAINTAINER:=Zoltan HERPAI <wigyori@uid0.hu>
 
@@ -168,6 +168,12 @@ define U-Boot/orangepi_pc
   BUILD_DEVICES:=sun8i-h3-orangepi-pc
 endef
 
+define U-Boot/orangepi_pc_plus
+  BUILD_SUBTARGET:=cortexa7
+  NAME:=Orange Pi PC Plus (H3)
+  BUILD_DEVICES:=sun8i-h3-orangepi-pc-plus
+endef
+
 define U-Boot/orangepi_plus
   BUILD_SUBTARGET:=cortexa7
   NAME:=Orange Pi Plus (H3)
@@ -268,6 +274,7 @@ UBOOT_TARGETS := \
 	orangepi_r1 \
 	orangepi_one \
 	orangepi_pc \
+	orangepi_pc_plus \
 	orangepi_plus \
 	orangepi_2 \
 	orangepi_pc2 \

+ 2 - 2
package/boot/uboot-sunxi/patches/003-add-theobroma-a31-pangolin.patch

@@ -1,6 +1,6 @@
 --- a/arch/arm/dts/Makefile
 +++ b/arch/arm/dts/Makefile
-@@ -306,6 +306,7 @@ dtb-$(CONFIG_MACH_SUN6I) += \
+@@ -313,6 +313,7 @@ dtb-$(CONFIG_MACH_SUN6I) += \
  	sun6i-a31-m9.dtb \
  	sun6i-a31-mele-a1000g-quad.dtb \
  	sun6i-a31-mixtile-loftq.dtb \
@@ -358,7 +358,7 @@
 +CONFIG_SUNXI_SPI=y
 --- a/arch/arm/mach-sunxi/Kconfig
 +++ b/arch/arm/mach-sunxi/Kconfig
-@@ -872,6 +872,14 @@ config VIDEO_LCD_PANEL_I2C_SCL
+@@ -875,6 +875,14 @@ config VIDEO_LCD_PANEL_I2C_SCL
  	Set the SCL pin for the LCD i2c interface. This takes a string in the
  	format understood by sunxi_name_to_gpio, e.g. PH1 for pin 1 of port H.
  

+ 2 - 2
package/boot/uboot-sunxi/patches/062-A20-improve-gmac-upload.patch

@@ -8,5 +8,5 @@
  CONFIG_SUN7I_GMAC=y
 +CONFIG_GMAC_TX_DELAY=1
  CONFIG_AXP_ALDO3_VOLT=2800
- CONFIG_AXP_ALDO4_VOLT=2800
- CONFIG_SCSI=y
+ CONFIG_AXP_ALDO3_VOLT_SLOPE_08=y
+ CONFIG_AXP_ALDO3_INRUSH_QUIRK=y

+ 44 - 0
package/boot/uboot-sunxi/patches/063-fix-lime2-revK-add-micrel-PHY.patch

@@ -0,0 +1,44 @@
+--- a/configs/A20-OLinuXino-Lime2-eMMC_defconfig
++++ b/configs/A20-OLinuXino-Lime2-eMMC_defconfig
+@@ -8,6 +8,8 @@ CONFIG_MMC_SUNXI_SLOT_EXTRA=2
+ CONFIG_USB0_VBUS_PIN="PC17"
+ CONFIG_USB0_VBUS_DET="PH5"
+ CONFIG_I2C1_ENABLE=y
++CONFIG_PHY_MICREL=y
++CONFIG_PHY_MICREL_KSZ90X1=y
+ CONFIG_SATAPWR="PC3"
+ CONFIG_AHCI=y
+ CONFIG_NR_DRAM_BANKS=1
+--- a/configs/A20-OLinuXino-Lime2_defconfig
++++ b/configs/A20-OLinuXino-Lime2_defconfig
+@@ -7,6 +7,8 @@ CONFIG_MMC0_CD_PIN="PH1"
+ CONFIG_USB0_VBUS_PIN="PC17"
+ CONFIG_USB0_VBUS_DET="PH5"
+ CONFIG_I2C1_ENABLE=y
++CONFIG_PHY_MICREL=y
++CONFIG_PHY_MICREL_KSZ90X1=y
+ CONFIG_SATAPWR="PC3"
+ CONFIG_AHCI=y
+ CONFIG_NR_DRAM_BANKS=1
+--- a/drivers/net/phy/micrel_ksz90x1.c
++++ b/drivers/net/phy/micrel_ksz90x1.c
+@@ -13,6 +13,8 @@
+ #include <errno.h>
+ #include <micrel.h>
+ #include <phy.h>
++#include <asm/io.h>
++#include <asm/arch/clock.h>
+ 
+ /*
+  * KSZ9021 - KSZ9031 common
+@@ -329,6 +331,10 @@ static int ksz9031_phy_extwrite(struct p
+ static int ksz9031_config(struct phy_device *phydev)
+ {
+ 	int ret;
++	struct sunxi_ccm_reg *const ccm =
++		(struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
++
++	setbits_le32(&ccm->gmac_clk_cfg, CCM_GMAC_CTRL_TX_CLK_DELAY(4));
+ 
+ 	ret = ksz9031_of_config(phydev);
+ 	if (ret)

+ 1 - 1
package/boot/uboot-sunxi/patches/102-sunxi-make_CONS_INDEX-configurable.patch

@@ -6,7 +6,7 @@ Subject: ARM: sunxi: Make CONS_INDEX configurable
 
 --- a/arch/arm/mach-sunxi/Kconfig
 +++ b/arch/arm/mach-sunxi/Kconfig
-@@ -535,6 +535,14 @@ config SYS_BOARD
+@@ -538,6 +538,14 @@ config SYS_BOARD
  config SYS_SOC
  	default "sunxi"
  

+ 2 - 2
package/boot/uboot-sunxi/patches/210-sunxi-deactivate-binman.patch

@@ -12,7 +12,7 @@ old way of generating images.
 
 --- a/Makefile
 +++ b/Makefile
-@@ -1255,8 +1255,10 @@ endif
+@@ -1344,8 +1344,10 @@ endif
  
  ifneq ($(CONFIG_ARCH_SUNXI),)
  ifeq ($(CONFIG_ARM64),)
@@ -27,7 +27,7 @@ old way of generating images.
  	$(call if_changed,cat)
 --- a/arch/arm/Kconfig
 +++ b/arch/arm/Kconfig
-@@ -820,7 +820,6 @@ config ARCH_SOCFPGA
+@@ -842,7 +842,6 @@ config ARCH_SOCFPGA
  
  config ARCH_SUNXI
  	bool "Support sunxi (Allwinner) SoCs"

+ 0 - 88
package/boot/uboot-xburst/Makefile

@@ -1,88 +0,0 @@
-#
-# Copyright (C) 2010 OpenWrt.org
-#
-# This is free software, licensed under the GNU General Public License v2.
-# See /LICENSE for more information.
-#
-
-include $(TOPDIR)/rules.mk
-include $(INCLUDE_DIR)/kernel.mk
-
-PKG_NAME:=u-boot
-PKG_VERSION:=2012.10-rc2
-PKG_RELEASE:=1
-
-PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
-PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
-PKG_SOURCE_URL:= \
-	http://mirror2.openwrt.org/sources \
-	ftp://ftp.denx.de/pub/u-boot
-PKG_HASH:=6d094cafa7ecea8b671fbdcd21130b6a4f5744fc47dd263e101ed5d3629dffd4
-PKG_TARGETS:=bin
-
-PKG_LICENSE:=GPL-2.0 GPL-2.0+
-PKG_LICENSE_FILES:=Licenses/README
-
-include $(INCLUDE_DIR)/package.mk
-
-define uboot/Default
-  TITLE:=
-  CONFIG:=
-  IMAGE:=
-endef
-
-define uboot/qi_lb60
-  TITLE:=U-boot for the qi_lb60 board
-endef
-
-UBOOTS:=qi_lb60
-
-define Package/uboot/template
-define Package/uboot-xburst-$(1)
-  SECTION:=boot
-  CATEGORY:=Boot Loaders
-  DEPENDS:=@TARGET_xburst
-  TITLE:=$(2)
-  URL:=http://www.denx.de/wiki/UBoot/WebHome
-  VARIANT:=$(1)
-endef
-endef
-
-define BuildUbootPackage
-	$(eval $(uboot/Default))
-	$(eval $(uboot/$(1)))
-	$(call Package/uboot/template,$(1),$(TITLE))
-endef
-
-
-ifdef BUILD_VARIANT
-$(eval $(call uboot/$(BUILD_VARIANT)))
-UBOOT_CONFIG:=$(if $(CONFIG),$(CONFIG),$(BUILD_VARIANT))
-UBOOT_IMAGE:=$(if $(IMAGE),$(IMAGE),librecmc-$(BOARD)-$(BUILD_VARIANT)-u-boot.bin)
-endif
-
-define Build/Configure
-	$(MAKE) -C $(PKG_BUILD_DIR) \
-		$(UBOOT_CONFIG)_config
-endef
-
-define Build/Compile
-	$(MAKE) -C $(PKG_BUILD_DIR) \
-		CROSS_COMPILE=$(TARGET_CROSS)
-endef
-
-define Package/uboot/install/template
-define Package/uboot-xburst-$(1)/install
-	$(CP) $(PKG_BUILD_DIR)/u-boot-xburst.bin $(BIN_DIR)/$(2)
-	rmdir $$(1)
-endef
-endef
-
-$(foreach u,$(UBOOTS), \
-	$(eval $(call Package/uboot/install/template,$(u),librecmc-$(BOARD)-$(u)-u-boot.bin)) \
-)
-
-$(foreach u,$(UBOOTS), \
-	$(eval $(call BuildUbootPackage,$(u))) \
-	$(eval $(call BuildPackage,uboot-xburst-$(u))) \
-)

+ 0 - 894
package/boot/uboot-xburst/patches/0001-qi_lb60-add-nand-spl-support.patch

@@ -1,894 +0,0 @@
-From 0329cf7965956a5a7044827e0ce88ae8d5150e54 Mon Sep 17 00:00:00 2001
-From: Xiangfu <xiangfu@openmobilefree.net>
-Date: Fri, 12 Oct 2012 09:46:58 +0800
-Subject: [PATCH 1/6] qi_lb60: add nand spl support
-
-  The JZ4740 CPU can load 8KB from two different addresses:
-   1. the normal area up to 8KB starting from NAND flash address 0x00000000
-   2. the backup area up to 8KB starting from NAND flash address 0x00002000
-
-Signed-off-by: Xiangfu <xiangfu@openmobilefree.net>
----
- Makefile                          |   12 +++
- arch/mips/cpu/xburst/Makefile     |    7 +-
- arch/mips/cpu/xburst/cpu.c        |    4 +
- arch/mips/cpu/xburst/jz4740.c     |   82 +++++++----------
- arch/mips/cpu/xburst/spl/Makefile |   47 ++++++++++
- arch/mips/cpu/xburst/spl/start.S  |   63 +++++++++++++
- board/qi/qi_lb60/Makefile         |    4 +
- board/qi/qi_lb60/qi_lb60-spl.c    |   30 +++++++
- board/qi/qi_lb60/qi_lb60.c        |    8 +-
- board/qi/qi_lb60/u-boot-spl.lds   |   61 +++++++++++++
- drivers/mtd/nand/jz4740_nand.c    |   39 ++++++++-
- include/configs/qi_lb60.h         |  175 ++++++++++++++++++-------------------
- 12 files changed, 386 insertions(+), 146 deletions(-)
- create mode 100644 arch/mips/cpu/xburst/spl/Makefile
- create mode 100644 arch/mips/cpu/xburst/spl/start.S
- create mode 100644 board/qi/qi_lb60/qi_lb60-spl.c
- create mode 100644 board/qi/qi_lb60/u-boot-spl.lds
-
-diff --git a/Makefile b/Makefile
-index 34d9075..a22778e 100644
---- a/Makefile
-+++ b/Makefile
-@@ -393,6 +393,10 @@ ALL-y += $(obj)u-boot-nodtb-tegra.bin
- endif
- endif
- 
-+ifeq ($(CPU),xburst)
-+ALL-y += $(obj)u-boot-xburst.bin
-+endif
-+
- all:		$(ALL-y) $(SUBDIR_EXAMPLES)
- 
- $(obj)u-boot.dtb:	$(obj)u-boot
-@@ -506,6 +510,14 @@ $(obj)u-boot-nodtb-tegra.bin:	$(obj)spl/u-boot-spl.bin $(obj)u-boot.bin
- endif
- endif
- 
-+ifeq ($(CPU),xburst)
-+$(obj)u-boot-xburst.bin:	$(obj)spl/u-boot-spl.bin $(obj)u-boot.bin
-+	        dd if=$(obj)spl/u-boot-spl.bin of=$(obj)spl/u-boot-pad.bin conv=sync bs=8192 count=1
-+		dd if=$(obj)spl/u-boot-spl.bin of=$(obj)spl/u-boot-pad.bin conv=sync,notrunc oflag=append bs=8192 count=1
-+	        tr '\0' '\377' < /dev/zero | dd of=$(obj)spl/u-boot-pad.bin conv=sync,notrunc oflag=append bs=16384 count=1
-+	        cat $(obj)spl/u-boot-pad.bin u-boot.bin > $@
-+endif
-+
- ifeq ($(CONFIG_SANDBOX),y)
- GEN_UBOOT = \
- 		cd $(LNDIR) && $(CC) $(SYMS) -T $(obj)u-boot.lds \
-diff --git a/arch/mips/cpu/xburst/Makefile b/arch/mips/cpu/xburst/Makefile
-index b1f2ae4..ec35e55 100644
---- a/arch/mips/cpu/xburst/Makefile
-+++ b/arch/mips/cpu/xburst/Makefile
-@@ -24,9 +24,12 @@ include $(TOPDIR)/config.mk
- 
- LIB	= $(obj)lib$(CPU).o
- 
-+COBJS-y	= cpu.o jz_serial.o
-+
-+ifneq ($(CONFIG_SPL_BUILD),y)
- START	= start.o
--SOBJS-y	=
--COBJS-y	= cpu.o timer.o jz_serial.o
-+COBJS-y += timer.o
-+endif
- 
- COBJS-$(CONFIG_JZ4740) += jz4740.o
- 
-diff --git a/arch/mips/cpu/xburst/cpu.c b/arch/mips/cpu/xburst/cpu.c
-index ddcbfaa..1432838 100644
---- a/arch/mips/cpu/xburst/cpu.c
-+++ b/arch/mips/cpu/xburst/cpu.c
-@@ -42,6 +42,8 @@
- 		:			\
- 		: "i" (op), "R" (*(unsigned char *)(addr)))
- 
-+#ifndef CONFIG_SPL_BUILD
-+
- void __attribute__((weak)) _machine_restart(void)
- {
- 	struct jz4740_wdt *wdt = (struct jz4740_wdt *)JZ4740_WDT_BASE;
-@@ -109,6 +111,8 @@ void invalidate_dcache_range(ulong start_addr, ulong stop)
- 		cache_op(Hit_Invalidate_D, addr);
- }
- 
-+#endif
-+
- void flush_icache_all(void)
- {
- 	u32 addr, t = 0;
-diff --git a/arch/mips/cpu/xburst/jz4740.c b/arch/mips/cpu/xburst/jz4740.c
-index c0b9817..8816aa3 100644
---- a/arch/mips/cpu/xburst/jz4740.c
-+++ b/arch/mips/cpu/xburst/jz4740.c
-@@ -32,31 +32,19 @@ int disable_interrupts(void)
- 	return 0;
- }
- 
--/*
-- * PLL output clock = EXTAL * NF / (NR * NO)
-- * NF = FD + 2, NR = RD + 2
-- * NO = 1 (if OD = 0), NO = 2 (if OD = 1 or 2), NO = 4 (if OD = 3)
-- */
- void pll_init(void)
- {
- 	struct jz4740_cpm *cpm = (struct jz4740_cpm *)JZ4740_CPM_BASE;
- 
--	register unsigned int cfcr, plcr1;
--	int n2FR[33] = {
--		0, 0, 1, 2, 3, 0, 4, 0, 5, 0, 0, 0, 6, 0, 0, 0,
--		7, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0,
--		9
--	};
--	int div[5] = {1, 3, 3, 3, 3}; /* divisors of I:S:P:L:M */
--	int nf, pllout2;
-+	register unsigned int cfcr, plcr;
-+	unsigned int nf, pllout2;
- 
- 	cfcr =	CPM_CPCCR_CLKOEN |
--		CPM_CPCCR_PCS |
--		(n2FR[div[0]] << CPM_CPCCR_CDIV_BIT) |
--		(n2FR[div[1]] << CPM_CPCCR_HDIV_BIT) |
--		(n2FR[div[2]] << CPM_CPCCR_PDIV_BIT) |
--		(n2FR[div[3]] << CPM_CPCCR_MDIV_BIT) |
--		(n2FR[div[4]] << CPM_CPCCR_LDIV_BIT);
-+		(0 << CPM_CPCCR_CDIV_BIT) |
-+		(2 << CPM_CPCCR_HDIV_BIT) |
-+		(2 << CPM_CPCCR_PDIV_BIT) |
-+		(2 << CPM_CPCCR_MDIV_BIT) |
-+		(2 << CPM_CPCCR_LDIV_BIT);
- 
- 	pllout2 = (cfcr & CPM_CPCCR_PCS) ?
- 		CONFIG_SYS_CPU_SPEED : (CONFIG_SYS_CPU_SPEED / 2);
-@@ -65,15 +53,18 @@ void pll_init(void)
- 	writel(pllout2 / 48000000 - 1, &cpm->uhccdr);
- 
- 	nf = CONFIG_SYS_CPU_SPEED * 2 / CONFIG_SYS_EXTAL;
--	plcr1 = ((nf - 2) << CPM_CPPCR_PLLM_BIT) | /* FD */
-+	plcr = ((nf - 2) << CPM_CPPCR_PLLM_BIT) | /* FD */
- 		(0 << CPM_CPPCR_PLLN_BIT) |	/* RD=0, NR=2 */
- 		(0 << CPM_CPPCR_PLLOD_BIT) |	/* OD=0, NO=1 */
--		(0x20 << CPM_CPPCR_PLLST_BIT) |	/* PLL stable time */
-+		(0x32 << CPM_CPPCR_PLLST_BIT) |	/* PLL stable time */
- 		CPM_CPPCR_PLLEN;		/* enable PLL */
- 
- 	/* init PLL */
- 	writel(cfcr, &cpm->cpccr);
--	writel(plcr1, &cpm->cppcr);
-+	writel(plcr, &cpm->cppcr);
-+
-+	while (!(readl(&cpm->cppcr) & CPM_CPPCR_PLLS))
-+		;
- }
- 
- void sdram_init(void)
-@@ -92,26 +83,12 @@ void sdram_init(void)
- 		2 << EMC_DMCR_TCL_BIT	/* CAS latency is 3 */
- 	};
- 
--	int div[] = {1, 2, 3, 4, 6, 8, 12, 16, 24, 32};
--
- 	cpu_clk = CONFIG_SYS_CPU_SPEED;
--	mem_clk = cpu_clk * div[__cpm_get_cdiv()] / div[__cpm_get_mdiv()];
-+	mem_clk = 84000000;
- 
- 	writel(0, &emc->bcr);	/* Disable bus release */
- 	writew(0, &emc->rtcsr);	/* Disable clock for counting */
- 
--	/* Fault DMCR value for mode register setting*/
--#define SDRAM_ROW0	11
--#define SDRAM_COL0	8
--#define SDRAM_BANK40	0
--
--	dmcr0 = ((SDRAM_ROW0 - 11) << EMC_DMCR_RA_BIT) |
--		((SDRAM_COL0 - 8) << EMC_DMCR_CA_BIT) |
--		(SDRAM_BANK40 << EMC_DMCR_BA_BIT) |
--		(SDRAM_BW16 << EMC_DMCR_BW_BIT) |
--		EMC_DMCR_EPIN |
--		cas_latency_dmcr[((SDRAM_CASL == 3) ? 1 : 0)];
--
- 	/* Basic DMCR value */
- 	dmcr = ((SDRAM_ROW - 11) << EMC_DMCR_RA_BIT) |
- 		((SDRAM_COL - 8) << EMC_DMCR_CA_BIT) |
-@@ -128,31 +105,31 @@ void sdram_init(void)
- 	if (tmp > 11)
- 		tmp = 11;
- 	dmcr |= (tmp - 4) << EMC_DMCR_TRAS_BIT;
--	tmp = SDRAM_RCD / ns;
- 
-+	tmp = SDRAM_RCD / ns;
- 	if (tmp > 3)
- 		tmp = 3;
- 	dmcr |= tmp << EMC_DMCR_RCD_BIT;
--	tmp = SDRAM_TPC / ns;
- 
-+	tmp = SDRAM_TPC / ns;
- 	if (tmp > 7)
- 		tmp = 7;
- 	dmcr |= tmp << EMC_DMCR_TPC_BIT;
--	tmp = SDRAM_TRWL / ns;
- 
-+	tmp = SDRAM_TRWL / ns;
- 	if (tmp > 3)
- 		tmp = 3;
- 	dmcr |= tmp << EMC_DMCR_TRWL_BIT;
--	tmp = (SDRAM_TRAS + SDRAM_TPC) / ns;
- 
-+	tmp = (SDRAM_TRAS + SDRAM_TPC) / ns;
- 	if (tmp > 14)
- 		tmp = 14;
- 	dmcr |= ((tmp + 1) >> 1) << EMC_DMCR_TRC_BIT;
- 
- 	/* SDRAM mode value */
--	sdmode = EMC_SDMR_BT_SEQ |
--		 EMC_SDMR_OM_NORMAL |
--		 EMC_SDMR_BL_4 |
-+	sdmode = EMC_SDMR_BT_SEQ	|
-+		 EMC_SDMR_OM_NORMAL	|
-+		 EMC_SDMR_BL_4		|
- 		 cas_latency_sdmr[((SDRAM_CASL == 3) ? 1 : 0)];
- 
- 	/* Stage 1. Precharge all banks by writing SDMR with DMCR.MRSET=0 */
-@@ -172,8 +149,8 @@ void sdram_init(void)
- 	if (tmp > 0xff)
- 		tmp = 0xff;
- 	writew(tmp, &emc->rtcor);
-+
- 	writew(0, &emc->rtcnt);
--	/* Divisor is 64, CKO/64 */
- 	writew(EMC_RTCSR_CKS_64, &emc->rtcsr);
- 
- 	/* Wait for number of auto-refresh cycles */
-@@ -182,13 +159,17 @@ void sdram_init(void)
- 		;
- 
- 	/* Stage 3. Mode Register Set */
-+	dmcr0 = (11 << EMC_DMCR_RA_BIT)	|
-+		(8 << EMC_DMCR_CA_BIT)	|
-+		(0 << EMC_DMCR_BA_BIT)	|
-+		EMC_DMCR_EPIN		|
-+		(SDRAM_BW16 << EMC_DMCR_BW_BIT) |
-+		cas_latency_dmcr[((SDRAM_CASL == 3) ? 1 : 0)];
- 	writel(dmcr0 | EMC_DMCR_RFSH | EMC_DMCR_MRSET, &emc->dmcr);
- 	writeb(0, JZ4740_EMC_SDMR0 | sdmode);
- 
- 	/* Set back to basic DMCR value */
- 	writel(dmcr | EMC_DMCR_RFSH | EMC_DMCR_MRSET, &emc->dmcr);
--
--	/* everything is ok now */
- }
- 
- DECLARE_GLOBAL_DATA_PTR;
-@@ -232,9 +213,10 @@ void rtc_init(void)
- phys_size_t initdram(int board_type)
- {
- 	struct jz4740_emc *emc = (struct jz4740_emc *)JZ4740_EMC_BASE;
--	u32 dmcr;
--	u32 rows, cols, dw, banks;
--	ulong size;
-+
-+	unsigned int dmcr;
-+	unsigned int rows, cols, dw, banks;
-+	unsigned long size;
- 
- 	dmcr = readl(&emc->dmcr);
- 	rows = 11 + ((dmcr & EMC_DMCR_RA_MASK) >> EMC_DMCR_RA_BIT);
-diff --git a/arch/mips/cpu/xburst/spl/Makefile b/arch/mips/cpu/xburst/spl/Makefile
-new file mode 100644
-index 0000000..f45e8c8
---- /dev/null
-+++ b/arch/mips/cpu/xburst/spl/Makefile
-@@ -0,0 +1,47 @@
-+#
-+# Copyright (C) 2011 Xiangfu Liu <xiangfu@openmobilefree.net>
-+#
-+# See file CREDITS for list of people who contributed to this
-+# project.
-+#
-+# 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, write to the Free Software
-+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
-+# MA 02111-1307 USA
-+#
-+
-+include $(TOPDIR)/config.mk
-+
-+LIB	= $(obj)lib$(CPU).o
-+
-+START	= start.o
-+SOBJS-y	=
-+COBJS-y	=
-+
-+SRCS	:= $(START:.o=.S) $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c)
-+OBJS	:= $(addprefix $(obj),$(SOBJS-y) $(COBJS-y))
-+START	:= $(addprefix $(obj),$(START))
-+
-+all:	$(obj).depend $(START) $(LIB)
-+
-+$(LIB):	$(OBJS)
-+	$(call cmd_link_o_target, $(OBJS))
-+
-+#########################################################################
-+
-+# defines $(obj).depend target
-+include $(SRCTREE)/rules.mk
-+
-+sinclude $(obj).depend
-+
-+#########################################################################
-diff --git a/arch/mips/cpu/xburst/spl/start.S b/arch/mips/cpu/xburst/spl/start.S
-new file mode 100644
-index 0000000..e31c4c8
---- /dev/null
-+++ b/arch/mips/cpu/xburst/spl/start.S
-@@ -0,0 +1,63 @@
-+/*
-+ * Copyright (c) 2010 Xiangfu Liu <xiangfu@openmobilefree.net>
-+ *
-+ * See file CREDITS for list of people who contributed to this
-+ * project.
-+ *
-+ * 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, write to the Free Software
-+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
-+ * MA 02111-1307 USA
-+ */
-+
-+#include <config.h>
-+#include <version.h>
-+#include <asm/regdef.h>
-+#include <asm/mipsregs.h>
-+#include <asm/addrspace.h>
-+#include <asm/cacheops.h>
-+
-+#include <asm/jz4740.h>
-+
-+	.set noreorder
-+
-+	.globl _start
-+	.text
-+_start:
-+	.word JZ4740_NANDBOOT_CFG /* fetched during NAND Boot */
-+reset:
-+	/*
-+	 * STATUS register
-+	 * CU0=UM=EXL=IE=0, BEV=ERL=1, IP2~7=1
-+	 */
-+	li	t0, 0x0040FC04
-+	mtc0	t0, CP0_STATUS
-+	/*
-+	 * CAUSE register
-+	 * IV=1, use the specical interrupt vector (0x200)
-+	 */
-+	li	t1, 0x00800000
-+	mtc0	t1, CP0_CAUSE
-+
-+	bal     1f
-+	 nop
-+	.word   _GLOBAL_OFFSET_TABLE_
-+1:
-+	move    gp, ra
-+	lw      t1, 0(ra)
-+	move	gp, t1
-+
-+	la	sp, 0x80004000
-+	la	t9, nand_spl_boot
-+	j	t9
-+	nop
-diff --git a/board/qi/qi_lb60/Makefile b/board/qi/qi_lb60/Makefile
-index 5dae11b..e399246 100644
---- a/board/qi/qi_lb60/Makefile
-+++ b/board/qi/qi_lb60/Makefile
-@@ -22,7 +22,11 @@ include $(TOPDIR)/config.mk
- 
- LIB	= $(obj)lib$(BOARD).o
- 
-+ifeq ($(CONFIG_SPL_BUILD),y)
-+COBJS	:= $(BOARD)-spl.o
-+else
- COBJS	:= $(BOARD).o
-+endif
- 
- SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
- OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
-diff --git a/board/qi/qi_lb60/qi_lb60-spl.c b/board/qi/qi_lb60/qi_lb60-spl.c
-new file mode 100644
-index 0000000..3fe3fa3
---- /dev/null
-+++ b/board/qi/qi_lb60/qi_lb60-spl.c
-@@ -0,0 +1,30 @@
-+/*
-+ * Authors: Xiangfu Liu <xiangfu@openmobilefree.cc>
-+ *
-+ * 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.
-+ */
-+
-+#include <common.h>
-+#include <nand.h>
-+#include <asm/io.h>
-+#include <asm/jz4740.h>
-+
-+void nand_spl_boot(void)
-+{
-+	__gpio_as_sdram_16bit_4720();
-+	__gpio_as_uart0();
-+	__gpio_jtag_to_uart0();
-+
-+	serial_init();
-+
-+	pll_init();
-+	sdram_init();
-+
-+	nand_init();
-+
-+	puts("\nQi LB60 SPL: Starting U-Boot ...\n");
-+	nand_boot();
-+}
-diff --git a/board/qi/qi_lb60/qi_lb60.c b/board/qi/qi_lb60/qi_lb60.c
-index d975209..3bd4e2f 100644
---- a/board/qi/qi_lb60/qi_lb60.c
-+++ b/board/qi/qi_lb60/qi_lb60.c
-@@ -1,5 +1,5 @@
- /*
-- * Authors: Xiangfu Liu <xiangfu@sharism.cc>
-+ * Authors: Xiangfu Liu <xiangfu@openmobilefree.net>
-  *
-  * This program is free software; you can redistribute it and/or
-  * modify it under the terms of the GNU General Public License
-@@ -97,8 +97,10 @@ int board_early_init_f(void)
- /* U-Boot common routines */
- int checkboard(void)
- {
--	printf("Board: Qi LB60 (Ingenic XBurst Jz4740 SoC, Speed %ld MHz)\n",
--	       gd->cpu_clk / 1000000);
-+	printf("Board: Qi LB60 (Ingenic XBurst Jz4740 SoC)\n");
-+	printf(" CPU: %ld\n", gd->cpu_clk);
-+	printf(" MEM: %ld\n", gd->mem_clk);
-+	printf(" DEV: %ld\n", gd->dev_clk);
- 
- 	return 0;
- }
-diff --git a/board/qi/qi_lb60/u-boot-spl.lds b/board/qi/qi_lb60/u-boot-spl.lds
-new file mode 100644
-index 0000000..930537f
---- /dev/null
-+++ b/board/qi/qi_lb60/u-boot-spl.lds
-@@ -0,0 +1,61 @@
-+/*
-+ * (C) Copyright 2012 Xiangfu Liu <xiangfu@openmobilefree.net>
-+ *
-+ * 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, write to the Free Software
-+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
-+ * MA 02111-1307 USA
-+ */
-+
-+OUTPUT_FORMAT("elf32-tradlittlemips", "elf32-tradlittlemips", "elf32-tradlittlemips")
-+
-+OUTPUT_ARCH(mips)
-+ENTRY(_start)
-+SECTIONS
-+{
-+	. = 0x80000000;
-+	. = ALIGN(4);
-+	.text :
-+	{
-+	  *(.text)
-+	}
-+
-+	. = ALIGN(4);
-+	.rodata  : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
-+
-+	. = ALIGN(4);
-+	.data  : { *(.data) }
-+
-+	. = ALIGN(4);
-+	.sdata  : { *(.sdata) }
-+
-+	_gp = ALIGN(16);
-+
-+	__got_start = .;
-+	.got  : { *(.got) }
-+	__got_end = .;
-+
-+	. = .;
-+	__u_boot_cmd_start = .;
-+	.u_boot_cmd : { *(.u_boot_cmd) }
-+	__u_boot_cmd_end = .;
-+
-+	uboot_end_data = .;
-+	num_got_entries = (__got_end - __got_start) >> 2;
-+
-+	. = ALIGN(4);
-+	.sbss  : { *(.sbss) }
-+	.bss  : { *(.bss) }
-+	uboot_end = .;
-+}
-+ASSERT(uboot_end <= 0x80002000, "NAND bootstrap too big");
-diff --git a/drivers/mtd/nand/jz4740_nand.c b/drivers/mtd/nand/jz4740_nand.c
-index 3ec34f3..24a4921 100644
---- a/drivers/mtd/nand/jz4740_nand.c
-+++ b/drivers/mtd/nand/jz4740_nand.c
-@@ -15,6 +15,9 @@
- #include <asm/io.h>
- #include <asm/jz4740.h>
- 
-+#ifdef CONFIG_SPL_BUILD
-+#define printf(s) puts(s)
-+#endif
- #define JZ_NAND_DATA_ADDR ((void __iomem *)0xB8000000)
- #define JZ_NAND_CMD_ADDR (JZ_NAND_DATA_ADDR + 0x8000)
- #define JZ_NAND_ADDR_ADDR (JZ_NAND_DATA_ADDR + 0x10000)
-@@ -176,7 +179,7 @@ static int jz_nand_rs_correct_data(struct mtd_info *mtd, u_char *dat,
- 		for (k = 0; k < 9; k++)
- 			writeb(read_ecc[k], &emc->nfpar[k]);
- 	}
--	/* Set PRDY */
-+
- 	writel(readl(&emc->nfecr) | EMC_NFECR_PRDY, &emc->nfecr);
- 
- 	/* Wait for completion */
-@@ -184,7 +187,7 @@ static int jz_nand_rs_correct_data(struct mtd_info *mtd, u_char *dat,
- 		status = readl(&emc->nfints);
- 	} while (!(status & EMC_NFINTS_DECF));
- 
--	/* disable ecc */
-+	/* Disable ECC */
- 	writel(readl(&emc->nfecr) & ~EMC_NFECR_ECCE, &emc->nfecr);
- 
- 	/* Check decoding */
-@@ -192,7 +195,7 @@ static int jz_nand_rs_correct_data(struct mtd_info *mtd, u_char *dat,
- 		return 0;
- 
- 	if (status & EMC_NFINTS_UNCOR) {
--		printf("uncorrectable ecc\n");
-+		printf("JZ4740 uncorrectable ECC\n");
- 		return -1;
- 	}
- 
-@@ -230,6 +233,32 @@ static int jz_nand_rs_correct_data(struct mtd_info *mtd, u_char *dat,
- 	return errcnt;
- }
- 
-+#ifdef CONFIG_SPL_BUILD
-+static void jz_nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
-+{
-+	int i;
-+	struct nand_chip *this = mtd->priv;
-+
-+#if (JZ4740_NANDBOOT_CFG == JZ4740_NANDBOOT_B16R3) || \
-+	(JZ4740_NANDBOOT_CFG == JZ4740_NANDBOOT_B16R2)
-+	for (i = 0; i < len; i += 2)
-+		buf[i] = readw(this->IO_ADDR_R);
-+#elif (JZ4740_NANDBOOT_CFG == JZ4740_NANDBOOT_B8R3) || \
-+	(JZ4740_NANDBOOT_CFG == JZ4740_NANDBOOT_B8R2)
-+	for (i = 0; i < len; i++)
-+		buf[i] = readb(this->IO_ADDR_R);
-+#else
-+	#error JZ4740_NANDBOOT_CFG not defined or wrong
-+#endif
-+}
-+
-+static uint8_t jz_nand_read_byte(struct mtd_info *mtd)
-+{
-+	struct nand_chip *this = mtd->priv;
-+	return readb(this->IO_ADDR_R);
-+}
-+#endif
-+
- /*
-  * Main initialization routine
-  */
-@@ -254,6 +283,10 @@ int board_nand_init(struct nand_chip *nand)
- 	nand->ecc.size		= CONFIG_SYS_NAND_ECCSIZE;
- 	nand->ecc.bytes		= CONFIG_SYS_NAND_ECCBYTES;
- 	nand->ecc.layout	= &qi_lb60_ecclayout_2gb;
-+#ifdef CONFIG_SPL_BUILD
-+	nand->read_byte		= jz_nand_read_byte;
-+	nand->read_buf		= jz_nand_read_buf;
-+#endif
- 	nand->chip_delay	= 50;
- 	nand->options		= NAND_USE_FLASH_BBT;
- 
-diff --git a/include/configs/qi_lb60.h b/include/configs/qi_lb60.h
-index 4bb5bbc..7bff444 100644
---- a/include/configs/qi_lb60.h
-+++ b/include/configs/qi_lb60.h
-@@ -1,5 +1,5 @@
- /*
-- * Authors: Xiangfu Liu <xiangfu.z@gmail.com>
-+ * Authors: Xiangfu Liu <xiangfu@openmobilefree.net>
-  *
-  * This program is free software; you can redistribute it and/or
-  * modify it under the terms of the GNU General Public License
-@@ -14,7 +14,6 @@
- #define CONFIG_SYS_LITTLE_ENDIAN
- #define CONFIG_JZSOC		/* Jz SoC */
- #define CONFIG_JZ4740		/* Jz4740 SoC */
--#define CONFIG_NAND_JZ4740
- 
- #define CONFIG_SYS_CPU_SPEED	336000000	/* CPU clock: 336 MHz */
- #define CONFIG_SYS_EXTAL	12000000	/* EXTAL freq: 12 MHz */
-@@ -24,24 +23,43 @@
- #define CONFIG_SYS_UART_BASE	JZ4740_UART0_BASE /* Base of the UART channel */
- #define CONFIG_BAUDRATE		57600
- 
-+#define CONFIG_BOOTP_MASK	(CONFIG_BOOTP_DEFAUL)
-+#define CONFIG_BOOTDELAY	0
-+#define CONFIG_BOOTARGS "mem=32M console=tty0 console=ttyS0,57600n8 ubi.mtd=2 rootfstype=ubifs root=ubi0:rootfs rw rootwait"
-+#define CONFIG_BOOTCOMMAND	"nand read 0x80600000 0x400000 0x280000;bootm"
-+
-+/*
-+ * Miscellaneous configurable options
-+ */
-+#define CONFIG_SYS_SDRAM_BASE		0x80000000	/* Cached addr */
-+#define CONFIG_SYS_INIT_SP_OFFSET	0x400000
-+#define CONFIG_SYS_LOAD_ADDR		0x80600000
-+#define CONFIG_SYS_MEMTEST_START	0x80100000
-+#define CONFIG_SYS_MEMTEST_END		0x80A00000
-+#define CONFIG_SYS_TEXT_BASE		0x80100000
-+#define CONFIG_SYS_MONITOR_BASE		CONFIG_SYS_TEXT_BASE
-+
-+#define CONFIG_SYS_MALLOC_LEN		(4 * 1024 * 1024)
-+#define CONFIG_SYS_BOOTPARAMS_LEN	(128 * 1024)
-+
-+#define CONFIG_SYS_CBSIZE	256 /* Console I/O Buffer Size */
-+#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE + sizeof(CONFIG_SYS_PROMPT) + 16)
-+
-+#define CONFIG_SYS_LONGHELP
-+#define CONFIG_SYS_MAXARGS	16
-+#define CONFIG_SYS_PROMPT	"NanoNote# "
-+
- #define CONFIG_SKIP_LOWLEVEL_INIT
- #define CONFIG_BOARD_EARLY_INIT_F
- #define CONFIG_SYS_NO_FLASH
- #define CONFIG_SYS_FLASH_BASE	0 /* init flash_base as 0 */
--#define CONFIG_ENV_OVERWRITE
--
--#define CONFIG_BOOTP_MASK	(CONFIG_BOOTP_DEFAUL)
--#define CONFIG_BOOTDELAY	0
--#define CONFIG_BOOTARGS		"mem=32M console=tty0 console=ttyS0,57600n8 ubi.mtd=2 rootfstype=ubifs root=ubi0:rootfs rw rootwait"
--#define CONFIG_BOOTCOMMAND	"nand read 0x80600000 0x400000 0x200000;bootm"
- 
- /*
-- * Command line configuration.
-+ * Command line configuration
-  */
- #define CONFIG_CMD_BOOTD	/* bootd			*/
- #define CONFIG_CMD_CONSOLE	/* coninfo			*/
- #define CONFIG_CMD_ECHO		/* echo arguments		*/
--
- #define CONFIG_CMD_LOADB	/* loadb			*/
- #define CONFIG_CMD_LOADS	/* loads			*/
- #define CONFIG_CMD_MEMORY	/* md mm nm mw cp cmp crc base loop mtest */
-@@ -58,45 +76,16 @@
- #define CONFIG_LOADS_ECHO	1	/* echo on for serial download */
- 
- /*
-- * Miscellaneous configurable options
-- */
--#define CONFIG_SYS_MAXARGS 16
--#define CONFIG_SYS_LONGHELP
--#define CONFIG_SYS_PROMPT "NanoNote# "
--#define CONFIG_SYS_CBSIZE 256 /* Console I/O Buffer Size */
--#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE + sizeof(CONFIG_SYS_PROMPT) + 16)
--
--#define CONFIG_SYS_MALLOC_LEN		(4 * 1024 * 1024)
--#define CONFIG_SYS_BOOTPARAMS_LEN	(128 * 1024)
--
--#define CONFIG_SYS_SDRAM_BASE		0x80000000	/* Cached addr */
--#define CONFIG_SYS_INIT_SP_OFFSET	0x400000
--#define CONFIG_SYS_LOAD_ADDR		0x80600000
--#define CONFIG_SYS_MEMTEST_START	0x80100000
--#define CONFIG_SYS_MEMTEST_END		0x80800000
--
--/*
-- * Environment
-+ * NAND driver configuration
-  */
--#define CONFIG_ENV_IS_IN_NAND		/* use NAND for environment vars */
--
--#define CONFIG_SYS_NAND_5_ADDR_CYCLE
--/*
-- * if board nand flash is 1GB, set to 1
-- * if board nand flash is 2GB, set to 2
-- * for change the PAGE_SIZE and BLOCK_SIZE
-- * will delete when there is no 1GB flash
-- */
--#define NANONOTE_NAND_SIZE	2
--
--#define CONFIG_SYS_NAND_PAGE_SIZE	(2048 * NANONOTE_NAND_SIZE)
--#define CONFIG_SYS_NAND_BLOCK_SIZE	(256 * NANONOTE_NAND_SIZE << 10)
--/* nand bad block was marked at this page in a block, start from 0 */
-+#define CONFIG_NAND_JZ4740
-+#define CONFIG_SYS_NAND_PAGE_SIZE	4096
-+#define CONFIG_SYS_NAND_BLOCK_SIZE	(512 << 10)
-+/* NAND bad block was marked at this page in a block, start from 0 */
- #define CONFIG_SYS_NAND_BADBLOCK_PAGE	127
- #define CONFIG_SYS_NAND_PAGE_COUNT	128
- #define CONFIG_SYS_NAND_BAD_BLOCK_POS	0
--/* ECC offset position in oob area, default value is 6 if it isn't defined */
--#define CONFIG_SYS_NAND_ECC_POS		(6 * NANONOTE_NAND_SIZE)
-+#define CONFIG_SYS_NAND_ECC_POS		12
- #define CONFIG_SYS_NAND_ECCSIZE		512
- #define CONFIG_SYS_NAND_ECCBYTES	9
- #define CONFIG_SYS_NAND_ECCPOS		\
-@@ -115,10 +104,9 @@
- #define CONFIG_SYS_ONENAND_BASE		CONFIG_SYS_NAND_BASE
- #define CONFIG_SYS_MAX_NAND_DEVICE	1
- #define CONFIG_SYS_NAND_SELECT_DEVICE	1 /* nand driver supports mutipl.*/
--#define CONFIG_NAND_SPL_TEXT_BASE	0x80000000
- 
- /*
-- * IPL (Initial Program Loader, integrated inside CPU)
-+ * IPL (Initial Program Loader, integrated inside Ingenic Xburst JZ4740 CPU)
-  * Will load first 8k from NAND (SPL) into cache and execute it from there.
-  *
-  * SPL (Secondary Program Loader)
-@@ -130,77 +118,88 @@
-  * NUB (NAND U-Boot)
-  * This NAND U-Boot (NUB) is a special U-Boot version which can be started
-  * from RAM. Therefore it mustn't (re-)configure the SDRAM controller.
-- *
-  */
-+
-+/*
-+ * NAND SPL configuration
-+ */
-+#define CONFIG_SPL
-+#define CONFIG_SPL_LIBGENERIC_SUPPORT
-+#define CONFIG_SPL_LIBCOMMON_SUPPORT
-+#define CONFIG_SPL_NAND_LOAD
-+#define CONFIG_SPL_NAND_SIMPLE
-+#define CONFIG_SPL_NAND_SUPPORT
-+#define CONFIG_SPL_TEXT_BASE	0x80000000
-+#define CONFIG_SPL_START_S_PATH	"arch/mips/cpu/xburst/spl"
-+
-+#define CONFIG_SYS_NAND_5_ADDR_CYCLE
-+#define CONFIG_SYS_NAND_HW_ECC_OOBFIRST
-+#define JZ4740_NANDBOOT_CFG		JZ4740_NANDBOOT_B8R3
-+
- #define CONFIG_SYS_NAND_U_BOOT_DST	0x80100000 /* Load NUB to this addr */
- #define CONFIG_SYS_NAND_U_BOOT_START	CONFIG_SYS_NAND_U_BOOT_DST
--/* Start NUB from this addr*/
-+					/* Start NUB from this addr */
-+#define CONFIG_SYS_NAND_U_BOOT_OFFS (32  << 10) /* Offset of NUB */
-+#define CONFIG_SYS_NAND_U_BOOT_SIZE (256 << 10) /* Size of NUB */
- 
- /*
-- * Define the partitioning of the NAND chip (only RAM U-Boot is needed here)
-+ * Environment configuration
-  */
--#define CONFIG_SYS_NAND_U_BOOT_OFFS (256 << 10) /* Offset to RAM U-Boot image */
--#define CONFIG_SYS_NAND_U_BOOT_SIZE (512 << 10) /* Size of RAM U-Boot image */
--
-+#define CONFIG_ENV_OVERWRITE
-+#define CONFIG_ENV_IS_IN_NAND
- #define CONFIG_ENV_SIZE		(4 << 10)
- #define CONFIG_ENV_OFFSET	\
- 	(CONFIG_SYS_NAND_BLOCK_SIZE + CONFIG_SYS_NAND_U_BOOT_SIZE)
- #define CONFIG_ENV_OFFSET_REDUND \
- 	(CONFIG_ENV_OFFSET  + CONFIG_SYS_NAND_BLOCK_SIZE)
- 
--#define CONFIG_SYS_TEXT_BASE	0x80100000
--#define CONFIG_SYS_MONITOR_BASE	CONFIG_SYS_TEXT_BASE
--
- /*
-- * SDRAM Info.
-+ * CPU cache configuration
-  */
--#define CONFIG_NR_DRAM_BANKS	1
-+#define CONFIG_SYS_DCACHE_SIZE		16384
-+#define CONFIG_SYS_ICACHE_SIZE		16384
-+#define CONFIG_SYS_CACHELINE_SIZE	32
- 
- /*
-- * Cache Configuration
-+ * SDRAM configuration
-  */
--#define CONFIG_SYS_DCACHE_SIZE	16384
--#define CONFIG_SYS_ICACHE_SIZE	16384
--#define CONFIG_SYS_CACHELINE_SIZE	32
-+#define CONFIG_NR_DRAM_BANKS	1
-+
-+#define SDRAM_BW16		1	/* Data bus width: 0-32bit, 1-16bit */
-+#define SDRAM_BANK4		1	/* Banks each chip: 0-2bank, 1-4bank */
-+#define SDRAM_ROW		13	/* Row address: 11 to 13 */
-+#define SDRAM_COL		9	/* Column address: 8 to 12 */
-+#define SDRAM_CASL		2	/* CAS latency: 2 or 3 */
-+#define SDRAM_TRAS		45	/* RAS# Active Time */
-+#define SDRAM_RCD		20	/* RAS# to CAS# Delay */
-+#define SDRAM_TPC		20	/* RAS# Precharge Time */
-+#define SDRAM_TRWL		7	/* Write Latency Time */
-+#define SDRAM_TREF		15625	/* Refresh period: 8192 cycles/64ms */
- 
- /*
-- * GPIO definition
-+ * GPIO configuration
-  */
--#define GPIO_LCD_CS	(2 * 32 + 21)
--#define GPIO_AMP_EN	(3 * 32 + 4)
-+#define GPIO_LCD_CS		(2 * 32 + 21)
-+#define GPIO_AMP_EN		(3 * 32 + 4)
- 
--#define GPIO_SDPW_EN	(3 * 32 + 2)
--#define GPIO_SD_DETECT	(3 * 32 + 0)
-+#define GPIO_SDPW_EN		(3 * 32 + 2)
-+#define GPIO_SD_DETECT		(3 * 32 + 0)
- 
--#define GPIO_BUZZ_PWM	(3 * 32 + 27)
--#define GPIO_USB_DETECT	(3 * 32 + 28)
-+#define GPIO_BUZZ_PWM		(3 * 32 + 27)
-+#define GPIO_USB_DETECT		(3 * 32 + 28)
- 
--#define GPIO_AUDIO_POP	(1 * 32 + 29)
--#define GPIO_COB_TEST	(1 * 32 + 30)
-+#define GPIO_AUDIO_POP		(1 * 32 + 29)
-+#define GPIO_COB_TEST		(1 * 32 + 30)
- 
- #define GPIO_KEYOUT_BASE	(2 * 32 + 10)
--#define GPIO_KEYIN_BASE	(3 * 32 + 18)
--#define GPIO_KEYIN_8	(3 * 32 + 26)
-+#define GPIO_KEYIN_BASE		(3 * 32 + 18)
-+#define GPIO_KEYIN_8		(3 * 32 + 26)
- 
--#define GPIO_SD_CD_N	GPIO_SD_DETECT		/* SD Card insert detect */
-+#define GPIO_SD_CD_N		GPIO_SD_DETECT	/* SD Card insert detect */
- #define GPIO_SD_VCC_EN_N	GPIO_SDPW_EN	/* SD Card Power Enable */
- 
- #define SPEN	GPIO_LCD_CS	/* LCDCS :Serial command enable      */
- #define SPDA	(2 * 32 + 22)	/* LCDSCL:Serial command clock input */
- #define SPCK	(2 * 32 + 23)	/* LCDSDA:Serial command data input  */
- 
--/* SDRAM paramters */
--#define SDRAM_BW16		1	/* Data bus width: 0-32bit, 1-16bit */
--#define SDRAM_BANK4		1	/* Banks each chip: 0-2bank, 1-4bank */
--#define SDRAM_ROW		13	/* Row address: 11 to 13 */
--#define SDRAM_COL		9	/* Column address: 8 to 12 */
--#define SDRAM_CASL		2	/* CAS latency: 2 or 3 */
--
--/* SDRAM Timings, unit: ns */
--#define SDRAM_TRAS		45	/* RAS# Active Time */
--#define SDRAM_RCD		20	/* RAS# to CAS# Delay */
--#define SDRAM_TPC		20	/* RAS# Precharge Time */
--#define SDRAM_TRWL		7	/* Write Latency Time */
--#define SDRAM_TREF		15625	/* Refresh period: 8192 cycles/64ms */
--
- #endif
--- 
-1.7.9.5
-

+ 0 - 916
package/boot/uboot-xburst/patches/0002-qi_lb60-add-software-usbboot-support.patch

@@ -1,916 +0,0 @@
-From fa51192b912d296b8eec10f7d44c6c17eb1dd368 Mon Sep 17 00:00:00 2001
-From: Xiangfu <xiangfu@openmobilefree.net>
-Date: Fri, 12 Oct 2012 09:47:39 +0800
-Subject: [PATCH 2/6] qi_lb60: add software usbboot support
-
-  JZ4740 CPU have a internal ROM have such kind of code, that make
-  JZ4740 can boot from USB
-
-  usbboot.S can downloads user program from the USB port to internal
-  SRAM and branches to the internal SRAM to execute the program
-
-Signed-off-by: Xiangfu <xiangfu@openmobilefree.net>
----
- board/qi/qi_lb60/Makefile      |    1 +
- board/qi/qi_lb60/qi_lb60-spl.c |   20 +
- board/qi/qi_lb60/usbboot.S     |  838 ++++++++++++++++++++++++++++++++++++++++
- 3 files changed, 859 insertions(+)
- create mode 100644 board/qi/qi_lb60/usbboot.S
-
-diff --git a/board/qi/qi_lb60/Makefile b/board/qi/qi_lb60/Makefile
-index e399246..6dd8c6f 100644
---- a/board/qi/qi_lb60/Makefile
-+++ b/board/qi/qi_lb60/Makefile
-@@ -23,6 +23,7 @@ include $(TOPDIR)/config.mk
- LIB	= $(obj)lib$(BOARD).o
- 
- ifeq ($(CONFIG_SPL_BUILD),y)
-+SOBJS	:= usbboot.o
- COBJS	:= $(BOARD)-spl.o
- else
- COBJS	:= $(BOARD).o
-diff --git a/board/qi/qi_lb60/qi_lb60-spl.c b/board/qi/qi_lb60/qi_lb60-spl.c
-index 3fe3fa3..aea459c 100644
---- a/board/qi/qi_lb60/qi_lb60-spl.c
-+++ b/board/qi/qi_lb60/qi_lb60-spl.c
-@@ -12,6 +12,24 @@
- #include <asm/io.h>
- #include <asm/jz4740.h>
- 
-+#define KEY_U_OUT       (32 * 2 + 16)
-+#define KEY_U_IN        (32 * 3 + 19)
-+
-+extern void usb_boot(void);
-+
-+static void check_usb_boot(void)
-+{
-+	__gpio_as_input(KEY_U_IN);
-+	__gpio_enable_pull(KEY_U_IN);
-+	__gpio_as_output(KEY_U_OUT);
-+	__gpio_clear_pin(KEY_U_OUT);
-+
-+	if (!__gpio_get_pin(KEY_U_IN)) {
-+		puts("[U] pressed, goto USBBOOT mode\n");
-+		usb_boot();
-+	}
-+}
-+
- void nand_spl_boot(void)
- {
- 	__gpio_as_sdram_16bit_4720();
-@@ -23,6 +41,8 @@ void nand_spl_boot(void)
- 	pll_init();
- 	sdram_init();
- 
-+	check_usb_boot();
-+
- 	nand_init();
- 
- 	puts("\nQi LB60 SPL: Starting U-Boot ...\n");
-diff --git a/board/qi/qi_lb60/usbboot.S b/board/qi/qi_lb60/usbboot.S
-new file mode 100644
-index 0000000..c872266
---- /dev/null
-+++ b/board/qi/qi_lb60/usbboot.S
-@@ -0,0 +1,838 @@
-+/*
-+ *  for jz4740 usb boot
-+ *
-+ *  Copyright (c) 2009 Author: <jlwei@ingenic.cn>
-+ *
-+ * See file CREDITS for list of people who contributed to this
-+ * project.
-+ *
-+ * 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, write to the Free Software
-+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
-+ * MA 02111-1307 USA
-+ */
-+    .set noreorder
-+    .globl usb_boot
-+    .text
-+
-+/*
-+ * Both NAND and USB boot load data to D-Cache first, then transfer
-+ * data from D-Cache to I-Cache, and jump to execute the code in I-Cache.
-+ * So init caches first and then dispatch to a proper boot routine.
-+ */
-+
-+.macro load_addr reg addr
-+	li \reg, 0x80000000
-+	addiu \reg, \reg, \addr
-+	la $2, usbboot_begin
-+	subu \reg, \reg, $2
-+.endm
-+
-+usb_boot:
-+	/* Initialize PLL: set ICLK to 84MHz and HCLK to 42MHz. */
-+	la	$9, 0xB0000000		/* CPCCR: Clock Control Register */
-+	la	$8, 0x42041110		/* I:S:M:P=1:2:2:2 */
-+	sw	$8, 0($9)
-+
-+	la	$9, 0xB0000010		/* CPPCR: PLL Control Register */
-+	la	$8, 0x06000120		/* M=12 N=0 D=0 CLK=12*(M+2)/(N+2) */
-+	sw	$8, 0($9)
-+
-+	mtc0	$0, $26		/* CP0_ERRCTL, restore WST reset state */
-+	nop
-+
-+	mtc0	$0, $16			/* CP0_CONFIG */
-+	nop
-+
-+	/* Relocate code to beginning of the ram */
-+
-+	la $2, usbboot_begin
-+	la $3, usbboot_end
-+	li $4, 0x80000000
-+
-+1:
-+	lw $5, 0($2)
-+	sw $5, 0($4)
-+	addiu $2, $2, 4
-+	bne $2, $3, 1b
-+	addiu $4, $4, 4
-+
-+	li $2, 0x80000000
-+	ori $3, $2, 0
-+	addiu $3, $3, usbboot_end
-+	la $4, usbboot_begin
-+	subu $3, $3, $4
-+
-+
-+2:
-+	cache	0x0, 0($2)		/* Index_Invalidate_I */
-+	cache	0x1, 0($2)		/* Index_Writeback_Inv_D */
-+	addiu	$2, $2, 32
-+	subu $4, $3, $2
-+	bgtz	$4, 2b
-+	nop
-+
-+	load_addr $3, usb_boot_return
-+
-+	jr $3
-+
-+usbboot_begin:
-+
-+init_caches:
-+	li	$2, 3			/* cacheable for kseg0 access */
-+	mtc0	$2, $16			/* CP0_CONFIG */
-+	nop
-+
-+	li	$2, 0x20000000		/* enable idx-store-data cache insn */
-+	mtc0	$2, $26			/* CP0_ERRCTL */
-+
-+	ori	$2, $28, 0		/* start address */
-+	ori	$3, $2, 0x3fe0		/* end address, total 16KB */
-+	mtc0	$0, $28, 0		/* CP0_TAGLO */
-+	mtc0	$0, $28, 1		/* CP0_DATALO */
-+cache_clear_a_line:
-+	cache	0x8, 0($2)		/* Index_Store_Tag_I */
-+	cache	0x9, 0($2)		/* Index_Store_Tag_D */
-+	bne	$2, $3, cache_clear_a_line
-+	addiu	$2, $2, 32		/* increment CACHE_LINE_SIZE */
-+
-+	ori	$2, $28, 0		/* start address */
-+	ori	$3, $2, 0x3fe0		/* end address, total 16KB */
-+	la	$4, 0x1ffff000		/* physical address and 4KB page mask */
-+cache_alloc_a_line:
-+	and	$5, $2, $4
-+	ori	$5, $5, 1		/* V bit of the physical tag */
-+	mtc0	$5, $28, 0		/* CP0_TAGLO */
-+	cache	0x8, 0($2)		/* Index_Store_Tag_I */
-+	cache	0x9, 0($2)		/* Index_Store_Tag_D */
-+	bne	$2, $3, cache_alloc_a_line
-+	addiu	$2, $2, 32		/* increment CACHE_LINE_SIZE */
-+
-+	nop
-+	nop
-+	nop
-+	/*
-+	 * Transfer data from dcache to icache, then jump to icache.
-+	 * Input parameters:
-+	 * $19: data length in bytes
-+	 * $20: jump target address
-+	 */
-+xfer_d2i:
-+
-+	ori	$8, $20, 0
-+	addu	$9, $8, $19		/* total 16KB */
-+
-+1:
-+	cache	0x0, 0($8)		/* Index_Invalidate_I */
-+	cache	0x1, 0($8)		/* Index_Writeback_Inv_D */
-+	bne	$8, $9, 1b
-+	addiu	$8, $8, 32
-+
-+	/* flush write-buffer */
-+	sync
-+
-+	/* Invalidate BTB */
-+	mfc0	$8, $16, 7		/* CP0_CONFIG */
-+	nop
-+	ori	$8, 2
-+	mtc0	$8, $16, 7
-+	nop
-+
-+	/* Overwrite config to disable ram initalisation */
-+	li $2, 0xff
-+	sb $2, 20($20)
-+
-+	jalr	$20
-+	nop
-+
-+icache_return:
-+	/* User code can return to here after executing itself in
-+	  icache, by jumping to $31. */
-+	b	usb_boot_return
-+	nop
-+
-+
-+usb_boot_return:
-+	/* Enable the USB PHY */
-+	la	$9, 0xB0000024		/* CPM_SCR */
-+	lw	$8, 0($9)
-+	ori	$8, 0x40		/* USBPHY_ENABLE */
-+	sw	$8, 0($9)
-+
-+	/* Initialize USB registers */
-+	la	$27, 0xb3040000	/* USB registers base address */
-+
-+	sb	$0, 0x0b($27)	/* INTRUSBE: disable common USB interrupts */
-+	sh	$0, 0x06($27)	/* INTRINE: disable EPIN interrutps */
-+	sh	$0, 0x08($27)	/* INTROUTE: disable EPOUT interrutps */
-+
-+	li	$9, 0x61
-+	sb	$9, 0x01($27)	/* POWER: HSENAB | SUSPENDM | SOFTCONN */
-+
-+	/* Initialize USB states */
-+	li	$22, 0			/* set EP0 to IDLE state */
-+	li	$23, 1			/* no data stage */
-+
-+	/* Main loop of polling the usb commands */
-+usb_command_loop:
-+	lbu	$9, 0x0a($27)		/* read INTRUSB */
-+	andi	$9, 0x04		/* check USB_INTR_RESET */
-+	beqz	$9, check_intr_ep0in
-+	nop
-+
-+ 	/* 1. Handle USB reset interrupt */
-+handle_reset_intr:
-+	lbu	$9, 0x01($27)		/* read POWER */
-+	andi	$9, 0x10		/* test HS_MODE */
-+	bnez	$9, _usb_set_maxpktsize
-+	li	$9, 512			/* max packet size of HS mode */
-+	li	$9, 64			/* max packet size of FS mode */
-+
-+_usb_set_maxpktsize:
-+	li	$8, 1
-+	sb	$8, 0x0e($27)		/* set INDEX 1 */
-+
-+	sh	$9, 0x10($27)		/* INMAXP */
-+	sb	$0, 0x13($27)		/* INCSRH */
-+	sh	$9, 0x14($27)		/* OUTMAXP */
-+	sb	$0, 0x17($27)		/* OUTCSRH */
-+
-+_usb_flush_fifo:
-+	li	$8, 0x48		/* INCSR_CDT && INCSR_FF */
-+	sb	$8, 0x12($27)		/* INCSR */
-+	li	$8, 0x90		/* OUTCSR_CDT && OUTCSR_FF */
-+	sb	$8, 0x16($27)		/* OUTCSR */
-+
-+	li	$22, 0			/* set EP0 to IDLE state */
-+	li	$23, 1			/* no data stage */
-+
-+	/* 2. Check and handle EP0 interrupt */
-+check_intr_ep0in:
-+	lhu	$10, 0x02($27)		/* read INTRIN */
-+	andi	$9, $10, 0x1		/* check EP0 interrupt */
-+	beqz	$9, check_intr_ep1in
-+	nop
-+
-+handle_ep0_intr:
-+	sb	$0, 0x0e($27)		/* set INDEX 0 */
-+	lbu	$11, 0x12($27)		/* read CSR0 */
-+
-+	andi	$9, $11, 0x04		/* check SENTSTALL */
-+	beqz	$9, _ep0_setupend
-+	nop
-+
-+_ep0_sentstall:
-+	andi	$9, $11, 0xdb
-+	sb	$9, 0x12($27)		/* clear SENDSTALL and SENTSTALL */
-+	li	$22, 0			/* set EP0 to IDLE state */
-+
-+_ep0_setupend:
-+	andi	$9, $11, 0x10		/* check SETUPEND */
-+	beqz	$9, ep0_idle_state
-+	nop
-+
-+	ori	$9, $11, 0x80
-+	sb	$9, 0x12($27)		/* set SVDSETUPEND */
-+	li	$22, 0			/* set EP0 to IDLE state */
-+
-+ep0_idle_state:
-+	bnez	$22, ep0_tx_state
-+	nop
-+
-+	/* 2.1 Handle EP0 IDLE state interrupt */
-+	andi	$9, $11, 0x01		/* check OUTPKTRDY */
-+	beqz	$9, check_intr_ep1in
-+	nop
-+
-+	/* Read 8-bytes setup packet from the FIFO */
-+	lw	$25, 0x20($27)		/* first word of setup packet */
-+	lw	$26, 0x20($27)		/* second word of setup packet */
-+
-+	andi	$9, $25, 0x60		/* bRequestType & USB_TYPE_MASK */
-+	beqz	$9, _ep0_std_req
-+	nop
-+
-+	/* 2.1.1 Vendor-specific setup request */
-+_ep0_vend_req:
-+	li	$22, 0			/* set EP0 to IDLE state */
-+	li	$23, 1			/* NoData = 1 */
-+
-+	andi	$9, $25, 0xff00		/* check bRequest */
-+	srl	$9, $9, 8
-+	beqz	$9, __ep0_get_cpu_info
-+	sub	$8, $9, 0x1
-+	beqz	$8, __ep0_set_data_address
-+	sub	$8, $9, 0x2
-+	beqz	$8, __ep0_set_data_length
-+	sub	$8, $9, 0x3
-+	beqz	$8, __ep0_flush_caches
-+	sub	$8, $9, 0x4
-+	beqz	$8, __ep0_prog_start1
-+	sub	$8, $9, 0x5
-+	beqz	$8, __ep0_prog_start2
-+	nop
-+	b	_ep0_idle_state_fini	/* invalid request */
-+	nop
-+
-+__ep0_get_cpu_info:
-+	load_addr $20, cpu_info_data	/* data pointer to transfer */
-+	li	$21, 8			/* bytes left to transfer */
-+	li	$22, 1			/* set EP0 to TX state */
-+	li	$23, 0			/* NoData = 0 */
-+
-+	b	_ep0_idle_state_fini
-+	nop
-+
-+__ep0_set_data_address:
-+	li	$9, 0xffff0000
-+	and	$9, $25, $9
-+	andi	$8, $26, 0xffff
-+	or	$20, $9, $8		/* data address of next transfer */
-+
-+	b	_ep0_idle_state_fini
-+	nop
-+
-+__ep0_set_data_length:
-+	li	$9, 0xffff0000
-+	and	$9, $25, $9
-+	andi	$8, $26, 0xffff
-+	or	$21, $9, $8		/* data length of next transfer */
-+
-+	li	$9, 0x48		/* SVDOUTPKTRDY and DATAEND */
-+	sb	$9, 0x12($27)		/* CSR0 */
-+
-+	/* We must write packet to FIFO before EP1-IN interrupt here. */
-+	b	handle_epin1_intr
-+	nop
-+
-+__ep0_flush_caches:
-+	/* Flush dcache and invalidate icache. */
-+	li	$8, 0x80000000
-+	addi	$9, $8, 0x3fe0		/* total 16KB */
-+
-+1:
-+	cache	0x0, 0($8)		/* Index_Invalidate_I */
-+	cache	0x1, 0($8)		/* Index_Writeback_Inv_D */
-+	bne	$8, $9, 1b
-+	addiu	$8, $8, 32
-+
-+	/* flush write-buffer */
-+	sync
-+
-+	/* Invalidate BTB */
-+	mfc0	$8, $16, 7		/* CP0_CONFIG */
-+	nop
-+	ori	$8, 2
-+	mtc0	$8, $16, 7
-+	nop
-+
-+	b	_ep0_idle_state_fini
-+	nop
-+
-+__ep0_prog_start1:
-+	li	$9, 0x48		/* SVDOUTPKTRDY and DATAEND */
-+	sb	$9, 0x12($27)		/* CSR0 */
-+
-+	li	$9, 0xffff0000
-+	and	$9, $25, $9
-+	andi	$8, $26, 0xffff
-+	or	$20, $9, $8		/* target address */
-+
-+	b	xfer_d2i
-+	li	$19, 0x2000		/* 16KB data length */
-+
-+__ep0_prog_start2:
-+	li	$9, 0x48		/* SVDOUTPKTRDY and DATAEND */
-+	sb	$9, 0x12($27)		/* CSR0 */
-+
-+	li	$9, 0xffff0000
-+	and	$9, $25, $9
-+	andi	$8, $26, 0xffff
-+	or	$20, $9, $8		/* target address */
-+
-+	jalr	$20		/* jump, and place the return address in $31 */
-+	nop
-+
-+__ep0_prog_start2_return:
-+/* User code can return to here after executing itself, by jumping to $31 */
-+	b	usb_boot_return
-+	nop
-+
-+	/* 2.1.2 Standard setup request */
-+_ep0_std_req:
-+	andi	$12, $25, 0xff00	/* check bRequest */
-+	srl	$12, $12, 8
-+	sub	$9, $12, 0x05		/* check USB_REQ_SET_ADDRESS */
-+	bnez	$9, __ep0_req_set_config
-+	nop
-+
-+	/* Handle USB_REQ_SET_ADDRESS */
-+__ep0_req_set_addr:
-+	srl	$9, $25, 16		/* get wValue */
-+	sb	$9, 0x0($27)		/* set FADDR */
-+	li	$23, 1			/* NoData = 1 */
-+	b	_ep0_idle_state_fini
-+	nop
-+
-+__ep0_req_set_config:
-+	sub	$9, $12, 0x09		/* check USB_REQ_SET_CONFIGURATION */
-+	bnez	$9, __ep0_req_get_desc
-+	nop
-+
-+	/* Handle USB_REQ_SET_CONFIGURATION */
-+	li	$23, 1			/* NoData = 1 */
-+	b	_ep0_idle_state_fini
-+	nop
-+
-+__ep0_req_get_desc:
-+	sub	$9, $12, 0x06		/* check USB_REQ_GET_DESCRIPTOR */
-+	bnez	$9, _ep0_idle_state_fini
-+	li	$23, 1			/* NoData = 1 */
-+
-+	/* Handle USB_REQ_GET_DESCRIPTOR */
-+	li	$23, 0			/* NoData = 0 */
-+
-+	srl	$9, $25, 24		/* wValue >> 8 */
-+	sub	$8, $9, 0x01		/* check USB_DT_DEVICE */
-+	beqz	$8, ___ep0_get_dev_desc
-+	srl	$21, $26, 16		/* get wLength */
-+	sub	$8, $9, 0x02		/* check USB_DT_CONFIG */
-+	beqz	$8, ___ep0_get_conf_desc
-+	sub	$8, $9, 0x03		/* check USB_DT_STRING */
-+	beqz	$8, ___ep0_get_string_desc
-+	sub	$8, $9, 0x06		/* check USB_DT_DEVICE_QUALIFIER */
-+	beqz	$8, ___ep0_get_dev_qualifier
-+	nop
-+	b	_ep0_idle_state_fini
-+	nop
-+
-+___ep0_get_dev_desc:
-+	load_addr	$20, device_desc	/* data pointer */
-+	li	$22, 1			/* set EP0 to TX state */
-+	sub	$8, $21, 18
-+	blez	$8, _ep0_idle_state_fini /* wLength <= 18 */
-+	nop
-+	li	$21, 18			/* max length of device_desc */
-+	b	_ep0_idle_state_fini
-+	nop
-+
-+___ep0_get_dev_qualifier:
-+	load_addr	$20, dev_qualifier	/* data pointer */
-+	li	$22, 1			/* set EP0 to TX state */
-+	sub	$8, $21, 10
-+	blez	$8, _ep0_idle_state_fini /* wLength <= 10 */
-+	nop
-+	li	$21, 10			/* max length of dev_qualifier */
-+	b	_ep0_idle_state_fini
-+	nop
-+
-+___ep0_get_conf_desc:
-+	load_addr	$20, config_desc_fs	/* data pointer of FS mode */
-+	lbu	$8, 0x01($27)		/* read POWER */
-+	andi	$8, 0x10		/* test HS_MODE */
-+	beqz	$8, ___ep0_get_conf_desc2
-+	nop
-+	load_addr $20, config_desc_hs	/* data pointer of HS mode */
-+
-+___ep0_get_conf_desc2:
-+	li	$22, 1			/* set EP0 to TX state */
-+	sub	$8, $21, 32
-+	blez	$8, _ep0_idle_state_fini /* wLength <= 32 */
-+	nop
-+	li	$21, 32			/* max length of config_desc */
-+	b	_ep0_idle_state_fini
-+	nop
-+
-+___ep0_get_string_desc:
-+	li	$22, 1			/* set EP0 to TX state */
-+
-+	srl	$9, $25, 16		/* wValue & 0xff */
-+	andi	$9, 0xff
-+
-+	sub	$8, $9, 1
-+	beqz	$8, ___ep0_get_string_manufacture
-+	sub	$8, $9, 2
-+	beqz	$8, ___ep0_get_string_product
-+	nop
-+
-+___ep0_get_string_lang_ids:
-+	load_addr	$20, string_lang_ids	/* data pointer */
-+	b	_ep0_idle_state_fini
-+	li	$21, 4			/* data length */
-+
-+___ep0_get_string_manufacture:
-+	load_addr	$20, string_manufacture	/* data pointer */
-+	b	_ep0_idle_state_fini
-+	li	$21, 16			/* data length */
-+
-+___ep0_get_string_product:
-+	load_addr	$20, string_product	/* data pointer */
-+	b	_ep0_idle_state_fini
-+	li	$21, 46			/* data length */
-+
-+_ep0_idle_state_fini:
-+	li	$9, 0x40		/* SVDOUTPKTRDY */
-+	beqz	$23, _ep0_idle_state_fini2
-+	nop
-+	ori	$9, $9, 0x08		/* DATAEND */
-+_ep0_idle_state_fini2:
-+	sb	$9, 0x12($27)		/* CSR0 */
-+	beqz	$22, check_intr_ep1in
-+	nop
-+
-+	/* 2.2 Handle EP0 TX state interrupt */
-+ep0_tx_state:
-+	sub	$9, $22, 1
-+	bnez	$9, check_intr_ep1in
-+	nop
-+
-+	sub	$9, $21, 64		/* max packetsize */
-+	blez	$9, _ep0_tx_state2	/* data count <= 64 */
-+	ori	$19, $21, 0
-+	li	$19, 64
-+
-+_ep0_tx_state2:
-+	beqz	$19, _ep0_tx_state3	/* send ZLP */
-+	ori	$18, $19, 0		/* record bytes to be transferred */
-+	sub	$21, $21, $19		/* decrement data count */
-+
-+_ep0_fifo_write_loop:
-+	lbu	$9, 0($20)		/* read data */
-+	sb	$9, 0x20($27)		/* load FIFO */
-+	sub	$19, $19, 1		/* decrement counter */
-+	bnez	$19, _ep0_fifo_write_loop
-+	addi	$20, $20, 1		/* increment data pointer */
-+
-+	sub	$9, $18, 64		/* max packetsize */
-+	beqz	$9, _ep0_tx_state4
-+	nop
-+
-+_ep0_tx_state3:
-+	/* transferred bytes < max packetsize */
-+	li	$9, 0x0a		/* set INPKTRDY and DATAEND */
-+	sb	$9, 0x12($27)		/* CSR0 */
-+	li	$22, 0			/* set EP0 to IDLE state */
-+	b	check_intr_ep1in
-+	nop
-+
-+_ep0_tx_state4:
-+	/* transferred bytes == max packetsize */
-+	li	$9, 0x02		/* set INPKTRDY */
-+	sb	$9, 0x12($27)		/* CSR0 */
-+	b	check_intr_ep1in
-+	nop
-+
-+	/* 3. Check and handle EP1 BULK-IN interrupt */
-+check_intr_ep1in:
-+	andi	$9, $10, 0x2		/* check EP1 IN interrupt */
-+	beqz	$9, check_intr_ep1out
-+	nop
-+
-+handle_epin1_intr:
-+	li	$9, 1
-+	sb	$9, 0x0e($27)		/* set INDEX 1 */
-+	lbu	$9, 0x12($27)		/* read INCSR */
-+
-+	andi	$8, $9, 0x2		/* check INCSR_FFNOTEMPT */
-+	bnez	$8, _epin1_tx_state4
-+	nop
-+
-+_epin1_write_fifo:
-+	lhu	$9, 0x10($27)		/* get INMAXP */
-+	sub	$8, $21, $9
-+	blez	$8, _epin1_tx_state1	/* bytes left <= INMAXP */
-+	ori	$19, $21, 0
-+	ori	$19, $9, 0
-+
-+_epin1_tx_state1:
-+	beqz	$19, _epin1_tx_state4	/* No data */
-+	nop
-+
-+	sub	$21, $21, $19		/* decrement data count */
-+
-+	srl	$5, $19, 2		/* # of word */
-+	andi	$6, $19, 0x3		/* # of byte */
-+	beqz	$5, _epin1_tx_state2
-+	nop
-+
-+_epin1_fifo_write_word:
-+	lw	$9, 0($20)		/* read data from source address */
-+	sw	$9, 0x24($27)		/* write FIFO */
-+	sub	$5, $5, 1		/* decrement counter */
-+	bnez	$5, _epin1_fifo_write_word
-+	addiu	$20, $20, 4		/* increment dest address */
-+
-+_epin1_tx_state2:
-+	beqz	$6, _epin1_tx_state3
-+	nop
-+
-+_epin1_fifo_write_byte:
-+	lbu	$9, 0($20)		/* read data from source address */
-+	sb	$9, 0x24($27)		/* write FIFO */
-+	sub	$6, $6, 1		/* decrement counter */
-+	bnez	$6, _epin1_fifo_write_byte
-+	addiu	$20, $20, 1		/* increment dest address */
-+
-+_epin1_tx_state3:
-+	li	$9, 0x1
-+	sb	$9, 0x12($27)		/* INCSR, set INPKTRDY */
-+
-+_epin1_tx_state4:
-+	/* 4. Check and handle EP1 BULK-OUT interrupt */
-+check_intr_ep1out:
-+	lhu	$9, 0x04($27)		/* read INTROUT */
-+	andi	$9, 0x2
-+	beqz	$9, check_status_next
-+	nop
-+
-+handle_epout1_intr:
-+	li	$9, 1
-+	sb	$9, 0x0e($27)		/* set INDEX 1 */
-+
-+	lbu	$9, 0x16($27)		/* read OUTCSR */
-+	andi	$9, 0x1			/* check OUTPKTRDY */
-+	beqz	$9, check_status_next
-+	nop
-+
-+_epout1_read_fifo:
-+	lhu	$19, 0x18($27)		/* read OUTCOUNT */
-+	srl	$5, $19, 2		/* # of word */
-+	andi	$6, $19, 0x3		/* # of byte */
-+	beqz	$5, _epout1_rx_state1
-+	nop
-+
-+_epout1_fifo_read_word:
-+	lw	$9, 0x24($27)		/* read FIFO */
-+	sw	$9, 0($20)		/* store to dest address */
-+	sub	$5, $5, 1		/* decrement counter */
-+	bnez	$5, _epout1_fifo_read_word
-+	addiu	$20, $20, 4		/* increment dest address */
-+
-+_epout1_rx_state1:
-+	beqz	$6, _epout1_rx_state2
-+	nop
-+
-+_epout1_fifo_read_byte:
-+	lbu	$9, 0x24($27)		/* read FIFO */
-+	sb	$9, 0($20)		/* store to dest address */
-+	sub	$6, $6, 1		/* decrement counter */
-+	bnez	$6, _epout1_fifo_read_byte
-+	addiu	$20, $20, 1		/* increment dest address */
-+
-+_epout1_rx_state2:
-+	sb	$0, 0x16($27)		/* clear OUTPKTRDY */
-+
-+check_status_next:
-+	b	usb_command_loop
-+	nop
-+
-+/* Device/Configuration/Interface/Endpoint/String Descriptors */
-+
-+	.align	2
-+device_desc:
-+	.byte	0x12		/* bLength */
-+	.byte	0x01		/* bDescriptorType */
-+	.byte	0x00		/* bcdUSB */
-+	.byte	0x02		/* bcdUSB */
-+	.byte	0x00		/* bDeviceClass */
-+	.byte	0x00		/* bDeviceSubClass */
-+	.byte	0x00		/* bDeviceProtocol */
-+	.byte	0x40		/* bMaxPacketSize0 */
-+	.byte	0x1a		/* idVendor */
-+	.byte	0x60		/* idVendor */
-+	.byte	0x40		/* idProduct */
-+	.byte	0x47		/* idProduct */
-+	.byte	0x00		/* bcdDevice */
-+	.byte	0x01		/* bcdDevice */
-+	.byte	0x01		/* iManufacturer */
-+	.byte	0x02		/* iProduct */
-+	.byte	0x00		/* iSerialNumber */
-+	.byte	0x01		/* bNumConfigurations */
-+
-+	.align	2
-+dev_qualifier:
-+	.byte	0x0a		/* bLength */
-+	.byte	0x06		/* bDescriptorType */
-+	.byte	0x00		/* bcdUSB */
-+	.byte	0x02		/* bcdUSB */
-+	.byte	0x00		/* bDeviceClass */
-+	.byte	0x00		/* bDeviceSubClass */
-+	.byte	0x00		/* bDeviceProtocol */
-+	.byte	0x40		/* bMaxPacketSize0 */
-+	.byte	0x01		/* bNumConfigurations */
-+	.byte	0x00		/* bRESERVED */
-+
-+	.align	2
-+config_desc_hs:
-+	.byte	0x09		/* bLength */
-+	.byte	0x02		/* bDescriptorType */
-+	.byte	0x20		/* wTotalLength */
-+	.byte	0x00		/* wTotalLength */
-+	.byte	0x01		/* bNumInterfaces */
-+	.byte	0x01		/* bConfigurationValue */
-+	.byte	0x00		/* iConfiguration */
-+	.byte	0xc0		/* bmAttributes */
-+	.byte	0x01		/* MaxPower */
-+intf_desc_hs:
-+	.byte	0x09		/* bLength */
-+	.byte	0x04		/* bDescriptorType */
-+	.byte	0x00		/* bInterfaceNumber */
-+	.byte	0x00		/* bAlternateSetting */
-+	.byte	0x02		/* bNumEndpoints */
-+	.byte	0xff		/* bInterfaceClass */
-+	.byte	0x00		/* bInterfaceSubClass */
-+	.byte	0x50		/* bInterfaceProtocol */
-+	.byte	0x00		/* iInterface */
-+ep1_desc_hs:
-+	.byte	0x07		/* bLength */
-+	.byte	0x05		/* bDescriptorType */
-+	.byte	0x01		/* bEndpointAddress */
-+	.byte	0x02		/* bmAttributes */
-+	.byte	0x00		/* wMaxPacketSize */
-+	.byte	0x02		/* wMaxPacketSize */
-+	.byte	0x00		/* bInterval */
-+ep2_desc_hs:
-+	.byte	0x07		/* bLength */
-+	.byte	0x05		/* bDescriptorType */
-+	.byte	0x81		/* bEndpointAddress */
-+	.byte	0x02		/* bmAttributes */
-+	.byte	0x00		/* wMaxPacketSize */
-+	.byte	0x02		/* wMaxPacketSize */
-+	.byte	0x00		/* bInterval */
-+
-+	.align	2
-+config_desc_fs:
-+	.byte	0x09		/* bLength */
-+	.byte	0x02		/* bDescriptorType */
-+	.byte	0x20		/* wTotalLength */
-+	.byte	0x00		/* wTotalLength */
-+	.byte	0x01		/* bNumInterfaces */
-+	.byte	0x01		/* bConfigurationValue */
-+	.byte	0x00		/* iConfiguration */
-+	.byte	0xc0		/* bmAttributes */
-+	.byte	0x01		/* MaxPower */
-+intf_desc_fs:
-+	.byte	0x09		/* bLength */
-+	.byte	0x04		/* bDescriptorType */
-+	.byte	0x00		/* bInterfaceNumber */
-+	.byte	0x00		/* bAlternateSetting */
-+	.byte	0x02		/* bNumEndpoints */
-+	.byte	0xff		/* bInterfaceClass */
-+	.byte	0x00		/* bInterfaceSubClass */
-+	.byte	0x50		/* bInterfaceProtocol */
-+	.byte	0x00		/* iInterface */
-+ep1_desc_fs:
-+	.byte	0x07		/* bLength */
-+	.byte	0x05		/* bDescriptorType */
-+	.byte	0x01		/* bEndpointAddress */
-+	.byte	0x02		/* bmAttributes */
-+	.byte	0x40		/* wMaxPacketSize */
-+	.byte	0x00		/* wMaxPacketSize */
-+	.byte	0x00		/* bInterval */
-+ep2_desc_fs:
-+	.byte	0x07		/* bLength */
-+	.byte	0x05		/* bDescriptorType */
-+	.byte	0x81		/* bEndpointAddress */
-+	.byte	0x02		/* bmAttributes */
-+	.byte	0x40		/* wMaxPacketSize */
-+	.byte	0x00		/* wMaxPacketSize */
-+	.byte	0x00		/* bInterval */
-+
-+	.align	2
-+string_lang_ids:
-+	.byte	0x04
-+	.byte	0x03
-+	.byte	0x09
-+	.byte	0x04
-+
-+	.align	2
-+string_manufacture:
-+	.byte	0x10
-+	.byte	0x03
-+	.byte	0x49
-+	.byte	0x00
-+	.byte	0x6e
-+	.byte	0x00
-+	.byte	0x67
-+	.byte	0x00
-+	.byte	0x65
-+	.byte	0x00
-+	.byte	0x6e
-+	.byte	0x00
-+	.byte	0x69
-+	.byte	0x00
-+	.byte	0x63
-+	.byte	0x00
-+
-+	.align	2
-+string_product:
-+	.byte	0x2e
-+	.byte	0x03
-+	.byte	0x4a
-+	.byte	0x00
-+	.byte	0x5a
-+	.byte	0x00
-+	.byte	0x34
-+	.byte	0x00
-+	.byte	0x37
-+	.byte	0x00
-+	.byte	0x34
-+	.byte	0x00
-+	.byte	0x30
-+	.byte	0x00
-+	.byte	0x20
-+	.byte	0x00
-+	.byte	0x55
-+	.byte	0x00
-+	.byte	0x53
-+	.byte	0x00
-+	.byte	0x42
-+	.byte	0x00
-+	.byte	0x20
-+	.byte	0x00
-+	.byte	0x42
-+	.byte	0x00
-+	.byte	0x6f
-+	.byte	0x00
-+	.byte	0x6f
-+	.byte	0x00
-+	.byte	0x74
-+	.byte	0x00
-+	.byte	0x20
-+	.byte	0x00
-+	.byte	0x44
-+	.byte	0x00
-+	.byte	0x65
-+	.byte	0x00
-+	.byte	0x76
-+	.byte	0x00
-+	.byte	0x69
-+	.byte	0x00
-+	.byte	0x63
-+	.byte	0x00
-+	.byte	0x65
-+	.byte	0x00
-+
-+	.align	2
-+cpu_info_data:
-+	.byte	0x4a
-+	.byte	0x5a
-+	.byte	0x34
-+	.byte	0x37
-+	.byte	0x34
-+	.byte	0x30
-+	.byte	0x56
-+	.byte	0x31
-+usbboot_end:
-+
-+    .set reorder
--- 
-1.7.9.5
-

+ 0 - 1664
package/boot/uboot-xburst/patches/0003-add-mmc-support.patch

@@ -1,1664 +0,0 @@
-From bd36739e77669e8df45c38f6acfe2cea511534d9 Mon Sep 17 00:00:00 2001
-From: Xiangfu <xiangfu@openmobilefree.net>
-Date: Wed, 10 Oct 2012 18:19:41 +0800
-Subject: [PATCH 3/6] add mmc support
-
----
- arch/mips/include/asm/jz4740.h |  166 ++++++
- board/qi/qi_lb60/qi_lb60.c     |    9 +-
- drivers/mmc/Makefile           |    1 +
- drivers/mmc/jz_mmc.c           | 1179 ++++++++++++++++++++++++++++++++++++++++
- drivers/mmc/jz_mmc.h           |  176 ++++++
- include/configs/qi_lb60.h      |    9 +
- include/mmc.h                  |   40 ++
- 7 files changed, 1578 insertions(+), 2 deletions(-)
- create mode 100644 drivers/mmc/jz_mmc.c
- create mode 100644 drivers/mmc/jz_mmc.h
-
-diff --git a/arch/mips/include/asm/jz4740.h b/arch/mips/include/asm/jz4740.h
-index 7a7cfff..68287fb 100644
---- a/arch/mips/include/asm/jz4740.h
-+++ b/arch/mips/include/asm/jz4740.h
-@@ -1146,5 +1146,171 @@ extern void sdram_init(void);
- extern void calc_clocks(void);
- extern void rtc_init(void);
- 
-+/*************************************************************************
-+ * MSC
-+ *************************************************************************/
-+#define REG8(addr)	*((volatile u8 *)(addr))
-+#define REG16(addr)	*((volatile u16 *)(addr))
-+#define REG32(addr)	*((volatile u32 *)(addr))
-+
-+#define	CPM_BASE	0xB0000000
-+#define CPM_CPCCR	(CPM_BASE+0x00)
-+#define CPM_MSCCDR	(CPM_BASE+0x68)
-+#define REG_CPM_MSCCDR	REG32(CPM_MSCCDR)
-+#define REG_CPM_CPCCR	REG32(CPM_CPCCR)
-+
-+#define	MSC_BASE	0xB0021000
-+
-+#define	MSC_STRPCL		(MSC_BASE + 0x000)
-+#define	MSC_STAT		(MSC_BASE + 0x004)
-+#define	MSC_CLKRT		(MSC_BASE + 0x008)
-+#define	MSC_CMDAT		(MSC_BASE + 0x00C)
-+#define	MSC_RESTO		(MSC_BASE + 0x010)
-+#define	MSC_RDTO		(MSC_BASE + 0x014)
-+#define	MSC_BLKLEN		(MSC_BASE + 0x018)
-+#define	MSC_NOB			(MSC_BASE + 0x01C)
-+#define	MSC_SNOB		(MSC_BASE + 0x020)
-+#define	MSC_IMASK		(MSC_BASE + 0x024)
-+#define	MSC_IREG		(MSC_BASE + 0x028)
-+#define	MSC_CMD			(MSC_BASE + 0x02C)
-+#define	MSC_ARG			(MSC_BASE + 0x030)
-+#define	MSC_RES			(MSC_BASE + 0x034)
-+#define	MSC_RXFIFO		(MSC_BASE + 0x038)
-+#define	MSC_TXFIFO		(MSC_BASE + 0x03C)
-+
-+#define	REG_MSC_STRPCL		REG16(MSC_STRPCL)
-+#define	REG_MSC_STAT		REG32(MSC_STAT)
-+#define	REG_MSC_CLKRT		REG16(MSC_CLKRT)
-+#define	REG_MSC_CMDAT		REG32(MSC_CMDAT)
-+#define	REG_MSC_RESTO		REG16(MSC_RESTO)
-+#define	REG_MSC_RDTO		REG16(MSC_RDTO)
-+#define	REG_MSC_BLKLEN		REG16(MSC_BLKLEN)
-+#define	REG_MSC_NOB		REG16(MSC_NOB)
-+#define	REG_MSC_SNOB		REG16(MSC_SNOB)
-+#define	REG_MSC_IMASK		REG16(MSC_IMASK)
-+#define	REG_MSC_IREG		REG16(MSC_IREG)
-+#define	REG_MSC_CMD		REG8(MSC_CMD)
-+#define	REG_MSC_ARG		REG32(MSC_ARG)
-+#define	REG_MSC_RES		REG16(MSC_RES)
-+#define	REG_MSC_RXFIFO		REG32(MSC_RXFIFO)
-+#define	REG_MSC_TXFIFO		REG32(MSC_TXFIFO)
-+
-+/* MSC Clock and Control Register (MSC_STRPCL) */
-+
-+#define MSC_STRPCL_EXIT_MULTIPLE	(1 << 7)
-+#define MSC_STRPCL_EXIT_TRANSFER	(1 << 6)
-+#define MSC_STRPCL_START_READWAIT	(1 << 5)
-+#define MSC_STRPCL_STOP_READWAIT	(1 << 4)
-+#define MSC_STRPCL_RESET		(1 << 3)
-+#define MSC_STRPCL_START_OP		(1 << 2)
-+#define MSC_STRPCL_CLOCK_CONTROL_BIT	0
-+#define MSC_STRPCL_CLOCK_CONTROL_MASK	(0x3 << MSC_STRPCL_CLOCK_CONTROL_BIT)
-+  #define MSC_STRPCL_CLOCK_CONTROL_STOP	  (0x1 << MSC_STRPCL_CLOCK_CONTROL_BIT) /* Stop MMC/SD clock */
-+  #define MSC_STRPCL_CLOCK_CONTROL_START  (0x2 << MSC_STRPCL_CLOCK_CONTROL_BIT) /* Start MMC/SD clock */
-+
-+/* MSC Status Register (MSC_STAT) */
-+
-+#define MSC_STAT_IS_RESETTING		(1 << 15)
-+#define MSC_STAT_SDIO_INT_ACTIVE	(1 << 14)
-+#define MSC_STAT_PRG_DONE		(1 << 13)
-+#define MSC_STAT_DATA_TRAN_DONE		(1 << 12)
-+#define MSC_STAT_END_CMD_RES		(1 << 11)
-+#define MSC_STAT_DATA_FIFO_AFULL	(1 << 10)
-+#define MSC_STAT_IS_READWAIT		(1 << 9)
-+#define MSC_STAT_CLK_EN			(1 << 8)
-+#define MSC_STAT_DATA_FIFO_FULL		(1 << 7)
-+#define MSC_STAT_DATA_FIFO_EMPTY	(1 << 6)
-+#define MSC_STAT_CRC_RES_ERR		(1 << 5)
-+#define MSC_STAT_CRC_READ_ERROR		(1 << 4)
-+#define MSC_STAT_CRC_WRITE_ERROR_BIT	2
-+#define MSC_STAT_CRC_WRITE_ERROR_MASK	(0x3 << MSC_STAT_CRC_WRITE_ERROR_BIT)
-+  #define MSC_STAT_CRC_WRITE_ERROR_NO		(0 << MSC_STAT_CRC_WRITE_ERROR_BIT) /* No error on transmission of data */
-+  #define MSC_STAT_CRC_WRITE_ERROR		(1 << MSC_STAT_CRC_WRITE_ERROR_BIT) /* Card observed erroneous transmission of data */
-+  #define MSC_STAT_CRC_WRITE_ERROR_NOSTS	(2 << MSC_STAT_CRC_WRITE_ERROR_BIT) /* No CRC status is sent back */
-+#define MSC_STAT_TIME_OUT_RES		(1 << 1)
-+#define MSC_STAT_TIME_OUT_READ		(1 << 0)
-+
-+/* MSC Bus Clock Control Register (MSC_CLKRT) */
-+
-+#define	MSC_CLKRT_CLK_RATE_BIT		0
-+#define	MSC_CLKRT_CLK_RATE_MASK		(0x7 << MSC_CLKRT_CLK_RATE_BIT)
-+  #define MSC_CLKRT_CLK_RATE_DIV_1	  (0x0 << MSC_CLKRT_CLK_RATE_BIT) /* CLK_SRC */
-+  #define MSC_CLKRT_CLK_RATE_DIV_2	  (0x1 << MSC_CLKRT_CLK_RATE_BIT) /* 1/2 of CLK_SRC */
-+  #define MSC_CLKRT_CLK_RATE_DIV_4	  (0x2 << MSC_CLKRT_CLK_RATE_BIT) /* 1/4 of CLK_SRC */
-+  #define MSC_CLKRT_CLK_RATE_DIV_8	  (0x3 << MSC_CLKRT_CLK_RATE_BIT) /* 1/8 of CLK_SRC */
-+  #define MSC_CLKRT_CLK_RATE_DIV_16	  (0x4 << MSC_CLKRT_CLK_RATE_BIT) /* 1/16 of CLK_SRC */
-+  #define MSC_CLKRT_CLK_RATE_DIV_32	  (0x5 << MSC_CLKRT_CLK_RATE_BIT) /* 1/32 of CLK_SRC */
-+  #define MSC_CLKRT_CLK_RATE_DIV_64	  (0x6 << MSC_CLKRT_CLK_RATE_BIT) /* 1/64 of CLK_SRC */
-+  #define MSC_CLKRT_CLK_RATE_DIV_128	  (0x7 << MSC_CLKRT_CLK_RATE_BIT) /* 1/128 of CLK_SRC */
-+
-+/* MSC Command Sequence Control Register (MSC_CMDAT) */
-+
-+#define	MSC_CMDAT_IO_ABORT	(1 << 11)
-+#define	MSC_CMDAT_BUS_WIDTH_BIT	9
-+#define	MSC_CMDAT_BUS_WIDTH_MASK (0x3 << MSC_CMDAT_BUS_WIDTH_BIT)
-+#define MSC_CMDAT_BUS_WIDTH_1BIT (0x0 << MSC_CMDAT_BUS_WIDTH_BIT)
-+#define MSC_CMDAT_BUS_WIDTH_4BIT (0x2 << MSC_CMDAT_BUS_WIDTH_BIT)
-+#define	MSC_CMDAT_DMA_EN	(1 << 8)
-+#define	MSC_CMDAT_INIT		(1 << 7)
-+#define	MSC_CMDAT_BUSY		(1 << 6)
-+#define	MSC_CMDAT_STREAM_BLOCK	(1 << 5)
-+#define	MSC_CMDAT_WRITE		(1 << 4)
-+#define	MSC_CMDAT_READ		(0 << 4)
-+#define	MSC_CMDAT_DATA_EN	(1 << 3)
-+#define	MSC_CMDAT_RESPONSE_BIT	0
-+#define	MSC_CMDAT_RESPONSE_MASK	(0x7 << MSC_CMDAT_RESPONSE_BIT)
-+#define MSC_CMDAT_RESPONSE_NONE	(0x0 << MSC_CMDAT_RESPONSE_BIT)
-+#define MSC_CMDAT_RESPONSE_R1	(0x1 << MSC_CMDAT_RESPONSE_BIT)
-+#define MSC_CMDAT_RESPONSE_R2	(0x2 << MSC_CMDAT_RESPONSE_BIT)
-+#define MSC_CMDAT_RESPONSE_R3	(0x3 << MSC_CMDAT_RESPONSE_BIT)
-+#define MSC_CMDAT_RESPONSE_R4	(0x4 << MSC_CMDAT_RESPONSE_BIT)
-+#define MSC_CMDAT_RESPONSE_R5	(0x5 << MSC_CMDAT_RESPONSE_BIT)
-+#define MSC_CMDAT_RESPONSE_R6	(0x6 << MSC_CMDAT_RESPONSE_BIT)
-+
-+/* MSC Interrupts Mask Register (MSC_IMASK) */
-+#define	MSC_IMASK_SDIO			(1 << 7)
-+#define	MSC_IMASK_TXFIFO_WR_REQ		(1 << 6)
-+#define	MSC_IMASK_RXFIFO_RD_REQ		(1 << 5)
-+#define	MSC_IMASK_END_CMD_RES		(1 << 2)
-+#define	MSC_IMASK_PRG_DONE		(1 << 1)
-+#define	MSC_IMASK_DATA_TRAN_DONE	(1 << 0)
-+
-+
-+/* MSC Interrupts Status Register (MSC_IREG) */
-+#define	MSC_IREG_SDIO			(1 << 7)
-+#define	MSC_IREG_TXFIFO_WR_REQ		(1 << 6)
-+#define	MSC_IREG_RXFIFO_RD_REQ		(1 << 5)
-+#define	MSC_IREG_END_CMD_RES		(1 << 2)
-+#define	MSC_IREG_PRG_DONE		(1 << 1)
-+#define	MSC_IREG_DATA_TRAN_DONE		(1 << 0)
-+
-+static __inline__ unsigned int __cpm_get_pllout2(void)
-+{
-+	if (REG_CPM_CPCCR & CPM_CPCCR_PCS)
-+		return __cpm_get_pllout();
-+	else
-+		return __cpm_get_pllout()/2;
-+}
-+
-+static inline void __cpm_select_msc_clk(int sd)
-+{
-+	unsigned int pllout2 = __cpm_get_pllout2();
-+	unsigned int div = 0;
-+
-+	if (sd) {
-+		div = pllout2 / 24000000;
-+	}
-+	else {
-+		div = pllout2 / 16000000;
-+	}
-+
-+	REG_CPM_MSCCDR = div - 1;
-+}
-+#define __msc_reset() 						\
-+do { 								\
-+	REG_MSC_STRPCL = MSC_STRPCL_RESET;			\
-+ 	while (REG_MSC_STAT & MSC_STAT_IS_RESETTING);		\
-+} while (0)
-+
- #endif	/* !__ASSEMBLY__ */
- #endif	/* __JZ4740_H__ */
-diff --git a/board/qi/qi_lb60/qi_lb60.c b/board/qi/qi_lb60/qi_lb60.c
-index 3bd4e2f..a2ba648 100644
---- a/board/qi/qi_lb60/qi_lb60.c
-+++ b/board/qi/qi_lb60/qi_lb60.c
-@@ -40,8 +40,13 @@ static void gpio_init(void)
- 		__gpio_clear_pin(GPIO_KEYOUT_BASE + i);
- 	}
- 
--	__gpio_as_input(GPIO_KEYIN_8);
--	__gpio_enable_pull(GPIO_KEYIN_8);
-+	if (__gpio_get_pin(GPIO_KEYIN_BASE + 2) == 0){
-+		printf("[S] pressed, enable UART0\n");
-+		__gpio_as_uart0();
-+	} else {
-+		__gpio_as_input(GPIO_KEYIN_8);
-+		__gpio_enable_pull(GPIO_KEYIN_8);
-+	}
- 
- 	/* enable the TP4, TP5 as UART0 */
- 	__gpio_jtag_to_uart0();
-diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile
-index 565ba6a..3c717b1 100644
---- a/drivers/mmc/Makefile
-+++ b/drivers/mmc/Makefile
-@@ -47,6 +47,7 @@ COBJS-$(CONFIG_SDHCI) += sdhci.o
- COBJS-$(CONFIG_S5P_SDHCI) += s5p_sdhci.o
- COBJS-$(CONFIG_SH_MMCIF) += sh_mmcif.o
- COBJS-$(CONFIG_TEGRA_MMC) += tegra_mmc.o
-+COBJS-$(CONFIG_JZ4740_MMC) += jz_mmc.o
- 
- COBJS	:= $(COBJS-y)
- SRCS	:= $(COBJS:.o=.c)
-diff --git a/drivers/mmc/jz_mmc.c b/drivers/mmc/jz_mmc.c
-new file mode 100644
-index 0000000..642cecc
---- /dev/null
-+++ b/drivers/mmc/jz_mmc.c
-@@ -0,0 +1,1179 @@
-+/*
-+ * (C) Copyright 2003
-+ * Kyle Harris, Nexus Technologies, Inc. kharris@nexus-tech.net
-+ *
-+ * See file CREDITS for list of people who contributed to this
-+ * project.
-+ *
-+ * 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, write to the Free Software
-+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
-+ * MA 02111-1307 USA
-+ */
-+
-+#include <config.h>
-+#include <common.h>
-+#include <part.h>
-+#include <mmc.h>
-+
-+#include <asm/io.h>
-+#include <asm/jz4740.h>
-+#include "jz_mmc.h"
-+
-+static int sd2_0 = 0;
-+static int mmc_ready = 0;
-+static int use_4bit;		/* Use 4-bit data bus */
-+/*
-+ *  MMC Events
-+ */
-+#define MMC_EVENT_NONE	        0x00	/* No events */
-+#define MMC_EVENT_RX_DATA_DONE	0x01	/* Rx data done */
-+#define MMC_EVENT_TX_DATA_DONE	0x02	/* Tx data done */
-+#define MMC_EVENT_PROG_DONE	0x04	/* Programming is done */
-+
-+
-+#define MMC_IRQ_MASK()				\
-+do {						\
-+      	REG_MSC_IMASK = 0xffff;			\
-+      	REG_MSC_IREG = 0xffff;			\
-+} while (0)
-+
-+/*
-+ * GPIO definition
-+ */
-+#if defined(CONFIG_SAKC)
-+
-+#define __msc_init_io()				\
-+do {						\
-+	__gpio_as_input(GPIO_SD_CD_N);		\
-+} while (0)
-+
-+#else
-+#define __msc_init_io()				\
-+do {						\
-+	__gpio_as_output(GPIO_SD_VCC_EN_N);	\
-+	__gpio_as_input(GPIO_SD_CD_N);		\
-+} while (0)
-+
-+#define __msc_enable_power()			\
-+do {						\
-+	__gpio_clear_pin(GPIO_SD_VCC_EN_N);	\
-+} while (0)
-+
-+#define __msc_disable_power()			\
-+do {						\
-+	__gpio_set_pin(GPIO_SD_VCC_EN_N);	\
-+} while (0)
-+	
-+#endif /* CONFIG_SAKE */
-+
-+#define __msc_card_detected()			\
-+({						\
-+	int detected = 1;			\
-+	__gpio_as_input(GPIO_SD_CD_N);		\
-+	__gpio_disable_pull(GPIO_SD_CD_N);	\
-+	if (!__gpio_get_pin(GPIO_SD_CD_N))	\
-+		detected = 0;			\
-+	detected;				\
-+})
-+
-+/*
-+ * Local functions
-+ */
-+
-+extern int
-+fat_register_device(block_dev_desc_t *dev_desc, int part_no);
-+
-+static block_dev_desc_t mmc_dev;
-+
-+block_dev_desc_t * mmc_get_dev(int dev)
-+{
-+	return ((block_dev_desc_t *)&mmc_dev);
-+}
-+
-+/* Stop the MMC clock and wait while it happens */
-+static inline int jz_mmc_stop_clock(void)
-+{
-+	int timeout = 1000;
-+
-+	REG_MSC_STRPCL = MSC_STRPCL_CLOCK_CONTROL_STOP;
-+
-+	while (timeout && (REG_MSC_STAT & MSC_STAT_CLK_EN)) {
-+		timeout--;
-+		if (timeout == 0)
-+			return MMC_ERROR_TIMEOUT;
-+		udelay(1);
-+	}
-+        return MMC_NO_ERROR;
-+}
-+
-+/* Start the MMC clock and operation */
-+static inline int jz_mmc_start_clock(void)
-+{
-+	REG_MSC_STRPCL = MSC_STRPCL_CLOCK_CONTROL_START | MSC_STRPCL_START_OP;
-+	return MMC_NO_ERROR;
-+}
-+
-+static inline u32 jz_mmc_calc_clkrt(int is_sd, u32 rate)
-+{
-+	u32 clkrt = 0;
-+	u32 clk_src = is_sd ? 24000000 : 16000000;
-+
-+  	while (rate < clk_src) {
-+      		clkrt ++;
-+      		clk_src >>= 1;
-+    	}
-+
-+	return clkrt;
-+}
-+
-+/* Set the MMC clock frequency */
-+void jz_mmc_set_clock(int sd, u32 rate)
-+{
-+	jz_mmc_stop_clock();
-+
-+	/* Select clock source of MSC */
-+	__cpm_select_msc_clk(sd);
-+
-+	/* Set clock dividor of MSC */
-+	REG_MSC_CLKRT = jz_mmc_calc_clkrt(sd, rate);
-+}
-+
-+static int jz_mmc_check_status(struct mmc_request *request)
-+{
-+	u32 status = REG_MSC_STAT;
-+
-+	/* Checking for response or data timeout */
-+	if (status & (MSC_STAT_TIME_OUT_RES | MSC_STAT_TIME_OUT_READ)) {
-+		printf("MMC/SD timeout, MMC_STAT 0x%x CMD %d\n", status, request->cmd);
-+		return MMC_ERROR_TIMEOUT;
-+	}
-+
-+	/* Checking for CRC error */
-+	if (status & (MSC_STAT_CRC_READ_ERROR | MSC_STAT_CRC_WRITE_ERROR | MSC_STAT_CRC_RES_ERR)) {
-+		printf("MMC/CD CRC error, MMC_STAT 0x%x\n", status);
-+		return MMC_ERROR_CRC;
-+	}
-+
-+	return MMC_NO_ERROR;
-+}
-+
-+/* Obtain response to the command and store it to response buffer */
-+static void jz_mmc_get_response(struct mmc_request *request)
-+{
-+	int i;
-+	u8 *buf;
-+	u32 data;
-+
-+	debug("fetch response for request %d, cmd %d\n", 
-+	      request->rtype, request->cmd);
-+
-+	buf = request->response;
-+	request->result = MMC_NO_ERROR;
-+
-+	switch (request->rtype) {
-+	case RESPONSE_R1: case RESPONSE_R1B: case RESPONSE_R6:
-+	case RESPONSE_R3: case RESPONSE_R4: case RESPONSE_R5:
-+	{
-+		data = REG_MSC_RES;
-+		buf[0] = (data >> 8) & 0xff;
-+		buf[1] = data & 0xff;
-+		data = REG_MSC_RES;
-+		buf[2] = (data >> 8) & 0xff;
-+		buf[3] = data & 0xff;
-+		data = REG_MSC_RES;
-+		buf[4] = data & 0xff;
-+
-+		debug("request %d, response [%02x %02x %02x %02x %02x]\n",
-+		      request->rtype, buf[0], buf[1], buf[2], buf[3], buf[4]);
-+		break;
-+	}
-+	case RESPONSE_R2_CID: case RESPONSE_R2_CSD:
-+	{
-+		for (i = 0; i < 16; i += 2) {
-+			data = REG_MSC_RES;
-+			buf[i] = (data >> 8) & 0xff;
-+			buf[i+1] = data & 0xff;
-+		}
-+		debug("request %d, response [", request->rtype);
-+#if CONFIG_MMC_DEBUG_VERBOSE > 2
-+		if (g_mmc_debug >= 3) {
-+			int n;
-+			for (n = 0; n < 17; n++)
-+				printk("%02x ", buf[n]);
-+			printk("]\n");
-+		}
-+#endif
-+		break;
-+	}
-+	case RESPONSE_NONE:
-+		debug("No response\n");
-+		break;
-+
-+	default:
-+		debug("unhandled response type for request %d\n", request->rtype);
-+		break;
-+	}
-+}
-+
-+static int jz_mmc_receive_data(struct mmc_request *req)
-+{
-+	u32  stat, timeout, data, cnt;
-+	u8 *buf = req->buffer;
-+	u32 wblocklen = (u32)(req->block_len + 3) >> 2; /* length in word */
-+
-+	timeout = 0x3ffffff;
-+
-+	while (timeout) {
-+		timeout--;
-+		stat = REG_MSC_STAT;
-+
-+		if (stat & MSC_STAT_TIME_OUT_READ)
-+			return MMC_ERROR_TIMEOUT;
-+		else if (stat & MSC_STAT_CRC_READ_ERROR)
-+			return MMC_ERROR_CRC;
-+		else if (!(stat & MSC_STAT_DATA_FIFO_EMPTY)
-+			 || (stat & MSC_STAT_DATA_FIFO_AFULL)) {
-+			/* Ready to read data */
-+			break;
-+		}
-+		udelay(1);
-+	}
-+	if (!timeout)
-+		return MMC_ERROR_TIMEOUT;
-+
-+	/* Read data from RXFIFO. It could be FULL or PARTIAL FULL */
-+	cnt = wblocklen;
-+	while (cnt) {
-+		data = REG_MSC_RXFIFO;
-+		{
-+			*buf++ = (u8)(data >> 0);
-+			*buf++ = (u8)(data >> 8);
-+			*buf++ = (u8)(data >> 16);
-+			*buf++ = (u8)(data >> 24);
-+		}
-+		cnt --;
-+		while (cnt && (REG_MSC_STAT & MSC_STAT_DATA_FIFO_EMPTY))
-+			;
-+	}
-+	return MMC_NO_ERROR;
-+}
-+
-+static int jz_mmc_transmit_data(struct mmc_request *req)
-+{
-+#if 0
-+	u32 nob = req->nob;
-+	u32 wblocklen = (u32)(req->block_len + 3) >> 2; /* length in word */
-+	u8 *buf = req->buffer;
-+	u32 *wbuf = (u32 *)buf;
-+	u32 waligned = (((u32)buf & 0x3) == 0); /* word aligned ? */
-+	u32 stat, timeout, data, cnt;
-+
-+	for (nob; nob >= 1; nob--) {
-+		timeout = 0x3FFFFFF;
-+
-+		while (timeout) {
-+			timeout--;
-+			stat = REG_MSC_STAT;
-+
-+			if (stat & (MSC_STAT_CRC_WRITE_ERROR | MSC_STAT_CRC_WRITE_ERROR_NOSTS))
-+				return MMC_ERROR_CRC;
-+			else if (!(stat & MSC_STAT_DATA_FIFO_FULL)) {
-+				/* Ready to write data */
-+				break;
-+			}
-+
-+			udelay(1);
-+		}
-+
-+		if (!timeout)
-+			return MMC_ERROR_TIMEOUT;
-+
-+		/* Write data to TXFIFO */
-+		cnt = wblocklen;
-+		while (cnt) {
-+			while (REG_MSC_STAT & MSC_STAT_DATA_FIFO_FULL)
-+				;
-+
-+			if (waligned) {
-+				REG_MSC_TXFIFO = *wbuf++;
-+			}
-+			else {
-+				data = *buf++ | (*buf++ << 8) | (*buf++ << 16) | (*buf++ << 24);
-+				REG_MSC_TXFIFO = data;
-+			}
-+
-+			cnt--;
-+		}
-+	}
-+#endif
-+	return MMC_NO_ERROR;
-+}
-+
-+
-+/*
-+ * Name:	  int jz_mmc_exec_cmd()
-+ * Function:      send command to the card, and get a response
-+ * Input:	  struct mmc_request *req	: MMC/SD request
-+ * Output:	  0:  right		>0:  error code
-+ */
-+int jz_mmc_exec_cmd(struct mmc_request *request)
-+{
-+	u32 cmdat = 0, events = 0;
-+	int retval, timeout = 0x3fffff;
-+
-+	/* Indicate we have no result yet */
-+	request->result = MMC_NO_RESPONSE;
-+	if (request->cmd == MMC_CIM_RESET) {
-+		/* On reset, 1-bit bus width */
-+		use_4bit = 0;
-+
-+		/* Reset MMC/SD controller */
-+		__msc_reset();
-+
-+		/* On reset, drop MMC clock down */
-+		jz_mmc_set_clock(0, MMC_CLOCK_SLOW);
-+
-+		/* On reset, stop MMC clock */
-+		jz_mmc_stop_clock();
-+	}
-+	if (request->cmd == MMC_CMD_SEND_OP_COND) {
-+		debug("Have an MMC card\n");
-+		/* always use 1bit for MMC */
-+		use_4bit = 0;
-+	}
-+	if (request->cmd == SET_BUS_WIDTH) {
-+		if (request->arg == 0x2) {
-+			printf("Use 4-bit bus width\n");
-+			use_4bit = 1;
-+		} else {
-+			printf("Use 1-bit bus width\n");
-+			use_4bit = 0;
-+		}
-+	}
-+
-+	/* stop clock */
-+	jz_mmc_stop_clock();
-+
-+	/* mask all interrupts */
-+	REG_MSC_IMASK = 0xffff;
-+
-+	/* clear status */
-+	REG_MSC_IREG = 0xffff;
-+
-+	/* use 4-bit bus width when possible */
-+	if (use_4bit)
-+		cmdat |= MSC_CMDAT_BUS_WIDTH_4BIT;
-+
-+        /* Set command type and events */
-+	switch (request->cmd) {
-+	/* MMC core extra command */
-+	case MMC_CIM_RESET:
-+		cmdat |= MSC_CMDAT_INIT; /* Initialization sequence sent prior to command */
-+		break;
-+
-+	/* bc - broadcast - no response */
-+	case MMC_CMD_GO_IDLE_STATE:
-+	case MMC_CMD_SET_DSR:
-+		break;
-+
-+	/* bcr - broadcast with response */
-+	case MMC_CMD_SEND_OP_COND:
-+	case MMC_CMD_ALL_SEND_CID:
-+	case MMC_GO_IRQ_STATE:
-+		break;
-+
-+	/* adtc - addressed with data transfer */
-+	case MMC_READ_DAT_UNTIL_STOP:
-+	case MMC_CMD_READ_SINGLE_BLOCK:
-+	case MMC_CMD_READ_MULTIPLE_BLOCK:
-+	case SD_CMD_APP_SEND_SCR:
-+		cmdat |= MSC_CMDAT_DATA_EN | MSC_CMDAT_READ;
-+		events = MMC_EVENT_RX_DATA_DONE;
-+		break;
-+
-+	case MMC_WRITE_DAT_UNTIL_STOP:
-+	case MMC_CMD_WRITE_SINGLE_BLOCK:
-+	case MMC_CMD_WRITE_MULTIPLE_BLOCK:
-+	case MMC_PROGRAM_CID:
-+	case MMC_PROGRAM_CSD:
-+	case MMC_SEND_WRITE_PROT:
-+	case MMC_GEN_CMD:
-+	case MMC_LOCK_UNLOCK:
-+		cmdat |= MSC_CMDAT_DATA_EN | MSC_CMDAT_WRITE;
-+		events = MMC_EVENT_TX_DATA_DONE | MMC_EVENT_PROG_DONE;
-+
-+		break;
-+
-+	case MMC_CMD_STOP_TRANSMISSION:
-+		events = MMC_EVENT_PROG_DONE;
-+		break;
-+
-+	/* ac - no data transfer */
-+	default:
-+		break;
-+	}
-+
-+	/* Set response type */
-+	switch (request->rtype) {
-+	case RESPONSE_NONE:
-+		break;
-+
-+	case RESPONSE_R1B:
-+		cmdat |= MSC_CMDAT_BUSY;
-+		/*FALLTHRU*/
-+	case RESPONSE_R1:
-+		cmdat |= MSC_CMDAT_RESPONSE_R1;
-+		break;
-+	case RESPONSE_R2_CID:
-+	case RESPONSE_R2_CSD:
-+		cmdat |= MSC_CMDAT_RESPONSE_R2;
-+		break;
-+	case RESPONSE_R3:
-+		cmdat |= MSC_CMDAT_RESPONSE_R3;
-+		break;
-+	case RESPONSE_R4:
-+		cmdat |= MSC_CMDAT_RESPONSE_R4;
-+		break;
-+	case RESPONSE_R5:
-+		cmdat |= MSC_CMDAT_RESPONSE_R5;
-+		break;
-+	case RESPONSE_R6:
-+		cmdat |= MSC_CMDAT_RESPONSE_R6;
-+		break;
-+	default:
-+		break;
-+	}
-+
-+	/* Set command index */
-+	if (request->cmd == MMC_CIM_RESET) {
-+		REG_MSC_CMD = MMC_CMD_GO_IDLE_STATE;
-+	} else {
-+		REG_MSC_CMD = request->cmd;
-+	}
-+
-+        /* Set argument */
-+	REG_MSC_ARG = request->arg;
-+
-+	/* Set block length and nob */
-+	if (request->cmd == SD_CMD_APP_SEND_SCR) { /* get SCR from DataFIFO */
-+		REG_MSC_BLKLEN = 8;
-+		REG_MSC_NOB = 1;
-+	} else {
-+		REG_MSC_BLKLEN = request->block_len;
-+		REG_MSC_NOB = request->nob;
-+	}
-+
-+	/* Set command */
-+	REG_MSC_CMDAT = cmdat;
-+
-+	debug("Send cmd %d cmdat: %x arg: %x resp %d\n", request->cmd,
-+	      cmdat, request->arg, request->rtype);
-+
-+        /* Start MMC/SD clock and send command to card */
-+	jz_mmc_start_clock();
-+
-+	/* Wait for command completion */
-+	while (timeout-- && !(REG_MSC_STAT & MSC_STAT_END_CMD_RES))
-+		;
-+
-+	if (timeout == 0)
-+		return MMC_ERROR_TIMEOUT;
-+
-+	REG_MSC_IREG = MSC_IREG_END_CMD_RES; /* clear flag */
-+
-+	/* Check for status */
-+	retval = jz_mmc_check_status(request);
-+	if (retval) {
-+		return retval;
-+	}
-+
-+	/* Complete command with no response */
-+	if (request->rtype == RESPONSE_NONE) {
-+		return MMC_NO_ERROR;
-+	}
-+
-+	/* Get response */
-+	jz_mmc_get_response(request);
-+
-+	/* Start data operation */
-+	if (events & (MMC_EVENT_RX_DATA_DONE | MMC_EVENT_TX_DATA_DONE)) {
-+		if (events & MMC_EVENT_RX_DATA_DONE) {
-+			if (request->cmd == SD_CMD_APP_SEND_SCR) {
-+				/* SD card returns SCR register as data.
-+				   MMC core expect it in the response buffer,
-+				   after normal response. */
-+				request->buffer = (u8 *)((u32)request->response + 5);
-+			}
-+			jz_mmc_receive_data(request);
-+		}
-+
-+		if (events & MMC_EVENT_TX_DATA_DONE) {
-+			jz_mmc_transmit_data(request);
-+		}
-+
-+		/* Wait for Data Done */
-+		while (!(REG_MSC_IREG & MSC_IREG_DATA_TRAN_DONE))
-+			;
-+		REG_MSC_IREG = MSC_IREG_DATA_TRAN_DONE; /* clear status */
-+	}
-+
-+	/* Wait for Prog Done event */
-+	if (events & MMC_EVENT_PROG_DONE) {
-+		while (!(REG_MSC_IREG & MSC_IREG_PRG_DONE))
-+			;
-+		REG_MSC_IREG = MSC_IREG_PRG_DONE; /* clear status */
-+	}
-+
-+	/* Command completed */
-+
-+	return MMC_NO_ERROR;			 /* return successfully */
-+}
-+
-+int mmc_block_read(u8 *dst, ulong src, ulong len)
-+{
-+
-+	struct mmc_request request;
-+	struct mmc_response_r1 r1;
-+	int retval = 0;
-+
-+	if (len == 0)
-+		goto exit;
-+
-+	mmc_simple_cmd(&request, MMC_CMD_SEND_STATUS, mmcinfo.rca, RESPONSE_R1);
-+	retval = mmc_unpack_r1(&request, &r1, 0);
-+	if (retval && (retval != MMC_ERROR_STATE_MISMATCH))
-+		goto exit;
-+
-+	mmc_simple_cmd(&request, MMC_CMD_SET_BLOCKLEN, len, RESPONSE_R1);
-+	if (retval = mmc_unpack_r1(&request, &r1, 0))
-+		goto exit;
-+
-+	if (!sd2_0)
-+		src *= mmcinfo.block_len;
-+
-+	mmc_send_cmd(&request, MMC_CMD_READ_SINGLE_BLOCK, src, 1, len, RESPONSE_R1, dst);
-+	if (retval = mmc_unpack_r1(&request, &r1, 0))
-+		goto exit;
-+
-+exit:
-+	return retval;
-+}
-+
-+ulong mmc_bread(int dev_num, ulong blkstart, ulong blkcnt, ulong *dst)
-+{
-+	if (!mmc_ready) {
-+		printf("Please initial the MMC first\n");
-+		return -1;
-+	}
-+
-+	int i = 0;
-+	ulong dst_tmp = dst;
-+ 
-+	for (i = 0; i < blkcnt; i++) {
-+		if ((mmc_block_read((uchar *)(dst_tmp), blkstart, mmcinfo.block_len)) < 0)
-+			return -1;
-+
-+		dst_tmp += mmcinfo.block_len;
-+		blkstart++;
-+	}
-+ 
-+	return i;
-+}
-+
-+int mmc_select_card(void)
-+{
-+	struct mmc_request request;
-+	struct mmc_response_r1 r1;
-+	int retval;
-+
-+	mmc_simple_cmd(&request, MMC_CMD_SELECT_CARD, mmcinfo.rca, RESPONSE_R1B);
-+	retval = mmc_unpack_r1(&request, &r1, 0);
-+	if (retval) {
-+		return retval;
-+	}
-+
-+	if (mmcinfo.sd) {
-+		mmc_simple_cmd(&request, MMC_CMD_APP_CMD,  mmcinfo.rca, RESPONSE_R1);
-+		retval = mmc_unpack_r1(&request,&r1,0);
-+		if (retval) {
-+			return retval;
-+		}
-+#if defined(MMC_BUS_WIDTH_1BIT)		
-+		mmc_simple_cmd(&request, SET_BUS_WIDTH, 1, RESPONSE_R1);
-+#else
-+		mmc_simple_cmd(&request, SET_BUS_WIDTH, 2, RESPONSE_R1);
-+#endif
-+                retval = mmc_unpack_r1(&request,&r1,0);
-+                if (retval) {
-+			return retval;
-+		}
-+	}
-+	return 0;
-+}
-+
-+/*
-+ * Configure card
-+ */
-+static void mmc_configure_card(void)
-+{
-+	u32 rate;
-+
-+	/* Get card info */
-+	if (sd2_0)
-+		mmcinfo.block_num = (mmcinfo.csd.c_size + 1) << 10;
-+	else
-+		mmcinfo.block_num = (mmcinfo.csd.c_size + 1) * (1 << (mmcinfo.csd.c_size_mult + 2));
-+
-+	mmcinfo.block_len = 1 << mmcinfo.csd.read_bl_len;
-+
-+	mmc_dev.if_type = IF_TYPE_SD;
-+	mmc_dev.part_type = PART_TYPE_DOS;
-+	mmc_dev.dev = 0;
-+	mmc_dev.lun = 0;
-+	mmc_dev.type = 0;
-+	mmc_dev.blksz = mmcinfo.block_len;
-+	mmc_dev.lba = mmcinfo.block_num;
-+	mmc_dev.removable = 0;
-+
-+	printf("%s Detected: %lu blocks of %lu bytes\n",
-+	       sd2_0 == 1 ? "SDHC" : "SD",
-+	       mmc_dev.lba,
-+	       mmc_dev.blksz);
-+
-+	/* Fix the clock rate */
-+	rate = mmc_tran_speed(mmcinfo.csd.tran_speed);
-+	if (rate < MMC_CLOCK_SLOW)
-+		rate = MMC_CLOCK_SLOW;
-+	if ((mmcinfo.sd == 0) && (rate > MMC_CLOCK_FAST))
-+		rate = MMC_CLOCK_FAST;
-+        if ((mmcinfo.sd) && (rate > SD_CLOCK_FAST))
-+		rate = SD_CLOCK_FAST;
-+
-+	debug("%s: block_len=%d block_num=%d rate=%d\n", 
-+	      __func__, mmcinfo.block_len, mmcinfo.block_num, rate);
-+
-+	jz_mmc_set_clock(mmcinfo.sd, rate);
-+}
-+
-+/*
-+ * State machine routines to initialize card(s)
-+ */
-+
-+/*
-+  CIM_SINGLE_CARD_ACQ  (frequency at 400 kHz)
-+  --- Must enter from GO_IDLE_STATE ---
-+  1. SD_SEND_OP_COND (SD Card) [CMD55] + [CMD41]
-+  2. SEND_OP_COND (Full Range) [CMD1]   {optional}
-+  3. SEND_OP_COND (Set Range ) [CMD1]
-+     If busy, delay and repeat step 2
-+  4. ALL_SEND_CID              [CMD2]
-+     If timeout, set an error (no cards found)
-+  5. SET_RELATIVE_ADDR         [CMD3]
-+  6. SEND_CSD                  [CMD9]
-+  7. SET_DSR                   [CMD4]    Only call this if (csd.dsr_imp).
-+  8. Set clock frequency (check available in csd.tran_speed)
-+ */
-+
-+#define MMC_INIT_DOING   0
-+#define MMC_INIT_PASSED  1
-+#define MMC_INIT_FAILED  2
-+
-+static int mmc_init_card_state(struct mmc_request *request)
-+{
-+	struct mmc_response_r1 r1;
-+	struct mmc_response_r3 r3;
-+	int retval;
-+	int ocr = 0x40300000;
-+	int limit_41 = 0;
-+
-+	switch (request->cmd) {
-+	case MMC_CMD_GO_IDLE_STATE: /* No response to parse */
-+		if (mmcinfo.sd)
-+			mmc_simple_cmd(request, 8, 0x1aa, RESPONSE_R1);
-+		else
-+			mmc_simple_cmd(request, MMC_CMD_SEND_OP_COND, MMC_OCR_ARG, RESPONSE_R3);
-+		break;
-+
-+	case 8:
-+        	retval = mmc_unpack_r1(request,&r1,mmcinfo.state);
-+		mmc_simple_cmd(request, MMC_CMD_APP_CMD,  0, RESPONSE_R1);
-+		break;
-+
-+        case MMC_CMD_APP_CMD:
-+        	retval = mmc_unpack_r1(request,&r1,mmcinfo.state);
-+		if (retval & (limit_41 < 100)) {
-+			debug("%s: unable to MMC_APP_CMD error=%d (%s)\n", 
-+			      __func__, retval, mmc_result_to_string(retval));
-+			limit_41++;
-+			mmc_simple_cmd(request, SD_CMD_APP_SEND_OP_COND, ocr, RESPONSE_R3);
-+		} else if (limit_41 < 100) {
-+			limit_41++;
-+			mmc_simple_cmd(request, SD_CMD_APP_SEND_OP_COND, ocr, RESPONSE_R3);
-+		} else{
-+			/* reset the card to idle*/
-+			mmc_simple_cmd(request, MMC_CMD_GO_IDLE_STATE, 0, RESPONSE_NONE);
-+			mmcinfo.sd = 0;
-+		}
-+		break;
-+
-+        case SD_CMD_APP_SEND_OP_COND:
-+                retval = mmc_unpack_r3(request, &r3);
-+                if (retval) {
-+			debug("%s: try MMC card\n", __func__);
-+			mmc_simple_cmd(request, SD_CMD_APP_SEND_OP_COND, MMC_OCR_ARG, RESPONSE_R3);
-+			break;
-+		}
-+
-+                debug("%s: read ocr value = 0x%08x\n", __func__, r3.ocr);
-+
-+		if(!(r3.ocr & MMC_CARD_BUSY || ocr == 0)){
-+			udelay(50000);
-+			mmc_simple_cmd(request, MMC_CMD_APP_CMD, 0, RESPONSE_R1);
-+		} else {
-+			mmcinfo.sd = 1; /* SD Card ready */
-+			mmcinfo.state = CARD_STATE_READY;
-+			mmc_simple_cmd(request, MMC_CMD_ALL_SEND_CID, 0, RESPONSE_R2_CID);
-+		}
-+		break;
-+
-+	case MMC_CMD_SEND_OP_COND:
-+		retval = mmc_unpack_r3(request, &r3);
-+		if (retval) {
-+			debug("%s: failed SEND_OP_COND error=%d (%s)\n", 
-+			      __func__, retval, mmc_result_to_string(retval));
-+			return MMC_INIT_FAILED;
-+		}
-+
-+		debug("%s: read ocr value = 0x%08x\n", __func__, r3.ocr);
-+		if (!(r3.ocr & MMC_CARD_BUSY)) {
-+	                mmc_simple_cmd(request, MMC_CMD_SEND_OP_COND, MMC_OCR_ARG, RESPONSE_R3);
-+		} else {
-+		        mmcinfo.sd = 0; /* MMC Card ready */
-+			mmcinfo.state = CARD_STATE_READY;
-+			mmc_simple_cmd(request, MMC_CMD_ALL_SEND_CID, 0, RESPONSE_R2_CID);
-+		}
-+		break;
-+
-+	case MMC_CMD_ALL_SEND_CID: 
-+		retval = mmc_unpack_cid( request, &mmcinfo.cid );
-+		/*FIXME:ignore CRC error for CMD2/CMD9/CMD10 */
-+		if ( retval && (retval != MMC_ERROR_CRC)) {
-+			debug("mmc_init_card_state: unable to ALL_SEND_CID error=%d (%s)\n", 
-+			      retval, mmc_result_to_string(retval));
-+			return MMC_INIT_FAILED;
-+		}
-+		mmcinfo.state = CARD_STATE_IDENT;
-+		if(mmcinfo.sd)
-+			mmc_simple_cmd(request, MMC_CMD_SET_RELATIVE_ADDR, 0, RESPONSE_R6);
-+                else
-+			mmc_simple_cmd(request, MMC_CMD_SET_RELATIVE_ADDR, ID_TO_RCA(mmcinfo.id) << 16, RESPONSE_R1);
-+		break;
-+
-+        case MMC_CMD_SET_RELATIVE_ADDR:
-+	        if (mmcinfo.sd)	{
-+			retval = mmc_unpack_r6(request, &r1, mmcinfo.state, &mmcinfo.rca);
-+			mmcinfo.rca = mmcinfo.rca << 16; 
-+			debug("%s: Get RCA from SD: 0x%04x Status: %x\n",
-+			      __func__, mmcinfo.rca, r1.status);
-+                } else {
-+			retval = mmc_unpack_r1(request,&r1,mmcinfo.state);
-+			mmcinfo.rca = ID_TO_RCA(mmcinfo.id) << 16;
-+	        }
-+		if (retval) {
-+			debug("%s: unable to SET_RELATIVE_ADDR error=%d (%s)\n", 
-+			      __func__, retval, mmc_result_to_string(retval));
-+			return MMC_INIT_FAILED;
-+		}
-+
-+		mmcinfo.state = CARD_STATE_STBY;
-+                mmc_simple_cmd(request, MMC_CMD_SEND_CSD, mmcinfo.rca, RESPONSE_R2_CSD);
-+
-+		break;
-+
-+	case MMC_CMD_SEND_CSD:
-+		retval = mmc_unpack_csd(request, &mmcinfo.csd);
-+		mmc_ready = 1;
-+		/*FIXME:ignore CRC error for CMD2/CMD9/CMD10 */
-+	        if (retval && (retval != MMC_ERROR_CRC)) {
-+			debug("%s: unable to SEND_CSD error=%d (%s)\n", 
-+			      __func__, retval, mmc_result_to_string(retval));
-+			return MMC_INIT_FAILED;
-+		}
-+		if (mmcinfo.csd.dsr_imp) {
-+			debug("%s: driver doesn't support setting DSR\n", __func__);
-+		}
-+		mmc_configure_card();
-+		return MMC_INIT_PASSED;
-+
-+	default:
-+		debug("%s: error!  Illegal last cmd %d\n", __func__, request->cmd);
-+		return MMC_INIT_FAILED;
-+	}
-+
-+	return MMC_INIT_DOING;
-+}
-+
-+int mmc_init_card(void)
-+{
-+	struct mmc_request request;
-+	int retval;
-+
-+	mmc_simple_cmd(&request, MMC_CIM_RESET, 0, RESPONSE_NONE); /* reset card */
-+	mmc_simple_cmd(&request, MMC_CMD_GO_IDLE_STATE, 0, RESPONSE_NONE);
-+	mmcinfo.sd = 1;  /* assuming a SD card */
-+
-+	while ((retval = mmc_init_card_state(&request)) == MMC_INIT_DOING)
-+		;
-+
-+	if (retval == MMC_INIT_PASSED)
-+		return MMC_NO_ERROR;
-+	else
-+		return MMC_NO_RESPONSE;
-+}
-+
-+int mmc_legacy_init(int verbose)
-+{
-+	if (!__msc_card_detected())
-+		return 1;
-+
-+	/* Step-1: init GPIO */
-+	__gpio_as_msc();
-+	__msc_init_io();
-+
-+	/* Step-2: turn on power of card */
-+#if !defined(CONFIG_SAKC)
-+	__msc_enable_power();
-+#endif
-+
-+	/* Step-3: Reset MSC Controller. */
-+	__msc_reset();
-+
-+	/* Step-3: mask all IRQs. */
-+	MMC_IRQ_MASK();
-+
-+	/* Step-4: stop MMC/SD clock */
-+	jz_mmc_stop_clock();
-+	mmc_init_card();
-+	mmc_select_card();
-+
-+	mmc_dev.block_read = mmc_bread;
-+	fat_register_device(&mmc_dev,1); /* partitions start counting with 1 */
-+
-+	return 0;
-+}
-+
-+/*
-+ * Debugging functions
-+ */
-+static char * mmc_result_strings[] = {
-+	"NO_RESPONSE",
-+	"NO_ERROR",
-+	"ERROR_OUT_OF_RANGE",
-+	"ERROR_ADDRESS",
-+	"ERROR_BLOCK_LEN",
-+	"ERROR_ERASE_SEQ",
-+	"ERROR_ERASE_PARAM",
-+	"ERROR_WP_VIOLATION",
-+	"ERROR_CARD_IS_LOCKED",
-+	"ERROR_LOCK_UNLOCK_FAILED",
-+	"ERROR_COM_CRC",
-+	"ERROR_ILLEGAL_COMMAND",
-+	"ERROR_CARD_ECC_FAILED",
-+	"ERROR_CC",
-+	"ERROR_GENERAL",
-+	"ERROR_UNDERRUN",
-+	"ERROR_OVERRUN",
-+	"ERROR_CID_CSD_OVERWRITE",
-+	"ERROR_STATE_MISMATCH",
-+	"ERROR_HEADER_MISMATCH",
-+	"ERROR_TIMEOUT",
-+	"ERROR_CRC",
-+	"ERROR_DRIVER_FAILURE",
-+};
-+
-+char * mmc_result_to_string(int i)
-+{
-+	return mmc_result_strings[i+1];
-+}
-+
-+static char * card_state_strings[] = {
-+	"empty",
-+	"idle",
-+	"ready",
-+	"ident",
-+	"stby",
-+	"tran",
-+	"data",
-+	"rcv",
-+	"prg",
-+	"dis",
-+};
-+
-+static inline char * card_state_to_string(int i)
-+{
-+	return card_state_strings[i+1];
-+}
-+
-+/*
-+ * Utility functions
-+ */
-+
-+#define PARSE_U32(_buf,_index) \
-+	(((u32)_buf[_index]) << 24) | (((u32)_buf[_index+1]) << 16) | \
-+        (((u32)_buf[_index+2]) << 8) | ((u32)_buf[_index+3]);
-+
-+#define PARSE_U16(_buf,_index) \
-+	(((u16)_buf[_index]) << 8) | ((u16)_buf[_index+1]);
-+
-+int mmc_unpack_csd(struct mmc_request *request, struct mmc_csd *csd)
-+{
-+	u8 *buf = request->response;
-+	int num = 0;
-+
-+	if (request->result)
-+		return request->result;
-+
-+	if (buf[0] != 0x3f)
-+		return MMC_ERROR_HEADER_MISMATCH;
-+
-+	csd->csd_structure = (buf[1] & 0xc0) >> 6;
-+	if (csd->csd_structure)
-+		sd2_0 = 1;
-+	else
-+		sd2_0 = 0;
-+
-+	switch (csd->csd_structure) {
-+	case 0 :/* Version 1.01-1.10
-+		 * Version 2.00/Standard Capacity */
-+		csd->taac               = buf[2];
-+		csd->nsac               = buf[3];
-+		csd->tran_speed         = buf[4];
-+		csd->ccc                = (((u16)buf[5]) << 4) | ((buf[6] & 0xf0) >> 4);
-+		csd->read_bl_len        = buf[6] & 0x0f;
-+		/* for support 2GB card*/
-+		if (csd->read_bl_len >= 10)
-+		{
-+			num = csd->read_bl_len - 9;
-+			csd->read_bl_len = 9;
-+		}
-+
-+		csd->read_bl_partial    = (buf[7] & 0x80) ? 1 : 0;
-+		csd->write_blk_misalign = (buf[7] & 0x40) ? 1 : 0;
-+		csd->read_blk_misalign  = (buf[7] & 0x20) ? 1 : 0;
-+		csd->dsr_imp            = (buf[7] & 0x10) ? 1 : 0;
-+		csd->c_size             = ((((u16)buf[7]) & 0x03) << 10) | (((u16)buf[8]) << 2) | (((u16)buf[9]) & 0xc0) >> 6;
-+
-+		if (num)
-+			csd->c_size = csd->c_size << num;
-+
-+
-+		csd->vdd_r_curr_min     = (buf[9] & 0x38) >> 3;
-+		csd->vdd_r_curr_max     = buf[9] & 0x07;
-+		csd->vdd_w_curr_min     = (buf[10] & 0xe0) >> 5;
-+		csd->vdd_w_curr_max     = (buf[10] & 0x1c) >> 2;
-+		csd->c_size_mult        = ((buf[10] & 0x03) << 1) | ((buf[11] & 0x80) >> 7);
-+		csd->sector_size    = (buf[11] & 0x7c) >> 2;
-+		csd->erase_grp_size = ((buf[11] & 0x03) << 3) | ((buf[12] & 0xe0) >> 5);
-+		csd->wp_grp_size        = buf[12] & 0x1f;
-+		csd->wp_grp_enable      = (buf[13] & 0x80) ? 1 : 0;
-+		csd->default_ecc        = (buf[13] & 0x60) >> 5;
-+		csd->r2w_factor         = (buf[13] & 0x1c) >> 2;
-+		csd->write_bl_len       = ((buf[13] & 0x03) << 2) | ((buf[14] & 0xc0) >> 6);
-+		if (csd->write_bl_len >= 10)
-+			csd->write_bl_len = 9;
-+
-+		csd->write_bl_partial   = (buf[14] & 0x20) ? 1 : 0;
-+		csd->file_format_grp    = (buf[15] & 0x80) ? 1 : 0;
-+		csd->copy               = (buf[15] & 0x40) ? 1 : 0;
-+		csd->perm_write_protect = (buf[15] & 0x20) ? 1 : 0;
-+		csd->tmp_write_protect  = (buf[15] & 0x10) ? 1 : 0;
-+		csd->file_format        = (buf[15] & 0x0c) >> 2;
-+		csd->ecc                = buf[15] & 0x03;
-+		break;
-+	case 1 :	/* Version 2.00/High Capacity */
-+		csd->taac               = 0;
-+		csd->nsac               = 0;
-+		csd->tran_speed         = buf[4];
-+		csd->ccc                = (((u16)buf[5]) << 4) | ((buf[6] & 0xf0) >> 4);
-+
-+		csd->read_bl_len        = 9;
-+		csd->read_bl_partial    = 0;
-+		csd->write_blk_misalign = 0;
-+		csd->read_blk_misalign  = 0;
-+		csd->dsr_imp            = (buf[7] & 0x10) ? 1 : 0;
-+		csd->c_size             = ((((u16)buf[8]) & 0x3f) << 16) | (((u16)buf[9]) << 8) | ((u16)buf[10]) ;
-+		csd->sector_size	= 0x7f;
-+		csd->erase_grp_size	= 0;
-+		csd->wp_grp_size        = 0;
-+		csd->wp_grp_enable      = 0;
-+		csd->default_ecc        = (buf[13] & 0x60) >> 5;
-+		csd->r2w_factor         = 4;/* Unused */
-+		csd->write_bl_len       = 9;
-+
-+		csd->write_bl_partial   = 0;
-+		csd->file_format_grp    = 0;
-+		csd->copy               = (buf[15] & 0x40) ? 1 : 0;
-+		csd->perm_write_protect = (buf[15] & 0x20) ? 1 : 0;
-+		csd->tmp_write_protect  = (buf[15] & 0x10) ? 1 : 0;
-+		csd->file_format        = 0;
-+		csd->ecc                = buf[15] & 0x03;
-+	}
-+
-+	return 0;
-+}
-+
-+int mmc_unpack_r1(struct mmc_request *request, struct mmc_response_r1 *r1, enum card_state state)
-+{
-+	u8 *buf = request->response;
-+
-+	if (request->result)
-+		return request->result;
-+
-+	r1->cmd    = buf[0];
-+	r1->status = PARSE_U32(buf,1);
-+
-+	debug("mmc_unpack_r1: cmd=%d status=%08x\n", r1->cmd, r1->status);
-+
-+	if (R1_STATUS(r1->status)) {
-+		if (r1->status & R1_OUT_OF_RANGE)       return MMC_ERROR_OUT_OF_RANGE;
-+		if (r1->status & R1_ADDRESS_ERROR)      return MMC_ERROR_ADDRESS;
-+		if (r1->status & R1_BLOCK_LEN_ERROR)    return MMC_ERROR_BLOCK_LEN;
-+		if (r1->status & R1_ERASE_SEQ_ERROR)    return MMC_ERROR_ERASE_SEQ;
-+		if (r1->status & R1_ERASE_PARAM)        return MMC_ERROR_ERASE_PARAM;
-+		if (r1->status & R1_WP_VIOLATION)       return MMC_ERROR_WP_VIOLATION;
-+		/*if (r1->status & R1_CARD_IS_LOCKED)     return MMC_ERROR_CARD_IS_LOCKED; */
-+		if (r1->status & R1_LOCK_UNLOCK_FAILED) return MMC_ERROR_LOCK_UNLOCK_FAILED;
-+		if (r1->status & R1_COM_CRC_ERROR)      return MMC_ERROR_COM_CRC;
-+		if (r1->status & R1_ILLEGAL_COMMAND)    return MMC_ERROR_ILLEGAL_COMMAND;
-+		if (r1->status & R1_CARD_ECC_FAILED)    return MMC_ERROR_CARD_ECC_FAILED;
-+		if (r1->status & R1_CC_ERROR)           return MMC_ERROR_CC;
-+		if (r1->status & R1_ERROR)              return MMC_ERROR_GENERAL;
-+		if (r1->status & R1_UNDERRUN)           return MMC_ERROR_UNDERRUN;
-+		if (r1->status & R1_OVERRUN)            return MMC_ERROR_OVERRUN;
-+		if (r1->status & R1_CID_CSD_OVERWRITE)  return MMC_ERROR_CID_CSD_OVERWRITE;
-+	}
-+
-+	if (buf[0] != request->cmd) 
-+		return MMC_ERROR_HEADER_MISMATCH;
-+
-+	/* This should be last - it's the least dangerous error */
-+
-+	return 0;
-+}
-+
-+int mmc_unpack_scr(struct mmc_request *request, struct mmc_response_r1 *r1, enum card_state state, u32 *scr)
-+{
-+        u8 *buf = request->response;
-+	if (request->result)
-+		return request->result;
-+
-+        *scr = PARSE_U32(buf, 5); /* Save SCR returned by the SD Card */
-+        return mmc_unpack_r1(request, r1, state);
-+
-+}
-+
-+int mmc_unpack_r6(struct mmc_request *request, struct mmc_response_r1 *r1, enum card_state state, int *rca)
-+{
-+	u8 *buf = request->response;
-+
-+	if (request->result)
-+		return request->result;
-+
-+        *rca = PARSE_U16(buf,1);  /* Save RCA returned by the SD Card */
-+
-+        *(buf+1) = 0;
-+        *(buf+2) = 0;
-+
-+        return mmc_unpack_r1(request, r1, state);
-+}
-+
-+int mmc_unpack_cid(struct mmc_request *request, struct mmc_cid *cid)
-+{
-+	int i;
-+	u8 *buf = request->response;
-+
-+	if (request->result) 
-+		return request->result;
-+
-+	cid->mid = buf[1];
-+	cid->oid = PARSE_U16(buf,2);
-+	for (i = 0 ; i < 5 ; i++)
-+		cid->pnm[i] = buf[4+i];
-+	cid->pnm[6] = 0;
-+	cid->prv = buf[10];
-+	cid->psn = PARSE_U32(buf,10);
-+	cid->mdt = buf[15];
-+
-+	printf("Man %02x OEM 0x%04x \"%s\" %d.%d 0x%08x "
-+	       "Date %02u/%04u\n",
-+	       cid->mid,
-+	       cid->oid,
-+	       cid->pnm, 
-+	       cid->prv >> 4,
-+	       cid->prv & 0xf, 
-+	       cid->psn,
-+	       cid->mdt & 0xf,
-+	       (cid->mdt >> 4) + 2000);
-+
-+	if (buf[0] != 0x3f)
-+		return MMC_ERROR_HEADER_MISMATCH;
-+      	return 0;
-+}
-+
-+int mmc_unpack_r3(struct mmc_request *request, struct mmc_response_r3 *r3)
-+{
-+	u8 *buf = request->response;
-+
-+	if (request->result)
-+		return request->result;
-+
-+	r3->ocr = PARSE_U32(buf,1);
-+	debug("mmc_unpack_r3: ocr=%08x\n", r3->ocr);
-+
-+	if (buf[0] != 0x3f)  return MMC_ERROR_HEADER_MISMATCH;
-+	return 0;
-+}
-+
-+#define KBPS 1
-+#define MBPS 1000
-+
-+static u32 ts_exp[] = { 100*KBPS, 1*MBPS, 10*MBPS, 100*MBPS, 0, 0, 0, 0 };
-+static u32 ts_mul[] = { 0,    1000, 1200, 1300, 1500, 2000, 2500, 3000, 
-+			3500, 4000, 4500, 5000, 5500, 6000, 7000, 8000 };
-+
-+u32 mmc_tran_speed(u8 ts)
-+{
-+	u32 rate = ts_exp[(ts & 0x7)] * ts_mul[(ts & 0x78) >> 3];
-+
-+	if (rate <= 0) {
-+		debug("%s: error - unrecognized speed 0x%02x\n", __func__, ts);
-+		return 1;
-+	}
-+
-+	return rate;
-+}
-+
-+void mmc_send_cmd(struct mmc_request *request, int cmd, u32 arg, 
-+		  u16 nob, u16 block_len, enum mmc_rsp_t rtype, u8 *buffer)
-+{
-+	request->cmd       = cmd;
-+	request->arg       = arg;
-+	request->rtype     = rtype;
-+	request->nob       = nob;
-+	request->block_len = block_len;
-+	request->buffer    = buffer;
-+	request->cnt       = nob * block_len;
-+
-+	jz_mmc_exec_cmd(request);
-+}
-diff --git a/drivers/mmc/jz_mmc.h b/drivers/mmc/jz_mmc.h
-new file mode 100644
-index 0000000..936c514
---- /dev/null
-+++ b/drivers/mmc/jz_mmc.h
-@@ -0,0 +1,176 @@
-+/*
-+ *  linux/drivers/mmc/jz_mmc.h
-+ *
-+ *  Author: Vladimir Shebordaev, Igor Oblakov
-+ *  Copyright:  MontaVista Software Inc.
-+ *
-+ *  $Id: jz_mmc.h,v 1.3 2007-06-15 08:04:20 jlwei Exp $
-+ *
-+ *  This program is free software; you can redistribute it and/or modify
-+ *  it under the terms of the GNU General Public License version 2 as
-+ *  published by the Free Software Foundation.
-+ */
-+#ifndef __MMC_JZMMC_H__
-+#define __MMC_JZMMC_H__
-+
-+#define ID_TO_RCA(x) ((x)+1)
-+#define MMC_OCR_ARG		0x00ff8000	/* Argument of OCR */
-+
-+/* Standard MMC/SD clock speeds */
-+#define MMC_CLOCK_SLOW    400000      /* 400 kHz for initial setup */
-+#define MMC_CLOCK_FAST  20000000      /* 20 MHz for maximum for normal operation */
-+#define SD_CLOCK_FAST   24000000      /* 24 MHz for SD Cards */
-+
-+/* Use negative numbers to disambiguate */
-+#define MMC_CIM_RESET            -1
-+#define SET_BUS_WIDTH            6    /* ac   [1:0] bus width    R1  */    
-+
-+#define R1_OUT_OF_RANGE		(1 << 31)	/* er, c */
-+#define R1_ADDRESS_ERROR	(1 << 30)	/* erx, c */
-+#define R1_BLOCK_LEN_ERROR	(1 << 29)	/* er, c */
-+#define R1_ERASE_SEQ_ERROR      (1 << 28)	/* er, c */
-+#define R1_ERASE_PARAM		(1 << 27)	/* ex, c */
-+#define R1_WP_VIOLATION		(1 << 26)	/* erx, c */
-+#define R1_CARD_IS_LOCKED	(1 << 25)	/* sx, a */
-+#define R1_LOCK_UNLOCK_FAILED	(1 << 24)	/* erx, c */
-+#define R1_COM_CRC_ERROR	(1 << 23)	/* er, b */
-+#define R1_ILLEGAL_COMMAND	(1 << 22)	/* er, b */
-+#define R1_CARD_ECC_FAILED	(1 << 21)	/* ex, c */
-+#define R1_CC_ERROR		(1 << 20)	/* erx, c */
-+#define R1_ERROR		(1 << 19)	/* erx, c */
-+#define R1_UNDERRUN		(1 << 18)	/* ex, c */
-+#define R1_OVERRUN		(1 << 17)	/* ex, c */
-+#define R1_CID_CSD_OVERWRITE	(1 << 16)	/* erx, c, CID/CSD overwrite */
-+#define R1_WP_ERASE_SKIP	(1 << 15)	/* sx, c */
-+#define R1_CARD_ECC_DISABLED	(1 << 14)	/* sx, a */
-+#define R1_ERASE_RESET		(1 << 13)	/* sr, c */
-+#define R1_STATUS(x)            (x & 0xFFFFE000)
-+
-+#define MMC_CARD_BUSY	0x80000000	/* Card Power up status bit */
-+
-+#define MMC_PROGRAM_CID          26   /* adtc                    R1  */
-+#define MMC_PROGRAM_CSD          27   /* adtc                    R1  */
-+
-+#define MMC_GO_IRQ_STATE         40   /* bcr                     R5  */
-+#define MMC_GEN_CMD              56   /* adtc [0] RD/WR          R1b */
-+#define MMC_LOCK_UNLOCK          42   /* adtc                    R1b */
-+#define MMC_WRITE_DAT_UNTIL_STOP 20   /* adtc [31:0] data addr   R1  */
-+#define MMC_READ_DAT_UNTIL_STOP  11   /* adtc [31:0] dadr        R1  */
-+#define MMC_SEND_WRITE_PROT      30   /* adtc [31:0] wpdata addr R1  */
-+
-+
-+enum mmc_result_t {
-+	MMC_NO_RESPONSE        = -1,
-+	MMC_NO_ERROR           = 0,
-+	MMC_ERROR_OUT_OF_RANGE,
-+	MMC_ERROR_ADDRESS,
-+	MMC_ERROR_BLOCK_LEN,
-+	MMC_ERROR_ERASE_SEQ,
-+	MMC_ERROR_ERASE_PARAM,
-+	MMC_ERROR_WP_VIOLATION,
-+	MMC_ERROR_CARD_IS_LOCKED,
-+	MMC_ERROR_LOCK_UNLOCK_FAILED,
-+	MMC_ERROR_COM_CRC,
-+	MMC_ERROR_ILLEGAL_COMMAND,
-+	MMC_ERROR_CARD_ECC_FAILED,
-+	MMC_ERROR_CC,
-+	MMC_ERROR_GENERAL,
-+	MMC_ERROR_UNDERRUN,
-+	MMC_ERROR_OVERRUN,
-+	MMC_ERROR_CID_CSD_OVERWRITE,
-+	MMC_ERROR_STATE_MISMATCH,
-+	MMC_ERROR_HEADER_MISMATCH,
-+	MMC_ERROR_TIMEOUT,
-+	MMC_ERROR_CRC,
-+	MMC_ERROR_DRIVER_FAILURE,
-+};
-+
-+enum card_state {
-+	CARD_STATE_EMPTY = -1,
-+	CARD_STATE_IDLE	 = 0,
-+	CARD_STATE_READY = 1,
-+	CARD_STATE_IDENT = 2,
-+	CARD_STATE_STBY	 = 3,
-+	CARD_STATE_TRAN	 = 4,
-+	CARD_STATE_DATA	 = 5,
-+	CARD_STATE_RCV	 = 6,
-+	CARD_STATE_PRG	 = 7,
-+	CARD_STATE_DIS	 = 8,
-+};
-+
-+enum mmc_rsp_t {
-+	RESPONSE_NONE   = 0,
-+	RESPONSE_R1     = 1,
-+	RESPONSE_R1B    = 2,
-+	RESPONSE_R2_CID = 3,
-+	RESPONSE_R2_CSD  = 4,
-+	RESPONSE_R3      = 5,
-+	RESPONSE_R4      = 6,
-+	RESPONSE_R5      = 7,
-+        RESPONSE_R6      = 8,
-+};
-+
-+struct mmc_response_r1 {
-+	u8  cmd;
-+	u32 status;
-+};
-+
-+struct mmc_response_r3 {  
-+	u32 ocr;
-+}; 
-+
-+/* the information structure of MMC/SD Card */
-+struct  mmc_info {
-+	int             id;     /* Card index */
-+        int             sd;     /* MMC or SD card */
-+        int             rca;    /* RCA */
-+        u32             scr;    /* SCR 63:32*/
-+	int             flags;  /* Ejected, inserted */
-+	enum card_state state;  /* empty, ident, ready, whatever */
-+
-+	/* Card specific information */
-+	struct mmc_cid  cid;
-+	struct mmc_csd  csd;
-+	u32             block_num;
-+	u32             block_len;
-+	u32             erase_unit;
-+};
-+
-+struct mmc_info mmcinfo;
-+
-+struct mmc_request {
-+	int               index;      /* Slot index - used for CS lines */
-+	int               cmd;        /* Command to send */
-+	u32               arg;        /* Argument to send */
-+	enum mmc_rsp_t    rtype;      /* Response type expected */
-+
-+	/* Data transfer (these may be modified at the low level) */
-+	u16               nob;        /* Number of blocks to transfer*/
-+	u16               block_len;  /* Block length */
-+	u8               *buffer;     /* Data buffer */
-+	u32               cnt;        /* Data length, for PIO */
-+
-+	/* Results */
-+	u8                response[18]; /* Buffer to store response - CRC is optional */
-+	enum mmc_result_t result;
-+};
-+
-+char * mmc_result_to_string(int);
-+int    mmc_unpack_csd(struct mmc_request *request, struct mmc_csd *csd);
-+int    mmc_unpack_r1(struct mmc_request *request, struct mmc_response_r1 *r1, enum card_state state);
-+int    mmc_unpack_r6(struct mmc_request *request, struct mmc_response_r1 *r1, enum card_state state, int *rca);
-+int    mmc_unpack_scr(struct mmc_request *request, struct mmc_response_r1 *r1, enum card_state state, u32 *scr);
-+int    mmc_unpack_cid(struct mmc_request *request, struct mmc_cid *cid);
-+int    mmc_unpack_r3(struct mmc_request *request, struct mmc_response_r3 *r3);
-+
-+void   mmc_send_cmd(struct mmc_request *request, int cmd, u32 arg, 
-+		     u16 nob, u16 block_len, enum mmc_rsp_t rtype, u8 *buffer);
-+u32    mmc_tran_speed(u8 ts);
-+void   jz_mmc_set_clock(int sd, u32 rate);
-+
-+static inline void mmc_simple_cmd(struct mmc_request *request, int cmd, u32 arg, enum mmc_rsp_t rtype)
-+{
-+	mmc_send_cmd( request, cmd, arg, 0, 0, rtype, 0);
-+}
-+
-+#endif /* __MMC_JZMMC_H__ */
-diff --git a/include/configs/qi_lb60.h b/include/configs/qi_lb60.h
-index 7bff444..7b33be0 100644
---- a/include/configs/qi_lb60.h
-+++ b/include/configs/qi_lb60.h
-@@ -31,6 +31,15 @@
- /*
-  * Miscellaneous configurable options
-  */
-+#define CONFIG_JZ4740_MMC
-+#define CONFIG_MMC      	1
-+#define CONFIG_FAT      	1
-+#define CONFIG_DOS_PARTITION	1
-+#define CONFIG_CMD_MMC
-+#define CONFIG_CMD_FAT
-+#define CONFIG_CMD_EXT2
-+
-+
- #define CONFIG_SYS_SDRAM_BASE		0x80000000	/* Cached addr */
- #define CONFIG_SYS_INIT_SP_OFFSET	0x400000
- #define CONFIG_SYS_LOAD_ADDR		0x80600000
-diff --git a/include/mmc.h b/include/mmc.h
-index a13e2bd..3c4761c 100644
---- a/include/mmc.h
-+++ b/include/mmc.h
-@@ -283,4 +283,44 @@ struct mmc *mmc_spi_init(uint bus, uint cs, uint speed, uint mode);
- int mmc_legacy_init(int verbose);
- #endif
- 
-+struct mmc_csd
-+{
-+	u8	csd_structure:2,
-+		spec_vers:4,
-+		rsvd1:2;
-+	u8	taac;
-+	u8	nsac;
-+	u8	tran_speed;
-+	u16	ccc:12,
-+		read_bl_len:4;
-+	u32	c_size:22;
-+	u64	read_bl_partial:1,
-+		write_blk_misalign:1,
-+		read_blk_misalign:1,
-+		dsr_imp:1,
-+		rsvd2:2,
-+		vdd_r_curr_min:3,
-+		vdd_r_curr_max:3,
-+		vdd_w_curr_min:3,
-+		vdd_w_curr_max:3,
-+		c_size_mult:3,
-+		sector_size:5,
-+		erase_grp_size:5,
-+		wp_grp_size:5,
-+		wp_grp_enable:1,
-+		default_ecc:2,
-+		r2w_factor:3,
-+		write_bl_len:4,
-+		write_bl_partial:1,
-+		rsvd3:5;
-+	u8	file_format_grp:1,
-+		copy:1,
-+		perm_write_protect:1,
-+		tmp_write_protect:1,
-+		file_format:2,
-+		ecc:2;
-+	u8	crc:7;
-+	u8	one:1;
-+};
-+
- #endif /* _MMC_H_ */
--- 
-1.7.9.5
-

+ 0 - 200
package/boot/uboot-xburst/patches/0004-add-more-boot-options-F1-F2-F3-F4-M-S.patch

@@ -1,200 +0,0 @@
-From c52b6168979d03fc31205444c3278c537787472a Mon Sep 17 00:00:00 2001
-From: Xiangfu <xiangfu@openmobilefree.net>
-Date: Wed, 10 Oct 2012 18:39:55 +0800
-Subject: [PATCH 4/6] add more boot options(F1/F2/F3/F4/M/S)
-
----
- arch/mips/include/asm/global_data.h |    3 +++
- arch/mips/lib/bootm.c               |   17 ++++++++++++++++-
- board/qi/qi_lb60/qi_lb60.c          |   26 +++++++++++++++++++++++---
- common/main.c                       |   21 +++++++++++++++++++--
- include/configs/qi_lb60.h           |   32 ++++++++++++++++++++++++++++++++
- 5 files changed, 93 insertions(+), 6 deletions(-)
-
-diff --git a/arch/mips/include/asm/global_data.h b/arch/mips/include/asm/global_data.h
-index 6e2cdc7..cd03d7e 100644
---- a/arch/mips/include/asm/global_data.h
-+++ b/arch/mips/include/asm/global_data.h
-@@ -59,6 +59,9 @@ typedef	struct	global_data {
- 	unsigned long	env_valid;	/* Checksum of Environment valid? */
- 	void		**jt;		/* jump table */
- 	char		env_buf[32];	/* buffer for getenv() before reloc. */
-+#if defined(CONFIG_NANONOTE)
-+        unsigned long   boot_option;
-+#endif
- } gd_t;
- 
- #include <asm-generic/global_data_flags.h>
-diff --git a/arch/mips/lib/bootm.c b/arch/mips/lib/bootm.c
-index 608c1a7..e00416b 100644
---- a/arch/mips/lib/bootm.c
-+++ b/arch/mips/lib/bootm.c
-@@ -47,10 +47,25 @@ int do_bootm_linux(int flag, int argc, char * const argv[],
- 			bootm_headers_t *images)
- {
- 	void (*theKernel) (int, char **, char **, int *);
--	char *commandline = getenv("bootargs");
-+	char *commandline;
- 	char env_buf[12];
- 	char *cp;
- 
-+#if defined(CONFIG_NANONOTE)
-+        if (gd->boot_option & BOOT_FROM_MEMCARD)
-+                commandline = getenv ("bootargsfromsd");
-+        else if (gd->boot_option & BOOT_WITH_F1)
-+                commandline = getenv ("bootargsf1");
-+        else if (gd->boot_option & BOOT_WITH_F2)
-+                commandline = getenv ("bootargsf2");
-+        else if (gd->boot_option & BOOT_WITH_F3)
-+                commandline = getenv ("bootargsf3");
-+        else if (gd->boot_option & BOOT_WITH_F4)
-+                commandline = getenv ("bootargsf4");
-+        else
-+#endif
-+                commandline = getenv ("bootargs");
-+
- 	if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
- 		return 1;
- 
-diff --git a/board/qi/qi_lb60/qi_lb60.c b/board/qi/qi_lb60/qi_lb60.c
-index a2ba648..d622219 100644
---- a/board/qi/qi_lb60/qi_lb60.c
-+++ b/board/qi/qi_lb60/qi_lb60.c
-@@ -15,7 +15,7 @@ DECLARE_GLOBAL_DATA_PTR;
- 
- static void gpio_init(void)
- {
--	unsigned int i;
-+	unsigned int i, j;
- 
- 	/* Initialize NAND Flash Pins */
- 	__gpio_as_nand();
-@@ -42,14 +42,34 @@ static void gpio_init(void)
- 
- 	if (__gpio_get_pin(GPIO_KEYIN_BASE + 2) == 0){
- 		printf("[S] pressed, enable UART0\n");
-+		gd->boot_option |= BOOT_WITH_ENABLE_UART;
- 		__gpio_as_uart0();
- 	} else {
- 		__gpio_as_input(GPIO_KEYIN_8);
- 		__gpio_enable_pull(GPIO_KEYIN_8);
- 	}
- 
--	/* enable the TP4, TP5 as UART0 */
--	__gpio_jtag_to_uart0();
-+	if (__gpio_get_pin(GPIO_KEYIN_BASE + 3) == 0) {
-+		printf("[M] pressed, boot from memory card\n");
-+		gd->boot_option |= BOOT_FROM_MEMCARD;
-+		__gpio_jtag_to_uart0();
-+	}
-+
-+	for (j = 0; j < 4; j++) {
-+		for (i = 0; i < 4; i++)
-+			__gpio_set_pin(GPIO_KEYOUT_BASE + i);
-+
-+		__gpio_clear_pin(GPIO_KEYOUT_BASE + j);
-+
-+		if (__gpio_get_pin(GPIO_KEYIN_BASE) == 0) {
-+			printf("[F%d] pressed", (j + 1));
-+			gd->boot_option |= (1 << (j + 2));
-+			/* BOOT_WITH_F1	(1 << 2) */
-+			/* BOOT_WITH_F2	(1 << 3) */
-+			/* BOOT_WITH_F3	(1 << 4) */
-+			/* BOOT_WITH_F4	(1 << 5) */
-+		}
-+	}
- 
- 	__gpio_as_output(GPIO_AUDIO_POP);
- 	__gpio_set_pin(GPIO_AUDIO_POP);
-diff --git a/common/main.c b/common/main.c
-index 9507cec..dbfb7ca 100644
---- a/common/main.c
-+++ b/common/main.c
-@@ -355,7 +355,11 @@ void main_loop (void)
- #if defined(CONFIG_BOOTDELAY) && (CONFIG_BOOTDELAY >= 0)
- 	s = getenv ("bootdelay");
- 	bootdelay = s ? (int)simple_strtol(s, NULL, 10) : CONFIG_BOOTDELAY;
--
-+#if defined(CONFIG_NANONOTE)
-+	DECLARE_GLOBAL_DATA_PTR;
-+	if (gd->boot_option & BOOT_WITH_ENABLE_UART)
-+		bootdelay = 3;
-+# endif
- 	debug ("### main_loop entered: bootdelay=%d\n\n", bootdelay);
- 
- #if defined(CONFIG_MENU_SHOW)
-@@ -379,7 +383,20 @@ void main_loop (void)
- 	}
- 	else
- #endif /* CONFIG_BOOTCOUNT_LIMIT */
--		s = getenv ("bootcmd");
-+#if defined(CONFIG_NANONOTE)
-+		if (gd->boot_option & BOOT_FROM_MEMCARD)
-+			s = getenv ("bootcmdfromsd");
-+		else if (gd->boot_option & BOOT_WITH_F1)
-+			s = getenv ("bootcmdf1");
-+		else if (gd->boot_option & BOOT_WITH_F2)
-+			s = getenv ("bootcmdf2");
-+		else if (gd->boot_option & BOOT_WITH_F3)
-+			s = getenv ("bootcmdf3");
-+		else if (gd->boot_option & BOOT_WITH_F4)
-+			s = getenv ("bootcmdf4");
-+		else
-+#endif
-+			s = getenv ("bootcmd");
- 
- 	debug ("### main_loop: bootcmd=\"%s\"\n", s ? s : "<UNDEFINED>");
- 
-diff --git a/include/configs/qi_lb60.h b/include/configs/qi_lb60.h
-index 7b33be0..52b370c 100644
---- a/include/configs/qi_lb60.h
-+++ b/include/configs/qi_lb60.h
-@@ -31,6 +31,7 @@
- /*
-  * Miscellaneous configurable options
-  */
-+#define CONFIG_NANONOTE
- #define CONFIG_JZ4740_MMC
- #define CONFIG_MMC      	1
- #define CONFIG_FAT      	1
-@@ -39,6 +40,37 @@
- #define CONFIG_CMD_FAT
- #define CONFIG_CMD_EXT2
- 
-+#define CONFIG_CMD_UBIFS
-+#define CONFIG_CMD_UBI
-+#define CONFIG_MTD_PARTITIONS
-+#define CONFIG_MTD_DEVICE
-+#define CONFIG_CMD_MTDPARTS
-+#define CONFIG_CMD_UBI
-+#define CONFIG_CMD_UBIFS
-+#define CONFIG_LZO
-+#define CONFIG_RBTREE
-+
-+#define MTDIDS_DEFAULT		"nand0=jz4740-nand"
-+#define MTDPARTS_DEFAULT	"mtdparts=jz4740-nand:4M@0(uboot)ro,4M@4M(kernel)ro,512M@8M(rootfs)ro,-(data)ro"
-+
-+#define BOOT_FROM_MEMCARD	1
-+#define BOOT_WITH_ENABLE_UART	(1 << 1)	/* Vaule for global_data.h gd->boot_option */
-+#define BOOT_WITH_F1		(1 << 2)
-+#define BOOT_WITH_F2		(1 << 3)
-+#define BOOT_WITH_F3		(1 << 4)
-+#define BOOT_WITH_F4		(1 << 5)
-+
-+#define CONFIG_EXTRA_ENV_SETTINGS \
-+	"bootcmdfromsd=mmc init; ext2load mmc 0 0x80600000 /boot/uImage; bootm;\0" \
-+	"bootargsfromsd=mem=32M console=tty0 console=ttyS0,57600n8 rootfstype=ext2 root=/dev/mmcblk0p1 rw rootwait\0" \
-+	"bootcmdf1=mmc init; ext2load mmc 0:1 0x80600000 /boot/uImage; bootm;\0" \
-+	"bootargsf1=mem=32M console=tty0 console=ttyS0,57600n8 rootfstype=ext2 root=/dev/mmcblk0p1 rw rootwait\0" \
-+	"bootcmdf2=mmc init; ext2load mmc 0:2 0x80600000 /boot/uImage; bootm;\0" \
-+	"bootargsf2=mem=32M console=tty0 console=ttyS0,57600n8 rootfstype=ext2 root=/dev/mmcblk0p2 rw rootwait\0" \
-+	"bootcmdf3=mmc init; ext2load mmc 0:3 0x80600000 /boot/uImage; bootm;\0" \
-+	"bootargsf3=mem=32M console=tty0 console=ttyS0,57600n8 rootfstype=ext2 root=/dev/mmcblk0p3 rw rootwait\0" \
-+	"bootcmdf4=mtdparts default;ubi part rootfs;ubifsmount rootfs;ubifsload 0x80600000 /boot/uImage; bootm;\0" \
-+	"bootargsf4=mem=32M console=tty0 console=ttyS0,57600n8 ubi.mtd=2 rootfstype=ubifs root=ubi0:rootfs rw rootwait"
- 
- #define CONFIG_SYS_SDRAM_BASE		0x80000000	/* Cached addr */
- #define CONFIG_SYS_INIT_SP_OFFSET	0x400000
--- 
-1.7.9.5
-

+ 0 - 847
package/boot/uboot-xburst/patches/0005-add-nanonote-lcd-support.patch

@@ -1,847 +0,0 @@
-From ca8c5216cfd3ad3fda9867ed2d157ae5a209834b Mon Sep 17 00:00:00 2001
-From: Xiangfu <xiangfu@openmobilefree.net>
-Date: Wed, 10 Oct 2012 22:05:27 +0800
-Subject: [PATCH 5/6] add nanonote lcd support
-
----
- arch/mips/include/asm/global_data.h |    1 +
- arch/mips/include/asm/jz4740.h      |   90 ++++++++
- arch/mips/lib/board.c               |    6 +
- common/lcd.c                        |    9 +-
- drivers/video/Makefile              |    1 +
- drivers/video/nanonote_gpm940b0.c   |  400 +++++++++++++++++++++++++++++++++++
- drivers/video/nanonote_gpm940b0.h   |  135 ++++++++++++
- include/configs/qi_lb60.h           |    7 +
- include/lcd.h                       |   52 ++++-
- 9 files changed, 697 insertions(+), 4 deletions(-)
- create mode 100644 drivers/video/nanonote_gpm940b0.c
- create mode 100644 drivers/video/nanonote_gpm940b0.h
-
-diff --git a/arch/mips/include/asm/global_data.h b/arch/mips/include/asm/global_data.h
-index cd03d7e..7cec2de 100644
---- a/arch/mips/include/asm/global_data.h
-+++ b/arch/mips/include/asm/global_data.h
-@@ -44,6 +44,7 @@ typedef	struct	global_data {
- 	unsigned long	per_clk;	/* Peripheral bus clock */
- 	unsigned long	mem_clk;	/* Memory bus clock */
- 	unsigned long	dev_clk;	/* Device clock */
-+        unsigned long   fb_base;        /* base address of framebuffer */
- 	/* "static data" needed by most of timer.c */
- 	unsigned long	tbl;
- 	unsigned long	lastinc;
-diff --git a/arch/mips/include/asm/jz4740.h b/arch/mips/include/asm/jz4740.h
-index 68287fb..13724a2 100644
---- a/arch/mips/include/asm/jz4740.h
-+++ b/arch/mips/include/asm/jz4740.h
-@@ -1312,5 +1312,95 @@ do { 								\
-  	while (REG_MSC_STAT & MSC_STAT_IS_RESETTING);		\
- } while (0)
- 
-+/*************************************************************************
-+ * LCD (LCD Controller)
-+ *************************************************************************/
-+#define REG32(addr)	*((volatile u32 *)(addr))
-+
-+#define	CPM_BASE	0xB0000000
-+#define CPM_CPCCR	(CPM_BASE+0x00)
-+#define REG_CPM_CPCCR	REG32(CPM_CPCCR)
-+
-+#define	LCD_BASE	0xB3050000
-+#define LCD_CFG		(LCD_BASE + 0x00) /* LCD Configure Register */
-+#define LCD_VSYNC	(LCD_BASE + 0x04) /* Vertical Synchronize Register */
-+#define LCD_HSYNC	(LCD_BASE + 0x08) /* Horizontal Synchronize Register */
-+#define LCD_VAT		(LCD_BASE + 0x0c) /* Virtual Area Setting Register */
-+#define LCD_DAH		(LCD_BASE + 0x10) /* Display Area Horizontal Start/End Point */
-+#define LCD_DAV		(LCD_BASE + 0x14) /* Display Area Vertical Start/End Point */
-+#define LCD_PS		(LCD_BASE + 0x18) /* PS Signal Setting */
-+#define LCD_CLS		(LCD_BASE + 0x1c) /* CLS Signal Setting */
-+#define LCD_SPL		(LCD_BASE + 0x20) /* SPL Signal Setting */
-+#define LCD_REV		(LCD_BASE + 0x24) /* REV Signal Setting */
-+#define LCD_CTRL	(LCD_BASE + 0x30) /* LCD Control Register */
-+#define LCD_STATE	(LCD_BASE + 0x34) /* LCD Status Register */
-+#define LCD_IID		(LCD_BASE + 0x38) /* Interrupt ID Register */
-+#define LCD_DA0		(LCD_BASE + 0x40) /* Descriptor Address Register 0 */
-+#define LCD_SA0		(LCD_BASE + 0x44) /* Source Address Register 0 */
-+#define LCD_FID0	(LCD_BASE + 0x48) /* Frame ID Register 0 */
-+#define LCD_CMD0	(LCD_BASE + 0x4c) /* DMA Command Register 0 */
-+#define LCD_DA1		(LCD_BASE + 0x50) /* Descriptor Address Register 1 */
-+#define LCD_SA1		(LCD_BASE + 0x54) /* Source Address Register 1 */
-+#define LCD_FID1	(LCD_BASE + 0x58) /* Frame ID Register 1 */
-+#define LCD_CMD1	(LCD_BASE + 0x5c) /* DMA Command Register 1 */
-+
-+#define REG_LCD_CFG	REG32(LCD_CFG)
-+#define REG_LCD_VSYNC	REG32(LCD_VSYNC)
-+#define REG_LCD_HSYNC	REG32(LCD_HSYNC)
-+#define REG_LCD_VAT	REG32(LCD_VAT)
-+#define REG_LCD_DAH	REG32(LCD_DAH)
-+#define REG_LCD_DAV	REG32(LCD_DAV)
-+#define REG_LCD_PS	REG32(LCD_PS)
-+#define REG_LCD_CLS	REG32(LCD_CLS)
-+#define REG_LCD_SPL	REG32(LCD_SPL)
-+#define REG_LCD_REV	REG32(LCD_REV)
-+#define REG_LCD_CTRL	REG32(LCD_CTRL)
-+#define REG_LCD_STATE	REG32(LCD_STATE)
-+#define REG_LCD_IID	REG32(LCD_IID)
-+#define REG_LCD_DA0	REG32(LCD_DA0)
-+#define REG_LCD_SA0	REG32(LCD_SA0)
-+#define REG_LCD_FID0	REG32(LCD_FID0)
-+#define REG_LCD_CMD0	REG32(LCD_CMD0)
-+#define REG_LCD_DA1	REG32(LCD_DA1)
-+#define REG_LCD_SA1	REG32(LCD_SA1)
-+#define REG_LCD_FID1	REG32(LCD_FID1)
-+#define REG_LCD_CMD1	REG32(LCD_CMD1)
-+
-+#define LCD_CTRL_BPP_BIT	0  /* Bits Per Pixel */
-+#define LCD_CTRL_BPP_MASK	(0x07 << LCD_CTRL_BPP_BIT)
-+  #define LCD_CTRL_BPP_1	(0 << LCD_CTRL_BPP_BIT) /* 1 bpp */
-+  #define LCD_CTRL_BPP_2	(1 << LCD_CTRL_BPP_BIT) /* 2 bpp */
-+  #define LCD_CTRL_BPP_4	(2 << LCD_CTRL_BPP_BIT) /* 4 bpp */
-+  #define LCD_CTRL_BPP_8	(3 << LCD_CTRL_BPP_BIT) /* 8 bpp */
-+  #define LCD_CTRL_BPP_16	(4 << LCD_CTRL_BPP_BIT) /* 15/16 bpp */
-+  #define LCD_CTRL_BPP_18_24	(5 << LCD_CTRL_BPP_BIT) /* 18/24/32 bpp */
-+
-+#define LCD_CTRL_BST_BIT	28  /* Burst Length Selection */
-+#define LCD_CTRL_BST_MASK	(0x03 << LCD_CTRL_BST_BIT)
-+  #define LCD_CTRL_BST_4	(0 << LCD_CTRL_BST_BIT) /* 4-word */
-+  #define LCD_CTRL_BST_8	(1 << LCD_CTRL_BST_BIT) /* 8-word */
-+  #define LCD_CTRL_BST_16	(2 << LCD_CTRL_BST_BIT) /* 16-word */
-+#define LCD_CTRL_RGB565		(0 << 27) /* RGB565 mode */
-+#define LCD_CTRL_RGB555		(1 << 27) /* RGB555 mode */
-+#define LCD_CTRL_OFUP		(1 << 26) /* Output FIFO underrun protection enable */
-+#define LCD_CTRL_FRC_BIT	24  /* STN FRC Algorithm Selection */
-+#define LCD_CTRL_FRC_MASK	(0x03 << LCD_CTRL_FRC_BIT)
-+  #define LCD_CTRL_FRC_16	(0 << LCD_CTRL_FRC_BIT) /* 16 grayscale */
-+  #define LCD_CTRL_FRC_4	(1 << LCD_CTRL_FRC_BIT) /* 4 grayscale */
-+  #define LCD_CTRL_FRC_2	(2 << LCD_CTRL_FRC_BIT) /* 2 grayscale */
-+
-+#define CPM_LPCDR	(CPM_BASE+0x64)
-+#define CPM_CLKGR	(CPM_BASE+0x20)
-+#define REG_CPM_LPCDR	REG32(CPM_LPCDR)
-+#define REG_CPM_CLKGR	REG32(CPM_CLKGR)
-+
-+#define __cpm_start_tcu()	(REG_CPM_CLKGR &= ~CPM_CLKGR_TCU)
-+#define __cpm_stop_lcd()	(REG_CPM_CLKGR |= CPM_CLKGR_LCD)
-+#define __cpm_set_pixdiv(v) \
-+	(REG_CPM_LPCDR = (REG_CPM_LPCDR & ~CPM_LPCDR_PIXDIV_MASK) | ((v) << (CPM_LPCDR_PIXDIV_BIT)))
-+#define __cpm_set_ldiv(v) \
-+	(REG_CPM_CPCCR = (REG_CPM_CPCCR & ~CPM_CPCCR_LDIV_MASK) | ((v) << (CPM_CPCCR_LDIV_BIT)))
-+#define __cpm_start_lcd()	(REG_CPM_CLKGR &= ~CPM_CLKGR_LCD)
-+
- #endif	/* !__ASSEMBLY__ */
- #endif	/* __JZ4740_H__ */
-diff --git a/arch/mips/lib/board.c b/arch/mips/lib/board.c
-index b14b33e..c2e64d9 100644
---- a/arch/mips/lib/board.c
-+++ b/arch/mips/lib/board.c
-@@ -172,6 +172,12 @@ void board_init_f(ulong bootflag)
- 	addr &= ~(4096 - 1);
- 	debug("Top of RAM usable for U-Boot at: %08lx\n", addr);
- 
-+#ifdef CONFIG_LCD
-+        /* reserve memory for LCD display (always full pages) */
-+        addr = lcd_setmem (addr);
-+        gd->fb_base = addr;
-+#endif /* CONFIG_LCD */
-+
- 	/* Reserve memory for U-Boot code, data & bss
- 	 * round down to next 16 kB limit
- 	 */
-diff --git a/common/lcd.c b/common/lcd.c
-index b6be800..af1281a 100644
---- a/common/lcd.c
-+++ b/common/lcd.c
-@@ -263,6 +263,13 @@ static void lcd_drawchars(ushort x, ushort y, uchar *str, int count)
- 						lcd_color_fg : lcd_color_bg;
- 				bits <<= 1;
- 			}
-+#elif LCD_BPP == LCD_COLOR32
-+                       uint *m = (uint *)d;
-+                       for (c=0; c<32; ++c) {
-+                               *m++ = (bits & 0x80) ?
-+				       lcd_color_fg : lcd_color_bg;
-+                               bits <<= 1;
-+                       }
- #endif
- 		}
- #if LCD_BPP == LCD_MONOCHROME
-@@ -509,7 +516,7 @@ static inline ushort *configuration_get_cmap(void)
- 	return (ushort *)&(cp->lcd_cmap[255 * sizeof(ushort)]);
- #elif defined(CONFIG_ATMEL_LCD)
- 	return (ushort *)(panel_info.mmio + ATMEL_LCDC_LUT(0));
--#elif !defined(CONFIG_ATMEL_HLCD) && !defined(CONFIG_EXYNOS_FB)
-+#elif !defined(CONFIG_ATMEL_HLCD) && !defined(CONFIG_EXYNOS_FB) && !defined(CONFIG_VIDEO_GPM940B0)
- 	return panel_info.cmap;
- #else
- #if defined(CONFIG_LCD_LOGO)
-diff --git a/drivers/video/Makefile b/drivers/video/Makefile
-index ebb6da8..03625bc 100644
---- a/drivers/video/Makefile
-+++ b/drivers/video/Makefile
-@@ -50,6 +50,7 @@ COBJS-$(CONFIG_VIDEO_SED13806) += sed13806.o
- COBJS-$(CONFIG_VIDEO_SM501) += sm501.o
- COBJS-$(CONFIG_VIDEO_SMI_LYNXEM) += smiLynxEM.o videomodes.o
- COBJS-$(CONFIG_VIDEO_VCXK) += bus_vcxk.o
-+COBJS-$(CONFIG_VIDEO_GPM940B0) += nanonote_gpm940b0.o
- 
- COBJS	:= $(sort $(COBJS-y))
- SRCS	:= $(COBJS:.o=.c)
-diff --git a/drivers/video/nanonote_gpm940b0.c b/drivers/video/nanonote_gpm940b0.c
-new file mode 100644
-index 0000000..11efb72
---- /dev/null
-+++ b/drivers/video/nanonote_gpm940b0.c
-@@ -0,0 +1,400 @@
-+/*
-+ * JzRISC lcd controller
-+ *
-+ * Xiangfu Liu <xiangfu@sharism.cc>
-+ *
-+ * 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, write to the Free Software
-+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
-+ * MA 02111-1307 USA
-+ */
-+
-+#include <config.h>
-+#include <common.h>
-+#include <lcd.h>
-+
-+#include <asm/io.h>               /* virt_to_phys() */
-+#include <asm/jz4740.h>
-+
-+#include "nanonote_gpm940b0.h"
-+
-+#define align2(n) (n)=((((n)+1)>>1)<<1)
-+#define align4(n) (n)=((((n)+3)>>2)<<2)
-+#define align8(n) (n)=((((n)+7)>>3)<<3)
-+
-+struct jzfb_info {
-+	unsigned int cfg;	/* panel mode and pin usage etc. */
-+	unsigned int w;
-+	unsigned int h;
-+	unsigned int bpp;	/* bit per pixel */
-+	unsigned int fclk;	/* frame clk */
-+	unsigned int hsw;	/* hsync width, in pclk */
-+	unsigned int vsw;	/* vsync width, in line count */
-+	unsigned int elw;	/* end of line, in pclk */
-+	unsigned int blw;	/* begin of line, in pclk */
-+	unsigned int efw;	/* end of frame, in line count */
-+	unsigned int bfw;	/* begin of frame, in line count */
-+};
-+
-+static struct jzfb_info jzfb = {
-+	MODE_8BIT_SERIAL_TFT | PCLK_N | HSYNC_N | VSYNC_N,
-+	320, 240, 32, 70, 1, 1, 273, 140, 1, 20
-+};
-+
-+vidinfo_t panel_info = {
-+	320, 240, LCD_BPP,
-+};
-+
-+void *lcd_base;
-+void *lcd_console_address;
-+int lcd_line_length;
-+int lcd_color_fg;
-+int lcd_color_bg;
-+short console_col;
-+short console_row;
-+
-+static int jz_lcd_init_mem(void *lcdbase, vidinfo_t *vid)
-+{
-+	u_long palette_mem_size;
-+	struct jz_fb_info *fbi = &vid->jz_fb;
-+	int fb_size = vid->vl_row * (vid->vl_col * NBITS (vid->vl_bpix)) / 8;
-+
-+	fbi->screen = (u_long)lcdbase;
-+	fbi->palette_size = 256;
-+	palette_mem_size = fbi->palette_size * sizeof(u16);
-+
-+	debug("jz_lcd.c palette_mem_size = 0x%08lx\n", (u_long) palette_mem_size);
-+	/* locate palette and descs at end of page following fb */
-+	fbi->palette = (u_long)lcdbase + fb_size + PAGE_SIZE - palette_mem_size;
-+
-+	return 0;
-+}
-+
-+static void jz_lcd_desc_init(vidinfo_t *vid)
-+{
-+	struct jz_fb_info * fbi;
-+	fbi = &vid->jz_fb;
-+	fbi->dmadesc_fblow = (struct jz_fb_dma_descriptor *)((unsigned int)fbi->palette - 3*16);
-+	fbi->dmadesc_fbhigh = (struct jz_fb_dma_descriptor *)((unsigned int)fbi->palette - 2*16);
-+	fbi->dmadesc_palette = (struct jz_fb_dma_descriptor *)((unsigned int)fbi->palette - 1*16);
-+
-+	#define BYTES_PER_PANEL	 (vid->vl_col * vid->vl_row * NBITS(vid->vl_bpix) / 8)
-+
-+	/* populate descriptors */
-+	fbi->dmadesc_fblow->fdadr = virt_to_phys(fbi->dmadesc_fblow);
-+	fbi->dmadesc_fblow->fsadr = virt_to_phys((void *)(fbi->screen + BYTES_PER_PANEL));
-+	fbi->dmadesc_fblow->fidr  = 0;
-+	fbi->dmadesc_fblow->ldcmd = BYTES_PER_PANEL / 4 ;
-+
-+	fbi->fdadr1 = virt_to_phys(fbi->dmadesc_fblow); /* only used in dual-panel mode */
-+
-+	fbi->dmadesc_fbhigh->fsadr = virt_to_phys((void *)fbi->screen);
-+	fbi->dmadesc_fbhigh->fidr = 0;
-+	fbi->dmadesc_fbhigh->ldcmd =  BYTES_PER_PANEL / 4; /* length in word */
-+
-+	fbi->dmadesc_palette->fsadr = virt_to_phys((void *)fbi->palette);
-+	fbi->dmadesc_palette->fidr  = 0;
-+	fbi->dmadesc_palette->ldcmd = (fbi->palette_size * 2)/4 | (1<<28);
-+
-+	if(NBITS(vid->vl_bpix) < 12) {
-+		/* assume any mode with <12 bpp is palette driven */
-+		fbi->dmadesc_palette->fdadr = virt_to_phys(fbi->dmadesc_fbhigh);
-+		fbi->dmadesc_fbhigh->fdadr = virt_to_phys(fbi->dmadesc_palette);
-+		/* flips back and forth between pal and fbhigh */
-+		fbi->fdadr0 = virt_to_phys(fbi->dmadesc_palette);
-+	} else {
-+		/* palette shouldn't be loaded in true-color mode */
-+		fbi->dmadesc_fbhigh->fdadr = virt_to_phys((void *)fbi->dmadesc_fbhigh);
-+		fbi->fdadr0 = virt_to_phys(fbi->dmadesc_fbhigh); /* no pal just fbhigh */
-+	}
-+}
-+
-+static int  jz_lcd_hw_init(vidinfo_t *vid)
-+{
-+	struct jz_fb_info *fbi = &vid->jz_fb;
-+	unsigned int val = 0;
-+	unsigned int pclk;
-+	unsigned int stnH;
-+	int pll_div;
-+
-+	/* Setting Control register */
-+	switch (jzfb.bpp) {
-+	case 1:
-+		val |= LCD_CTRL_BPP_1;
-+		break;
-+	case 2:
-+		val |= LCD_CTRL_BPP_2;
-+		break;
-+	case 4:
-+		val |= LCD_CTRL_BPP_4;
-+		break;
-+	case 8:
-+		val |= LCD_CTRL_BPP_8;
-+		break;
-+	case 15:
-+		val |= LCD_CTRL_RGB555;
-+	case 16:
-+		val |= LCD_CTRL_BPP_16;
-+		break;
-+	case 17 ... 32:
-+		val |= LCD_CTRL_BPP_18_24;	/* target is 4bytes/pixel */
-+		break;
-+
-+	default:
-+		printf("jz_lcd.c The BPP %d is not supported\n", jzfb.bpp);
-+		val |= LCD_CTRL_BPP_16;
-+		break;
-+	}
-+
-+	switch (jzfb.cfg & MODE_MASK) {
-+	case MODE_STN_MONO_DUAL:
-+	case MODE_STN_COLOR_DUAL:
-+	case MODE_STN_MONO_SINGLE:
-+	case MODE_STN_COLOR_SINGLE:
-+		switch (jzfb.bpp) {
-+		case 1:
-+			/* val |= LCD_CTRL_PEDN; */
-+		case 2:
-+			val |= LCD_CTRL_FRC_2;
-+			break;
-+		case 4:
-+			val |= LCD_CTRL_FRC_4;
-+			break;
-+		case 8:
-+		default:
-+			val |= LCD_CTRL_FRC_16;
-+			break;
-+		}
-+		break;
-+	}
-+
-+	val |= LCD_CTRL_BST_16;		/* Burst Length is 16WORD=64Byte */
-+	val |= LCD_CTRL_OFUP;		/* OutFIFO underrun protect */
-+
-+	switch (jzfb.cfg & MODE_MASK) {
-+	case MODE_STN_MONO_DUAL:
-+	case MODE_STN_COLOR_DUAL:
-+	case MODE_STN_MONO_SINGLE:
-+	case MODE_STN_COLOR_SINGLE:
-+		switch (jzfb.cfg & STN_DAT_PINMASK) {
-+		case STN_DAT_PIN1:
-+			/* Do not adjust the hori-param value. */
-+			break;
-+		case STN_DAT_PIN2:
-+			align2(jzfb.hsw);
-+			align2(jzfb.elw);
-+			align2(jzfb.blw);
-+			break;
-+		case STN_DAT_PIN4:
-+			align4(jzfb.hsw);
-+			align4(jzfb.elw);
-+			align4(jzfb.blw);
-+			break;
-+		case STN_DAT_PIN8:
-+			align8(jzfb.hsw);
-+			align8(jzfb.elw);
-+			align8(jzfb.blw);
-+			break;
-+		}
-+		break;
-+	}
-+
-+	REG_LCD_CTRL = val;
-+
-+	switch (jzfb.cfg & MODE_MASK) {
-+	case MODE_STN_MONO_DUAL:
-+	case MODE_STN_COLOR_DUAL:
-+	case MODE_STN_MONO_SINGLE:
-+	case MODE_STN_COLOR_SINGLE:
-+		if (((jzfb.cfg & MODE_MASK) == MODE_STN_MONO_DUAL) ||
-+		    ((jzfb.cfg & MODE_MASK) == MODE_STN_COLOR_DUAL))
-+			stnH = jzfb.h >> 1;
-+		else
-+			stnH = jzfb.h;
-+
-+		REG_LCD_VSYNC = (0 << 16) | jzfb.vsw;
-+		REG_LCD_HSYNC = ((jzfb.blw+jzfb.w) << 16) | (jzfb.blw+jzfb.w+jzfb.hsw);
-+
-+		/* Screen setting */
-+		REG_LCD_VAT = ((jzfb.blw + jzfb.w + jzfb.hsw + jzfb.elw) << 16) | (stnH + jzfb.vsw + jzfb.bfw + jzfb.efw);
-+		REG_LCD_DAH = (jzfb.blw << 16) | (jzfb.blw + jzfb.w);
-+		REG_LCD_DAV = (0 << 16) | (stnH);
-+
-+		/* AC BIAs signal */
-+		REG_LCD_PS = (0 << 16) | (stnH+jzfb.vsw+jzfb.efw+jzfb.bfw);
-+
-+		break;
-+
-+	case MODE_TFT_GEN:
-+	case MODE_TFT_SHARP:
-+	case MODE_TFT_CASIO:
-+	case MODE_TFT_SAMSUNG:
-+	case MODE_8BIT_SERIAL_TFT:
-+	case MODE_TFT_18BIT:
-+		REG_LCD_VSYNC = (0 << 16) | jzfb.vsw;
-+		REG_LCD_HSYNC = (0 << 16) | jzfb.hsw;
-+		REG_LCD_DAV =((jzfb.vsw+jzfb.bfw) << 16) | (jzfb.vsw +jzfb.bfw+jzfb.h);
-+		REG_LCD_DAH = ((jzfb.hsw + jzfb.blw) << 16) | (jzfb.hsw + jzfb.blw + jzfb.w );
-+		REG_LCD_VAT = (((jzfb.blw + jzfb.w + jzfb.elw + jzfb.hsw)) << 16) \
-+			| (jzfb.vsw + jzfb.bfw + jzfb.h + jzfb.efw);
-+		break;
-+	}
-+
-+	switch (jzfb.cfg & MODE_MASK) {
-+	case MODE_TFT_SAMSUNG:
-+	{
-+		unsigned int total, tp_s, tp_e, ckv_s, ckv_e;
-+		unsigned int rev_s, rev_e, inv_s, inv_e;
-+
-+		pclk = val * (jzfb.w + jzfb.hsw + jzfb.elw + jzfb.blw) *
-+			(jzfb.h + jzfb.vsw + jzfb.efw + jzfb.bfw); /* Pixclk */
-+
-+		total = jzfb.blw + jzfb.w + jzfb.elw + jzfb.hsw;
-+		tp_s = jzfb.blw + jzfb.w + 1;
-+		tp_e = tp_s + 1;
-+		ckv_s = tp_s - pclk/(1000000000/4100);
-+		ckv_e = tp_s + total;
-+		rev_s = tp_s - 11;	/* -11.5 clk */
-+		rev_e = rev_s + total;
-+		inv_s = tp_s;
-+		inv_e = inv_s + total;
-+		REG_LCD_CLS = (tp_s << 16) | tp_e;
-+		REG_LCD_PS = (ckv_s << 16) | ckv_e;
-+		REG_LCD_SPL = (rev_s << 16) | rev_e;
-+		REG_LCD_REV = (inv_s << 16) | inv_e;
-+		jzfb.cfg |= STFT_REVHI | STFT_SPLHI;
-+		break;
-+	}
-+	case MODE_TFT_SHARP:
-+	{
-+		unsigned int total, cls_s, cls_e, ps_s, ps_e;
-+		unsigned int spl_s, spl_e, rev_s, rev_e;
-+		total = jzfb.blw + jzfb.w + jzfb.elw + jzfb.hsw;
-+		spl_s = 1;
-+		spl_e = spl_s + 1;
-+		cls_s = 0;
-+		cls_e = total - 60;	/* > 4us (pclk = 80ns) */
-+		ps_s = cls_s;
-+		ps_e = cls_e;
-+		rev_s = total - 40;	/* > 3us (pclk = 80ns) */
-+		rev_e = rev_s + total;
-+		jzfb.cfg |= STFT_PSHI; 
-+		REG_LCD_SPL = (spl_s << 16) | spl_e;
-+		REG_LCD_CLS = (cls_s << 16) | cls_e;
-+		REG_LCD_PS = (ps_s << 16) | ps_e;
-+		REG_LCD_REV = (rev_s << 16) | rev_e;
-+		break;
-+	}
-+	case MODE_TFT_CASIO:
-+		break;
-+	}
-+
-+	/* Configure the LCD panel */
-+	REG_LCD_CFG = jzfb.cfg;
-+
-+	/* Timing setting */
-+	__cpm_stop_lcd();
-+
-+	val = jzfb.fclk; /* frame clk */
-+	if ( (jzfb.cfg & MODE_MASK) != MODE_8BIT_SERIAL_TFT) {
-+		pclk = val * (jzfb.w + jzfb.hsw + jzfb.elw + jzfb.blw) *
-+			(jzfb.h + jzfb.vsw + jzfb.efw + jzfb.bfw); /* Pixclk */
-+	} else {
-+		/* serial mode: Hsync period = 3*Width_Pixel */
-+		pclk = val * (jzfb.w*3 + jzfb.hsw + jzfb.elw + jzfb.blw) *
-+			(jzfb.h + jzfb.vsw + jzfb.efw + jzfb.bfw); /* Pixclk */
-+	}
-+
-+	if (((jzfb.cfg & MODE_MASK) == MODE_STN_COLOR_SINGLE) ||
-+	    ((jzfb.cfg & MODE_MASK) == MODE_STN_COLOR_DUAL))
-+		pclk = (pclk * 3);
-+
-+	if (((jzfb.cfg & MODE_MASK) == MODE_STN_COLOR_SINGLE) ||
-+	    ((jzfb.cfg & MODE_MASK) == MODE_STN_COLOR_DUAL) ||
-+	    ((jzfb.cfg & MODE_MASK) == MODE_STN_MONO_SINGLE) ||
-+	    ((jzfb.cfg & MODE_MASK) == MODE_STN_MONO_DUAL))
-+		pclk = pclk >> ((jzfb.cfg & STN_DAT_PINMASK) >> 4);
-+
-+	if (((jzfb.cfg & MODE_MASK) == MODE_STN_COLOR_DUAL) ||
-+	    ((jzfb.cfg & MODE_MASK) == MODE_STN_MONO_DUAL))
-+		pclk >>= 1;
-+
-+	pll_div = (REG_CPM_CPCCR & CPM_CPCCR_PCS); /* clock source,0:pllout/2 1: pllout */
-+	pll_div = pll_div ? 1 : 2;
-+	val = (__cpm_get_pllout() / pll_div) / pclk;
-+	val--;
-+	if (val > 0x1ff) {
-+		printf("CPM_LPCDR too large, set it to 0x1ff\n");
-+		val = 0x1ff;
-+	}
-+	__cpm_set_pixdiv(val);
-+
-+	val = pclk * 3 ;	/* LCDClock > 2.5*Pixclock */
-+	if (val > 150000000) {
-+		printf("Warning: LCDClock=%d\n, LCDClock must less or equal to 150MHz.\n", val);
-+		printf("Change LCDClock to 150MHz\n");
-+		val = 150000000;
-+	}
-+	val = (__cpm_get_pllout() / pll_div) / val;
-+	val--;
-+	if (val > 0x1f) {
-+		printf("CPM_CPCCR.LDIV too large, set it to 0x1f\n");
-+		val = 0x1f;
-+	}
-+	__cpm_set_ldiv( val );
-+	REG_CPM_CPCCR |= CPM_CPCCR_CE ; /* update divide */
-+
-+	__cpm_start_lcd();
-+	udelay(1000);
-+
-+	REG_LCD_DA0 = fbi->fdadr0; /* frame descripter*/
-+
-+	if (((jzfb.cfg & MODE_MASK) == MODE_STN_COLOR_DUAL) ||
-+	    ((jzfb.cfg & MODE_MASK) == MODE_STN_MONO_DUAL))
-+		REG_LCD_DA1 = fbi->fdadr1; /* frame descripter*/
-+
-+	return 0;
-+}
-+
-+void lcd_ctrl_init (void *lcdbase)
-+{
-+	__lcd_display_pin_init();
-+	__lcd_display_on() ;
-+
-+	jz_lcd_init_mem(lcdbase, &panel_info);
-+	jz_lcd_desc_init(&panel_info);
-+	jz_lcd_hw_init(&panel_info);
-+
-+}
-+
-+/*
-+ * Before enabled lcd controller, lcd registers should be configured correctly.
-+ */
-+void lcd_enable (void)
-+{
-+	REG_LCD_CTRL &= ~(1<<4); /* LCDCTRL.DIS */
-+	REG_LCD_CTRL |= 1<<3;    /* LCDCTRL.ENA*/
-+}
-+
-+void lcd_disable (void)
-+{
-+	REG_LCD_CTRL |= (1<<4);
-+}
-+
-+void lcd_setcolreg (ushort regno, ushort red, ushort green, ushort blue)
-+{
-+}
-+
-+void lcd_initcolregs (void)
-+{
-+}
-diff --git a/drivers/video/nanonote_gpm940b0.h b/drivers/video/nanonote_gpm940b0.h
-new file mode 100644
-index 0000000..efe491e
---- /dev/null
-+++ b/drivers/video/nanonote_gpm940b0.h
-@@ -0,0 +1,135 @@
-+/*
-+ * JzRISC lcd controller
-+ *
-+ * Xiangfu Liu <xiangfu@sharism.cc>
-+ *
-+ * 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, write to the Free Software
-+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
-+ * MA 02111-1307 USA
-+ */
-+
-+#ifndef __QI_LB60_GPM940B0_H__
-+#define __QI_LB60_GPM940B0_H__
-+
-+struct lcd_desc{
-+	unsigned int next_desc; /* LCDDAx */
-+	unsigned int databuf;   /* LCDSAx */
-+	unsigned int frame_id;  /* LCDFIDx */ 
-+	unsigned int cmd;       /* LCDCMDx */
-+};
-+
-+#define MODE_MASK		0x0f
-+#define MODE_TFT_GEN		0x00
-+#define MODE_TFT_SHARP		0x01
-+#define MODE_TFT_CASIO		0x02
-+#define MODE_TFT_SAMSUNG	0x03
-+#define MODE_CCIR656_NONINT	0x04
-+#define MODE_CCIR656_INT	0x05
-+#define MODE_STN_COLOR_SINGLE	0x08
-+#define MODE_STN_MONO_SINGLE	0x09
-+#define MODE_STN_COLOR_DUAL	0x0a
-+#define MODE_STN_MONO_DUAL	0x0b
-+#define MODE_8BIT_SERIAL_TFT    0x0c
-+
-+#define MODE_TFT_18BIT          (1<<7)
-+
-+#define STN_DAT_PIN1	(0x00 << 4)
-+#define STN_DAT_PIN2	(0x01 << 4)
-+#define STN_DAT_PIN4	(0x02 << 4)
-+#define STN_DAT_PIN8	(0x03 << 4)
-+#define STN_DAT_PINMASK	STN_DAT_PIN8
-+
-+#define STFT_PSHI	(1 << 15)
-+#define STFT_CLSHI	(1 << 14)
-+#define STFT_SPLHI	(1 << 13)
-+#define STFT_REVHI	(1 << 12)
-+
-+#define SYNC_MASTER	(0 << 16)
-+#define SYNC_SLAVE	(1 << 16)
-+
-+#define DE_P		(0 << 9)
-+#define DE_N		(1 << 9)
-+
-+#define PCLK_P		(0 << 10)
-+#define PCLK_N		(1 << 10)
-+
-+#define HSYNC_P		(0 << 11)
-+#define HSYNC_N		(1 << 11)
-+
-+#define VSYNC_P		(0 << 8)
-+#define VSYNC_N		(1 << 8)
-+
-+#define DATA_NORMAL	(0 << 17)
-+#define DATA_INVERSE	(1 << 17)
-+
-+
-+/* Jz LCDFB supported I/O controls. */
-+#define FBIOSETBACKLIGHT	0x4688
-+#define FBIODISPON		0x4689
-+#define FBIODISPOFF		0x468a
-+#define FBIORESET		0x468b
-+#define FBIOPRINT_REG		0x468c
-+
-+/*
-+ * LCD panel specific definition
-+ */
-+#define MODE	(0xc9)		/* 8bit serial RGB */
-+
-+#define __spi_write_reg1(reg, val)		\
-+do {						\
-+	unsigned char no;			\
-+	unsigned short value;			\
-+	unsigned char a=reg;			\
-+	unsigned char b=val;			\
-+	__gpio_set_pin(SPEN);			\
-+	__gpio_set_pin(SPCK);			\
-+	__gpio_clear_pin(SPDA);			\
-+	__gpio_clear_pin(SPEN);			\
-+	value=((a<<8)|(b&0xFF));		\
-+	for(no=0;no<16;no++)			\
-+	{					\
-+		__gpio_clear_pin(SPCK);		\
-+		if((value&0x8000)==0x8000)	\
-+			__gpio_set_pin(SPDA);	\
-+		else				\
-+			__gpio_clear_pin(SPDA);	\
-+		__gpio_set_pin(SPCK);		\
-+		value=(value<<1);		\
-+	}					\
-+	__gpio_set_pin(SPEN);			\
-+} while (0)
-+
-+#define __lcd_display_pin_init()		\
-+do {						\
-+	__cpm_start_tcu();			\
-+	__gpio_as_output(SPEN); /* use SPDA */	\
-+	__gpio_as_output(SPCK); /* use SPCK */	\
-+	__gpio_as_output(SPDA); /* use SPDA */	\
-+} while (0)
-+
-+#define __lcd_display_on()			\
-+do {						\
-+	__spi_write_reg1(0x05, 0x1e);		\
-+	__spi_write_reg1(0x05, 0x5e);		\
-+	__spi_write_reg1(0x07, 0x8d);		\
-+	__spi_write_reg1(0x13, 0x01);		\
-+	__spi_write_reg1(0x05, 0x5f);		\
-+} while (0)
-+
-+#define __lcd_display_off()			\
-+do {						\
-+	__spi_write_reg1(0x05, 0x5e);		\
-+} while (0)
-+
-+#endif /* __QI_LB60_GPM940B0_H__ */
-diff --git a/include/configs/qi_lb60.h b/include/configs/qi_lb60.h
-index 52b370c..d3e78ad 100644
---- a/include/configs/qi_lb60.h
-+++ b/include/configs/qi_lb60.h
-@@ -32,6 +32,13 @@
-  * Miscellaneous configurable options
-  */
- #define CONFIG_NANONOTE
-+
-+#define CONFIG_LCD
-+#define CONFIG_SYS_WHITE_ON_BLACK
-+#define LCD_BPP			LCD_COLOR32
-+#define CONFIG_VIDEO_GPM940B0
-+
-+
- #define CONFIG_JZ4740_MMC
- #define CONFIG_MMC      	1
- #define CONFIG_FAT      	1
-diff --git a/include/lcd.h b/include/lcd.h
-index 42070d7..6de5482 100644
---- a/include/lcd.h
-+++ b/include/lcd.h
-@@ -263,8 +263,44 @@ typedef struct vidinfo {
- 
- void init_panel_info(vidinfo_t *vid);
- 
--#else
-+#elif defined(CONFIG_JZSOC)
-+/*
-+ * LCD controller stucture for JZSOC: JZ4740
-+ */
-+struct jz_fb_dma_descriptor {
-+       u_long  fdadr;          /* Frame descriptor address register */
-+       u_long  fsadr;          /* Frame source address register */
-+       u_long  fidr;           /* Frame ID register */
-+       u_long  ldcmd;          /* Command register */
-+};
-+
-+/*
-+ * Jz LCD info
-+ */
-+struct jz_fb_info {
-+
-+       u_long  fdadr0; /* physical address of frame/palette descriptor */
-+       u_long  fdadr1; /* physical address of frame descriptor */
-+
-+       /* DMA descriptors */
-+       struct  jz_fb_dma_descriptor *  dmadesc_fblow;
-+       struct  jz_fb_dma_descriptor *  dmadesc_fbhigh;
-+       struct  jz_fb_dma_descriptor *  dmadesc_palette;
-+       u_long  screen;         /* address of frame buffer */
-+       u_long  palette;        /* address of palette memory */
-+       u_int   palette_size;
-+};
-+typedef struct vidinfo {
-+       ushort  vl_col;         /* Number of columns (i.e. 640) */
-+       ushort  vl_row;         /* Number of rows (i.e. 480) */
-+       u_char  vl_bpix;        /* Bits per pixel, 0 = 1, 1 = 2, 2 = 4, 3 = 8 */
-+
-+       struct jz_fb_info jz_fb;
-+} vidinfo_t;
-+
-+extern vidinfo_t panel_info;
- 
-+#else
- typedef struct vidinfo {
- 	ushort	vl_col;		/* Number of columns (i.e. 160) */
- 	ushort	vl_row;		/* Number of rows (i.e. 100) */
-@@ -318,6 +354,7 @@ void lcd_show_board_info(void);
- #define LCD_COLOR4	2
- #define LCD_COLOR8	3
- #define LCD_COLOR16	4
-+#define LCD_COLOR32	5
- 
- /*----------------------------------------------------------------------*/
- #if defined(CONFIG_LCD_INFO_BELOW_LOGO)
-@@ -369,7 +406,7 @@ void lcd_show_board_info(void);
- # define CONSOLE_COLOR_GREY	14
- # define CONSOLE_COLOR_WHITE	15	/* Must remain last / highest	*/
- 
--#else
-+#elif LCD_BPP == LCD_COLOR16
- 
- /*
-  * 16bpp color definitions
-@@ -377,6 +414,15 @@ void lcd_show_board_info(void);
- # define CONSOLE_COLOR_BLACK	0x0000
- # define CONSOLE_COLOR_WHITE	0xffff	/* Must remain last / highest	*/
- 
-+#elif LCD_BPP == LCD_COLOR32
-+/*
-+ * 18,24,32 bpp color definitions
-+ */
-+# define CONSOLE_COLOR_BLACK   0x00000000
-+# define CONSOLE_COLOR_WHITE   0xffffffff /* Must remain last / highest */
-+
-+#else
-+
- #endif /* color definitions */
- 
- /************************************************************************/
-@@ -406,7 +452,7 @@ void lcd_show_board_info(void);
- #if LCD_BPP == LCD_MONOCHROME
- # define COLOR_MASK(c)		((c)	  | (c) << 1 | (c) << 2 | (c) << 3 | \
- 				 (c) << 4 | (c) << 5 | (c) << 6 | (c) << 7)
--#elif (LCD_BPP == LCD_COLOR8) || (LCD_BPP == LCD_COLOR16)
-+#elif (LCD_BPP == LCD_COLOR8) || (LCD_BPP == LCD_COLOR16) || (LCD_BPP == LCD_COLOR32)
- # define COLOR_MASK(c)		(c)
- #else
- # error Unsupported LCD BPP.
--- 
-1.7.9.5
-

+ 0 - 60
package/boot/uboot-xburst/patches/0006-enable-silent-console.patch

@@ -1,60 +0,0 @@
-From 5eb4d4c598f2806bd1b3d1140e917bfead7851ad Mon Sep 17 00:00:00 2001
-From: Xiangfu <xiangfu@openmobilefree.net>
-Date: Wed, 10 Oct 2012 23:51:26 +0800
-Subject: [PATCH 6/6] enable silent console
-
----
- common/console.c          |   16 ++++++++++++++++
- include/configs/qi_lb60.h |    2 ++
- 2 files changed, 18 insertions(+)
-
-diff --git a/common/console.c b/common/console.c
-index 1177f7d..e8a2078 100644
---- a/common/console.c
-+++ b/common/console.c
-@@ -685,6 +685,14 @@ done:
- 
- 	gd->flags |= GD_FLG_DEVINIT;	/* device initialization completed */
- 
-+#ifdef CONFIG_SILENT_CONSOLE
-+	/* Check one more time the contents of the silent environment
-+	 * variable, because if the environment is loaded from NAND it was
-+	 * not available when console_init_f() was called */
-+	if (getenv("silent") != NULL)
-+		gd->flags |= GD_FLG_SILENT;
-+#endif
-+
- 	stdio_print_current_devices();
- 
- #ifdef CONFIG_SYS_CONSOLE_ENV_OVERWRITE
-@@ -760,6 +768,14 @@ int console_init_r(void)
- 
- 	gd->flags |= GD_FLG_DEVINIT;	/* device initialization completed */
- 
-+#ifdef CONFIG_SILENT_CONSOLE
-+	/* Check one more time the contents of the silent environment
-+	 * variable, because if the environment is loaded from NAND it was
-+	 * not available when console_init_f() was called */
-+	if (getenv("silent") != NULL)
-+		gd->flags |= GD_FLG_SILENT;
-+#endif
-+
- 	stdio_print_current_devices();
- 
- 	/* Setting environment variables */
-diff --git a/include/configs/qi_lb60.h b/include/configs/qi_lb60.h
-index d3e78ad..a3534ff 100644
---- a/include/configs/qi_lb60.h
-+++ b/include/configs/qi_lb60.h
-@@ -102,6 +102,8 @@
- #define CONFIG_SYS_NO_FLASH
- #define CONFIG_SYS_FLASH_BASE	0 /* init flash_base as 0 */
- 
-+#define CONFIG_SILENT_CONSOLE		1	/* Enable silent console */
-+
- /*
-  * Command line configuration
-  */
--- 
-1.7.9.5
-

+ 1 - 1
package/devel/perf/Makefile

@@ -26,7 +26,7 @@ include $(INCLUDE_DIR)/package.mk
 define Package/perf
   SECTION:=devel
   CATEGORY:=Development
-  DEPENDS:= +libelf +libdw +(mips||mipsel||powerpc||i386||x86_64||arm||aarch64):libunwind +libpthread +librt +objdump @!LINUX_3_18 @!IN_SDK @!TARGET_arc770 @KERNEL_PERF_EVENTS
+  DEPENDS:= +libelf +libdw +(mips||mipsel||powerpc||i386||x86_64||arm||aarch64):libunwind +libpthread +librt +objdump @!IN_SDK @!TARGET_arc770 @KERNEL_PERF_EVENTS
   TITLE:=Linux performance monitoring tool
   VERSION:=$(LINUX_VERSION)-$(PKG_RELEASE)
   URL:=http://www.kernel.org

+ 2 - 2
package/devel/strace/Makefile

@@ -9,12 +9,12 @@ include $(TOPDIR)/rules.mk
 include $(INCLUDE_DIR)/kernel.mk
 
 PKG_NAME:=strace
-PKG_VERSION:=4.26
+PKG_VERSION:=5.0
 PKG_RELEASE:=1
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
 PKG_SOURCE_URL:=https://strace.io/files/$(PKG_VERSION)
-PKG_HASH:=7c4d2ffeef4f7d1cdc71062ca78d1130eb52f947c2fca82f59f6a1183bfa1e1c
+PKG_HASH:=3b7ad77eb2b81dc6078046a9cc56eed5242b67b63748e7fc28f7c2daf4e647da
 
 PKG_LICENSE:=BSD-3c
 PKG_LICENSE_FILES:=COPYRIGHT

+ 0 - 91
package/devel/strace/patches/001-mips-o32-fix-build.patch

@@ -1,91 +0,0 @@
-From 2c8b6de913973274e877639658e9e7273a012adb Mon Sep 17 00:00:00 2001
-From: "Dmitry V. Levin" <ldv@altlinux.org>
-Date: Tue, 8 Jan 2019 19:23:44 +0000
-Subject: [PATCH] mips o32: fix build
-
-Commit 917c2ccf3a67 "Refactor stack pointers" moved mips_REG_* macros
-from linux/mips/arch_regs.h to linux/mips/arch_regs.c because these
-macros are no longer used outside syscall.c or files included by
-syscall.c, but this caused a build regression on mips o32 because
-decode_syscall_subcall() uses mips_REG_SP prior to its definition.
-
-* syscall.c (decode_syscall_subcall): Move ...
-* linux/mips/get_syscall_args.c: ... here.
-* NEWS: Mention this fix.
-
-Reported-by: Baruch Siach <baruch@tkos.co.il>
-Fixes: v4.26~61 "Refactor stack pointers"
----
- NEWS                          |  1 +
- linux/mips/get_syscall_args.c | 26 ++++++++++++++++++++++++++
- syscall.c                     | 27 ++-------------------------
- 3 files changed, 29 insertions(+), 25 deletions(-)
-
---- a/linux/mips/get_syscall_args.c
-+++ b/linux/mips/get_syscall_args.c
-@@ -37,3 +37,29 @@ arch_get_syscall_args(struct tcb *tcp)
- #endif
- 	return 1;
- }
-+
-+#ifdef SYS_syscall_subcall
-+static void
-+decode_syscall_subcall(struct tcb *tcp)
-+{
-+	if (!scno_is_valid(tcp->u_arg[0]))
-+		return;
-+	tcp->scno = tcp->u_arg[0];
-+	tcp->qual_flg = qual_flags(tcp->scno);
-+	tcp->s_ent = &sysent[tcp->scno];
-+	memmove(&tcp->u_arg[0], &tcp->u_arg[1],
-+		sizeof(tcp->u_arg) - sizeof(tcp->u_arg[0]));
-+	/*
-+	 * Fetching the last arg of 7-arg syscalls (fadvise64_64
-+	 * and sync_file_range) requires additional code,
-+	 * see linux/mips/get_syscall_args.c
-+	 */
-+	if (tcp->s_ent->nargs == MAX_ARGS) {
-+		if (umoven(tcp,
-+			   mips_REG_SP + MAX_ARGS * sizeof(tcp->u_arg[0]),
-+			   sizeof(tcp->u_arg[0]),
-+			   &tcp->u_arg[MAX_ARGS - 1]) < 0)
-+		tcp->u_arg[MAX_ARGS - 1] = 0;
-+	}
-+}
-+#endif /* SYS_syscall_subcall */
---- a/syscall.c
-+++ b/syscall.c
-@@ -349,31 +349,8 @@ decode_ipc_subcall(struct tcb *tcp)
- #endif /* SYS_ipc_subcall */
- 
- #ifdef SYS_syscall_subcall
--static void
--decode_syscall_subcall(struct tcb *tcp)
--{
--	if (!scno_is_valid(tcp->u_arg[0]))
--		return;
--	tcp->scno = tcp->u_arg[0];
--	tcp->qual_flg = qual_flags(tcp->scno);
--	tcp->s_ent = &sysent[tcp->scno];
--	memmove(&tcp->u_arg[0], &tcp->u_arg[1],
--		sizeof(tcp->u_arg) - sizeof(tcp->u_arg[0]));
--# ifdef LINUX_MIPSO32
--	/*
--	 * Fetching the last arg of 7-arg syscalls (fadvise64_64
--	 * and sync_file_range) requires additional code,
--	 * see linux/mips/get_syscall_args.c
--	 */
--	if (tcp->s_ent->nargs == MAX_ARGS) {
--		if (umoven(tcp,
--			   mips_REG_SP + MAX_ARGS * sizeof(tcp->u_arg[0]),
--			   sizeof(tcp->u_arg[0]),
--			   &tcp->u_arg[MAX_ARGS - 1]) < 0)
--		tcp->u_arg[MAX_ARGS - 1] = 0;
--	}
--# endif /* LINUX_MIPSO32 */
--}
-+/* The implementation is architecture specific.  */
-+static void decode_syscall_subcall(struct tcb *);
- #endif /* SYS_syscall_subcall */
- 
- static void

+ 5 - 5
package/devel/strace/patches/100-workaround--pt-reg-collisions-ppc.patch

@@ -1,17 +1,17 @@
 --- a/ptrace.h
 +++ b/ptrace.h
 @@ -30,7 +30,14 @@
- # define ptrace_peeksiginfo_args XXX_ptrace_peeksiginfo_args
- #endif
+ #  define ptrace_peeksiginfo_args XXX_ptrace_peeksiginfo_args
+ # endif
  
 +#if POWERPC
 +#include <linux/types.h>
 +#define __ASSEMBLY__
 +#endif
- #include <linux/ptrace.h>
+ # include <linux/ptrace.h>
 +#if POWERPC
 +#undef __ASSEMBLY__
 +#endif
  
- #ifdef HAVE_STRUCT_IA64_FPREG
- # undef ia64_fpreg
+ # ifdef HAVE_STRUCT_IA64_FPREG
+ #  undef ia64_fpreg

+ 185 - 0
package/devel/valgrind/Makefile

@@ -0,0 +1,185 @@
+#
+# Copyright (C) 2006-2013 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=valgrind
+PKG_VERSION:=3.15.0
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=http://sourceware.org/pub/valgrind/
+PKG_HASH:=417c7a9da8f60dd05698b3a7bc6002e4ef996f14c13f0ff96679a16873e78ab1
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name>
+PKG_LICENSE:=GPL-2.0+
+PKG_CPE_ID:=cpe:/a:valgrind:valgrind
+
+PKG_FIXUP = autoreconf
+PKG_INSTALL := 1
+PKG_BUILD_PARALLEL := 1
+PKG_USE_MIPS16:=0
+PKG_SSP:=0
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+define Package/valgrind
+  SECTION:=devel
+  CATEGORY:=Development
+  DEPENDS:=@mips||mipsel||i386||x86_64||powerpc||arm_v7||aarch64 +libpthread +librt
+  TITLE:=debugging and profiling tools for Linux
+  URL:=http://www.valgrind.org
+endef
+
+define Package/valgrind/default
+  $(Package/valgrind)
+  DEPENDS := valgrind
+endef
+
+define Package/valgrind-cachegrind
+  $(Package/valgrind/default)
+  TITLE += (cache profiling)
+endef
+
+define Package/valgrind-callgrind
+  $(Package/valgrind/default)
+  TITLE += (callgraph profiling)
+endef
+
+define Package/valgrind-drd
+  $(Package/valgrind/default)
+  TITLE += (thread error detection)
+endef
+
+define Package/valgrind-massif
+  $(Package/valgrind/default)
+  TITLE += (heap profiling)
+endef
+
+define Package/valgrind-helgrind
+  $(Package/valgrind/default)
+  TITLE += (thread debugging)
+endef
+
+define Package/valgrind-vgdb
+  $(Package/valgrind/default)
+  TITLE += (GDB interface)
+endef
+
+define Package/valgrind/description
+	Valgrind is an award-winning suite of tools for debugging and
+	profiling Linux programs. With the tools that come with Valgrind,
+	you can automatically detect many memory management and threading
+	bugs, avoiding hours of frustrating bug-hunting, making your
+	programs more stable. You can also perform detailed profiling,
+	to speed up and reduce memory use of your programs.
+endef
+
+CPU := $(patsubst x86_64,amd64,$(patsubst x86,i386,$(patsubst um,$(ARCH),$(LINUX_KARCH))))
+
+CONFIGURE_VARS += \
+	UNAME_R=$(LINUX_VERSION)
+
+ifeq ($(CONFIG_ARCH_64BIT),y)
+	CONFIGURE_ARGS += \
+		--enable-only64bit
+	BITS := 64bit
+else
+	CONFIGURE_ARGS += \
+		--enable-only32bit
+	BITS := 32bit
+endif
+
+CONFIGURE_ARGS += \
+	--enable-tls \
+	--without-x \
+	--without-mpicc \
+	--without-uiout \
+	--disable-valgrindmi \
+	--disable-tui \
+	--disable-valgrindtk \
+	--without-included-gettext \
+	--with-pagesize=4 \
+
+define Package/valgrind/install	
+	$(INSTALL_DIR) $(1)/usr/bin
+	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/valgrind* $(1)/usr/bin/
+	$(INSTALL_DIR) $(1)/usr/lib/valgrind
+	$(CP) \
+		./files/default.supp \
+		$(PKG_INSTALL_DIR)/usr/lib/valgrind/none-* \
+		$(PKG_INSTALL_DIR)/usr/lib/valgrind/vgpreload_core*.so \
+		$(PKG_INSTALL_DIR)/usr/lib/valgrind/$(BITS)-core*.xml \
+		$(PKG_INSTALL_DIR)/usr/lib/valgrind/$(BITS)-linux*.xml \
+		$(PKG_INSTALL_DIR)/usr/lib/valgrind/memcheck-* \
+		$(PKG_INSTALL_DIR)/usr/lib/valgrind/vgpreload_memcheck*.so \
+		$(1)/usr/lib/valgrind/
+
+ifneq ($(ARCH),aarch64)
+	$(CP) \
+		$(PKG_INSTALL_DIR)/usr/lib/valgrind/$(CPU)-*.xml \
+		$(1)/usr/lib/valgrind/
+endif
+endef
+
+define Package/valgrind-cachegrind/install
+	$(INSTALL_DIR) $(1)/usr/bin
+	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/cg_* $(1)/usr/bin/
+	$(INSTALL_DIR) $(1)/usr/lib/valgrind
+	$(CP) \
+		$(PKG_INSTALL_DIR)/usr/lib/valgrind/cachegrind-* \
+		$(1)/usr/lib/valgrind/
+endef
+
+define Package/valgrind-callgrind/install
+	$(INSTALL_DIR) $(1)/usr/bin
+	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/callgrind* $(1)/usr/bin/
+	$(INSTALL_DIR) $(1)/usr/lib/valgrind
+	$(CP) \
+		$(PKG_INSTALL_DIR)/usr/lib/valgrind/callgrind-* \
+		$(1)/usr/lib/valgrind/
+endef
+
+define Package/valgrind-drd/install
+	$(INSTALL_DIR) $(1)/usr/lib/valgrind
+	$(CP) \
+		$(PKG_INSTALL_DIR)/usr/lib/valgrind/drd-* \
+		$(PKG_INSTALL_DIR)/usr/lib/valgrind/vgpreload_drd*.so \
+		$(1)/usr/lib/valgrind/
+endef
+
+define Package/valgrind-massif/install
+	$(INSTALL_DIR) $(1)/usr/bin
+	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/ms_print $(1)/usr/bin/
+	$(INSTALL_DIR) $(1)/usr/lib/valgrind
+	$(CP) \
+		$(PKG_INSTALL_DIR)/usr/lib/valgrind/massif-* \
+		$(PKG_INSTALL_DIR)/usr/lib/valgrind/vgpreload_massif*.so \
+		$(1)/usr/lib/valgrind/
+endef
+
+define Package/valgrind-helgrind/install
+	$(INSTALL_DIR) $(1)/usr/lib/valgrind
+	$(CP) \
+		$(PKG_INSTALL_DIR)/usr/lib/valgrind/helgrind-* \
+		$(PKG_INSTALL_DIR)/usr/lib/valgrind/vgpreload_helgrind*.so \
+		$(1)/usr/lib/valgrind/
+endef
+
+define Package/valgrind-vgdb/install
+	$(INSTALL_DIR) $(1)/usr/bin
+	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/vgdb $(1)/usr/bin/
+endef
+
+$(eval $(call BuildPackage,valgrind))
+$(eval $(call BuildPackage,valgrind-cachegrind))
+$(eval $(call BuildPackage,valgrind-callgrind))
+$(eval $(call BuildPackage,valgrind-drd))
+$(eval $(call BuildPackage,valgrind-massif))
+$(eval $(call BuildPackage,valgrind-helgrind))
+$(eval $(call BuildPackage,valgrind-vgdb))

+ 42 - 0
package/devel/valgrind/files/default.supp

@@ -0,0 +1,42 @@
+{
+   ld(Addr1)
+   Memcheck:Addr1
+   fun:*
+   obj:/lib/ld-*
+}
+{
+   ld(Addr2)
+   Memcheck:Addr2
+   fun:*
+   obj:/lib/ld-*
+}
+{
+   ld(Addr4)
+   Memcheck:Addr4
+   fun:*
+   obj:/lib/ld-*
+}
+{
+   ld(Cond)
+   Memcheck:Cond
+   fun:*
+   obj:/lib/ld-*
+}
+{
+	strlen(Cond)
+	Memcheck:Cond
+	fun:strlen
+	fun:*
+}
+{
+	strnlen(Cond)
+	Memcheck:Cond
+	fun:strnlen
+	fun:*
+}
+{
+	index(Cond)
+	Memcheck:Cond
+	fun:index
+	fun:*
+}

+ 11 - 0
package/devel/valgrind/patches/100-fix_configure_check.patch

@@ -0,0 +1,11 @@
+--- a/configure.ac
++++ b/configure.ac
+@@ -341,7 +341,7 @@ case "${host_os}" in
+         # Ok, this is linux. Check the kernel version
+         AC_MSG_CHECKING([for the kernel version])
+ 
+-        kernel=`uname -r`
++        kernel=${UNAME_R:-`uname -r`}
+ 
+         case "${kernel}" in
+              0.*|1.*|2.0.*|2.1.*|2.2.*|2.3.*|2.4.*|2.5.*) 

+ 17 - 0
package/devel/valgrind/patches/130-fix_arm_arch_detection.patch

@@ -0,0 +1,17 @@
+Description: Fix FTBFS on armhf by correctly detecting the architecture
+Origin: vendor
+Bug-Debian: http://bugs.debian.org/730844
+Author: Alessandro Ghedini <ghedo@debian.org>
+Last-Update: 2013-11-30
+
+--- a/configure.ac
++++ b/configure.ac
+@@ -252,7 +252,7 @@ case "${host_cpu}" in
+         ARCH_MAX="s390x"
+         ;;
+ 
+-     armv7*)
++     arm*)
+ 	AC_MSG_RESULT([ok (${host_cpu})])
+ 	ARCH_MAX="arm"
+ 	;;

+ 1 - 0
package/kernel/button-hotplug/src/button-hotplug.c

@@ -85,6 +85,7 @@ static struct bh_map button_map[] = {
 	BH_MAP(BTN_9,		"BTN_9"),
 	BH_MAP(KEY_RESTART,	"reset"),
 	BH_MAP(KEY_POWER,	"power"),
+	BH_MAP(KEY_POWER2,	"reboot"),
 	BH_MAP(KEY_RFKILL,	"rfkill"),
 	BH_MAP(KEY_WPS_BUTTON,	"wps"),
 	BH_MAP(KEY_WIMAX,	"wwan"),

+ 59 - 0
package/kernel/cryptodev-linux/Makefile

@@ -0,0 +1,59 @@
+#
+# Copyright (C) 2014 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+# $Id$
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=cryptodev-linux
+PKG_VERSION:=1.10
+PKG_RELEASE:=1
+
+PKG_SOURCE_URL:=https://codeload.github.com/$(PKG_NAME)/$(PKG_NAME)/tar.gz/$(PKG_NAME)-$(PKG_VERSION)?
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_HASH:=833ab7c5c88d2b700a7c702a151254c089a3058886a63cc7d12630e364b8ea83
+PKG_LICENSE:=GPL-2.0
+PKG_LICENSE_FILES:=COPYING
+
+PKG_MAINTAINER:=Ansuel Smith <ansuelsmth@gmail.com>
+
+PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_NAME)-$(PKG_NAME)-$(PKG_VERSION)
+
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/cryptodev
+  SUBMENU:=Cryptographic API modules
+  DEFAULT:=m if ALL
+  TITLE:=Driver for cryptographic acceleration
+  URL:=http://cryptodev-linux.org/
+  VERSION:=$(LINUX_VERSION)+$(PKG_VERSION)-$(BOARD)-$(PKG_RELEASE)
+  DEPENDS:=+kmod-crypto-authenc +kmod-crypto-hash
+  FILES:=$(PKG_BUILD_DIR)/cryptodev.$(LINUX_KMOD_SUFFIX)
+  AUTOLOAD:=$(call AutoLoad,50,cryptodev)
+  MODPARAMS.cryptodev:=cryptodev_verbosity=-1
+endef
+
+define KernelPackage/cryptodev/description
+  This is a driver for that allows to use the Linux kernel supported
+  hardware ciphers by user-space applications.
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+	$(MAKE) -C $(PKG_BUILD_DIR) \
+		$(KERNEL_MAKE_FLAGS) \
+		KERNEL_DIR="$(LINUX_DIR)"
+endef
+
+define Build/InstallDev
+	$(INSTALL_DIR) $(STAGING_DIR)/usr/include/crypto
+	$(CP) $(PKG_BUILD_DIR)/crypto/cryptodev.h $(STAGING_DIR)/usr/include/crypto/
+endef
+
+$(eval $(call KernelPackage,cryptodev))

+ 161 - 91
package/kernel/gpio-button-hotplug/src/gpio-button-hotplug.c

@@ -26,28 +26,15 @@
 #include <linux/interrupt.h>
 #include <linux/platform_device.h>
 #include <linux/of_gpio.h>
+#include <linux/of_irq.h>
 #include <linux/gpio_keys.h>
-
-#define DRV_NAME	"gpio-keys"
+#include <linux/gpio/consumer.h>
 
 #define BH_SKB_SIZE	2048
 
+#define DRV_NAME	"gpio-keys"
 #define PFX	DRV_NAME ": "
 
-#undef BH_DEBUG
-
-#ifdef BH_DEBUG
-#define BH_DBG(fmt, args...) printk(KERN_DEBUG "%s: " fmt, DRV_NAME, ##args )
-#else
-#define BH_DBG(fmt, args...) do {} while (0)
-#endif
-
-#define BH_ERR(fmt, args...) printk(KERN_ERR "%s: " fmt, DRV_NAME, ##args )
-
-struct bh_priv {
-	unsigned long		seen;
-};
-
 struct bh_event {
 	const char		*name;
 	unsigned int		type;
@@ -65,12 +52,16 @@ struct bh_map {
 
 struct gpio_keys_button_data {
 	struct delayed_work work;
-	struct bh_priv bh;
+	unsigned long seen;
+	int map_entry;
 	int last_state;
 	int count;
 	int threshold;
 	int can_sleep;
-	struct gpio_keys_button *b;
+	int irq;
+	unsigned int software_debounce;
+	struct gpio_desc *gpiod;
+	const struct gpio_keys_button *b;
 };
 
 extern u64 uevent_next_seqnum(void);
@@ -100,6 +91,7 @@ static struct bh_map button_map[] = {
 	BH_MAP(KEY_LIGHTS_TOGGLE,	"lights_toggle"),
 	BH_MAP(KEY_PHONE,		"phone"),
 	BH_MAP(KEY_POWER,		"power"),
+	BH_MAP(KEY_POWER2,		"reboot"),
 	BH_MAP(KEY_RESTART,		"reset"),
 	BH_MAP(KEY_RFKILL,		"rfkill"),
 	BH_MAP(KEY_VIDEO,		"video"),
@@ -133,7 +125,7 @@ int bh_event_add_var(struct bh_event *event, int argv, const char *format, ...)
 	s = skb_put(event->skb, len + 1);
 	strcpy(s, buf);
 
-	BH_DBG("added variable '%s'\n", s);
+	pr_debug(PFX "added variable '%s'\n", s);
 
 	return 0;
 }
@@ -200,7 +192,7 @@ static void button_hotplug_work(struct work_struct *work)
 
  out_free_skb:
 	if (ret) {
-		BH_ERR("work error %d\n", ret);
+		pr_err(PFX "work error %d\n", ret);
 		kfree_skb(event->skb);
 	}
  out_free_event:
@@ -212,8 +204,8 @@ static int button_hotplug_create_event(const char *name, unsigned int type,
 {
 	struct bh_event *event;
 
-	BH_DBG("create event, name=%s, seen=%lu, pressed=%d\n",
-		name, seen, pressed);
+	pr_debug(PFX "create event, name=%s, seen=%lu, pressed=%d\n",
+		 name, seen, pressed);
 
 	event = kzalloc(sizeof(*event), GFP_KERNEL);
 	if (!event)
@@ -243,36 +235,6 @@ static int button_get_index(unsigned int code)
 	return -1;
 }
 
-static void button_hotplug_event(struct gpio_keys_button_data *data,
-			   unsigned int type, int value)
-{
-	struct bh_priv *priv = &data->bh;
-	unsigned long seen = jiffies;
-	int btn;
-
-	BH_DBG("event type=%u, code=%u, value=%d\n", type, data->b->code, value);
-
-	if ((type != EV_KEY) && (type != EV_SW))
-		return;
-
-	btn = button_get_index(data->b->code);
-	if (btn < 0)
-		return;
-
-	button_hotplug_create_event(button_map[btn].name, type,
-			(seen - priv->seen) / HZ, value);
-	priv->seen = seen;
-}
-
-struct gpio_keys_button_dev {
-	int polled;
-	struct delayed_work work;
-
-	struct device *dev;
-	struct gpio_keys_platform_data *pdata;
-	struct gpio_keys_button_data data[0];
-};
-
 static int gpio_button_get_value(struct gpio_keys_button_data *bdata)
 {
 	int val;
@@ -285,27 +247,61 @@ static int gpio_button_get_value(struct gpio_keys_button_data *bdata)
 	return val ^ bdata->b->active_low;
 }
 
-static void gpio_keys_polled_check_state(struct gpio_keys_button_data *bdata)
+static void gpio_keys_handle_button(struct gpio_keys_button_data *bdata)
 {
+	unsigned int type = bdata->b->type ?: EV_KEY;
 	int state = gpio_button_get_value(bdata);
+	unsigned long seen = jiffies;
 
-	if (state != bdata->last_state) {
-		unsigned int type = bdata->b->type ?: EV_KEY;
+	pr_debug(PFX "event type=%u, code=%u, pressed=%d\n",
+		 type, bdata->b->code, state);
+
+	/* is this the initialization state? */
+	if (bdata->last_state == -1) {
+		/*
+		 * Don't advertise unpressed buttons on initialization.
+		 * Just save their state and continue otherwise this
+		 * can cause libreCMC to enter failsafe.
+		 */
+		if (type == EV_KEY && state == 0)
+			goto set_state;
+		/*
+		 * But we are very interested in pressed buttons and
+		 * initial switch state. These will be reported to
+		 * userland.
+		 */
+	} else if (bdata->last_state == state) {
+		/* reset asserted counter (only relevant for polled keys) */
+		bdata->count = 0;
+		return;
+	}
 
-		if (bdata->count < bdata->threshold) {
-			bdata->count++;
-			return;
-		}
+	if (bdata->count < bdata->threshold) {
+		bdata->count++;
+		return;
+	}
 
-		if ((bdata->last_state != -1) || (type == EV_SW))
-			button_hotplug_event(bdata, type, state);
+	if (bdata->seen == 0)
+		bdata->seen = seen;
 
-		bdata->last_state = state;
-	}
+	button_hotplug_create_event(button_map[bdata->map_entry].name, type,
+				    (seen - bdata->seen) / HZ, state);
+	bdata->seen = seen;
 
+set_state:
+	bdata->last_state = state;
 	bdata->count = 0;
 }
 
+struct gpio_keys_button_dev {
+	int polled;
+	struct delayed_work work;
+
+	struct device *dev;
+	struct gpio_keys_platform_data *pdata;
+	struct gpio_keys_button_data data[0];
+};
+
 static void gpio_keys_polled_queue_work(struct gpio_keys_button_dev *bdev)
 {
 	struct gpio_keys_platform_data *pdata = bdev->pdata;
@@ -324,7 +320,9 @@ static void gpio_keys_polled_poll(struct work_struct *work)
 
 	for (i = 0; i < bdev->pdata->nbuttons; i++) {
 		struct gpio_keys_button_data *bdata = &bdev->data[i];
-		gpio_keys_polled_check_state(bdata);
+
+		if (bdata->gpiod)
+			gpio_keys_handle_button(bdata);
 	}
 	gpio_keys_polled_queue_work(bdev);
 }
@@ -339,11 +337,21 @@ static void gpio_keys_polled_close(struct gpio_keys_button_dev *bdev)
 		pdata->disable(bdev->dev);
 }
 
+static void gpio_keys_irq_work_func(struct work_struct *work)
+{
+	struct gpio_keys_button_data *bdata = container_of(work,
+		struct gpio_keys_button_data, work.work);
+
+	gpio_keys_handle_button(bdata);
+}
+
 static irqreturn_t button_handle_irq(int irq, void *_bdata)
 {
-	struct gpio_keys_button_data *bdata = (struct gpio_keys_button_data *) _bdata;
+	struct gpio_keys_button_data *bdata =
+		(struct gpio_keys_button_data *) _bdata;
 
-	button_hotplug_event(bdata, bdata->b->type ?: EV_KEY, gpio_button_get_value(bdata));
+	mod_delayed_work(system_wq, &bdata->work,
+			 msecs_to_jiffies(bdata->software_debounce));
 
 	return IRQ_HANDLED;
 }
@@ -389,7 +397,9 @@ gpio_keys_get_devtree_pdata(struct device *dev)
 			continue;
 		}
 
-		button = &pdata->buttons[i++];
+		button = (struct gpio_keys_button *)(&pdata->buttons[i++]);
+
+		button->irq = irq_of_parse_and_map(pp, 0);
 
 		button->gpio = of_get_gpio_flags(pp, 0, &flags);
 		if (button->gpio < 0) {
@@ -402,7 +412,7 @@ gpio_keys_get_devtree_pdata(struct device *dev)
 				return ERR_PTR(error);
 			}
 		} else {
-			button->active_low = flags & OF_GPIO_ACTIVE_LOW;
+			button->active_low = !!(flags & OF_GPIO_ACTIVE_LOW);
 		}
 
 		if (of_property_read_u32(pp, "linux,code", &button->code)) {
@@ -509,6 +519,19 @@ static int gpio_keys_button_probe(struct platform_device *pdev,
 			return -EINVAL;
 		}
 
+		bdata->map_entry = button_get_index(button->code);
+		if (bdata->map_entry < 0) {
+			dev_warn(dev, DRV_NAME "does not support key code:%u\n",
+				button->code);
+			continue;
+		}
+
+		if (!(button->type == 0 || button->type == EV_KEY ||
+		      button->type == EV_SW)) {
+			dev_warn(dev, DRV_NAME "only supports buttons or switches\n");
+			continue;
+		}
+
 		error = devm_gpio_request(dev, gpio,
 				     button->desc ? button->desc : DRV_NAME);
 		if (error) {
@@ -516,6 +539,9 @@ static int gpio_keys_button_probe(struct platform_device *pdev,
 				gpio, error);
 			return error;
 		}
+		bdata->gpiod = gpio_to_desc(gpio);
+		if (!bdata->gpiod)
+			return -EINVAL;
 
 		error = gpio_direction_input(gpio);
 		if (error) {
@@ -526,13 +552,27 @@ static int gpio_keys_button_probe(struct platform_device *pdev,
 		}
 
 		bdata->can_sleep = gpio_cansleep(gpio);
-		bdata->last_state = -1;
+		bdata->last_state = -1; /* Unknown state on boot */
 
-		if (bdev->polled)
+		if (bdev->polled) {
 			bdata->threshold = DIV_ROUND_UP(button->debounce_interval,
-						pdata->poll_interval);
-		else
-			bdata->threshold = 1;
+							pdata->poll_interval);
+		} else {
+			/* bdata->threshold = 0; already initialized */
+
+			if (button->debounce_interval) {
+				error = gpiod_set_debounce(bdata->gpiod,
+					button->debounce_interval * 1000);
+				/*
+				 * use timer if gpiolib doesn't provide
+				 * debounce.
+				 */
+				if (error < 0) {
+					bdata->software_debounce =
+						button->debounce_interval;
+				}
+			}
+		}
 
 		bdata->b = &pdata->buttons[i];
 	}
@@ -560,26 +600,45 @@ static int gpio_keys_probe(struct platform_device *pdev)
 
 	pdata = bdev->pdata;
 	for (i = 0; i < pdata->nbuttons; i++) {
-		struct gpio_keys_button *button = &pdata->buttons[i];
+		const struct gpio_keys_button *button = &pdata->buttons[i];
 		struct gpio_keys_button_data *bdata = &bdev->data[i];
+		unsigned long irqflags = IRQF_ONESHOT;
+
+		INIT_DELAYED_WORK(&bdata->work, gpio_keys_irq_work_func);
 
-		if (!button->irq)
-			button->irq = gpio_to_irq(button->gpio);
-		if (button->irq < 0) {
-			dev_err(&pdev->dev, "failed to get irq for gpio:%d\n", button->gpio);
+		if (!bdata->gpiod)
 			continue;
+
+		if (!button->irq) {
+			bdata->irq = gpio_to_irq(button->gpio);
+
+			if (bdata->irq < 0) {
+				dev_err(&pdev->dev, "failed to get irq for gpio:%d\n",
+					button->gpio);
+				continue;
+			}
+
+			irqflags |= IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING;
+		} else {
+			bdata->irq = button->irq;
 		}
 
-		ret = devm_request_threaded_irq(&pdev->dev, button->irq, NULL, button_handle_irq,
-						IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
-						dev_name(&pdev->dev), bdata);
-		if (ret < 0)
-			dev_err(&pdev->dev, "failed to request irq:%d for gpio:%d\n", button->irq, button->gpio);
-		else
-			dev_dbg(&pdev->dev, "gpio:%d has irq:%d\n", button->gpio, button->irq);
+		schedule_delayed_work(&bdata->work,
+				      msecs_to_jiffies(bdata->software_debounce));
+
+		ret = devm_request_threaded_irq(&pdev->dev,
+			bdata->irq, NULL, button_handle_irq,
+			irqflags, dev_name(&pdev->dev), bdata);
 
-		if (bdata->b->type == EV_SW)
-			button_hotplug_event(bdata, EV_SW, gpio_button_get_value(bdata));
+		if (ret < 0) {
+			bdata->irq = 0;
+			dev_err(&pdev->dev, "failed to request irq:%d for gpio:%d\n",
+				bdata->irq, button->gpio);
+			continue;
+		} else {
+			dev_dbg(&pdev->dev, "gpio:%d has irq:%d\n",
+				button->gpio, bdata->irq);
+		}
 	}
 
 	return 0;
@@ -590,7 +649,6 @@ static int gpio_keys_polled_probe(struct platform_device *pdev)
 	struct gpio_keys_platform_data *pdata;
 	struct gpio_keys_button_dev *bdev;
 	int ret;
-	int i;
 
 	ret = gpio_keys_button_probe(pdev, &bdev, 1);
 
@@ -604,14 +662,24 @@ static int gpio_keys_polled_probe(struct platform_device *pdev)
 	if (pdata->enable)
 		pdata->enable(bdev->dev);
 
-	for (i = 0; i < pdata->nbuttons; i++)
-		gpio_keys_polled_check_state(&bdev->data[i]);
-
 	gpio_keys_polled_queue_work(bdev);
 
 	return ret;
 }
 
+static void gpio_keys_irq_close(struct gpio_keys_button_dev *bdev)
+{
+	struct gpio_keys_platform_data *pdata = bdev->pdata;
+	size_t i;
+
+	for (i = 0; i < pdata->nbuttons; i++) {
+		struct gpio_keys_button_data *bdata = &bdev->data[i];
+
+		disable_irq(bdata->irq);
+		cancel_delayed_work_sync(&bdata->work);
+	}
+}
+
 static int gpio_keys_remove(struct platform_device *pdev)
 {
 	struct gpio_keys_button_dev *bdev = platform_get_drvdata(pdev);
@@ -620,6 +688,8 @@ static int gpio_keys_remove(struct platform_device *pdev)
 
 	if (bdev->polled)
 		gpio_keys_polled_close(bdev);
+	else
+		gpio_keys_irq_close(bdev);
 
 	return 0;
 }

+ 4 - 4
package/kernel/kmod-sched-cake/Makefile

@@ -13,9 +13,9 @@ PKG_RELEASE:=1
 
 PKG_SOURCE_PROTO:=git
 PKG_SOURCE_URL:=https://github.com/dtaht/sch_cake.git
-PKG_SOURCE_DATE:=2019-01-08
-PKG_SOURCE_VERSION:=331ac70c8580544cd08a556579dc8807d9941d2e
-PKG_MIRROR_HASH:=e2174531a92d1e9c48bcb74757399255aa205cb64f9863f307e357c5e23c3449
+PKG_SOURCE_DATE:=2019-03-12
+PKG_SOURCE_VERSION:=057c738801e9dc64e8dd72a3fc4f50734214433c
+PKG_MIRROR_HASH:=5bf06a804824db36ae393fc174aeec7b12633176e05a765c0931b39df5bd34df
 PKG_MAINTAINER:=Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
 
 include $(INCLUDE_DIR)/package.mk
@@ -26,7 +26,7 @@ define KernelPackage/sched-cake
   URL:=https://github.com/dtaht/sch_cake
   FILES:=$(PKG_BUILD_DIR)/sch_cake.ko
   AUTOLOAD:=$(call AutoLoad,75,sch_cake)
-  DEPENDS:=+kmod-ipt-conntrack @!LINUX_3_18
+  DEPENDS:=+kmod-ipt-conntrack
 endef
 
 include $(INCLUDE_DIR)/kernel-defaults.mk

+ 3 - 3
package/kernel/linux/modules/block.mk

@@ -209,7 +209,7 @@ $(eval $(call KernelPackage,block2mtd))
 define KernelPackage/dax
   SUBMENU:=$(BLOCK_MENU)
   TITLE:=DAX: direct access to differentiated memory
-  DEPENDS:=@!LINUX_3_18 @!LINUX_4_9
+  DEPENDS:=@!LINUX_4_9
   KCONFIG:=CONFIG_DAX
   FILES:=$(LINUX_DIR)/drivers/dax/dax.ko
 endef
@@ -220,7 +220,7 @@ $(eval $(call KernelPackage,dax))
 define KernelPackage/dm
   SUBMENU:=$(BLOCK_MENU)
   TITLE:=Device Mapper
-  DEPENDS:=+kmod-crypto-manager +!(LINUX_3_18||LINUX_4_9):kmod-dax
+  DEPENDS:=+kmod-crypto-manager +!LINUX_4_9:kmod-dax
   # All the "=n" are unnecessary, they're only there
   # to stop the config from asking the question.
   # MIRROR is M because I've needed it for pvmove.
@@ -337,7 +337,7 @@ $(eval $(call KernelPackage,md-raid10))
 
 
 define KernelPackage/md-raid456
-$(call KernelPackage/md/Depends,+kmod-lib-raid6 +kmod-lib-xor +!LINUX_3_18:kmod-lib-crc32c)
+$(call KernelPackage/md/Depends,+kmod-lib-raid6 +kmod-lib-xor +kmod-lib-crc32c)
   TITLE:=RAID Level 456 Driver
   KCONFIG:= \
        CONFIG_ASYNC_CORE \

+ 14 - 2
package/kernel/linux/modules/can.mk

@@ -26,7 +26,6 @@ define KernelPackage/can
 	CONFIG_CAN_MSCAN=n \
 	CONFIG_CAN_SJA1000=n \
 	CONFIG_CAN_SOFTING=n \
-	CONFIG_CAN_XILINXCAN=n \
 	CONFIG_NET_EMATCH_CANID=n \
 	CONFIG_CAN_DEBUG_DEVICES=n
   FILES:=$(LINUX_DIR)/drivers/net/can/can-dev.ko \
@@ -99,7 +98,7 @@ $(eval $(call KernelPackage,can-c-can-pci))
 define KernelPackage/can-c-can-platform
   TITLE:=Platform Bus based BOSCH C_CAN/D_CAN driver
   KCONFIG:=CONFIG_CAN_C_CAN_PLATFORM
-  DEPENDS:=kmod-can-c-can +!LINUX_3_18:kmod-regmap-core
+  DEPENDS:=kmod-can-c-can +kmod-regmap-core
   FILES:=$(LINUX_DIR)/drivers/net/can/c_can/c_can_platform.ko
   AUTOLOAD:=$(call AutoProbe,c_can_platform)
   $(call AddDepends/can)
@@ -277,4 +276,17 @@ endef
 
 $(eval $(call KernelPackage,can-vcan))
 
+define KernelPackage/can-xilinx-can
+  TITLE:=Xilinx CAN IP
+  KCONFIG:=CONFIG_CAN_XILINXCAN
+  FILES:=$(LINUX_DIR)/drivers/net/can/xilinx_can.ko
+  AUTOLOAD:=$(call AutoProbe,xilinx_can)
+  $(call AddDepends/can,@TARGET_zynq)
+endef
+
+define KernelPackage/can-xilinx-can/description
+ Xilinx CAN driver. This driver supports both
+ soft AXI CAN IP and Zynq CANPS IP.
+endef
 
+$(eval $(call KernelPackage,can-xilinx-can))

+ 30 - 6
package/kernel/linux/modules/crypto.mk

@@ -40,7 +40,7 @@ define KernelPackage/crypto-aead
 	CONFIG_CRYPTO_AEAD2
   FILES:=$(LINUX_DIR)/crypto/aead.ko
   AUTOLOAD:=$(call AutoLoad,09,aead,1)
-  $(call AddDepends/crypto, +!LINUX_3_18:kmod-crypto-null)
+  $(call AddDepends/crypto, +kmod-crypto-null)
 endef
 
 $(eval $(call KernelPackage,crypto-aead))
@@ -48,7 +48,7 @@ $(eval $(call KernelPackage,crypto-aead))
 
 define KernelPackage/crypto-authenc
   TITLE:=Combined mode wrapper for IPsec
-  DEPENDS:=+kmod-crypto-manager +!LINUX_3_18:kmod-crypto-null
+  DEPENDS:=+kmod-crypto-manager +kmod-crypto-null
   KCONFIG:=CONFIG_CRYPTO_AUTHENC
   FILES:=$(LINUX_DIR)/crypto/authenc.ko
   AUTOLOAD:=$(call AutoLoad,09,authenc)
@@ -145,7 +145,7 @@ $(eval $(call KernelPackage,crypto-cts))
 
 define KernelPackage/crypto-deflate
   TITLE:=Deflate compression CryptoAPI module
-  DEPENDS:=+kmod-lib-zlib-inflate +kmod-lib-zlib-deflate +!(LINUX_3_18||LINUX_4_9):kmod-crypto-acompress
+  DEPENDS:=+kmod-lib-zlib-inflate +kmod-lib-zlib-deflate +!LINUX_4_9:kmod-crypto-acompress
   KCONFIG:=CONFIG_CRYPTO_DEFLATE
   FILES:=$(LINUX_DIR)/crypto/deflate.ko
   AUTOLOAD:=$(call AutoLoad,09,deflate)
@@ -180,7 +180,7 @@ $(eval $(call KernelPackage,crypto-ecb))
 
 define KernelPackage/crypto-ecdh
   TITLE:=ECDH algorithm
-  DEPENDS:=@!LINUX_3_18 +kmod-crypto-kpp
+  DEPENDS:=+kmod-crypto-kpp
   KCONFIG:= CONFIG_CRYPTO_ECDH
   FILES:= \
 	$(LINUX_DIR)/crypto/ecdh_generic.ko
@@ -226,6 +226,18 @@ endef
 $(eval $(call KernelPackage,crypto-gcm))
 
 
+define KernelPackage/crypto-xcbc
+  TITLE:=XCBC CryptoAPI module
+  DEPENDS:=+kmod-crypto-hash +kmod-crypto-manager
+  KCONFIG:=CONFIG_CRYPTO_XCBC
+  FILES:=$(LINUX_DIR)/crypto/xcbc.ko
+  AUTOLOAD:=$(call AutoLoad,09,xcbc)
+  $(call AddDepends/crypto)
+endef
+
+$(eval $(call KernelPackage,crypto-xcbc))
+
+
 define KernelPackage/crypto-gf128
   TITLE:=GF(2^128) multiplication functions CryptoAPI module
   KCONFIG:=CONFIG_CRYPTO_GF128MUL
@@ -274,7 +286,7 @@ $(eval $(call KernelPackage,crypto-hmac))
 
 define KernelPackage/crypto-hw-ccp
   TITLE:=AMD Cryptographic Coprocessor
-  DEPENDS:=+kmod-crypto-authenc +kmod-crypto-hash +kmod-crypto-manager +kmod-random-core +kmod-crypto-sha1 +kmod-crypto-sha256 +!(LINUX_3_18||LINUX_4_9):kmod-crypto-rsa
+  DEPENDS:=+kmod-crypto-authenc +kmod-crypto-hash +kmod-crypto-manager +kmod-random-core +kmod-crypto-sha1 +kmod-crypto-sha256 +!LINUX_4_9:kmod-crypto-rsa
   KCONFIG:= \
 	CONFIG_CRYPTO_HW=y \
 	CONFIG_CRYPTO_DEV_CCP=y \
@@ -571,7 +583,7 @@ $(eval $(call KernelPackage,crypto-pcompress))
 
 define KernelPackage/crypto-rsa
   TITLE:=RSA algorithm
-  DEPENDS:=@!LINUX_3_18 +kmod-crypto-manager +kmod-asn1-decoder
+  DEPENDS:=+kmod-crypto-manager +kmod-asn1-decoder
   KCONFIG:= CONFIG_CRYPTO_RSA
   HIDDEN:=1
   FILES:= \
@@ -585,6 +597,18 @@ endef
 $(eval $(call KernelPackage,crypto-rsa))
 
 
+define KernelPackage/crypto-rmd160
+  TITLE:=RIPEMD160 digest CryptoAPI module
+  DEPENDS:=+kmod-crypto-hash
+  KCONFIG:=CONFIG_CRYPTO_RMD160
+  FILES:=$(LINUX_DIR)/crypto/rmd160.ko
+  AUTOLOAD:=$(call AutoLoad,09,rmd160)
+  $(call AddDepends/crypto)
+endef
+
+$(eval $(call KernelPackage,crypto-rmd160))
+
+
 define KernelPackage/crypto-rng
   TITLE:=CryptoAPI random number generation
   DEPENDS:=+kmod-crypto-hash +kmod-crypto-hmac +kmod-crypto-sha256

+ 1 - 1
package/kernel/linux/modules/fs.mk

@@ -68,7 +68,7 @@ $(eval $(call KernelPackage,fs-autofs4))
 define KernelPackage/fs-btrfs
   SUBMENU:=$(FS_MENU)
   TITLE:=BTRFS filesystem support
-  DEPENDS:=+kmod-lib-crc32c +kmod-lib-lzo +kmod-lib-zlib-inflate +kmod-lib-zlib-deflate +kmod-lib-raid6 +kmod-lib-xor +!(LINUX_3_18||LINUX_4_9):kmod-lib-zstd
+  DEPENDS:=+kmod-lib-crc32c +kmod-lib-lzo +kmod-lib-zlib-inflate +kmod-lib-zlib-deflate +kmod-lib-raid6 +kmod-lib-xor +!LINUX_4_9:kmod-lib-zstd
   KCONFIG:=\
 	CONFIG_BTRFS_FS \
 	CONFIG_BTRFS_FS_POSIX_ACL=n \

+ 1 - 1
package/kernel/linux/modules/hwmon.mk

@@ -112,7 +112,7 @@ define KernelPackage/hwmon-ina2xx
   KCONFIG:=CONFIG_SENSORS_INA2XX
   FILES:=$(LINUX_DIR)/drivers/hwmon/ina2xx.ko
   AUTOLOAD:=$(call AutoProbe,ina2xx)
-  $(call AddDepends/hwmon,+kmod-i2c-core +!LINUX_3_18:kmod-regmap-i2c)
+  $(call AddDepends/hwmon,+kmod-i2c-core +kmod-regmap-i2c)
 endef
 
 define KernelPackage/hwmon-ina2xx/description

+ 3 - 3
package/kernel/linux/modules/iio.mk

@@ -132,7 +132,7 @@ $(eval $(call KernelPackage,iio-dht11))
 define KernelPackage/iio-bmp280
   SUBMENU:=$(IIO_MENU)
   TITLE:=BMP180/BMP280/BME280 pressure/temperatur sensor
-  DEPENDS:=@!LINUX_3_18 +kmod-iio-core +kmod-regmap-core
+  DEPENDS:=+kmod-iio-core +kmod-regmap-core
   KCONFIG:=CONFIG_BMP280
   FILES:=$(LINUX_DIR)/drivers/iio/pressure/bmp280.ko
 endef
@@ -152,7 +152,7 @@ define KernelPackage/iio-bmp280-i2c
   DEPENDS:=+kmod-iio-bmp280 +kmod-i2c-core +kmod-regmap-i2c
   KCONFIG:=CONFIG_BMP280_I2C
   FILES:=$(LINUX_DIR)/drivers/iio/pressure/bmp280-i2c.ko
-  AUTOLOAD:=$(call AutoProbe,iio-bmp280-i2c)
+  AUTOLOAD:=$(call AutoProbe,bmp280-i2c)
 endef
 define KernelPackage/iio-bmp280-i2c/description
  This driver adds support for Bosch Sensortec's digital pressure and
@@ -168,7 +168,7 @@ define KernelPackage/iio-bmp280-spi
   DEPENDS:=+kmod-iio-bmp280 +kmod-spi-bitbang
   KCONFIG:=CONFIG_BMP280_SPI
   FILES:=$(LINUX_DIR)/drivers/iio/pressure/bmp280-spi.ko
-  AUTOLOAD:=$(call AutoProbe,iio-bmp280-spi)
+  AUTOLOAD:=$(call AutoProbe,bmp280-spi)
 endef
 define KernelPackage/iio-bmp280-spi/description
  This driver adds support for Bosch Sensortec's digital pressure and

+ 2 - 2
package/kernel/linux/modules/lib.mk

@@ -101,7 +101,7 @@ $(eval $(call KernelPackage,lib-crc32c))
 define KernelPackage/lib-lzo
   SUBMENU:=$(LIB_MENU)
   TITLE:=LZO support
-  DEPENDS:=+!(LINUX_3_18||LINUX_4_9):kmod-crypto-acompress
+  DEPENDS:=+!LINUX_4_9:kmod-crypto-acompress
   KCONFIG:= \
 	CONFIG_CRYPTO_LZO@ge4.9 \
 	CONFIG_LZO_COMPRESS \
@@ -146,7 +146,7 @@ $(eval $(call KernelPackage,lib-zstd))
 define KernelPackage/lib-lz4
   SUBMENU:=$(LIB_MENU)
   TITLE:=LZ4 support
-  DEPENDS:=+!(LINUX_3_18||LINUX_4_9):kmod-crypto-acompress
+  DEPENDS:=+!LINUX_4_9:kmod-crypto-acompress
   HIDDEN:=1
   KCONFIG:= \
 	CONFIG_CRYPTO_LZ4@ge4.9 \

+ 5 - 19
package/kernel/linux/modules/netdevices.mk

@@ -113,7 +113,7 @@ $(eval $(call KernelPackage,mii))
 define KernelPackage/mdio-gpio
   SUBMENU:=$(NETWORK_DEVICES_MENU)
   TITLE:= Supports GPIO lib-based MDIO busses
-  DEPENDS:=+kmod-libphy @GPIO_SUPPORT +(TARGET_armvirt||TARGET_brcm2708_bcm2708||TARGET_samsung):kmod-of-mdio
+  DEPENDS:=+kmod-libphy @GPIO_SUPPORT +(TARGET_armvirt||TARGET_brcm2708_bcm2708||TARGET_samsung||TARGET_tegra):kmod-of-mdio
   KCONFIG:= \
 	CONFIG_MDIO_BITBANG \
 	CONFIG_MDIO_GPIO
@@ -261,7 +261,7 @@ $(eval $(call KernelPackage,switch-rtl8306))
 define KernelPackage/switch-rtl8366-smi
   SUBMENU:=$(NETWORK_DEVICES_MENU)
   TITLE:=Realtek RTL8366 SMI switch interface support
-  DEPENDS:=@GPIO_SUPPORT +kmod-swconfig +(TARGET_armvirt||TARGET_brcm2708_bcm2708||TARGET_samsung):kmod-of-mdio
+  DEPENDS:=@GPIO_SUPPORT +kmod-swconfig +(TARGET_armvirt||TARGET_brcm2708_bcm2708||TARGET_samsung||TARGET_tegra):kmod-of-mdio
   KCONFIG:=CONFIG_RTL8366_SMI
   FILES:=$(LINUX_DIR)/drivers/net/phy/rtl8366_smi.ko
   AUTOLOAD:=$(call AutoLoad,42,rtl8366_smi)
@@ -479,22 +479,6 @@ endef
 $(eval $(call KernelPackage,8139cp))
 
 
-define KernelPackage/r8169
-  SUBMENU:=$(NETWORK_DEVICES_MENU)
-  TITLE:=RealTek RTL-8169 PCI Gigabit Ethernet Adapter kernel support
-  DEPENDS:=@PCI_SUPPORT +kmod-mii +LINUX_4_19:kmod-phy-realtek
-  KCONFIG:=CONFIG_R8169 \
-    CONFIG_R8169_NAPI=y \
-    CONFIG_R8169_VLAN=n
-  FILES:=$(LINUX_DIR)/drivers/net/ethernet/realtek/r8169.ko
-  AUTOLOAD:=$(call AutoProbe,r8169)
-endef
-
-define KernelPackage/r8169/description
- Kernel modules for RealTek RTL-8169 PCI Gigabit Ethernet adapters
-endef
-
-$(eval $(call KernelPackage,r8169))
 
 
 define KernelPackage/ne2k-pci
@@ -684,7 +668,7 @@ define KernelPackage/tg3
   TITLE:=Broadcom Tigon3 Gigabit Ethernet
   KCONFIG:=CONFIG_TIGON3 \
 	CONFIG_TIGON3_HWMON=n
-  DEPENDS:=+!TARGET_brcm47xx:kmod-libphy +(LINUX_3_18||LINUX_4_9):kmod-hwmon-core +kmod-ptp
+  DEPENDS:=+!TARGET_brcm47xx:kmod-libphy +LINUX_4_9:kmod-hwmon-core +kmod-ptp
   SUBMENU:=$(NETWORK_DEVICES_MENU)
   FILES:=$(LINUX_DIR)/drivers/net/ethernet/broadcom/tg3.ko
   AUTOLOAD:=$(call AutoLoad,19,tg3,1)
@@ -959,3 +943,5 @@ define KernelPackage/ethoc/description
 endef
 
 $(eval $(call KernelPackage,ethoc))
+
+

+ 2 - 2
package/kernel/linux/modules/netfilter.mk

@@ -152,7 +152,7 @@ define KernelPackage/nf-flow
 	CONFIG_NETFILTER_INGRESS=y \
 	CONFIG_NF_FLOW_TABLE \
 	CONFIG_NF_FLOW_TABLE_HW
-  DEPENDS:=+kmod-nf-conntrack @!LINUX_3_18 @!LINUX_4_9
+  DEPENDS:=+kmod-nf-conntrack @!LINUX_4_9
   FILES:= \
 	$(LINUX_DIR)/net/netfilter/nf_flow_table.ko \
 	$(LINUX_DIR)/net/netfilter/nf_flow_table_hw.ko
@@ -368,7 +368,7 @@ IPVS_MODULES:= \
 define KernelPackage/nf-ipvs
   SUBMENU:=Netfilter Extensions
   TITLE:=IP Virtual Server modules
-  DEPENDS:=@IPV6 +kmod-lib-crc32c +kmod-ipt-conntrack +kmod-nf-conntrack
+  DEPENDS:=@IPV6 +kmod-lib-crc32c +kmod-ipt-conntrack +kmod-nf-conntrack +LINUX_4_14:kmod-nf-conntrack6
   KCONFIG:= \
 	CONFIG_IP_VS \
 	CONFIG_IP_VS_IPV6=y \

+ 76 - 7
package/kernel/linux/modules/netsupport.mk

@@ -383,6 +383,22 @@ endef
 $(eval $(call KernelPackage,ip6-vti))
 
 
+define KernelPackage/xfrm-interface
+  SUBMENU:=$(NETWORK_SUPPORT_MENU)
+  TITLE:=IPsec XFRM Interface
+  DEPENDS:=+kmod-ipsec4 +kmod-ipsec6 @!LINUX_4_14
+  KCONFIG:=CONFIG_XFRM_INTERFACE
+  FILES:=$(LINUX_DIR)/net/xfrm/xfrm_interface.ko
+  AUTOLOAD:=$(call AutoLoad,33,xfrm_interface)
+endef
+
+define KernelPackage/xfrm-interface/description
+ Kernel module for XFRM interface support
+endef
+
+$(eval $(call KernelPackage,xfrm-interface))
+
+
 define KernelPackage/iptunnel4
   SUBMENU:=$(NETWORK_SUPPORT_MENU)
   TITLE:=IPv4 tunneling
@@ -717,7 +733,7 @@ $(eval $(call KernelPackage,mppe))
 
 SCHED_MODULES = $(patsubst $(LINUX_DIR)/net/sched/%.ko,%,$(wildcard $(LINUX_DIR)/net/sched/*.ko))
 SCHED_MODULES_CORE = sch_ingress sch_fq_codel sch_hfsc sch_htb sch_tbf cls_basic cls_fw cls_route cls_flow cls_tcindex cls_u32 em_u32 act_mirred act_skbedit cls_matchall
-SCHED_MODULES_FILTER = $(SCHED_MODULES_CORE) act_connmark sch_netem em_ipset cls_bpf act_bpf
+SCHED_MODULES_FILTER = $(SCHED_MODULES_CORE) act_connmark act_ctinfo sch_netem sch_mqprio em_ipset cls_bpf cls_flower act_bpf act_vlan
 SCHED_MODULES_EXTRA = $(filter-out $(SCHED_MODULES_FILTER),$(SCHED_MODULES))
 SCHED_FILES = $(patsubst %,$(LINUX_DIR)/net/sched/%.ko,$(filter $(SCHED_MODULES_CORE),$(SCHED_MODULES)))
 SCHED_FILES_EXTRA = $(patsubst %,$(LINUX_DIR)/net/sched/%.ko,$(SCHED_MODULES_EXTRA))
@@ -725,7 +741,6 @@ SCHED_FILES_EXTRA = $(patsubst %,$(LINUX_DIR)/net/sched/%.ko,$(SCHED_MODULES_EXT
 define KernelPackage/sched-core
   SUBMENU:=$(NETWORK_SUPPORT_MENU)
   TITLE:=Traffic schedulers
-  DEPENDS:=@!LINUX_3_18
   KCONFIG:= \
 	CONFIG_NET_SCHED=y \
 	CONFIG_NET_SCH_HFSC \
@@ -757,6 +772,53 @@ endef
 $(eval $(call KernelPackage,sched-core))
 
 
+define KernelPackage/sched-flower
+  SUBMENU:=$(NETWORK_SUPPORT_MENU)
+  TITLE:=Flower traffic classifier
+  DEPENDS:=+kmod-sched-core
+  KCONFIG:=CONFIG_NET_CLS_FLOWER
+  FILES:=$(LINUX_DIR)/net/sched/cls_flower.ko
+  AUTOLOAD:=$(call AutoProbe, cls_flower)
+endef
+
+define KernelPackage/sched-flower/description
+ Allows to classify packets based on a configurable combination of packet keys and masks.
+endef
+
+$(eval $(call KernelPackage,sched-flower))
+
+
+define KernelPackage/sched-act-vlan
+  SUBMENU:=$(NETWORK_SUPPORT_MENU)
+  TITLE:=Traffic VLAN manipulation
+  DEPENDS:=+kmod-sched-core
+  KCONFIG:=CONFIG_NET_ACT_VLAN
+  FILES:=$(LINUX_DIR)/net/sched/act_vlan.ko
+  AUTOLOAD:=$(call AutoProbe, act_vlan)
+endef
+
+define KernelPackage/sched-act-vlan/description
+ Allows to configure rules to push or pop vlan headers.
+endef
+
+$(eval $(call KernelPackage,sched-act-vlan))
+
+
+define KernelPackage/sched-mqprio
+  SUBMENU:=$(NETWORK_SUPPORT_MENU)
+  TITLE:=Multi-queue priority scheduler (MQPRIO)
+  DEPENDS:=+kmod-sched-core
+  KCONFIG:=CONFIG_NET_SCH_MQPRIO
+  FILES:=$(LINUX_DIR)/net/sched/sch_mqprio.ko
+  AUTOLOAD:=$(call AutoProbe, sch_mqprio)
+endef
+
+define KernelPackage/sched-mqprio/description
+  This scheduler allows QOS to be offloaded on NICs that have support for offloading QOS schedulers.
+endef
+
+$(eval $(call KernelPackage,sched-mqprio))
+
 define KernelPackage/sched-connmark
   SUBMENU:=$(NETWORK_SUPPORT_MENU)
   TITLE:=Traffic shaper conntrack mark support
@@ -767,6 +829,15 @@ define KernelPackage/sched-connmark
 endef
 $(eval $(call KernelPackage,sched-connmark))
 
+define KernelPackage/sched-ctinfo
+  SUBMENU:=$(NETWORK_SUPPORT_MENU)
+  TITLE:=Traffic shaper ctinfo support
+  DEPENDS:=+kmod-sched-core +kmod-ipt-core +kmod-ipt-conntrack-extra
+  KCONFIG:=CONFIG_NET_ACT_CTINFO
+  FILES:=$(LINUX_DIR)/net/sched/act_ctinfo.ko
+  AUTOLOAD:=$(call AutoLoad,71, act_ctinfo)
+endef
+$(eval $(call KernelPackage,sched-ctinfo))
 
 define KernelPackage/sched-ipset
   SUBMENU:=$(NETWORK_SUPPORT_MENU)
@@ -785,7 +856,6 @@ $(eval $(call KernelPackage,sched-ipset))
 define KernelPackage/sched-bpf
   SUBMENU:=$(NETWORK_SUPPORT_MENU)
   TITLE:=Traffic shaper support for Berkeley Packet Filter
-  DEPENDS:=@!LINUX_3_18
   KCONFIG:= \
 	CONFIG_NET_CLS_BPF \
 	CONFIG_NET_ACT_BPF
@@ -801,7 +871,6 @@ $(eval $(call KernelPackage,sched-bpf))
 define KernelPackage/bpf-test
   SUBMENU:=$(NETWORK_SUPPORT_MENU)
   TITLE:=Test Berkeley Packet Filter functionality
-  DEPENDS:=@!LINUX_3_18
   KCONFIG:=CONFIG_TEST_BPF
   FILES:=$(LINUX_DIR)/lib/test_bpf.ko
 endef
@@ -849,7 +918,7 @@ $(eval $(call KernelPackage,sched))
 define KernelPackage/tcp-bbr
   SUBMENU:=$(NETWORK_SUPPORT_MENU)
   TITLE:=BBR TCP congestion control
-  DEPENDS:=@!LINUX_3_18 +LINUX_4_9:kmod-sched
+  DEPENDS:=+LINUX_4_9:kmod-sched
   KCONFIG:= \
 	CONFIG_TCP_CONG_ADVANCED=y \
 	CONFIG_TCP_CONG_BBR
@@ -1065,7 +1134,7 @@ $(eval $(call KernelPackage,rxrpc))
 define KernelPackage/mpls
   SUBMENU:=$(NETWORK_SUPPORT_MENU)
   TITLE:=MPLS support
-  DEPENDS:=@!LINUX_3_18 +LINUX_4_19:kmod-iptunnel
+  DEPENDS:=+LINUX_4_19:kmod-iptunnel
   KCONFIG:= \
 	CONFIG_MPLS=y \
 	CONFIG_LWTUNNEL=y \
@@ -1142,7 +1211,7 @@ $(eval $(call KernelPackage,mdio))
 define KernelPackage/macsec
   SUBMENU:=$(NETWORK_SUPPORT_MENU)
   TITLE:=IEEE 802.1AE MAC-level encryption (MAC)
-  DEPENDS:=+kmod-crypto-gcm @!LINUX_3_18
+  DEPENDS:=+kmod-crypto-gcm
   KCONFIG:=CONFIG_MACSEC
   FILES:=$(LINUX_DIR)/drivers/net/macsec.ko
   AUTOLOAD:=$(call AutoLoad,13,macsec)

+ 22 - 19
package/kernel/linux/modules/other.mk

@@ -30,7 +30,7 @@ $(eval $(call KernelPackage,6lowpan))
 define KernelPackage/bluetooth
   SUBMENU:=$(OTHER_MENU)
   TITLE:=Bluetooth support
-  DEPENDS:=@USB_SUPPORT +kmod-usb-core +kmod-crypto-hash +kmod-crypto-ecb +kmod-lib-crc16 +kmod-hid +!LINUX_3_18:kmod-crypto-cmac +!LINUX_3_18:kmod-regmap-core +!(LINUX_3_18||LINUX_4_9):kmod-crypto-ecdh
+  DEPENDS:=@USB_SUPPORT +kmod-usb-core +kmod-crypto-hash +kmod-crypto-ecb +kmod-lib-crc16 +kmod-hid +kmod-crypto-cmac +kmod-regmap-core +!LINUX_4_9:kmod-crypto-ecdh
   KCONFIG:= \
 	CONFIG_BT \
 	CONFIG_BT_BREDR=y \
@@ -178,7 +178,7 @@ $(eval $(call KernelPackage,gpio-dev))
 define KernelPackage/gpio-mcp23s08
   SUBMENU:=$(OTHER_MENU)
   TITLE:=Microchip MCP23xxx I/O expander
-  DEPENDS:=@GPIO_SUPPORT +kmod-i2c-core +!(LINUX_3_18||LINUX_4_9):kmod-regmap-i2c
+  DEPENDS:=@GPIO_SUPPORT +kmod-i2c-core +!LINUX_4_9:kmod-regmap-i2c
   KCONFIG:= \
 	CONFIG_GPIO_MCP23S08 \
 	CONFIG_PINCTRL_MCP23S08
@@ -435,7 +435,7 @@ define KernelPackage/rtc-ds1307
   SUBMENU:=$(OTHER_MENU)
   TITLE:=Dallas/Maxim DS1307 (and compatible) RTC support
   DEFAULT:=m if ALL_KMODS && RTC_SUPPORT
-  DEPENDS:=+kmod-i2c-core +!(LINUX_3_18||LINUX_4_9):kmod-regmap-i2c +!(LINUX_3_18||LINUX_4_9):kmod-hwmon-core
+  DEPENDS:=+kmod-i2c-core +!LINUX_4_9:kmod-regmap-i2c +!LINUX_4_9:kmod-hwmon-core
   KCONFIG:=CONFIG_RTC_DRV_DS1307 \
 	CONFIG_RTC_CLASS=y
   FILES:=$(LINUX_DIR)/drivers/rtc/rtc-ds1307.ko
@@ -487,6 +487,24 @@ endef
 $(eval $(call KernelPackage,rtc-ds1672))
 
 
+define KernelPackage/rtc-em3027
+  SUBMENU:=$(OTHER_MENU)
+  TITLE:=Microelectronic EM3027 RTC support
+  DEFAULT:=m if ALL_KMODS && RTC_SUPPORT
+  DEPENDS:=+kmod-i2c-core
+  KCONFIG:=CONFIG_RTC_DRV_EM3027 \
+	CONFIG_RTC_CLASS=y
+  FILES:=$(LINUX_DIR)/drivers/rtc/rtc-em3027.ko
+  AUTOLOAD:=$(call AutoProbe,rtc-em3027)
+endef
+
+define KernelPackage/rtc-em3027/description
+ Kernel module for Microelectronic EM3027 RTC.
+endef
+
+$(eval $(call KernelPackage,rtc-em3027))
+
+
 define KernelPackage/rtc-isl1208
   SUBMENU:=$(OTHER_MENU)
   TITLE:=Intersil ISL1208 RTC support
@@ -893,21 +911,6 @@ endef
 
 $(eval $(call KernelPackage,random-core))
 
-define KernelPackage/random-omap
-  SUBMENU:=$(OTHER_MENU)
-  TITLE:=Hardware Random Number Generator OMAP support
-  KCONFIG:=CONFIG_HW_RANDOM_OMAP
-  FILES:=$(LINUX_DIR)/drivers/char/hw_random/omap-rng.ko
-  DEPENDS:=@TARGET_omap24xx +kmod-random-core
-  AUTOLOAD:=$(call AutoProbe,random-omap)
-endef
-
-define KernelPackage/random-omap/description
- Kernel module for the OMAP Random Number Generator
- found on OMAP16xx, OMAP2/3/4/5 and AM33xx/AM43xx multimedia processors.
-endef
-
-$(eval $(call KernelPackage,random-omap))
 
 define KernelPackage/random-tpm
   SUBMENU:=$(OTHER_MENU)
@@ -994,7 +997,7 @@ $(eval $(call KernelPackage,echo))
 define KernelPackage/bmp085
   SUBMENU:=$(OTHER_MENU)
   TITLE:=BMP085/BMP18x pressure sensor
-  DEPENDS:= +kmod-regmap-core @!LINUX_3_18
+  DEPENDS:= +kmod-regmap-core
   KCONFIG:= CONFIG_BMP085
   FILES:= $(LINUX_DIR)/drivers/misc/bmp085.ko
 endef

+ 1 - 0
package/kernel/linux/modules/sound.mk

@@ -191,6 +191,7 @@ define KernelPackage/sound-soc-core
   DEPENDS:=+kmod-regmap-core +kmod-ac97
   KCONFIG:= \
 	CONFIG_SND_SOC \
+	CONFIG_SND_SOC_ADI=n \
 	CONFIG_SND_SOC_DMAENGINE_PCM=y \
 	CONFIG_SND_SOC_ALL_CODECS=n
   FILES:=$(LINUX_DIR)/sound/soc/snd-soc-core.ko

+ 12 - 4
package/kernel/linux/modules/usb.mk

@@ -39,7 +39,6 @@ endef
 define KernelPackage/usb-ledtrig-usbport
   TITLE:=LED trigger for USB ports
   KCONFIG:=CONFIG_USB_LEDS_TRIGGER_USBPORT
-  DEPENDS:=@!LINUX_3_18
   FILES:=$(LINUX_DIR)/drivers/usb/core/ledtrig-usbport.ko
   AUTOLOAD:=$(call AutoLoad,50,ledtrig-usbport)
   $(call AddDepends/usb)
@@ -375,6 +374,7 @@ define KernelPackage/usb2
 	+TARGET_brcm47xx:kmod-usb-bcma \
 	+TARGET_brcm47xx:kmod-usb-ssb \
 	+TARGET_bcm53xx:kmod-usb-bcma \
+	+TARGET_bcm53xx:kmod-phy-bcm-ns-usb2 \
 	+TARGET_ath79:kmod-phy-ath79-usb \
 	+kmod-usb-ehci
   KCONFIG:=\
@@ -394,7 +394,13 @@ define KernelPackage/usb2
   ifneq ($(wildcard $(LINUX_DIR)/drivers/usb/host/ehci-atmel.ko),)
     FILES+=$(LINUX_DIR)/drivers/usb/host/ehci-atmel.ko
   endif
-  AUTOLOAD:=$(call AutoLoad,40,ehci-hcd ehci-platform ehci-orion ehci-atmel,1)
+  ifneq ($(wildcard $(LINUX_DIR)/drivers/usb/host/ehci-fsl.ko),)
+    FILES+=$(LINUX_DIR)/drivers/usb/host/ehci-fsl.ko
+  endif
+  ifneq ($(wildcard $(LINUX_DIR)/drivers/usb/host/fsl-mph-dr-of.ko),)
+    FILES+=$(LINUX_DIR)/drivers/usb/host/fsl-mph-dr-of.ko
+  endif
+  AUTOLOAD:=$(call AutoLoad,40,ehci-hcd ehci-platform ehci-orion ehci-atmel ehci-fsl fsl-mph-dr-of,1)
   $(call AddDepends/usb)
 endef
 
@@ -627,6 +633,8 @@ endef
 $(eval $(call KernelPackage,usb-serial-ch341))
 
 
+
+
 define KernelPackage/usb-serial-ftdi
   TITLE:=Support for FTDI devices
   KCONFIG:=CONFIG_USB_SERIAL_FTDI_SIO
@@ -1629,8 +1637,8 @@ XHCI_AUTOLOAD := $(patsubst $(LINUX_DIR)/drivers/usb/host/%.ko,%,$(XHCI_FILES))
 define KernelPackage/usb3
   TITLE:=Support for USB3 controllers
   DEPENDS:= \
-
-
+	+TARGET_bcm53xx:kmod-usb-bcma \
+	+TARGET_bcm53xx:kmod-phy-bcm-ns-usb3
   KCONFIG:= \
 	CONFIG_USB_PCI=y \
 	CONFIG_USB_XHCI_HCD \

+ 40 - 7
package/kernel/linux/modules/video.mk

@@ -187,7 +187,7 @@ define KernelPackage/fb-tft
   SUBMENU:=$(VIDEO_MENU)
   TITLE:=Support for small TFT LCD display modules
   DEPENDS:= \
-	  @GPIO_SUPPORT @!LINUX_3_18 @!LINUX_4_9 +kmod-backlight \
+	  @GPIO_SUPPORT @!LINUX_4_9 +kmod-backlight \
 	  +kmod-fb +kmod-fb-sys-fops +kmod-fb-sys-ram +kmod-spi-bitbang
   KCONFIG:= \
        CONFIG_FB_BACKLIGHT=y \
@@ -239,11 +239,46 @@ endef
 
 $(eval $(call KernelPackage,drm))
 
+define KernelPackage/drm-ttm
+  SUBMENU:=$(VIDEO_MENU)
+  TITLE:=GPU memory management subsystem
+  DEPENDS:=@DISPLAY_SUPPORT +kmod-drm
+  KCONFIG:=CONFIG_DRM_TTM
+  FILES:=$(LINUX_DIR)/drivers/gpu/drm/ttm/ttm.ko
+  AUTOLOAD:=$(call AutoProbe,ttm)
+endef
+
+define KernelPackage/drm-ttm/description
+  GPU memory management subsystem for devices with multiple GPU memory types.
+  Will be enabled automatically if a device driver uses it.
+endef
+
+$(eval $(call KernelPackage,drm-ttm))
+
+define KernelPackage/drm-kms-helper
+  SUBMENU:=$(VIDEO_MENU)
+  TITLE:=CRTC helpers for KMS drivers
+  DEPENDS:=@DISPLAY_SUPPORT +kmod-drm +kmod-fb +kmod-fb-sys-fops +kmod-fb-cfb-copyarea \
+	+kmod-fb-cfb-fillrect +kmod-fb-cfb-imgblt +kmod-fb-sys-ram
+  KCONFIG:= \
+    CONFIG_DRM_KMS_HELPER \
+    CONFIG_DRM_KMS_FB_HELPER=y
+  FILES:=$(LINUX_DIR)/drivers/gpu/drm/drm_kms_helper.ko
+  AUTOLOAD:=$(call AutoProbe,drm_kms_helper)
+endef
+
+define KernelPackage/drm-kms-helper/description
+  CRTC helpers for KMS drivers.
+endef
+
+$(eval $(call KernelPackage,drm-kms-helper))
+
+
 
 define KernelPackage/drm-imx
   SUBMENU:=$(VIDEO_MENU)
   TITLE:=Freescale i.MX DRM support
-  DEPENDS:=@TARGET_imx6 +kmod-drm +kmod-fb +kmod-fb-cfb-copyarea +kmod-fb-cfb-imgblt +kmod-fb-cfb-fillrect +kmod-fb-sys-fops +kmod-fb-sys-ram
+  DEPENDS:=@TARGET_imx6 +kmod-drm-kms-helper
   KCONFIG:=CONFIG_DRM_IMX \
 	CONFIG_DRM_FBDEV_EMULATION=y \
 	CONFIG_DRM_FBDEV_OVERALLOC=100 \
@@ -251,8 +286,6 @@ define KernelPackage/drm-imx
 	CONFIG_RESET_CONTROLLER=y \
 	CONFIG_DRM_IMX_IPUV3 \
 	CONFIG_IMX_IPUV3 \
-	CONFIG_DRM_KMS_HELPER \
-	CONFIG_DRM_KMS_FB_HELPER=y \
 	CONFIG_DRM_GEM_CMA_HELPER=y \
 	CONFIG_DRM_KMS_CMA_HELPER=y \
 	CONFIG_DRM_IMX_FB_HELPER \
@@ -262,8 +295,7 @@ define KernelPackage/drm-imx
 	CONFIG_DRM_IMX_HDMI=n
   FILES:= \
 	$(LINUX_DIR)/drivers/gpu/drm/imx/imxdrm.ko \
-	$(LINUX_DIR)/drivers/gpu/ipu-v3/imx-ipu-v3.ko \
-	$(LINUX_DIR)/drivers/gpu/drm/drm_kms_helper.ko
+	$(LINUX_DIR)/drivers/gpu/ipu-v3/imx-ipu-v3.ko
   AUTOLOAD:=$(call AutoLoad,08,imxdrm imx-ipu-v3 imx-ipuv3-crtc)
 endef
 
@@ -318,6 +350,7 @@ endef
 
 $(eval $(call KernelPackage,drm-imx-ldb))
 
+
 #
 # Video Capture
 #
@@ -364,7 +397,7 @@ endef
 
 define KernelPackage/video-videobuf2
   TITLE:=videobuf2 lib
-  DEPENDS:=+kmod-dma-buf @!LINUX_3_18
+  DEPENDS:=+kmod-dma-buf
   KCONFIG:= \
 	CONFIG_VIDEOBUF2_CORE \
 	CONFIG_VIDEOBUF2_MEMOPS \

+ 1 - 1
package/kernel/linux/modules/w1.mk

@@ -14,7 +14,7 @@ define KernelPackage/w1
   TITLE:=Dallas's 1-wire support
   KCONFIG:=CONFIG_W1
   FILES:=$(LINUX_DIR)/drivers/w1/wire.ko
-  DEPENDS:=+!(LINUX_3_18||LINUX_4_9):kmod-hwmon-core
+  DEPENDS:=+!LINUX_4_9:kmod-hwmon-core
 endef
 
 define KernelPackage/w1/description

+ 14 - 4
package/kernel/linux/modules/wpan.mk

@@ -9,7 +9,6 @@ WPAN_MENU:=WPAN 802.15.4 Support
 define KernelPackage/ieee802154
   SUBMENU:=$(WPAN_MENU)
   TITLE:=IEEE-802.15.4 support
-  DEPENDS:=@!LINUX_3_18
   KCONFIG:= \
 	CONFIG_IEEE802154 \
 	CONFIG_IEEE802154_SOCKET=y \
@@ -33,7 +32,7 @@ $(eval $(call KernelPackage,ieee802154))
 define KernelPackage/mac802154
   SUBMENU:=$(WPAN_MENU)
   TITLE:=MAC-802.15.4 support
-  DEPENDS:=+kmod-ieee802154 +kmod-crypto-aead +kmod-lib-crc-ccitt @!LINUX_3_18
+  DEPENDS:=+kmod-ieee802154 +kmod-crypto-aead +kmod-lib-crc-ccitt
   KCONFIG:= \
 	CONFIG_MAC802154 \
 	CONFIG_IEEE802154_DRIVERS=y
@@ -56,7 +55,7 @@ $(eval $(call KernelPackage,mac802154))
 define KernelPackage/fakelb
   SUBMENU:=$(WPAN_MENU)
   TITLE:=Fake LR-WPAN driver
-  DEPENDS:=+kmod-mac802154 @!LINUX_3_18
+  DEPENDS:=+kmod-mac802154
   KCONFIG:=CONFIG_IEEE802154_FAKELB
   FILES:=$(LINUX_DIR)/drivers/net/ieee802154/fakelb.ko
   AUTOLOAD:=$(call AutoLoad,92,fakelb)
@@ -69,6 +68,17 @@ endef
 
 $(eval $(call KernelPackage,fakelb))
 
+define KernelPackage/atusb
+  SUBMENU:=$(WPAN_MENU)
+  TITLE:=ATUSB transceiver driver
+  DEPENDS:=@USB_SUPPORT +kmod-usb-core +kmod-mac802154
+  KCONFIG:=CONFIG_IEEE802154_ATUSB
+  FILES:=$(LINUX_DIR)/drivers/net/ieee802154/atusb.ko
+  AUTOLOAD:=$(call AutoProbe,atusb)
+endef
+
+$(eval $(call KernelPackage,atusb))
+
 define KernelPackage/at86rf230
   SUBMENU:=$(WPAN_MENU)
   TITLE:=AT86RF230 transceiver driver
@@ -109,7 +119,7 @@ $(eval $(call KernelPackage,cc2520))
 define KernelPackage/ieee802154_6lowpan
   SUBMENU:=$(WPAN_MENU)
   TITLE:= 6LoWPAN support over IEEE-802.15.4
-  DEPENDS:=@!LINUX_3_18 +kmod-6lowpan +kmod-ieee802154
+  DEPENDS:=+kmod-6lowpan +kmod-ieee802154
   KCONFIG:=CONFIG_IEEE802154_6LOWPAN
   FILES:= \
 	$(LINUX_DIR)/net/ieee802154/6lowpan/ieee802154_6lowpan.ko@ge4.0 \

+ 72 - 6
package/kernel/mac80211/Makefile

@@ -10,10 +10,10 @@ include $(INCLUDE_DIR)/kernel.mk
 
 PKG_NAME:=mac80211
 
-PKG_VERSION:=4.19.23-1
-PKG_RELEASE:=4
-PKG_SOURCE_URL:=@KERNEL/linux/kernel/projects/backports/stable/v4.19.23/
-PKG_HASH:=703e940b542eb56067fcd847a7c69398dcc9829f34472647eea4211cb2ab3b83
+PKG_VERSION:=4.19.66-1
+PKG_RELEASE:=1
+PKG_SOURCE_URL:=@KERNEL/linux/kernel/projects/backports/stable/v4.19.66/
+PKG_HASH:=1f3c6a58cb45b247f6e473d1b52236bfbb41cb3e11e38a74526727e911b51a02
 
 PKG_SOURCE:=backports-$(PKG_VERSION).tar.xz
 PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/backports-$(PKG_VERSION)
@@ -22,15 +22,19 @@ PKG_BUILD_PARALLEL:=1
 PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name>
 
 PKG_DRIVERS = \
+	adm8211 \
 	lib80211 \
 	mac80211-hwsim
-
+	
 
 PKG_CONFIG_DEPENDS:= \
 	CONFIG_PACKAGE_kmod-mac80211 \
 	CONFIG_PACKAGE_MAC80211_DEBUGFS \
 	CONFIG_PACKAGE_MAC80211_MESH \
 	CONFIG_PACKAGE_MAC80211_TRACING \
+	CONFIG_PACKAGE_IWLWIFI_DEBUG \
+	CONFIG_PACKAGE_IWLWIFI_DEBUGFS \
+	CONFIG_PACKAGE_RTLWIFI_DEBUG \
 
 include $(INCLUDE_DIR)/package.mk
 
@@ -55,7 +59,19 @@ config-y:= \
 	MAC80211_RC_DEFAULT_MINSTREL \
 	WLAN_VENDOR_ADMTEK \
 	WLAN_VENDOR_ATH \
-
+	WLAN_VENDOR_ATMEL \
+	WLAN_VENDOR_BROADCOM \
+	WLAN_VENDOR_CISCO \
+	WLAN_VENDOR_INTEL \
+	WLAN_VENDOR_INTERSIL \
+	WLAN_VENDOR_MARVELL \
+	WLAN_VENDOR_MEDIATEK \
+	WLAN_VENDOR_RALINK \
+	WLAN_VENDOR_REALTEK \
+	WLAN_VENDOR_RSI \
+	WLAN_VENDOR_ST \
+	WLAN_VENDOR_TI \
+	WLAN_VENDOR_ZYDAS \
 
 config-$(call config_package,cfg80211) += CFG80211
 
@@ -124,6 +140,25 @@ define KernelPackage/mac80211/description
 Generic IEEE 802.11 Networking Stack (mac80211)
 endef
 
+define KernelPackage/adm8211
+  $(call KernelPackage/mac80211/Default)
+  TITLE:=ADMTek 8211 support
+  DEPENDS+=@PCI_SUPPORT +kmod-mac80211 +kmod-eeprom-93cx6
+  FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/admtek/adm8211.ko
+  AUTOLOAD:=$(call AutoProbe,adm8211)
+endef
+
+
+
+
+
+
+
+
+
+
+
+
 define KernelPackage/lib80211
   $(call KernelPackage/mac80211/Default)
   TITLE:=802.11 Networking stack
@@ -159,6 +194,25 @@ define KernelPackage/mac80211-hwsim
   AUTOLOAD:=$(call AutoProbe,mac80211_hwsim)
 endef
 
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
 
 ifdef CONFIG_PACKAGE_MAC80211_DEBUGFS
   config-y += \
@@ -173,8 +227,16 @@ endif
 
 config-$(call config_package,lib80211) += LIB80211 LIB80211_CRYPT_WEP LIB80211_CRYPT_CCMP LIB80211_CRYPT_TKIP
 
+
 config-$(call config_package,mac80211-hwsim) += MAC80211_HWSIM
 
+
+
+config-$(call config_package,adm8211) += ADM8211
+config-$(call config_package,rsi91x) += RSI_91X
+config-$(call config_package,rsi91x-usb) += RSI_USB
+config-$(call config_package,rsi91x-sdio) += RSI_SDIO
+
 config-$(CONFIG_LEDS_TRIGGERS) += MAC80211_LEDS
 
 MAKE_OPTS:= -C "$(PKG_BUILD_DIR)" \
@@ -243,6 +305,7 @@ define Build/Patch
 	$(call PatchDir,$(PKG_BUILD_DIR),$(PATCH_DIR)/ath,ath/)
 	$(call PatchDir,$(PKG_BUILD_DIR),$(PATCH_DIR)/rt2x00,rt2x00/)
 	$(call PatchDir,$(PKG_BUILD_DIR),$(PATCH_DIR)/mwl,mwl/)
+	$(call PatchDir,$(PKG_BUILD_DIR),$(PATCH_DIR)/brcm,brcm/)
 	$(if $(QUILT),touch $(PKG_BUILD_DIR)/.quilt_used)
 endef
 
@@ -252,6 +315,7 @@ define Quilt/Refresh/Package
 	$(call Quilt/RefreshDir,$(PKG_BUILD_DIR),$(PATCH_DIR)/ath,ath/)
 	$(call Quilt/RefreshDir,$(PKG_BUILD_DIR),$(PATCH_DIR)/rt2x00,rt2x00/)
 	$(call Quilt/RefreshDir,$(PKG_BUILD_DIR),$(PATCH_DIR)/mwl,mwl/)
+	$(call Quilt/RefreshDir,$(PKG_BUILD_DIR),$(PATCH_DIR)/brcm,brcm/)
 endef
 
 define Build/Compile
@@ -274,6 +338,7 @@ define Build/InstallDev
 endef
 
 
+
 define KernelPackage/cfg80211/install
 	$(INSTALL_DIR) $(1)/lib/wifi $(1)/lib/netifd/wireless
 	$(INSTALL_DATA) ./files/lib/wifi/mac80211.sh $(1)/lib/wifi
@@ -282,6 +347,7 @@ define KernelPackage/cfg80211/install
 	$(INSTALL_DATA) ./files/mac80211.hotplug $(1)/etc/hotplug.d/ieee80211/10-wifi-detect
 endef
 
+
 $(eval $(foreach drv,$(PKG_DRIVERS),$(call KernelPackage,$(drv))))
 $(eval $(call KernelPackage,cfg80211))
 $(eval $(call KernelPackage,mac80211))

+ 5 - 37
package/kernel/mac80211/ath.mk

@@ -1,5 +1,5 @@
 PKG_DRIVERS += \
-	ath ath5k ath6kl ath9k ath9k-common ath9k-htc \
+	ath ath5k ath9k ath9k-common ath9k-htc \
 	carl9170
 
 PKG_CONFIG_DEPENDS += \
@@ -49,9 +49,6 @@ else
   config-y += ATH5K_PCI
 endif
 
-config-$(call config_package,ath6kl) += ATH6KL
-config-$(call config_package,ath6kl-sdio) += ATH6KL_SDIO
-config-$(call config_package,ath6kl-usb) += ATH6KL_USB
 
 config-$(call config_package,carl9170) += CARL9170
 
@@ -73,7 +70,7 @@ define KernelPackage/ath/config
 		bool "Atheros wireless debugging"
 		help
 		  Say Y, if you want to debug atheros wireless drivers.
-		  Only ath9k makes use of this.
+		  Only ath9k & ath10k make use of this.
 
 	config PACKAGE_ATH_DFS
 		bool "Enable DFS support"
@@ -131,42 +128,10 @@ define KernelPackage/ath5k/description
  Atheros 5xxx chipset.
 endef
 
-define KernelPackage/ath6kl
-  $(call KernelPackage/mac80211/Default)
-  TITLE:=Atheros FullMAC wireless devices (common code for ath6kl_sdio and ath6kl_usb)
-  URL:=https://wireless.wiki.kernel.org/en/users/drivers/ath6kl
-  HIDDEN:=1
-  DEPENDS+= +kmod-ath +@DRIVER_11N_SUPPORT
-  FILES:= $(PKG_BUILD_DIR)/drivers/net/wireless/ath/ath6kl/ath6kl_core.ko
-endef
 
-define KernelPackage/ath6kl-sdio
-  $(call KernelPackage/mac80211/Default)
-  TITLE:=Atheros 802.11n SDIO wireless cards support
-  URL:=https://wireless.wiki.kernel.org/en/users/drivers/ath6kl
-  DEPENDS+= +kmod-mmc +kmod-ath6kl
-  FILES:= $(PKG_BUILD_DIR)/drivers/net/wireless/ath/ath6kl/ath6kl_sdio.ko
-  AUTOLOAD:=$(call AutoProbe,ath6kl_sdio)
-endef
 
-define KernelPackage/ath6kl-sdio/description
-This module adds support for wireless adapters based on
-Atheros IEEE 802.11n AR6003 and AR6004 family of chipsets.
-endef
 
-define KernelPackage/ath6kl-usb
-  $(call KernelPackage/mac80211/Default)
-  TITLE:=Atheros 802.11n USB wireless cards support
-  URL:=https://wireless.wiki.kernel.org/en/users/drivers/ath6kl
-  DEPENDS+= @USB_SUPPORT +kmod-usb-core +kmod-ath6kl
-  FILES:= $(PKG_BUILD_DIR)/drivers/net/wireless/ath/ath6kl/ath6kl_usb.ko
-  AUTOLOAD:=$(call AutoProbe,ath6kl_usb)
-endef
 
-define KernelPackage/ath6kl-usb/description
-This module adds support for wireless adapters based on the
-Atheros IEEE 802.11n AR6004 chipset.
-endef
 
 define KernelPackage/ath9k-common
   $(call KernelPackage/mac80211/Default)
@@ -226,6 +191,9 @@ This module adds support for wireless adapters based on
 Atheros USB AR9271 and AR7010 family of chipsets.
 endef
 
+
+
+
 define KernelPackage/carl9170
   $(call KernelPackage/mac80211/Default)
   TITLE:=Driver for Atheros AR9170 USB sticks

+ 20 - 4
package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh

@@ -23,6 +23,7 @@ drv_mac80211_init_device_config() {
 
 	config_add_string path phy 'macaddr:macaddr'
 	config_add_string hwmode
+	config_add_string tx_burst
 	config_add_int beacon_int chanbw frag rts
 	config_add_int rxantenna txantenna antenna_gain txpower distance
 	config_add_boolean noscan ht_coex
@@ -97,7 +98,10 @@ mac80211_hostapd_setup_base() {
 	[ "$auto_channel" -gt 0 ] && json_get_values channel_list channels
 
 	json_get_vars noscan ht_coex
-	json_get_values ht_capab_list ht_capab
+	json_get_values ht_capab_list ht_capab tx_burst
+
+	[ -n "$noscan" -a "$noscan" -gt 0 ] && hostapd_noscan=1
+	[ "$tx_burst" = 0 ] && tx_burst=
 
 	ieee80211n=1
 	ht_capab=
@@ -227,6 +231,7 @@ mac80211_hostapd_setup_base() {
 			vht_link_adapt:3 \
 			vht160:2
 
+		set_default tx_burst 2.0
 		append base_cfg "ieee80211ac=1" "$N"
 		vht_cap=0
 		for cap in $(iw phy "$phy" info | awk -F "[()]" '/VHT Capabilities/ { print $2 }'); do
@@ -307,7 +312,8 @@ mac80211_hostapd_setup_base() {
 	cat >> "$hostapd_conf_file" <<EOF
 ${channel:+channel=$channel}
 ${channel_list:+chanlist=$channel_list}
-${noscan:+noscan=$noscan}
+${hostapd_noscan:+noscan=1}
+${tx_burst:+tx_queue_data2_burst=$tx_burst}
 $base_cfg
 
 EOF
@@ -735,6 +741,10 @@ mac80211_interface_cleanup() {
 	done
 }
 
+mac80211_set_noscan() {
+	hostapd_noscan=1
+}
+
 drv_mac80211_cleanup() {
 	hostapd_common_cleanup
 }
@@ -781,11 +791,14 @@ drv_mac80211_setup() {
 		done
 	}
 
-	set_default rxantenna all
-	set_default txantenna all
+	set_default rxantenna 0xffffffff
+	set_default txantenna 0xffffffff
 	set_default distance 0
 	set_default antenna_gain 0
 
+	[ "$txantenna" = "all" ] && txantenna=0xffffffff
+	[ "$rxantenna" = "all" ] && rxantenna=0xffffffff
+
 	iw phy "$phy" set antenna $txantenna $rxantenna >/dev/null 2>&1
 	iw phy "$phy" set antenna_gain $antenna_gain
 	iw phy "$phy" set distance "$distance"
@@ -795,9 +808,12 @@ drv_mac80211_setup() {
 
 	has_ap=
 	hostapd_ctrl=
+	hostapd_noscan=
 	for_each_interface "ap" mac80211_check_ap
 
 	rm -f "$hostapd_conf_file"
+
+	for_each_interface "sta adhoc mesh" mac80211_set_noscan
 	[ -n "$has_ap" ] && mac80211_hostapd_setup_base "$phy"
 
 	for_each_interface "sta adhoc mesh monitor" mac80211_prepare_vif

+ 1 - 1
package/kernel/mac80211/patches/ath/350-ath9k_hw-reset-AHB-WMAC-interface-on-AR91xx.patch

@@ -9,7 +9,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
 
 --- a/drivers/net/wireless/ath/ath9k/hw.c
 +++ b/drivers/net/wireless/ath/ath9k/hw.c
-@@ -1421,8 +1421,12 @@ static bool ath9k_hw_set_reset(struct at
+@@ -1435,8 +1435,12 @@ static bool ath9k_hw_set_reset(struct at
  	if (!AR_SREV_9100(ah))
  		REG_WRITE(ah, AR_RC, 0);
  

+ 2 - 2
package/kernel/mac80211/patches/ath/351-ath9k_hw-issue-external-reset-for-QCA955x.patch

@@ -10,7 +10,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
 
 --- a/drivers/net/wireless/ath/ath9k/hw.c
 +++ b/drivers/net/wireless/ath/ath9k/hw.c
-@@ -1298,39 +1298,56 @@ void ath9k_hw_get_delta_slope_vals(struc
+@@ -1312,39 +1312,56 @@ void ath9k_hw_get_delta_slope_vals(struc
  	*coef_exponent = coef_exp - 16;
  }
  
@@ -94,7 +94,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
  	return true;
  }
  
-@@ -1383,24 +1400,24 @@ static bool ath9k_hw_set_reset(struct at
+@@ -1397,24 +1414,24 @@ static bool ath9k_hw_set_reset(struct at
  			rst_flags |= AR_RTC_RC_MAC_COLD;
  	}
  

+ 2 - 2
package/kernel/mac80211/patches/ath/356-Revert-ath9k-interpret-requested-txpower-in-EIRP-dom.patch

@@ -8,7 +8,7 @@ This reverts commit 71f5137bf010c6faffab50c0ec15374c59c4a411.
 
 --- a/drivers/net/wireless/ath/ath9k/hw.c
 +++ b/drivers/net/wireless/ath/ath9k/hw.c
-@@ -2962,7 +2962,8 @@ void ath9k_hw_apply_txpower(struct ath_h
+@@ -2976,7 +2976,8 @@ void ath9k_hw_apply_txpower(struct ath_h
  {
  	struct ath_regulatory *reg = ath9k_hw_regulatory(ah);
  	struct ieee80211_channel *channel;
@@ -18,7 +18,7 @@ This reverts commit 71f5137bf010c6faffab50c0ec15374c59c4a411.
  	u16 ctl = NO_CTL;
  
  	if (!chan)
-@@ -2974,9 +2975,14 @@ void ath9k_hw_apply_txpower(struct ath_h
+@@ -2988,9 +2989,14 @@ void ath9k_hw_apply_txpower(struct ath_h
  	channel = chan->chan;
  	chan_pwr = min_t(int, channel->max_power * 2, MAX_RATE_POWER);
  	new_pwr = min_t(int, chan_pwr, reg->power_limit);

+ 4 - 4
package/kernel/mac80211/patches/ath/365-ath9k-adjust-tx-power-reduction-for-US-regulatory-do.patch

@@ -3,7 +3,7 @@ Date: Wed, 19 Jul 2017 08:49:31 +0200
 Subject: [PATCH] ath9k: adjust tx power reduction for US regulatory
  domain
 
-FCC regulatory rules allow for up to 3 dBi antenna gain. Account for
+FCC regulatory rules allow for up to 6 dBi antenna gain. Account for
 this in the EEPROM based tx power reduction code.
 
 Signed-off-by: Felix Fietkau <nbd@nbd.name>
@@ -11,13 +11,13 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
 
 --- a/drivers/net/wireless/ath/ath9k/hw.c
 +++ b/drivers/net/wireless/ath/ath9k/hw.c
-@@ -2981,6 +2981,10 @@ void ath9k_hw_apply_txpower(struct ath_h
+@@ -2995,6 +2995,10 @@ void ath9k_hw_apply_txpower(struct ath_h
  	if (ant_gain > max_gain)
  		ant_reduction = ant_gain - max_gain;
  
-+	/* FCC allows maximum antenna gain of 3 dBi */
++	/* FCC allows maximum antenna gain of 6 dBi */
 +	if (reg->region == NL80211_DFS_FCC)
-+		ant_reduction = max_t(int, ant_reduction - 6, 0);
++		ant_reduction = max_t(int, ant_reduction - 12, 0);
 +
  	ah->eep_ops->set_txpower(ah, chan, ctl,
  				 ant_reduction, new_pwr, test);

+ 2 - 2
package/kernel/mac80211/patches/ath/404-regd_no_assoc_hints.patch

@@ -1,6 +1,6 @@
 --- a/net/wireless/reg.c
 +++ b/net/wireless/reg.c
-@@ -2982,6 +2982,8 @@ void regulatory_hint_country_ie(struct w
+@@ -3021,6 +3021,8 @@ void regulatory_hint_country_ie(struct w
  	enum environment_cap env = ENVIRON_ANY;
  	struct regulatory_request *request = NULL, *lr;
  
@@ -9,7 +9,7 @@
  	/* IE len must be evenly divisible by 2 */
  	if (country_ie_len & 0x01)
  		return;
-@@ -3188,6 +3190,7 @@ static void restore_regulatory_settings(
+@@ -3227,6 +3229,7 @@ static void restore_regulatory_settings(
  
  void regulatory_hint_disconnect(void)
  {

+ 1 - 1
package/kernel/mac80211/patches/ath/510-ath9k_intr_mitigation_tweak.patch

@@ -1,6 +1,6 @@
 --- a/drivers/net/wireless/ath/ath9k/hw.c
 +++ b/drivers/net/wireless/ath/ath9k/hw.c
-@@ -392,13 +392,8 @@ static void ath9k_hw_init_config(struct
+@@ -403,13 +403,8 @@ static void ath9k_hw_init_config(struct
  
  	ah->config.rx_intr_mitigation = true;
  

+ 1 - 1
package/kernel/mac80211/patches/ath/513-ath9k_add_pci_ids.patch

@@ -1,6 +1,6 @@
 --- a/drivers/net/wireless/ath/ath9k/hw.c
 +++ b/drivers/net/wireless/ath/ath9k/hw.c
-@@ -649,6 +649,7 @@ int ath9k_hw_init(struct ath_hw *ah)
+@@ -663,6 +663,7 @@ int ath9k_hw_init(struct ath_hw *ah)
  
  	/* These are all the AR5008/AR9001/AR9002/AR9003 hardware family of chipsets */
  	switch (ah->hw_version.devid) {

+ 2 - 2
package/kernel/mac80211/patches/ath/542-ath9k_debugfs_diag.patch

@@ -94,7 +94,7 @@
  struct ath_gen_timer *ath_gen_timer_alloc(struct ath_hw *ah,
 --- a/drivers/net/wireless/ath/ath9k/hw.c
 +++ b/drivers/net/wireless/ath/ath9k/hw.c
-@@ -1869,6 +1869,20 @@ u32 ath9k_hw_get_tsf_offset(struct times
+@@ -1883,6 +1883,20 @@ u32 ath9k_hw_get_tsf_offset(struct times
  }
  EXPORT_SYMBOL(ath9k_hw_get_tsf_offset);
  
@@ -115,7 +115,7 @@
  int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
  		   struct ath9k_hw_cal_data *caldata, bool fastcc)
  {
-@@ -2077,6 +2091,7 @@ int ath9k_hw_reset(struct ath_hw *ah, st
+@@ -2091,6 +2105,7 @@ int ath9k_hw_reset(struct ath_hw *ah, st
  		ar9003_hw_disable_phy_restart(ah);
  
  	ath9k_hw_apply_gpio_override(ah);

+ 4 - 4
package/kernel/mac80211/patches/ath/544-ath9k-ar933x-usb-hang-workaround.patch

@@ -20,7 +20,7 @@
  /******************/
  /* Chip Revisions */
  /******************/
-@@ -1441,6 +1454,9 @@ static bool ath9k_hw_set_reset(struct at
+@@ -1455,6 +1468,9 @@ static bool ath9k_hw_set_reset(struct at
  		udelay(50);
  	}
  
@@ -30,7 +30,7 @@
  	return true;
  }
  
-@@ -1540,6 +1556,9 @@ static bool ath9k_hw_chip_reset(struct a
+@@ -1554,6 +1570,9 @@ static bool ath9k_hw_chip_reset(struct a
  		ar9003_hw_internal_regulator_apply(ah);
  	ath9k_hw_init_pll(ah, chan);
  
@@ -40,7 +40,7 @@
  	return true;
  }
  
-@@ -1847,8 +1866,14 @@ static int ath9k_hw_do_fastcc(struct ath
+@@ -1861,8 +1880,14 @@ static int ath9k_hw_do_fastcc(struct ath
  	if (AR_SREV_9271(ah))
  		ar9002_hw_load_ani_reg(ah, chan);
  
@@ -55,7 +55,7 @@
  	return -EINVAL;
  }
  
-@@ -2102,6 +2127,9 @@ int ath9k_hw_reset(struct ath_hw *ah, st
+@@ -2116,6 +2141,9 @@ int ath9k_hw_reset(struct ath_hw *ah, st
  		ath9k_hw_set_radar_params(ah);
  	}
  

+ 94 - 0
package/kernel/mac80211/patches/ath/558-ath9k-dynack-introduce-ath_dynack_set_timeout-routin.patch

@@ -0,0 +1,94 @@
+From 4420866ef1b602682b009e0186fbb8aefd2125be Mon Sep 17 00:00:00 2001
+From: Lorenzo Bianconi <lorenzo@kernel.org>
+Date: Tue, 20 Aug 2019 18:20:19 +0200
+Subject: [PATCH 1/4] ath9k: dynack: introduce ath_dynack_set_timeout routine
+
+Introduce ath_dynack_set_timeout routine to configure slottime/ack/cts
+timeouts and remove duplicated code
+
+Tested-by: Koen Vandeputte <koen.vandeputte@ncentric.com>
+Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
+---
+ drivers/net/wireless/ath/ath9k/dynack.c | 37 ++++++++++++++-----------
+ 1 file changed, 21 insertions(+), 16 deletions(-)
+
+diff --git a/drivers/net/wireless/ath/ath9k/dynack.c b/drivers/net/wireless/ath/ath9k/dynack.c
+index f112fa5b2eac..38dbe25919f7 100644
+--- a/drivers/net/wireless/ath/ath9k/dynack.c
++++ b/drivers/net/wireless/ath/ath9k/dynack.c
+@@ -78,6 +78,24 @@ static inline bool ath_dynack_bssidmask(struct ath_hw *ah, const u8 *mac)
+ 	return true;
+ }
+ 
++/**
++ * ath_dynack_set_timeout - configure timeouts/slottime registers
++ * @ah: ath hw
++ * @to: timeout value
++ *
++ */
++static void ath_dynack_set_timeout(struct ath_hw *ah, int to)
++{
++	struct ath_common *common = ath9k_hw_common(ah);
++	int slottime = (to - 3) / 2;
++
++	ath_dbg(common, DYNACK, "ACK timeout %u slottime %u\n",
++		to, slottime);
++	ath9k_hw_setslottime(ah, slottime);
++	ath9k_hw_set_ack_timeout(ah, to);
++	ath9k_hw_set_cts_timeout(ah, to);
++}
++
+ /**
+  * ath_dynack_compute_ackto - compute ACK timeout as the maximum STA timeout
+  * @ah: ath hw
+@@ -86,7 +104,6 @@ static inline bool ath_dynack_bssidmask(struct ath_hw *ah, const u8 *mac)
+  */
+ static void ath_dynack_compute_ackto(struct ath_hw *ah)
+ {
+-	struct ath_common *common = ath9k_hw_common(ah);
+ 	struct ath_dynack *da = &ah->dynack;
+ 	struct ath_node *an;
+ 	int to = 0;
+@@ -96,15 +113,8 @@ static void ath_dynack_compute_ackto(struct ath_hw *ah)
+ 			to = an->ackto;
+ 
+ 	if (to && da->ackto != to) {
+-		u32 slottime;
+-
+-		slottime = (to - 3) / 2;
++		ath_dynack_set_timeout(ah, to);
+ 		da->ackto = to;
+-		ath_dbg(common, DYNACK, "ACK timeout %u slottime %u\n",
+-			da->ackto, slottime);
+-		ath9k_hw_setslottime(ah, slottime);
+-		ath9k_hw_set_ack_timeout(ah, da->ackto);
+-		ath9k_hw_set_cts_timeout(ah, da->ackto);
+ 	}
+ }
+ 
+@@ -198,10 +208,7 @@ void ath_dynack_sample_tx_ts(struct ath_hw *ah, struct sk_buff *skb,
+ 		    ieee80211_is_assoc_resp(hdr->frame_control) ||
+ 		    ieee80211_is_auth(hdr->frame_control)) {
+ 			ath_dbg(common, DYNACK, "late ack\n");
+-
+-			ath9k_hw_setslottime(ah, (LATEACK_TO - 3) / 2);
+-			ath9k_hw_set_ack_timeout(ah, LATEACK_TO);
+-			ath9k_hw_set_cts_timeout(ah, LATEACK_TO);
++			ath_dynack_set_timeout(ah, LATEACK_TO);
+ 			if (sta) {
+ 				struct ath_node *an;
+ 
+@@ -340,9 +347,7 @@ void ath_dynack_reset(struct ath_hw *ah)
+ 	da->ack_rbf.h_rb = 0;
+ 
+ 	/* init acktimeout */
+-	ath9k_hw_setslottime(ah, (ackto - 3) / 2);
+-	ath9k_hw_set_ack_timeout(ah, ackto);
+-	ath9k_hw_set_cts_timeout(ah, ackto);
++	ath_dynack_set_timeout(ah, ackto);
+ }
+ EXPORT_SYMBOL(ath_dynack_reset);
+ 
+-- 
+2.17.1
+

+ 0 - 73
package/kernel/mac80211/patches/ath/558-ath9k-only-mask-use_eeprom-on-of-noeeprom.patch

@@ -1,73 +0,0 @@
-ath9k: Avoid OF no-EEPROM quirks without qca,no-eeprom
-
-ath9k_of_init() function[0] was initially written on the assumption that
-if someone had an explicit ath9k OF node that "there must be something
-wrong, why would someone add an OF node if everything is fine"[1]
-(Quoting Martin Blumenstingl)
-
-"it turns out it's not that simple. with your requirements I'm now aware
-of two use-cases where the current code in ath9k_of_init() doesn't work
-without modifications"[1]
-
-The "your requirements" Martin speaks of is the result of the fact that I
-have a device (PowerCloud Systems CR5000) that uses the EEPROM for
-caldata and firmware but for which the MAC address is take from the MTD
-"art" partition[2], or more succinctly:
-
-"some cards come with a physical EEPROM chip so "qca,no-eeprom" should not
-be set (your use-case). in this case AH_USE_EEPROM should be set (which
-is the default when there is no OF node)"[1]
-
-The other use case is:
-
-the firmware on some PowerMac G5 seems to add a OF node for the ath9k
-card automatically. depending on the EEPROM on the card AH_NO_EEP_SWAP
-should be unset (which is the default when there is no OF node). see [3]
-
-After this patch to ath9k_of_init() the new behavior will be:
-
-    if there's no OF node then everything is the same as before
-    if there's an empty OF node then ath9k will use the hardware EEPROM
-      (before ath9k would fail to initialize because no EEPROM data was
-      provided by userspace)
-    if there's an OF node with only a MAC address then ath9k will use
-      the MAC address and the hardware EEPROM (see the case above)
-    with "qca,no-eeprom" EEPROM data from userspace will be requested.
-      the behavior here will not change
-[1]
-
-Martin provides additional background on EEPROM swapping[1] which I have
-included in the patch annotation but not the commit message.
-
-Thanks to Christian Lampartar <chunkeey@gmail.com> for all his help on
-troubleshooting this issue and the basis for this patch.
-
-Fixes: 138b41253d9c ("ath9k: parse the device configuration from an OF node")
-
-[0]https://elixir.bootlin.com/linux/v4.20-rc7/source/drivers/net/wireless/ath/ath9k/init.c#L615
-[1]https://github.com/librecmc/librecmc/pull/1645#issuecomment-448027058
-[2]https://github.com/librecmc/librecmc/pull/1613
-[3]https://patchwork.kernel.org/patch/10241731/
-
-Signed-off-by: Daniel F. Dickinson <cshored@thecshore.com>
---- a/drivers/net/wireless/ath/ath9k/init.c
-+++ b/drivers/net/wireless/ath/ath9k/init.c
-@@ -642,15 +642,15 @@ static int ath9k_of_init(struct ath_soft
- 		ret = ath9k_eeprom_request(sc, eeprom_name);
- 		if (ret)
- 			return ret;
-+
-+		ah->ah_flags &= ~AH_USE_EEPROM;
-+		ah->ah_flags |= AH_NO_EEP_SWAP;
- 	}
- 
- 	mac = of_get_mac_address(np);
- 	if (mac)
- 		ether_addr_copy(common->macaddr, mac);
- 
--	ah->ah_flags &= ~AH_USE_EEPROM;
--	ah->ah_flags |= AH_NO_EEP_SWAP;
--
- 	return 0;
- }
- 

+ 32 - 0
package/kernel/mac80211/patches/ath/559-ath9k-dynack-properly-set-last-timeout-timestamp-in-.patch

@@ -0,0 +1,32 @@
+From e5b56ce50eab31d24df6a70cf025db3acc4aa3ac Mon Sep 17 00:00:00 2001
+From: Lorenzo Bianconi <lorenzo@kernel.org>
+Date: Tue, 20 Aug 2019 18:20:20 +0200
+Subject: [PATCH 2/4] ath9k: dynack: properly set last timeout timestamp in
+ ath_dynack_reset
+
+Add compute timeout to last computation timestamp in
+ath_dynack_reset in order to not run ath_dynack_compute_ackto
+immediately
+
+Tested-by: Koen Vandeputte <koen.vandeputte@ncentric.com>
+Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
+---
+ drivers/net/wireless/ath/ath9k/dynack.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/net/wireless/ath/ath9k/dynack.c b/drivers/net/wireless/ath/ath9k/dynack.c
+index 38dbe25919f7..398ea872751f 100644
+--- a/drivers/net/wireless/ath/ath9k/dynack.c
++++ b/drivers/net/wireless/ath/ath9k/dynack.c
+@@ -338,7 +338,7 @@ void ath_dynack_reset(struct ath_hw *ah)
+ 	u32 ackto = 9 + 16 + 64;
+ 	struct ath_dynack *da = &ah->dynack;
+ 
+-	da->lto = jiffies;
++	da->lto = jiffies + COMPUTE_TO;
+ 	da->ackto = ackto;
+ 
+ 	da->st_rbf.t_rb = 0;
+-- 
+2.17.1
+

+ 96 - 0
package/kernel/mac80211/patches/ath/560-ath9k-dynack-set-max-timeout-according-to-channel-wi.patch

@@ -0,0 +1,96 @@
+From 3f737abb7d53cc80d619a3b4a30b6fa63cdc8df7 Mon Sep 17 00:00:00 2001
+From: Lorenzo Bianconi <lorenzo@kernel.org>
+Date: Tue, 20 Aug 2019 18:20:21 +0200
+Subject: [PATCH 3/4] ath9k: dynack: set max timeout according to channel width
+
+Compute maximum configurable ackimeout/ctstimeout according to channel
+width (clockrate)
+
+Tested-by: Koen Vandeputte <koen.vandeputte@ncentric.com>
+Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
+---
+ drivers/net/wireless/ath/ath9k/dynack.c | 38 +++++++++++++++++++------
+ 1 file changed, 30 insertions(+), 8 deletions(-)
+
+diff --git a/drivers/net/wireless/ath/ath9k/dynack.c b/drivers/net/wireless/ath/ath9k/dynack.c
+index 398ea872751f..fe9181533de3 100644
+--- a/drivers/net/wireless/ath/ath9k/dynack.c
++++ b/drivers/net/wireless/ath/ath9k/dynack.c
+@@ -20,11 +20,30 @@
+ 
+ #define COMPUTE_TO		(5 * HZ)
+ #define LATEACK_DELAY		(10 * HZ)
+-#define LATEACK_TO		256
+-#define MAX_DELAY		300
+ #define EWMA_LEVEL		96
+ #define EWMA_DIV		128
+ 
++/**
++ * ath_dynack_get_max_to - set max timeout according to channel width
++ * @ah: ath hw
++ *
++ */
++static u32 ath_dynack_get_max_to(struct ath_hw *ah)
++{
++	const struct ath9k_channel *chan = ah->curchan;
++
++	if (!chan)
++		return 300;
++
++	if (IS_CHAN_HT40(chan))
++		return 300;
++	if (IS_CHAN_HALF_RATE(chan))
++		return 750;
++	if (IS_CHAN_QUARTER_RATE(chan))
++		return 1500;
++	return 600;
++}
++
+ /**
+  * ath_dynack_ewma - EWMA (Exponentially Weighted Moving Average) calculation
+  *
+@@ -126,15 +145,16 @@ static void ath_dynack_compute_ackto(struct ath_hw *ah)
+  */
+ static void ath_dynack_compute_to(struct ath_hw *ah)
+ {
+-	u32 ackto, ack_ts;
+-	u8 *dst, *src;
++	struct ath_dynack *da = &ah->dynack;
++	u32 ackto, ack_ts, max_to;
+ 	struct ieee80211_sta *sta;
+-	struct ath_node *an;
+ 	struct ts_info *st_ts;
+-	struct ath_dynack *da = &ah->dynack;
++	struct ath_node *an;
++	u8 *dst, *src;
+ 
+ 	rcu_read_lock();
+ 
++	max_to = ath_dynack_get_max_to(ah);
+ 	while (da->st_rbf.h_rb != da->st_rbf.t_rb &&
+ 	       da->ack_rbf.h_rb != da->ack_rbf.t_rb) {
+ 		ack_ts = da->ack_rbf.tstamp[da->ack_rbf.h_rb];
+@@ -150,7 +170,7 @@ static void ath_dynack_compute_to(struct ath_hw *ah)
+ 		if (ack_ts > st_ts->tstamp + st_ts->dur) {
+ 			ackto = ack_ts - st_ts->tstamp - st_ts->dur;
+ 
+-			if (ackto < MAX_DELAY) {
++			if (ackto < max_to) {
+ 				sta = ieee80211_find_sta_by_ifaddr(ah->hw, dst,
+ 								   src);
+ 				if (sta) {
+@@ -207,8 +227,10 @@ void ath_dynack_sample_tx_ts(struct ath_hw *ah, struct sk_buff *skb,
+ 		if (ieee80211_is_assoc_req(hdr->frame_control) ||
+ 		    ieee80211_is_assoc_resp(hdr->frame_control) ||
+ 		    ieee80211_is_auth(hdr->frame_control)) {
++			u32 max_to = ath_dynack_get_max_to(ah);
++
+ 			ath_dbg(common, DYNACK, "late ack\n");
+-			ath_dynack_set_timeout(ah, LATEACK_TO);
++			ath_dynack_set_timeout(ah, max_to);
+ 			if (sta) {
+ 				struct ath_node *an;
+ 
+-- 
+2.17.1
+

+ 78 - 0
package/kernel/mac80211/patches/ath/561-ath9k-dynack-set-ackto-to-max-timeout-in-ath_dynack_.patch

@@ -0,0 +1,78 @@
+From cc783bfa67e87d2e6206f7626b7bbb74d5c5f269 Mon Sep 17 00:00:00 2001
+From: Lorenzo Bianconi <lorenzo@kernel.org>
+Date: Tue, 20 Aug 2019 18:20:22 +0200
+Subject: [PATCH 4/4] ath9k: dynack: set ackto to max timeout in
+ ath_dynack_reset
+
+Initialize acktimeout to the maximum configurable value in
+ath_dynack_reset in order to not disconnect long distance static links
+enabling dynack and even to take care of possible errors configuring
+a static timeout. Moreover initialize station timeout value to the current
+acktimeout value
+
+Tested-by: Koen Vandeputte <koen.vandeputte@ncentric.com>
+Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
+---
+ drivers/net/wireless/ath/ath9k/dynack.c | 20 +++++++++++++-------
+ 1 file changed, 13 insertions(+), 7 deletions(-)
+
+diff --git a/drivers/net/wireless/ath/ath9k/dynack.c b/drivers/net/wireless/ath/ath9k/dynack.c
+index fe9181533de3..f786be04d0ac 100644
+--- a/drivers/net/wireless/ath/ath9k/dynack.c
++++ b/drivers/net/wireless/ath/ath9k/dynack.c
+@@ -321,11 +321,9 @@ EXPORT_SYMBOL(ath_dynack_sample_ack_ts);
+  */
+ void ath_dynack_node_init(struct ath_hw *ah, struct ath_node *an)
+ {
+-	/* ackto = slottime + sifs + air delay */
+-	u32 ackto = 9 + 16 + 64;
+ 	struct ath_dynack *da = &ah->dynack;
+ 
+-	an->ackto = ackto;
++	an->ackto = da->ackto;
+ 
+ 	spin_lock(&da->qlock);
+ 	list_add_tail(&an->list, &da->nodes);
+@@ -356,20 +354,26 @@ EXPORT_SYMBOL(ath_dynack_node_deinit);
+  */
+ void ath_dynack_reset(struct ath_hw *ah)
+ {
+-	/* ackto = slottime + sifs + air delay */
+-	u32 ackto = 9 + 16 + 64;
+ 	struct ath_dynack *da = &ah->dynack;
++	struct ath_node *an;
++
++	spin_lock_bh(&da->qlock);
+ 
+ 	da->lto = jiffies + COMPUTE_TO;
+-	da->ackto = ackto;
+ 
+ 	da->st_rbf.t_rb = 0;
+ 	da->st_rbf.h_rb = 0;
+ 	da->ack_rbf.t_rb = 0;
+ 	da->ack_rbf.h_rb = 0;
+ 
++	da->ackto = ath_dynack_get_max_to(ah);
++	list_for_each_entry(an, &da->nodes, list)
++		an->ackto = da->ackto;
++
+ 	/* init acktimeout */
+-	ath_dynack_set_timeout(ah, ackto);
++	ath_dynack_set_timeout(ah, da->ackto);
++
++	spin_unlock_bh(&da->qlock);
+ }
+ EXPORT_SYMBOL(ath_dynack_reset);
+ 
+@@ -386,6 +390,8 @@ void ath_dynack_init(struct ath_hw *ah)
+ 
+ 	spin_lock_init(&da->qlock);
+ 	INIT_LIST_HEAD(&da->nodes);
++	/* ackto = slottime + sifs + air delay */
++	da->ackto = 9 + 16 + 64;
+ 
+ 	ah->hw->wiphy->features |= NL80211_FEATURE_ACKTO_ESTIMATION;
+ }
+-- 
+2.17.1
+

+ 7 - 5
package/kernel/mac80211/patches/build/001-fix_build.patch

@@ -27,7 +27,7 @@
  	@set -e ; test -f local-symbols || (						\
  	echo "/--------------"								;\
  	echo "| You shouldn't run make in the backports tree, but only in"		;\
-@@ -60,57 +62,61 @@ mrproper:
+@@ -60,58 +62,62 @@ mrproper:
  	echo "| (that isn't currently running.)"					;\
  	echo "\\--"									;\
  	false)
@@ -56,12 +56,13 @@
 -			done								\
 -		) > Kconfig.kernel							;\
 -		kver=$$($(MAKE) --no-print-directory -C $(KLIB_BUILD) kernelversion |	\
--			sed 's/^\(\([3-4]\|2\.6\)\.[0-9]\+\).*/\1/;t;d')		;\
+-			sed 's/^\(\([3-5]\|2\.6\)\.[0-9]\+\).*/\1/;t;d')		;\
 -		test "$$kver" != "" || echo "Kernel version parse failed!"		;\
 -		test "$$kver" != ""							;\
 -		kvers="$$(seq 14 39 | sed 's/^/2.6./')"					;\
 -		kvers="$$kvers $$(seq 0 19 | sed 's/^/3./')"				;\
--		kvers="$$kvers $$(seq 0 99 | sed 's/^/4./')"				;\
+-		kvers="$$kvers $$(seq 0 20 | sed 's/^/4./')"				;\
+-		kvers="$$kvers $$(seq 0 99 | sed 's/^/5./')"				;\
 -		print=0									;\
 -		for v in $$kvers ; do							\
 -			if [ "$$print" = "1" ] ; then					\
@@ -112,12 +113,13 @@
 +
 +Kconfig.versions: Kconfig.kernel
 +	@kver=$$($(MAKE) --no-print-directory -C $(KLIB_BUILD) kernelversion |	\
-+		sed 's/^\(\([3-4]\|2\.6\)\.[0-9]\+\).*/\1/;t;d')		;\
++		sed 's/^\(\([3-5]\|2\.6\)\.[0-9]\+\).*/\1/;t;d')		;\
 +	test "$$kver" != "" || echo "Kernel version parse failed!"		;\
 +	test "$$kver" != ""							;\
 +	kvers="$$(seq 14 39 | sed 's/^/2.6./')"					;\
 +	kvers="$$kvers $$(seq 0 19 | sed 's/^/3./')"				;\
-+	kvers="$$kvers $$(seq 0 99 | sed 's/^/4./')"				;\
++	kvers="$$kvers $$(seq 0 20 | sed 's/^/4./')"				;\
++	kvers="$$kvers $$(seq 0 99 | sed 's/^/5./')"				;\
 +	print=0									;\
 +	for v in $$kvers ; do							\
 +		if [ "$$print" = "1" ] ; then					\

+ 2 - 2
package/kernel/mac80211/patches/rt2x00/004-rt2x00-do-not-check-for-txstatus-timeout-every-time-.patch

@@ -51,7 +51,7 @@ Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
  		rt2800mmio_enable_interrupt(rt2x00dev,
 --- a/drivers/net/wireless/ralink/rt2x00/rt2x00.h
 +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00.h
-@@ -980,6 +980,8 @@ struct rt2x00_dev {
+@@ -979,6 +979,8 @@ struct rt2x00_dev {
  	 */
  	DECLARE_KFIFO_PTR(txstatus_fifo, u32);
  
@@ -62,7 +62,7 @@ Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
  	 */
 --- a/drivers/net/wireless/ralink/rt2x00/rt2x00queue.c
 +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00queue.c
-@@ -1039,6 +1039,7 @@ void rt2x00queue_start_queues(struct rt2
+@@ -1042,6 +1042,7 @@ void rt2x00queue_start_queues(struct rt2
  	 */
  	tx_queue_for_each(rt2x00dev, queue)
  		rt2x00queue_start_queue(queue);

+ 1 - 1
package/kernel/mac80211/patches/rt2x00/005-rt2x00-use-different-txstatus-timeouts-when-flushing.patch

@@ -97,7 +97,7 @@ Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
  	 * Driver configuration
 --- a/drivers/net/wireless/ralink/rt2x00/rt2x00mac.c
 +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00mac.c
-@@ -720,8 +720,12 @@ void rt2x00mac_flush(struct ieee80211_hw
+@@ -710,8 +710,12 @@ void rt2x00mac_flush(struct ieee80211_hw
  	if (!test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags))
  		return;
  

+ 39 - 0
package/kernel/mac80211/patches/rt2x00/020-cfg80211-add-ratelimited-variants-of-err-and-warn.patch

@@ -0,0 +1,39 @@
+From patchwork Tue Mar 12 09:51:40 2019
+Content-Type: text/plain; charset="utf-8"
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+X-Patchwork-Submitter: Stanislaw Gruszka <sgruszka@redhat.com>
+X-Patchwork-Id: 10848957
+X-Patchwork-Delegate: johannes@sipsolutions.net
+From: Stanislaw Gruszka <sgruszka@redhat.com>
+To: linux-wireless@vger.kernel.org
+Cc: =?utf-8?q?Tomislav_Po=C5=BEega?= <pozega.tomislav@gmail.com>,
+ Daniel Golle <daniel@makrotopia.org>, Felix Fietkau <nbd@nbd.name>,
+ Mathias Kresin <dev@kresin.me>
+Subject: [PATCH v3 1/4] cfg80211: add ratelimited variants of err and warn
+Date: Tue, 12 Mar 2019 10:51:40 +0100
+Message-Id: <1552384303-29529-2-git-send-email-sgruszka@redhat.com>
+In-Reply-To: <1552384303-29529-1-git-send-email-sgruszka@redhat.com>
+References: <1552384303-29529-1-git-send-email-sgruszka@redhat.com>
+
+wiphy_{err,warn}_ratelimited will be used by rt2x00
+
+Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
+---
+ include/net/cfg80211.h | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+--- a/include/net/cfg80211.h
++++ b/include/net/cfg80211.h
+@@ -6597,6 +6597,11 @@ int cfg80211_external_auth_request(struc
+ #define wiphy_info(wiphy, format, args...)			\
+ 	dev_info(&(wiphy)->dev, format, ##args)
+ 
++#define wiphy_err_ratelimited(wiphy, format, args...)		\
++	dev_err_ratelimited(&(wiphy)->dev, format, ##args)
++#define wiphy_warn_ratelimited(wiphy, format, args...)		\
++	dev_warn_ratelimited(&(wiphy)->dev, format, ##args)
++
+ #define wiphy_debug(wiphy, format, args...)			\
+ 	wiphy_printk(KERN_DEBUG, wiphy, format, ##args)
+ 

+ 0 - 33
package/kernel/mac80211/patches/rt2x00/020-rt2x00-do-not-print-error-when-queue-is-full.patch

@@ -1,33 +0,0 @@
-From 1a8a8989b779e51e4652a30e9f22c36a1b6ffc4b Mon Sep 17 00:00:00 2001
-From: Stanislaw Gruszka <sgruszka@redhat.com>
-Date: Thu, 20 Dec 2018 16:16:11 +0100
-X-Patchwork-Submitter: Stanislaw Gruszka <sgruszka@redhat.com>
-X-Patchwork-Id: 10739037
-X-Patchwork-Delegate: kvalo@adurom.com
-Subject: [PATCH 20/28] rt2x00: do not print error when queue is full
-
-For unknown reasons printk() on some context can cause CPU hung on
-embedded MT7620 AP/router MIPS platforms. What can result on wifi
-disconnects.
-
-This patch move queue full messages to debug level what is consistent
-with other mac80211 drivers which drop packet silently if tx queue is
-full. This make MT7620 OpenWRT routers more stable, what was reported
-by various users.
-
-Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
----
- drivers/net/wireless/ralink/rt2x00/rt2x00queue.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
---- a/drivers/net/wireless/ralink/rt2x00/rt2x00queue.c
-+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00queue.c
-@@ -671,7 +671,7 @@ int rt2x00queue_write_tx_frame(struct da
- 	spin_lock(&queue->tx_lock);
- 
- 	if (unlikely(rt2x00queue_full(queue))) {
--		rt2x00_err(queue->rt2x00dev, "Dropping frame due to full tx queue %d\n",
-+		rt2x00_dbg(queue->rt2x00dev, "Dropping frame due to full tx queue %d\n",
- 			   queue->qid);
- 		ret = -ENOBUFS;
- 		goto out;

+ 42 - 0
package/kernel/mac80211/patches/rt2x00/021-rt2x00-use-ratelimited-variants-dev_warn-dev_err.patch

@@ -0,0 +1,42 @@
+From patchwork Tue Mar 12 09:51:41 2019
+Content-Type: text/plain; charset="utf-8"
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+X-Patchwork-Submitter: Stanislaw Gruszka <sgruszka@redhat.com>
+X-Patchwork-Id: 10848959
+X-Patchwork-Delegate: kvalo@adurom.com
+From: Stanislaw Gruszka <sgruszka@redhat.com>
+To: linux-wireless@vger.kernel.org
+Cc: =?utf-8?q?Tomislav_Po=C5=BEega?= <pozega.tomislav@gmail.com>,
+ Daniel Golle <daniel@makrotopia.org>, Felix Fietkau <nbd@nbd.name>,
+ Mathias Kresin <dev@kresin.me>
+Subject: [PATCH v3 2/4] rt2x00: use ratelimited variants dev_warn/dev_err
+Date: Tue, 12 Mar 2019 10:51:41 +0100
+Message-Id: <1552384303-29529-3-git-send-email-sgruszka@redhat.com>
+In-Reply-To: <1552384303-29529-1-git-send-email-sgruszka@redhat.com>
+References: <1552384303-29529-1-git-send-email-sgruszka@redhat.com>
+
+As reported by Randy we can overwhelm logs on some USB error conditions.
+To avoid that use dev_warn_ratelimited() and dev_err_ratelimitd().
+
+Reported-and-tested-by: Randy Oostdyk <linux-kernel@oostdyk.com>
+Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
+---
+ drivers/net/wireless/ralink/rt2x00/rt2x00.h | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/drivers/net/wireless/ralink/rt2x00/rt2x00.h
++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00.h
+@@ -69,10 +69,10 @@
+ 	printk(KERN_ERR KBUILD_MODNAME ": %s: Error - " fmt,		\
+ 	       __func__, ##__VA_ARGS__)
+ #define rt2x00_err(dev, fmt, ...)					\
+-	wiphy_err((dev)->hw->wiphy, "%s: Error - " fmt,			\
++	wiphy_err_ratelimited((dev)->hw->wiphy, "%s: Error - " fmt,	\
+ 		  __func__, ##__VA_ARGS__)
+ #define rt2x00_warn(dev, fmt, ...)					\
+-	wiphy_warn((dev)->hw->wiphy, "%s: Warning - " fmt,		\
++	wiphy_warn_ratelimited((dev)->hw->wiphy, "%s: Warning - " fmt,	\
+ 		   __func__, ##__VA_ARGS__)
+ #define rt2x00_info(dev, fmt, ...)					\
+ 	wiphy_info((dev)->hw->wiphy, "%s: Info - " fmt,			\

+ 96 - 0
package/kernel/mac80211/patches/rt2x00/022-rt2x00-check-number-of-EPROTO-errors.patch

@@ -0,0 +1,96 @@
+From patchwork Tue Mar 12 09:51:42 2019
+Content-Type: text/plain; charset="utf-8"
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+X-Patchwork-Submitter: Stanislaw Gruszka <sgruszka@redhat.com>
+X-Patchwork-Id: 10848961
+X-Patchwork-Delegate: kvalo@adurom.com
+From: Stanislaw Gruszka <sgruszka@redhat.com>
+To: linux-wireless@vger.kernel.org
+Cc: =?utf-8?q?Tomislav_Po=C5=BEega?= <pozega.tomislav@gmail.com>,
+ Daniel Golle <daniel@makrotopia.org>, Felix Fietkau <nbd@nbd.name>,
+ Mathias Kresin <dev@kresin.me>
+Subject: [PATCH v3 3/4] rt2x00: check number of EPROTO errors
+Date: Tue, 12 Mar 2019 10:51:42 +0100
+Message-Id: <1552384303-29529-4-git-send-email-sgruszka@redhat.com>
+In-Reply-To: <1552384303-29529-1-git-send-email-sgruszka@redhat.com>
+References: <1552384303-29529-1-git-send-email-sgruszka@redhat.com>
+
+Some USB host devices/drivers on some conditions can always return
+EPROTO error on submitted URBs. That can cause infinity loop in the
+rt2x00 driver.
+
+Since we can have single EPROTO errors we can not mark as device as
+removed to avoid infinity loop. However we can count consecutive
+EPROTO errors and mark device as removed if get lot of it.
+I choose number 10 as threshold.
+
+Reported-and-tested-by: Randy Oostdyk <linux-kernel@oostdyk.com>
+Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
+---
+ drivers/net/wireless/ralink/rt2x00/rt2x00.h    |  1 +
+ drivers/net/wireless/ralink/rt2x00/rt2x00usb.c | 22 +++++++++++++++++++---
+ 2 files changed, 20 insertions(+), 3 deletions(-)
+
+--- a/drivers/net/wireless/ralink/rt2x00/rt2x00.h
++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00.h
+@@ -1016,6 +1016,7 @@ struct rt2x00_dev {
+ 	unsigned int extra_tx_headroom;
+ 
+ 	struct usb_anchor *anchor;
++	unsigned int num_proto_errs;
+ 
+ 	/* Clock for System On Chip devices. */
+ 	struct clk *clk;
+--- a/drivers/net/wireless/ralink/rt2x00/rt2x00usb.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00usb.c
+@@ -31,6 +31,22 @@
+ #include "rt2x00.h"
+ #include "rt2x00usb.h"
+ 
++static bool rt2x00usb_check_usb_error(struct rt2x00_dev *rt2x00dev, int status)
++{
++	if (status == -ENODEV || status == -ENOENT)
++		return true;
++
++	if (status == -EPROTO || status == -ETIMEDOUT)
++		rt2x00dev->num_proto_errs++;
++	else
++		rt2x00dev->num_proto_errs = 0;
++
++	if (rt2x00dev->num_proto_errs > 3)
++		return true;
++
++	return false;
++}
++
+ /*
+  * Interfacing with the HW.
+  */
+@@ -57,7 +73,7 @@ int rt2x00usb_vendor_request(struct rt2x
+ 		if (status >= 0)
+ 			return 0;
+ 
+-		if (status == -ENODEV || status == -ENOENT) {
++		if (rt2x00usb_check_usb_error(rt2x00dev, status)) {
+ 			/* Device has disappeared. */
+ 			clear_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags);
+ 			break;
+@@ -321,7 +337,7 @@ static bool rt2x00usb_kick_tx_entry(stru
+ 
+ 	status = usb_submit_urb(entry_priv->urb, GFP_ATOMIC);
+ 	if (status) {
+-		if (status == -ENODEV || status == -ENOENT)
++		if (rt2x00usb_check_usb_error(rt2x00dev, status))
+ 			clear_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags);
+ 		set_bit(ENTRY_DATA_IO_FAILED, &entry->flags);
+ 		rt2x00lib_dmadone(entry);
+@@ -410,7 +426,7 @@ static bool rt2x00usb_kick_rx_entry(stru
+ 
+ 	status = usb_submit_urb(entry_priv->urb, GFP_ATOMIC);
+ 	if (status) {
+-		if (status == -ENODEV || status == -ENOENT)
++		if (rt2x00usb_check_usb_error(rt2x00dev, status))
+ 			clear_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags);
+ 		set_bit(ENTRY_DATA_IO_FAILED, &entry->flags);
+ 		rt2x00lib_dmadone(entry);

Some files were not shown because too many files changed in this diff