axxia-reset.c 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * Reset driver for Axxia devices
  3. *
  4. * Copyright (C) 2014 LSI
  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 version 2 and
  8. * only version 2 as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. */
  16. #include <linux/init.h>
  17. #include <linux/err.h>
  18. #include <linux/io.h>
  19. #include <linux/kernel.h>
  20. #include <linux/mfd/syscon.h>
  21. #include <linux/module.h>
  22. #include <linux/of.h>
  23. #include <linux/platform_device.h>
  24. #include <linux/reboot.h>
  25. #include <linux/regmap.h>
  26. #include <asm/system_misc.h>
  27. #define SC_CRIT_WRITE_KEY 0x1000
  28. #define SC_LATCH_ON_RESET 0x1004
  29. #define SC_RESET_CONTROL 0x1008
  30. #define RSTCTL_RST_ZERO (1<<3)
  31. #define RSTCTL_RST_FAB (1<<2)
  32. #define RSTCTL_RST_CHIP (1<<1)
  33. #define RSTCTL_RST_SYS (1<<0)
  34. #define SC_EFUSE_INT_STATUS 0x180c
  35. #define EFUSE_READ_DONE (1<<31)
  36. static struct regmap *syscon;
  37. static void do_axxia_restart(enum reboot_mode reboot_mode, const char *cmd)
  38. {
  39. /* Access Key (0xab) */
  40. regmap_write(syscon, SC_CRIT_WRITE_KEY, 0xab);
  41. /* Select internal boot from 0xffff0000 */
  42. regmap_write(syscon, SC_LATCH_ON_RESET, 0x00000040);
  43. /* Assert ResetReadDone (to avoid hanging in boot ROM) */
  44. regmap_write(syscon, SC_EFUSE_INT_STATUS, EFUSE_READ_DONE);
  45. /* Assert chip reset */
  46. regmap_update_bits(syscon, SC_RESET_CONTROL,
  47. RSTCTL_RST_CHIP, RSTCTL_RST_CHIP);
  48. }
  49. static int axxia_reset_probe(struct platform_device *pdev)
  50. {
  51. struct device *dev = &pdev->dev;
  52. syscon = syscon_regmap_lookup_by_phandle(dev->of_node, "syscon");
  53. if (IS_ERR(syscon)) {
  54. pr_err("%s: syscon lookup failed\n", dev->of_node->name);
  55. return PTR_ERR(syscon);
  56. }
  57. arm_pm_restart = do_axxia_restart;
  58. return 0;
  59. }
  60. static const struct of_device_id of_axxia_reset_match[] = {
  61. { .compatible = "lsi,axm55xx-reset", },
  62. {},
  63. };
  64. MODULE_DEVICE_TABLE(of, of_axxia_reset_match);
  65. static struct platform_driver axxia_reset_driver = {
  66. .probe = axxia_reset_probe,
  67. .driver = {
  68. .name = "axxia-reset",
  69. .of_match_table = of_match_ptr(of_axxia_reset_match),
  70. },
  71. };
  72. static int __init axxia_reset_init(void)
  73. {
  74. return platform_driver_register(&axxia_reset_driver);
  75. }
  76. device_initcall(axxia_reset_init);