1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2010 Marcin Bukat
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 ****************************************************************************/
31 bool tuner_power(bool status
)
34 and_l(~(1<<17), &GPIO1_OUT
);
36 or_l((1<<17), &GPIO1_OUT
);
40 #endif /* #if CONFIG_TUNER */
44 /* GPIO53 has to be high - low resets device
45 * it is setup in crt0.S
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
);
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
);
58 /* GPIO46 is wall charger detect (input) */
59 and_l(~(1<<14), &GPIO1_ENABLE
);
60 or_l((1<<14), &GPIO1_FUNCTION
);
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
);
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
);
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
);
78 /* The boot loader controls the power */
79 ide_power_enable(true);
83 unsigned int power_input_status(void)
85 unsigned int status
= POWER_INPUT_NONE
;
86 /* GPIO46 is AC plug detect (low = AC plugged) */
87 if (!(GPIO1_READ
& (1<<14)))
89 status
|= POWER_INPUT_MAIN_CHARGER
;
90 /* tristate GPIO23 to start charging cycle */
91 and_l(~(1<<23), &GPIO_ENABLE
);
95 /* drive GPIO23 high to enter LTC1733 shutdown mode */
96 or_l((1<<23), &GPIO_ENABLE
);
101 /* Returns true if the unit is charging the batteries. */
102 bool charging_state(void)
104 if (!(GPIO1_READ
& (1<<14)))
105 return (GPIO_READ
& (1<<30) )?false:true;
110 void ide_power_enable(bool on
)
113 and_l(~(1<<18),&GPIO1_OUT
);
115 or_l((1<<18),&GPIO1_OUT
);
118 bool ide_powered(void)
120 return (GPIO1_OUT
& (1<<18))?false:true;
125 #ifdef HAVE_LCD_SHUTDOWN
128 set_irq_level(DISABLE_INTERRUPTS
);
129 and_l(~(1<<21), &GPIO1_OUT
); /* pull KEEPACT low */