2
0

sifive_gpio.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * SiFive System-on-Chip general purpose input/output register definition
  3. *
  4. * Copyright 2019 AdaCore
  5. *
  6. * Base on nrf51_gpio.c:
  7. *
  8. * Copyright 2018 Steffen Görtz <contrib@steffen-goertz.de>
  9. *
  10. * This code is licensed under the GPL version 2 or later. See
  11. * the COPYING file in the top-level directory.
  12. */
  13. #ifndef SIFIVE_GPIO_H
  14. #define SIFIVE_GPIO_H
  15. #include "hw/sysbus.h"
  16. #include "qom/object.h"
  17. #define TYPE_SIFIVE_GPIO "sifive_soc.gpio"
  18. typedef struct SIFIVEGPIOState SIFIVEGPIOState;
  19. DECLARE_INSTANCE_CHECKER(SIFIVEGPIOState, SIFIVE_GPIO,
  20. TYPE_SIFIVE_GPIO)
  21. #define SIFIVE_GPIO_PINS 32
  22. #define SIFIVE_GPIO_SIZE 0x100
  23. #define SIFIVE_GPIO_REG_VALUE 0x000
  24. #define SIFIVE_GPIO_REG_INPUT_EN 0x004
  25. #define SIFIVE_GPIO_REG_OUTPUT_EN 0x008
  26. #define SIFIVE_GPIO_REG_PORT 0x00C
  27. #define SIFIVE_GPIO_REG_PUE 0x010
  28. #define SIFIVE_GPIO_REG_DS 0x014
  29. #define SIFIVE_GPIO_REG_RISE_IE 0x018
  30. #define SIFIVE_GPIO_REG_RISE_IP 0x01C
  31. #define SIFIVE_GPIO_REG_FALL_IE 0x020
  32. #define SIFIVE_GPIO_REG_FALL_IP 0x024
  33. #define SIFIVE_GPIO_REG_HIGH_IE 0x028
  34. #define SIFIVE_GPIO_REG_HIGH_IP 0x02C
  35. #define SIFIVE_GPIO_REG_LOW_IE 0x030
  36. #define SIFIVE_GPIO_REG_LOW_IP 0x034
  37. #define SIFIVE_GPIO_REG_IOF_EN 0x038
  38. #define SIFIVE_GPIO_REG_IOF_SEL 0x03C
  39. #define SIFIVE_GPIO_REG_OUT_XOR 0x040
  40. struct SIFIVEGPIOState {
  41. SysBusDevice parent_obj;
  42. MemoryRegion mmio;
  43. qemu_irq irq[SIFIVE_GPIO_PINS];
  44. qemu_irq output[SIFIVE_GPIO_PINS];
  45. uint32_t value; /* Actual value of the pin */
  46. uint32_t input_en;
  47. uint32_t output_en;
  48. uint32_t port; /* Pin value requested by the user */
  49. uint32_t pue;
  50. uint32_t ds;
  51. uint32_t rise_ie;
  52. uint32_t rise_ip;
  53. uint32_t fall_ie;
  54. uint32_t fall_ip;
  55. uint32_t high_ie;
  56. uint32_t high_ip;
  57. uint32_t low_ie;
  58. uint32_t low_ip;
  59. uint32_t iof_en;
  60. uint32_t iof_sel;
  61. uint32_t out_xor;
  62. uint32_t in;
  63. uint32_t in_mask;
  64. /* config */
  65. uint32_t ngpio;
  66. };
  67. #endif /* SIFIVE_GPIO_H */