source: svn/trunk/newcon3bcm2_21bu/dta/src/settop_api/bsettop.c @ 53

Last change on this file since 53 was 2, checked in by jglee, 11 years ago

first commit

  • Property svn:executable set to *
File size: 4.7 KB
Line 
1/***************************************************************************
2 *     Copyright (c) 2003-2006, Broadcom Corporation
3 *     All Rights Reserved
4 *     Confidential Property of Broadcom Corporation
5 *
6 *  THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE
7 *  AGREEMENT  BETWEEN THE USER AND BROADCOM.  YOU HAVE NO RIGHT TO USE OR
8 *  EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT.
9 *
10 * $brcm_Workfile:  $
11 * $brcm_Revision:  $
12 * $brcm_Date: $
13 *
14 * Module Description:
15 *
16 * Revision History:
17 *
18 * $brcm_Log:  $
19 *
20 ***************************************************************************/
21#include "bsettop.h"
22
23#include "bstd.h"
24#include "gist.h"
25#include "bchp_timer.h"
26#if (BCHP_CHIP!=7552)
27#include "bchp_clk.h"
28#endif
29#ifdef CONFIG_WATCHDOG
30#include "bchp_int_id_timer.h"
31#endif
32BDBG_MODULE(bsettop);
33
34bool initialized = false;
35
36/*
37Summary:
38        Watchdog ISR.
39Description:
40        Service the watchdog interrupt.
41*/
42#ifdef CONFIG_WATCHDOG 
43static BINT_CallbackHandle h_wd_callback;
44
45static void bsettop_wd_isr(void *data, int param)
46{
47        unsigned int reg = BREG_Read32(GetREG(), BCHP_TIMER_TIMER_IS);
48        if (reg & BCHP_TIMER_TIMER_IS_WDINT_MASK)
49        {
50                /* Re write start sequence */
51                BREG_Write32(GetREG(), BCHP_TIMER_WDCMD,0xFF00);
52                BREG_Write32(GetREG(), BCHP_TIMER_WDCMD,0x00FF);
53        }
54#if 0
55        else if (g_p_dsp->timer_isr)
56        {
57                g_p_dsp->timer_isr(data);
58        }
59#endif
60}
61#endif
62
63/*
64Summary:
65    To turn off power on unused modules to save powers.
66
67Description:
68*/
69bresult bsettop_pm_off(void)
70{
71#if (BCHP_CHIP!=7552)
72        uint32_t val;
73
74        BDBG_WRN(("%s: enter", __func__));
75        val = BREG_Read32(GetREG(), BCHP_CLK_PM_CTRL);
76        val |= BCHP_CLK_PM_CTRL_DIS_USB_216M_CLK_MASK;                  /* turn off USB */
77        //val |= BCHP_CLK_PM_CTRL_DIS_BVN_ENET_216M_CLK_MASK;           /* turn off ethernet */
78        val |= BCHP_CLK_PM_CTRL_DIS_DDR23_ALT_216M_CLK_MASK;    /* turn off ALT DDR23 */
79        val |= BCHP_CLK_PM_CTRL_DIS_MEMC_ALT_216M_CLK_MASK;             /* turn off ALT MEMC */
80        val |= BCHP_CLK_PM_CTRL_DIS_HDMI_ALT_216M_CLK_MASK;             /* turn off ALT HDMI */
81        BREG_Write32(GetREG(), BCHP_CLK_PM_CTRL, val);
82
83        val = BREG_Read32(GetREG(), BCHP_CLK_PM_CTRL_1);
84        val |= BCHP_CLK_PM_CTRL_1_DIS_MEMC_108M_CLK_MASK;
85        val |= BCHP_CLK_PM_CTRL_1_DIS_USB_108M_CLK_MASK;
86        val |= BCHP_CLK_PM_CTRL_1_DIS_DDR23_108M_CLK_MASK;
87        val |= BCHP_CLK_PM_CTRL_1_DIS_DDR23_ALT_108M_CLK_MASK;
88        val |= BCHP_CLK_PM_CTRL_1_DIS_HDMI_ALT_108M_CLK_MASK;
89        val |= BCHP_CLK_PM_CTRL_1_DIS_MEMC_ALT_108M_CLK_MASK;
90        //val |= BCHP_CLK_PM_CTRL_1_DIS_VEC_ALT_108M_CLK_MASK;
91        BREG_Write32(GetREG(), BCHP_CLK_PM_CTRL_1, val);
92
93        val = BREG_Read32(GetREG(), BCHP_CLK_PM_CTRL_2);
94        val |= BCHP_CLK_PM_CTRL_2_DIS_ENET_25M_CLK_MASK;
95        val |= BCHP_CLK_PM_CTRL_2_DIS_JOTP_9M_CLK_MASK;
96        val |= BCHP_CLK_PM_CTRL_2_DIS_HIF_54M_CLK_MASK;
97        BREG_Write32(GetREG(), BCHP_CLK_PM_CTRL_2, val);
98#endif
99    return b_ok;
100}
101
102/*
103Summary:
104        Initializes the settop API.
105
106Description:
107        Required before any other call. If you don't call it, some key functions will fail;
108        others will succeed but will result in undefined behavior.
109
110        Use the BSETTOP_VERSION macro to pass the correct version. This verifies
111        at run-time that the correct shared library is being used.
112*/
113bresult bsettop_init(bsettop_version version)
114{
115
116        if (initialized)
117        {
118                BDBG_MSG(("\n\n### bsettop_init already initialized ###\n\n"));
119                return b_ok;
120        }
121        // now in ram_init so it is called earlier in the initialization process - gist_init();
122        // bsettop_pm_off();
123       
124#ifdef CONFIG_WATCHDOG 
125
126        /* Start watchdog timer */
127        if (BREG_Read32(GetREG(), BCHP_TIMER_WDCRS) == BCHP_TIMER_WDCRS_WDCR_MASK)
128        {
129                BDBG_MSG(("\n\n### WATCHDOG TIMER OCCURED ###\n\n"));
130
131                /* Clear the reset status register */
132                BREG_Write32(GetREG(), BCHP_TIMER_WDCRS,BCHP_TIMER_WDCRS_WDCR_MASK);
133
134                /* Possible TODO put extra debug code here to determine cause of reset*/
135        }
136
137        BINT_CreateCallback(&h_wd_callback, GetINT(), BCHP_INT_ID_WDINT, bsettop_wd_isr, NULL, 0);
138        BINT_EnableCallback(h_wd_callback);
139       
140        BREG_Write32(GetREG(), BCHP_TIMER_WDTIMEOUT,0x1FFFFFFF);
141        BREG_Write32(GetREG(), BCHP_TIMER_TIMER_IE0,BCHP_TIMER_TIMER_IE0_WDINTMASK_MASK);
142
143        /* Write start sequence */
144        BREG_Write32(GetREG(), BCHP_TIMER_WDCMD,0xFF00);
145        BREG_Write32(GetREG(), BCHP_TIMER_WDCMD,0x00FF);
146#endif 
147        initialized = true;
148        return b_ok;
149}
150
151/*
152Summary:
153        Releases resources
154
155Description:
156        This function is used to release resources allocated during bsettop_init.
157        User should call this function before exit from an application.
158*/
159void bsettop_uninit(void)
160{
161}
162
163/*
164Summary:
165        Perform periodic power monitoring functions
166*/
167
168void bsettop_pvt(void)
169{
170#ifdef CONFIG_MONITOR_PVT
171        BCHP_AvsSettings avs;
172        BDBG_MSG(("%s Execute BCHP_Monitor_Pvt\n",__FUNCTION__));
173        avs.hardStopOffset = 2;
174        avs.maxVoltageStopOffset = 4;
175        BCHP_MonitorPvt(GetCHP(), &avs);
176#endif
177}
178
Note: See TracBrowser for help on using the repository browser.