22d3280738811edcf3f5eda68a2e7977a742c5f2
[profile/ivi/intel-emgd-kmod.git] / emgd / state / power / plb / pwr_plb.c
1 /*
2  *-----------------------------------------------------------------------------
3  * Filename: pwr_plb.c
4  * $Revision: 1.8 $
5  *-----------------------------------------------------------------------------
6  * Copyright (c) 2002-2010, Intel Corporation.
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining a copy
9  * of this software and associated documentation files (the "Software"), to deal
10  * in the Software without restriction, including without limitation the rights
11  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12  * copies of the Software, and to permit persons to whom the Software is
13  * furnished to do so, subject to the following conditions:
14  *
15  * The above copyright notice and this permission notice shall be included in
16  * all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24  * THE SOFTWARE.
25  *
26  *-----------------------------------------------------------------------------
27  * Description:
28  *
29  *-----------------------------------------------------------------------------
30  */
31
32 /* copied from napa */
33
34 #include <io.h>
35 #include "igd_pwr.h"
36 #include "../cmn/pwr_dispatch.h"
37 #include <plb/regs.h>
38
39 /*!
40  * @addtogroup state_group
41  * @{
42  */
43
44 static int pwr_query_full_plb(unsigned int power_state);
45 static int pwr_set_plb(igd_context_t *context, unsigned int power_state);
46 static int pwr_init_plb(igd_context_t *context);
47
48 pwr_dispatch_t pwr_dispatch_plb = {
49         pwr_query_full_plb,
50         pwr_set_plb,
51         pwr_init_plb,
52 };
53
54 /*!
55  * This function returns "0" for all ACPI system states.
56  *
57  * @param power_state the requested power state
58  *
59  * @return 0
60  */
61 static int pwr_query_full_plb(unsigned int power_state)
62 {                                                          /* pwr_query_full */
63         switch( power_state ) {
64
65         case IGD_ADAPTERPOWERSTATE_ON:
66         case IGD_ADAPTERPOWERSTATE_STANDBY:
67         case IGD_ADAPTERPOWERSTATE_OFF:
68         case IGD_ADAPTERPOWERSTATE_SUSPEND:
69         case IGD_ADAPTERPOWERSTATE_HIBERNATE:
70         default:
71                 return 0;
72                 break;
73         }
74 }                                                          /* pwr_query_full */
75
76 /*!
77  *
78  * @patam context
79  * @param power_state the requested power state
80  *
81  * @return 0
82  */
83 static int pwr_set_plb(igd_context_t *context, unsigned int power_state)
84 {
85         unsigned char *mmio;
86
87         mmio = context->device_context.virt_mmadr;
88
89         switch (power_state) {
90         case IGD_POWERSTATE_D0:
91                 break;
92         case IGD_POWERSTATE_D1:
93                 break;
94         case IGD_POWERSTATE_D2:
95                 break;
96         case IGD_POWERSTATE_D3:
97                 break;
98
99         default:
100                 break;
101         }
102         return 0;
103 }
104
105 /*!
106  *
107  * @param context
108  *
109  * @return 0
110  */
111 static int pwr_init_plb(igd_context_t *context)
112 {
113         unsigned char *mmio;
114
115         mmio = context->device_context.virt_mmadr;
116
117         /* Reset CLKGATECTL and CLKGATECTLOVR */
118         EMGD_WRITE32(0x1111111, mmio + PSB_CR_CLKGATECTL);
119         EMGD_WRITE32(0, mmio + PSB_CR_CLKGATECTL + 8);
120
121         return 0;
122 }
123