projects
/
open-ath9k-htc-firmware.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request #139 from olerem/gcc-7
[open-ath9k-htc-firmware.git]
/
target_firmware
/
magpie_fw_dev
/
target
/
init
/
init.c
diff --git
a/target_firmware/magpie_fw_dev/target/init/init.c
b/target_firmware/magpie_fw_dev/target/init/init.c
index b6e6a4456c8b860dee9575e945f74938f34994a8..7484c0522bdc0b01d62ee1a690f7945dc54454d5 100755
(executable)
--- a/
target_firmware/magpie_fw_dev/target/init/init.c
+++ b/
target_firmware/magpie_fw_dev/target/init/init.c
@@
-34,11
+34,16
@@
*/
#if defined(_RAM_)
*/
#if defined(_RAM_)
+#include <wlan_pci.h>
+#include <rom.h>
+
#include "athos_api.h"
#include "athos_api.h"
-
+#include "usb_defs.h"
+
+#include "adf_os_io.h"
+
#if defined(PROJECT_MAGPIE)
#include "regdump.h"
#if defined(PROJECT_MAGPIE)
#include "regdump.h"
-#include "usb_defs.h"
extern uint32_t *init_htc_handle;
uint8_t htc_complete_setup = 0;
void reset_EP4_FIFO(void);
extern uint32_t *init_htc_handle;
uint8_t htc_complete_setup = 0;
void reset_EP4_FIFO(void);
@@
-63,8
+68,6
@@
uint32_t idle_cnt = 0;
int (* save_cmnos_printf)(const char * fmt, ...);
#endif
int (* save_cmnos_printf)(const char * fmt, ...);
#endif
-#define ATH_DATE_STRING __DATE__" "__TIME__
-
static void idle_task();
#if defined(PROJECT_MAGPIE)
static void idle_task();
#if defined(PROJECT_MAGPIE)
@@
-86,40
+89,34
@@
void fatal_exception_func()
void
change_magpie_clk(void)
{
void
change_magpie_clk(void)
{
-
volatile uint32_t rd_data
;
+
iowrite32(0x00056004, BIT4 | BIT0)
;
- HAL_WORD_REG_WRITE(0x00056004, 0x11);
- rd_data = HAL_WORD_REG_READ(0x00056004) & 0x1;
-
- /* Wait for the update bit to get cleared */
- while (rd_data)
- rd_data = HAL_WORD_REG_READ(0x00056004) & 0x1;
+ /* Wait for the update bit (BIT0) to get cleared */
+ while (ioread32(0x00056004) & BIT0)
+ ;
/* Put the PLL into reset */
/* Put the PLL into reset */
- rd_data = HAL_WORD_REG_READ(0x00050010) | (1<<1);
- HAL_WORD_REG_WRITE(0x00050010,rd_data);
+ io32_set(0x00050010, BIT1);
/*
* XXX: statically set the CPU clock to 200Mhz
*/
/*
* XXX: statically set the CPU clock to 200Mhz
*/
- /* Setting
of the PLL
*/
- HAL_WORD_REG_WRITE(0x00056000, 0x325);//400 MHz
+ /* Setting
PLL to 400MHz
*/
+ iowrite32(0x00056000, 0x325);
/* Pull CPU PLL out of Reset */
/* Pull CPU PLL out of Reset */
- rd_data = HAL_WORD_REG_READ(0x00050010) & ~(1<<1);
- HAL_WORD_REG_WRITE(0x00050010,rd_data);
+ io32_clr(0x00050010, BIT1);
A_DELAY_USECS(60); // wait for stable
A_DELAY_USECS(60); // wait for stable
- /* CPU & AHB settings */
+ /* CPU & AHB settings */
/*
* AHB clk = ( CPU clk / 2 )
*/
/*
* AHB clk = ( CPU clk / 2 )
*/
- HAL_WORD_REG_WRITE(0x00056004, ((0x00001 | (1 << 16)|(1 << 8)))); // set plldiv to 2
- rd_data = HAL_WORD_REG_READ(0x00056004) & 0x1;
+ iowrite32(0x00056004, 0x00001 | BIT16 | BIT8); /* set plldiv to 2 */
- while (
rd_data
)
-
rd_data = HAL_WORD_REG_READ(0x00056004) & 0x1
;
+ while (
ioread32(0x00056004) & BIT0
)
+ ;
/* UART Setting */
A_UART_HWINIT((100*1000*1000), 115200);
/* UART Setting */
A_UART_HWINIT((100*1000*1000), 115200);
@@
-137,25
+134,23
@@
void exception_reset(struct register_dump_s *dump)
/* phase II reset */
A_PRINTF("exception reset-phase 2\n");
/* phase II reset */
A_PRINTF("exception reset-phase 2\n");
-
*((volatile uint32_t*)WATCH_DOG_MAGIC_PATTERN_ADDR) = WDT_MAGIC_PATTERN
;
+
iowrite32(WATCH_DOG_MAGIC_PATTERN_ADDR, WDT_MAGIC_PATTERN)
;
- HAL_WORD_REG_WRITE(MAGPIE_REG_RST_RESET_ADDR,
- HAL_WORD_REG_READ(MAGPIE_REG_RST_RESET_ADDR)|(BIT10|BIT8|BIT7|BIT6));
+ io32_set(MAGPIE_REG_RST_RESET_ADDR, BIT10 | BIT8 | BIT7 | BIT6);
- HAL_WORD_REG_WRITE(MAGPIE_REG_AHB_ARB_ADDR,
- (HAL_WORD_REG_READ(MAGPIE_REG_AHB_ARB_ADDR)|BIT1));
+ io32_set(MAGPIE_REG_AHB_ARB_ADDR, BIT1);
-
HAL_WORD_REG_WRITE((USB_CTRL_BASE_ADDRESS+0x118)
, 0x0);
-
HAL_WORD_REG_WRITE(0x50010, HAL_WORD_REG_READ(0x50010)|
BIT4);
+
iowrite32_usb(ZM_SOC_USB_DMA_RESET_OFFSET
, 0x0);
+
io32_set(0x50010,
BIT4);
A_DELAY_USECS(5);
A_DELAY_USECS(5);
-
HAL_WORD_REG_WRITE(0x50010, HAL_WORD_REG_READ(0x50010)&~
BIT4);
+
io32_clr(0x50010,
BIT4);
A_DELAY_USECS(5);
A_DELAY_USECS(5);
-
HAL_WORD_REG_WRITE((USB_CTRL_BASE_ADDRESS+0x118), 0x1
);
+
iowrite32_usb(ZM_SOC_USB_DMA_RESET_OFFSET, BIT0
);
// set clock to bypass mode - 40Mhz from XTAL
// set clock to bypass mode - 40Mhz from XTAL
-
HAL_WORD_REG_WRITE(MAGPIE_REG_CPU_PLL_BYPASS_ADDR, (BIT0|BIT4)
);
+
iowrite32(MAGPIE_REG_CPU_PLL_BYPASS_ADDR, BIT0 | BIT4
);
A_DELAY_USECS(100); // wait for stable
A_DELAY_USECS(100); // wait for stable
-
HAL_WORD_REG_WRITE(MAGPIE_REG_CPU_PLL_ADDR, (BIT16)
);
+
iowrite32(MAGPIE_REG_CPU_PLL_ADDR, BIT16
);
A_UART_HWINIT((40*1000*1000), 115200);
A_UART_HWINIT((40*1000*1000), 115200);
@@
-166,9
+161,12
@@
void exception_reset(struct register_dump_s *dump)
MAGPIE_REG_USB_RX1_SWAP_DATA = 0x1;
MAGPIE_REG_USB_RX2_SWAP_DATA = 0x1;
MAGPIE_REG_USB_RX1_SWAP_DATA = 0x1;
MAGPIE_REG_USB_RX2_SWAP_DATA = 0x1;
- A_PRINTF("Jump to BOOT\n");
-
- // reboot.....
+ A_PRINTF("Cold reboot initiated.");
+#if defined(PROJECT_MAGPIE)
+ iowrite32(WATCH_DOG_MAGIC_PATTERN_ADDR, 0);
+#elif defined(PROJECT_K2)
+ iowrite32(MAGPIE_REG_RST_STATUS_ADDR, 0);
+#endif /* #if defined(PROJECT_MAGPIE) */
A_USB_JUMP_BOOT();
}
A_USB_JUMP_BOOT();
}
@@
-176,10
+174,10
@@
void reset_EP4_FIFO(void)
{
int i;
{
int i;
- /
/ reset EP4 FIFO
-
USB_BYTE_REG_WRITE(ZM_EP4_BYTE_COUNT_HIGH_OFFSET, (USB_BYTE_REG_READ(ZM_EP4_BYTE_COUNT_HIGH_OFFSET) | BIT4)
);
+ /
* reset EP4 FIFO */
+
io8_set_usb(ZM_EP4_BYTE_COUNT_HIGH_OFFSET, BIT4
);
for(i = 0; i < 100; i++) {}
for(i = 0; i < 100; i++) {}
- USB_BYTE_REG_WRITE(ZM_EP4_BYTE_COUNT_HIGH_OFFSET, (USB_BYTE_REG_READ(ZM_EP4_BYTE_COUNT_HIGH_OFFSET) & ~BIT4));
+ io8_clr_usb(ZM_EP4_BYTE_COUNT_HIGH_OFFSET, BIT4);
}
LOCAL void zfGenExceptionEvent(uint32_t exccause, uint32_t pc, uint32_t badvaddr)
}
LOCAL void zfGenExceptionEvent(uint32_t exccause, uint32_t pc, uint32_t badvaddr)
@@
-189,13
+187,13
@@
LOCAL void zfGenExceptionEvent(uint32_t exccause, uint32_t pc, uint32_t badvaddr
A_PRINTF("<Exception>Tgt Drv send an event 44332211 to Host Drv\n");
mUSB_STATUS_IN_INT_DISABLE();
A_PRINTF("<Exception>Tgt Drv send an event 44332211 to Host Drv\n");
mUSB_STATUS_IN_INT_DISABLE();
- USB_WORD_REG_WRITE(ZM_CBUS_FIFO_SIZE_OFFSET, 0x0f);
+ iowrite32_usb(ZM_CBUS_FIFO_SIZE_OFFSET, 0x0f);
+
+ iowrite32_usb(ZM_EP3_DATA_OFFSET, pattern);
+ iowrite32_usb(ZM_EP3_DATA_OFFSET, exccause);
+ iowrite32_usb(ZM_EP3_DATA_OFFSET, pc);
+ iowrite32_usb(ZM_EP3_DATA_OFFSET, badvaddr);
- USB_WORD_REG_WRITE(ZM_EP3_DATA_OFFSET, pattern);
- USB_WORD_REG_WRITE(ZM_EP3_DATA_OFFSET, exccause);
- USB_WORD_REG_WRITE(ZM_EP3_DATA_OFFSET, pc);
- USB_WORD_REG_WRITE(ZM_EP3_DATA_OFFSET, badvaddr);
-
mUSB_EP3_XFER_DONE();
}
mUSB_EP3_XFER_DONE();
}
@@
-206,10
+204,10
@@
LOCAL void zfGenWrongEpidEvent(uint32_t epid)
A_PRINTF("<WrongEPID>Tgt Drv send an event 44332212 to Host Drv\n");
mUSB_STATUS_IN_INT_DISABLE();
A_PRINTF("<WrongEPID>Tgt Drv send an event 44332212 to Host Drv\n");
mUSB_STATUS_IN_INT_DISABLE();
-
USB_WORD_REG_WRITE
(ZM_CBUS_FIFO_SIZE_OFFSET, 0x0f);
+
iowrite32_usb
(ZM_CBUS_FIFO_SIZE_OFFSET, 0x0f);
-
USB_WORD_REG_WRITE
(ZM_EP3_DATA_OFFSET, pattern);
-
USB_WORD_REG_WRITE
(ZM_EP3_DATA_OFFSET, epid);
+
iowrite32_usb
(ZM_EP3_DATA_OFFSET, pattern);
+
iowrite32_usb
(ZM_EP3_DATA_OFFSET, epid);
mUSB_EP3_XFER_DONE();
}
mUSB_EP3_XFER_DONE();
}
@@
-239,14
+237,14
@@
AR6002_fatal_exception_handler_patch(CPU_exception_frame_t *exc_frame)
#endif
A_ASSFAIL(&dump);
#endif
A_ASSFAIL(&dump);
-#if defined(_ROM_)
+#if defined(_ROM_)
A_WDT_ENABLE();
#endif
while(1) ;
}
A_WDT_ENABLE();
#endif
while(1) ;
}
-void
+void
HTCControlSvcProcessMsg_patch(HTC_ENDPOINT_ID EndpointID, adf_nbuf_t hdr_buf,
adf_nbuf_t pBuffers, void *arg)
{
HTCControlSvcProcessMsg_patch(HTC_ENDPOINT_ID EndpointID, adf_nbuf_t hdr_buf,
adf_nbuf_t pBuffers, void *arg)
{
@@
-267,7
+265,7
@@
HTCControlSvcProcessMsg_patch(HTC_ENDPOINT_ID EndpointID, adf_nbuf_t hdr_buf,
}
/* Patch callback for check the endpoint ID is correct or not */
}
/* Patch callback for check the endpoint ID is correct or not */
-void
+void
HTCMsgRecvHandler_patch(adf_nbuf_t hdr_buf, adf_nbuf_t buffer, void *context)
{
int eid;
HTCMsgRecvHandler_patch(adf_nbuf_t hdr_buf, adf_nbuf_t buffer, void *context)
{
int eid;
@@
-275,27
+273,27
@@
HTCMsgRecvHandler_patch(adf_nbuf_t hdr_buf, adf_nbuf_t buffer, void *context)
a_uint32_t anblen;
adf_nbuf_t tmp_nbuf;
HTC_FRAME_HDR *pHTCHdr;
a_uint32_t anblen;
adf_nbuf_t tmp_nbuf;
HTC_FRAME_HDR *pHTCHdr;
-
+
if (hdr_buf == ADF_NBUF_NULL) {
/* HTC hdr is not in the hdr_buf */
tmp_nbuf = buffer;
} else {
tmp_nbuf = hdr_buf;
}
if (hdr_buf == ADF_NBUF_NULL) {
/* HTC hdr is not in the hdr_buf */
tmp_nbuf = buffer;
} else {
tmp_nbuf = hdr_buf;
}
-
- adf_nbuf_peek_header(tmp_nbuf, &anbdata, &anblen);
- pHTCHdr = (HTC_FRAME_HDR *)anbdata;
-
+
+ adf_nbuf_peek_header(tmp_nbuf, &anbdata, &anblen);
+ pHTCHdr = (HTC_FRAME_HDR *)anbdata;
+
eid = pHTCHdr->EndpointID;
eid = pHTCHdr->EndpointID;
-
+
if ((eid != 0) && (htc_complete_setup == 0)) {
A_PRINTF("\nHTC Hdr EndpointID = %d, anblen = %d\n", pHTCHdr->EndpointID, anblen);
A_PRINTF("HTC Hder : %2x-%2x-%2x-%2x-%2x-%2x-%2x-%2x-%2x-%2x-%2x-%2x\n",
if ((eid != 0) && (htc_complete_setup == 0)) {
A_PRINTF("\nHTC Hdr EndpointID = %d, anblen = %d\n", pHTCHdr->EndpointID, anblen);
A_PRINTF("HTC Hder : %2x-%2x-%2x-%2x-%2x-%2x-%2x-%2x-%2x-%2x-%2x-%2x\n",
- *anbdata, *(anbdata+1), *(anbdata+2), *(anbdata+3),
+ *anbdata, *(anbdata+1), *(anbdata+2), *(anbdata+3),
*(anbdata+4), *(anbdata+5), *(anbdata+6), *(anbdata+7),
*(anbdata+4), *(anbdata+5), *(anbdata+6), *(anbdata+7),
- *(anbdata+8), *(anbdata+9), *(anbdata+10), *(anbdata+11));
+ *(anbdata+8), *(anbdata+9), *(anbdata+10), *(anbdata+11));
A_PRINTF("init_htc_handle = 0x%8x\n", init_htc_handle);
A_PRINTF("init_htc_handle = 0x%8x\n", init_htc_handle);
-
+
if (pHTCHdr->EndpointID == 1) {
A_PRINTF("Return WMI Command buffer\n");
HTC_ReturnBuffers(init_htc_handle, 1, tmp_nbuf);
if (pHTCHdr->EndpointID == 1) {
A_PRINTF("Return WMI Command buffer\n");
HTC_ReturnBuffers(init_htc_handle, 1, tmp_nbuf);
@@
-307,8
+305,8
@@
HTCMsgRecvHandler_patch(adf_nbuf_t hdr_buf, adf_nbuf_t buffer, void *context)
} else {
if ((pHTCHdr->EndpointID < 0) || (pHTCHdr->EndpointID >= ENDPOINT_MAX)) {
A_PRINTF("HTC Hdr EndpointID = %d, anblen = %d\n", pHTCHdr->EndpointID, anblen);
} else {
if ((pHTCHdr->EndpointID < 0) || (pHTCHdr->EndpointID >= ENDPOINT_MAX)) {
A_PRINTF("HTC Hdr EndpointID = %d, anblen = %d\n", pHTCHdr->EndpointID, anblen);
- A_PRINTF("HTC Hder : %2x-%2x-%2x-%2x-%2x-%2x-%2x-%2x\n",
- *anbdata, *(anbdata+1), *(anbdata+2), *(anbdata+3),
+ A_PRINTF("HTC Hder : %2x-%2x-%2x-%2x-%2x-%2x-%2x-%2x\n",
+ *anbdata, *(anbdata+1), *(anbdata+2), *(anbdata+3),
*(anbdata+4), *(anbdata+5), *(anbdata+6), *(anbdata+7));
if (anblen > 64) {
*(anbdata+4), *(anbdata+5), *(anbdata+6), *(anbdata+7));
if (anblen > 64) {
@@
-352,18
+350,11
@@
static void idle_task()
return;
}
return;
}
-void wlan_task(void)
+void
__noreturn
wlan_task(void)
{
loop_low=loop_high=0;
while(1) {
{
loop_low=loop_high=0;
while(1) {
-#if defined(PROJECT_MAGPIE)
- if (bJumptoFlash){
- bJumptoFlash = FALSE;
- break;
- }
-#endif
-
/* update wdt timer */
A_WDT_TASK();
/* update wdt timer */
A_WDT_TASK();