reset-stih415.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*
  2. * Copyright (C) 2013 STMicroelectronics (R&D) Limited
  3. * Author: Stephen Gallimore <stephen.gallimore@st.com>
  4. * Author: Srinivas Kandagatla <srinivas.kandagatla@st.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. */
  11. #include <linux/module.h>
  12. #include <linux/of.h>
  13. #include <linux/of_platform.h>
  14. #include <linux/platform_device.h>
  15. #include <dt-bindings/reset/stih415-resets.h>
  16. #include "reset-syscfg.h"
  17. /*
  18. * STiH415 Peripheral powerdown definitions.
  19. */
  20. static const char stih415_front[] = "st,stih415-front-syscfg";
  21. static const char stih415_rear[] = "st,stih415-rear-syscfg";
  22. static const char stih415_sbc[] = "st,stih415-sbc-syscfg";
  23. static const char stih415_lpm[] = "st,stih415-lpm-syscfg";
  24. #define STIH415_PDN_FRONT(_bit) \
  25. _SYSCFG_RST_CH(stih415_front, SYSCFG_114, _bit, SYSSTAT_187, _bit)
  26. #define STIH415_PDN_REAR(_cntl, _stat) \
  27. _SYSCFG_RST_CH(stih415_rear, SYSCFG_336, _cntl, SYSSTAT_384, _stat)
  28. #define STIH415_SRST_REAR(_reg, _bit) \
  29. _SYSCFG_RST_CH_NO_ACK(stih415_rear, _reg, _bit)
  30. #define STIH415_SRST_SBC(_reg, _bit) \
  31. _SYSCFG_RST_CH_NO_ACK(stih415_sbc, _reg, _bit)
  32. #define STIH415_SRST_FRONT(_reg, _bit) \
  33. _SYSCFG_RST_CH_NO_ACK(stih415_front, _reg, _bit)
  34. #define STIH415_SRST_LPM(_reg, _bit) \
  35. _SYSCFG_RST_CH_NO_ACK(stih415_lpm, _reg, _bit)
  36. #define SYSCFG_114 0x38 /* Powerdown request EMI/NAND/Keyscan */
  37. #define SYSSTAT_187 0x15c /* Powerdown status EMI/NAND/Keyscan */
  38. #define SYSCFG_336 0x90 /* Powerdown request USB/SATA/PCIe */
  39. #define SYSSTAT_384 0x150 /* Powerdown status USB/SATA/PCIe */
  40. #define SYSCFG_376 0x130 /* Reset generator 0 control 0 */
  41. #define SYSCFG_166 0x108 /* Softreset Ethernet 0 */
  42. #define SYSCFG_31 0x7c /* Softreset Ethernet 1 */
  43. #define LPM_SYSCFG_1 0x4 /* Softreset IRB */
  44. static const struct syscfg_reset_channel_data stih415_powerdowns[] = {
  45. [STIH415_EMISS_POWERDOWN] = STIH415_PDN_FRONT(0),
  46. [STIH415_NAND_POWERDOWN] = STIH415_PDN_FRONT(1),
  47. [STIH415_KEYSCAN_POWERDOWN] = STIH415_PDN_FRONT(2),
  48. [STIH415_USB0_POWERDOWN] = STIH415_PDN_REAR(0, 0),
  49. [STIH415_USB1_POWERDOWN] = STIH415_PDN_REAR(1, 1),
  50. [STIH415_USB2_POWERDOWN] = STIH415_PDN_REAR(2, 2),
  51. [STIH415_SATA0_POWERDOWN] = STIH415_PDN_REAR(3, 3),
  52. [STIH415_SATA1_POWERDOWN] = STIH415_PDN_REAR(4, 4),
  53. [STIH415_PCIE_POWERDOWN] = STIH415_PDN_REAR(5, 8),
  54. };
  55. static const struct syscfg_reset_channel_data stih415_softresets[] = {
  56. [STIH415_ETH0_SOFTRESET] = STIH415_SRST_FRONT(SYSCFG_166, 0),
  57. [STIH415_ETH1_SOFTRESET] = STIH415_SRST_SBC(SYSCFG_31, 0),
  58. [STIH415_IRB_SOFTRESET] = STIH415_SRST_LPM(LPM_SYSCFG_1, 6),
  59. [STIH415_USB0_SOFTRESET] = STIH415_SRST_REAR(SYSCFG_376, 9),
  60. [STIH415_USB1_SOFTRESET] = STIH415_SRST_REAR(SYSCFG_376, 10),
  61. [STIH415_USB2_SOFTRESET] = STIH415_SRST_REAR(SYSCFG_376, 11),
  62. [STIH415_KEYSCAN_SOFTRESET] = STIH415_SRST_LPM(LPM_SYSCFG_1, 8),
  63. };
  64. static struct syscfg_reset_controller_data stih415_powerdown_controller = {
  65. .wait_for_ack = true,
  66. .nr_channels = ARRAY_SIZE(stih415_powerdowns),
  67. .channels = stih415_powerdowns,
  68. };
  69. static struct syscfg_reset_controller_data stih415_softreset_controller = {
  70. .wait_for_ack = false,
  71. .active_low = true,
  72. .nr_channels = ARRAY_SIZE(stih415_softresets),
  73. .channels = stih415_softresets,
  74. };
  75. static const struct of_device_id stih415_reset_match[] = {
  76. { .compatible = "st,stih415-powerdown",
  77. .data = &stih415_powerdown_controller, },
  78. { .compatible = "st,stih415-softreset",
  79. .data = &stih415_softreset_controller, },
  80. {},
  81. };
  82. static struct platform_driver stih415_reset_driver = {
  83. .probe = syscfg_reset_probe,
  84. .driver = {
  85. .name = "reset-stih415",
  86. .of_match_table = stih415_reset_match,
  87. },
  88. };
  89. static int __init stih415_reset_init(void)
  90. {
  91. return platform_driver_register(&stih415_reset_driver);
  92. }
  93. arch_initcall(stih415_reset_init);