tcc77x targets: various minor cleanups
[maemo-rb.git] / firmware / target / arm / tcc77x / iaudio7 / power-iaudio7.c
blobbaf93b73aa80b65c4fc4ec269682ee26814b912c
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2008 Vitja Makarov
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.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
21 #include <stdbool.h>
23 #include "config.h"
24 #include "cpu.h"
25 #include "kernel.h"
26 #include "system.h"
27 #include "power.h"
28 #include "backlight-target.h"
30 #include "pcf50606.h"
32 void power_init(void)
34 pcf50606_write(PCF5060X_DCDC1, 0x90);
35 pcf50606_write(PCF5060X_DCDC2, 0x48);
36 pcf50606_write(PCF5060X_DCDC3, 0xfc);
37 pcf50606_write(PCF5060X_DCDC4, 0xb1);
39 pcf50606_write(PCF5060X_IOREGC, 0xe9);
40 /* 3.3V, touch-panel */
41 pcf50606_write(PCF5060X_D1REGC1, 0xf8);
42 pcf50606_write(PCF5060X_D2REGC1, 0xf2);
43 pcf50606_write(PCF5060X_D3REGC1, 0xf5);
45 pcf50606_write(PCF5060X_LPREGC1, 0x00);
46 pcf50606_write(PCF5060X_LPREGC2, 0x02);
48 pcf50606_write(PCF5060X_DCUDC1, 0xe6);
49 pcf50606_write(PCF5060X_DCUDC2, 0x30);
51 pcf50606_write(PCF5060X_DCDEC1, 0xe7);
52 pcf50606_write(PCF5060X_DCDEC2, 0x02);
54 pcf50606_write(PCF5060X_INT1M, 0x5b);
55 pcf50606_write(PCF5060X_INT1M, 0xaf);
56 pcf50606_write(PCF5060X_INT1M, 0x8f);
58 pcf50606_write(PCF5060X_OOCC1, 0x40);
59 pcf50606_write(PCF5060X_OOCC2, 0x05);
61 pcf50606_write(PCF5060X_MBCC3, 0x3a);
62 pcf50606_write(PCF5060X_GPOC1, 0x00);
63 pcf50606_write(PCF5060X_BBCC, 0xf8);
66 /* Control leds on ata2501 board */
67 void power_touch_panel(bool on)
69 if (on)
70 pcf50606_write(PCF5060X_D1REGC1, 0xf8);
71 else
72 pcf50606_write(PCF5060X_D1REGC1, 0x00);
75 void ide_power_enable(bool on)
77 (void) on;
80 bool ide_powered(void)
82 return true;
85 void power_off(void)
87 /* Forcibly cut power to SoC & peripherals by putting the PCF to sleep */
88 pcf50606_write(PCF5060X_OOCC1, GOSTDBY | CHGWAK | EXTONWAK);
91 #if CONFIG_TUNER
92 #include "tuner.h"
94 /** Tuner **/
95 static bool powered = false;
97 #define TUNNER_CLK (1 << 5)
98 #define TUNNER_DATA (1 << 6)
99 #define TUNNER_NR_W (1 << 7)
101 bool tuner_power(bool status)
103 bool old_status;
104 lv24020lp_lock();
106 old_status = powered;
108 if (status != old_status)
110 if (status)
112 /* When power up, host should initialize the 3-wire bus
113 in host read mode: */
115 /* 1. Set direction of the DATA-line to input-mode. */
116 GPIOA_DIR &= ~TUNNER_DATA;
118 /* 2. Drive NR_W low */
119 GPIOA &= ~TUNNER_NR_W;
120 GPIOA_DIR |= TUNNER_NR_W;
122 /* 3. Drive CLOCK high */
123 GPIOA |= TUNNER_CLK;
124 GPIOA_DIR |= TUNNER_CLK;
126 lv24020lp_power(true);
128 else
130 lv24020lp_power(false);
132 /* set all as inputs */
133 GPIOC_DIR &= ~(TUNNER_CLK | TUNNER_DATA | TUNNER_NR_W);
136 powered = status;
139 lv24020lp_unlock();
140 return old_status;
143 #endif /* CONFIG_TUNER */
145 unsigned int power_input_status(void)
147 return (GPIOA & 0x1) ?
148 POWER_INPUT_MAIN_CHARGER : POWER_INPUT_NONE;