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
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2005-12-11 10:52:17 +00:00
|
|
|
*
|
|
|
|
* 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"
|
2008-04-04 20:24:08 +00:00
|
|
|
#include "pcf5060x.h"
|
2008-07-16 11:02:14 +00:00
|
|
|
#include "pcf50605.h"
|
2006-05-02 08:08:10 +00:00
|
|
|
|
2007-09-28 15:09:54 +00:00
|
|
|
unsigned char pcf50605_wakeup_flags = 0;
|
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)
|
|
|
|
{
|
2007-02-28 21:55:11 +00:00
|
|
|
int i;
|
2007-11-26 07:59:42 +00:00
|
|
|
|
|
|
|
i2c_lock();
|
|
|
|
|
2007-02-28 21:55:11 +00:00
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
pp_i2c_send(0x8, address + i, buf[i]);
|
2007-11-26 07:59:42 +00:00
|
|
|
|
|
|
|
i2c_unlock();
|
|
|
|
|
2005-12-11 10:52:17 +00:00
|
|
|
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)
|
|
|
|
{
|
2008-04-04 20:24:08 +00:00
|
|
|
pcf50605_write(PCF5060X_OOCC1,
|
|
|
|
GOSTDBY | CHGWAK | EXTONWAK | pcf50605_wakeup_flags);
|
2005-12-21 23:32:19 +00:00
|
|
|
}
|
|
|
|
|
2006-05-02 08:08:10 +00:00
|
|
|
void pcf50605_init(void)
|
|
|
|
{
|
2008-06-14 22:22:51 +00:00
|
|
|
#if (defined (IPOD_VIDEO) || defined (IPOD_NANO))
|
|
|
|
/* I/O and GPO voltage supply. ECO not allowed regarding data sheet. Defaults:
|
|
|
|
* iPod Video = 0xf8 = 3.3V ON
|
|
|
|
* iPod nano = 0xf5 = 3.0V ON */
|
|
|
|
pcf50605_write(PCF5060X_IOREGC, 0xf5); /* 3.0V ON */
|
2008-02-10 05:39:20 +00:00
|
|
|
|
2008-06-14 22:22:51 +00:00
|
|
|
/* Core voltage supply. ECO not stable, assumed due to less precision of
|
|
|
|
* voltage in ECO mode. DCDC2 is not relevant as this may be used for
|
|
|
|
* voltage scaling. Default is 1.2V ON for PP5022/PP5024 */
|
2008-04-20 18:28:25 +00:00
|
|
|
pcf50605_write(PCF5060X_DCDC1, 0xec); /* 1.2V ON */
|
|
|
|
pcf50605_write(PCF5060X_DCDC2, 0x0c); /* OFF */
|
2008-02-10 05:39:20 +00:00
|
|
|
|
2008-06-14 22:22:51 +00:00
|
|
|
/* Unknown. Defaults:
|
|
|
|
* iPod Video = 0xe3 = 1.8V ON
|
|
|
|
* iPod nano = 0xe3 = 1.8V ON */
|
2008-04-20 18:28:25 +00:00
|
|
|
pcf50605_write(PCF5060X_DCUDC1, 0xe3); /* 1.8V ON */
|
2008-02-10 05:39:20 +00:00
|
|
|
|
2008-06-14 22:22:51 +00:00
|
|
|
/* Codec voltage supply. ECO not allowed as max. current of 5mA is not
|
|
|
|
* sufficient. Defaults:
|
|
|
|
* iPod Video = 0xf5 = 3.0V ON
|
|
|
|
* iPod nano = 0xef = 2.4V ON */
|
2008-04-20 18:28:25 +00:00
|
|
|
pcf50605_write(PCF5060X_D1REGC1, 0xf0); /* 2.5V ON */
|
2008-02-10 05:39:20 +00:00
|
|
|
|
2008-06-14 22:22:51 +00:00
|
|
|
/* PCF5060X_D2REGC1 is set in accordance to the accessory power setting */
|
|
|
|
|
2008-07-01 20:42:19 +00:00
|
|
|
#if defined (IPOD_VIDEO)
|
2008-06-14 22:22:51 +00:00
|
|
|
/* LCD voltage supply. Defaults:
|
2008-07-01 20:42:19 +00:00
|
|
|
* iPod Video = 0xf5 = 3.0V ON */
|
2008-04-20 18:28:25 +00:00
|
|
|
pcf50605_write(PCF5060X_D3REGC1, 0xf1); /* 2.6V ON */
|
2008-07-01 20:42:19 +00:00
|
|
|
#elif defined (IPOD_NANO)
|
|
|
|
/* D3REGC has effect on LCD and ATA, leave it unchanged due to possible ATA
|
|
|
|
* failures. Defaults:
|
|
|
|
* iPod nano = 0xf5 = 3.0V ON */
|
|
|
|
pcf50605_write(PCF5060X_D3REGC1, 0xf5); /* 3.0V ON */
|
|
|
|
#endif
|
2008-06-14 22:22:51 +00:00
|
|
|
|
|
|
|
/* PCF5060X_LPREGC1 is leaved untouched as the setting varies over the
|
|
|
|
* different iPod platforms. Defaults:
|
|
|
|
* iPod Video = 0x1f = 0ff
|
|
|
|
* iPod nano = 0xf6 = 3.1V ON */
|
2008-02-10 05:39:20 +00:00
|
|
|
#else
|
|
|
|
/* keep initialization from svn for other iPods */
|
2008-04-04 20:24:08 +00:00
|
|
|
pcf50605_write(PCF5060X_D1REGC1, 0xf5); /* 3.0V ON */
|
|
|
|
pcf50605_write(PCF5060X_D3REGC1, 0xf5); /* 3.0V ON */
|
2008-04-14 17:06:32 +00:00
|
|
|
#endif
|
2006-05-02 08:08:10 +00:00
|
|
|
}
|