summaryrefslogtreecommitdiff
path: root/firmware/target/arm/tcc77x/iaudio7/power-iaudio7.c
diff options
context:
space:
mode:
authorDave Chapman <dave@dchapman.com>2008-09-06 17:50:59 +0000
committerDave Chapman <dave@dchapman.com>2008-09-06 17:50:59 +0000
commitd462a64a918117991e11dade2d7fa3a28196e07a (patch)
tree0a6f5ed8777b18bb1641fbb3608f10374901706c /firmware/target/arm/tcc77x/iaudio7/power-iaudio7.c
parentb87715f670f04c9adbe358c32a385c6771d99a81 (diff)
downloadrockbox-d462a64a918117991e11dade2d7fa3a28196e07a.tar.gz
rockbox-d462a64a918117991e11dade2d7fa3a28196e07a.zip
Initial commit of iaudio 7 port by Vitja Makarov (FS#9245). Port is at quite an advanced stage, but is troubled by the lack of a reliable NAND driver (similar to the Cowon D2 port) and is not yet suitable for non-developers.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18435 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/tcc77x/iaudio7/power-iaudio7.c')
-rw-r--r--firmware/target/arm/tcc77x/iaudio7/power-iaudio7.c146
1 files changed, 146 insertions, 0 deletions
diff --git a/firmware/target/arm/tcc77x/iaudio7/power-iaudio7.c b/firmware/target/arm/tcc77x/iaudio7/power-iaudio7.c
new file mode 100644
index 0000000000..ef012cbbdf
--- /dev/null
+++ b/firmware/target/arm/tcc77x/iaudio7/power-iaudio7.c
@@ -0,0 +1,146 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 Vitja Makarov
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#include <stdbool.h>
22
23#include "config.h"
24#include "cpu.h"
25#include "kernel.h"
26#include "system.h"
27#include "power.h"
28
29#include "pcf50606.h"
30
31void power_init(void)
32{
33 pcf50606_write(PCF5060X_DCDC1, 0x90);
34 pcf50606_write(PCF5060X_DCDC2, 0x48);
35 pcf50606_write(PCF5060X_DCDC3, 0xfc);
36 pcf50606_write(PCF5060X_DCDC4, 0xb1);
37
38 pcf50606_write(PCF5060X_IOREGC, 0xe9);
39 /* 3.3V, touch-panel */
40 pcf50606_write(PCF5060X_D1REGC1, 0xf8);
41 pcf50606_write(PCF5060X_D2REGC1, 0xf2);
42 pcf50606_write(PCF5060X_D3REGC1, 0xf5);
43
44 pcf50606_write(PCF5060X_LPREGC1, 0x00);
45 pcf50606_write(PCF5060X_LPREGC2, 0x02);
46
47 pcf50606_write(PCF5060X_DCUDC1, 0xe6);
48 pcf50606_write(PCF5060X_DCUDC2, 0x30);
49
50 pcf50606_write(PCF5060X_DCDEC1, 0xe7);
51 pcf50606_write(PCF5060X_DCDEC2, 0x02);
52
53 pcf50606_write(PCF5060X_INT1M, 0x5b);
54 pcf50606_write(PCF5060X_INT1M, 0xaf);
55 pcf50606_write(PCF5060X_INT1M, 0x8f);
56
57 pcf50606_write(PCF5060X_OOCC1, 0x40);
58 pcf50606_write(PCF5060X_OOCC2, 0x05);
59
60 pcf50606_write(PCF5060X_MBCC3, 0x3a);
61 pcf50606_write(PCF5060X_GPOC1, 0x00);
62 pcf50606_write(PCF5060X_BBCC, 0xf8);
63}
64
65/* Control leds on ata2501 board */
66void power_touch_panel(bool on)
67{
68 if (on)
69 pcf50606_write(PCF5060X_D1REGC1, 0xf8);
70 else
71 pcf50606_write(PCF5060X_D1REGC1, 0x00);
72}
73
74void ide_power_enable(bool on)
75{
76}
77
78bool ide_powered(void)
79{
80 return true;
81}
82
83void power_off(void)
84{
85 /* Forcibly cut power to SoC & peripherals by putting the PCF to sleep */
86 pcf50606_write(PCF5060X_OOCC1, GOSTDBY | CHGWAK | EXTONWAK);
87}
88
89#if CONFIG_TUNER
90#include "tuner.h"
91
92/** Tuner **/
93static bool powered = false;
94
95#define TUNNER_CLK (1 << 5)
96#define TUNNER_DATA (1 << 6)
97#define TUNNER_NR_W (1 << 7)
98
99bool tuner_power(bool status)
100{
101 bool old_status;
102 lv24020lp_lock();
103
104 old_status = powered;
105
106 if (status != old_status)
107 {
108 if (status)
109 {
110 /* When power up, host should initialize the 3-wire bus
111 in host read mode: */
112
113 /* 1. Set direction of the DATA-line to input-mode. */
114 GPIOA_DIR &= ~TUNNER_DATA;
115
116 /* 2. Drive NR_W low */
117 GPIOA &= ~TUNNER_NR_W;
118 GPIOA_DIR |= TUNNER_NR_W;
119
120 /* 3. Drive CLOCK high */
121 GPIOA |= TUNNER_CLK;
122 GPIOA_DIR |= TUNNER_CLK;
123
124 lv24020lp_power(true);
125 }
126 else
127 {
128 lv24020lp_power(false);
129
130 /* set all as inputs */
131 GPIOC_DIR &= ~(TUNNER_CLK | TUNNER_DATA | TUNNER_NR_W);
132 }
133
134 powered = status;
135 }
136
137 lv24020lp_unlock();
138 return old_status;
139}
140
141#endif /* CONFIG_TUNER */
142
143bool charger_inserted(void)
144{
145 return (GPIOA & 0x1) ? true : false;
146}