From e7b2332d05dc5126aeca1aeee2a322ee13ba00f1 Mon Sep 17 00:00:00 2001 From: Piotr Dymacz Date: Sun, 18 Sep 2016 18:49:20 +0200 Subject: [PATCH] Add support for YunCore AP90Q (QCA9531 based) For this board we need a custom delay in low level GPIO init. AP90Q contains huge capacitor on reset button line which breaks O/C recovery mode and makes board start always with safe clocks. --- Makefile | 3 +++ README.md | 2 ++ READMEPL.md | 2 ++ u-boot/Makefile | 7 ++++++ u-boot/cpu/mips/ar7240/qca_gpio_init.S | 21 ++++++++++++++++ u-boot/include/configs/ap143.h | 33 +++++++++++++++++++------- 6 files changed, 60 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 3db4ffa..722832a 100644 --- a/Makefile +++ b/Makefile @@ -240,6 +240,9 @@ village-telco_mesh-potato_v2: wallys_dr531: @$(call build,192,1,ETH_CONFIG=_s27) +yuncore_ap90q: + @$(call build,256,1,ETH_CONFIG=_s27) + zbtlink_zbt-we1526: @$(call build,256,1,ETH_CONFIG=_s27) diff --git a/README.md b/README.md index fb2db4c..bab2c22 100644 --- a/README.md +++ b/README.md @@ -97,6 +97,7 @@ Currently supported devices: - Comfast CF-E314N - Comfast CF-E320N v2 - Comfast CF-E520N/CF-E530N + - YunCore AP90Q I tested this modification on most of these devices, with OpenWrt and OFW firmware. If you are not sure about the version of your device, please contact with me **before** you try to make an upgrade. Changing bootloader to a wrong version will probably damage your router and you will need special hardware to fix it, so please, **be very careful**. @@ -135,6 +136,7 @@ More information about supported devices: | Comfast CF-E314N | QCA9531 | 16 MiB | 64 MiB DDR2 | 64 KiB, LZMA | RO | | Comfast CF-E320N v2 | QCA9531 | 16 MiB | 64 MiB DDR2 | 64 KiB, LZMA | RO | | Comfast CF-E520N/CF-E530N | QCA9531 | 8 MiB | 32 MiB DDR2 | 64 KiB, LZMA | RO | +| YunCore AP90Q | QCA9531 | 16 MiB | 128 MiB DDR2 | 256 KiB | R/W | *(LZMA) - U-Boot binary image is compressed with LZMA.* *(R/W) - environment exists in separate FLASH block which allows you to save it and keep after power down.* diff --git a/READMEPL.md b/READMEPL.md index d562080..b200cba 100644 --- a/READMEPL.md +++ b/READMEPL.md @@ -94,6 +94,7 @@ Lista obecnie wspieranych urządzeń: - Comfast CF-E314N - Comfast CF-E320N v2 - Comfast CF-E520N/CF-E530N + - YunCore AP90Q Przetestowałem swoją modyfikację na większości z wymienionych powyżej urządzeń, z obrazami OpenWrt i oficjalnym firmware producenta. Jeżeli nie jesteś pewien wersji sprzętowej swojego urządzenia, proszę skontaktuj się ze mną **zanim** dokonasz wymiany obrazu bootloadera. Zmiana na niewłaściwą wersję najprawdopodobniej doprowadzi do uszkodzenia Twojego urządzenia i jedyną możliwością jego ponownego uruchomienia będzie przeprogramowanie kości FLASH w zewnętrznym programatorze. @@ -132,6 +133,7 @@ Dodatkowe informacje o wspieranych urządzeniach: | Comfast CF-E314N | QCA9531 | 16 MiB | 64 MiB DDR2 | 64 KiB, LZMA | RO | | Comfast CF-E320N v2 | QCA9531 | 16 MiB | 64 MiB DDR2 | 64 KiB, LZMA | RO | | Comfast CF-E520N/CF-E530N | QCA9531 | 8 MiB | 32 MiB DDR2 | 64 KiB, LZMA | RO | +| YunCore AP90Q | QCA9531 | 16 MiB | 128 MiB DDR2 | 256 KiB | R/W | *(LZMA) - obraz binarny U-Boot został dodatkowo skompresowany przy pomocy LZMA.* *(R/W) - zmienne środowiskowe przechowywane są w osobnym bloku FLASH, co pozwala na ich zachowanie po odłączeniu zasilaniu.* diff --git a/u-boot/Makefile b/u-boot/Makefile index 8c8f9ea..725fb47 100644 --- a/u-boot/Makefile +++ b/u-boot/Makefile @@ -554,6 +554,13 @@ wallys_dr531: qca953x_common @$(call define_add,CONFIG_PCI,1) @$(MKCONFIG) -a ap143 mips mips ap143 ar7240 ar7240 +yuncore_ap90q: qca953x_common + @$(call config_init,YunCore AP90Q,ap90q,16,17,1,QCA_QCA953X_SOC) + @$(call define_add,CONFIG_FOR_YUNCORE_AP90Q,1) + @$(call define_add,CFG_ATHRS27_PHY,1) + @$(call define_add,CFG_ATH_GMAC_NMACS,2) + @$(MKCONFIG) -a ap143 mips mips ap143 ar7240 ar7240 + zbtlink_zbt-we1526: qca953x_common @$(call config_init,Zbtlink ZBT-WE1526,zbt-we1526,16,17,1,QCA_QCA953X_SOC) @$(call define_add,CONFIG_FOR_ZBTLINK_ZBT_WE1526,1) diff --git a/u-boot/cpu/mips/ar7240/qca_gpio_init.S b/u-boot/cpu/mips/ar7240/qca_gpio_init.S index 6f58920..5b2c01b 100644 --- a/u-boot/cpu/mips/ar7240/qca_gpio_init.S +++ b/u-boot/cpu/mips/ar7240/qca_gpio_init.S @@ -621,6 +621,27 @@ gpio_setup: * after initial/basic GPIO configuration */ +/* + * YunCore AP90Q has on PCB, on button reset + * line (GPIO17) a huge capacitor (~10u)... + * which means that before the voltage level + * rises to VCC, our O/C recovery mode reads + * reset button input as low. + * + * So, delay start for some time here. + * + * FIXME! + */ +#if defined(CONFIG_FOR_YUNCORE_AP90Q) + li t8, 0 + li t9, 0x7530 + +loop_start: + addi t8, t8, 1 + bne t8, t9, loop_start + nop +#endif /* CONFIG_FOR_YUNCORE_AP90Q */ + jr ra nop diff --git a/u-boot/include/configs/ap143.h b/u-boot/include/configs/ap143.h index 4e8dc8a..ad5eaf8 100644 --- a/u-boot/include/configs/ap143.h +++ b/u-boot/include/configs/ap143.h @@ -71,6 +71,13 @@ #define CONFIG_QCA_GPIO_MASK_IN GPIO17 #define CONFIG_QCA_GPIO_MASK_OUT_INIT_H CONFIG_QCA_GPIO_MASK_LED_ACT_L +#elif defined(CONFIG_FOR_YUNCORE_AP90Q) + + #define CONFIG_QCA_GPIO_MASK_LED_ACT_L GPIO4 | GPIO12 | GPIO16 + #define CONFIG_QCA_GPIO_MASK_OUT CONFIG_QCA_GPIO_MASK_LED_ACT_L + #define CONFIG_QCA_GPIO_MASK_IN GPIO17 + #define CONFIG_QCA_GPIO_MASK_OUT_INIT_H CONFIG_QCA_GPIO_MASK_LED_ACT_L + #elif defined(CONFIG_FOR_ZBTLINK_ZBT_WE1526) #define CONFIG_QCA_GPIO_MASK_LED_ACT_L GPIO4 | GPIO11 | GPIO12 |\ @@ -119,7 +126,8 @@ "rootfstype=jffs2 init=/sbin/init "\ "mtdparts=ath-nor0:256k(u-boot),64k(u-boot-env),6336k(rootfs),1408k" -#elif defined(CONFIG_FOR_ZBTLINK_ZBT_WE1526) +#elif defined(CONFIG_FOR_YUNCORE_AP90Q) ||\ + defined(CONFIG_FOR_ZBTLINK_ZBT_WE1526) #define CONFIG_BOOTARGS "console=ttyS0,115200 root=31:02 "\ "rootfstype=squashfs init=/sbin/init "\ @@ -141,7 +149,8 @@ #define CFG_LOAD_ADDR 0x9F020000 #elif defined(CONFIG_FOR_WALLYS_DR531) #define CFG_LOAD_ADDR 0x9F050000 -#elif defined(CONFIG_FOR_ZBTLINK_ZBT_WE1526) +#elif defined(CONFIG_FOR_YUNCORE_AP90Q) ||\ + defined(CONFIG_FOR_ZBTLINK_ZBT_WE1526) #define CFG_LOAD_ADDR 0x9FE80000 #endif @@ -168,7 +177,8 @@ #define CFG_ENV_ADDR 0x9F030000 #define CFG_ENV_SIZE 0xF800 #define CFG_ENV_SECT_SIZE 0x10000 -#elif defined(CONFIG_FOR_ZBTLINK_ZBT_WE1526) +#elif defined(CONFIG_FOR_YUNCORE_AP90Q) ||\ + defined(CONFIG_FOR_ZBTLINK_ZBT_WE1526) #define CFG_ENV_ADDR 0x9F040000 #define CFG_ENV_SIZE 0xFC00 #define CFG_ENV_SECT_SIZE 0x10000 @@ -206,7 +216,8 @@ #define OFFSET_MAC_DATA_BLOCK 0x030000 #define OFFSET_MAC_DATA_BLOCK_LENGTH 0x010000 #define OFFSET_MAC_ADDRESS 0x00F810 -#elif defined(CONFIG_FOR_ZBTLINK_ZBT_WE1526) +#elif defined(CONFIG_FOR_YUNCORE_AP90Q) ||\ + defined(CONFIG_FOR_ZBTLINK_ZBT_WE1526) #define OFFSET_MAC_DATA_BLOCK 0xFF0000 #define OFFSET_MAC_DATA_BLOCK_LENGTH 0x010000 #define OFFSET_MAC_ADDRESS 0x000000 @@ -235,7 +246,8 @@ * HTTP recovery configuration * =========================== */ -#if defined(CONFIG_FOR_ZBTLINK_ZBT_WE1526) +#if defined(CONFIG_FOR_YUNCORE_AP90Q) ||\ + defined(CONFIG_FOR_ZBTLINK_ZBT_WE1526) #define WEBFAILSAFE_UPLOAD_KERNEL_ADDRESS CFG_FLASH_BASE + 0x50000 #else #define WEBFAILSAFE_UPLOAD_KERNEL_ADDRESS CFG_LOAD_ADDR @@ -249,7 +261,8 @@ defined(CONFIG_FOR_TPLINK_WR802N) ||\ defined(CONFIG_FOR_TPLINK_WR841N_V9) #define WEBFAILSAFE_UPLOAD_LIMITED_AREA_IN_BYTES (192 * 1024) -#elif defined(CONFIG_FOR_WALLYS_DR531) ||\ +#elif defined(CONFIG_FOR_WALLYS_DR531) ||\ + defined(CONFIG_FOR_YUNCORE_AP90Q) ||\ defined(CONFIG_FOR_ZBTLINK_ZBT_WE1526) #define WEBFAILSAFE_UPLOAD_LIMITED_AREA_IN_BYTES (384 * 1024) #endif @@ -267,6 +280,7 @@ defined(CONFIG_FOR_COMFAST_CF_E320N_V2) ||\ defined(CONFIG_FOR_COMFAST_CF_E520N_CF_E530N) ||\ defined(CONFIG_FOR_WALLYS_DR531) ||\ + defined(CONFIG_FOR_YUNCORE_AP90Q) ||\ defined(CONFIG_FOR_ZBTLINK_ZBT_WE1526) #define CONFIG_QCA_PLL QCA_PLL_PRESET_650_400_200 #endif @@ -286,7 +300,8 @@ #define CONFIG_QCA_PLL_IN_FLASH_BLOCK_OFFSET 0x30000 #define CONFIG_QCA_PLL_IN_FLASH_BLOCK_SIZE 0x10000 -#elif defined(CONFIG_FOR_ZBTLINK_ZBT_WE1526) +#elif defined(CONFIG_FOR_YUNCORE_AP90Q) ||\ + defined(CONFIG_FOR_ZBTLINK_ZBT_WE1526) #define CONFIG_QCA_PLL_IN_FLASH_BLOCK_OFFSET 0x40000 #define CONFIG_QCA_PLL_IN_FLASH_BLOCK_SIZE 0x10000 @@ -302,11 +317,13 @@ !defined(CONFIG_FOR_COMFAST_CF_E320N_V2) &&\ !defined(CONFIG_FOR_COMFAST_CF_E520N_CF_E530N) &&\ !defined(CONFIG_FOR_WALLYS_DR531) &&\ + !defined(CONFIG_FOR_YUNCORE_AP90Q) &&\ !defined(CONFIG_FOR_ZBTLINK_ZBT_WE1526) #define CONFIG_UPG_UBOOT_SIZE_BACKUP_HEX 0x20000 #endif -#if defined(CONFIG_FOR_ZBTLINK_ZBT_WE1526) +#if defined(CONFIG_FOR_YUNCORE_AP90Q) ||\ + defined(CONFIG_FOR_ZBTLINK_ZBT_WE1526) #define CONFIG_UPG_SCRIPTS_FW_ADDR_HEX 0x9F050000 #endif -- 2.25.1