summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Purchase <shotofadds@rockbox.org>2008-04-04 20:24:08 +0000
committerRob Purchase <shotofadds@rockbox.org>2008-04-04 20:24:08 +0000
commit9b691d335ae4bf3d666d7991fedf56731d8f533e (patch)
treecbb8e923b451bdb1fa559998689d6b06c73cfe3f
parentac9b92716a11cf7699f6ce9668b1ca5cd4171cf9 (diff)
downloadrockbox-9b691d335ae4bf3d666d7991fedf56731d8f533e.tar.gz
rockbox-9b691d335ae4bf3d666d7991fedf56731d8f533e.zip
Split out the PCF5060x register defines into a common header and create a generic pcf50606.c using standard i2c read/writes.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16966 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/SOURCES1
-rw-r--r--firmware/drivers/pcf50605.c70
-rw-r--r--firmware/drivers/pcf50606.c45
-rw-r--r--firmware/export/pcf50606.h6
-rw-r--r--firmware/export/pcf5060x.h93
5 files changed, 157 insertions, 58 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES
index 19b160d8d8..fa2222e7d0 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -901,6 +901,7 @@ target/arm/tcc77x/iaudio7/power-iaudio7.c
901 901
902#ifdef COWON_D2 902#ifdef COWON_D2
903#ifndef SIMULATOR 903#ifndef SIMULATOR
904drivers/pcf50606.c
904target/arm/lcd-as-memframe.S 905target/arm/lcd-as-memframe.S
905target/arm/tcc780x/adc-tcc780x.c 906target/arm/tcc780x/adc-tcc780x.c
906target/arm/tcc780x/ata-nand-tcc780x.c 907target/arm/tcc780x/ata-nand-tcc780x.c
diff --git a/firmware/drivers/pcf50605.c b/firmware/drivers/pcf50605.c
index afa0a5ca11..7d88e46aa2 100644
--- a/firmware/drivers/pcf50605.c
+++ b/firmware/drivers/pcf50605.c
@@ -29,54 +29,7 @@
29#include "i2c-pp.h" 29#include "i2c-pp.h"
30#endif 30#endif
31#include "rtc.h" 31#include "rtc.h"
32 32#include "pcf5060x.h"
33#define OOCS 0x01
34#define INT1 0x02
35#define INT2 0x03
36#define INT3 0x04
37#define INT1M 0x05
38#define INT2M 0x06
39#define INT3M 0x07
40#define OOCC1 0x08
41 #define GOSTDBY 0x1
42 #define TOTRST (0x1 << 1)
43 #define CLK32ON (0x1 << 2)
44 #define WDTRST (0x1 << 3)
45 #define RTCWAK (0x1 << 4)
46 #define CHGWAK (0x1 << 5)
47 #define EXTONWAK (0x01 << 6)
48#define OOCC2 0x09
49#define RTCSC 0x0a
50#define RTCMN 0x0b
51#define RTCHR 0x0c
52#define RTCWD 0x0d
53#define RTCDT 0x0e
54#define RTCMT 0x0f
55#define RTCYR 0x10
56#define RTCSCA 0x11
57#define RTCMNA 0x12
58#define RTCHRA 0x13
59#define RTCWDA 0x14
60#define RTCDTA 0x15
61#define RTCMTA 0x16
62#define RTCYRA 0x17
63#define PSSC 0x18
64#define PWROKM 0x19
65#define PWROKS 0x1a
66#define DCDC1 0x1b
67#define DCDC2 0x1c
68#define DCDC3 0x1d
69#define DCDC4 0x1e
70#define DCDEC1 0x1f
71#define DCDEC2 0x20
72#define DCUDC1 0x21
73#define DCUDC2 0x22
74#define IOREGC 0x23
75#define D1REGC1 0x24
76#define D2REGC1 0x25
77#define D3REGC1 0x26
78#define LPREG1C 0x27
79
80 33
81unsigned char pcf50605_wakeup_flags = 0; 34unsigned char pcf50605_wakeup_flags = 0;
82 35
@@ -117,7 +70,8 @@ int pcf50605_write_multiple(int address, const unsigned char* buf, int count)
117 power on your iPod again. */ 70 power on your iPod again. */
118void pcf50605_standby_mode(void) 71void pcf50605_standby_mode(void)
119{ 72{
120 pcf50605_write(OOCC1, GOSTDBY | CHGWAK | EXTONWAK | pcf50605_wakeup_flags); 73 pcf50605_write(PCF5060X_OOCC1,
74 GOSTDBY | CHGWAK | EXTONWAK | pcf50605_wakeup_flags);
121} 75}
122 76
123void pcf50605_init(void) 77void pcf50605_init(void)
@@ -125,27 +79,27 @@ void pcf50605_init(void)
125#if defined (IPOD_VIDEO) 79#if defined (IPOD_VIDEO)
126 /* I/O and GPO voltage supply (default: 0xf8 = 3.3V ON) */ 80 /* I/O and GPO voltage supply (default: 0xf8 = 3.3V ON) */
127 /* ECO not allowed regarding data sheet */ 81 /* ECO not allowed regarding data sheet */
128 pcf50605_write(IOREGC, 0xf8); /* 3.3V ON */ 82 pcf50605_write(PCF5060X_IOREGC, 0xf8); /* 3.3V ON */
129 83
130 /* core voltage supply (default DCDC1/DCDC2: 0xec = 1.2V ON) */ 84 /* core voltage supply (default DCDC1/DCDC2: 0xec = 1.2V ON) */
131 /* ECO not stable, assumed due to less precision of voltage in ECO mode */ 85 /* ECO not stable, assumed due to less precision of voltage in ECO mode */
132 pcf50605_write(DCDC1, 0xec); /* 1.2V ON */ 86 pcf50605_write(PCF5060X_DCDC1, 0xec); /* 1.2V ON */
133 pcf50605_write(DCDC2, 0x0c); /* OFF */ 87 pcf50605_write(PCF5060X_DCDC2, 0x0c); /* OFF */
134 88
135 /* unknown (default: 0xe3 = 1.8V ON) */ 89 /* unknown (default: 0xe3 = 1.8V ON) */
136 pcf50605_write(DCUDC1, 0xe3); /* 1.8V ON */ 90 pcf50605_write(PCF5060X_DCUDC1, 0xe3); /* 1.8V ON */
137 91
138 /* WM8758 voltage supply (default: 0xf5 = 3.0V ON) */ 92 /* WM8758 voltage supply (default: 0xf5 = 3.0V ON) */
139 /* ECO not allowed as max. current of 5mA is not sufficient */ 93 /* ECO not allowed as max. current of 5mA is not sufficient */
140 pcf50605_write(D1REGC1, 0xf0); /* 2.5V ON */ 94 pcf50605_write(PCF5060X_D1REGC1, 0xf0); /* 2.5V ON */
141 95
142 /* LCD voltage supply (default: 0xf5 = 3.0V ON) */ 96 /* LCD voltage supply (default: 0xf5 = 3.0V ON) */
143 pcf50605_write(D3REGC1, 0xf1); /* 2.6V ON */ 97 pcf50605_write(PCF5060X_D3REGC1, 0xf1); /* 2.6V ON */
144#else 98#else
145 /* keep initialization from svn for other iPods */ 99 /* keep initialization from svn for other iPods */
146 pcf50605_write(D1REGC1, 0xf5); /* 3.0V ON */ 100 pcf50605_write(PCF5060X_D1REGC1, 0xf5); /* 3.0V ON */
147 pcf50605_write(D3REGC1, 0xf5); /* 3.0V ON */ 101 pcf50605_write(PCF5060X_D3REGC1, 0xf5); /* 3.0V ON */
148#endif 102#endif
149 /* Dock Connector pin 17 (default: OFF) */ 103 /* Dock Connector pin 17 (default: OFF) */
150 pcf50605_write(D2REGC1, 0xf8); /* 3.3V ON */ 104 pcf50605_write(PCF5060X_D2REGC1, 0xf8); /* 3.3V ON */
151} 105}
diff --git a/firmware/drivers/pcf50606.c b/firmware/drivers/pcf50606.c
new file mode 100644
index 0000000000..a93b94399e
--- /dev/null
+++ b/firmware/drivers/pcf50606.c
@@ -0,0 +1,45 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 by Rob Purchase
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#include "pcf50606.h"
20#include "i2c.h"
21
22#define PCF50606_ADDR 0x10
23
24int pcf50606_write(int address, unsigned char val)
25{
26 unsigned char data[] = { address, val };
27 return i2c_write(PCF50606_ADDR, data, 2);
28}
29
30int pcf50606_read(int address)
31{
32 unsigned char val = -1;
33 i2c_readmem(PCF50606_ADDR, address, &val, 1);
34 return val;
35}
36
37int pcf50606_read_multiple(int address, unsigned char* buf, int count)
38{
39 return i2c_readmem(PCF50606_ADDR, address, buf, count);
40}
41
42void pcf50606_init(void)
43{
44 // TODO
45}
diff --git a/firmware/export/pcf50606.h b/firmware/export/pcf50606.h
index fab7e987d9..44ca24f661 100644
--- a/firmware/export/pcf50606.h
+++ b/firmware/export/pcf50606.h
@@ -19,6 +19,12 @@
19#ifndef PCF50606_H 19#ifndef PCF50606_H
20#define PCF50606_H 20#define PCF50606_H
21 21
22#include "pcf5060x.h"
23#include "system.h"
24
25/* The following functions may either be implemented by an optimised driver
26 in the target tree, or by the generic drivers/pcf50606.c */
27
22void pcf50606_init(void); 28void pcf50606_init(void);
23int pcf50606_write_multiple(int address, const unsigned char* buf, int count); 29int pcf50606_write_multiple(int address, const unsigned char* buf, int count);
24int pcf50606_write(int address, unsigned char val); 30int pcf50606_write(int address, unsigned char val);
diff --git a/firmware/export/pcf5060x.h b/firmware/export/pcf5060x.h
new file mode 100644
index 0000000000..c05ab283e7
--- /dev/null
+++ b/firmware/export/pcf5060x.h
@@ -0,0 +1,93 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 by Rob Purchase
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#ifndef PCF5060X_H
20#define PCF5060X_H
21
22/* PCF50605/6 Registers from datasheet rev2.2 */
23
24#define PCF5060X_ID 0x00
25#define PCF5060X_OOCS 0x01
26#define PCF5060X_INT1 0x02
27#define PCF5060X_INT2 0x03
28#define PCF5060X_INT3 0x04
29#define PCF5060X_INT1M 0x05
30#define PCF5060X_INT2M 0x06
31#define PCF5060X_INT3M 0x07
32#define PCF5060X_OOCC1 0x08
33 #define GOSTDBY 0x1
34 #define TOTRST (0x1 << 1)
35 #define CLK32ON (0x1 << 2)
36 #define WDTRST (0x1 << 3)
37 #define RTCWAK (0x1 << 4)
38 #define CHGWAK (0x1 << 5)
39 #define EXTONWAK (0x01 << 6)
40#define PCF5060X_OOCC2 0x09
41#define PCF5060X_RTCSC 0x0a
42#define PCF5060X_RTCMN 0x0b
43#define PCF5060X_RTCHR 0x0c
44#define PCF5060X_RTCWD 0x0d
45#define PCF5060X_RTCDT 0x0e
46#define PCF5060X_RTCMT 0x0f
47#define PCF5060X_RTCYR 0x10
48#define PCF5060X_RTCSCA 0x11
49#define PCF5060X_RTCMNA 0x12
50#define PCF5060X_RTCHRA 0x13
51#define PCF5060X_RTCWDA 0x14
52#define PCF5060X_RTCDTA 0x15
53#define PCF5060X_RTCMTA 0x16
54#define PCF5060X_RTCYRA 0x17
55#define PCF5060X_PSSC 0x18
56#define PCF5060X_PWROKM 0x19
57#define PCF5060X_PWROKS 0x1a
58#define PCF5060X_DCDC1 0x1b
59#define PCF5060X_DCDC2 0x1c
60#define PCF5060X_DCDC3 0x1d
61#define PCF5060X_DCDC4 0x1e
62#define PCF5060X_DCDEC1 0x1f
63#define PCF5060X_DCDEC2 0x20
64#define PCF5060X_DCUDC1 0x21
65#define PCF5060X_DCUDC2 0x22
66#define PCF5060X_IOREGC 0x23
67#define PCF5060X_D1REGC1 0x24
68#define PCF5060X_D2REGC1 0x25
69#define PCF5060X_D3REGC1 0x26
70#define PCF5060X_LPREGC1 0x27
71#define PCF5060X_LPREGC2 0x28
72#define PCF5060X_MBCC1 0x29
73#define PCF5060X_MBCC2 0x2a
74#define PCF5060X_MBCC3 0x2b
75#define PCF5060X_MBCS1 0x2c
76#define PCF5060X_BBCC 0x2d
77#define PCF5060X_ADCC1 0x2e
78#define PCF5060X_ADCC2 0x2f
79#define PCF5060X_ADCS1 0x30
80#define PCF5060X_ADCS2 0x31
81#define PCF5060X_ADCS3 0x32
82#define PCF5060X_ACDC1 0x33
83#define PCF5060X_BVMC 0x34
84#define PCF5060X_PWMC1 0x35
85#define PCF5060X_LEDC1 0x36
86#define PCF5060X_LEDC2 0x37
87#define PCF5060X_GPOC1 0x38
88#define PCF5060X_GPOC2 0x39
89#define PCF5060X_GPOC3 0x3a
90#define PCF5060X_GPOC4 0x3b
91#define PCF5060X_GPOC5 0x3c
92
93#endif /* PCF5060X_H */