diff options
Diffstat (limited to 'firmware/target/coldfire')
-rw-r--r-- | firmware/target/coldfire/iaudio/m3/power-m3.c | 11 | ||||
-rw-r--r-- | firmware/target/coldfire/iaudio/m5/power-m5.c | 11 | ||||
-rw-r--r-- | firmware/target/coldfire/iaudio/x5/power-x5.c | 11 | ||||
-rw-r--r-- | firmware/target/coldfire/iriver/h100/power-h100.c | 21 | ||||
-rw-r--r-- | firmware/target/coldfire/iriver/h300/power-h300.c | 53 |
5 files changed, 63 insertions, 44 deletions
diff --git a/firmware/target/coldfire/iaudio/m3/power-m3.c b/firmware/target/coldfire/iaudio/m3/power-m3.c index 5dbeadf732..4c446e54d0 100644 --- a/firmware/target/coldfire/iaudio/m3/power-m3.c +++ b/firmware/target/coldfire/iaudio/m3/power-m3.c | |||
@@ -27,8 +27,6 @@ | |||
27 | #include "power.h" | 27 | #include "power.h" |
28 | #include "system.h" | 28 | #include "system.h" |
29 | 29 | ||
30 | #ifndef SIMULATOR | ||
31 | |||
32 | void power_init(void) | 30 | void power_init(void) |
33 | { | 31 | { |
34 | /* Set KEEPACT */ | 32 | /* Set KEEPACT */ |
@@ -47,9 +45,10 @@ void power_init(void) | |||
47 | #endif | 45 | #endif |
48 | } | 46 | } |
49 | 47 | ||
50 | bool charger_inserted(void) | 48 | unsigned int power_input_status(void) |
51 | { | 49 | { |
52 | return (GPIO1_READ & 0x00000020) == 0; | 50 | return ((GPIO1_READ & 0x00000020) == 0) ? |
51 | POWER_INPUT_MAIN_CHARGER : POWER_INPUT_NONE; | ||
53 | } | 52 | } |
54 | 53 | ||
55 | void ide_power_enable(bool on) | 54 | void ide_power_enable(bool on) |
@@ -77,8 +76,6 @@ void power_off(void) | |||
77 | asm("halt"); | 76 | asm("halt"); |
78 | } | 77 | } |
79 | 78 | ||
80 | #endif /* SIMULATOR */ | ||
81 | |||
82 | bool tuner_power(bool status) | 79 | bool tuner_power(bool status) |
83 | { | 80 | { |
84 | (void)status; | 81 | (void)status; |
diff --git a/firmware/target/coldfire/iaudio/m5/power-m5.c b/firmware/target/coldfire/iaudio/m5/power-m5.c index 987ce0f3c5..8bb36c663d 100644 --- a/firmware/target/coldfire/iaudio/m5/power-m5.c +++ b/firmware/target/coldfire/iaudio/m5/power-m5.c | |||
@@ -27,8 +27,6 @@ | |||
27 | #include "pcf50606.h" | 27 | #include "pcf50606.h" |
28 | #include "lcd-remote-target.h" | 28 | #include "lcd-remote-target.h" |
29 | 29 | ||
30 | #ifndef SIMULATOR | ||
31 | |||
32 | void power_init(void) | 30 | void power_init(void) |
33 | { | 31 | { |
34 | /* Charger detect */ | 32 | /* Charger detect */ |
@@ -38,9 +36,10 @@ void power_init(void) | |||
38 | pcf50606_init(); | 36 | pcf50606_init(); |
39 | } | 37 | } |
40 | 38 | ||
41 | bool charger_inserted(void) | 39 | unsigned int power_input_status(void) |
42 | { | 40 | { |
43 | return (GPIO1_READ & 0x01000000) != 0; | 41 | return (GPIO1_READ & 0x01000000) ? |
42 | POWER_INPUT_MAIN_CHARGER : POWER_INPUT_NONE; | ||
44 | } | 43 | } |
45 | 44 | ||
46 | void ide_power_enable(bool on) | 45 | void ide_power_enable(bool on) |
@@ -66,5 +65,3 @@ void power_off(void) | |||
66 | and_l(~0x00000008, &GPIO_OUT); /* Set KEEPACT low */ | 65 | and_l(~0x00000008, &GPIO_OUT); /* Set KEEPACT low */ |
67 | asm("halt"); | 66 | asm("halt"); |
68 | } | 67 | } |
69 | |||
70 | #endif /* SIMULATOR */ | ||
diff --git a/firmware/target/coldfire/iaudio/x5/power-x5.c b/firmware/target/coldfire/iaudio/x5/power-x5.c index 22f56961bf..4feb9c15d0 100644 --- a/firmware/target/coldfire/iaudio/x5/power-x5.c +++ b/firmware/target/coldfire/iaudio/x5/power-x5.c | |||
@@ -27,8 +27,6 @@ | |||
27 | #include "pcf50606.h" | 27 | #include "pcf50606.h" |
28 | #include "lcd-remote-target.h" | 28 | #include "lcd-remote-target.h" |
29 | 29 | ||
30 | #ifndef SIMULATOR | ||
31 | |||
32 | void power_init(void) | 30 | void power_init(void) |
33 | { | 31 | { |
34 | /* Charger detect */ | 32 | /* Charger detect */ |
@@ -38,9 +36,10 @@ void power_init(void) | |||
38 | pcf50606_init(); | 36 | pcf50606_init(); |
39 | } | 37 | } |
40 | 38 | ||
41 | bool charger_inserted(void) | 39 | unsigned int power_input_status(void) |
42 | { | 40 | { |
43 | return (GPIO1_READ & 0x01000000) != 0; | 41 | return (GPIO1_READ & 0x01000000) ? |
42 | POWER_INPUT_MAIN_CHARGER : POWER_INPUT_NONE; | ||
44 | } | 43 | } |
45 | 44 | ||
46 | void ide_power_enable(bool on) | 45 | void ide_power_enable(bool on) |
@@ -67,8 +66,6 @@ void power_off(void) | |||
67 | asm("halt"); | 66 | asm("halt"); |
68 | } | 67 | } |
69 | 68 | ||
70 | #endif /* SIMULATOR */ | ||
71 | |||
72 | bool tuner_power(bool status) | 69 | bool tuner_power(bool status) |
73 | { | 70 | { |
74 | (void)status; | 71 | (void)status; |
diff --git a/firmware/target/coldfire/iriver/h100/power-h100.c b/firmware/target/coldfire/iriver/h100/power-h100.c index 6eb403732d..2717e42f4a 100644 --- a/firmware/target/coldfire/iriver/h100/power-h100.c +++ b/firmware/target/coldfire/iriver/h100/power-h100.c | |||
@@ -26,19 +26,14 @@ | |||
26 | #include "power.h" | 26 | #include "power.h" |
27 | #include "spdif.h" | 27 | #include "spdif.h" |
28 | 28 | ||
29 | |||
30 | #if CONFIG_TUNER | 29 | #if CONFIG_TUNER |
31 | |||
32 | bool tuner_power(bool status) | 30 | bool tuner_power(bool status) |
33 | { | 31 | { |
34 | (void)status; | 32 | (void)status; |
35 | return true; | 33 | return true; |
36 | } | 34 | } |
37 | |||
38 | #endif /* #if CONFIG_TUNER */ | 35 | #endif /* #if CONFIG_TUNER */ |
39 | 36 | ||
40 | #ifndef SIMULATOR | ||
41 | |||
42 | void power_init(void) | 37 | void power_init(void) |
43 | { | 38 | { |
44 | or_l(0x00080000, &GPIO1_OUT); | 39 | or_l(0x00080000, &GPIO1_OUT); |
@@ -56,14 +51,16 @@ void power_init(void) | |||
56 | #endif | 51 | #endif |
57 | } | 52 | } |
58 | 53 | ||
59 | 54 | unsigned int power_input_status(void) | |
60 | bool charger_inserted(void) | 55 | { |
61 | { | 56 | return (GPIO1_READ & 0x00400000) ? |
62 | return (GPIO1_READ & 0x00400000)?true:false; | 57 | POWER_INPUT_MAIN_CHARGER : POWER_INPUT_NONE; |
63 | } | 58 | } |
59 | |||
64 | /* Returns true if the unit is charging the batteries. */ | 60 | /* Returns true if the unit is charging the batteries. */ |
65 | bool charging_state(void) { | 61 | bool charging_state(void) |
66 | return charger_inserted(); | 62 | { |
63 | return (power_input_status() & POWER_INPUT_CHARGER) != 0; | ||
67 | } | 64 | } |
68 | 65 | ||
69 | #ifdef HAVE_SPDIF_POWER | 66 | #ifdef HAVE_SPDIF_POWER |
@@ -119,5 +116,3 @@ void power_off(void) | |||
119 | asm("halt"); | 116 | asm("halt"); |
120 | while(1); | 117 | while(1); |
121 | } | 118 | } |
122 | |||
123 | #endif /* SIMULATOR */ | ||
diff --git a/firmware/target/coldfire/iriver/h300/power-h300.c b/firmware/target/coldfire/iriver/h300/power-h300.c index ea66625794..400dc02526 100644 --- a/firmware/target/coldfire/iriver/h300/power-h300.c +++ b/firmware/target/coldfire/iriver/h300/power-h300.c | |||
@@ -25,20 +25,18 @@ | |||
25 | #include "system.h" | 25 | #include "system.h" |
26 | #include "power.h" | 26 | #include "power.h" |
27 | #include "pcf50606.h" | 27 | #include "pcf50606.h" |
28 | #include "usb.h" | ||
29 | #include "logf.h" | ||
28 | 30 | ||
29 | 31 | ||
30 | #if CONFIG_TUNER | 32 | #if CONFIG_TUNER |
31 | |||
32 | bool tuner_power(bool status) | 33 | bool tuner_power(bool status) |
33 | { | 34 | { |
34 | (void)status; | 35 | (void)status; |
35 | return true; | 36 | return true; |
36 | } | 37 | } |
37 | |||
38 | #endif /* #if CONFIG_TUNER */ | 38 | #endif /* #if CONFIG_TUNER */ |
39 | 39 | ||
40 | #ifndef SIMULATOR | ||
41 | |||
42 | void power_init(void) | 40 | void power_init(void) |
43 | { | 41 | { |
44 | or_l(0x00080000, &GPIO1_OUT); | 42 | or_l(0x00080000, &GPIO1_OUT); |
@@ -56,17 +54,54 @@ void power_init(void) | |||
56 | 54 | ||
57 | 55 | ||
58 | #if CONFIG_CHARGING | 56 | #if CONFIG_CHARGING |
59 | bool charger_inserted(void) | 57 | unsigned int power_input_status(void) |
60 | { | 58 | { |
61 | return (GPIO1_READ & 0x00400000)?true:false; | 59 | unsigned int status = POWER_INPUT_NONE; |
60 | |||
61 | if (GPIO1_READ & 0x00400000) | ||
62 | status |= POWER_INPUT_MAIN_CHARGER; | ||
63 | |||
64 | #ifdef HAVE_USB_POWER | ||
65 | if (usb_detect() == USB_INSERTED && pcf50606_usb_charging_enabled()) | ||
66 | status |= POWER_INPUT_USB_CHARGER; | ||
67 | /* CHECK: Can the device be powered from USB w/o charging it? */ | ||
68 | #endif | ||
69 | |||
70 | return status; | ||
62 | } | 71 | } |
72 | |||
73 | #ifdef HAVE_USB_POWER | ||
74 | bool usb_charging_enable(bool on) | ||
75 | { | ||
76 | bool rc = false; | ||
77 | int irqlevel; | ||
78 | logf("usb_charging_enable(%s)\n", on ? "on" : "off" ); | ||
79 | irqlevel = disable_irq_save(); | ||
80 | pcf50606_set_usb_charging(on); | ||
81 | rc = on; | ||
82 | restore_irq(irqlevel); | ||
83 | return rc; | ||
84 | } | ||
85 | #endif /* HAVE_USB_POWER */ | ||
86 | |||
63 | #endif /* CONFIG_CHARGING */ | 87 | #endif /* CONFIG_CHARGING */ |
64 | 88 | ||
65 | /* Returns true if the unit is charging the batteries. */ | 89 | /* Returns true if the unit is charging the batteries. */ |
66 | bool charging_state(void) { | 90 | bool charging_state(void) |
91 | { | ||
67 | return (GPIO_READ & 0x00800000)?true:false; | 92 | return (GPIO_READ & 0x00800000)?true:false; |
68 | } | 93 | } |
69 | 94 | ||
95 | bool usb_charging_enabled(void) | ||
96 | { | ||
97 | bool rc = false; | ||
98 | /* TODO: read the state of the GPOOD2 register... | ||
99 | * (this also means to set the irq level here) */ | ||
100 | rc = pcf50606_usb_charging_enabled(); | ||
101 | |||
102 | logf("usb charging %s", rc ? "enabled" : "disabled" ); | ||
103 | return rc; | ||
104 | } | ||
70 | 105 | ||
71 | void ide_power_enable(bool on) | 106 | void ide_power_enable(bool on) |
72 | { | 107 | { |
@@ -90,5 +125,3 @@ void power_off(void) | |||
90 | asm("halt"); | 125 | asm("halt"); |
91 | while(1); | 126 | while(1); |
92 | } | 127 | } |
93 | |||
94 | #endif /* SIMULATOR */ | ||