carl9170 firmware: compact pta_init
authorChristian Lamparter <chunkeey@googlemail.com>
Sat, 14 Aug 2010 16:59:01 +0000 (18:59 +0200)
committerChristian Lamparter <chunkeey@googlemail.com>
Sat, 14 Aug 2010 16:59:01 +0000 (18:59 +0200)
A small gain can be obtained by caching the temporary
usb control flag modifications and commit the new
setting at the end.

Signed-off-by: Christian Lamparter <chunkeey@googlemail.com>
carlfw/include/usb.h
carlfw/usb/main.c
carlfw/usb/usb.c
include/shared/hw.h

index f4357603029f8b093286d7615efb58330b13eb63..1fb9e82a70ad6dc55110d9054d9db97ecfe1247d 100644 (file)
@@ -122,12 +122,12 @@ static inline __inline void usb_data_in0Byte(void)
 
 static inline __inline void usb_stop_down_queue(void)
 {
-       andl(AR9170_USB_REG_DMA_CTL, ~AR9170_DMA_CTL_ENABLE_TO_DEVICE);
+       andl(AR9170_USB_REG_DMA_CTL, ~AR9170_USB_DMA_CTL_ENABLE_TO_DEVICE);
 }
 
 static inline __inline void usb_start_down_queue(void)
 {
-       orl(AR9170_USB_REG_DMA_CTL, AR9170_DMA_CTL_ENABLE_TO_DEVICE);
+       orl(AR9170_USB_REG_DMA_CTL, AR9170_USB_DMA_CTL_ENABLE_TO_DEVICE);
 }
 
 static inline __inline void usb_clear_input_ep_toggle(unsigned int ep)
index a1cd2c9919b90fad5272e6c42c18d0c69902e91e..1a966256e2989decba5ff9be1b87fd609d71cdb5 100644 (file)
@@ -222,6 +222,8 @@ static void turn_power_off(void)
 
        set(AR9170_PWR_REG_BASE, 0x40021);
 
+       set(AR9170_MAC_REG_DMA_TRIGGER, 0);
+
        set(AR9170_MAC_REG_POWER_STATE_CTRL,
            AR9170_MAC_POWER_STATE_CTRL_RESET);
 
index 48b34183caafe949bd9e0b47b5953cb936b39a4a..12b487b278294b3e93e5901d6d2932c806ecdecd 100644 (file)
@@ -184,6 +184,7 @@ static void usb_reset_eps(void)
 #ifdef CONFIG_CARL9170FW_USB_INIT_FIRMWARE
 static void usb_pta_init(void)
 {
+       unsigned int usb_dma_ctrl = 0;
        /* Set PTA mode to USB */
        andl(AR9170_PTA_REG_DMA_MODE_CTRL,
                ~AR9170_PTA_DMA_MODE_CTRL_DISABLE_USB);
@@ -197,38 +198,32 @@ static void usb_pta_init(void)
                fw.usb.cfg_desc = &usb_config_highspeed;
 
                /* 512 Byte DMA transfers */
-               orl(AR9170_USB_REG_DMA_CTL, AR9170_DMA_CTL_HIGH_SPEED);
+               usb_dma_ctrl |= AR9170_USB_DMA_CTL_HIGH_SPEED;
        } else {
                fw.usb.cfg_desc = &usb_config_fullspeed;
                fw.usb.os_cfg_desc = &usb_config_highspeed;
        }
 
 #ifdef CONFIG_CARL9170FW_USB_UP_STREAM
-       /* Enable upload stream mode */
-       andl(AR9170_USB_REG_DMA_CTL, ~AR9170_DMA_CTL_UP_PACKET_MODE);
-
-       /* reset maximum transfer size */
-       andl(AR9170_USB_REG_DMA_CTL, ~(AR9170_DMA_CTL_UP_STREAM));
-
 # if (CONFIG_CARL9170FW_RX_FRAME_LEN == 4096)
-       orl(AR9170_USB_REG_DMA_CTL, AR9170_DMA_CTL_UP_STREAM_4K);
+       usb_dma_ctrl |= AR9170_USB_DMA_CTL_UP_STREAM_4K;
 # elif (CONFIG_CARL9170FW_RX_FRAME_LEN == 8192)
-       orl(AR9170_USB_REG_DMA_CTL, AR9170_DMA_CTL_UP_STREAM_8K);
+       usb_dma_ctrl |= AR9170_USB_DMA_CTL_UP_STREAM_8K;
 # elif (CONFIG_CARL9170FW_RX_FRAME_LEN == 16384)
-       orl(AR9170_USB_REG_DMA_CTL, AR9170_DMA_CTL_UP_STREAM_16K);
+       usb_dma_ctrl |= AR9170_USB_DMA_CTL_UP_STREAM_16K;
 # elif (CONFIG_CARL9170FW_RX_FRAME_LEN == 32768)
