mcb-internal.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. #ifndef __MCB_INTERNAL
  2. #define __MCB_INTERNAL
  3. #include <linux/types.h>
  4. #define PCI_VENDOR_ID_MEN 0x1a88
  5. #define PCI_DEVICE_ID_MEN_CHAMELEON 0x4d45
  6. #define CHAMELEONV2_MAGIC 0xabce
  7. #define CHAM_HEADER_SIZE 0x200
  8. enum chameleon_descriptor_type {
  9. CHAMELEON_DTYPE_GENERAL = 0x0,
  10. CHAMELEON_DTYPE_BRIDGE = 0x1,
  11. CHAMELEON_DTYPE_CPU = 0x2,
  12. CHAMELEON_DTYPE_BAR = 0x3,
  13. CHAMELEON_DTYPE_END = 0xf,
  14. };
  15. enum chameleon_bus_type {
  16. CHAMELEON_BUS_WISHBONE,
  17. CHAMELEON_BUS_AVALON,
  18. CHAMELEON_BUS_LPC,
  19. CHAMELEON_BUS_ISA,
  20. };
  21. /**
  22. * struct chameleon_fpga_header
  23. *
  24. * @revision: Revison of Chameleon table in FPGA
  25. * @model: Chameleon table model ASCII char
  26. * @minor: Revision minor
  27. * @bus_type: Bus type (usually %CHAMELEON_BUS_WISHBONE)
  28. * @magic: Chameleon header magic number (0xabce for version 2)
  29. * @reserved: Reserved
  30. * @filename: Filename of FPGA bitstream
  31. */
  32. struct chameleon_fpga_header {
  33. u8 revision;
  34. char model;
  35. u8 minor;
  36. u8 bus_type;
  37. u16 magic;
  38. u16 reserved;
  39. /* This one has no '\0' at the end!!! */
  40. char filename[CHAMELEON_FILENAME_LEN];
  41. } __packed;
  42. #define HEADER_MAGIC_OFFSET 0x4
  43. /**
  44. * struct chameleon_gdd - Chameleon General Device Descriptor
  45. *
  46. * @irq: the position in the FPGA's IRQ controller vector
  47. * @rev: the revision of the variant's implementation
  48. * @var: the variant of the IP core
  49. * @dev: the device the IP core is
  50. * @dtype: device descriptor type
  51. * @bar: BAR offset that must be added to module offset
  52. * @inst: the instance number of the device, 0 is first instance
  53. * @group: the group the device belongs to (0 = no group)
  54. * @reserved: reserved
  55. * @offset: beginning of the address window of desired module
  56. * @size: size of the module's address window
  57. */
  58. struct chameleon_gdd {
  59. __le32 reg1;
  60. __le32 reg2;
  61. __le32 offset;
  62. __le32 size;
  63. } __packed;
  64. /* GDD Register 1 fields */
  65. #define GDD_IRQ(x) ((x) & 0x1f)
  66. #define GDD_REV(x) (((x) >> 5) & 0x3f)
  67. #define GDD_VAR(x) (((x) >> 11) & 0x3f)
  68. #define GDD_DEV(x) (((x) >> 18) & 0x3ff)
  69. #define GDD_DTY(x) (((x) >> 28) & 0xf)
  70. /* GDD Register 2 fields */
  71. #define GDD_BAR(x) ((x) & 0x7)
  72. #define GDD_INS(x) (((x) >> 3) & 0x3f)
  73. #define GDD_GRP(x) (((x) >> 9) & 0x3f)
  74. /**
  75. * struct chameleon_bdd - Chameleon Bridge Device Descriptor
  76. *
  77. * @irq: the position in the FPGA's IRQ controller vector
  78. * @rev: the revision of the variant's implementation
  79. * @var: the variant of the IP core
  80. * @dev: the device the IP core is
  81. * @dtype: device descriptor type
  82. * @bar: BAR offset that must be added to module offset
  83. * @inst: the instance number of the device, 0 is first instance
  84. * @dbar: destination bar from the bus _behind_ the bridge
  85. * @chamoff: offset within the BAR of the source bus
  86. * @offset:
  87. * @size:
  88. */
  89. struct chameleon_bdd {
  90. unsigned int irq:6;
  91. unsigned int rev:6;
  92. unsigned int var:6;
  93. unsigned int dev:10;
  94. unsigned int dtype:4;
  95. unsigned int bar:3;
  96. unsigned int inst:6;
  97. unsigned int dbar:3;
  98. unsigned int group:6;
  99. unsigned int reserved:14;
  100. u32 chamoff;
  101. u32 offset;
  102. u32 size;
  103. } __packed;
  104. struct chameleon_bar {
  105. u32 addr;
  106. u32 size;
  107. };
  108. #define BAR_CNT(x) ((x) & 0x07)
  109. #define CHAMELEON_BAR_MAX 6
  110. #define BAR_DESC_SIZE(x) ((x) * sizeof(struct chameleon_bar) + sizeof(__le32))
  111. int chameleon_parse_cells(struct mcb_bus *bus, phys_addr_t mapbase,
  112. void __iomem *base);
  113. #endif