gic600_multichip_private.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. * Copyright (c) 2019-2023, ARM Limited. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef GIC600_MULTICHIP_PRIVATE_H
  7. #define GIC600_MULTICHIP_PRIVATE_H
  8. #include <drivers/arm/gic600_multichip.h>
  9. #include "gicv3_private.h"
  10. /* GIC600 GICD multichip related offsets */
  11. #define GICD_CHIPSR U(0xC000)
  12. #define GICD_DCHIPR U(0xC004)
  13. #define GICD_CHIPR U(0xC008)
  14. /* GIC600 GICD multichip related masks */
  15. #define GICD_CHIPRx_PUP_BIT BIT_64(1)
  16. #define GICD_CHIPRx_SOCKET_STATE BIT_64(0)
  17. #define GICD_DCHIPR_PUP_BIT BIT_32(0)
  18. #define GICD_CHIPSR_RTS_MASK (BIT_32(4) | BIT_32(5))
  19. /* GIC600 GICD multichip related shifts */
  20. #define GICD_CHIPRx_ADDR_SHIFT 16
  21. #define GICD_CHIPSR_RTS_SHIFT 4
  22. #define GICD_DCHIPR_RT_OWNER_SHIFT 4
  23. /* Other shifts and masks remain the same between GIC-600 and GIC-700. */
  24. #define GIC_700_SPI_BLOCK_MIN_SHIFT 9
  25. #define GIC_700_SPI_BLOCKS_SHIFT 3
  26. #define GIC_600_SPI_BLOCK_MIN_SHIFT 10
  27. #define GIC_600_SPI_BLOCKS_SHIFT 5
  28. #define GICD_CHIPSR_RTS_STATE_DISCONNECTED U(0)
  29. #define GICD_CHIPSR_RTS_STATE_UPDATING U(1)
  30. #define GICD_CHIPSR_RTS_STATE_CONSISTENT U(2)
  31. /* SPI interrupt id minimum and maximum range */
  32. #define GIC600_SPI_ID_MIN 32
  33. #define GIC600_SPI_ID_MAX 991
  34. #define GIC700_SPI_ID_MIN 32
  35. #define GIC700_SPI_ID_MAX 991
  36. #define GIC700_ESPI_ID_MIN 4096
  37. #define GIC700_ESPI_ID_MAX 5119
  38. /* Number of retries for PUP update */
  39. #define GICD_PUP_UPDATE_RETRIES 10000
  40. #define SPI_BLOCK_MIN_VALUE(spi_id_min) \
  41. (((spi_id_min) - GIC600_SPI_ID_MIN) / \
  42. GIC600_SPI_ID_MIN)
  43. #define SPI_BLOCKS_VALUE(spi_id_min, spi_id_max) \
  44. (((spi_id_max) - (spi_id_min) + 1) / \
  45. GIC600_SPI_ID_MIN)
  46. #define ESPI_BLOCK_MIN_VALUE(spi_id_min) \
  47. (((spi_id_min) - GIC700_ESPI_ID_MIN + 1) / \
  48. GIC700_SPI_ID_MIN)
  49. #define GICD_CHIPR_VALUE_GIC_700(chip_addr, spi_block_min, spi_blocks) \
  50. (((chip_addr) << GICD_CHIPRx_ADDR_SHIFT) | \
  51. ((spi_block_min) << GIC_700_SPI_BLOCK_MIN_SHIFT) | \
  52. ((spi_blocks) << GIC_700_SPI_BLOCKS_SHIFT))
  53. #define GICD_CHIPR_VALUE_GIC_600(chip_addr, spi_block_min, spi_blocks) \
  54. (((chip_addr) << GICD_CHIPRx_ADDR_SHIFT) | \
  55. ((spi_block_min) << GIC_600_SPI_BLOCK_MIN_SHIFT) | \
  56. ((spi_blocks) << GIC_600_SPI_BLOCKS_SHIFT))
  57. /*
  58. * Multichip data assertion macros
  59. */
  60. /* Set bits from 0 to ((spi_id_max + 1) / 32) */
  61. #define SPI_BLOCKS_TILL_MAX(spi_id_max) \
  62. ((1ULL << (((spi_id_max) + 1) >> 5)) - 1)
  63. /* Set bits from 0 to (spi_id_min / 32) */
  64. #define SPI_BLOCKS_TILL_MIN(spi_id_min) ((1 << ((spi_id_min) >> 5)) - 1)
  65. /* Set bits from (spi_id_min / 32) to ((spi_id_max + 1) / 32) */
  66. #define BLOCKS_OF_32(spi_id_min, spi_id_max) \
  67. SPI_BLOCKS_TILL_MAX(spi_id_max) ^ \
  68. SPI_BLOCKS_TILL_MIN(spi_id_min)
  69. /*******************************************************************************
  70. * GIC-600 multichip operation related helper functions
  71. ******************************************************************************/
  72. static inline uint32_t read_gicd_dchipr(uintptr_t base)
  73. {
  74. return mmio_read_32(base + GICD_DCHIPR);
  75. }
  76. static inline uint64_t read_gicd_chipr_n(uintptr_t base, uint8_t n)
  77. {
  78. return mmio_read_64(base + (GICD_CHIPR + (8U * n)));
  79. }
  80. static inline uint32_t read_gicd_chipsr(uintptr_t base)
  81. {
  82. return mmio_read_32(base + GICD_CHIPSR);
  83. }
  84. static inline void write_gicd_dchipr(uintptr_t base, uint32_t val)
  85. {
  86. mmio_write_32(base + GICD_DCHIPR, val);
  87. }
  88. static inline void write_gicd_chipr_n(uintptr_t base, uint8_t n, uint64_t val)
  89. {
  90. mmio_write_64(base + (GICD_CHIPR + (8U * n)), val);
  91. }
  92. #endif /* GIC600_MULTICHIP_PRIVATE_H */