diff options
author | Marcin Bukat <marcin.bukat@gmail.com> | 2010-11-12 21:52:29 +0000 |
---|---|---|
committer | Marcin Bukat <marcin.bukat@gmail.com> | 2010-11-12 21:52:29 +0000 |
commit | 123bebeada5dce220d8ce96d31ed711cb13d8d05 (patch) | |
tree | e1d45698eb457c142916271529ca28834708937c /firmware/target/coldfire/mpio/power-mpio.c | |
parent | 6c8267a42cffd711dcd4230415f7e0ab15b855b3 (diff) | |
download | rockbox-123bebeada5dce220d8ce96d31ed711cb13d8d05.tar.gz rockbox-123bebeada5dce220d8ce96d31ed711cb13d8d05.zip |
MPIO: move files a bit in preparation for HD300 port
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28567 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/coldfire/mpio/power-mpio.c')
-rw-r--r-- | firmware/target/coldfire/mpio/power-mpio.c | 130 |
1 files changed, 130 insertions, 0 deletions
diff --git a/firmware/target/coldfire/mpio/power-mpio.c b/firmware/target/coldfire/mpio/power-mpio.c new file mode 100644 index 0000000000..3034bab82d --- /dev/null +++ b/firmware/target/coldfire/mpio/power-mpio.c | |||
@@ -0,0 +1,130 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2010 Marcin Bukat | ||
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 "lcd.h" | ||
28 | #include "power.h" | ||
29 | |||
30 | #if CONFIG_TUNER | ||
31 | bool tuner_power(bool status) | ||
32 | { | ||
33 | if (status) | ||
34 | and_l(~(1<<17), &GPIO1_OUT); | ||
35 | else | ||
36 | or_l((1<<17), &GPIO1_OUT); | ||
37 | |||
38 | return status; | ||
39 | } | ||
40 | #endif /* #if CONFIG_TUNER */ | ||
41 | |||
42 | void power_init(void) | ||
43 | { | ||
44 | /* GPIO53 has to be high - low resets device | ||
45 | * it is setup in crt0.S | ||
46 | */ | ||
47 | |||
48 | /* GPIO50 is ATA power (default OFF) */ | ||
49 | or_l((1<<18), &GPIO1_OUT); | ||
50 | or_l((1<<18), &GPIO1_ENABLE); | ||
51 | or_l((1<<18), &GPIO1_FUNCTION); | ||
52 | |||
53 | /* GPIO49 is FM power (default OFF) */ | ||
54 | or_l((1<<17), &GPIO1_OUT); | ||
55 | or_l((1<<17), &GPIO1_ENABLE); | ||
56 | or_l((1<<17), &GPIO1_FUNCTION); | ||
57 | |||
58 | /* GPIO46 is wall charger detect (input) */ | ||
59 | and_l(~(1<<14), &GPIO1_ENABLE); | ||
60 | or_l((1<<14), &GPIO1_FUNCTION); | ||
61 | |||
62 | /* GPIO31 needs to be low */ | ||
63 | and_l(~(1<<31), &GPIO_OUT); | ||
64 | or_l((1<<31),&GPIO_ENABLE); | ||
65 | or_l((1<<31),&GPIO_FUNCTION); | ||
66 | |||
67 | /* turn off charger by default*/ | ||
68 | or_l((1<<23), &GPIO_OUT); | ||
69 | or_l((1<<23), &GPIO_ENABLE); | ||
70 | or_l((1<<23), &GPIO_FUNCTION); | ||
71 | |||
72 | /* high current charge mode */ | ||
73 | or_l((1<<15), &GPIO_OUT); | ||
74 | or_l((1<<15),&GPIO_ENABLE); | ||
75 | or_l((1<<15),&GPIO_FUNCTION); | ||
76 | |||
77 | #ifndef BOOTLOADER | ||
78 | /* The boot loader controls the power */ | ||
79 | ide_power_enable(true); | ||
80 | #endif | ||
81 | } | ||
82 | |||
83 | unsigned int power_input_status(void) | ||
84 | { | ||
85 | unsigned int status = POWER_INPUT_NONE; | ||
86 | /* GPIO46 is AC plug detect (low = AC plugged) */ | ||
87 | if (!(GPIO1_READ & (1<<14))) | ||
88 | { | ||
89 | status |= POWER_INPUT_MAIN_CHARGER; | ||
90 | /* tristate GPIO23 to start charging cycle */ | ||
91 | and_l(~(1<<23), &GPIO_ENABLE); | ||
92 | } | ||
93 | else | ||
94 | { | ||
95 | /* drive GPIO23 high to enter LTC1733 shutdown mode */ | ||
96 | or_l((1<<23), &GPIO_ENABLE); | ||
97 | } | ||
98 | return status; | ||
99 | } | ||
100 | |||
101 | /* Returns true if the unit is charging the batteries. */ | ||
102 | bool charging_state(void) | ||
103 | { | ||
104 | if (!(GPIO1_READ & (1<<14))) | ||
105 | return (GPIO_READ & (1<<30) )?false:true; | ||
106 | else | ||
107 | return false; | ||
108 | } | ||
109 | |||
110 | void ide_power_enable(bool on) | ||
111 | { | ||
112 | if (on) | ||
113 | and_l(~(1<<18),&GPIO1_OUT); | ||
114 | else | ||
115 | or_l((1<<18),&GPIO1_OUT); | ||
116 | } | ||
117 | |||
118 | bool ide_powered(void) | ||
119 | { | ||
120 | return (GPIO1_OUT & (1<<18))?false:true; | ||
121 | } | ||
122 | |||
123 | void power_off(void) | ||
124 | { | ||
125 | lcd_shutdown(); | ||
126 | set_irq_level(DISABLE_INTERRUPTS); | ||
127 | and_l(~(1<<21), &GPIO1_OUT); /* pull KEEPACT low */ | ||
128 | asm("halt"); | ||
129 | while(1); | ||
130 | } | ||