xref: /qemu/hw/gpio/imx_gpio.c (revision eba837a31b9579e30cc6d7ecb4b5c2662a6ffaba)
1f4427280SJean-Christophe Dubois /*
2f4427280SJean-Christophe Dubois  * i.MX processors GPIO emulation.
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 
208ef94f0bSPeter Maydell #include "qemu/osdep.h"
21f4427280SJean-Christophe Dubois #include "hw/gpio/imx_gpio.h"
2264552b6bSMarkus Armbruster #include "hw/irq.h"
23a27bd6c7SMarkus Armbruster #include "hw/qdev-properties.h"
24d6454270SMarkus Armbruster #include "migration/vmstate.h"
2503dd024fSPaolo Bonzini #include "qemu/log.h"
260b8fa32fSMarkus Armbruster #include "qemu/module.h"
27e3778c84SBernhard Beschow #include "trace.h"
28f4427280SJean-Christophe Dubois 
29f4427280SJean-Christophe Dubois #ifndef DEBUG_IMX_GPIO
30f4427280SJean-Christophe Dubois #define DEBUG_IMX_GPIO 0
31f4427280SJean-Christophe Dubois #endif
32f4427280SJean-Christophe Dubois 
33f4427280SJean-Christophe Dubois typedef enum IMXGPIOLevel {
34f4427280SJean-Christophe Dubois     IMX_GPIO_LEVEL_LOW = 0,
35f4427280SJean-Christophe Dubois     IMX_GPIO_LEVEL_HIGH = 1,
36f4427280SJean-Christophe Dubois } IMXGPIOLevel;
37f4427280SJean-Christophe Dubois 
38f4427280SJean-Christophe Dubois static const char *imx_gpio_reg_name(uint32_t reg)
39f4427280SJean-Christophe Dubois {
40f4427280SJean-Christophe Dubois     switch (reg) {
41f4427280SJean-Christophe Dubois     case DR_ADDR:
42f4427280SJean-Christophe Dubois         return "DR";
43f4427280SJean-Christophe Dubois     case GDIR_ADDR:
44f4427280SJean-Christophe Dubois         return "GDIR";
45f4427280SJean-Christophe Dubois     case PSR_ADDR:
46f4427280SJean-Christophe Dubois         return "PSR";
47f4427280SJean-Christophe Dubois     case ICR1_ADDR:
48f4427280SJean-Christophe Dubois         return "ICR1";
49f4427280SJean-Christophe Dubois     case ICR2_ADDR:
50f4427280SJean-Christophe Dubois         return "ICR2";
51f4427280SJean-Christophe Dubois     case IMR_ADDR:
52f4427280SJean-Christophe Dubois         return "IMR";
53f4427280SJean-Christophe Dubois     case ISR_ADDR:
54f4427280SJean-Christophe Dubois         return "ISR";
55f4427280SJean-Christophe Dubois     case EDGE_SEL_ADDR:
56f4427280SJean-Christophe Dubois         return "EDGE_SEL";
57f4427280SJean-Christophe Dubois     default:
58f4427280SJean-Christophe Dubois         return "[?]";
59f4427280SJean-Christophe Dubois     }
60f4427280SJean-Christophe Dubois }
61f4427280SJean-Christophe Dubois 
62f4427280SJean-Christophe Dubois static void imx_gpio_update_int(IMXGPIOState *s)
63f4427280SJean-Christophe Dubois {
64f1f7e4bfSJean-Christophe Dubois     if (s->has_upper_pin_irq) {
65f1f7e4bfSJean-Christophe Dubois         qemu_set_irq(s->irq[0], (s->isr & s->imr & 0x0000FFFF) ? 1 : 0);
66f1f7e4bfSJean-Christophe Dubois         qemu_set_irq(s->irq[1], (s->isr & s->imr & 0xFFFF0000) ? 1 : 0);
67f1f7e4bfSJean-Christophe Dubois     } else {
68f1f7e4bfSJean-Christophe Dubois         qemu_set_irq(s->irq[0], (s->isr & s->imr) ? 1 : 0);
69f1f7e4bfSJean-Christophe Dubois     }
70f4427280SJean-Christophe Dubois }
71f4427280SJean-Christophe Dubois 
72f4427280SJean-Christophe Dubois static void imx_gpio_set_int_line(IMXGPIOState *s, int line, IMXGPIOLevel level)
73f4427280SJean-Christophe Dubois {
74f4427280SJean-Christophe Dubois     /* if this signal isn't configured as an input signal, nothing to do */
75*eba837a3SBernhard Beschow     if (extract32(s->gdir, line, 1)) {
76f4427280SJean-Christophe Dubois         return;
77f4427280SJean-Christophe Dubois     }
78f4427280SJean-Christophe Dubois 
79f4427280SJean-Christophe Dubois     /* When set, EDGE_SEL overrides the ICR config */
80f4427280SJean-Christophe Dubois     if (extract32(s->edge_sel, line, 1)) {
81f4427280SJean-Christophe Dubois         /* we detect interrupt on rising and falling edge */
82f4427280SJean-Christophe Dubois         if (extract32(s->psr, line, 1) != level) {
83f4427280SJean-Christophe Dubois             /* level changed */
84f4427280SJean-Christophe Dubois             s->isr = deposit32(s->isr, line, 1, 1);
85f4427280SJean-Christophe Dubois         }
86f4427280SJean-Christophe Dubois     } else if (extract64(s->icr, 2*line + 1, 1)) {
87f4427280SJean-Christophe Dubois         /* interrupt is edge sensitive */
88f4427280SJean-Christophe Dubois         if (extract32(s->psr, line, 1) != level) {
89f4427280SJean-Christophe Dubois             /* level changed */
90f4427280SJean-Christophe Dubois             if (extract64(s->icr, 2*line, 1) != level) {
91f4427280SJean-Christophe Dubois                 s->isr = deposit32(s->isr, line, 1, 1);
92f4427280SJean-Christophe Dubois             }
93f4427280SJean-Christophe Dubois         }
94f4427280SJean-Christophe Dubois     } else {
95f4427280SJean-Christophe Dubois         /* interrupt is level sensitive */
96f4427280SJean-Christophe Dubois         if (extract64(s->icr, 2*line, 1) == level) {
97f4427280SJean-Christophe Dubois             s->isr = deposit32(s->isr, line, 1, 1);
98f4427280SJean-Christophe Dubois         }
99f4427280SJean-Christophe Dubois     }
100f4427280SJean-Christophe Dubois }
101f4427280SJean-Christophe Dubois 
102f4427280SJean-Christophe Dubois static void imx_gpio_set(void *opaque, int line, int level)
103f4427280SJean-Christophe Dubois {
104f4427280SJean-Christophe Dubois     IMXGPIOState *s = IMX_GPIO(opaque);
105f4427280SJean-Christophe Dubois     IMXGPIOLevel imx_level = level ? IMX_GPIO_LEVEL_HIGH : IMX_GPIO_LEVEL_LOW;
106f4427280SJean-Christophe Dubois 
107e3778c84SBernhard Beschow     trace_imx_gpio_set(DEVICE(s)->canonical_path, line, imx_level);
108e3778c84SBernhard Beschow 
109f4427280SJean-Christophe Dubois     imx_gpio_set_int_line(s, line, imx_level);
110f4427280SJean-Christophe Dubois 
111f4427280SJean-Christophe Dubois     /* this is an input signal, so set PSR */
112f4427280SJean-Christophe Dubois     s->psr = deposit32(s->psr, line, 1, imx_level);
113f4427280SJean-Christophe Dubois 
114f4427280SJean-Christophe Dubois     imx_gpio_update_int(s);
115f4427280SJean-Christophe Dubois }
116f4427280SJean-Christophe Dubois 
117f4427280SJean-Christophe Dubois static void imx_gpio_set_all_int_lines(IMXGPIOState *s)
118f4427280SJean-Christophe Dubois {
119f4427280SJean-Christophe Dubois     int i;
120f4427280SJean-Christophe Dubois 
121f4427280SJean-Christophe Dubois     for (i = 0; i < IMX_GPIO_PIN_COUNT; i++) {
122f4427280SJean-Christophe Dubois         IMXGPIOLevel imx_level = extract32(s->psr, i, 1);
123f4427280SJean-Christophe Dubois         imx_gpio_set_int_line(s, i, imx_level);
124f4427280SJean-Christophe Dubois     }
125f4427280SJean-Christophe Dubois 
126f4427280SJean-Christophe Dubois     imx_gpio_update_int(s);
127f4427280SJean-Christophe Dubois }
128f4427280SJean-Christophe Dubois 
129f4427280SJean-Christophe Dubois static inline void imx_gpio_set_all_output_lines(IMXGPIOState *s)
130f4427280SJean-Christophe Dubois {
131f4427280SJean-Christophe Dubois     int i;
132f4427280SJean-Christophe Dubois 
133f4427280SJean-Christophe Dubois     for (i = 0; i < IMX_GPIO_PIN_COUNT; i++) {
134f4427280SJean-Christophe Dubois         /*
135f4427280SJean-Christophe Dubois          * if the line is set as output, then forward the line
136f4427280SJean-Christophe Dubois          * level to its user.
137f4427280SJean-Christophe Dubois          */
138f4427280SJean-Christophe Dubois         if (extract32(s->gdir, i, 1) && s->output[i]) {
139f4427280SJean-Christophe Dubois             qemu_set_irq(s->output[i], extract32(s->dr, i, 1));
140f4427280SJean-Christophe Dubois         }
141f4427280SJean-Christophe Dubois     }
142f4427280SJean-Christophe Dubois }
143f4427280SJean-Christophe Dubois 
144f4427280SJean-Christophe Dubois static uint64_t imx_gpio_read(void *opaque, hwaddr offset, unsigned size)
145f4427280SJean-Christophe Dubois {
146f4427280SJean-Christophe Dubois     IMXGPIOState *s = IMX_GPIO(opaque);
147f4427280SJean-Christophe Dubois     uint32_t reg_value = 0;
148f4427280SJean-Christophe Dubois 
149f4427280SJean-Christophe Dubois     switch (offset) {
150f4427280SJean-Christophe Dubois     case DR_ADDR:
151f4427280SJean-Christophe Dubois         /*
152f4427280SJean-Christophe Dubois          * depending on the "line" configuration, the bit values
153f4427280SJean-Christophe Dubois          * are coming either from DR or PSR
154f4427280SJean-Christophe Dubois          */
155f4427280SJean-Christophe Dubois         reg_value = (s->dr & s->gdir) | (s->psr & ~s->gdir);
156f4427280SJean-Christophe Dubois         break;
157f4427280SJean-Christophe Dubois 
158f4427280SJean-Christophe Dubois     case GDIR_ADDR:
159f4427280SJean-Christophe Dubois         reg_value = s->gdir;
160f4427280SJean-Christophe Dubois         break;
161f4427280SJean-Christophe Dubois 
162f4427280SJean-Christophe Dubois     case PSR_ADDR:
163f4427280SJean-Christophe Dubois         reg_value = s->psr & ~s->gdir;
164f4427280SJean-Christophe Dubois         break;
165f4427280SJean-Christophe Dubois 
166f4427280SJean-Christophe Dubois     case ICR1_ADDR:
167f4427280SJean-Christophe Dubois         reg_value = extract64(s->icr, 0, 32);
168f4427280SJean-Christophe Dubois         break;
169f4427280SJean-Christophe Dubois 
170f4427280SJean-Christophe Dubois     case ICR2_ADDR:
171f4427280SJean-Christophe Dubois         reg_value = extract64(s->icr, 32, 32);
172f4427280SJean-Christophe Dubois         break;
173f4427280SJean-Christophe Dubois 
174f4427280SJean-Christophe Dubois     case IMR_ADDR:
175f4427280SJean-Christophe Dubois         reg_value = s->imr;
176f4427280SJean-Christophe Dubois         break;
177f4427280SJean-Christophe Dubois 
178f4427280SJean-Christophe Dubois     case ISR_ADDR:
179f4427280SJean-Christophe Dubois         reg_value = s->isr;
180f4427280SJean-Christophe Dubois         break;
181f4427280SJean-Christophe Dubois 
182f4427280SJean-Christophe Dubois     case EDGE_SEL_ADDR:
183f4427280SJean-Christophe Dubois         if (s->has_edge_sel) {
184f4427280SJean-Christophe Dubois             reg_value = s->edge_sel;
185f4427280SJean-Christophe Dubois         } else {
18656411125SJean-Christophe Dubois             qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: EDGE_SEL register not "
187f4427280SJean-Christophe Dubois                           "present on this version of GPIO device\n",
188f4427280SJean-Christophe Dubois                           TYPE_IMX_GPIO, __func__);
189f4427280SJean-Christophe Dubois         }
190f4427280SJean-Christophe Dubois         break;
191f4427280SJean-Christophe Dubois 
192f4427280SJean-Christophe Dubois     default:
19356411125SJean-Christophe Dubois         qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: Bad register at offset 0x%"
19456411125SJean-Christophe Dubois                       HWADDR_PRIx "\n", TYPE_IMX_GPIO, __func__, offset);
195f4427280SJean-Christophe Dubois         break;
196f4427280SJean-Christophe Dubois     }
197f4427280SJean-Christophe Dubois 
198e3778c84SBernhard Beschow     trace_imx_gpio_read(DEVICE(s)->canonical_path, imx_gpio_reg_name(offset),
199e3778c84SBernhard Beschow                         reg_value);
200f4427280SJean-Christophe Dubois 
201f4427280SJean-Christophe Dubois     return reg_value;
202f4427280SJean-Christophe Dubois }
203f4427280SJean-Christophe Dubois 
204f4427280SJean-Christophe Dubois static void imx_gpio_write(void *opaque, hwaddr offset, uint64_t value,
205f4427280SJean-Christophe Dubois                            unsigned size)
206f4427280SJean-Christophe Dubois {
207f4427280SJean-Christophe Dubois     IMXGPIOState *s = IMX_GPIO(opaque);
208f4427280SJean-Christophe Dubois 
209e3778c84SBernhard Beschow     trace_imx_gpio_write(DEVICE(s)->canonical_path, imx_gpio_reg_name(offset),
210e3778c84SBernhard Beschow                          value);
211f4427280SJean-Christophe Dubois 
212f4427280SJean-Christophe Dubois     switch (offset) {
213f4427280SJean-Christophe Dubois     case DR_ADDR:
214f4427280SJean-Christophe Dubois         s->dr = value;
215f4427280SJean-Christophe Dubois         imx_gpio_set_all_output_lines(s);
216f4427280SJean-Christophe Dubois         break;
217f4427280SJean-Christophe Dubois 
218f4427280SJean-Christophe Dubois     case GDIR_ADDR:
219f4427280SJean-Christophe Dubois         s->gdir = value;
220f4427280SJean-Christophe Dubois         imx_gpio_set_all_output_lines(s);
221f4427280SJean-Christophe Dubois         imx_gpio_set_all_int_lines(s);
222f4427280SJean-Christophe Dubois         break;
223f4427280SJean-Christophe Dubois 
224f4427280SJean-Christophe Dubois     case ICR1_ADDR:
225f4427280SJean-Christophe Dubois         s->icr = deposit64(s->icr, 0, 32, value);
226f4427280SJean-Christophe Dubois         imx_gpio_set_all_int_lines(s);
227f4427280SJean-Christophe Dubois         break;
228f4427280SJean-Christophe Dubois 
229f4427280SJean-Christophe Dubois     case ICR2_ADDR:
230f4427280SJean-Christophe Dubois         s->icr = deposit64(s->icr, 32, 32, value);
231f4427280SJean-Christophe Dubois         imx_gpio_set_all_int_lines(s);
232f4427280SJean-Christophe Dubois         break;
233f4427280SJean-Christophe Dubois 
234f4427280SJean-Christophe Dubois     case IMR_ADDR:
235f4427280SJean-Christophe Dubois         s->imr = value;
236f4427280SJean-Christophe Dubois         imx_gpio_update_int(s);
237f4427280SJean-Christophe Dubois         break;
238f4427280SJean-Christophe Dubois 
239f4427280SJean-Christophe Dubois     case ISR_ADDR:
240fb70029bSGuenter Roeck         s->isr &= ~value;
241f4427280SJean-Christophe Dubois         imx_gpio_set_all_int_lines(s);
242f4427280SJean-Christophe Dubois         break;
243f4427280SJean-Christophe Dubois 
244f4427280SJean-Christophe Dubois     case EDGE_SEL_ADDR:
245f4427280SJean-Christophe Dubois         if (s->has_edge_sel) {
246f4427280SJean-Christophe Dubois             s->edge_sel = value;
247f4427280SJean-Christophe Dubois             imx_gpio_set_all_int_lines(s);
248f4427280SJean-Christophe Dubois         } else {
24956411125SJean-Christophe Dubois             qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: EDGE_SEL register not "
250f4427280SJean-Christophe Dubois                           "present on this version of GPIO device\n",
251f4427280SJean-Christophe Dubois                           TYPE_IMX_GPIO, __func__);
252f4427280SJean-Christophe Dubois         }
253f4427280SJean-Christophe Dubois         break;
254f4427280SJean-Christophe Dubois 
255f4427280SJean-Christophe Dubois     default:
25656411125SJean-Christophe Dubois         qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: Bad register at offset 0x%"
25756411125SJean-Christophe Dubois                       HWADDR_PRIx "\n", TYPE_IMX_GPIO, __func__, offset);
258f4427280SJean-Christophe Dubois         break;
259f4427280SJean-Christophe Dubois     }
260f4427280SJean-Christophe Dubois }
261f4427280SJean-Christophe Dubois 
262f4427280SJean-Christophe Dubois static const MemoryRegionOps imx_gpio_ops = {
263f4427280SJean-Christophe Dubois     .read = imx_gpio_read,
264f4427280SJean-Christophe Dubois     .write = imx_gpio_write,
265f4427280SJean-Christophe Dubois     .valid.min_access_size = 4,
266f4427280SJean-Christophe Dubois     .valid.max_access_size = 4,
267f4427280SJean-Christophe Dubois     .endianness = DEVICE_NATIVE_ENDIAN,
268f4427280SJean-Christophe Dubois };
269f4427280SJean-Christophe Dubois 
270f4427280SJean-Christophe Dubois static const VMStateDescription vmstate_imx_gpio = {
271f4427280SJean-Christophe Dubois     .name = TYPE_IMX_GPIO,
272f4427280SJean-Christophe Dubois     .version_id = 1,
273f4427280SJean-Christophe Dubois     .minimum_version_id = 1,
2743b9e779bSRichard Henderson     .fields = (const VMStateField[]) {
275f4427280SJean-Christophe Dubois         VMSTATE_UINT32(dr, IMXGPIOState),
276f4427280SJean-Christophe Dubois         VMSTATE_UINT32(gdir, IMXGPIOState),
277f4427280SJean-Christophe Dubois         VMSTATE_UINT32(psr, IMXGPIOState),
278f4427280SJean-Christophe Dubois         VMSTATE_UINT64(icr, IMXGPIOState),
279f4427280SJean-Christophe Dubois         VMSTATE_UINT32(imr, IMXGPIOState),
280f4427280SJean-Christophe Dubois         VMSTATE_UINT32(isr, IMXGPIOState),
281f4427280SJean-Christophe Dubois         VMSTATE_BOOL(has_edge_sel, IMXGPIOState),
282f4427280SJean-Christophe Dubois         VMSTATE_UINT32(edge_sel, IMXGPIOState),
283f4427280SJean-Christophe Dubois         VMSTATE_END_OF_LIST()
284f4427280SJean-Christophe Dubois     }
285f4427280SJean-Christophe Dubois };
286f4427280SJean-Christophe Dubois 
287de531a6bSRichard Henderson static const Property imx_gpio_properties[] = {
288f4427280SJean-Christophe Dubois     DEFINE_PROP_BOOL("has-edge-sel", IMXGPIOState, has_edge_sel, true),
289f1f7e4bfSJean-Christophe Dubois     DEFINE_PROP_BOOL("has-upper-pin-irq", IMXGPIOState, has_upper_pin_irq,
290f1f7e4bfSJean-Christophe Dubois                      false),
291f4427280SJean-Christophe Dubois };
292f4427280SJean-Christophe Dubois 
293f4427280SJean-Christophe Dubois static void imx_gpio_reset(DeviceState *dev)
294f4427280SJean-Christophe Dubois {
295f4427280SJean-Christophe Dubois     IMXGPIOState *s = IMX_GPIO(dev);
296f4427280SJean-Christophe Dubois 
297f4427280SJean-Christophe Dubois     s->dr       = 0;
298f4427280SJean-Christophe Dubois     s->gdir     = 0;
299f4427280SJean-Christophe Dubois     s->psr      = 0;
300f4427280SJean-Christophe Dubois     s->icr      = 0;
301f4427280SJean-Christophe Dubois     s->imr      = 0;
302f4427280SJean-Christophe Dubois     s->isr      = 0;
303f4427280SJean-Christophe Dubois     s->edge_sel = 0;
304f4427280SJean-Christophe Dubois 
305f4427280SJean-Christophe Dubois     imx_gpio_set_all_output_lines(s);
306f4427280SJean-Christophe Dubois     imx_gpio_update_int(s);
307f4427280SJean-Christophe Dubois }
308f4427280SJean-Christophe Dubois 
309f4427280SJean-Christophe Dubois static void imx_gpio_realize(DeviceState *dev, Error **errp)
310f4427280SJean-Christophe Dubois {
311f4427280SJean-Christophe Dubois     IMXGPIOState *s = IMX_GPIO(dev);
312f4427280SJean-Christophe Dubois 
313f4427280SJean-Christophe Dubois     memory_region_init_io(&s->iomem, OBJECT(s), &imx_gpio_ops, s,
314f4427280SJean-Christophe Dubois                           TYPE_IMX_GPIO, IMX_GPIO_MEM_SIZE);
315f4427280SJean-Christophe Dubois 
316f4427280SJean-Christophe Dubois     qdev_init_gpio_in(DEVICE(s), imx_gpio_set, IMX_GPIO_PIN_COUNT);
317f4427280SJean-Christophe Dubois     qdev_init_gpio_out(DEVICE(s), s->output, IMX_GPIO_PIN_COUNT);
318f4427280SJean-Christophe Dubois 
319f1f7e4bfSJean-Christophe Dubois     sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq[0]);
320f1f7e4bfSJean-Christophe Dubois     sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq[1]);
321f4427280SJean-Christophe Dubois     sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem);
322f4427280SJean-Christophe Dubois }
323f4427280SJean-Christophe Dubois 
32412d1a768SPhilippe Mathieu-Daudé static void imx_gpio_class_init(ObjectClass *klass, const void *data)
325f4427280SJean-Christophe Dubois {
326f4427280SJean-Christophe Dubois     DeviceClass *dc = DEVICE_CLASS(klass);
327f4427280SJean-Christophe Dubois 
328f4427280SJean-Christophe Dubois     dc->realize = imx_gpio_realize;
329e3d08143SPeter Maydell     device_class_set_legacy_reset(dc, imx_gpio_reset);
3304f67d30bSMarc-André Lureau     device_class_set_props(dc, imx_gpio_properties);
331f4427280SJean-Christophe Dubois     dc->vmsd = &vmstate_imx_gpio;
332f4427280SJean-Christophe Dubois     dc->desc = "i.MX GPIO controller";
333f4427280SJean-Christophe Dubois }
334f4427280SJean-Christophe Dubois 
335f4427280SJean-Christophe Dubois static const TypeInfo imx_gpio_info = {
336f4427280SJean-Christophe Dubois     .name = TYPE_IMX_GPIO,
337f4427280SJean-Christophe Dubois     .parent = TYPE_SYS_BUS_DEVICE,
338f4427280SJean-Christophe Dubois     .instance_size = sizeof(IMXGPIOState),
339f4427280SJean-Christophe Dubois     .class_init = imx_gpio_class_init,
340f4427280SJean-Christophe Dubois };
341f4427280SJean-Christophe Dubois 
342f4427280SJean-Christophe Dubois static void imx_gpio_register_types(void)
343f4427280SJean-Christophe Dubois {
344f4427280SJean-Christophe Dubois     type_register_static(&imx_gpio_info);
345f4427280SJean-Christophe Dubois }
346f4427280SJean-Christophe Dubois 
347f4427280SJean-Christophe Dubois type_init(imx_gpio_register_types)
348