summaryrefslogtreecommitdiff
path: root/firmware/target/arm/pbell/vibe500/power-vibe500.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/pbell/vibe500/power-vibe500.c')
-rw-r--r--firmware/target/arm/pbell/vibe500/power-vibe500.c103
1 files changed, 103 insertions, 0 deletions
diff --git a/firmware/target/arm/pbell/vibe500/power-vibe500.c b/firmware/target/arm/pbell/vibe500/power-vibe500.c
new file mode 100644
index 0000000000..e55c69e033
--- /dev/null
+++ b/firmware/target/arm/pbell/vibe500/power-vibe500.c
@@ -0,0 +1,103 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id:$
9 *
10 * Copyright (C) 2009 by Szymon Dziok
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include "config.h"
23#include "cpu.h"
24#include <stdbool.h>
25#include "kernel.h"
26#include "system.h"
27#include "power.h"
28#include "logf.h"
29#include "usb.h"
30#include "synaptics-mep.h"
31
32void power_init(void)
33{
34 GPIOD_ENABLE |= 0x80; /* enable ACK */
35 GPIOA_ENABLE |= (0x10 | 0x20); /* enable DATA, CLK */
36
37 GPIOD_OUTPUT_EN |= 0x80; /* set ACK */
38 GPIOD_OUTPUT_VAL |= 0x80; /* high */
39
40 GPIOA_OUTPUT_EN &= ~0x20; /* CLK */
41
42 GPIOA_OUTPUT_EN |= 0x10; /* set DATA */
43 GPIOA_OUTPUT_VAL |= 0x10; /* high */
44
45 if (!touchpad_init())
46 {
47 logf("touchpad not ready");
48 }
49 /* Sound unmute (on) */
50 GPIO_CLEAR_BITWISE(GPIOL_OUTPUT_VAL, 0x10);
51}
52
53unsigned int power_input_status(void)
54{
55 unsigned int status = POWER_INPUT_NONE;
56 /* GPIOL - external charger connected */
57 if (GPIOL_INPUT_VAL & 0x20)
58 status = POWER_INPUT_MAIN_CHARGER;
59 /* GPIOL - usb connected */
60 if (GPIOL_INPUT_VAL & 0x04)
61 status |= POWER_INPUT_USB_CHARGER;
62
63 return status;
64}
65
66void ide_power_enable(bool on)
67{
68 if(on){
69 GPIO_SET_BITWISE(GPIOC_OUTPUT_VAL, 0x08);
70 DEV_EN |= DEV_IDE0;
71 } else
72 {
73 DEV_EN &= ~DEV_IDE0;
74 GPIO_CLEAR_BITWISE(GPIOC_OUTPUT_VAL, 0x08);
75 }
76}
77
78bool ide_powered(void)
79{
80 return ((GPIOC_INPUT_VAL & 0x08) == 1);
81}
82
83void power_off(void)
84{
85 /* from the OF */
86/*
87 DEV_INIT2 |= DEV_I2S;
88 GPIO_SET_BITWISE(GPIOL_OUTPUT_VAL, 0x10);
89 sleep(HZ/100);
90 GPIO_SET_BITWISE(GPIOL_OUTPUT_VAL, 0x10);
91 sleep(HZ);
92 GPIO_CLEAR_BITWISE(GPIOB_OUTPUT_VAL, 0x80);
93 sleep(HZ);
94 GPIO_CLEAR_BITWISE(GPIOC_OUTPUT_VAL, 0x08);
95 GPO32_VAL |= 0x40000000;
96 GPO32_ENABLE |= 0x40000000;
97*/
98 /* Sound mute (off) */
99 DEV_INIT2 |= DEV_I2S;
100 GPIO_SET_BITWISE(GPIOL_OUTPUT_VAL, 0x10);
101 /* shutdown bit */
102 GPIO_CLEAR_BITWISE(GPIOB_OUTPUT_VAL, 0x80);
103}