diff options
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/drivers/pcf50606.c | 24 | ||||
-rw-r--r-- | firmware/drivers/pcf50635.c | 124 |
2 files changed, 91 insertions, 57 deletions
diff --git a/firmware/drivers/pcf50606.c b/firmware/drivers/pcf50606.c index 4ef747fe80..d44718c58b 100644 --- a/firmware/drivers/pcf50606.c +++ b/firmware/drivers/pcf50606.c | |||
@@ -54,15 +54,21 @@ int pcf50606_read_multiple(int address, unsigned char* buf, int count) | |||
54 | void pcf50606_init(void) | 54 | void pcf50606_init(void) |
55 | { | 55 | { |
56 | #ifdef COWON_D2 | 56 | #ifdef COWON_D2 |
57 | /* Set outputs as per OF - further investigation required. */ | 57 | /* Set outputs as per OF - further investigation required. */ |
58 | pcf50606_write(PCF5060X_DCDEC1, 0xe4); | 58 | static const char init_data[] = |
59 | pcf50606_write(PCF5060X_IOREGC, 0xf5); | 59 | {PCF5060X_DCDEC1, 0xe4, |
60 | pcf50606_write(PCF5060X_D1REGC1, 0xf5); | 60 | PCF5060X_IOREGC, 0xf5, |
61 | pcf50606_write(PCF5060X_D2REGC1, 0xe9); | 61 | PCF5060X_D1REGC1, 0xf5, |
62 | pcf50606_write(PCF5060X_D3REGC1, 0xf8); /* WM8985 3.3v */ | 62 | PCF5060X_D2REGC1, 0xe9, |
63 | pcf50606_write(PCF5060X_DCUDC1, 0xe7); | 63 | PCF5060X_D3REGC1, 0xf8, /* WM8985 3.3v */ |
64 | pcf50606_write(PCF5060X_LPREGC1, 0x0); | 64 | PCF5060X_DCUDC1, 0xe7, |
65 | pcf50606_write(PCF5060X_LPREGC2, 0x2); | 65 | PCF5060X_LPREGC1, 0x0, |
66 | PCF5060X_LPREGC2, 0x2, | ||
67 | 0}; | ||
68 | |||
69 | const char* ptr; | ||
70 | for (ptr = init_data; *ptr != 0; ptr += 2) | ||
71 | pcf50606_write(ptr[0], ptr[1]); | ||
66 | #endif | 72 | #endif |
67 | } | 73 | } |
68 | 74 | ||
diff --git a/firmware/drivers/pcf50635.c b/firmware/drivers/pcf50635.c index c436498670..9ccf5e29e2 100644 --- a/firmware/drivers/pcf50635.c +++ b/firmware/drivers/pcf50635.c | |||
@@ -55,56 +55,84 @@ int pcf50635_read_multiple(int address, unsigned char* buf, int count) | |||
55 | void pcf50635_init(void) | 55 | void pcf50635_init(void) |
56 | { | 56 | { |
57 | #ifdef COWON_D2 | 57 | #ifdef COWON_D2 |
58 | /* Configure outputs as per OF */ | 58 | static const char init_data[] = |
59 | pcf50635_write(PCF5063X_REG_DOWN1OUT, 0x13); /* DOWN1 = 1.2V */ | 59 | { |
60 | pcf50635_write(PCF5063X_REG_DOWN1CTL, 0x1e); /* DOWN1 DVM step = max */ | 60 | /* DOWN1: 1.2V, max DVM step, enabled */ |
61 | pcf50635_write(PCF5063X_REG_DOWN1ENA, 0x1); /* DOWN1 enable */ | 61 | PCF5063X_REG_DOWN1OUT, 0x13, |
62 | pcf50635_write(PCF5063X_REG_DOWN2OUT, 0x2f); /* DOWN2 = 1.8V */ | 62 | PCF5063X_REG_DOWN1CTL, 0x1e, |
63 | pcf50635_write(PCF5063X_REG_DOWN2CTL, 0x1e); /* DOWN2 DVM step = max */ | 63 | PCF5063X_REG_DOWN1ENA, 0x1, |
64 | pcf50635_write(PCF5063X_REG_DOWN2ENA, 0x1); /* DOWN2 enable */ | 64 | |
65 | pcf50635_write(PCF5063X_REG_AUTOOUT, 0x5f); /* AUTO = 3.0V */ | 65 | /* DOWN2: 1.8V, max DVM step, enabled */ |
66 | pcf50635_write(PCF5063X_REG_AUTOENA, 0x1); /* AUTO enable */ | 66 | PCF5063X_REG_DOWN2OUT, 0x2f, |
67 | pcf50635_write(PCF5063X_REG_LDO1OUT, 0x18); /* LDO1 = 3.3V */ | 67 | PCF5063X_REG_DOWN2CTL, 0x1e, |
68 | pcf50635_write(PCF5063X_REG_LDO1ENA, 0x1); /* LDO1 enable */ | 68 | PCF5063X_REG_DOWN2ENA, 0x1, |
69 | pcf50635_write(PCF5063X_REG_LDO2OUT, 0x15); /* LDO2 = 3.0V */ | 69 | |
70 | pcf50635_write(PCF5063X_REG_LDO2ENA, 0x1); /* LDO2 enable */ | 70 | /* AUTO: 3.0V, enabled */ |
71 | pcf50635_write(PCF5063X_REG_LDO3ENA, 0x0); /* LDO3 disable */ | 71 | PCF5063X_REG_AUTOOUT, 0x5f, |
72 | pcf50635_write(PCF5063X_REG_LDO4OUT, 0x15); /* LDO4 = 3.0V */ | 72 | PCF5063X_REG_AUTOENA, 0x1, |
73 | pcf50635_write(PCF5063X_REG_LDO4ENA, 0x1); /* LDO4 enable */ | 73 | |
74 | pcf50635_write(PCF5063X_REG_LDO5OUT, 0x9); /* LDO5 = 1.8V */ | 74 | /* LDO1: 3.3V, enabled */ |
75 | pcf50635_write(PCF5063X_REG_LDO5ENA, 0x1); /* LDO4 enable */ | 75 | PCF5063X_REG_LDO1OUT, 0x18, |
76 | pcf50635_write(PCF5063X_REG_LDO6OUT, 0xc); /* LDO6 = 2.1V */ | 76 | PCF5063X_REG_LDO1ENA, 0x1, |
77 | pcf50635_write(PCF5063X_REG_LDO6ENA, 0x1); /* LDO4 enable */ | 77 | |
78 | pcf50635_write(PCF5063X_REG_HCLDOENA, 0x0); /* HCLDO disable */ | 78 | /* LDO2: 3.0V, enabled */ |
79 | 79 | PCF5063X_REG_LDO2OUT, 0x15, | |
80 | /* Configure automatic battery charging as per OF */ | 80 | PCF5063X_REG_LDO2ENA, 0x1, |
81 | |||
82 | /* LDO4: 3.0V, enabled */ | ||
83 | PCF5063X_REG_LDO4OUT, 0x15, | ||
84 | PCF5063X_REG_LDO4ENA, 0x1, | ||
85 | |||
86 | /* LDO5: 1.8V, enabled */ | ||
87 | PCF5063X_REG_LDO5OUT, 0x9, | ||
88 | PCF5063X_REG_LDO5ENA, 0x1, | ||
89 | |||
90 | /* LDO6: 2.1V, enabled */ | ||
91 | PCF5063X_REG_LDO6OUT, 0xc, | ||
92 | PCF5063X_REG_LDO6ENA, 0x1, | ||
93 | |||
94 | /* LDO3 and HCLDO disabled */ | ||
95 | PCF5063X_REG_LDO3ENA, 0x0, | ||
96 | PCF5063X_REG_HCLDOENA, 0x0, | ||
97 | |||
98 | /* Disable GPIOs */ | ||
99 | PCF5063X_REG_GPIOCTL, 0x0, | ||
100 | PCF5063X_REG_GPIO1CFG, 0x0, | ||
101 | PCF5063X_REG_GPIO2CFG, 0x0, | ||
102 | PCF5063X_REG_GPIO3CFG, 0x0, | ||
103 | |||
104 | /* IRQ masks (OF values in brackets) */ | ||
105 | PCF5063X_REG_INT1M, 0xff, /* (0x8a enable alarm, usbins, adpins) */ | ||
106 | PCF5063X_REG_INT2M, 0xff, /* (0xff all masked) */ | ||
107 | PCF5063X_REG_INT3M, 0xff, /* (0x7f enable onkey1s) */ | ||
108 | PCF5063X_REG_INT4M, 0xff, /* (0xfd enable lowbat) */ | ||
109 | PCF5063X_REG_INT5M, 0xff, /* (0xff all masked) */ | ||
110 | |||
111 | /* Wakeup mode */ | ||
112 | PCF5063X_REG_OOCMODE, 0x0, /* onkey falling edge */ | ||
113 | PCF5063X_REG_OOCCTL, 0x2, /* actphrst = phase 3 */ | ||
114 | PCF5063X_REG_OOCWAKE, 0xc1, /* wakeup on adapter, usb, onkey */ | ||
115 | |||
116 | /* Configure battery charger as per OF */ | ||
117 | PCF5063X_REG_MBCC2, 0xa8, /* Vmax = 4.2V, Vbatcond = 2.7V, long debounce */ | ||
118 | PCF5063X_REG_MBCC3, 0x2a, /* precharge level = 16% */ | ||
119 | PCF5063X_REG_MBCC4, 0x94, /* fastcharge level = 58% */ | ||
120 | PCF5063X_REG_MBCC5, 0xff, /* fastcharge level (usb) = 100% */ | ||
121 | PCF5063X_REG_MBCC6, 0x4, /* cutoff level = 12.5% */ | ||
122 | PCF5063X_REG_MBCC7, 0xc1, /* bat-sysImax = 2.2A, USB = 500mA */ | ||
123 | PCF5063X_REG_BVMCTL, 0xe, /* batok level = 3.4V */ | ||
124 | |||
125 | /* end marker */ | ||
126 | 0}; | ||
127 | |||
128 | const char* ptr; | ||
129 | for (ptr = init_data; *ptr != 0; ptr += 2) | ||
130 | pcf50635_write(ptr[0], ptr[1]); | ||
131 | |||
132 | /* Enable automatic charging, preserving default values */ | ||
81 | pcf50635_write(PCF5063X_REG_MBCC1, | 133 | pcf50635_write(PCF5063X_REG_MBCC1, |
82 | pcf50635_read(PCF5063X_REG_MBCC1) | 7); /* auto charge termination & resume */ | 134 | pcf50635_read(PCF5063X_REG_MBCC1) | 7); |
83 | pcf50635_write(PCF5063X_REG_MBCC2, 0xa8); /* Vmax = 4.2V, Vbatcond = 2.7V, long debounce */ | ||
84 | pcf50635_write(PCF5063X_REG_MBCC3, 0x2a); /* precharge level = 16% */ | ||
85 | pcf50635_write(PCF5063X_REG_MBCC4, 0x94); /* fastcharge level = 58% */ | ||
86 | pcf50635_write(PCF5063X_REG_MBCC5, 0xff); /* fastcharge level (usb) = 100% */ | ||
87 | pcf50635_write(PCF5063X_REG_MBCC6, 0x4); /* cutoff level = 12.5% */ | ||
88 | pcf50635_write(PCF5063X_REG_MBCC7, 0xc1); /* bat-sysimax = 2.2A, USB = 500mA */ | ||
89 | pcf50635_write(PCF5063X_REG_BVMCTL, 0xe); /* batok level = 3.4V */ | ||
90 | 135 | ||
91 | /* IRQ masks */ | ||
92 | pcf50635_write(PCF5063X_REG_INT1M, 0x8a); /* enable alarm, usbins, adpins */ | ||
93 | pcf50635_write(PCF5063X_REG_INT2M, 0xff); /* mask all */ | ||
94 | pcf50635_write(PCF5063X_REG_INT3M, 0x7f); /* enable onkey1s */ | ||
95 | pcf50635_write(PCF5063X_REG_INT4M, 0xfd); /* enable lowbat */ | ||
96 | pcf50635_write(PCF5063X_REG_INT5M, 0xff); /* mask all */ | ||
97 | |||
98 | pcf50635_write(PCF5063X_REG_OOCMODE, 0x0); | ||
99 | pcf50635_write(PCF5063X_REG_OOCCTL, 0x2); /* actphrst = phase 3 */ | ||
100 | pcf50635_write(PCF5063X_REG_OOCWAKE, /* adapter, usb, (rtc) wake */ | ||
101 | (pcf50635_read(PCF5063X_REG_OOCWAKE) & 0x10) | 0xc1); | ||
102 | |||
103 | /* We don't care about the GPIOs, disable them */ | ||
104 | pcf50635_write(PCF5063X_REG_GPIOCTL, 0x0); | ||
105 | pcf50635_write(PCF5063X_REG_GPIO1CFG, 0x0); | ||
106 | pcf50635_write(PCF5063X_REG_GPIO2CFG, 0x0); | ||
107 | pcf50635_write(PCF5063X_REG_GPIO3CFG, 0x0); | ||
108 | #endif | 136 | #endif |
109 | } | 137 | } |
110 | 138 | ||