8036-ls2085a-Add-support-for-reset.patch 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. From 4b9227ba510562a51e87487905895aea97e17e77 Mon Sep 17 00:00:00 2001
  2. From: pankaj chauhan <pankaj.chauhan@freescale.com>
  3. Date: Tue, 3 Feb 2015 13:08:52 +0530
  4. Subject: [PATCH 36/70] ls2085a: Add support for reset
  5. Add support for layerscape reset driver.
  6. Reset is implemented by raising RESET_REQ_B.
  7. Signed-off-by: pankaj chauhan <pankaj.chauhan@freescale.com>
  8. Signed-off-by: Stuart Yoder <stuart.yoder@freescale.com>
  9. (cherry picked from commit f248be3aea58ca32b7d77413d742996249b293e9)
  10. ---
  11. drivers/power/reset/Kconfig | 7 ++-
  12. drivers/power/reset/Makefile | 1 +
  13. drivers/power/reset/ls-reboot.c | 93 +++++++++++++++++++++++++++++++++++++++
  14. 3 files changed, 100 insertions(+), 1 deletion(-)
  15. create mode 100644 drivers/power/reset/ls-reboot.c
  16. --- a/drivers/power/reset/Kconfig
  17. +++ b/drivers/power/reset/Kconfig
  18. @@ -173,5 +173,10 @@ config POWER_RESET_ZX
  19. help
  20. Reboot support for ZTE SoCs.
  21. -endif
  22. +config POWER_RESET_LAYERSCAPE
  23. + bool "Freescale LayerScape reset driver"
  24. + depends on ARCH_FSL_LS2085A
  25. + help
  26. + Reboot support for the Freescale LayerScape SoCs.
  27. +endif
  28. --- a/drivers/power/reset/Makefile
  29. +++ b/drivers/power/reset/Makefile
  30. @@ -20,3 +20,4 @@ obj-$(CONFIG_POWER_RESET_SYSCON) += sysc
  31. obj-$(CONFIG_POWER_RESET_SYSCON_POWEROFF) += syscon-poweroff.o
  32. obj-$(CONFIG_POWER_RESET_RMOBILE) += rmobile-reset.o
  33. obj-$(CONFIG_POWER_RESET_ZX) += zx-reboot.o
  34. +obj-$(CONFIG_POWER_RESET_LAYERSCAPE) += ls-reboot.o
  35. --- /dev/null
  36. +++ b/drivers/power/reset/ls-reboot.c
  37. @@ -0,0 +1,93 @@
  38. +/*
  39. + * Freescale LayerScape reboot driver
  40. + *
  41. + * Copyright (c) 2015, Freescale Semiconductor.
  42. + * Author: Pankaj Chauhan <pankaj.chauhan@freescale.com>
  43. + *
  44. + * This program is free software; you can redistribute it and/or modify
  45. + * it under the terms of the GNU General Public License version 2 as
  46. + * published by the Free Software Foundation.
  47. + *
  48. + * This program is distributed in the hope that it will be useful,
  49. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  50. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  51. + * GNU General Public License for more details.
  52. + *
  53. + * You should have received a copy of the GNU General Public License
  54. + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  55. + */
  56. +
  57. +#include <linux/io.h>
  58. +#include <linux/of_device.h>
  59. +#include <linux/of_address.h>
  60. +#include <linux/platform_device.h>
  61. +#include <linux/stat.h>
  62. +#include <linux/slab.h>
  63. +#include <asm/system_misc.h>
  64. +
  65. +struct ls_reboot_priv {
  66. + struct device *dev;
  67. + u32 *rstcr;
  68. +};
  69. +
  70. +static struct ls_reboot_priv *ls_reboot_priv;
  71. +
  72. +static void ls_reboot(enum reboot_mode reboot_mode, const char *cmd)
  73. +{
  74. + struct ls_reboot_priv *priv = ls_reboot_priv;
  75. + u32 val;
  76. + unsigned long timeout;
  77. +
  78. + if (ls_reboot_priv) {
  79. + val = readl(priv->rstcr);
  80. + val |= 0x02;
  81. + writel(val, priv->rstcr);
  82. + }
  83. +
  84. + timeout = jiffies + HZ;
  85. + while (time_before(jiffies, timeout))
  86. + cpu_relax();
  87. +
  88. +}
  89. +
  90. +static int ls_reboot_probe(struct platform_device *pdev)
  91. +{
  92. + ls_reboot_priv = devm_kzalloc(&pdev->dev,
  93. + sizeof(*ls_reboot_priv), GFP_KERNEL);
  94. + if (!ls_reboot_priv) {
  95. + dev_err(&pdev->dev, "out of memory for context\n");
  96. + return -ENODEV;
  97. + }
  98. +
  99. + ls_reboot_priv->rstcr = of_iomap(pdev->dev.of_node, 0);
  100. + if (!ls_reboot_priv->rstcr) {
  101. + devm_kfree(&pdev->dev, ls_reboot_priv);
  102. + dev_err(&pdev->dev, "can not map resource\n");
  103. + return -ENODEV;
  104. + }
  105. +
  106. + ls_reboot_priv->dev = &pdev->dev;
  107. +
  108. + arm_pm_restart = ls_reboot;
  109. +
  110. + return 0;
  111. +}
  112. +
  113. +static struct of_device_id ls_reboot_of_match[] = {
  114. + { .compatible = "fsl,ls-reset" },
  115. + {}
  116. +};
  117. +
  118. +static struct platform_driver ls_reboot_driver = {
  119. + .probe = ls_reboot_probe,
  120. + .driver = {
  121. + .name = "ls-reset",
  122. + .of_match_table = ls_reboot_of_match,
  123. + },
  124. +};
  125. +
  126. +static int __init ls_reboot_init(void)
  127. +{
  128. + return platform_driver_register(&ls_reboot_driver);
  129. +}
  130. +device_initcall(ls_reboot_init);