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