diff options
-rw-r--r-- | docs/CREDITS | 1 | ||||
-rw-r--r-- | firmware/drivers/pcf50635.c | 4 | ||||
-rw-r--r-- | firmware/target/arm/tcc780x/cowond2/power-cowond2.c | 34 |
3 files changed, 35 insertions, 4 deletions
diff --git a/docs/CREDITS b/docs/CREDITS index 01a976e92d..1558b84f26 100644 --- a/docs/CREDITS +++ b/docs/CREDITS | |||
@@ -605,6 +605,7 @@ Michael Goerner | |||
605 | Richard Brittain | 605 | Richard Brittain |
606 | Andrew Ryabinin | 606 | Andrew Ryabinin |
607 | Maksim Postolati | 607 | Maksim Postolati |
608 | Stanislav Chizhik | ||
608 | 609 | ||
609 | The libmad team | 610 | The libmad team |
610 | The wavpack team | 611 | The wavpack team |
diff --git a/firmware/drivers/pcf50635.c b/firmware/drivers/pcf50635.c index 9ccf5e29e2..38104b8d04 100644 --- a/firmware/drivers/pcf50635.c +++ b/firmware/drivers/pcf50635.c | |||
@@ -102,9 +102,9 @@ void pcf50635_init(void) | |||
102 | PCF5063X_REG_GPIO3CFG, 0x0, | 102 | PCF5063X_REG_GPIO3CFG, 0x0, |
103 | 103 | ||
104 | /* IRQ masks (OF values in brackets) */ | 104 | /* IRQ masks (OF values in brackets) */ |
105 | PCF5063X_REG_INT1M, 0xff, /* (0x8a enable alarm, usbins, adpins) */ | 105 | PCF5063X_REG_INT1M, 0xfa, /* (0x8a enable alarm, usbins, adpins) */ |
106 | PCF5063X_REG_INT2M, 0xff, /* (0xff all masked) */ | 106 | PCF5063X_REG_INT2M, 0xff, /* (0xff all masked) */ |
107 | PCF5063X_REG_INT3M, 0xff, /* (0x7f enable onkey1s) */ | 107 | PCF5063X_REG_INT3M, 0x7f, /* (0x7f enable onkey1s) */ |
108 | PCF5063X_REG_INT4M, 0xff, /* (0xfd enable lowbat) */ | 108 | PCF5063X_REG_INT4M, 0xff, /* (0xfd enable lowbat) */ |
109 | PCF5063X_REG_INT5M, 0xff, /* (0xff all masked) */ | 109 | PCF5063X_REG_INT5M, 0xff, /* (0xff all masked) */ |
110 | 110 | ||
diff --git a/firmware/target/arm/tcc780x/cowond2/power-cowond2.c b/firmware/target/arm/tcc780x/cowond2/power-cowond2.c index 7e8f066c58..02e0282ead 100644 --- a/firmware/target/arm/tcc780x/cowond2/power-cowond2.c +++ b/firmware/target/arm/tcc780x/cowond2/power-cowond2.c | |||
@@ -51,6 +51,10 @@ void power_init(void) | |||
51 | pmu = PCF50635; | 51 | pmu = PCF50635; |
52 | 52 | ||
53 | pcf50635_init(); | 53 | pcf50635_init(); |
54 | |||
55 | /* Clear pending interrupts from pcf50635 */ | ||
56 | unsigned char data[5]; /* 0 = INT1, 1 = INT2, 2 = INT3, ... 4 = INT5 */ | ||
57 | pcf50635_read_multiple(PCF5063X_REG_INT1, data, 5); | ||
54 | } | 58 | } |
55 | else | 59 | else |
56 | { | 60 | { |
@@ -64,11 +68,11 @@ void power_init(void) | |||
64 | /* Clear pending interrupts */ | 68 | /* Clear pending interrupts */ |
65 | unsigned char data[3]; /* 0 = INT1, 1 = INT2, 2 = INT3 */ | 69 | unsigned char data[3]; /* 0 = INT1, 1 = INT2, 2 = INT3 */ |
66 | pcf50606_read_multiple(0x02, data, 3); | 70 | pcf50606_read_multiple(0x02, data, 3); |
71 | } | ||
67 | 72 | ||
68 | #ifndef BOOTLOADER | 73 | #ifndef BOOTLOADER |
69 | IEN |= EXT3_IRQ_MASK; /* Unmask EXT3 */ | 74 | IEN |= EXT3_IRQ_MASK; /* Unmask EXT3 */ |
70 | #endif | 75 | #endif |
71 | } | ||
72 | } | 76 | } |
73 | 77 | ||
74 | void power_off(void) | 78 | void power_off(void) |
@@ -85,6 +89,8 @@ void power_off(void) | |||
85 | #ifndef BOOTLOADER | 89 | #ifndef BOOTLOADER |
86 | void EXT3(void) | 90 | void EXT3(void) |
87 | { | 91 | { |
92 | if (get_pmu_type() == PCF50606) | ||
93 | { | ||
88 | unsigned char data[3]; /* 0 = INT1, 1 = INT2, 2 = INT3 */ | 94 | unsigned char data[3]; /* 0 = INT1, 1 = INT2, 2 = INT3 */ |
89 | 95 | ||
90 | /* Clear pending interrupts from pcf50606 */ | 96 | /* Clear pending interrupts from pcf50606 */ |
@@ -104,6 +110,21 @@ void EXT3(void) | |||
104 | /* Touchscreen event, do something about it */ | 110 | /* Touchscreen event, do something about it */ |
105 | touchscreen_handle_device_irq(); | 111 | touchscreen_handle_device_irq(); |
106 | } | 112 | } |
113 | } | ||
114 | else | ||
115 | { | ||
116 | unsigned char data[5]; /* 0 = INT1, 1 = INT2, 2 = INT3, ... 4 = INT5 */ | ||
117 | |||
118 | /* Clear pending interrupts from pcf50635 */ | ||
119 | pcf50635_read_multiple(PCF5063X_REG_INT1, data, 5); | ||
120 | |||
121 | if (data[2] & PCF5063X_INT3_ONKEY1S) | ||
122 | { | ||
123 | |||
124 | if (!charger_inserted()) | ||
125 | sys_poweroff(); | ||
126 | } | ||
127 | } | ||
107 | } | 128 | } |
108 | #endif | 129 | #endif |
109 | 130 | ||
@@ -126,7 +147,16 @@ unsigned int power_input_status(void) | |||
126 | } | 147 | } |
127 | else | 148 | else |
128 | { | 149 | { |
129 | /* TODO: use adapter/usb connection state from PCF50635 driver */ | 150 | /* pcf50635 power input status can be obtained from MBCS1 register */ |
151 | |||
152 | int mbcs1 = pcf50635_read(PCF5063X_REG_MBCS1); | ||
153 | /* Check AC adapter presence*/ | ||
154 | if (mbcs1 & PCF5063X_MBCS1_ADAPTPRES) | ||
155 | return POWER_INPUT_MAIN_CHARGER; | ||
156 | |||
157 | /* Check USB presence */ | ||
158 | if (mbcs1 & PCF5063X_MBCS1_USBPRES) | ||
159 | return POWER_INPUT_USB_CHARGER; | ||
130 | } | 160 | } |
131 | 161 | ||
132 | return POWER_INPUT_NONE; | 162 | return POWER_INPUT_NONE; |