0005-MIPS-lantiq-add-reset-controller-api-support.patch 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. From 223f1c46e109a8420765aee099a5d1dc4ab7ee98 Mon Sep 17 00:00:00 2001
  2. From: John Crispin <blogic@openwrt.org>
  3. Date: Tue, 3 Sep 2013 13:18:12 +0200
  4. Subject: [PATCH 05/36] MIPS: lantiq: add reset-controller api support
  5. Add a reset-controller binding for the reset registers found on the lantiq
  6. SoC.
  7. Signed-off-by: John Crispin <blogic@openwrt.org>
  8. ---
  9. arch/mips/lantiq/xway/reset.c | 61 +++++++++++++++++++++++++++++++++++++++++
  10. 1 file changed, 61 insertions(+)
  11. --- a/arch/mips/lantiq/xway/reset.c
  12. +++ b/arch/mips/lantiq/xway/reset.c
  13. @@ -14,6 +14,7 @@
  14. #include <linux/delay.h>
  15. #include <linux/of_address.h>
  16. #include <linux/of_platform.h>
  17. +#include <linux/reset-controller.h>
  18. #include <asm/reboot.h>
  19. @@ -113,6 +114,66 @@ void ltq_reset_once(unsigned int module,
  20. ltq_rcu_w32(ltq_rcu_r32(RCU_RST_REQ) & ~module, RCU_RST_REQ);
  21. }
  22. +static int ltq_assert_device(struct reset_controller_dev *rcdev,
  23. + unsigned long id)
  24. +{
  25. + u32 val;
  26. +
  27. + if (id < 8)
  28. + return -1;
  29. +
  30. + val = ltq_rcu_r32(RCU_RST_REQ);
  31. + val |= BIT(id);
  32. + ltq_rcu_w32(val, RCU_RST_REQ);
  33. +
  34. + return 0;
  35. +}
  36. +
  37. +static int ltq_deassert_device(struct reset_controller_dev *rcdev,
  38. + unsigned long id)
  39. +{
  40. + u32 val;
  41. +
  42. + if (id < 8)
  43. + return -1;
  44. +
  45. + val = ltq_rcu_r32(RCU_RST_REQ);
  46. + val &= ~BIT(id);
  47. + ltq_rcu_w32(val, RCU_RST_REQ);
  48. +
  49. + return 0;
  50. +}
  51. +
  52. +static int ltq_reset_device(struct reset_controller_dev *rcdev,
  53. + unsigned long id)
  54. +{
  55. + ltq_assert_device(rcdev, id);
  56. + return ltq_deassert_device(rcdev, id);
  57. +}
  58. +
  59. +static struct reset_control_ops reset_ops = {
  60. + .reset = ltq_reset_device,
  61. + .assert = ltq_assert_device,
  62. + .deassert = ltq_deassert_device,
  63. +};
  64. +
  65. +static struct reset_controller_dev reset_dev = {
  66. + .ops = &reset_ops,
  67. + .owner = THIS_MODULE,
  68. + .nr_resets = 32,
  69. + .of_reset_n_cells = 1,
  70. +};
  71. +
  72. +void ltq_rst_init(void)
  73. +{
  74. + reset_dev.of_node = of_find_compatible_node(NULL, NULL,
  75. + "lantiq,xway-reset");
  76. + if (!reset_dev.of_node)
  77. + pr_err("Failed to find reset controller node");
  78. + else
  79. + reset_controller_register(&reset_dev);
  80. +}
  81. +
  82. static void ltq_machine_restart(char *command)
  83. {
  84. local_irq_disable();