From: Christian Lamparter Date: Fri, 13 Aug 2010 20:02:00 +0000 (+0200) Subject: carl9170 firmware: Initialize USB subsystem before the DMA engine X-Git-Tag: 1.8.5~7 X-Git-Url: https://jxself.org/git/?p=carl9170fw.git;a=commitdiff_plain;h=0f370216f7d50a6c8ffebfb1ba49b196e869d0ec carl9170 firmware: Initialize USB subsystem before the DMA engine 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 --- diff --git a/carlfw/src/main.c b/carlfw/src/main.c index bdb68ba..35f5d29 100644 --- a/carlfw/src/main.c +++ b/carlfw/src/main.c @@ -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) { diff --git a/carlfw/usb/usb.c b/carlfw/usb/usb.c index 3a8f27e..48b3418 100644 --- a/carlfw/usb/usb.c +++ b/carlfw/usb/usb.c @@ -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 */