1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Driver for pcf50605 PMU and RTC
12 * Based on code from the ipodlinux project - http://ipodlinux.org/
13 * Adapted for Rockbox in December 2005
15 * Original file: linux/arch/armnommu/mach-ipod/pcf50605.c
17 * Copyright (c) 2003-2005 Bernard Leach (leachbj@bouncycastle.org)
19 * All files in this archive are subject to the GNU General Public License.
20 * See the file COPYING in the source tree root for full license agreement.
22 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
23 * KIND, either express or implied.
25 ****************************************************************************/
28 #if CONFIG_I2C == I2C_PP5020 || CONFIG_I2C == I2C_PP5002
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)
81 unsigned char pcf50605_wakeup_flags
= 0;
83 int pcf50605_read(int address
)
85 return i2c_readbyte(0x8,address
);
88 int pcf50605_read_multiple(int address
, unsigned char* buf
, int count
)
90 int read
= i2c_readbytes(0x08, address
, count
, buf
);
94 int pcf50605_write(int address
, unsigned char val
)
96 pp_i2c_send(0x8, address
, val
);
100 int pcf50605_write_multiple(int address
, const unsigned char* buf
, int count
)
106 for (i
= 0; i
< count
; i
++)
107 pp_i2c_send(0x8, address
+ i
, buf
[i
]);
114 /* The following command puts the iPod into a deep sleep. Warning
115 from the good people of ipodlinux - never issue this command
116 without setting CHGWAK or EXTONWAK if you ever want to be able to
117 power on your iPod again. */
118 void pcf50605_standby_mode(void)
120 pcf50605_write(OOCC1
, GOSTDBY
| CHGWAK
| EXTONWAK
| pcf50605_wakeup_flags
);
123 void pcf50605_init(void)
125 #if defined (IPOD_VIDEO)
126 /* I/O and GPO voltage supply (default: 0xf8 = 3.3V ON) */
127 /* ECO not allowed regarding data sheet */
128 pcf50605_write(IOREGC
, 0xf8); /* 3.3V ON */
130 /* core voltage supply (default DCDC1/DCDC2: 0xec = 1.2V ON) */
131 /* ECO not stable, assumed due to less precision of voltage in ECO mode */
132 pcf50605_write(DCDC1
, 0xec); /* 1.2V ON */
133 pcf50605_write(DCDC2
, 0x0c); /* OFF */
135 /* unknown (default: 0xe3 = 1.8V ON) */
136 pcf50605_write(DCUDC1
, 0xe3); /* 1.8V ON */
138 /* WM8758 voltage supply (default: 0xf5 = 3.0V ON) */
139 /* ECO not allowed as max. current of 5mA is not sufficient */
140 pcf50605_write(D1REGC1
, 0xf0); /* 2.5V ON */
142 /* LCD voltage supply (default: 0xf5 = 3.0V ON) */
143 pcf50605_write(D3REGC1
, 0xf1); /* 2.6V ON */
145 /* keep initialization from svn for other iPods */
146 pcf50605_write(D1REGC1
, 0xf5); /* 3.0V ON */
147 pcf50605_write(D3REGC1
, 0xf5); /* 3.0V ON */
149 /* Dock Connector pin 17 (default: OFF) */
150 pcf50605_write(D2REGC1
, 0xf8); /* 3.3V ON */