npcm_pspi.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Nuvoton Peripheral SPI Module
  3. *
  4. * Copyright 2023 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 NPCM_PSPI_H
  17. #define NPCM_PSPI_H
  18. #include "hw/ssi/ssi.h"
  19. #include "hw/sysbus.h"
  20. /*
  21. * Number of registers in our device state structure. Don't change this without
  22. * incrementing the version_id in the vmstate.
  23. */
  24. #define NPCM_PSPI_NR_REGS 3
  25. /**
  26. * NPCMPSPIState - Device state for one Flash Interface Unit.
  27. * @parent: System bus device.
  28. * @mmio: Memory region for register access.
  29. * @spi: The SPI bus mastered by this controller.
  30. * @regs: Register contents.
  31. * @irq: The interrupt request queue for this module.
  32. *
  33. * Each PSPI has a shared bank of registers, and controls up to four chip
  34. * selects. Each chip select has a dedicated memory region which may be used to
  35. * read and write the flash connected to that chip select as if it were memory.
  36. */
  37. typedef struct NPCMPSPIState {
  38. SysBusDevice parent;
  39. MemoryRegion mmio;
  40. SSIBus *spi;
  41. uint16_t regs[NPCM_PSPI_NR_REGS];
  42. qemu_irq irq;
  43. } NPCMPSPIState;
  44. #define TYPE_NPCM_PSPI "npcm-pspi"
  45. OBJECT_DECLARE_SIMPLE_TYPE(NPCMPSPIState, NPCM_PSPI)
  46. #endif /* NPCM_PSPI_H */