summaryrefslogtreecommitdiff
path: root/cesar/hal/leon/gpio.h
blob: 46dde1db2e41c8fd49620c288fb518b6911b36a0 (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
#ifndef hal_leon_gpio_h
#define hal_leon_gpio_h
/* Cesar project {{{
 *
 * Copyright (C) 2009 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    hal/leon/gpio.h
 * \brief   Leon2 GPIO support.
 * \ingroup hal_leon
 */

/** GPIO base address. */
#define LEON_GPIO_BASE 0x800000a0

/** GPIO input/output. */
#define LEON_GPIO_PORT (* (volatile u32 *) (LEON_GPIO_BASE + 0x00))

/** GPIO direction, 1 for output. */
#define LEON_GPIO_DIR (* (volatile u32 *) (LEON_GPIO_BASE + 0x04))

/** GPIO interrupt register. */
#define LEON_GPIO_IT (* (volatile u32 *) (LEON_GPIO_BASE + 0x08))

/** GPIO interrupt configuration, following flags, or'ed. */
#define LEON_GPIO_IT_CONFIG(n, config) ((config) << ((n) * 8))

/** GPIO interrupt enabled. */
#define LEON_GPIO_IT_CONFIG_ENABLED 0x80

/** GPIO interrupt edge. */
#define LEON_GPIO_IT_CONFIG_EDGE 0x40

/** GPIO interrupt polarity. */
#define LEON_GPIO_IT_CONFIG_POL 0x20

/** Number of GPIO. */
#define LEON_GPIO_NB 16

/** GPIO pin functions base address, this is a hack as Leon is not supposed to
 * use those registers. */
#define LEON_RB_GPIO_CONFIG_BASE 0xc8040208

/** GPIO pin functions registers, set to 1 to connect pin to Leon GPIO. */
#define LEON_RB_GPIO_CONFIG(gpio) \
    (((volatile u32 *) (LEON_RB_GPIO_CONFIG_BASE))[(gpio)])

/** GPIO debug registers, set to 1 to enable debug mode. */
#define LEON_RB_GPIO_DEBUG (* (volatile u32 *) (0xc8040248))

/** Interrupt numbers. */
#define LEON_GPIO_ITC1_IT(n) (4 + (n))

#endif /* hal_leon_gpio_h */