test.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Test-related constants for sandbox
  4. *
  5. * Copyright (c) 2014 Google, Inc
  6. */
  7. #ifndef __ASM_TEST_H
  8. #define __ASM_TEST_H
  9. /* The sandbox driver always permits an I2C device with this address */
  10. #define SANDBOX_I2C_TEST_ADDR 0x59
  11. #define SANDBOX_PCI_VENDOR_ID 0x1234
  12. #define SANDBOX_PCI_DEVICE_ID 0x5678
  13. #define SANDBOX_PCI_CLASS_CODE PCI_CLASS_CODE_COMM
  14. #define SANDBOX_PCI_CLASS_SUB_CODE PCI_CLASS_SUB_CODE_COMM_SERIAL
  15. #define PCI_CAP_ID_PM_OFFSET 0x50
  16. #define PCI_CAP_ID_EXP_OFFSET 0x60
  17. #define PCI_CAP_ID_MSIX_OFFSET 0x70
  18. #define PCI_EXT_CAP_ID_ERR_OFFSET 0x100
  19. #define PCI_EXT_CAP_ID_VC_OFFSET 0x200
  20. #define PCI_EXT_CAP_ID_DSN_OFFSET 0x300
  21. /* Useful for PCI_VDEVICE() macro */
  22. #define PCI_VENDOR_ID_SANDBOX SANDBOX_PCI_VENDOR_ID
  23. #define SWAP_CASE_DRV_DATA 0x55aa
  24. #define SANDBOX_CLK_RATE 32768
  25. /* System controller driver data */
  26. enum {
  27. SYSCON0 = 32,
  28. SYSCON1,
  29. SYSCON_COUNT
  30. };
  31. /**
  32. * sandbox_i2c_set_test_mode() - set test mode for running unit tests
  33. *
  34. * See sandbox_i2c_xfer() for the behaviour changes.
  35. *
  36. * @bus: sandbox I2C bus to adjust
  37. * @test_mode: true to select test mode, false to run normally
  38. */
  39. void sandbox_i2c_set_test_mode(struct udevice *bus, bool test_mode);
  40. enum sandbox_i2c_eeprom_test_mode {
  41. SIE_TEST_MODE_NONE,
  42. /* Permits read/write of only one byte per I2C transaction */
  43. SIE_TEST_MODE_SINGLE_BYTE,
  44. };
  45. void sandbox_i2c_eeprom_set_test_mode(struct udevice *dev,
  46. enum sandbox_i2c_eeprom_test_mode mode);
  47. void sandbox_i2c_eeprom_set_offset_len(struct udevice *dev, int offset_len);
  48. /*
  49. * sandbox_timer_add_offset()
  50. *
  51. * Allow tests to add to the time reported through lib/time.c functions
  52. * offset: number of milliseconds to advance the system time
  53. */
  54. void sandbox_timer_add_offset(unsigned long offset);
  55. /**
  56. * sandbox_i2c_rtc_set_offset() - set the time offset from system/base time
  57. *
  58. * @dev: RTC device to adjust
  59. * @use_system_time: true to use system time, false to use @base_time
  60. * @offset: RTC offset from current system/base time (-1 for no
  61. * change)
  62. * @return old value of RTC offset
  63. */
  64. long sandbox_i2c_rtc_set_offset(struct udevice *dev, bool use_system_time,
  65. int offset);
  66. /**
  67. * sandbox_i2c_rtc_get_set_base_time() - get and set the base time
  68. *
  69. * @dev: RTC device to adjust
  70. * @base_time: New base system time (set to -1 for no change)
  71. * @return old base time
  72. */
  73. long sandbox_i2c_rtc_get_set_base_time(struct udevice *dev, long base_time);
  74. int sandbox_usb_keyb_add_string(struct udevice *dev, const char *str);
  75. /**
  76. * sandbox_osd_get_mem() - get the internal memory of a sandbox OSD
  77. *
  78. * @dev: OSD device for which to access the internal memory for
  79. * @buf: pointer to buffer to receive the OSD memory data
  80. * @buflen: length of buffer in bytes
  81. */
  82. int sandbox_osd_get_mem(struct udevice *dev, u8 *buf, size_t buflen);
  83. /**
  84. * sandbox_pwm_get_config() - get the PWM config for a channel
  85. *
  86. * @dev: Device to check
  87. * @channel: Channel number to check
  88. * @period_ns: Period of the PWM in nanoseconds
  89. * @duty_ns: Current duty cycle of the PWM in nanoseconds
  90. * @enable: true if the PWM is enabled
  91. * @polarity: true if the PWM polarity is active high
  92. * @return 0 if OK, -ENOSPC if the PWM number is invalid
  93. */
  94. int sandbox_pwm_get_config(struct udevice *dev, uint channel, uint *period_nsp,
  95. uint *duty_nsp, bool *enablep, bool *polarityp);
  96. /**
  97. * sandbox_sf_set_block_protect() - Set the BP bits of the status register
  98. *
  99. * @dev: Device to update
  100. * @bp_mask: BP bits to set (bits 2:0, so a value of 0 to 7)
  101. */
  102. void sandbox_sf_set_block_protect(struct udevice *dev, int bp_mask);
  103. /**
  104. * sandbox_get_codec_params() - Read back codec parameters
  105. *
  106. * This reads back the parameters set by audio_codec_set_params() for the
  107. * sandbox audio driver. Arguments are as for that function.
  108. */
  109. void sandbox_get_codec_params(struct udevice *dev, int *interfacep, int *ratep,
  110. int *mclk_freqp, int *bits_per_samplep,
  111. uint *channelsp);
  112. #endif