firmware.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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 "common.h"
  18. #include "smc.h"
  19. static int exynos_do_idle(void)
  20. {
  21. exynos_smc(SMC_CMD_SLEEP, 0, 0, 0);
  22. return 0;
  23. }
  24. static int exynos_cpu_boot(int cpu)
  25. {
  26. /*
  27. * Exynos3250 doesn't need to send smc command for secondary CPU boot
  28. * because Exynos3250 removes WFE in secure mode.
  29. */
  30. if (soc_is_exynos3250())
  31. return 0;
  32. /*
  33. * The second parameter of SMC_CMD_CPU1BOOT command means CPU id.
  34. * But, Exynos4212 has only one secondary CPU so second parameter
  35. * isn't used for informing secure firmware about CPU id.
  36. */
  37. if (soc_is_exynos4212())
  38. cpu = 0;
  39. exynos_smc(SMC_CMD_CPU1BOOT, cpu, 0, 0);
  40. return 0;
  41. }
  42. static int exynos_set_cpu_boot_addr(int cpu, unsigned long boot_addr)
  43. {
  44. void __iomem *boot_reg;
  45. if (!sysram_ns_base_addr)
  46. return -ENODEV;
  47. boot_reg = sysram_ns_base_addr + 0x1c;
  48. /*
  49. * Almost all Exynos-series of SoCs that run in secure mode don't need
  50. * additional offset for every CPU, with Exynos4412 being the only
  51. * exception.
  52. */
  53. if (soc_is_exynos4412())
  54. boot_reg += 4 * cpu;
  55. __raw_writel(boot_addr, boot_reg);
  56. return 0;
  57. }
  58. static const struct firmware_ops exynos_firmware_ops = {
  59. .do_idle = exynos_do_idle,
  60. .set_cpu_boot_addr = exynos_set_cpu_boot_addr,
  61. .cpu_boot = exynos_cpu_boot,
  62. };
  63. void __init exynos_firmware_init(void)
  64. {
  65. struct device_node *nd;
  66. const __be32 *addr;
  67. nd = of_find_compatible_node(NULL, NULL,
  68. "samsung,secure-firmware");
  69. if (!nd)
  70. return;
  71. addr = of_get_address(nd, 0, NULL, NULL);
  72. if (!addr) {
  73. pr_err("%s: No address specified.\n", __func__);
  74. return;
  75. }
  76. pr_info("Running under secure firmware.\n");
  77. register_firmware_ops(&exynos_firmware_ops);
  78. }