diff options
Diffstat (limited to 'firmware/drivers/power.c')
-rw-r--r-- | firmware/drivers/power.c | 42 |
1 files changed, 34 insertions, 8 deletions
diff --git a/firmware/drivers/power.c b/firmware/drivers/power.c index 549624fd92..a701d01658 100644 --- a/firmware/drivers/power.c +++ b/firmware/drivers/power.c | |||
@@ -36,11 +36,6 @@ void power_init(void) | |||
36 | or_b(0x20, &PBIORL); /* Set charging control bit to output */ | 36 | or_b(0x20, &PBIORL); /* Set charging control bit to output */ |
37 | charger_enable(false); /* Default to charger OFF */ | 37 | charger_enable(false); /* Default to charger OFF */ |
38 | #endif | 38 | #endif |
39 | #ifdef HAVE_ATA_POWER_OFF | ||
40 | or_b(0x20, &PADRL); /* leave the disk on */ | ||
41 | or_b(0x20, &PAIORL); | ||
42 | PACR2 &= 0xFBFF; | ||
43 | #endif | ||
44 | } | 39 | } |
45 | 40 | ||
46 | bool charger_inserted(void) | 41 | bool charger_inserted(void) |
@@ -79,16 +74,47 @@ void charger_enable(bool on) | |||
79 | 74 | ||
80 | void ide_power_enable(bool on) | 75 | void ide_power_enable(bool on) |
81 | { | 76 | { |
82 | #ifdef HAVE_ATA_POWER_OFF | 77 | (void)on; |
78 | bool touched = false; | ||
79 | |||
80 | #ifdef NEEDS_ATA_POWER_ON | ||
83 | if(on) | 81 | if(on) |
82 | { | ||
84 | or_b(0x20, &PADRL); | 83 | or_b(0x20, &PADRL); |
85 | else | 84 | touched = true; |
85 | } | ||
86 | #endif | ||
87 | #ifdef HAVE_ATA_POWER_OFF | ||
88 | if(!on) | ||
89 | { | ||
86 | and_b(~0x20, &PADRL); | 90 | and_b(~0x20, &PADRL); |
91 | touched = true; | ||
92 | } | ||
93 | #endif | ||
94 | |||
95 | /* late port preparation, else problems with read/modify/write | ||
96 | of other bits on same port, while input and floating high */ | ||
97 | if (touched) | ||
98 | { | ||
99 | or_b(0x20, &PAIORL); /* PA5 is an output */ | ||
100 | PACR2 &= 0xFBFF; /* GPIO for PA5 */ | ||
101 | } | ||
102 | } | ||
103 | |||
104 | |||
105 | bool ide_powered(void) | ||
106 | { | ||
107 | #if defined(NEEDS_ATA_POWER_ON) || defined(HAVE_ATA_POWER_OFF) | ||
108 | if ((PACR2 & 0x0400) || !(PAIOR & 0x0020)) // not configured for output | ||
109 | return true; // would be floating high, disk on | ||
110 | else | ||
111 | return (PADR & 0x0020) != 0; | ||
87 | #else | 112 | #else |
88 | on = on; | 113 | return TRUE; /* pretend always powered if not controlable */ |
89 | #endif | 114 | #endif |
90 | } | 115 | } |
91 | 116 | ||
117 | |||
92 | void power_off(void) | 118 | void power_off(void) |
93 | { | 119 | { |
94 | set_irq_level(15); | 120 | set_irq_level(15); |