mpc85xx_pm_ops.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * MPC85xx PM operators
  4. *
  5. * Copyright 2015 Freescale Semiconductor Inc.
  6. */
  7. #define pr_fmt(fmt) "%s: " fmt, __func__
  8. #include <linux/kernel.h>
  9. #include <linux/of.h>
  10. #include <linux/of_address.h>
  11. #include <linux/fsl/guts.h>
  12. #include <asm/io.h>
  13. #include <asm/fsl_pm.h>
  14. #include "smp.h"
  15. static struct ccsr_guts __iomem *guts;
  16. #ifdef CONFIG_FSL_PMC
  17. static void mpc85xx_irq_mask(int cpu)
  18. {
  19. }
  20. static void mpc85xx_irq_unmask(int cpu)
  21. {
  22. }
  23. static void mpc85xx_cpu_die(int cpu)
  24. {
  25. u32 tmp;
  26. tmp = (mfspr(SPRN_HID0) & ~(HID0_DOZE|HID0_SLEEP)) | HID0_NAP;
  27. mtspr(SPRN_HID0, tmp);
  28. /* Enter NAP mode. */
  29. tmp = mfmsr();
  30. tmp |= MSR_WE;
  31. asm volatile(
  32. "msync\n"
  33. "mtmsr %0\n"
  34. "isync\n"
  35. :
  36. : "r" (tmp));
  37. }
  38. static void mpc85xx_cpu_up_prepare(int cpu)
  39. {
  40. }
  41. #endif
  42. static void mpc85xx_freeze_time_base(bool freeze)
  43. {
  44. uint32_t mask;
  45. mask = CCSR_GUTS_DEVDISR_TB0 | CCSR_GUTS_DEVDISR_TB1;
  46. if (freeze)
  47. setbits32(&guts->devdisr, mask);
  48. else
  49. clrbits32(&guts->devdisr, mask);
  50. in_be32(&guts->devdisr);
  51. }
  52. static const struct of_device_id mpc85xx_smp_guts_ids[] = {
  53. { .compatible = "fsl,mpc8572-guts", },
  54. { .compatible = "fsl,p1020-guts", },
  55. { .compatible = "fsl,p1021-guts", },
  56. { .compatible = "fsl,p1022-guts", },
  57. { .compatible = "fsl,p1023-guts", },
  58. { .compatible = "fsl,p2020-guts", },
  59. { .compatible = "fsl,bsc9132-guts", },
  60. {},
  61. };
  62. static const struct fsl_pm_ops mpc85xx_pm_ops = {
  63. .freeze_time_base = mpc85xx_freeze_time_base,
  64. #ifdef CONFIG_FSL_PMC
  65. .irq_mask = mpc85xx_irq_mask,
  66. .irq_unmask = mpc85xx_irq_unmask,
  67. .cpu_die = mpc85xx_cpu_die,
  68. .cpu_up_prepare = mpc85xx_cpu_up_prepare,
  69. #endif
  70. };
  71. int __init mpc85xx_setup_pmc(void)
  72. {
  73. struct device_node *np;
  74. np = of_find_matching_node(NULL, mpc85xx_smp_guts_ids);
  75. if (np) {
  76. guts = of_iomap(np, 0);
  77. of_node_put(np);
  78. if (!guts) {
  79. pr_err("Could not map guts node address\n");
  80. return -ENOMEM;
  81. }
  82. qoriq_pm_ops = &mpc85xx_pm_ops;
  83. }
  84. return 0;
  85. }