board_bcm21664.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Copyright (C) 2014 Broadcom Corporation
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License as
  6. * published by the Free Software Foundation version 2.
  7. *
  8. * This program is distributed "as is" WITHOUT ANY WARRANTY of any
  9. * kind, whether express or implied; without even the implied warranty
  10. * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. */
  13. #include <linux/of_address.h>
  14. #include <linux/of_platform.h>
  15. #include <linux/io.h>
  16. #include <asm/mach/arch.h>
  17. #include "kona_l2_cache.h"
  18. #define RSTMGR_DT_STRING "brcm,bcm21664-resetmgr"
  19. #define RSTMGR_REG_WR_ACCESS_OFFSET 0
  20. #define RSTMGR_REG_CHIP_SOFT_RST_OFFSET 4
  21. #define RSTMGR_WR_PASSWORD 0xa5a5
  22. #define RSTMGR_WR_PASSWORD_SHIFT 8
  23. #define RSTMGR_WR_ACCESS_ENABLE 1
  24. static void bcm21664_restart(enum reboot_mode mode, const char *cmd)
  25. {
  26. void __iomem *base;
  27. struct device_node *resetmgr;
  28. resetmgr = of_find_compatible_node(NULL, NULL, RSTMGR_DT_STRING);
  29. if (!resetmgr) {
  30. pr_emerg("Couldn't find " RSTMGR_DT_STRING "\n");
  31. return;
  32. }
  33. base = of_iomap(resetmgr, 0);
  34. if (!base) {
  35. pr_emerg("Couldn't map " RSTMGR_DT_STRING "\n");
  36. return;
  37. }
  38. /*
  39. * A soft reset is triggered by writing a 0 to bit 0 of the soft reset
  40. * register. To write to that register we must first write the password
  41. * and the enable bit in the write access enable register.
  42. */
  43. writel((RSTMGR_WR_PASSWORD << RSTMGR_WR_PASSWORD_SHIFT) |
  44. RSTMGR_WR_ACCESS_ENABLE,
  45. base + RSTMGR_REG_WR_ACCESS_OFFSET);
  46. writel(0, base + RSTMGR_REG_CHIP_SOFT_RST_OFFSET);
  47. /* Wait for reset */
  48. while (1);
  49. }
  50. static void __init bcm21664_init(void)
  51. {
  52. of_platform_populate(NULL, of_default_bus_match_table, NULL,
  53. &platform_bus);
  54. kona_l2_cache_init();
  55. }
  56. static const char * const bcm21664_dt_compat[] = {
  57. "brcm,bcm21664",
  58. NULL,
  59. };
  60. DT_MACHINE_START(BCM21664_DT, "BCM21664 Broadcom Application Processor")
  61. .init_machine = bcm21664_init,
  62. .restart = bcm21664_restart,
  63. .dt_compat = bcm21664_dt_compat,
  64. MACHINE_END