firmware.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * Copyright (C) 2012 Samsung Electronics.
  3. * Kyungmin Park <kyungmin.park@samsung.com>
  4. * Tomasz Figa <t.figa@samsung.com>
  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 as
  8. * published by the Free Software Foundation.
  9. */
  10. #include <linux/kernel.h>
  11. #include <linux/io.h>
  12. #include <linux/init.h>
  13. #include <linux/of.h>
  14. #include <linux/of_address.h>
  15. #include <asm/firmware.h>
  16. #include <mach/map.h>
  17. #include "smc.h"
  18. static int exynos_do_idle(void)
  19. {
  20. exynos_smc(SMC_CMD_SLEEP, 0, 0, 0);
  21. return 0;
  22. }
  23. static int exynos_cpu_boot(int cpu)
  24. {
  25. exynos_smc(SMC_CMD_CPU1BOOT, cpu, 0, 0);
  26. return 0;
  27. }
  28. static int exynos_set_cpu_boot_addr(int cpu, unsigned long boot_addr)
  29. {
  30. void __iomem *boot_reg = S5P_VA_SYSRAM_NS + 0x1c + 4*cpu;
  31. __raw_writel(boot_addr, boot_reg);
  32. return 0;
  33. }
  34. static const struct firmware_ops exynos_firmware_ops = {
  35. .do_idle = exynos_do_idle,
  36. .set_cpu_boot_addr = exynos_set_cpu_boot_addr,
  37. .cpu_boot = exynos_cpu_boot,
  38. };
  39. void __init exynos_firmware_init(void)
  40. {
  41. if (of_have_populated_dt()) {
  42. struct device_node *nd;
  43. const __be32 *addr;
  44. nd = of_find_compatible_node(NULL, NULL,
  45. "samsung,secure-firmware");
  46. if (!nd)
  47. return;
  48. addr = of_get_address(nd, 0, NULL, NULL);
  49. if (!addr) {
  50. pr_err("%s: No address specified.\n", __func__);
  51. return;
  52. }
  53. }
  54. pr_info("Running under secure firmware.\n");
  55. register_firmware_ops(&exynos_firmware_ops);
  56. }