reset-stih407.c 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. /*
  2. * Copyright (C) 2014 STMicroelectronics (R&D) Limited
  3. * Author: Giuseppe Cavallaro <[email protected]>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. */
  10. #include <linux/module.h>
  11. #include <linux/of.h>
  12. #include <linux/of_platform.h>
  13. #include <linux/platform_device.h>
  14. #include <dt-bindings/reset/stih407-resets.h>
  15. #include "reset-syscfg.h"
  16. /* STiH407 Peripheral powerdown definitions. */
  17. static const char stih407_core[] = "st,stih407-core-syscfg";
  18. static const char stih407_sbc_reg[] = "st,stih407-sbc-reg-syscfg";
  19. static const char stih407_lpm[] = "st,stih407-lpm-syscfg";
  20. #define STIH407_PDN_0(_bit) \
  21. _SYSCFG_RST_CH(stih407_core, SYSCFG_5000, _bit, SYSSTAT_5500, _bit)
  22. #define STIH407_PDN_1(_bit) \
  23. _SYSCFG_RST_CH(stih407_core, SYSCFG_5001, _bit, SYSSTAT_5501, _bit)
  24. #define STIH407_PDN_ETH(_bit, _stat) \
  25. _SYSCFG_RST_CH(stih407_sbc_reg, SYSCFG_4032, _bit, SYSSTAT_4520, _stat)
  26. /* Powerdown requests control 0 */
  27. #define SYSCFG_5000 0x0
  28. #define SYSSTAT_5500 0x7d0
  29. /* Powerdown requests control 1 (High Speed Links) */
  30. #define SYSCFG_5001 0x4
  31. #define SYSSTAT_5501 0x7d4
  32. /* Ethernet powerdown/status/reset */
  33. #define SYSCFG_4032 0x80
  34. #define SYSSTAT_4520 0x820
  35. #define SYSCFG_4002 0x8
  36. static const struct syscfg_reset_channel_data stih407_powerdowns[] = {
  37. [STIH407_EMISS_POWERDOWN] = STIH407_PDN_0(1),
  38. [STIH407_NAND_POWERDOWN] = STIH407_PDN_0(0),
  39. [STIH407_USB3_POWERDOWN] = STIH407_PDN_1(6),
  40. [STIH407_USB2_PORT1_POWERDOWN] = STIH407_PDN_1(5),
  41. [STIH407_USB2_PORT0_POWERDOWN] = STIH407_PDN_1(4),
  42. [STIH407_PCIE1_POWERDOWN] = STIH407_PDN_1(3),
  43. [STIH407_PCIE0_POWERDOWN] = STIH407_PDN_1(2),
  44. [STIH407_SATA1_POWERDOWN] = STIH407_PDN_1(1),
  45. [STIH407_SATA0_POWERDOWN] = STIH407_PDN_1(0),
  46. [STIH407_ETH1_POWERDOWN] = STIH407_PDN_ETH(0, 2),
  47. };
  48. /* Reset Generator control 0/1 */
  49. #define SYSCFG_5128 0x200
  50. #define SYSCFG_5131 0x20c
  51. #define SYSCFG_5132 0x210
  52. #define LPM_SYSCFG_1 0x4 /* Softreset IRB & SBC UART */
  53. #define STIH407_SRST_CORE(_reg, _bit) \
  54. _SYSCFG_RST_CH_NO_ACK(stih407_core, _reg, _bit)
  55. #define STIH407_SRST_SBC(_reg, _bit) \
  56. _SYSCFG_RST_CH_NO_ACK(stih407_sbc_reg, _reg, _bit)
  57. #define STIH407_SRST_LPM(_reg, _bit) \
  58. _SYSCFG_RST_CH_NO_ACK(stih407_lpm, _reg, _bit)
  59. static const struct syscfg_reset_channel_data stih407_softresets[] = {
  60. [STIH407_ETH1_SOFTRESET] = STIH407_SRST_SBC(SYSCFG_4002, 4),
  61. [STIH407_MMC1_SOFTRESET] = STIH407_SRST_CORE(SYSCFG_5132, 3),
  62. [STIH407_USB2_PORT0_SOFTRESET] = STIH407_SRST_CORE(SYSCFG_5132, 28),
  63. [STIH407_USB2_PORT1_SOFTRESET] = STIH407_SRST_CORE(SYSCFG_5132, 29),
  64. [STIH407_PICOPHY_SOFTRESET] = STIH407_SRST_CORE(SYSCFG_5132, 30),
  65. [STIH407_IRB_SOFTRESET] = STIH407_SRST_LPM(LPM_SYSCFG_1, 6),
  66. [STIH407_PCIE0_SOFTRESET] = STIH407_SRST_CORE(SYSCFG_5132, 6),
  67. [STIH407_PCIE1_SOFTRESET] = STIH407_SRST_CORE(SYSCFG_5132, 15),
  68. [STIH407_SATA0_SOFTRESET] = STIH407_SRST_CORE(SYSCFG_5132, 7),
  69. [STIH407_SATA1_SOFTRESET] = STIH407_SRST_CORE(SYSCFG_5132, 16),
  70. [STIH407_MIPHY0_SOFTRESET] = STIH407_SRST_CORE(SYSCFG_5132, 4),
  71. [STIH407_MIPHY1_SOFTRESET] = STIH407_SRST_CORE(SYSCFG_5132, 13),
  72. [STIH407_MIPHY2_SOFTRESET] = STIH407_SRST_CORE(SYSCFG_5132, 22),
  73. [STIH407_SATA0_PWR_SOFTRESET] = STIH407_SRST_CORE(SYSCFG_5132, 5),
  74. [STIH407_SATA1_PWR_SOFTRESET] = STIH407_SRST_CORE(SYSCFG_5132, 14),
  75. [STIH407_DELTA_SOFTRESET] = STIH407_SRST_CORE(SYSCFG_5131, 3),
  76. [STIH407_BLITTER_SOFTRESET] = STIH407_SRST_CORE(SYSCFG_5131, 10),
  77. [STIH407_HDTVOUT_SOFTRESET] = STIH407_SRST_CORE(SYSCFG_5131, 11),
  78. [STIH407_HDQVDP_SOFTRESET] = STIH407_SRST_CORE(SYSCFG_5131, 12),
  79. [STIH407_VDP_AUX_SOFTRESET] = STIH407_SRST_CORE(SYSCFG_5131, 14),
  80. [STIH407_COMPO_SOFTRESET] = STIH407_SRST_CORE(SYSCFG_5131, 15),
  81. [STIH407_HDMI_TX_PHY_SOFTRESET] = STIH407_SRST_CORE(SYSCFG_5131, 21),
  82. [STIH407_JPEG_DEC_SOFTRESET] = STIH407_SRST_CORE(SYSCFG_5131, 23),
  83. [STIH407_VP8_DEC_SOFTRESET] = STIH407_SRST_CORE(SYSCFG_5131, 24),
  84. [STIH407_GPU_SOFTRESET] = STIH407_SRST_CORE(SYSCFG_5131, 30),
  85. [STIH407_HVA_SOFTRESET] = STIH407_SRST_CORE(SYSCFG_5132, 0),
  86. [STIH407_ERAM_HVA_SOFTRESET] = STIH407_SRST_CORE(SYSCFG_5132, 1),
  87. [STIH407_LPM_SOFTRESET] = STIH407_SRST_SBC(SYSCFG_4002, 2),
  88. [STIH407_KEYSCAN_SOFTRESET] = STIH407_SRST_LPM(LPM_SYSCFG_1, 8),
  89. [STIH407_ST231_AUD_SOFTRESET] = STIH407_SRST_CORE(SYSCFG_5131, 26),
  90. [STIH407_ST231_DMU_SOFTRESET] = STIH407_SRST_CORE(SYSCFG_5131, 27),
  91. [STIH407_ST231_GP0_SOFTRESET] = STIH407_SRST_CORE(SYSCFG_5131, 28),
  92. [STIH407_ST231_GP1_SOFTRESET] = STIH407_SRST_CORE(SYSCFG_5128, 2),
  93. };
  94. /* PicoPHY reset/control */
  95. #define SYSCFG_5061 0x0f4
  96. static const struct syscfg_reset_channel_data stih407_picophyresets[] = {
  97. [STIH407_PICOPHY0_RESET] = STIH407_SRST_CORE(SYSCFG_5061, 5),
  98. [STIH407_PICOPHY1_RESET] = STIH407_SRST_CORE(SYSCFG_5061, 6),
  99. [STIH407_PICOPHY2_RESET] = STIH407_SRST_CORE(SYSCFG_5061, 7),
  100. };
  101. static const struct syscfg_reset_controller_data stih407_powerdown_controller = {
  102. .wait_for_ack = true,
  103. .nr_channels = ARRAY_SIZE(stih407_powerdowns),
  104. .channels = stih407_powerdowns,
  105. };
  106. static const struct syscfg_reset_controller_data stih407_softreset_controller = {
  107. .wait_for_ack = false,
  108. .active_low = true,
  109. .nr_channels = ARRAY_SIZE(stih407_softresets),
  110. .channels = stih407_softresets,
  111. };
  112. static const struct syscfg_reset_controller_data stih407_picophyreset_controller = {
  113. .wait_for_ack = false,
  114. .nr_channels = ARRAY_SIZE(stih407_picophyresets),
  115. .channels = stih407_picophyresets,
  116. };
  117. static const struct of_device_id stih407_reset_match[] = {
  118. {
  119. .compatible = "st,stih407-powerdown",
  120. .data = &stih407_powerdown_controller,
  121. },
  122. {
  123. .compatible = "st,stih407-softreset",
  124. .data = &stih407_softreset_controller,
  125. },
  126. {
  127. .compatible = "st,stih407-picophyreset",
  128. .data = &stih407_picophyreset_controller,
  129. },
  130. { /* sentinel */ },
  131. };
  132. static struct platform_driver stih407_reset_driver = {
  133. .probe = syscfg_reset_probe,
  134. .driver = {
  135. .name = "reset-stih407",
  136. .of_match_table = stih407_reset_match,
  137. },
  138. };
  139. static int __init stih407_reset_init(void)
  140. {
  141. return platform_driver_register(&stih407_reset_driver);
  142. }
  143. arch_initcall(stih407_reset_init);