aq_hw_utils.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * aQuantia Corporation Network Driver
  3. * Copyright (C) 2014-2017 aQuantia Corporation. All rights reserved
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms and conditions of the GNU General Public License,
  7. * version 2, as published by the Free Software Foundation.
  8. */
  9. /* File aq_hw_utils.h: Declaration of helper functions used across hardware
  10. * layer.
  11. */
  12. #ifndef AQ_HW_UTILS_H
  13. #define AQ_HW_UTILS_H
  14. #include "aq_common.h"
  15. #ifndef HIDWORD
  16. #define LODWORD(_qw) ((u32)(_qw))
  17. #define HIDWORD(_qw) ((u32)(((_qw) >> 32) & 0xffffffff))
  18. #endif
  19. #define AQ_HW_SLEEP(_US_) mdelay(_US_)
  20. #define AQ_HW_WAIT_FOR(_B_, _US_, _N_) \
  21. do { \
  22. unsigned int AQ_HW_WAIT_FOR_i; \
  23. for (AQ_HW_WAIT_FOR_i = _N_; (!(_B_)) && (AQ_HW_WAIT_FOR_i);\
  24. --AQ_HW_WAIT_FOR_i) {\
  25. udelay(_US_); \
  26. } \
  27. if (!AQ_HW_WAIT_FOR_i) {\
  28. err = -ETIME; \
  29. } \
  30. } while (0)
  31. struct aq_hw_s;
  32. void aq_hw_write_reg_bit(struct aq_hw_s *aq_hw, u32 addr, u32 msk,
  33. u32 shift, u32 val);
  34. u32 aq_hw_read_reg_bit(struct aq_hw_s *aq_hw, u32 addr, u32 msk, u32 shift);
  35. u32 aq_hw_read_reg(struct aq_hw_s *hw, u32 reg);
  36. void aq_hw_write_reg(struct aq_hw_s *hw, u32 reg, u32 value);
  37. int aq_hw_err_from_flags(struct aq_hw_s *hw);
  38. #endif /* AQ_HW_UTILS_H */