carl9170 firmware: Initialize USB subsystem before the DMA engine
authorChristian Lamparter <chunkeey@googlemail.com>
Fri, 13 Aug 2010 20:02:00 +0000 (22:02 +0200)
committerChristian Lamparter <chunkeey@googlemail.com>
Fri, 13 Aug 2010 20:02:00 +0000 (22:02 +0200)
The documentation states that the USB DMA engine control register
(0x1e1108) should be modified when the state engine is idling.
By tuning the initialization order and placing a larger workload
in between, the state machine should now always be in the correct
state.

Signed-off-by: Christian Lamparter <chunkeey@googlemail.com>
carlfw/src/main.c
carlfw/usb/usb.c

index bdb68babd58a79bbf583b3314573256cf6fe3a9f..35f5d29c88d770541440edbcf57623f4442fa1c3 100644 (file)
@@ -43,15 +43,14 @@ static void init(void)
        /* 25/50/100ms timer (depends on cpu clock) */
        timer_init(0, 50000);
 
-       /* turn off all leds */
-       led_set(0);
+       /* USB init */
+       usb_init();
+
+       memset(&dma_mem, 0, sizeof(dma_mem));
 
        /* fill DMA rings */
        dma_init_descriptors();
 
-       /* USB init */
-       usb_init();
-
        /* clear all interrupt */
        set(AR9170_MAC_REG_INT_CTRL, 0xffff);
 
@@ -115,7 +114,6 @@ void __attribute__((noreturn)) start(void)
 {
        /* initialize firmware context and DMA memory */
        memset(&fw, 0, sizeof(fw));
-       memset(&dma_mem, 0, sizeof(dma_mem));
 
        /* watchdog magic pattern check */
        if ((get(AR9170_PWR_REG_WATCH_DOG_MAGIC) & 0xffff0000) == 0x12340000) {
index 3a8f27e8ace66ebde1d9e479c8d0959e7703e6e9..48b34183caafe949bd9e0b47b5953cb936b39a4a 100644 (file)
@@ -231,10 +231,6 @@ static void usb_pta_init(void)
        orl(AR9170_USB_REG_DMA_CTL, AR9170_DMA_CTL_DOWN_STREAM);
 #endif /* CONFIG_CARL9170FW_USB_DOWN_STREAM */
 
-       /* Enable up stream and down stream */
-       orl(AR9170_USB_REG_DMA_CTL, AR9170_DMA_CTL_ENABLE_TO_DEVICE |
-           AR9170_DMA_CTL_ENABLE_FROM_DEVICE);
-
 #ifdef CONFIG_CARL9170FW_USB_UP_STREAM
        /* Set the up stream mode maximum aggregate number */
        set(AR9170_USB_REG_MAX_AGG_UPLOAD, 4);
@@ -246,6 +242,9 @@ static void usb_pta_init(void)
        set(AR9170_USB_REG_UPLOAD_TIME_CTL, 0x80);
 #endif /* CONFIG_CARL9170FW_USB_UP_STREAM */
 
+       /* Enable up stream and down stream */
+       orl(AR9170_USB_REG_DMA_CTL, AR9170_DMA_CTL_ENABLE_TO_DEVICE |
+           AR9170_DMA_CTL_ENABLE_FROM_DEVICE);
 }
 #endif /* CONFIG_CARL9170FW_USB_INIT_FIRMWARE */