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
)
36 and_l(~(1<<17), &GPIO1_OUT
);
40 or_l((1<<17), &GPIO1_OUT
);
45 #endif /* #if CONFIG_TUNER */
49 /* GPIO53 has to be high - low resets device */
50 /* GPIO49 is FM related */
51 or_l((1<<21)|(1<<17), &GPIO1_OUT
);
52 or_l((1<<21)|(1<<17), &GPIO1_ENABLE
);
53 or_l((1<<21)|(1<<17)|(1<<14), &GPIO1_FUNCTION
);
55 and_l(~(1<<15), &GPIO_OUT
);
56 or_l((1<<15),&GPIO_ENABLE
);
57 or_l((1<<15),&GPIO_FUNCTION
);
59 or_l((1<<23), &GPIO_OUT
);
60 and_l(~(1<<23), &GPIO_ENABLE
);
61 or_l((1<<23), &GPIO_FUNCTION
);
64 /* The boot loader controls the power */
65 ide_power_enable(true);
69 unsigned int power_input_status(void)
71 unsigned int status
= POWER_INPUT_NONE
;
72 /* GPIO46 is AC plug detect (low = AC plugged) */
73 if (!(GPIO1_READ
& (1<<14)))
74 status
|= POWER_INPUT_MAIN_CHARGER
;
79 /* Returns true if the unit is charging the batteries. */
80 bool charging_state(void)
82 if (!(GPIO1_READ
& (1<<14)))
83 return (GPIO_READ
& (1<<30) )?false:true;
88 void ide_power_enable(bool on
)
92 and_l(~(1<<31),&GPIO_OUT
);
94 or_l((1<<31),&GPIO_OUT
);
96 or_l((1<<31),&GPIO_ENABLE
);
97 or_l((1<<31),&GPIO_FUNCTION
);
101 bool ide_powered(void)
109 set_irq_level(DISABLE_INTERRUPTS
);
110 and_l(~(1<<21), &GPIO1_OUT
); /* pull KEEPACT low */