imx.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Interconnect framework driver for i.MX SoC
  4. *
  5. * Copyright (c) 2019, BayLibre
  6. * Copyright (c) 2019-2020, NXP
  7. * Author: Alexandre Bailon <[email protected]>
  8. * Author: Leonard Crestez <[email protected]>
  9. */
  10. #ifndef __DRIVERS_INTERCONNECT_IMX_H
  11. #define __DRIVERS_INTERCONNECT_IMX_H
  12. #include <linux/interconnect-provider.h>
  13. #include <linux/kernel.h>
  14. #define IMX_ICC_MAX_LINKS 4
  15. /*
  16. * High throughput priority level in Regulator mode
  17. * Read Priority in Fixed/Limiter mode
  18. */
  19. #define PRIORITY0_SHIFT 0
  20. /*
  21. * Low throughput priority level in Regulator mode
  22. * Write Priority in Fixed/Limiter mode
  23. */
  24. #define PRIORITY1_SHIFT 8
  25. #define PRIORITY_MASK 0x7
  26. #define PRIORITY_COMP_MARK BIT(31) /* Must set */
  27. #define IMX_NOC_MODE_FIXED 0
  28. #define IMX_NOC_MODE_LIMITER 1
  29. #define IMX_NOC_MODE_BYPASS 2
  30. #define IMX_NOC_MODE_REGULATOR 3
  31. #define IMX_NOC_MODE_UNCONFIGURED 0xFF
  32. #define IMX_NOC_PRIO_REG 0x8
  33. #define IMX_NOC_MODE_REG 0xC
  34. #define IMX_NOC_BANDWIDTH_REG 0x10
  35. #define IMX_NOC_SATURATION 0x14
  36. #define IMX_NOC_EXT_CTL_REG 0x18
  37. struct imx_icc_provider {
  38. void __iomem *noc_base;
  39. struct icc_provider provider;
  40. };
  41. /*
  42. * struct imx_icc_node_adj - Describe a dynamic adjustable node
  43. */
  44. struct imx_icc_node_adj_desc {
  45. unsigned int bw_mul, bw_div;
  46. const char *phandle_name;
  47. bool main_noc;
  48. };
  49. /*
  50. * struct imx_icc_node - Describe an interconnect node
  51. * @name: name of the node
  52. * @id: an unique id to identify the node
  53. * @links: an array of slaves' node id
  54. * @num_links: number of id defined in links
  55. */
  56. struct imx_icc_node_desc {
  57. const char *name;
  58. u16 id;
  59. u16 links[IMX_ICC_MAX_LINKS];
  60. u16 num_links;
  61. const struct imx_icc_node_adj_desc *adj;
  62. };
  63. /*
  64. * struct imx_icc_noc_setting - Describe an interconnect node setting
  65. * @reg: register offset inside the NoC
  66. * @prio_level: priority level
  67. * @mode: functional mode
  68. * @ext_control: external input control
  69. */
  70. struct imx_icc_noc_setting {
  71. u32 reg;
  72. u32 prio_level;
  73. u32 mode;
  74. u32 ext_control;
  75. };
  76. #define DEFINE_BUS_INTERCONNECT(_name, _id, _adj, ...) \
  77. { \
  78. .id = _id, \
  79. .name = _name, \
  80. .adj = _adj, \
  81. .num_links = ARRAY_SIZE(((int[]){ __VA_ARGS__ })), \
  82. .links = { __VA_ARGS__ }, \
  83. }
  84. #define DEFINE_BUS_MASTER(_name, _id, _dest_id) \
  85. DEFINE_BUS_INTERCONNECT(_name, _id, NULL, _dest_id)
  86. #define DEFINE_BUS_SLAVE(_name, _id, _adj) \
  87. DEFINE_BUS_INTERCONNECT(_name, _id, _adj)
  88. int imx_icc_register(struct platform_device *pdev,
  89. struct imx_icc_node_desc *nodes,
  90. int nodes_count,
  91. struct imx_icc_noc_setting *noc_settings);
  92. void imx_icc_unregister(struct platform_device *pdev);
  93. #endif /* __DRIVERS_INTERCONNECT_IMX_H */