mach_desc.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * Copyright (C) 2012 Synopsys, Inc. (www.synopsys.com)
  3. *
  4. * based on METAG mach/arch.h (which in turn was based on ARM)
  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. #ifndef _ASM_ARC_MACH_DESC_H_
  11. #define _ASM_ARC_MACH_DESC_H_
  12. /**
  13. * struct machine_desc - Board specific callbacks, called from ARC common code
  14. * Provided by each ARC board using MACHINE_START()/MACHINE_END(), so
  15. * a multi-platform kernel builds with array of such descriptors.
  16. * We extend the early DT scan to also match the DT's "compatible" string
  17. * against the @dt_compat of all such descriptors, and one with highest
  18. * "DT score" is selected as global @machine_desc.
  19. *
  20. * @name: Board/SoC name
  21. * @dt_compat: Array of device tree 'compatible' strings
  22. * (XXX: although only 1st entry is looked at)
  23. * @init_early: Very early callback [called from setup_arch()]
  24. * @init_irq: setup external IRQ controllers [called from init_IRQ()]
  25. * @init_smp: for each CPU (e.g. setup IPI)
  26. * [(M):init_IRQ(), (o):start_kernel_secondary()]
  27. * @init_time: platform specific clocksource/clockevent registration
  28. * [called from time_init()]
  29. * @init_machine: arch initcall level callback (e.g. populate static
  30. * platform devices or parse Devicetree)
  31. * @init_late: Late initcall level callback
  32. *
  33. */
  34. struct machine_desc {
  35. const char *name;
  36. const char **dt_compat;
  37. void (*init_early)(void);
  38. void (*init_irq)(void);
  39. #ifdef CONFIG_SMP
  40. void (*init_smp)(unsigned int);
  41. #endif
  42. void (*init_time)(void);
  43. void (*init_machine)(void);
  44. void (*init_late)(void);
  45. };
  46. /*
  47. * Current machine - only accessible during boot.
  48. */
  49. extern struct machine_desc *machine_desc;
  50. /*
  51. * Machine type table - also only accessible during boot
  52. */
  53. extern struct machine_desc __arch_info_begin[], __arch_info_end[];
  54. #define for_each_machine_desc(p) \
  55. for (p = __arch_info_begin; p < __arch_info_end; p++)
  56. static inline struct machine_desc *default_machine_desc(void)
  57. {
  58. /* the default machine is the last one linked in */
  59. if (__arch_info_end - 1 < __arch_info_begin)
  60. return NULL;
  61. return __arch_info_end - 1;
  62. }
  63. /*
  64. * Set of macros to define architecture features.
  65. * This is built into a table by the linker.
  66. */
  67. #define MACHINE_START(_type, _name) \
  68. static const struct machine_desc __mach_desc_##_type \
  69. __used \
  70. __attribute__((__section__(".arch.info.init"))) = { \
  71. .name = _name,
  72. #define MACHINE_END \
  73. };
  74. extern struct machine_desc *setup_machine_fdt(void *dt);
  75. extern void __init copy_devtree(void);
  76. #endif