fix: the problem to which new filetypes cannot be registered.
[kugel-rb.git] / firmware / drivers / pcf50605.c
bloba76c1dbc3c4a94c811eecf7acdfcf92df0f62202
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
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 * This program is free software; you can redistribute it and/or
20 * modify it under the terms of the GNU General Public License
21 * as published by the Free Software Foundation; either version 2
22 * of the License, or (at your option) any later version.
24 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
25 * KIND, either express or implied.
27 ****************************************************************************/
28 #include "system.h"
29 #include "config.h"
30 #if CONFIG_I2C == I2C_PP5020 || CONFIG_I2C == I2C_PP5002
31 #include "i2c-pp.h"
32 #endif
33 #include "rtc.h"
34 #include "pcf5060x.h"
35 #include "pcf50605.h"
37 unsigned char pcf50605_wakeup_flags = 0;
39 int pcf50605_read(int address)
41 return i2c_readbyte(0x8,address);
44 int pcf50605_read_multiple(int address, unsigned char* buf, int count)
46 int read = i2c_readbytes(0x08, address, count, buf);
47 return read - count;
50 int pcf50605_write(int address, unsigned char val)
52 pp_i2c_send(0x8, address, val);
53 return 0;
56 int pcf50605_write_multiple(int address, const unsigned char* buf, int count)
58 int i;
60 i2c_lock();
62 for (i = 0; i < count; i++)
63 pp_i2c_send(0x8, address + i, buf[i]);
65 i2c_unlock();
67 return 0;
70 /* The following command puts the iPod into a deep sleep. Warning
71 from the good people of ipodlinux - never issue this command
72 without setting CHGWAK or EXTONWAK if you ever want to be able to
73 power on your iPod again. */
74 void pcf50605_standby_mode(void)
76 pcf50605_write(PCF5060X_OOCC1,
77 GOSTDBY | CHGWAK | EXTONWAK | pcf50605_wakeup_flags);
80 void pcf50605_init(void)
82 #if (defined (IPOD_VIDEO) || defined (IPOD_NANO))
83 /* I/O and GPO voltage supply. ECO not allowed regarding data sheet. Defaults:
84 * iPod Video = 0xf8 = 3.3V ON
85 * iPod nano = 0xf5 = 3.0V ON */
86 pcf50605_write(PCF5060X_IOREGC, 0xf5); /* 3.0V ON */
88 /* Core voltage supply. ECO not stable, assumed due to less precision of
89 * voltage in ECO mode. DCDC2 is not relevant as this may be used for
90 * voltage scaling. Default is 1.2V ON for PP5022/PP5024 */
91 pcf50605_write(PCF5060X_DCDC1, 0xec); /* 1.2V ON */
92 pcf50605_write(PCF5060X_DCDC2, 0x0c); /* OFF */
94 /* Unknown. Defaults:
95 * iPod Video = 0xe3 = 1.8V ON
96 * iPod nano = 0xe3 = 1.8V ON */
97 pcf50605_write(PCF5060X_DCUDC1, 0xe3); /* 1.8V ON */
99 /* Codec voltage supply. ECO not allowed as max. current of 5mA is not
100 * sufficient. Defaults:
101 * iPod Video = 0xf5 = 3.0V ON
102 * iPod nano = 0xef = 2.4V ON */
103 pcf50605_write(PCF5060X_D1REGC1, 0xf0); /* 2.5V ON */
105 /* PCF5060X_D2REGC1 is set in accordance to the accessory power setting */
107 #if defined (IPOD_VIDEO)
108 /* LCD voltage supply. Defaults:
109 * iPod Video = 0xf5 = 3.0V ON */
110 pcf50605_write(PCF5060X_D3REGC1, 0xf1); /* 2.6V ON */
111 #elif defined (IPOD_NANO)
112 /* D3REGC has effect on LCD and ATA, leave it unchanged due to possible ATA
113 * failures. Defaults:
114 * iPod nano = 0xf5 = 3.0V ON */
115 pcf50605_write(PCF5060X_D3REGC1, 0xf5); /* 3.0V ON */
116 #endif
118 /* PCF5060X_LPREGC1 is leaved untouched as the setting varies over the
119 * different iPod platforms. Defaults:
120 * iPod Video = 0x1f = 0ff
121 * iPod nano = 0xf6 = 3.1V ON */
122 #else
123 /* keep initialization from svn for other iPods */
124 pcf50605_write(PCF5060X_D1REGC1, 0xf5); /* 3.0V ON */
125 pcf50605_write(PCF5060X_D3REGC1, 0xf5); /* 3.0V ON */
126 #endif