cpu_func.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * (C) Copyright 2000-2009
  4. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  5. * Copyright 2019 Google LLC
  6. */
  7. #ifndef __CPU_LEGACY_H
  8. #define __CPU_LEGACY_H
  9. #include <linux/types.h>
  10. /*
  11. * Multicore arch functions
  12. *
  13. * These should be moved to use the CPU uclass.
  14. */
  15. int cpu_status(u32 nr);
  16. int cpu_reset(u32 nr);
  17. int cpu_disable(u32 nr);
  18. int cpu_release(u32 nr, int argc, char *const argv[]);
  19. static inline int cpumask_next(int cpu, unsigned int mask)
  20. {
  21. for (cpu++; !((1 << cpu) & mask); cpu++)
  22. ;
  23. return cpu;
  24. }
  25. #define for_each_cpu(iter, cpu, num_cpus, mask) \
  26. for (iter = 0, cpu = cpumask_next(-1, mask); \
  27. iter < num_cpus; \
  28. iter++, cpu = cpumask_next(cpu, mask)) \
  29. int cpu_numcores(void);
  30. int cpu_num_dspcores(void);
  31. u32 cpu_mask(void);
  32. u32 cpu_dsp_mask(void);
  33. int is_core_valid(unsigned int core);
  34. /**
  35. * checkcpu() - perform an early check of the CPU
  36. *
  37. * This is used on PowerPC, SH and X86 machines as a CPU init mechanism. It is
  38. * called during the pre-relocation init sequence in board_init_f().
  39. *
  40. * @return 0 if oK, -ve on error
  41. */
  42. int checkcpu(void);
  43. void smp_set_core_boot_addr(unsigned long addr, int corenr);
  44. void smp_kick_all_cpus(void);
  45. int icache_status(void);
  46. void icache_enable(void);
  47. void icache_disable(void);
  48. int dcache_status(void);
  49. void dcache_enable(void);
  50. void dcache_disable(void);
  51. void mmu_disable(void);
  52. /* arch/$(ARCH)/lib/cache.c */
  53. void enable_caches(void);
  54. void flush_cache(unsigned long addr, unsigned long size);
  55. void flush_dcache_all(void);
  56. void flush_dcache_range(unsigned long start, unsigned long stop);
  57. void invalidate_dcache_range(unsigned long start, unsigned long stop);
  58. void invalidate_dcache_all(void);
  59. void invalidate_icache_all(void);
  60. enum {
  61. /* Disable caches (else flush caches but leave them active) */
  62. CBL_DISABLE_CACHES = 1 << 0,
  63. CBL_SHOW_BOOTSTAGE_REPORT = 1 << 1,
  64. CBL_ALL = 3,
  65. };
  66. /**
  67. * Clean up ready for linux
  68. *
  69. * @param flags Flags to control what is done
  70. */
  71. int cleanup_before_linux_select(int flags);
  72. void reset_cpu(ulong addr);
  73. ;
  74. #endif