imx_gpio.h 1.9 KB

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