Add initial Packard Bell Vibe 500 port, by Szymon Dziok
[kugel-rb.git] / firmware / target / arm / pbell / vibe500 / power-vibe500.c
blobe55c69e0334f8398e1ea1179243e9cf2a25e1875
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id:$
10 * Copyright (C) 2009 by Szymon Dziok
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.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
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"
32 void power_init(void)
34 GPIOD_ENABLE |= 0x80; /* enable ACK */
35 GPIOA_ENABLE |= (0x10 | 0x20); /* enable DATA, CLK */
37 GPIOD_OUTPUT_EN |= 0x80; /* set ACK */
38 GPIOD_OUTPUT_VAL |= 0x80; /* high */
40 GPIOA_OUTPUT_EN &= ~0x20; /* CLK */
42 GPIOA_OUTPUT_EN |= 0x10; /* set DATA */
43 GPIOA_OUTPUT_VAL |= 0x10; /* high */
45 if (!touchpad_init())
47 logf("touchpad not ready");
49 /* Sound unmute (on) */
50 GPIO_CLEAR_BITWISE(GPIOL_OUTPUT_VAL, 0x10);
53 unsigned int power_input_status(void)
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;
63 return status;
66 void ide_power_enable(bool on)
68 if(on){
69 GPIO_SET_BITWISE(GPIOC_OUTPUT_VAL, 0x08);
70 DEV_EN |= DEV_IDE0;
71 } else
73 DEV_EN &= ~DEV_IDE0;
74 GPIO_CLEAR_BITWISE(GPIOC_OUTPUT_VAL, 0x08);
78 bool ide_powered(void)
80 return ((GPIOC_INPUT_VAL & 0x08) == 1);
83 void power_off(void)
85 /* from the OF */
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;
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);