i.MX31/Gigabeat S minor cleaning: Make HW access more obvious in places I forgot...
[kugel-rb.git] / firmware / target / arm / imx31 / gpio-imx31.h
bloba1358672e87fd565a85ca0447790a7271bd4b114
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (c) 2008 by Michael Sevakis
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 #ifndef GPIO_IMX31_H
22 #define GPIO_IMX31_H
24 /* Static registration mechanism for imx31 GPIO interrupts */
25 #define USE_GPIO1_EVENTS (1 << 0)
26 #define USE_GPIO2_EVENTS (1 << 1)
27 #define USE_GPIO3_EVENTS (1 << 2)
29 /* Module indexes defined by which GPIO modules are used */
30 enum gpio_module_number
32 __GPIO_NUM_START = -1,
33 #if (GPIO_EVENT_MASK & USE_GPIO1_EVENTS)
34 GPIO1_NUM,
35 #endif
36 #if (GPIO_EVENT_MASK & USE_GPIO2_EVENTS)
37 GPIO2_NUM,
38 #endif
39 #if (GPIO_EVENT_MASK & USE_GPIO3_EVENTS)
40 GPIO3_NUM,
41 #endif
42 GPIO_NUM_GPIO,
45 /* Possible values for gpio interrupt line config */
46 enum gpio_int_sense_enum
48 GPIO_SENSE_LOW_LEVEL = 0, /* High-level sensitive */
49 GPIO_SENSE_HIGH_LEVEL, /* Low-level sensitive */
50 GPIO_SENSE_RISING, /* Rising-edge sensitive */
51 GPIO_SENSE_FALLING, /* Falling-edge sensitive */
54 #define GPIO_SENSE_CONFIG_MASK 0x3
56 /* Pending events will be called in array order which allows easy
57 * pioritization */
59 /* Describes a single event for a pin */
60 struct gpio_event
62 unsigned long mask; /* mask: 1 << (0...31) */
63 enum gpio_int_sense_enum sense; /* Type of sense */
64 void (*callback)(void); /* Callback function */
67 /* Module corresponding to the event ID is identified by range */
68 enum gpio_event_bases
70 #if (GPIO_EVENT_MASK & USE_GPIO1_EVENTS)
71 GPIO1_EVENT_FIRST = 32*GPIO1_NUM,
72 #endif
73 #if (GPIO_EVENT_MASK & USE_GPIO2_EVENTS)
74 GPIO2_EVENT_FIRST = 32*GPIO2_NUM,
75 #endif
76 #if (GPIO_EVENT_MASK & USE_GPIO3_EVENTS)
77 GPIO3_EVENT_FIRST = 32*GPIO3_NUM,
78 #endif
81 #include "gpio-target.h"
83 void gpio_init(void);
84 bool gpio_enable_event(enum gpio_event_ids id);
85 void gpio_disable_event(enum gpio_event_ids id);
87 #endif /* GPIO_IMX31_H */