Fix Philips sa9200 red (HAVE_LCD_SLEEP is not defined in the bootloader so there...
[kugel-rb/myfork.git] / firmware / target / arm / philips / sa9200 / power-sa9200.c
blob1570954fcc91473a2ecddafc8c440da9a2d9fa3b
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2006 by Daniel Ankers
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 <stdbool.h>
23 #include "system.h"
24 #include "cpu.h"
25 #include "ascodec.h"
26 #include "as3514.h"
27 #include "power.h"
28 #include "synaptics-mep.h"
29 #include "lcd.h"
30 #include "logf.h"
32 void power_init(void)
34 #ifndef BOOTLOADER
35 /* Power on and initialize the touchpad here because we need it for
36 both buttons and button lights */
37 DEV_INIT2 &= ~0x800;
39 char byte = ascodec_read(AS3514_CVDD_DCDC3);
40 byte = (byte & ~0x18) | 0x08;
41 ascodec_write(AS3514_CVDD_DCDC3, byte);
43 /* LEDs for REW, FFWD, MENU */
44 GPIOD_ENABLE |= (0x40 | 0x20 | 0x04);
45 GPIOD_OUTPUT_VAL |= (0x40 | 0x20 | 0x04);
46 GPIOD_OUTPUT_EN |= (0x40 | 0x20 | 0x04);
47 udelay(20000);
49 GPIOL_ENABLE |= 0x10;
50 GPIOL_OUTPUT_VAL &= ~0x10;
51 GPIOL_OUTPUT_EN |= 0x10;
52 udelay(100000);
54 /* enable DATA, ACK, CLK lines */
55 GPIOD_ENABLE |= (0x10 | 0x08 | 0x02);
57 GPIOD_OUTPUT_EN |= 0x08; /* ACK */
58 GPIOD_OUTPUT_VAL |= 0x08; /* high */
60 GPIOD_OUTPUT_EN &= ~0x02; /* CLK */
62 GPIOD_OUTPUT_EN |= 0x10; /* DATA */
63 GPIOD_OUTPUT_VAL |= 0x10; /* high */
65 if (!touchpad_init())
67 logf("touchpad not ready");
69 #endif
72 void power_off(void)
74 char byte;
76 /* Backlight off */
77 ascodec_write(AS3514_DCDC15, 0);
79 #ifdef HAVE_LCD_SLEEP
80 /* LCD off/sleep (otherwise the image slowly fades out) */
81 lcd_sleep();
82 #endif
84 /* Send shutdown command to PMU */
85 byte = ascodec_read(AS3514_SYSTEM);
86 byte &= ~0x1;
87 ascodec_write(AS3514_SYSTEM, byte);
89 /* Stop interrupts on both cores */
90 disable_interrupt(IRQ_FIQ_STATUS);
91 COP_INT_DIS = -1;
92 CPU_INT_DIS = -1;
94 /* Halt everything and wait for device to power off */
95 while (1)
97 COP_CTL = 0x40000000;
98 CPU_CTL = 0x40000000;
102 unsigned int power_input_status(void)
104 unsigned int status = POWER_INPUT_NONE;
106 /* GPIOF indicates that the connector is present,
107 GPIOB indicates that there's power there too.
108 Same status bits for both USB and the charger. */
109 if (!(GPIOF_INPUT_VAL & 0x80) && (GPIOB_INPUT_VAL & 0x40))
110 status = POWER_INPUT_MAIN_CHARGER;
112 return status;
115 void ide_power_enable(bool on)
117 (void)on;