source: svn/newcon3bcm2_21bu/nexus/modules/dma/7552/src/nexus_dma_module.c

Last change on this file was 76, checked in by megakiss, 10 years ago

1W 대기전력을 만족시키기 위하여 POWEROFF시 튜너를 Standby 상태로 함

  • Property svn:executable set to *
File size: 8.8 KB
Line 
1/***************************************************************************
2 *     (c)2007-2011 Broadcom Corporation
3 *
4 *  This program is the proprietary software of Broadcom Corporation and/or its licensors,
5 *  and may only be used, duplicated, modified or distributed pursuant to the terms and
6 *  conditions of a separate, written license agreement executed between you and Broadcom
7 *  (an "Authorized License").  Except as set forth in an Authorized License, Broadcom grants
8 *  no license (express or implied), right to use, or waiver of any kind with respect to the
9 *  Software, and Broadcom expressly reserves all rights in and to the Software and all
10 *  intellectual property rights therein.  IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU
11 *  HAVE NO RIGHT TO USE THIS SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY
12 *  NOTIFY BROADCOM AND DISCONTINUE ALL USE OF THE SOFTWARE.
13 *
14 *  Except as expressly set forth in the Authorized License,
15 *
16 *  1.     This program, including its structure, sequence and organization, constitutes the valuable trade
17 *  secrets of Broadcom, and you shall use all reasonable efforts to protect the confidentiality thereof,
18 *  and to use this information only in connection with your use of Broadcom integrated circuit products.
19 *
20 *  2.     TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
21 *  AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES, REPRESENTATIONS OR
22 *  WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO
23 *  THE SOFTWARE.  BROADCOM SPECIFICALLY DISCLAIMS ANY AND ALL IMPLIED WARRANTIES
24 *  OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE,
25 *  LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION
26 *  OR CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING OUT OF
27 *  USE OR PERFORMANCE OF THE SOFTWARE.
28 *
29 *  3.     TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM OR ITS
30 *  LICENSORS BE LIABLE FOR (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR
31 *  EXEMPLARY DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO YOUR
32 *  USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM HAS BEEN ADVISED OF
33 *  THE POSSIBILITY OF SUCH DAMAGES; OR (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT
34 *  ACTUALLY PAID FOR THE SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE
35 *  LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF ESSENTIAL PURPOSE OF
36 *  ANY LIMITED REMEDY.
37 *
38 * $brcm_Workfile: nexus_dma_module.c $
39 * $brcm_Revision: 24 $
40 * $brcm_Date: 11/10/11 6:00p $
41 *
42 * Module Description:
43 *
44 * Revision History:
45 *
46 * $brcm_Log: /nexus/modules/dma/7425/src/nexus_dma_module.c $
47 *
48 * 24   11/10/11 6:00p jtna
49 * SW7425-1709: move NEXUS_DmaModule_Standby_priv prototype to separate,
50 *  private header file
51 *
52 * 23   11/9/11 10:56a jtna
53 * SW7425-1709: silence compiler warning for undef NEXUS_POWER_MANAGEMENT
54 *
55 * 22   11/8/11 6:00p jtna
56 * SW7425-1709: make use of BMMD_Standby/Resume
57 *
58 * 21   11/8/11 3:06p jtna
59 * SW7425-1079: move power management from nexus_dma to bmmd
60 *
61 * 20   10/3/11 11:10a erickson
62 * SW7420-1995: cannot unregister handles is module is being
63 *  uninitialized. requires special case.
64 *
65 * 19   8/24/11 3:51p jtna
66 * SW7346-337: fix coverity warning for platforms with
67 *  NEXUS_NUM_SHARF_DMA_CHANNELS==0
68 *
69 * 18   8/3/11 11:09a gmohile
70 * SW7125-1014 : Add module to active priority scheduler
71 *
72 * 17   7/21/11 2:40p jtna
73 * SW7346-337: fix benign coverity warning
74 *
75 * 16   5/12/11 2:53p jtna
76 * SW7550-739: merge SHARF support
77 *
78 * 15   4/22/11 6:50p jtna
79 * SW7420-420: merge BMMD-based Nexus DMA module
80 *
81 **************************************************************************/
82#include "nexus_dma_module.h"
83#include "nexus_dma_init.h"
84#include "priv/nexus_dma_standby_priv.h"
85
86#if BCHP_CHIP == 7408
87#include "bchp_hif_cpu_intr1.h"
88#endif
89
90BDBG_MODULE(nexus_dma);
91
92/* global module handle & data */
93NEXUS_DmaModuleData g_NEXUS_dmaModuleData;
94BDBG_OBJECT_ID(NEXUS_Dma);
95BDBG_OBJECT_ID(NEXUS_DmaJob);
96
97void NEXUS_DmaModule_GetDefaultSettings( NEXUS_DmaModuleSettings *pSettings )
98{
99    BKNI_Memset(pSettings, 0, sizeof(*pSettings));
100}
101
102NEXUS_ModuleHandle NEXUS_DmaModule_Init( const NEXUS_DmaModuleSettings *pSettings )
103{
104    NEXUS_ModuleSettings moduleSettings;
105    BMMD_Settings mmdSettings;
106    NEXUS_Error errCode;
107    unsigned i = 0;
108
109    BDBG_ASSERT(NULL==g_NEXUS_dmaModuleData.dmaModule && NULL==g_NEXUS_dmaModuleData.channel[0].mmd);
110
111#if NEXUS_HAS_SECURITY
112    if (!pSettings->modules.security) {
113        BDBG_ERR(("Dma module requires the Security module"));
114        return NULL;
115    }
116#else
117    BSTD_UNUSED(pSettings);
118#endif
119    /* init global module data */
120    BKNI_Memset(&g_NEXUS_dmaModuleData, 0, sizeof(g_NEXUS_dmaModuleData));
121
122    /* init global module handle */
123    NEXUS_Module_GetDefaultSettings(&moduleSettings);
124    moduleSettings.priority = NEXUS_ModulePriority_eHighActiveStandby; /* dma interface is fast */
125    g_NEXUS_dmaModuleData.dmaModule = NEXUS_Module_Create("dma", &moduleSettings);
126    if ( NULL == g_NEXUS_dmaModuleData.dmaModule ) {
127        errCode = BERR_TRACE(BERR_OS_ERROR);
128        return NULL;
129    }
130
131    BMMD_GetDefaultSettings(&mmdSettings);
132    mmdSettings.engineType = BMMD_EngineType_eDma;
133    for (i=0; (int)i<NEXUS_NUM_DMA_CHANNELS; i++) { /* the cast to int suppresses a benign compiler warning */
134        mmdSettings.engineType = BMMD_EngineType_eDma;
135        mmdSettings.engineIndex = i;
136        errCode = BMMD_Open(g_pCoreHandles->chp, g_pCoreHandles->reg, g_pCoreHandles->heap[0], g_pCoreHandles->bint, &mmdSettings, &g_NEXUS_dmaModuleData.channel[i].mmd);
137        if (errCode) {
138            errCode = BERR_TRACE(errCode);
139            goto error;
140        }
141    }
142#if NEXUS_NUM_SHARF_DMA_CHANNELS
143    for (; i<NEXUS_NUM_DMA_CHANNELS+NEXUS_NUM_SHARF_DMA_CHANNELS; i++) {
144        mmdSettings.engineType = BMMD_EngineType_eSharf;
145        mmdSettings.engineIndex = i-NEXUS_NUM_DMA_CHANNELS;
146        errCode = BMMD_Open(g_pCoreHandles->chp, g_pCoreHandles->reg, g_pCoreHandles->heap[0], g_pCoreHandles->bint, &mmdSettings, &g_NEXUS_dmaModuleData.channel[i].mmd);
147        if (errCode) {
148            errCode = BERR_TRACE(errCode);
149            goto error;
150        }
151    }
152#endif
153
154    return g_NEXUS_dmaModuleData.dmaModule;
155
156error:
157    NEXUS_DmaModule_Uninit();
158    return NULL;
159}
160
161/***************************************************************************
162Summary:
163Shutdown all open channels and handles at module close time
164***************************************************************************/
165static void NEXUS_Dma_P_Shutdown(void)
166{
167    int i;
168    NEXUS_DmaHandle dma;
169
170    for (i=0; i<NEXUS_NUM_DMA_CHANNELS+NEXUS_NUM_SHARF_DMA_CHANNELS; i++) {
171        while ( (dma = BLST_S_FIRST(&g_NEXUS_dmaModuleData.channel[i].dmaHandles)) ) {
172            BDBG_WRN(("Automatically closing DMA %p", dma));
173            NEXUS_Dma_Close(dma);
174        }
175    }
176    return ;
177}
178
179void NEXUS_DmaModule_Uninit(void)
180{
181    unsigned i;
182    BDBG_ASSERT(g_NEXUS_dmaModuleData.dmaModule);
183     
184    g_NEXUS_dmaModuleData.shutdown = true;
185    NEXUS_Dma_P_Shutdown();
186   
187    /* 7408 XPT hardware is broken. Need to disable MDMA L1 interrupt before XPT can be unintialised */
188#if BCHP_CHIP == 7408
189    NEXUS_Core_DisableInterrupt(BCHP_HIF_CPU_INTR1_INTR_W0_MASK_STATUS_XPT_MDMA_CPU_INTR_SHIFT);
190    NEXUS_Core_DisconnectInterrupt(BCHP_HIF_CPU_INTR1_INTR_W0_MASK_STATUS_XPT_MDMA_CPU_INTR_SHIFT);
191#endif
192
193    for (i=0; i<NEXUS_NUM_DMA_CHANNELS+NEXUS_NUM_SHARF_DMA_CHANNELS; i++) {
194        if (g_NEXUS_dmaModuleData.channel[i].mmd) {
195            BMMD_Close(g_NEXUS_dmaModuleData.channel[i].mmd);
196        }
197    }
198    NEXUS_Module_Destroy(g_NEXUS_dmaModuleData.dmaModule);
199    BKNI_Memset(&g_NEXUS_dmaModuleData, 0, sizeof(g_NEXUS_dmaModuleData));
200
201    return;
202}
203
204NEXUS_Error NEXUS_DmaModule_Standby_priv(bool enabled, const NEXUS_StandbySettings *pSettings)
205{
206#if NEXUS_POWER_MANAGEMENT
207    unsigned i;
208    BERR_Code rc;
209    BSTD_UNUSED(pSettings);
210
211    if (enabled) {
212        for (i=0; i<NEXUS_NUM_DMA_CHANNELS+NEXUS_NUM_SHARF_DMA_CHANNELS; i++) {
213            if (g_NEXUS_dmaModuleData.channel[i].mmd) {
214                rc = BMMD_Standby(g_NEXUS_dmaModuleData.channel[i].mmd, NULL);
215                if (rc!=BERR_SUCCESS) {
216                    goto error;
217                }
218            }
219        }
220    }
221    else {
222        for (i=0; i<NEXUS_NUM_DMA_CHANNELS+NEXUS_NUM_SHARF_DMA_CHANNELS; i++) {
223            if (g_NEXUS_dmaModuleData.channel[i].mmd) {
224                BMMD_Resume(g_NEXUS_dmaModuleData.channel[i].mmd);
225            }
226        }
227    }
228
229    return NEXUS_SUCCESS;
230   
231error:
232    /* resume all MMD modules */
233    for (i=0; i<NEXUS_NUM_DMA_CHANNELS+NEXUS_NUM_SHARF_DMA_CHANNELS; i++) {
234        if (g_NEXUS_dmaModuleData.channel[i].mmd) {
235            BMMD_Resume(g_NEXUS_dmaModuleData.channel[i].mmd);
236        }
237    }   
238    return NEXUS_NOT_SUPPORTED;
239#else
240    BSTD_UNUSED(pSettings);
241    BSTD_UNUSED(enabled);
242    return NEXUS_SUCCESS;
243#endif
244}
245
Note: See TracBrowser for help on using the repository browser.