li reg_ref_clk_val, 40
/*
- * Several WLAN module resets as in broken Atheros SDK code
- * TODO: do we really need this?
+ * Several WLAN module resets as in Atheros (Q)SDK
*/
wlan_rst_init:
- li reg_loop_counter, 10
+ li t8, QCA_RST_RST_REG
+
+ /* 2x WLAN resets */
+ lw t9, 0(t8)
+ or t9, t9, QCA_RST_RESET_WLAN_RST_MASK
+ sw t9, 0(t8)
+ nop
+ nop
+ lw t9, 0(t8)
+ and t9, t9, ~QCA_RST_RESET_WLAN_RST_MASK
+ sw t9, 0(t8)
+ nop
+ nop
+
+ lw t9, 0(t8)
+ or t9, t9, QCA_RST_RESET_WLAN_RST_MASK
+ sw t9, 0(t8)
+ nop
+ nop
+ lw t9, 0(t8)
+ and t9, t9, ~QCA_RST_RESET_WLAN_RST_MASK
+ sw t9, 0(t8)
+ nop
+ nop
wlan_rst:
li t8, QCA_RST_RST_REG
+
lw t9, 0(t8)
or t9, t9, QCA_RST_RESET_WLAN_RST_MASK
sw t9, 0(t8)
nop
nop
-
lw t9, 0(t8)
and t9, t9, ~QCA_RST_RESET_WLAN_RST_MASK
sw t9, 0(t8)
nop
nop
+ li reg_loop_counter, 30
+
+eep_busy:
+ beq zero, reg_loop_counter, wlan_rst
+ nop
addi reg_loop_counter, reg_loop_counter, -1
- bnez reg_loop_counter, wlan_rst
+ li t8, QCA_RST_BOOTSTRAP_REG
+ lw t9, 0(t8)
+ and t9, t9, QCA_RST_BOOTSTRAP_EEPBUSY_MASK
+ bnez t9, eep_busy
nop
/*
/*
* Load target value into CPU_CLOCK_CONTROL register, but for now keep bypass
* enabled (by default, after reset, it should be bypassed, do it just in case)
- * and AHB_POST_DIV equal to 4
*/
cpu_clock_control:
li t8, QCA_PLL_CPU_CLK_CTRL_REG
move t9, reg_cpu_clk_ctrl
or t9, t9, QCA_PLL_CPU_CLK_CTRL_BYPASS_MASK
- and t9, t9, ~QCA_PLL_CPU_CLK_CTRL_AHB_POST_DIV_MASK
- or t9, t9, (3 << QCA_PLL_CPU_CLK_CTRL_AHB_POST_DIV_SHIFT)
sw t9, 0(t8)
/*
/* Disable bypassing all clocks, use target AHB_POST_DIV value */
pll_bypass_disable:
- li t8, QCA_PLL_CPU_CLK_CTRL_REG
- move t9, reg_cpu_clk_ctrl
- and t9, t9, ~QCA_PLL_CPU_CLK_CTRL_BYPASS_MASK
- sw t9, 0(t8)
+ li t8, QCA_PLL_CPU_CLK_CTRL_REG
+ lw t9, 0(t8)
+ and t9, t9, ~QCA_PLL_CPU_CLK_CTRL_BYPASS_MASK
+ sw t9, 0(t8)
/* Setup SPI (clock and other settings) */
spi_setup:
#endif
#endif
+ /*
+ * Workaround for hang issue,
+ * from original Atheros (Q)SDK:
+ *
+ * "Hornet 1.1 currently need a reset
+ * once we boot to let the resetb has
+ * enough time to stable, so that
+ * trigger reset at 1st boot".
+ *
+ * Read one 4 byte value from SRAM base address and compare it with
+ * known magic number (0x12345678 here), if it's the same, it means
+ * that this is not first boot and we can continue. Otherwise, make
+ * full chip reset (it's not power reset, SRAM data will survive).
+ *
+ * We need it here as it's first custom asm code executed in start{_bootstrap).S
+ *
+ * TODO: FIXME!
+ */
+first_boot:
+ li t8, 0xBD000000
+ lw t9, 0(t8)
+ li t7, 0x12345678
+ sw t7, 0(t8)
+ bne t9, t7, full_reset
+ nop
+
+ b gpio_setup
+ nop
+
+full_reset:
+ li t8, QCA_RST_RST_REG
+ lw t9, 0(t8)
+ or t9, t9, QCA_RST_RESET_FULL_CHIP_RST_MASK
+ sw t9, 0(t8)
+ nop
+
/*
* GPIO configuration, using GPIO_FUNCTION_1 register:
* 1. Disable JTAG by default
* 3. Disable HSUART RTS/CTS on GPIO11/12 if needed
* 4. Disable selected Ethernet switch LEDs if needed
*/
+gpio_setup:
li t8, QCA_GPIO_FUNC_1_REG
lw t9, 0(t8)
#if defined(CONFIG_SKIP_LOWLEVEL_INIT) || \
#define QCA_RST_BOOTSTRAP_REF_CLK_40M_VAL 0x1
#if (SOC_TYPE & QCA_AR933X_SOC)
+ #define QCA_RST_BOOTSTRAP_USB_MODE_DEV_SHIFT 3
+ #define QCA_RST_BOOTSTRAP_USB_MODE_DEV_MASK (1 << QCA_RST_BOOTSTRAP_USB_MODE_DEV_SHIFT)
+ #define QCA_RST_BOOTSTRAP_EEPBUSY_SHIFT 4
+ #define QCA_RST_BOOTSTRAP_EEPBUSY_MASK (1 << QCA_RST_BOOTSTRAP_EEPBUSY_SHIFT)
#define QCA_RST_BOOTSTRAP_MEM_TYPE_SHIFT 12
#define QCA_RST_BOOTSTRAP_MEM_TYPE_MASK BITS(QCA_RST_BOOTSTRAP_MEM_TYPE_SHIFT, 2)
- #define QCA_RST_BOOTSTRAP_MEM_TYPE_SDR_VAL 0
- #define QCA_RST_BOOTSTRAP_MEM_TYPE_DDR1_VAL 1
- #define QCA_RST_BOOTSTRAP_MEM_TYPE_DDR2_VAL 2
#define QCA_RST_BOOTSTRAP_JTAG_APB_SEL_SHIFT 16
#define QCA_RST_BOOTSTRAP_JTAG_APB_SEL_MASK (1 << QCA_RST_BOOTSTRAP_JTAG_APB_SEL_SHIFT)
#define QCA_RST_BOOTSTRAP_MDIO_SLAVE_EN_SHIFT 17
#define QCA_RST_BOOTSTRAP_MDIO_SLAVE_EN_MASK (1 << QCA_RST_BOOTSTRAP_MDIO_SLAVE_EN_SHIFT)
#define QCA_RST_BOOTSTRAP_MDIO_GPIO_EN_SHIFT 18
#define QCA_RST_BOOTSTRAP_MDIO_GPIO_EN_MASK (1 << QCA_RST_BOOTSTRAP_MDIO_GPIO_EN_SHIFT)
+
+ #define QCA_RST_BOOTSTRAP_MEM_TYPE_SDR_VAL 0
+ #define QCA_RST_BOOTSTRAP_MEM_TYPE_DDR1_VAL 1
+ #define QCA_RST_BOOTSTRAP_MEM_TYPE_DDR2_VAL 2
#else
#define QCA_RST_BOOTSTRAP_MEM_TYPE_SHIFT 0
#define QCA_RST_BOOTSTRAP_MEM_TYPE_MASK (1 << QCA_RST_BOOTSTRAP_MEM_TYPE_SHIFT)
#endif
- #define QCA_RST_BOOTSTRAP_MEM_TYPE_SDR_VAL 3
- #define QCA_RST_BOOTSTRAP_MEM_TYPE_DDR1_VAL 1
- #define QCA_RST_BOOTSTRAP_MEM_TYPE_DDR2_VAL 0
-
#define QCA_RST_BOOTSTRAP_BOOT_SEL_SHIFT 2
#define QCA_RST_BOOTSTRAP_BOOT_SEL_MASK (1 << QCA_RST_BOOTSTRAP_BOOT_SEL_SHIFT)
#define QCA_RST_BOOTSTRAP_DDR_WIDTH_32_SHIFT 3
#define QCA_RST_BOOTSTRAP_DDR_WIDTH_32_MASK (1 << QCA_RST_BOOTSTRAP_DDR_WIDTH_32_SHIFT)
#define QCA_RST_BOOTSTRAP_JTAG_MODE_SHIFT 5
#define QCA_RST_BOOTSTRAP_JTAG_MODE_MASK (1 << QCA_RST_BOOTSTRAP_JTAG_MODE_SHIFT)
+ #define QCA_RST_BOOTSTRAP_USB_MODE_DEV_SHIFT 7
+ #define QCA_RST_BOOTSTRAP_USB_MODE_DEV_MASK (1 << QCA_RST_BOOTSTRAP_USB_MODE_DEV_SHIFT)
+
+ #define QCA_RST_BOOTSTRAP_MEM_TYPE_SDR_VAL 3
+ #define QCA_RST_BOOTSTRAP_MEM_TYPE_DDR1_VAL 1
+ #define QCA_RST_BOOTSTRAP_MEM_TYPE_DDR2_VAL 0
#endif
/* RST_RESET */