hdd6330: change the synaptics-mep driver in a few places according to the touchpad...
[kugel-rb.git] / firmware / target / arm / pbell / vibe500 / power-vibe500.c
bloba5660d7e7353806345b9710ccbf8d288e288d5fb
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 /* Max touch sensivity = 0x77, Rate=80/s,NoFilter=0,
50 KeyMatrix=0,Buttons=1,Relative=0,Absolute=1.
51 MEP parameter 0x20 - Report Modes */
52 touchpad_set_parameter(0,0x20,0x7785);
53 /* MinAbsReporting=0, NotAllCapButtons=0,SingleCapButton=0,
54 50msDebounce=0,MotionReporting=1 (reduce transmission overhead),
55 ClipZifnoFinger=0,DisableDeceleration=0,Dribble=0.
56 MEP parameter 0x21 - Enhanced Operating Configuration */
57 touchpad_set_parameter(0,0x21,0x0008);
58 /* Set the GPO_LEVELS = 0 - for the button lights */
59 touchpad_set_parameter(0,0x23,0x0000);
61 /* Sound unmute (on) */
62 GPIO_CLEAR_BITWISE(GPIOL_OUTPUT_VAL, 0x10);
65 unsigned int power_input_status(void)
67 unsigned int status = POWER_INPUT_NONE;
68 /* GPIOL - external charger connected */
69 if (GPIOL_INPUT_VAL & 0x20)
70 status = POWER_INPUT_MAIN_CHARGER;
71 /* GPIOL - usb connected */
72 if (GPIOL_INPUT_VAL & 0x04)
73 status |= POWER_INPUT_USB_CHARGER;
75 return status;
78 void ide_power_enable(bool on)
80 if(on){
81 GPIO_SET_BITWISE(GPIOC_OUTPUT_VAL, 0x08);
82 DEV_EN |= DEV_IDE0;
83 } else
85 DEV_EN &= ~DEV_IDE0;
86 GPIO_CLEAR_BITWISE(GPIOC_OUTPUT_VAL, 0x08);
90 bool ide_powered(void)
92 return ((GPIOC_INPUT_VAL & 0x08) == 1);
95 void power_off(void)
97 /* Sound mute (off) */
98 DEV_INIT2 |= DEV_I2S;
99 GPIO_SET_BITWISE(GPIOL_OUTPUT_VAL, 0x10);
100 /* shutdown bit */
101 GPIO_CLEAR_BITWISE(GPIOB_OUTPUT_VAL, 0x80);
102 /* button lights off */
103 touchpad_set_parameter(0,0x22,0x0000);
104 /* ATA power off */
105 ide_power_enable(false);
106 /* ? - in the OF */
107 GPO32_VAL |= 0x40000000;
108 GPO32_ENABLE |= 0x40000000;
109 /* lcd controller off ? - makes lcd white until power on */
110 GPIO_CLEAR_BITWISE(GPIOJ_OUTPUT_VAL, 0x04);
111 /* a way to poweroff while charging = system_reset */
112 if (power_input_status())
113 system_reboot();