npcm7xx_gpio.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * Nuvoton NPCM7xx General Purpose Input / Output (GPIO)
  3. *
  4. * Copyright 2020 Google LLC
  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
  8. * version 2 as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. */
  15. #ifndef NPCM7XX_GPIO_H
  16. #define NPCM7XX_GPIO_H
  17. #include "exec/memory.h"
  18. #include "hw/sysbus.h"
  19. /* Number of pins managed by each controller. */
  20. #define NPCM7XX_GPIO_NR_PINS (32)
  21. /*
  22. * Number of registers in our device state structure. Don't change this without
  23. * incrementing the version_id in the vmstate.
  24. */
  25. #define NPCM7XX_GPIO_NR_REGS (0x80 / sizeof(uint32_t))
  26. typedef struct NPCM7xxGPIOState {
  27. SysBusDevice parent;
  28. /* Properties to be defined by the SoC */
  29. uint32_t reset_pu;
  30. uint32_t reset_pd;
  31. uint32_t reset_osrc;
  32. uint32_t reset_odsc;
  33. MemoryRegion mmio;
  34. qemu_irq irq;
  35. qemu_irq output[NPCM7XX_GPIO_NR_PINS];
  36. uint32_t pin_level;
  37. uint32_t ext_level;
  38. uint32_t ext_driven;
  39. uint32_t regs[NPCM7XX_GPIO_NR_REGS];
  40. } NPCM7xxGPIOState;
  41. #define TYPE_NPCM7XX_GPIO "npcm7xx-gpio"
  42. #define NPCM7XX_GPIO(obj) \
  43. OBJECT_CHECK(NPCM7xxGPIOState, (obj), TYPE_NPCM7XX_GPIO)
  44. #endif /* NPCM7XX_GPIO_H */