seq_hwio.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. * Copyright (c) 2019, The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. /*********************************************************************************
  17. *
  18. * DESCRIPTION
  19. * - This is an extension of standard msmhwio.h to support relative addressing
  20. * scheme used in SCALe auto-generated sequences.
  21. * - The objective of this new addressing scheme is enable the same C function
  22. * definition to be applicable to multiple baseances of the same block.
  23. * - Such code reuse is not feasible with the standard HWIO macros that use a
  24. * absolute addressing scheme.
  25. * - Compared to the standard HWIO macros, the new macros defined here take an
  26. * additional parameter 'baseance offset'. So are the C functions generated
  27. * by SCALe Autoseq from .seq inputs.
  28. * - As such, macros defined in this file must be used with 'seq_msmhwiobase.h',
  29. * 'seq_msmhwioreg.h', and the C codes generated from SCALe Autoseq.
  30. * - Macros defined in this file leverage the lower-level macros from the
  31. * standard 'msmhwio.h', and the two sets of macros are compatible.
  32. *
  33. ********************************************************************************/
  34. #ifndef __SEQ_H__
  35. #define __SEQ_H__
  36. #include "HALhwio.h"
  37. /**** Register Ref Read ****/
  38. #define SEQ_INH(base, regtype, reg) \
  39. SEQ_##regtype##_INH(base, reg)
  40. /**** Masked Register Read ****/
  41. #define SEQ_INMH(base, regtype, reg, mask) \
  42. SEQ_##regtype##_INMH(base, reg, mask)
  43. /**** Ref Reg Field Read ****/
  44. #define SEQ_INFH(base, regtype, reg, fld) \
  45. (SEQ_##regtype##_INMH(base, reg, HWIO_FMSK(regtype, fld)) >> HWIO_SHFT(regtype, fld))
  46. /**** Ref Register Write ****/
  47. #define SEQ_OUTH(base, regtype, reg, val) \
  48. SEQ_##regtype##_OUTH(base, reg, val)
  49. /**** Ref Register Masked Write ****/
  50. #define SEQ_OUTMH(base, regtype, reg, mask, val) \
  51. SEQ_##regtype##_OUTMH(base, reg, mask, val)
  52. /**** Ref Register Field Write ****/
  53. #define SEQ_OUTFH(base, regtype, reg, fld, val) \
  54. SEQ_##regtype##_OUTMH(base, reg, HWIO_FMSK(regtype, fld), val << HWIO_SHFT(regtype, fld))
  55. /**** seq_msg() ****
  56. typedef enum {
  57. DEBUG,
  58. INFO,
  59. WARNING,
  60. ERROR,
  61. FATAL
  62. } SeverityLevel ;
  63. void seq_msg(SeverityLevel severity, unsigned int msg_id, const char *format_str, ... );
  64. */
  65. /************ seq_wait() ************/
  66. typedef enum {
  67. SEC,
  68. MS,
  69. US,
  70. NS
  71. } SEQ_TimeUnit;
  72. void seq_wait(uint32_t time_value, SEQ_TimeUnit time_unit);
  73. /************ seq_poll() ************/
  74. uint32_t seq_poll(uint32_t reg_offset, uint32_t expect_value, uint32_t value_mask, uint32_t value_shift, uint32_t max_poll_cnt);
  75. #endif /* __SEQ_H__ */