1
2
3
4
5
6
7
8
9
10
11
12
13
14#ifndef AQ_HW_UTILS_H
15#define AQ_HW_UTILS_H
16
17#include "aq_common.h"
18
19#ifndef HIDWORD
20#define LODWORD(_qw) ((u32)(_qw))
21#define HIDWORD(_qw) ((u32)(((_qw) >> 32) & 0xffffffff))
22#endif
23
24#define AQ_HW_SLEEP(_US_) mdelay(_US_)
25
26#define AQ_HW_WAIT_FOR(_B_, _US_, _N_) \
27do { \
28 unsigned int AQ_HW_WAIT_FOR_i; \
29 for (AQ_HW_WAIT_FOR_i = _N_; (!(_B_)) && (AQ_HW_WAIT_FOR_i);\
30 --AQ_HW_WAIT_FOR_i) {\
31 udelay(_US_); \
32 } \
33 if (!AQ_HW_WAIT_FOR_i) {\
34 err = -ETIME; \
35 } \
36} while (0)
37
38#define aq_pr_err(...) pr_err(AQ_CFG_DRV_NAME ": " __VA_ARGS__)
39#define aq_pr_trace(...) pr_info(AQ_CFG_DRV_NAME ": " __VA_ARGS__)
40
41struct aq_hw_s;
42
43void aq_hw_write_reg_bit(struct aq_hw_s *aq_hw, u32 addr, u32 msk,
44 u32 shift, u32 val);
45u32 aq_hw_read_reg_bit(struct aq_hw_s *aq_hw, u32 addr, u32 msk, u32 shift);
46u32 aq_hw_read_reg(struct aq_hw_s *hw, u32 reg);
47void aq_hw_write_reg(struct aq_hw_s *hw, u32 reg, u32 value);
48int aq_hw_err_from_flags(struct aq_hw_s *hw);
49
50#endif
51