keystone.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Keystone2 based boards and SOC related code.
  3. *
  4. * Copyright 2013 Texas Instruments, Inc.
  5. * Cyril Chemparathy <cyril@ti.com>
  6. * Santosh Shilimkar <santosh.shillimkar@ti.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms and conditions of the GNU General Public License,
  10. * version 2, as published by the Free Software Foundation.
  11. */
  12. #include <linux/io.h>
  13. #include <linux/of.h>
  14. #include <linux/init.h>
  15. #include <linux/of_platform.h>
  16. #include <linux/of_address.h>
  17. #include <asm/setup.h>
  18. #include <asm/mach/map.h>
  19. #include <asm/mach/arch.h>
  20. #include <asm/mach/time.h>
  21. #include <asm/smp_plat.h>
  22. #include "keystone.h"
  23. #define PLL_RESET_WRITE_KEY_MASK 0xffff0000
  24. #define PLL_RESET_WRITE_KEY 0x5a69
  25. #define PLL_RESET BIT(16)
  26. static void __iomem *keystone_rstctrl;
  27. static void __init keystone_init(void)
  28. {
  29. struct device_node *node;
  30. node = of_find_compatible_node(NULL, NULL, "ti,keystone-reset");
  31. if (WARN_ON(!node))
  32. pr_warn("ti,keystone-reset node undefined\n");
  33. keystone_rstctrl = of_iomap(node, 0);
  34. if (WARN_ON(!keystone_rstctrl))
  35. pr_warn("ti,keystone-reset iomap error\n");
  36. of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
  37. }
  38. static const char *keystone_match[] __initconst = {
  39. "ti,keystone-evm",
  40. NULL,
  41. };
  42. void keystone_restart(enum reboot_mode mode, const char *cmd)
  43. {
  44. u32 val;
  45. BUG_ON(!keystone_rstctrl);
  46. /* Enable write access to RSTCTRL */
  47. val = readl(keystone_rstctrl);
  48. val &= PLL_RESET_WRITE_KEY_MASK;
  49. val |= PLL_RESET_WRITE_KEY;
  50. writel(val, keystone_rstctrl);
  51. /* Reset the SOC */
  52. val = readl(keystone_rstctrl);
  53. val &= ~PLL_RESET;
  54. writel(val, keystone_rstctrl);
  55. }
  56. DT_MACHINE_START(KEYSTONE, "Keystone")
  57. .smp = smp_ops(keystone_smp_ops),
  58. .init_machine = keystone_init,
  59. .dt_compat = keystone_match,
  60. .restart = keystone_restart,
  61. MACHINE_END