diff options
Diffstat (limited to 'firmware/target/coldfire/mpio/hd200/power-hd200.c')
-rw-r--r-- | firmware/target/coldfire/mpio/hd200/power-hd200.c | 65 |
1 files changed, 41 insertions, 24 deletions
diff --git a/firmware/target/coldfire/mpio/hd200/power-hd200.c b/firmware/target/coldfire/mpio/hd200/power-hd200.c index dd8576b9e4..4fc28e1436 100644 --- a/firmware/target/coldfire/mpio/hd200/power-hd200.c +++ b/firmware/target/coldfire/mpio/hd200/power-hd200.c | |||
@@ -30,15 +30,10 @@ | |||
30 | #if CONFIG_TUNER | 30 | #if CONFIG_TUNER |
31 | bool tuner_power(bool status) | 31 | bool tuner_power(bool status) |
32 | { | 32 | { |
33 | (void)status; | ||
34 | if (status) | 33 | if (status) |
35 | { | ||
36 | and_l(~(1<<17), &GPIO1_OUT); | 34 | and_l(~(1<<17), &GPIO1_OUT); |
37 | } | ||
38 | else | 35 | else |
39 | { | ||
40 | or_l((1<<17), &GPIO1_OUT); | 36 | or_l((1<<17), &GPIO1_OUT); |
41 | } | ||
42 | 37 | ||
43 | return status; | 38 | return status; |
44 | } | 39 | } |
@@ -46,20 +41,39 @@ bool tuner_power(bool status) | |||
46 | 41 | ||
47 | void power_init(void) | 42 | void power_init(void) |
48 | { | 43 | { |
49 | /* GPIO53 has to be high - low resets device */ | 44 | /* GPIO53 has to be high - low resets device |
50 | /* GPIO49 is FM related */ | 45 | * it is setup in crt0.S |
51 | or_l((1<<21)|(1<<17), &GPIO1_OUT); | 46 | */ |
52 | or_l((1<<21)|(1<<17), &GPIO1_ENABLE); | ||
53 | or_l((1<<21)|(1<<17)|(1<<14), &GPIO1_FUNCTION); | ||
54 | 47 | ||
55 | and_l(~(1<<15), &GPIO_OUT); | 48 | /* GPIO50 is ATA power (default OFF) */ |
56 | or_l((1<<15),&GPIO_ENABLE); | 49 | or_l((1<<18), &GPIO1_OUT); |
57 | or_l((1<<15),&GPIO_FUNCTION); | 50 | or_l((1<<18), &GPIO1_ENABLE); |
51 | or_l((1<<18), &GPIO1_FUNCTION); | ||
58 | 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*/ | ||
59 | or_l((1<<23), &GPIO_OUT); | 68 | or_l((1<<23), &GPIO_OUT); |
60 | and_l(~(1<<23), &GPIO_ENABLE); | 69 | and_l(~(1<<23), &GPIO_ENABLE); |
61 | or_l((1<<23), &GPIO_FUNCTION); | 70 | or_l((1<<23), &GPIO_FUNCTION); |
62 | 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 | |||
63 | #ifndef BOOTLOADER | 77 | #ifndef BOOTLOADER |
64 | /* The boot loader controls the power */ | 78 | /* The boot loader controls the power */ |
65 | ide_power_enable(true); | 79 | ide_power_enable(true); |
@@ -71,8 +85,16 @@ unsigned int power_input_status(void) | |||
71 | unsigned int status = POWER_INPUT_NONE; | 85 | unsigned int status = POWER_INPUT_NONE; |
72 | /* GPIO46 is AC plug detect (low = AC plugged) */ | 86 | /* GPIO46 is AC plug detect (low = AC plugged) */ |
73 | if (!(GPIO1_READ & (1<<14))) | 87 | if (!(GPIO1_READ & (1<<14))) |
74 | status |= POWER_INPUT_MAIN_CHARGER; | 88 | { |
75 | 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 | } | ||
76 | return status; | 98 | return status; |
77 | } | 99 | } |
78 | 100 | ||
@@ -87,20 +109,15 @@ bool charging_state(void) | |||
87 | 109 | ||
88 | void ide_power_enable(bool on) | 110 | void ide_power_enable(bool on) |
89 | { | 111 | { |
90 | (void)on; | 112 | if (on) |
91 | if (on) | 113 | and_l(~(1<<18),&GPIO1_OUT); |
92 | and_l(~(1<<31),&GPIO_OUT); | ||
93 | else | 114 | else |
94 | or_l((1<<31),&GPIO_OUT); | 115 | or_l((1<<18),&GPIO1_OUT); |
95 | |||
96 | or_l((1<<31),&GPIO_ENABLE); | ||
97 | or_l((1<<31),&GPIO_FUNCTION); | ||
98 | |||
99 | } | 116 | } |
100 | 117 | ||
101 | bool ide_powered(void) | 118 | bool ide_powered(void) |
102 | { | 119 | { |
103 | return true; | 120 | return (GPIO1_OUT & (1<<18))?false:true; |
104 | } | 121 | } |
105 | 122 | ||
106 | void power_off(void) | 123 | void power_off(void) |