npcm8xx.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*
  2. * Nuvoton NPCM8xx SoC family.
  3. *
  4. * Copyright 2022 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 NPCM8XX_H
  17. #define NPCM8XX_H
  18. #include "hw/adc/npcm7xx_adc.h"
  19. #include "hw/core/split-irq.h"
  20. #include "hw/cpu/cluster.h"
  21. #include "hw/gpio/npcm7xx_gpio.h"
  22. #include "hw/i2c/npcm7xx_smbus.h"
  23. #include "hw/intc/arm_gic_common.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/nvram/npcm7xx_otp.h"
  32. #include "hw/sd/npcm7xx_sdhci.h"
  33. #include "hw/timer/npcm7xx_timer.h"
  34. #include "hw/ssi/npcm7xx_fiu.h"
  35. #include "hw/usb/hcd-ehci.h"
  36. #include "hw/usb/hcd-ohci.h"
  37. #include "target/arm/cpu.h"
  38. #define NPCM8XX_MAX_NUM_CPUS (4)
  39. /* The first half of the address space is reserved for DDR4 DRAM. */
  40. #define NPCM8XX_DRAM_BA (0x00000000)
  41. #define NPCM8XX_DRAM_SZ (2 * GiB)
  42. /* Magic addresses for setting up direct kernel booting and SMP boot stubs. */
  43. #define NPCM8XX_LOADER_START (0x00000000) /* Start of SDRAM */
  44. #define NPCM8XX_SMP_LOADER_START (0xffff0000) /* Boot ROM */
  45. #define NPCM8XX_SMP_BOOTREG_ADDR (0xf080013c) /* GCR.SCRPAD */
  46. #define NPCM8XX_BOARD_SETUP_ADDR (0xffff1000) /* Boot ROM */
  47. #define NPCM8XX_NR_PWM_MODULES 3
  48. struct NPCM8xxMachine {
  49. MachineState parent_obj;
  50. /*
  51. * PWM fan splitter. each splitter connects to one PWM output and
  52. * multiple MFT inputs.
  53. */
  54. SplitIRQ fan_splitter[NPCM8XX_NR_PWM_MODULES *
  55. NPCM7XX_PWM_PER_MODULE];
  56. };
  57. struct NPCM8xxMachineClass {
  58. MachineClass parent_class;
  59. const char *soc_type;
  60. };
  61. #define TYPE_NPCM8XX_MACHINE MACHINE_TYPE_NAME("npcm8xx")
  62. OBJECT_DECLARE_TYPE(NPCM8xxMachine, NPCM8xxMachineClass, NPCM8XX_MACHINE)
  63. struct NPCM8xxState {
  64. DeviceState parent_obj;
  65. ARMCPU cpu[NPCM8XX_MAX_NUM_CPUS];
  66. CPUClusterState cpu_cluster;
  67. GICState gic;
  68. MemoryRegion sram;
  69. MemoryRegion irom;
  70. MemoryRegion ram3;
  71. MemoryRegion *dram;
  72. NPCMGCRState gcr;
  73. NPCMCLKState clk;
  74. NPCM7xxTimerCtrlState tim[3];
  75. NPCM7xxADCState adc;
  76. NPCM7xxPWMState pwm[NPCM8XX_NR_PWM_MODULES];
  77. NPCM7xxMFTState mft[8];
  78. NPCM7xxOTPState fuse_array;
  79. NPCM7xxMCState mc;
  80. NPCM7xxRNGState rng;
  81. NPCM7xxGPIOState gpio[8];
  82. NPCM7xxSMBusState smbus[27];
  83. EHCISysBusState ehci[2];
  84. OHCISysBusState ohci[2];
  85. NPCM7xxFIUState fiu[3];
  86. NPCM7xxSDHCIState mmc;
  87. };
  88. struct NPCM8xxClass {
  89. DeviceClass parent_class;
  90. /* Bitmask of modules that are permanently disabled on this chip. */
  91. uint32_t disabled_modules;
  92. /* Number of CPU cores enabled in this SoC class. */
  93. uint32_t num_cpus;
  94. };
  95. #define TYPE_NPCM8XX "npcm8xx"
  96. OBJECT_DECLARE_TYPE(NPCM8xxState, NPCM8xxClass, NPCM8XX)
  97. /**
  98. * npcm8xx_load_kernel - Loads memory with everything needed to boot
  99. * @machine - The machine containing the SoC to be booted.
  100. * @soc - The SoC containing the CPU to be booted.
  101. *
  102. * This will set up the ARM boot info structure for the specific NPCM8xx
  103. * derivative and call arm_load_kernel() to set up loading of the kernel, etc.
  104. * into memory, if requested by the user.
  105. */
  106. void npcm8xx_load_kernel(MachineState *machine, NPCM8xxState *soc);
  107. #endif /* NPCM8XX_H */