1 /*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include <apInt.h>
18 #include <gpio.h>
19 #include <variant/inc/variant.h>
20 #include <plat/inc/gpio.h>
21 #include <seos.h>
22 #include <platform.h>
23 #include <plat/inc/plat.h>
24
25 static struct Gpio *apIntWkup;
26 #ifdef AP_INT_NONWAKEUP
27 static struct Gpio *apIntNonWkup;
28 #endif
29
apIntInit()30 void apIntInit()
31 {
32 apIntWkup = gpioRequest(AP_INT_WAKEUP);
33 gpioConfigOutput(apIntWkup, GPIO_SPEED_LOW, GPIO_PULL_NONE, GPIO_OUT_PUSH_PULL, 1);
34
35 #ifdef AP_INT_NONWAKEUP
36 apIntNonWkup = gpioRequest(AP_INT_NONWAKEUP);
37 gpioConfigOutput(apIntNonWkup, GPIO_SPEED_LOW, GPIO_PULL_NONE, GPIO_OUT_PUSH_PULL, 1);
38 #endif
39 }
40
apIntSet(bool wakeup)41 void apIntSet(bool wakeup)
42 {
43 if (wakeup) {
44 platRequestDevInSleepMode(Stm32sleepWakeup, 12);
45 gpioSet(apIntWkup, 0);
46 }
47 #ifdef AP_INT_NONWAKEUP
48 else
49 gpioSet(apIntNonWkup, 0);
50 #endif
51 }
52
apIntClear(bool wakeup)53 void apIntClear(bool wakeup)
54 {
55 if (wakeup) {
56 platReleaseDevInSleepMode(Stm32sleepWakeup);
57 gpioSet(apIntWkup, 1);
58 }
59 #ifdef AP_INT_NONWAKEUP
60 else
61 gpioSet(apIntNonWkup, 1);
62 #endif
63 }
64