summaryrefslogtreecommitdiffstats
path: root/firmware/target/arm/s5l8702/dma-s5l8702.c
blob: 6fe25f712ad55b515db4ab4903fc5c2ebdd8d7a5 (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
59
60
61
62
63
64
65
66
67
68
/***************************************************************************
 *             __________               __   ___.
 *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
 *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
 *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
 *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
 *                     \/            \/     \/    \/            \/
 * $Id$
 *
 * Copyright (C) 2014 by Cástor Muñoz
 *
 * 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 <config.h>

#include "s5l8702.h"
#include "pl080.h"
#include "dma-s5l8702.h"

/* s5l8702 PL080 controllers configuration */
struct dmac s5l8702_dmac0 = {
    .baddr = S5L8702_DMAC0_BASE,
    .m1 = DMACCONFIG_M_LITTLE_ENDIAN,
    .m2 = DMACCONFIG_M_LITTLE_ENDIAN,
};

struct dmac s5l8702_dmac1 = {
    .baddr = S5L8702_DMAC1_BASE,
    .m1 = DMACCONFIG_M_LITTLE_ENDIAN,
    .m2 = DMACCONFIG_M_LITTLE_ENDIAN,
};

void ICODE_ATTR INT_DMAC0(void)
{
    dmac_callback(&s5l8702_dmac0);
}

void ICODE_ATTR INT_DMAC1(void)
{
    dmac_callback(&s5l8702_dmac1);
}

void dma_init_ctrl(struct dmac* dmac, int irq, int clockgate, int onoff)
{
    /* init DMAC */
    VIC0INTENCLEAR = (1 << irq);        /* disable interrupts */
    PWRCON(0) &= ~(1 << clockgate);     /* unmask clock gate */
    dmac_open(dmac);                    /* init/reset controller */

    if (onoff)
        VIC0INTENABLE = (1 << irq);     /* enable interrupts */
    else
        PWRCON(0) |= (1 << clockgate);  /* mask clockgate */
}

void dma_init(void)
{
    dma_init_ctrl(&s5l8702_dmac0, IRQ_DMAC0, CLOCKGATE_DMAC0, 1);
    dma_init_ctrl(&s5l8702_dmac1, IRQ_DMAC1, CLOCKGATE_DMAC1, 0);
}