2005-12-11 10:52:17 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
2005-12-19 14:30:52 +00:00
|
|
|
* Driver for pcf50605 PMU and RTC
|
2005-12-11 10:52:17 +00:00
|
|
|
*
|
2005-12-19 14:30:52 +00:00
|
|
|
* Based on code from the ipodlinux project - http://ipodlinux.org/
|
|
|
|
* Adapted for Rockbox in December 2005
|
|
|
|
*
|
|
|
|
* Original file: linux/arch/armnommu/mach-ipod/pcf50605.c
|
|
|
|
*
|
|
|
|
* Copyright (c) 2003-2005 Bernard Leach (leachbj@bouncycastle.org)
|
2005-12-11 10:52:17 +00:00
|
|
|
*
|
|
|
|
* All files in this archive are subject to the GNU General Public License.
|
|
|
|
* See the file COPYING in the source tree root for full license agreement.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
2006-03-09 19:47:12 +00:00
|
|
|
#include "system.h"
|
2005-12-11 10:52:17 +00:00
|
|
|
#include "config.h"
|
2007-01-27 20:39:09 +00:00
|
|
|
#if CONFIG_I2C == I2C_PP5020 || CONFIG_I2C == I2C_PP5002
|
|
|
|
#include "i2c-pp.h"
|
2006-02-05 17:16:34 +00:00
|
|
|
#endif
|
2005-12-11 10:52:17 +00:00
|
|
|
#include "rtc.h"
|
|
|
|
|
2005-12-21 23:32:19 +00:00
|
|
|
#define OOCS 0x01
|
|
|
|
#define INT1 0x02
|
|
|
|
#define INT2 0x03
|
|
|
|
#define INT3 0x04
|
|
|
|
#define INT1M 0x05
|
|
|
|
#define INT2M 0x06
|
|
|
|
#define INT3M 0x07
|
|
|
|
#define OOCC1 0x08
|
|
|
|
#define GOSTDBY 0x1
|
|
|
|
#define TOTRST (0x1 << 1)
|
|
|
|
#define CLK32ON (0x1 << 2)
|
|
|
|
#define WDTRST (0x1 << 3)
|
|
|
|
#define RTCWAK (0x1 << 4)
|
|
|
|
#define CHGWAK (0x1 << 5)
|
|
|
|
#define EXTONWAK (0x01 << 6)
|
|
|
|
#define OOCC2 0x09
|
|
|
|
#define RTCSC 0x0a
|
|
|
|
#define RTCMN 0x0b
|
|
|
|
#define RTCHR 0x0c
|
|
|
|
#define RTCWD 0x0d
|
|
|
|
#define RTCDT 0x0e
|
|
|
|
#define RTCMT 0x0f
|
|
|
|
#define RTCYR 0x10
|
|
|
|
#define RTCSCA 0x11
|
|
|
|
#define RTCMNA 0x12
|
|
|
|
#define RTCHRA 0x13
|
|
|
|
#define RTCWDA 0x14
|
|
|
|
#define RTCDTA 0x15
|
|
|
|
#define RTCMTA 0x16
|
|
|
|
#define RTCYRA 0x17
|
|
|
|
#define PSSC 0x18
|
|
|
|
#define PWROKM 0x19
|
|
|
|
#define PWROKS 0x1a
|
2006-05-02 08:08:10 +00:00
|
|
|
#define D1REGC1 0x24
|
|
|
|
#define VOUT_3000mV 0xf5
|
|
|
|
#define VOUT_3300mV 0xf8
|
|
|
|
#define D2REGC1 0x25
|
|
|
|
#define D3REGC1 0x26
|
|
|
|
|
2005-12-21 23:32:19 +00:00
|
|
|
|
2005-12-11 10:52:17 +00:00
|
|
|
int pcf50605_read(int address)
|
|
|
|
{
|
|
|
|
return i2c_readbyte(0x8,address);
|
|
|
|
}
|
|
|
|
|
|
|
|
int pcf50605_read_multiple(int address, unsigned char* buf, int count)
|
|
|
|
{
|
2006-03-09 19:47:12 +00:00
|
|
|
int read = i2c_readbytes(0x08, address, count, buf);
|
|
|
|
return read - count;
|
2005-12-11 10:52:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int pcf50605_write(int address, unsigned char val)
|
|
|
|
{
|
2006-10-27 11:24:23 +00:00
|
|
|
pp_i2c_send(0x8, address, val);
|
2005-12-11 10:52:17 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int pcf50605_write_multiple(int address, const unsigned char* buf, int count)
|
|
|
|
{
|
|
|
|
/* TODO */
|
|
|
|
(void)address;
|
|
|
|
(void)buf;
|
|
|
|
(void)count;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-12-21 23:32:19 +00:00
|
|
|
/* The following command puts the iPod into a deep sleep. Warning
|
|
|
|
from the good people of ipodlinux - never issue this command
|
|
|
|
without setting CHGWAK or EXTONWAK if you ever want to be able to
|
|
|
|
power on your iPod again. */
|
|
|
|
void pcf50605_standby_mode(void)
|
|
|
|
{
|
|
|
|
pcf50605_write(OOCC1, GOSTDBY | CHGWAK | EXTONWAK);
|
|
|
|
}
|
|
|
|
|
2006-05-02 08:08:10 +00:00
|
|
|
void pcf50605_init(void)
|
|
|
|
{
|
|
|
|
/* The following values were taken from the ipodlinux kernel source */
|
|
|
|
pcf50605_write(D1REGC1, VOUT_3000mV); /* Unknown */
|
|
|
|
pcf50605_write(D2REGC1, VOUT_3300mV); /* Dock Connector pin 17 */
|
|
|
|
pcf50605_write(D3REGC1, VOUT_3000mV); /* Unknown */
|
|
|
|
}
|