npcm7xx.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /*
  2. * Nuvoton NPCM7xx SoC family.
  3. *
  4. * Copyright 2020 Google LLC
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the
  8. * Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful, but WITHOUT
  12. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  14. * for more details.
  15. */
  16. #ifndef NPCM7XX_H
  17. #define NPCM7XX_H
  18. #include "hw/boards.h"
  19. #include "hw/adc/npcm7xx_adc.h"
  20. #include "hw/core/split-irq.h"
  21. #include "hw/cpu/a9mpcore.h"
  22. #include "hw/gpio/npcm7xx_gpio.h"
  23. #include "hw/i2c/npcm7xx_smbus.h"
  24. #include "hw/mem/npcm7xx_mc.h"
  25. #include "hw/misc/npcm_clk.h"
  26. #include "hw/misc/npcm_gcr.h"
  27. #include "hw/misc/npcm7xx_mft.h"
  28. #include "hw/misc/npcm7xx_pwm.h"
  29. #include "hw/misc/npcm7xx_rng.h"
  30. #include "hw/net/npcm7xx_emc.h"
  31. #include "hw/net/npcm_gmac.h"
  32. #include "hw/nvram/npcm7xx_otp.h"
  33. #include "hw/timer/npcm7xx_timer.h"
  34. #include "hw/ssi/npcm7xx_fiu.h"
  35. #include "hw/ssi/npcm_pspi.h"
  36. #include "hw/usb/hcd-ehci.h"
  37. #include "hw/usb/hcd-ohci.h"
  38. #include "target/arm/cpu.h"
  39. #include "hw/sd/npcm7xx_sdhci.h"
  40. #define NPCM7XX_MAX_NUM_CPUS (2)
  41. /* The first half of the address space is reserved for DDR4 DRAM. */
  42. #define NPCM7XX_DRAM_BA (0x00000000)
  43. #define NPCM7XX_DRAM_SZ (2 * GiB)
  44. /* Magic addresses for setting up direct kernel booting and SMP boot stubs. */
  45. #define NPCM7XX_LOADER_START (0x00000000) /* Start of SDRAM */
  46. #define NPCM7XX_SMP_LOADER_START (0xffff0000) /* Boot ROM */
  47. #define NPCM7XX_SMP_BOOTREG_ADDR (0xf080013c) /* GCR.SCRPAD */
  48. #define NPCM7XX_GIC_CPU_IF_ADDR (0xf03fe100) /* GIC within A9 */
  49. #define NPCM7XX_BOARD_SETUP_ADDR (0xffff1000) /* Boot ROM */
  50. #define NPCM7XX_NR_PWM_MODULES 2
  51. struct NPCM7xxMachine {
  52. MachineState parent;
  53. /*
  54. * PWM fan splitter. each splitter connects to one PWM output and
  55. * multiple MFT inputs.
  56. */
  57. SplitIRQ fan_splitter[NPCM7XX_NR_PWM_MODULES *
  58. NPCM7XX_PWM_PER_MODULE];
  59. };
  60. #define TYPE_NPCM7XX_MACHINE MACHINE_TYPE_NAME("npcm7xx")
  61. OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxMachine, NPCM7XX_MACHINE)
  62. typedef struct NPCM7xxMachineClass {
  63. MachineClass parent;
  64. const char *soc_type;
  65. } NPCM7xxMachineClass;
  66. #define NPCM7XX_MACHINE_CLASS(klass) \
  67. OBJECT_CLASS_CHECK(NPCM7xxMachineClass, (klass), TYPE_NPCM7XX_MACHINE)
  68. #define NPCM7XX_MACHINE_GET_CLASS(obj) \
  69. OBJECT_GET_CLASS(NPCM7xxMachineClass, (obj), TYPE_NPCM7XX_MACHINE)
  70. struct NPCM7xxState {
  71. DeviceState parent;
  72. ARMCPU cpu[NPCM7XX_MAX_NUM_CPUS];
  73. A9MPPrivState a9mpcore;
  74. MemoryRegion sram;
  75. MemoryRegion irom;
  76. MemoryRegion ram3;
  77. MemoryRegion *dram;
  78. NPCMGCRState gcr;
  79. NPCMCLKState clk;
  80. NPCM7xxTimerCtrlState tim[3];
  81. NPCM7xxADCState adc;
  82. NPCM7xxPWMState pwm[NPCM7XX_NR_PWM_MODULES];
  83. NPCM7xxMFTState mft[8];
  84. NPCM7xxOTPState key_storage;
  85. NPCM7xxOTPState fuse_array;
  86. NPCM7xxMCState mc;
  87. NPCM7xxRNGState rng;
  88. NPCM7xxGPIOState gpio[8];
  89. NPCM7xxSMBusState smbus[16];
  90. EHCISysBusState ehci;
  91. OHCISysBusState ohci;
  92. NPCM7xxFIUState fiu[2];
  93. NPCM7xxEMCState emc[2];
  94. NPCMGMACState gmac[2];
  95. NPCM7xxSDHCIState mmc;
  96. NPCMPSPIState pspi[2];
  97. };
  98. #define TYPE_NPCM7XX "npcm7xx"
  99. OBJECT_DECLARE_TYPE(NPCM7xxState, NPCM7xxClass, NPCM7XX)
  100. #define TYPE_NPCM730 "npcm730"
  101. #define TYPE_NPCM750 "npcm750"
  102. typedef struct NPCM7xxClass {
  103. DeviceClass parent;
  104. /* Bitmask of modules that are permanently disabled on this chip. */
  105. uint32_t disabled_modules;
  106. /* Number of CPU cores enabled in this SoC class (may be 1 or 2). */
  107. uint32_t num_cpus;
  108. } NPCM7xxClass;
  109. /**
  110. * npcm7xx_load_kernel - Loads memory with everything needed to boot
  111. * @machine - The machine containing the SoC to be booted.
  112. * @soc - The SoC containing the CPU to be booted.
  113. *
  114. * This will set up the ARM boot info structure for the specific NPCM7xx
  115. * derivative and call arm_load_kernel() to set up loading of the kernel, etc.
  116. * into memory, if requested by the user.
  117. */
  118. void npcm7xx_load_kernel(MachineState *machine, NPCM7xxState *soc);
  119. #endif /* NPCM7XX_H */