imx.h 2.7 KB

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