Enable 'touchscreen areas' on the D2, based on JdGordon's m:robe code. Disable the...
[Rockbox.git] / firmware / target / arm / tcc780x / cowond2 / power-cowond2.c
blobc7441256c537969fc44aba25caf264ac3314b912
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2007 Dave Chapman
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
19 #include "cpu.h"
20 #include "kernel.h"
21 #include "system.h"
22 #include "power.h"
23 #include "pcf50606.h"
24 #include "button-target.h"
26 #ifndef SIMULATOR
28 void power_init(void)
30 unsigned char data[3]; /* 0 = INT1, 1 = INT2, 2 = INT3 */
32 /* Clear pending interrupts from pcf50606 */
33 pcf50606_read_multiple(0x02, data, 3);
35 /* Set outputs as per OF - further investigation required. */
36 pcf50606_write(PCF5060X_DCDEC1, 0xe4);
37 pcf50606_write(PCF5060X_IOREGC, 0xf5);
38 pcf50606_write(PCF5060X_D1REGC1, 0xf5);
39 pcf50606_write(PCF5060X_D2REGC1, 0xe9);
40 pcf50606_write(PCF5060X_D3REGC1, 0xf8); /* WM8985 3.3v */
41 pcf50606_write(PCF5060X_DCUDC1, 0xe7);
42 pcf50606_write(PCF5060X_LPREGC1, 0x0);
43 pcf50606_write(PCF5060X_LPREGC2, 0x2);
45 #ifndef BOOTLOADER
46 IEN |= EXT3_IRQ_MASK; /* Unmask EXT3 */
47 #endif
50 void ide_power_enable(bool on)
52 (void)on;
55 bool ide_powered(void)
57 return true;
60 void power_off(void)
62 /* Forcibly cut power to SoC & peripherals by putting the PCF to sleep */
63 pcf50606_write(PCF5060X_OOCC1, GOSTDBY | CHGWAK | EXTONWAK);
66 #ifndef BOOTLOADER
67 void EXT3(void)
69 unsigned char data[3]; /* 0 = INT1, 1 = INT2, 2 = INT3 */
71 /* Clear pending interrupts from pcf50606 */
72 int fiq_status = disable_fiq_save();
73 pcf50606_read_multiple(0x02, data, 3);
75 if (data[0] & 0x04)
77 /* ONKEY1S: don't reset the timeout, because we want a way to power off
78 the player in the event of a crashed plugin or UIE/panic, etc. */
79 #if 0
80 /* ONKEY1S: reset timeout as we're using SW poweroff */
81 pcf50606_write(0x08, pcf50606_read(0x08) | 0x02); /* OOCC1: TOTRST=1 */
82 #endif
85 if (data[2] & 0x08)
87 /* Touchscreen event, do something about it */
88 button_set_touch_available();
90 restore_fiq(fiq_status);
92 #endif
94 #if CONFIG_CHARGING
95 bool charger_inserted(void)
97 return (GPIOC & (1<<26)) ? false:true;
99 #endif
101 #else /* SIMULATOR */
103 bool charger_inserted(void)
105 return false;
108 void charger_enable(bool on)
110 (void)on;
113 void power_off(void)
117 void ide_power_enable(bool on)
119 (void)on;
122 #endif /* SIMULATOR */