2 * This file contains the configuration parameters for the DB12x (AR9344) board.
5 #ifndef _AP143_CONFIG_H
6 #define _AP143_CONFIG_H
10 #include <soc/soc_common.h>
15 #if defined(CONFIG_FOR_TPLINK_WR820N_CN) ||\
16 defined(CONFIG_FOR_TPLINK_WR802N)
18 #define CONFIG_QCA_GPIO_MASK_LEDS_ACTIVE_LO GPIO13
21 #define CONFIG_QCA_GPIO_MASK_OUTPUTS CONFIG_QCA_GPIO_MASK_LEDS_ACTIVE_LO
22 #define CONFIG_QCA_GPIO_MASK_INPUTS GPIO12
25 #define CONFIG_QCA_GPIO_MASK_OUTPUTS_INIT_HI CONFIG_QCA_GPIO_MASK_LEDS_ACTIVE_LO
27 #elif defined(CONFIG_FOR_TPLINK_WR841N_V9)
29 #define CONFIG_QCA_GPIO_MASK_LEDS_ACTIVE_LO (GPIO3 | GPIO4 | GPIO11 | GPIO13 |\
30 GPIO14 | GPIO15 | GPIO16)
33 #define CONFIG_QCA_GPIO_MASK_OUTPUTS CONFIG_QCA_GPIO_MASK_LEDS_ACTIVE_LO
34 #define CONFIG_QCA_GPIO_MASK_INPUTS (GPIO12 | GPIO17)
37 #define CONFIG_QCA_GPIO_MASK_OUTPUTS_INIT_HI CONFIG_QCA_GPIO_MASK_LEDS_ACTIVE_LO
42 * Miscellaneous configurable options
44 #ifndef CONFIG_BOOTDELAY
45 #define CONFIG_BOOTDELAY 1
50 #define CONFIG_BAUDRATE 115200
51 #define CFG_BAUDRATE_TABLE { 600, 1200, 2400, 4800, 9600, 14400, \
52 19200, 28800, 38400, 56000, 57600, 115200 }
54 #define CFG_ALT_MEMTEST
55 #define CFG_HUSH_PARSER
56 #define CFG_LONGHELP /* undef to save memory */
57 #define CFG_PROMPT "uboot> " /* Monitor Command Prompt */
58 #define CFG_PROMPT_HUSH_PS2 "> "
59 #define CFG_CBSIZE 1024 /* Console I/O Buffer Size */
60 #define CFG_PBSIZE (CFG_CBSIZE+sizeof(CFG_PROMPT)+16) /* Print Buffer Size, was: def + 16 */
61 #define CFG_MAXARGS 16 /* max number of command */
62 #define CFG_MALLOC_LEN 512*1024 /* def: 128*1024 */
63 #define CFG_BOOTPARAMS_LEN 512*1024 /* def: 128 */
64 #define CFG_SDRAM_BASE 0x80000000 /* Cached addr */
65 #define CFG_MEMTEST_START (CFG_SDRAM_BASE + 0x200000) /* RAM test start = CFG_SDRAM_BASE + 2 MB */
66 #define CFG_MEMTEST_END (CFG_SDRAM_BASE + bd->bi_memsize - 0x200001) /* RAM test end = CFG_SDRAM_BASE + RAM size - 2 MB - 1 Byte */
67 #define CFG_RX_ETH_BUFFER 16
69 #if defined(CONFIG_SILENT_CONSOLE)
70 #define SILENT_ENV_VARIABLE "silent=1\0"
72 #define SILENT_ENV_VARIABLE ""
75 #define CFG_DCACHE_SIZE 32768
76 #define CFG_ICACHE_SIZE 65536
77 #define CFG_CACHELINE_SIZE 32
80 * FLASH and environment organization
82 #define CFG_MAX_FLASH_BANKS 1
83 #define CFG_MAX_FLASH_SECT 4096 // 4 KB sectors in 16 MB flash
84 #define CFG_FLASH_SECTOR_SIZE 64 * 1024
87 * We boot from this flash
89 #define CFG_FLASH_BASE 0x9F000000
90 #ifdef COMPRESSED_UBOOT
91 #define BOOTSTRAP_TEXT_BASE CFG_FLASH_BASE
92 #define BOOTSTRAP_CFG_MONITOR_BASE BOOTSTRAP_TEXT_BASE
96 * The following #defines are needed to get flash environment right
98 #define CFG_MONITOR_BASE TEXT_BASE
99 #define CFG_MONITOR_LEN (192 << 10)
104 #undef CONFIG_BOOTARGS
105 #if defined(CONFIG_FOR_TPLINK_WR820N_CN)
106 #define CONFIG_BOOTARGS "console=ttyS0,115200 root=31:02 rootfstype=squashfs init=/sbin/init mtdparts=ath-nor0:32k(u-boot1),32k(u-boot2),3008k(rootfs),896k(uImage),64k(mib0),64k(ART)"
107 #elif defined(CONFIG_FOR_TPLINK_WR841N_V9) ||\
108 defined(CONFIG_FOR_TPLINK_WR802N)
109 #define CONFIG_BOOTARGS "console=ttyS0,115200 root=31:02 rootfstype=squashfs init=/sbin/init mtdparts=ath-nor0:128k(u-boot),1024k(kernel),2816k(rootfs),64k(config),64k(art)"
113 * Other env default values
115 #undef CONFIG_BOOTFILE
116 #define CONFIG_BOOTFILE "firmware.bin"
118 #undef CONFIG_LOADADDR
119 #define CONFIG_LOADADDR 0x80800000
121 #if defined(CONFIG_FOR_TPLINK_WR820N_CN) ||\
122 defined(CONFIG_FOR_TPLINK_WR802N) ||\
123 defined(CONFIG_FOR_TPLINK_WR841N_V9)
124 #define CFG_LOAD_ADDR 0x9F020000
125 #define UPDATE_SCRIPT_FW_ADDR "0x9F020000"
126 #define CONFIG_BOOTCOMMAND "bootm 0x9F020000"
129 #define CONFIG_IPADDR 192.168.1.1
130 #define CONFIG_SERVERIP 192.168.1.2
133 * PLL/Clocks configuration
138 #define CFG_HZ bd->bi_cfg_hz
140 #if defined(CONFIG_FOR_TPLINK_WR820N_CN) ||\
141 defined(CONFIG_FOR_TPLINK_WR802N) ||\
142 defined(CONFIG_FOR_TPLINK_WR841N_V9)
143 #define CONFIG_QCA_PLL QCA_PLL_PRESET_550_400_200
147 * For PLL/clocks recovery use reset button by default
149 #ifdef CONFIG_GPIO_RESET_BTN
150 #define CONFIG_QCA_GPIO_OC_RECOVERY_BTN CONFIG_GPIO_RESET_BTN
153 #ifdef CONFIG_GPIO_RESET_BTN_ACTIVE_LOW
154 #define CONFIG_QCA_GPIO_OC_RECOVERY_BTN_ACTIVE_LOW 1
158 * Address and size of Primary Environment Sector
160 #define CFG_ENV_IS_IN_FLASH 1
161 #undef CFG_ENV_IS_NOWHERE
163 #if defined(CONFIG_FOR_TPLINK_WR820N_CN) ||\
164 defined(CONFIG_FOR_TPLINK_WR802N) ||\
165 defined(CONFIG_FOR_TPLINK_WR841N_V9)
166 #define CFG_ENV_ADDR 0x9F01EC00
167 #define CFG_ENV_SIZE 0x1000
168 #define CFG_ENV_SECT_SIZE 0x10000
174 #if defined(CONFIG_FOR_TPLINK_WR820N_CN) ||\
175 defined(CONFIG_FOR_TPLINK_WR802N) ||\
176 defined(CONFIG_FOR_TPLINK_WR841N_V9)
177 #define CONFIG_COMMANDS (CFG_CMD_MEMORY | \
192 // Enable NetConsole and custom NetConsole port
193 #define CONFIG_NETCONSOLE
194 #define CONFIG_NETCONSOLE_PORT 6666
197 * Web Failsafe configuration
199 #define WEBFAILSAFE_UPLOAD_RAM_ADDRESS CONFIG_LOADADDR
200 #define WEBFAILSAFE_UPLOAD_UBOOT_ADDRESS CFG_FLASH_BASE
202 // Firmware partition offset
203 #if defined(CONFIG_FOR_TPLINK_WR820N_CN) ||\
204 defined(CONFIG_FOR_TPLINK_WR802N) ||\
205 defined(CONFIG_FOR_TPLINK_WR841N_V9)
206 #define WEBFAILSAFE_UPLOAD_KERNEL_ADDRESS WEBFAILSAFE_UPLOAD_UBOOT_ADDRESS + 0x20000
209 // U-Boot partition size
210 #define WEBFAILSAFE_UPLOAD_UBOOT_SIZE_IN_BYTES (CONFIG_MAX_UBOOT_SIZE_KB * 1024)
212 // TODO: should be == CONFIG_MAX_UBOOT_SIZE_KB
213 #if defined(CONFIG_FOR_TPLINK_WR820N_CN) ||\
214 defined(CONFIG_FOR_TPLINK_WR802N) ||\
215 defined(CONFIG_FOR_TPLINK_WR841N_V9)
216 #define UPDATE_SCRIPT_UBOOT_SIZE_IN_BYTES "0x1EC00"
217 #define UPDATE_SCRIPT_UBOOT_BACKUP_SIZE_IN_BYTES "0x20000"
220 // ART partition size
221 #define WEBFAILSAFE_UPLOAD_ART_SIZE_IN_BYTES (64 * 1024)
223 // max. firmware size <= (FLASH_SIZE - WEBFAILSAFE_UPLOAD_LIMITED_AREA_IN_BYTES)
224 // TP-Link: 64k(U-Boot),64k(MAC/model/WPS pin block),64k(ART)
225 #if defined(CONFIG_FOR_TPLINK_WR820N_CN) ||\
226 defined(CONFIG_FOR_TPLINK_WR802N) ||\
227 defined(CONFIG_FOR_TPLINK_WR841N_V9)
228 #define WEBFAILSAFE_UPLOAD_LIMITED_AREA_IN_BYTES (192 * 1024)
231 // progress state info
232 #define WEBFAILSAFE_PROGRESS_START 0
233 #define WEBFAILSAFE_PROGRESS_TIMEOUT 1
234 #define WEBFAILSAFE_PROGRESS_UPLOAD_READY 2
235 #define WEBFAILSAFE_PROGRESS_UPGRADE_READY 3
236 #define WEBFAILSAFE_PROGRESS_UPGRADE_FAILED 4
239 #define WEBFAILSAFE_UPGRADE_TYPE_FIRMWARE 0
240 #define WEBFAILSAFE_UPGRADE_TYPE_UBOOT 1
241 #define WEBFAILSAFE_UPGRADE_TYPE_ART 2
243 /*-----------------------------------------------------------------------*/
246 * Additional environment variables for simple upgrades
248 #define CONFIG_EXTRA_ENV_SETTINGS "uboot_addr=0x9F000000\0" \
249 "uboot_name=uboot.bin\0" \
250 "uboot_size=" UPDATE_SCRIPT_UBOOT_SIZE_IN_BYTES "\0" \
251 "uboot_backup_size=" UPDATE_SCRIPT_UBOOT_BACKUP_SIZE_IN_BYTES "\0" \
253 "if ping $serverip; then " \
254 "mw.b $loadaddr 0xFF $uboot_backup_size && " \
255 "cp.b $uboot_addr $loadaddr $uboot_backup_size && " \
256 "tftp $loadaddr $uboot_name && " \
257 "if itest.l $filesize <= $uboot_size; then " \
258 "erase $uboot_addr +$uboot_backup_size && " \
259 "cp.b $loadaddr $uboot_addr $uboot_backup_size && " \
262 "echo ERROR! Wrong file size!; " \
265 "echo ERROR! Server not reachable!; " \
270 * Cache lock for stack
272 #define CFG_INIT_SP_OFFSET 0x1000
273 #define CONFIG_INIT_SRAM_SP_OFFSET 0xbd001800
275 /* For Merlin, both PCI, PCI-E interfaces are valid */
276 #define ATH_ART_PCICFG_OFFSET 12
277 /* use eth1(LAN) as the net interface */
278 #define CONFIG_AG7240_SPEPHY
279 #define CONFIG_NET_MULTI
281 #if defined(CONFIG_FOR_TPLINK_WR820N_CN) ||\
282 defined(CONFIG_FOR_TPLINK_WR802N) ||\
283 defined(CONFIG_FOR_TPLINK_WR841N_V9)
284 #define WLANCAL 0x9fff1000
285 #define BOARDCAL 0x9fff0000
287 #define CFG_MII0_RMII 1
288 #define CFG_BOOTM_LEN (16 << 20) /* 16 MB */
292 /* MAC address, model and PIN number offsets in FLASH */
293 #if defined(CONFIG_FOR_TPLINK_WR820N_CN) ||\
294 defined(CONFIG_FOR_TPLINK_WR802N) ||\
295 defined(CONFIG_FOR_TPLINK_WR841N_V9)
296 #define OFFSET_MAC_DATA_BLOCK 0x010000
297 #define OFFSET_MAC_DATA_BLOCK_LENGTH 0x010000
298 #define OFFSET_MAC_ADDRESS 0x00FC00
299 #define OFFSET_ROUTER_MODEL 0x00FD00
300 #define OFFSET_PIN_NUMBER 0x00FE00
304 * PLL and clocks configurations from FLASH
306 #if defined(CONFIG_FOR_TPLINK_WR820N_CN) ||\
307 defined(CONFIG_FOR_TPLINK_WR802N) ||\
308 defined(CONFIG_FOR_TPLINK_WR841N_V9)
310 * All TP-Link routers have a lot of unused space
311 * in FLASH, in second 64 KiB block.
312 * We will store there PLL and CLOCK
313 * registers configuration.
315 #define CONFIG_QCA_PLL_IN_FLASH_BLOCK_OFFSET 0x00010000
316 #define CONFIG_QCA_PLL_IN_FLASH_BLOCK_SIZE 0x00010000
320 #if defined(CONFIG_QCA_PLL_IN_FLASH_BLOCK_OFFSET)
321 /* Use last 32 bytes */
322 #define CONFIG_QCA_PLL_IN_FLASH_MAGIC_OFFSET (CFG_FLASH_BASE + \
323 CONFIG_QCA_PLL_IN_FLASH_BLOCK_OFFSET + \
327 #include <cmd_confdefs.h>
329 #endif /* __AP143_CONFIG_H */