-       orl(AR9170_USB_REG_DMA_CTL, AR9170_DMA_CTL_UP_STREAM_32K);
+       usb_dma_ctrl |= AR9170_USB_DMA_CTL_UP_STREAM_32K;
 # else
 #      error "Invalid AR9170_RX_FRAME_LEN setting"
 # endif
 
 #else /* CONFIG_CARL9170FW_USB_UP_STREAM */
-       orl(AR9170_USB_REG_DMA_CTL, AR9170_DMA_CTL_UP_PACKET_MODE);
+       usb_dma_ctrl |= AR9170_USB_DMA_CTL_UP_PACKET_MODE;
 #endif /* CONFIG_CARL9170FW_USB_UP_STREAM */
 
 #ifdef CONFIG_CARL9170FW_USB_DOWN_STREAM
        /* Enable down stream mode */
-       orl(AR9170_USB_REG_DMA_CTL, AR9170_DMA_CTL_DOWN_STREAM);
+       usb_dma_ctrl |= AR9170_USB_DMA_CTL_DOWN_STREAM;
 #endif /* CONFIG_CARL9170FW_USB_DOWN_STREAM */
 
 #ifdef CONFIG_CARL9170FW_USB_UP_STREAM
@@ -243,8 +238,10 @@ static void usb_pta_init(void)
 #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);
+       usb_dma_ctrl |= AR9170_USB_DMA_CTL_ENABLE_TO_DEVICE |
+           AR9170_USB_DMA_CTL_ENABLE_FROM_DEVICE;
+
+       set(AR9170_USB_REG_DMA_CTL, usb_dma_ctrl);
 }
 #endif /* CONFIG_CARL9170FW_USB_INIT_FIRMWARE */
 
index 30b19a7ef312968fb95525dbd0938113d9a55b3a..14973128ea4d6fb26f945f1e0b8ed0324f68ef86 100644 (file)
 
 #define        AR9170_USB_REG_FIFO_SIZE                (AR9170_USB_REG_BASE + 0x100)
 #define        AR9170_USB_REG_DMA_CTL                  (AR9170_USB_REG_BASE + 0x108)
-#define                AR9170_DMA_CTL_ENABLE_TO_DEVICE         BIT(0)
-#define                AR9170_DMA_CTL_ENABLE_FROM_DEVICE       BIT(1)
-#define                AR9170_DMA_CTL_HIGH_SPEED               BIT(2)
-#define                AR9170_DMA_CTL_UP_PACKET_MODE           BIT(3)
-#define                AR9170_DMA_CTL_UP_STREAM_S              4
-#define                AR9170_DMA_CTL_UP_STREAM                (3 << 4)
-#define                AR9170_DMA_CTL_UP_STREAM_4K             (0 << 4)
-#define                AR9170_DMA_CTL_UP_STREAM_8K             (1 << 4)
-#define                AR9170_DMA_CTL_UP_STREAM_16K            (2 << 4)
-#define                AR9170_DMA_CTL_UP_STREAM_32K            (3 << 4)
-#define                AR9170_DMA_CTL_DOWN_STREAM              BIT(6)
+#define                AR9170_USB_DMA_CTL_ENABLE_TO_DEVICE     BIT(0)
+#define                AR9170_USB_DMA_CTL_ENABLE_FROM_DEVICE   BIT(1)
+#define                AR9170_USB_DMA_CTL_HIGH_SPEED           BIT(2)
+#define                AR9170_USB_DMA_CTL_UP_PACKET_MODE       BIT(3)
+#define                AR9170_USB_DMA_CTL_UP_STREAM_S          4
+#define                AR9170_USB_DMA_CTL_UP_STREAM            (BIT(4) | BIT(5))
+#define                AR9170_USB_DMA_CTL_UP_STREAM_4K         (0)
+#define                AR9170_USB_DMA_CTL_UP_STREAM_8K         BIT(4)
+#define                AR9170_USB_DMA_CTL_UP_STREAM_16K        BIT(5)
+#define                AR9170_USB_DMA_CTL_UP_STREAM_32K        (BIT(4) | BIT(5))
+#define                AR9170_USB_DMA_CTL_DOWN_STREAM          BIT(6)
+
+#define        AR9170_USB_REG_DMA_STATUS               (AR9170_USB_REG_BASE + 0x10c)
+#define                AR9170_USB_DMA_STATUS_UP_IDLE           BIT(8)
+#define                AR9170_USB_DMA_STATUS_DN_IDLE           BIT(16)
 
 #define        AR9170_USB_REG_MAX_AGG_UPLOAD           (AR9170_USB_REG_BASE + 0x110)
 #define        AR9170_USB_REG_UPLOAD_TIME_CTL          (AR9170_USB_REG_BASE + 0x114)