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.c34
1 files changed, 19 insertions, 15 deletions
diff --git a/firmware/drivers/power.c b/firmware/drivers/power.c
index 33015b2f4c..c0fa57d3b0 100644
--- a/firmware/drivers/power.c
+++ b/firmware/drivers/power.c
@@ -21,6 +21,7 @@
21#include "config.h" 21#include "config.h"
22#include "adc.h" 22#include "adc.h"
23#include "kernel.h" 23#include "kernel.h"
24#include "system.h"
24#include "power.h" 25#include "power.h"
25 26
26#ifdef HAVE_CHARGE_CTRL 27#ifdef HAVE_CHARGE_CTRL
@@ -32,11 +33,11 @@ bool charger_enabled;
32void power_init(void) 33void power_init(void)
33{ 34{
34#ifdef HAVE_CHARGE_CTRL 35#ifdef HAVE_CHARGE_CTRL
35 PBIOR |= 0x20; /* Set charging control bit to output */ 36 __set_bit_constant(5, &PBIORL); /* Set charging control bit to output */
36 charger_enable(false); /* Default to charger OFF */ 37 charger_enable(false); /* Default to charger OFF */
37#endif 38#endif
38#ifdef HAVE_ATA_POWER_OFF 39#ifdef HAVE_ATA_POWER_OFF
39 PAIOR |= 0x20; 40 __set_bit_constant(5, &PAIORL);
40 PACR2 &= 0xFBFF; 41 PACR2 &= 0xFBFF;
41#endif 42#endif
42} 43}
@@ -60,11 +61,14 @@ bool charger_inserted(void)
60void charger_enable(bool on) 61void charger_enable(bool on)
61{ 62{
62#ifdef HAVE_CHARGE_CTRL 63#ifdef HAVE_CHARGE_CTRL
63 if(on) { 64 if(on)
64 PBDR &= ~0x20; 65 {
66 __clear_bit_constant(5, &PBDRL);
65 charger_enabled = 1; 67 charger_enabled = 1;
66 } else { 68 }
67 PBDR |= 0x20; 69 else
70 {
71 __set_bit_constant(5, &PBDRL);
68 charger_enabled = 0; 72 charger_enabled = 0;
69 } 73 }
70#else 74#else
@@ -76,9 +80,9 @@ void ide_power_enable(bool on)
76{ 80{
77#ifdef HAVE_ATA_POWER_OFF 81#ifdef HAVE_ATA_POWER_OFF
78 if(on) 82 if(on)
79 PADR |= 0x20; 83 __set_bit_constant(5, &PADRL);
80 else 84 else
81 PADR &= ~0x20; 85 __clear_bit_constant(5, &PADRL);
82#else 86#else
83 on = on; 87 on = on;
84#endif 88#endif
@@ -88,14 +92,14 @@ void power_off(void)
88{ 92{
89 set_irq_level(15); 93 set_irq_level(15);
90#ifdef HAVE_POWEROFF_ON_PBDR 94#ifdef HAVE_POWEROFF_ON_PBDR
91 PBDR &= ~PBDR_BTN_OFF; 95 __clear_mask_constant(PBDR_BTN_OFF, &PBDRL);
92 PBIOR |= PBDR_BTN_OFF; 96 __set_mask_constant(PBDR_BTN_OFF, &PBIORL);
93#elif defined(HAVE_POWEROFF_ON_PB5) 97#elif defined(HAVE_POWEROFF_ON_PB5)
94 PBDR &= ~0x20; 98 __clear_bit_constant(5, &PBDRL);
95 PBIOR |= 0x20; 99 __set_bit_constant(5, &PBIORL);
96#else 100#else
97 PADR &= ~0x800; 101 __clear_bit_constant(11-8, &PADRH);
98 PAIOR |= 0x800; 102 __set_bit_constant(11-8, &PAIORH);
99#endif 103#endif
100 while(1); 104 while(1);
101} 105}