summaryrefslogtreecommitdiff
path: root/firmware/target/arm/tcc780x/cowond2/power-cowond2.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/tcc780x/cowond2/power-cowond2.c')
-rw-r--r--firmware/target/arm/tcc780x/cowond2/power-cowond2.c60
1 files changed, 40 insertions, 20 deletions
diff --git a/firmware/target/arm/tcc780x/cowond2/power-cowond2.c b/firmware/target/arm/tcc780x/cowond2/power-cowond2.c
index 8190108dd4..d5f4ec9768 100644
--- a/firmware/target/arm/tcc780x/cowond2/power-cowond2.c
+++ b/firmware/target/arm/tcc780x/cowond2/power-cowond2.c
@@ -23,31 +23,51 @@
23#include "system.h" 23#include "system.h"
24#include "power.h" 24#include "power.h"
25#include "pcf50606.h" 25#include "pcf50606.h"
26#include "pcf50635.h"
26#include "button-target.h" 27#include "button-target.h"
27#include "tuner.h" 28#include "tuner.h"
28#include "backlight-target.h" 29#include "backlight-target.h"
29#include "powermgmt.h" 30#include "powermgmt.h"
31#include "power-target.h"
32
33static enum pmu_type pmu;
34
35enum pmu_type get_pmu_type()
36{
37 return pmu;
38}
30 39
31void power_init(void) 40void power_init(void)
32{ 41{
33 unsigned char data[3]; /* 0 = INT1, 1 = INT2, 2 = INT3 */ 42 /* Configure GPA6 as input and wait a short while */
43 GPIOA_DIR &= ~(1<<6);
34 44
35 /* Clear pending interrupts from pcf50606 */ 45 udelay(10);
36 pcf50606_read_multiple(0x02, data, 3); 46
37 47 /* Value of GPA6 determines PMU chip type */
38 /* Set outputs as per OF - further investigation required. */ 48 if (GPIOA & (1<<6))
39 pcf50606_write(PCF5060X_DCDEC1, 0xe4); 49 {
40 pcf50606_write(PCF5060X_IOREGC, 0xf5); 50 pmu = PCF50635;
41 pcf50606_write(PCF5060X_D1REGC1, 0xf5); 51
42 pcf50606_write(PCF5060X_D2REGC1, 0xe9); 52 pcf50635_init();
43 pcf50606_write(PCF5060X_D3REGC1, 0xf8); /* WM8985 3.3v */ 53 }
44 pcf50606_write(PCF5060X_DCUDC1, 0xe7); 54 else
45 pcf50606_write(PCF5060X_LPREGC1, 0x0); 55 {
46 pcf50606_write(PCF5060X_LPREGC2, 0x2); 56 pmu = PCF50606;
57
58 /* Configure GPA6 for output (backlight enable) */
59 GPIOA_DIR |= (1<<6);
60
61 pcf50606_init();
62
63 /* Clear pending interrupts */
64 unsigned char data[3]; /* 0 = INT1, 1 = INT2, 2 = INT3 */
65 pcf50606_read_multiple(0x02, data, 3);
47 66
48#ifndef BOOTLOADER 67#ifndef BOOTLOADER
49 IEN |= EXT3_IRQ_MASK; /* Unmask EXT3 */ 68 IEN |= EXT3_IRQ_MASK; /* Unmask EXT3 */
50#endif 69#endif
70 }
51} 71}
52 72
53void power_off(void) 73void power_off(void)
@@ -55,7 +75,7 @@ void power_off(void)
55 /* Turn the backlight off first to avoid a bright stripe on power-off */ 75 /* Turn the backlight off first to avoid a bright stripe on power-off */
56 _backlight_off(); 76 _backlight_off();
57 sleep(HZ/10); 77 sleep(HZ/10);
58 78
59 /* Power off the player using the same mechanism as the OF */ 79 /* Power off the player using the same mechanism as the OF */
60 GPIOA_CLEAR = (1<<7); 80 GPIOA_CLEAR = (1<<7);
61 while(true); 81 while(true);
@@ -114,15 +134,15 @@ bool tuner_power(bool status)
114 in host read mode: */ 134 in host read mode: */
115 135
116 /* 1. Set direction of the DATA-line to input-mode. */ 136 /* 1. Set direction of the DATA-line to input-mode. */
117 GPIOC_DIR &= ~(1 << 30); 137 GPIOC_DIR &= ~(1 << 30);
118 138
119 /* 2. Drive NR_W low */ 139 /* 2. Drive NR_W low */
120 GPIOC_CLEAR = (1 << 31); 140 GPIOC_CLEAR = (1 << 31);
121 GPIOC_DIR |= (1 << 31); 141 GPIOC_DIR |= (1 << 31);
122 142
123 /* 3. Drive CLOCK high */ 143 /* 3. Drive CLOCK high */
124 GPIOC_SET = (1 << 29); 144 GPIOC_SET = (1 << 29);
125 GPIOC_DIR |= (1 << 29); 145 GPIOC_DIR |= (1 << 29);
126 146
127 lv24020lp_power(true); 147 lv24020lp_power(true);
128 } 148 }