summaryrefslogtreecommitdiff
path: root/firmware/drivers/power.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers/power.c')
-rw-r--r--firmware/drivers/power.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/firmware/drivers/power.c b/firmware/drivers/power.c
index 3a69b37953..0ef79c8561 100644
--- a/firmware/drivers/power.c
+++ b/firmware/drivers/power.c
@@ -117,15 +117,31 @@ void ide_power_enable(bool on)
117#ifdef NEEDS_ATA_POWER_ON 117#ifdef NEEDS_ATA_POWER_ON
118 if(on) 118 if(on)
119 { 119 {
120#ifdef ATA_POWER_PLAYERSTYLE
121 if (read_rom_version() > 451) /* new players only */
122 {
123 or_b(0x10, &PBDRL);
124 touched = true;
125 }
126#else
120 or_b(0x20, &PADRL); 127 or_b(0x20, &PADRL);
121 touched = true; 128 touched = true;
129#endif
122 } 130 }
123#endif 131#endif
124#ifdef HAVE_ATA_POWER_OFF 132#ifdef HAVE_ATA_POWER_OFF
125 if(!on) 133 if(!on)
126 { 134 {
135#ifdef ATA_POWER_PLAYERSTYLE
136 if (read_rom_version() > 451) /* new players only */
137 {
138 and_b(~0x10, &PBDRL);
139 touched = true;
140 }
141#else
127 and_b(~0x20, &PADRL); 142 and_b(~0x20, &PADRL);
128 touched = true; 143 touched = true;
144#endif
129 } 145 }
130#endif 146#endif
131 147
@@ -133,8 +149,13 @@ void ide_power_enable(bool on)
133 of other bits on same port, while input and floating high */ 149 of other bits on same port, while input and floating high */
134 if (touched) 150 if (touched)
135 { 151 {
152#ifdef ATA_POWER_PLAYERSTYLE
153 or_b(0x10, &PBIORL); /* PB4 is an output */
154 PBCR2 &= ~0x0300; /* GPIO for PB4 */
155#else
136 or_b(0x20, &PAIORL); /* PA5 is an output */ 156 or_b(0x20, &PAIORL); /* PA5 is an output */
137 PACR2 &= 0xFBFF; /* GPIO for PA5 */ 157 PACR2 &= 0xFBFF; /* GPIO for PA5 */
158#endif
138 } 159 }
139} 160}
140#endif /* !HAVE_MMC */ 161#endif /* !HAVE_MMC */
@@ -143,10 +164,22 @@ void ide_power_enable(bool on)
143bool ide_powered(void) 164bool ide_powered(void)
144{ 165{
145#if defined(NEEDS_ATA_POWER_ON) || defined(HAVE_ATA_POWER_OFF) 166#if defined(NEEDS_ATA_POWER_ON) || defined(HAVE_ATA_POWER_OFF)
167#ifdef ATA_POWER_PLAYERSTYLE
168 if (read_rom_version() > 451) /* new players only */
169 {
170 if ((PBCR2 & 0x0300) || !(PBIOR & 0x0010)) /* not configured for output */
171 return false; /* would be floating low, disk off */
172 else
173 return (PBDR & 0x0010) != 0;
174 }
175 else
176 return true; /* old player: always on */
177#else
146 if ((PACR2 & 0x0400) || !(PAIOR & 0x0020)) /* not configured for output */ 178 if ((PACR2 & 0x0400) || !(PAIOR & 0x0020)) /* not configured for output */
147 return true; /* would be floating high, disk on */ 179 return true; /* would be floating high, disk on */
148 else 180 else
149 return (PADR & 0x0020) != 0; 181 return (PADR & 0x0020) != 0;
182#endif /* ATA_POWER_PLAYERSTYLE */
150#else 183#else
151 return true; /* pretend always powered if not controlable */ 184 return true; /* pretend always powered if not controlable */
152#endif 185#endif