@echo "#define CFG_ATHRS17_PHY 1" >> include/config.h
@echo "#define CFG_AG7240_NMACS 1" >> include/config.h
@echo "#define CFG_DUAL_PHY_SUPPORT 1" >> include/config.h
+ @echo "#define GPIO_SYS_LED_BIT 14" >> include/config.h
+ @echo "#define GPIO_SYS_LED_ON 0" >> include/config.h
+ @echo "#define GPIO_WLAN_2G_LED_BIT 13" >> include/config.h
+ @echo "#define GPIO_WLAN_2G_LED_ON 0" >> include/config.h
+ @echo "#define GPIO_USB1_LED_BIT 11" >> include/config.h
+ @echo "#define GPIO_USB1_LED_ON 0" >> include/config.h
+ @echo "#define GPIO_USB2_LED_BIT 12" >> include/config.h
+ @echo "#define GPIO_USB2_LED_ON 0" >> include/config.h
+ @echo "#define GPIO_QSS_LED_BIT 15" >> include/config.h
+ @echo "#define GPIO_QSS_LED_ON 0" >> include/config.h
+ @echo "#define GPIO_RST_BUTTON_BIT 16" >> include/config.h
+ @echo "#define GPIO_RST_BUTTON_IS_ACTIVE_LOW 1" >> include/config.h
@echo "#define DEFAULT_FLASH_SIZE_IN_MB 8" >> include/config.h
@echo "#define BOARD_CUSTOM_STRING \"DB120 (AR9344) U-Boot for TL-WDR3600/43x0\"" >> include/config.h
@echo "#define DDR2_32BIT_SUPPORT 1" >> include/config.h
@echo "#define CFG_ATHRS27_PHY 1" >> include/config.h
@echo "#define CFG_AG7240_NMACS 2" >> include/config.h
+ @echo "#define GPIO_SYS_LED_BIT 14" >> include/config.h
+ @echo "#define GPIO_SYS_LED_ON 0" >> include/config.h
+ @echo "#define GPIO_WLAN_LED_BIT 13" >> include/config.h
+ @echo "#define GPIO_WLAN_LED_ON 0" >> include/config.h
+ @echo "#define GPIO_INTERNET_LED_BIT 18" >> include/config.h
+ @echo "#define GPIO_INTERNET_LED_ON 0" >> include/config.h
+ @echo "#define GPIO_LAN1_LED_BIT 19" >> include/config.h
+ @echo "#define GPIO_LAN1_LED_ON 0" >> include/config.h
+ @echo "#define GPIO_LAN2_LED_BIT 20" >> include/config.h
+ @echo "#define GPIO_LAN2_LED_ON 0" >> include/config.h
+ @echo "#define GPIO_LAN3_LED_BIT 21" >> include/config.h
+ @echo "#define GPIO_LAN3_LED_ON 0" >> include/config.h
+ @echo "#define GPIO_LAN4_LED_BIT 12" >> include/config.h
+ @echo "#define GPIO_LAN4_LED_ON 0" >> include/config.h
+ @echo "#define GPIO_QSS_LED_BIT 15" >> include/config.h
+ @echo "#define GPIO_QSS_LED_ON 0" >> include/config.h
+ @echo "#define GPIO_RST_BUTTON_BIT 17" >> include/config.h
+ @echo "#define GPIO_RST_BUTTON_IS_ACTIVE_LOW 1" >> include/config.h
@echo "#define DEFAULT_FLASH_SIZE_IN_MB 4" >> include/config.h
@echo "#define BOARD_CUSTOM_STRING \"AP123 (AR9341) U-Boot for TL-WR841N/D v8\"" >> include/config.h
void led_toggle(void){\r
unsigned int gpio;\r
\r
- gpio = ar7240_reg_rd(AR7240_GPIO_OUT);\r
+ gpio = ar7240_reg_rd(AR934X_GPIO_OUT);\r
\r
- // SYS LED is connected to GPIO 14\r
- gpio ^= 1 << 14;\r
+#if defined(CONFIG_FOR_TPLINK_WDR3600_WDR43X0_V1)\r
+ gpio ^= 1 << GPIO_SYS_LED_BIT;\r
+#elif defined(CONFIG_FOR_TPLINK_WR841N_V8)\r
+ gpio ^= 1 << GPIO_SYS_LED_BIT;\r
+#else\r
+ #error "Custom GPIO in leg_toggle() not defined!"\r
+#endif\r
\r
- ar7240_reg_wr(AR7240_GPIO_OUT, gpio);\r
+ ar7240_reg_wr(AR934X_GPIO_OUT, gpio);\r
}\r
\r
void all_led_on(void){\r
unsigned int gpio;\r
\r
- gpio = ar7240_reg_rd(AR7240_GPIO_OUT);\r
-\r
- // SYS LED (GPIO 14) and WLAN24 (GPIO 13)\r
- SETBITVAL(gpio, 14, 0);\r
- SETBITVAL(gpio, 13, 0);\r
-\r
- ar7240_reg_wr(AR7240_GPIO_OUT, gpio);\r
+ gpio = ar7240_reg_rd(AR934X_GPIO_OUT);\r
+\r
+#if defined(CONFIG_FOR_TPLINK_WDR3600_WDR43X0_V1)\r
+ SETBITVAL(gpio, GPIO_SYS_LED_BIT, GPIO_SYS_LED_ON);\r
+ SETBITVAL(gpio, GPIO_WLAN_2G_LED_BIT, GPIO_WLAN_2G_LED_ON);\r
+ SETBITVAL(gpio, GPIO_USB1_LED_BIT, GPIO_USB1_LED_ON);\r
+ SETBITVAL(gpio, GPIO_USB2_LED_BIT, GPIO_USB2_LED_ON);\r
+ //SETBITVAL(gpio, GPIO_QSS_LED_BIT, GPIO_QSS_LED_ON);\r
+#elif defined(CONFIG_FOR_TPLINK_WR841N_V8)\r
+ SETBITVAL(gpio, GPIO_SYS_LED_BIT, GPIO_SYS_LED_ON);\r
+ SETBITVAL(gpio, GPIO_WLAN_LED_BIT, GPIO_WLAN_LED_ON);\r
+ SETBITVAL(gpio, GPIO_INTERNET_LED_BIT, GPIO_INTERNET_LED_ON);\r
+ SETBITVAL(gpio, GPIO_LAN1_LED_BIT, GPIO_LAN1_LED_ON);\r
+ SETBITVAL(gpio, GPIO_LAN2_LED_BIT, GPIO_LAN2_LED_ON);\r
+ SETBITVAL(gpio, GPIO_LAN3_LED_BIT, GPIO_LAN3_LED_ON);\r
+ SETBITVAL(gpio, GPIO_LAN4_LED_BIT, GPIO_LAN4_LED_ON);\r
+ SETBITVAL(gpio, GPIO_QSS_LED_BIT, GPIO_QSS_LED_ON);\r
+#else\r
+ #error "Custom GPIO in all_led_on() not defined!"\r
+#endif\r
+\r
+ ar7240_reg_wr(AR934X_GPIO_OUT, gpio);\r
}\r
\r
void all_led_off(void){\r
unsigned int gpio;\r
\r
- gpio = ar7240_reg_rd(AR7240_GPIO_OUT);\r
-\r
- // SYS LED (GPIO 14) and WLAN24 (GPIO 13)\r
- SETBITVAL(gpio, 14, 1);\r
- SETBITVAL(gpio, 13, 1);\r
-\r
- ar7240_reg_wr(AR7240_GPIO_OUT, gpio);\r
+ gpio = ar7240_reg_rd(AR934X_GPIO_OUT);\r
+\r
+#if defined(CONFIG_FOR_TPLINK_WDR3600_WDR43X0_V1)\r
+ SETBITVAL(gpio, GPIO_SYS_LED_BIT, !GPIO_SYS_LED_ON);\r
+ SETBITVAL(gpio, GPIO_WLAN_2G_LED_BIT, !GPIO_WLAN_2G_LED_ON);\r
+ SETBITVAL(gpio, GPIO_USB1_LED_BIT, !GPIO_USB1_LED_ON);\r
+ SETBITVAL(gpio, GPIO_USB2_LED_BIT, !GPIO_USB2_LED_ON);\r
+ //SETBITVAL(gpio, GPIO_QSS_LED_BIT, !GPIO_QSS_LED_ON);\r
+#elif defined(CONFIG_FOR_TPLINK_WR841N_V8)\r
+ SETBITVAL(gpio, GPIO_SYS_LED_BIT, !GPIO_SYS_LED_ON);\r
+ SETBITVAL(gpio, GPIO_WLAN_LED_BIT, !GPIO_WLAN_LED_ON);\r
+ SETBITVAL(gpio, GPIO_INTERNET_LED_BIT, !GPIO_INTERNET_LED_ON);\r
+ SETBITVAL(gpio, GPIO_LAN1_LED_BIT, !GPIO_LAN1_LED_ON);\r
+ SETBITVAL(gpio, GPIO_LAN2_LED_BIT, !GPIO_LAN2_LED_ON);\r
+ SETBITVAL(gpio, GPIO_LAN3_LED_BIT, !GPIO_LAN3_LED_ON);\r
+ SETBITVAL(gpio, GPIO_LAN4_LED_BIT, !GPIO_LAN4_LED_ON);\r
+ SETBITVAL(gpio, GPIO_QSS_LED_BIT, !GPIO_QSS_LED_ON);\r
+#else\r
+ #error "Custom GPIO in all_led_off() not defined!"\r
+#endif\r
+\r
+ ar7240_reg_wr(AR934X_GPIO_OUT, gpio);\r
}\r
\r
// get button status\r
+#ifndef GPIO_RST_BUTTON_BIT\r
+ #error "GPIO_RST_BUTTON_BIT not defined!"\r
+#endif\r
int reset_button_status(void){\r
- // RESET BUTTON is connected to GPIO 16\r
- if(ar7240_reg_rd(AR7240_GPIO_IN) & (1 << 16)){\r
- return 0;\r
+ unsigned int gpio;\r
+\r
+ gpio = ar7240_reg_rd(AR934X_GPIO_IN);\r
+\r
+ if(gpio & (1 << GPIO_RST_BUTTON_BIT)){\r
+#if defined(GPIO_RST_BUTTON_IS_ACTIVE_LOW)\r
+ return(0);\r
+#else\r
+ return(1);\r
+#endif\r
} else {\r
- return 1;\r
+#if defined(GPIO_RST_BUTTON_IS_ACTIVE_LOW)\r
+ return(1);\r
+#else\r
+ return(0);\r
+#endif\r
}\r
}\r
\r
-void gpio_config(void){\r
- /* disable the CLK_OBS on GPIO_4 and set GPIO4 as input */\r
- ar7240_reg_rmw_clear(GPIO_OE_ADDRESS, (1 << 4));\r
- ar7240_reg_rmw_clear(GPIO_OUT_FUNCTION1_ADDRESS, GPIO_OUT_FUNCTION1_ENABLE_GPIO_4_MASK);\r
- ar7240_reg_rmw_set(GPIO_OUT_FUNCTION1_ADDRESS, GPIO_OUT_FUNCTION1_ENABLE_GPIO_4_SET(0x80));\r
- ar7240_reg_rmw_set(GPIO_OE_ADDRESS, (1 << 4));\r
-}\r
-\r
void ath_set_tuning_caps(void){\r
typedef struct {\r
u_int8_t pad[0x28];\r
\r
//wasp_usb_initial_config();\r
\r
- gpio_config();\r
-\r
/* Needed here not to mess with Ethernet clocks */\r
ath_set_tuning_caps();\r
\r
#define AR7100_SPI_CLOCK 0x1F000004
-#ifdef CONFIG_WASP_SUPPORT
- #define ATH_APB_BASE 0xB8000000 /* KSEG1ADDR(0x18000000) */
- #define ATH_GPIO_BASE ATH_APB_BASE+0x00040000
- #define ATH_GPIO_OE ATH_GPIO_BASE+0x0
- #define ATH_GPIO_OUT ATH_GPIO_BASE+0x8
- #define ATH_GPIO_OUT_FUNCTION0 ATH_GPIO_BASE+0x2c
- #define ATH_GPIO_OUT_FUNCTION1 ATH_GPIO_BASE+0x30
- #define ATH_GPIO_OUT_FUNCTION2 ATH_GPIO_BASE+0x34
- #define ATH_GPIO_OUT_FUNCTION3 ATH_GPIO_BASE+0x38
- #define ATH_GPIO_OUT_FUNCTION4 ATH_GPIO_BASE+0x3c
- #define ATH_GPIO_OUT_FUNCTION5 ATH_GPIO_BASE+0x40
-#endif
-
-
#define RVECENT(f,n) \
b f; nop
.align 4
reset:
-#ifdef CONFIG_WASP_SUPPORT
-#ifndef CONFIG_AP123
- /* GPIO Init */
- li a1, ATH_GPIO_OE
+#if defined(CONFIG_WASP_SUPPORT)
+
+ /*
+ * Disable JTAG
+ */
+
+ // Set BIT 1 to 1 in AR934X_GPIO_FUNCTION
+ li a1, AR934X_GPIO_FUNCTION
lw v1, 0(a1)
- /* GPIO 11-15 as output */
- li v0, ~((1 << 15) | (1 << 14) | (1 << 13) | (1 << 12) | (1 << 11))
+ li v0, 0x2
+ or v1, v1, v0
+ sw v1, 0(a1)
+
+#if defined(CONFIG_FOR_TPLINK_WDR3600_WDR43X0_V1)
+ /*
+ * LED's/Reset GPIOs on WDR3600/WDR43x0 v1:
+ *
+ * 11 => USB1
+ * 12 => USB2
+ * 13 => WLAN2G
+ * 14 => SYS
+ * 15 => QSS
+ *
+ * 16 => Reset button
+ *
+ * All used GPIOs are active LOW!
+ */
+
+ // GPIO Init
+ li a1, AR934X_GPIO_OE
+ lw v1, 0(a1)
+ li v0, 0xFFFF07FF
and v1, v1, v0
- /* save GPIO Config Value */
sw v1, 0(a1)
- lw v0, 0(a1)
- /* set gpio funtion for gpio11 */
- li a1, ATH_GPIO_OUT_FUNCTION2
+ // Set gpio function for GPIO 11
+ li a1, AR934X_GPIO_OUT_FUNCTION2
lw v1, 0(a1)
- li v0, 0x00ffffff
+ li v0, 0x00FFFFFF
and v1, v1, v0
- /* set v1 value to ATH_GPIO_OUT_FUNCTION2 */
sw v1, 0(a1)
- /* set gpio funtion for gpio12~15 */
- li a1, ATH_GPIO_OUT_FUNCTION3
+ // Set gpio function for GPIOs 12~15
+ li a1, AR934X_GPIO_OUT_FUNCTION3
lw v1, 0(a1)
li v0, 0x0
and v1, v1, v0
- /* set v1 value to ATH_GPIO_OUT_FUNCTION3 */
sw v1, 0(a1)
- /* turn on gpio11-15 */
- li a1, ATH_GPIO_OUT
+ // Turn on GPIOs 11~15
+ li a1, AR934X_GPIO_OUT
lw v1, 0(a1)
- li v0, ~((1 << 15) | (1 << 14) | (1 << 13) | (1 << 12) | (1 << 11))
+ li v0, 0xFFFF07FF
and v1, v1, v0
- /* set v1 value to ATH_GPIO_OUT */
sw v1, 0(a1)
- /* wait for a while, for leds' bootup blink*/
+ // wait for a while, for leds' bootup blink
li a1, 0
li v1, 0x70000
bne a1, v1, 1b
nop
- /* turn off gpio11-15 */
- li a1, ATH_GPIO_OUT
+ // Turn off GPIOs 11~15
+ li a1, AR934X_GPIO_OUT
lw v1, 0(a1)
- li v0, ((1 << 15) | (1 << 14) | (1 << 13) | (1 << 12) | (1 << 11))
+ li v0, ~(0xFFFF07FF)
+ or v1, v1, v0
+ sw v1, 0(a1)
+
+#elif defined(CONFIG_FOR_TPLINK_WR841N_V8)
+ /*
+ * LED's/Reset GPIOs on WR841N/D v8:
+ *
+ * 12 => LAN4
+ * 13 => WLAN
+ * 14 => SYS
+ * 15 => QSS
+ * 18 => WAN
+ * 19 => LAN1
+ * 20 => LAN2
+ * 21 => LAN3
+ *
+ * 17 => Reset button (already set as input)
+ *
+ * All used GPIOs are active LOW!
+ */
+
+ // GPIOs init
+ li a1, AR934X_GPIO_OE
+ lw v1, 0(a1)
+ li v0, 0xFFC30FFF
+ and v1, v1, v0
+ sw v1, 0(a1)
+
+ // Set gpio function for GPIO 11
+ li a1, AR934X_GPIO_OUT_FUNCTION2
+ lw v1, 0(a1)
+ li v0, 0x00ffffff
+ and v1, v1, v0
+ sw v1, 0(a1)
+
+ // Set gpio function for GPIOs 12~15
+ li a1, AR934X_GPIO_OUT_FUNCTION3
+ lw v1, 0(a1)
+ li v0, 0x0
+ and v1, v1, v0
+ sw v1, 0(a1)
+
+ // Turn off GPIOs
+ li a1, AR934X_GPIO_OUT
+ lw v1, 0(a1)
+ li v0, ~(0xFFC30FFF)
or v1, v1, v0
- /* set v1 value to ATH_GPIO_OUT */
sw v1, 0(a1)
#endif
-#endif
+
+#endif /* #if defined(CONFIG_WASP_SUPPORT) */
/*
* Clearing CP0 registers - This is generally required for the MIPS-24k
\r
#define XTAL_ADDRESS 0x18116290\r
\r
-#define GPIO_OE_ADDRESS 0x18040000\r
-\r
-\r
#define PCIE_PHY_REG_1_SERDES_DIS_RXIMP_MSB 31\r
#define PCIE_PHY_REG_1_SERDES_DIS_RXIMP_LSB 31\r
#define PCIE_PHY_REG_1_SERDES_DIS_RXIMP_MASK 0x80000000\r
#define PCIE_PHY_REG_1_S_RESET 0xe // 14\r
#define PCIE_PHY_REG_1_ADDRESS 0x18116cc0\r
\r
+#define AR934X_GPIO_BASE 0x18040000\r
+#define AR934X_GPIO_OE AR934X_GPIO_BASE + 0x0\r
+#define AR934X_GPIO_IN AR934X_GPIO_BASE + 0x4\r
+#define AR934X_GPIO_OUT AR934X_GPIO_BASE + 0x8\r
+#define AR934X_GPIO_SET AR934X_GPIO_BASE + 0xC\r
+#define AR934X_GPIO_CLEAR AR934X_GPIO_BASE + 0x10\r
+#define AR934X_GPIO_INT AR934X_GPIO_BASE + 0x14\r
+#define AR934X_GPIO_INT_TYPE AR934X_GPIO_BASE + 0x18\r
+#define AR934X_GPIO_INT_POLARITY AR934X_GPIO_BASE + 0x1C\r
+#define AR934X_GPIO_INT_PENDING AR934X_GPIO_BASE + 0x20\r
+#define AR934X_GPIO_INT_MASK AR934X_GPIO_BASE + 0x24\r
+#define AR934X_GPIO_IN_ETH_SWITCH_LED AR934X_GPIO_BASE + 0x28\r
+#define AR934X_GPIO_OUT_FUNCTION0 AR934X_GPIO_BASE + 0x2C\r
+#define AR934X_GPIO_OUT_FUNCTION1 AR934X_GPIO_BASE + 0x30\r
+#define AR934X_GPIO_OUT_FUNCTION2 AR934X_GPIO_BASE + 0x34\r
+#define AR934X_GPIO_OUT_FUNCTION3 AR934X_GPIO_BASE + 0x38\r
+#define AR934X_GPIO_OUT_FUNCTION4 AR934X_GPIO_BASE + 0x3C\r
+#define AR934X_GPIO_IN_ENABLE0 AR934X_GPIO_BASE + 0x44\r
+#define AR934X_GPIO_IN_ENABLE1 AR934X_GPIO_BASE + 0x48\r
+#define AR934X_GPIO_IN_ENABLE2 AR934X_GPIO_BASE + 0x4C\r
+#define AR934X_GPIO_IN_ENABLE3 AR934X_GPIO_BASE + 0x50\r
+#define AR934X_GPIO_IN_ENABLE4 AR934X_GPIO_BASE + 0x54\r
+#define AR934X_GPIO_IN_ENABLE9 AR934X_GPIO_BASE + 0x68\r
+#define AR934X_GPIO_FUNCTION AR934X_GPIO_BASE + 0x6C\r
\r
#define GPIO_OUT_FUNCTION1_ENABLE_GPIO_7_MSB 31\r
#define GPIO_OUT_FUNCTION1_ENABLE_GPIO_7_LSB 24\r