summaryrefslogtreecommitdiffstats
path: root/firmware/target/arm/as3525/sansa-clip/backlight-clip.c
blob: 2064f0992f113a9e5a3150899d4f09d907230e69 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/***************************************************************************
 *             __________               __   ___.
 *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
 *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
 *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
 *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
 *                     \/            \/     \/    \/            \/
 * $Id$
 *
 * Copyright © 2008 Rafaël Carré
 *
 * 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.
 *
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
 * KIND, either express or implied.
 *
 ****************************************************************************/

#include "backlight-target.h"
#include "as3525.h"

/* TODO : backlight brightness */

/* XXX : xpd is used for SD/MCI interface
 * If interrupts are used to access this interface, they should be
 * disabled in _buttonlight_on/off ()
 */

void _buttonlight_on(void)
{
    int saved_ccu_io;

    saved_ccu_io = CCU_IO;  /* save XPD setting */

    CCU_IO &= ~(3<<2);      /* setup xpd as GPIO */

    GPIOD_DIR |= (1<<7);
    GPIOD_PIN(7) = (1<<7);  /* set pin d7 high */

    CCU_IO = saved_ccu_io;  /* restore the previous XPD setting */
}

void _buttonlight_off(void)
{
    int saved_ccu_io;

    saved_ccu_io = CCU_IO;  /* save XPD setting */

    CCU_IO &= ~(3<<2);      /* setup xpd as GPIO */

    GPIOD_DIR |= (1<<7);
    GPIOD_PIN(7) = 0;       /* set pin d7 low */

    CCU_IO = saved_ccu_io;  /* restore the previous XPD setting */
}