pnv_spi.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * QEMU PowerPC SPI model
  3. *
  4. * Copyright (c) 2024, IBM Corporation.
  5. *
  6. * SPDX-License-Identifier: GPL-2.0-or-later
  7. *
  8. * This model Supports a connection to a single SPI responder.
  9. * Introduced for P10 to provide access to SPI seeproms, TPM, flash device
  10. * and an ADC controller.
  11. *
  12. * All SPI function control is mapped into the SPI register space to enable
  13. * full control by firmware.
  14. *
  15. * SPI Controller has sequencer and shift engine. The SPI shift engine
  16. * performs serialization and de-serialization according to the control by
  17. * the sequencer and according to the setup defined in the configuration
  18. * registers and the SPI sequencer implements the main control logic.
  19. */
  20. #ifndef PPC_PNV_SPI_H
  21. #define PPC_PNV_SPI_H
  22. #include "hw/ssi/ssi.h"
  23. #include "hw/sysbus.h"
  24. #include "qemu/fifo8.h"
  25. #define TYPE_PNV_SPI "pnv-spi"
  26. OBJECT_DECLARE_SIMPLE_TYPE(PnvSpi, PNV_SPI)
  27. #define PNV_SPI_REG_SIZE 8
  28. #define PNV_SPI_REGS 7
  29. #define TYPE_PNV_SPI_BUS "spi"
  30. typedef struct PnvSpi {
  31. SysBusDevice parent_obj;
  32. SSIBus *ssi_bus;
  33. qemu_irq *cs_line;
  34. MemoryRegion xscom_spic_regs;
  35. Fifo8 tx_fifo;
  36. Fifo8 rx_fifo;
  37. uint8_t fail_count; /* RDR Match failure counter */
  38. /* SPI object number */
  39. uint32_t spic_num;
  40. uint32_t chip_id;
  41. uint8_t transfer_len;
  42. uint8_t responder_select;
  43. /* To verify if shift_n1 happens prior to shift_n2 */
  44. bool shift_n1_done;
  45. /* Loop counter for branch operation opcode Ex/Fx */
  46. uint8_t loop_counter_1;
  47. uint8_t loop_counter_2;
  48. /* N1/N2_bits specifies the size of the N1/N2 segment of a frame in bits.*/
  49. uint8_t N1_bits;
  50. uint8_t N2_bits;
  51. /* Number of bytes in a payload for the N1/N2 frame segment.*/
  52. uint8_t N1_bytes;
  53. uint8_t N2_bytes;
  54. /* Number of N1/N2 bytes marked for transmit */
  55. uint8_t N1_tx;
  56. uint8_t N2_tx;
  57. /* Number of N1/N2 bytes marked for receive */
  58. uint8_t N1_rx;
  59. uint8_t N2_rx;
  60. /* SPI registers */
  61. uint64_t regs[PNV_SPI_REGS];
  62. uint8_t seq_op[PNV_SPI_REG_SIZE];
  63. uint64_t status;
  64. } PnvSpi;
  65. #endif /* PPC_PNV_SPI_H */