pm_smbus.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #ifndef PM_SMBUS_H
  2. #define PM_SMBUS_H
  3. #include "exec/memory.h"
  4. #include "hw/i2c/smbus_master.h"
  5. #define PM_SMBUS_MAX_MSG_SIZE 32
  6. typedef struct PMSMBus {
  7. I2CBus *smbus;
  8. MemoryRegion io;
  9. uint8_t smb_stat;
  10. uint8_t smb_ctl;
  11. uint8_t smb_cmd;
  12. uint8_t smb_addr;
  13. uint8_t smb_data0;
  14. uint8_t smb_data1;
  15. uint8_t smb_data[PM_SMBUS_MAX_MSG_SIZE];
  16. uint8_t smb_blkdata;
  17. uint8_t smb_auxctl;
  18. uint32_t smb_index;
  19. /* Set by pm_smbus.c */
  20. void (*reset)(struct PMSMBus *s);
  21. /* Set by the user. */
  22. bool i2c_enable;
  23. void (*set_irq)(struct PMSMBus *s, bool enabled);
  24. void *opaque;
  25. /* Internally used by pm_smbus. */
  26. /* Set on block transfers after the last byte has been read, so the
  27. INTR bit can be set at the right time. */
  28. bool op_done;
  29. /* Set during an I2C block read, so we know how to handle data. */
  30. bool in_i2c_block_read;
  31. /* Used to work around a bug in AMIBIOS, see smb_transaction_start() */
  32. bool start_transaction_on_status_read;
  33. } PMSMBus;
  34. void pm_smbus_init(DeviceState *parent, PMSMBus *smb, bool force_aux_blk);
  35. /*
  36. * For backwards compatibility on migration, older versions don't have
  37. * working migration for pm_smbus, this lets us ignore the migrations
  38. * for older machine versions.
  39. */
  40. bool pm_smbus_vmstate_needed(void);
  41. extern const VMStateDescription pmsmb_vmstate;
  42. #endif /* PM_SMBUS_H */