virtio_mmio.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Copyright (C) 2018, Tuomas Tynkkynen <tuomas.tynkkynen@iki.fi>
  4. * Copyright (C) 2018, Bin Meng <bmeng.cn@gmail.com>
  5. *
  6. * From Linux kernel include/uapi/linux/virtio_mmio.h
  7. */
  8. #ifndef _LINUX_VIRTIO_MMIO_H
  9. #define _LINUX_VIRTIO_MMIO_H
  10. /* Control registers */
  11. /* Magic value ("virt" string) - Read Only */
  12. #define VIRTIO_MMIO_MAGIC_VALUE 0x000
  13. /* Virtio device version - Read Only */
  14. #define VIRTIO_MMIO_VERSION 0x004
  15. /* Virtio device ID - Read Only */
  16. #define VIRTIO_MMIO_DEVICE_ID 0x008
  17. /* Virtio vendor ID - Read Only */
  18. #define VIRTIO_MMIO_VENDOR_ID 0x00c
  19. /*
  20. * Bitmask of the features supported by the device (host)
  21. * (32 bits per set) - Read Only
  22. */
  23. #define VIRTIO_MMIO_DEVICE_FEATURES 0x010
  24. /* Device (host) features set selector - Write Only */
  25. #define VIRTIO_MMIO_DEVICE_FEATURES_SEL 0x014
  26. /*
  27. * Bitmask of features activated by the driver (guest)
  28. * (32 bits per set) - Write Only
  29. */
  30. #define VIRTIO_MMIO_DRIVER_FEATURES 0x020
  31. /* Activated features set selector - Write Only */
  32. #define VIRTIO_MMIO_DRIVER_FEATURES_SEL 0x024
  33. #ifndef VIRTIO_MMIO_NO_LEGACY /* LEGACY DEVICES ONLY! */
  34. /* Guest's memory page size in bytes - Write Only */
  35. #define VIRTIO_MMIO_GUEST_PAGE_SIZE 0x028
  36. #endif
  37. /* Queue selector - Write Only */
  38. #define VIRTIO_MMIO_QUEUE_SEL 0x030
  39. /* Maximum size of the currently selected queue - Read Only */
  40. #define VIRTIO_MMIO_QUEUE_NUM_MAX 0x034
  41. /* Queue size for the currently selected queue - Write Only */
  42. #define VIRTIO_MMIO_QUEUE_NUM 0x038
  43. #ifndef VIRTIO_MMIO_NO_LEGACY /* LEGACY DEVICES ONLY! */
  44. /* Used Ring alignment for the currently selected queue - Write Only */
  45. #define VIRTIO_MMIO_QUEUE_ALIGN 0x03c
  46. /* Guest's PFN for the currently selected queue - Read Write */
  47. #define VIRTIO_MMIO_QUEUE_PFN 0x040
  48. #endif
  49. /* Ready bit for the currently selected queue - Read Write */
  50. #define VIRTIO_MMIO_QUEUE_READY 0x044
  51. /* Queue notifier - Write Only */
  52. #define VIRTIO_MMIO_QUEUE_NOTIFY 0x050
  53. /* Interrupt status - Read Only */
  54. #define VIRTIO_MMIO_INTERRUPT_STATUS 0x060
  55. /* Interrupt acknowledge - Write Only */
  56. #define VIRTIO_MMIO_INTERRUPT_ACK 0x064
  57. /* Device status register - Read Write */
  58. #define VIRTIO_MMIO_STATUS 0x070
  59. /* Selected queue's Descriptor Table address, 64 bits in two halves */
  60. #define VIRTIO_MMIO_QUEUE_DESC_LOW 0x080
  61. #define VIRTIO_MMIO_QUEUE_DESC_HIGH 0x084
  62. /* Selected queue's Available Ring address, 64 bits in two halves */
  63. #define VIRTIO_MMIO_QUEUE_AVAIL_LOW 0x090
  64. #define VIRTIO_MMIO_QUEUE_AVAIL_HIGH 0x094
  65. /* Selected queue's Used Ring address, 64 bits in two halves */
  66. #define VIRTIO_MMIO_QUEUE_USED_LOW 0x0a0
  67. #define VIRTIO_MMIO_QUEUE_USED_HIGH 0x0a4
  68. /* Configuration atomicity value */
  69. #define VIRTIO_MMIO_CONFIG_GENERATION 0x0fc
  70. /*
  71. * The config space is defined by each driver as
  72. * the per-driver configuration space - Read Write
  73. */
  74. #define VIRTIO_MMIO_CONFIG 0x100
  75. /* Interrupt flags (re: interrupt status & acknowledge registers) */
  76. #define VIRTIO_MMIO_INT_VRING BIT(0)
  77. #define VIRTIO_MMIO_INT_CONFIG BIT(1)
  78. /*
  79. * The alignment to use between consumer and producer parts of vring.
  80. * Currently hardcoded to the page size.
  81. */
  82. #define PAGE_SHIFT 12
  83. #define VIRTIO_MMIO_VRING_ALIGN PAGE_SIZE
  84. /**
  85. * virtio mmio transport driver private data
  86. *
  87. * @base: mmio transport device register base
  88. * @version: mmio transport device version
  89. */
  90. struct virtio_mmio_priv {
  91. void __iomem *base;
  92. u32 version;
  93. };
  94. #endif /* _LINUX_VIRTIO_MMIO_H */