ccn.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. * Copyright (c) 2015, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef CCN_H
  7. #define CCN_H
  8. /*
  9. * This macro defines the maximum number of master interfaces that reside on
  10. * Request nodes which the CCN driver can accommodate. The driver APIs to add
  11. * and remove Request nodes from snoop/dvm domains take a bit map of master
  12. * interfaces as inputs. The largest C data type that can be used is a 64-bit
  13. * unsigned integer. Hence the value of 64. The platform will have to ensure
  14. * that the master interfaces are numbered from 0-63.
  15. */
  16. #define CCN_MAX_RN_MASTERS 64
  17. /*
  18. * The following constants define the various run modes that the platform can
  19. * request the CCN driver to place the L3 cache in. These map to the
  20. * programmable P-State values in a HN-F P-state register.
  21. */
  22. #define CCN_L3_RUN_MODE_NOL3 0x0 /* HNF_PM_NOL3 */
  23. #define CCN_L3_RUN_MODE_SFONLY 0x1 /* HNF_PM_SFONLY */
  24. #define CCN_L3_RUN_MODE_HAM 0x2 /* HNF_PM_HALF */
  25. #define CCN_L3_RUN_MODE_FAM 0x3 /* HNF_PM_FULL */
  26. /* part 0 IDs for various CCN variants */
  27. #define CCN_502_PART0_ID 0x30
  28. #define CCN_504_PART0_ID 0x26
  29. #define CCN_505_PART0_ID 0x27
  30. #define CCN_508_PART0_ID 0x28
  31. #define CCN_512_PART0_ID 0x29
  32. /*
  33. * The following macro takes the value returned from a read of a HN-F P-state
  34. * status register and returns the retention state value.
  35. */
  36. #define CCN_GET_RETENTION_STATE(pstate) ((pstate >> 4) & 0x3)
  37. /*
  38. * The following macro takes the value returned from a read of a HN-F P-state
  39. * status register and returns the run state value.
  40. */
  41. #define CCN_GET_RUN_STATE(pstate) (pstate & 0xf)
  42. #ifndef __ASSEMBLER__
  43. #include <stdint.h>
  44. /*
  45. * This structure describes some of the implementation defined attributes of the
  46. * CCN IP. It is used by the platform port to specify these attributes in order
  47. * to initialise the CCN driver. The attributes are described below.
  48. *
  49. * 1. The 'num_masters' field specifies the total number of master interfaces
  50. * resident on Request nodes.
  51. *
  52. * 2. The 'master_to_rn_id_map' field is a ponter to an array in which each
  53. * index corresponds to a master interface and its value corresponds to the
  54. * Request node on which the master interface resides.
  55. * This field is not simply defined as an array of size CCN_MAX_RN_MASTERS.
  56. * In reality, a platform will have much fewer master * interfaces than
  57. * CCN_MAX_RN_MASTERS. With an array of this size, it would also have to
  58. * set the unused entries to a suitable value. Zeroing the array would not
  59. * be enough since 0 is also a valid node id. Hence, such an array is not
  60. * used.
  61. *
  62. * 3. The 'periphbase' field is the base address of the programmer's view of the
  63. * CCN IP.
  64. */
  65. typedef struct ccn_desc {
  66. unsigned int num_masters;
  67. const unsigned char *master_to_rn_id_map;
  68. uintptr_t periphbase;
  69. } ccn_desc_t;
  70. /* Enum used to loop through all types of nodes in CCN*/
  71. typedef enum node_types {
  72. NODE_TYPE_RNF = 0,
  73. NODE_TYPE_RNI,
  74. NODE_TYPE_RND,
  75. NODE_TYPE_HNF,
  76. NODE_TYPE_HNI,
  77. NODE_TYPE_SN,
  78. NUM_NODE_TYPES
  79. } node_types_t;
  80. void ccn_init(const ccn_desc_t *plat_ccn_desc);
  81. void ccn_enter_snoop_dvm_domain(unsigned long long master_iface_map);
  82. void ccn_exit_snoop_dvm_domain(unsigned long long master_iface_map);
  83. void ccn_enter_dvm_domain(unsigned long long master_iface_map);
  84. void ccn_exit_dvm_domain(unsigned long long master_iface_map);
  85. void ccn_set_l3_run_mode(unsigned int mode);
  86. void ccn_program_sys_addrmap(unsigned int sn0_id,
  87. unsigned int sn1_id,
  88. unsigned int sn2_id,
  89. unsigned int top_addr_bit0,
  90. unsigned int top_addr_bit1,
  91. unsigned char three_sn_en);
  92. unsigned int ccn_get_l3_run_mode(void);
  93. int ccn_get_part0_id(uintptr_t periphbase);
  94. void ccn_write_node_reg(node_types_t node_type, unsigned int node_id,
  95. unsigned int reg_offset,
  96. unsigned long long val);
  97. unsigned long long ccn_read_node_reg(node_types_t node_type,
  98. unsigned int node_id,
  99. unsigned int reg_offset);
  100. #endif /* __ASSEMBLER__ */
  101. #endif /* CCN_H */