xref: /qemu/include/hw/gpio/imx_gpio.h (revision f4427280977902273f98280b2572d88b6ed53144)
1*f4427280SJean-Christophe Dubois /*
2*f4427280SJean-Christophe Dubois  * i.MX processors GPIO registers definition.
3*f4427280SJean-Christophe Dubois  *
4*f4427280SJean-Christophe Dubois  * Copyright (C) 2015 Jean-Christophe Dubois <jcd@tribudubois.net>
5*f4427280SJean-Christophe Dubois  *
6*f4427280SJean-Christophe Dubois  * This program is free software; you can redistribute it and/or
7*f4427280SJean-Christophe Dubois  * modify it under the terms of the GNU General Public License as
8*f4427280SJean-Christophe Dubois  * published by the Free Software Foundation; either version 2 or
9*f4427280SJean-Christophe Dubois  * (at your option) version 3 of the License.
10*f4427280SJean-Christophe Dubois  *
11*f4427280SJean-Christophe Dubois  * This program is distributed in the hope that it will be useful,
12*f4427280SJean-Christophe Dubois  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13*f4427280SJean-Christophe Dubois  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14*f4427280SJean-Christophe Dubois  * GNU General Public License for more details.
15*f4427280SJean-Christophe Dubois  *
16*f4427280SJean-Christophe Dubois  * You should have received a copy of the GNU General Public License along
17*f4427280SJean-Christophe Dubois  * with this program; if not, see <http://www.gnu.org/licenses/>.
18*f4427280SJean-Christophe Dubois  */
19*f4427280SJean-Christophe Dubois 
20*f4427280SJean-Christophe Dubois #ifndef __IMX_GPIO_H_
21*f4427280SJean-Christophe Dubois #define __IMX_GPIO_H_
22*f4427280SJean-Christophe Dubois 
23*f4427280SJean-Christophe Dubois #include <hw/sysbus.h>
24*f4427280SJean-Christophe Dubois 
25*f4427280SJean-Christophe Dubois #define TYPE_IMX_GPIO "imx.gpio"
26*f4427280SJean-Christophe Dubois #define IMX_GPIO(obj) OBJECT_CHECK(IMXGPIOState, (obj), TYPE_IMX_GPIO)
27*f4427280SJean-Christophe Dubois 
28*f4427280SJean-Christophe Dubois #define IMX_GPIO_MEM_SIZE 0x20
29*f4427280SJean-Christophe Dubois 
30*f4427280SJean-Christophe Dubois /* i.MX GPIO memory map */
31*f4427280SJean-Christophe Dubois #define DR_ADDR             0x00 /* DATA REGISTER */
32*f4427280SJean-Christophe Dubois #define GDIR_ADDR           0x04 /* DIRECTION REGISTER */
33*f4427280SJean-Christophe Dubois #define PSR_ADDR            0x08 /* PAD STATUS REGISTER */
34*f4427280SJean-Christophe Dubois #define ICR1_ADDR           0x0c /* INTERRUPT CONFIGURATION REGISTER 1 */
35*f4427280SJean-Christophe Dubois #define ICR2_ADDR           0x10 /* INTERRUPT CONFIGURATION REGISTER 2 */
36*f4427280SJean-Christophe Dubois #define IMR_ADDR            0x14 /* INTERRUPT MASK REGISTER */
37*f4427280SJean-Christophe Dubois #define ISR_ADDR            0x18 /* INTERRUPT STATUS REGISTER */
38*f4427280SJean-Christophe Dubois #define EDGE_SEL_ADDR       0x1c /* EDGE SEL REGISTER */
39*f4427280SJean-Christophe Dubois 
40*f4427280SJean-Christophe Dubois #define IMX_GPIO_PIN_COUNT 32
41*f4427280SJean-Christophe Dubois 
42*f4427280SJean-Christophe Dubois typedef struct IMXGPIOState {
43*f4427280SJean-Christophe Dubois     /*< private >*/
44*f4427280SJean-Christophe Dubois     SysBusDevice parent_obj;
45*f4427280SJean-Christophe Dubois 
46*f4427280SJean-Christophe Dubois     /*< public >*/
47*f4427280SJean-Christophe Dubois     MemoryRegion iomem;
48*f4427280SJean-Christophe Dubois 
49*f4427280SJean-Christophe Dubois     uint32_t dr;
50*f4427280SJean-Christophe Dubois     uint32_t gdir;
51*f4427280SJean-Christophe Dubois     uint32_t psr;
52*f4427280SJean-Christophe Dubois     uint64_t icr;
53*f4427280SJean-Christophe Dubois     uint32_t imr;
54*f4427280SJean-Christophe Dubois     uint32_t isr;
55*f4427280SJean-Christophe Dubois     bool has_edge_sel;
56*f4427280SJean-Christophe Dubois     uint32_t edge_sel;
57*f4427280SJean-Christophe Dubois 
58*f4427280SJean-Christophe Dubois     qemu_irq irq;
59*f4427280SJean-Christophe Dubois     qemu_irq output[IMX_GPIO_PIN_COUNT];
60*f4427280SJean-Christophe Dubois } IMXGPIOState;
61*f4427280SJean-Christophe Dubois 
62*f4427280SJean-Christophe Dubois #endif /* __IMX_GPIO_H_ */
63