1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * aQuantia Corporation Network Driver
4  * Copyright (C) 2014-2017 aQuantia Corporation. All rights reserved
5  */
6 
7 /* File aq_hw_utils.h: Declaration of helper functions used across hardware
8  * layer.
9  */
10 
11 #ifndef AQ_HW_UTILS_H
12 #define AQ_HW_UTILS_H
13 
14 #include <linux/iopoll.h>
15 
16 #include "aq_common.h"
17 
18 #ifndef HIDWORD
19 #define LODWORD(_qw)    ((u32)(_qw))
20 #define HIDWORD(_qw)    ((u32)(((_qw) >> 32) & 0xffffffff))
21 #endif
22 
23 #define AQ_HW_SLEEP(_US_) mdelay(_US_)
24 
25 #define aq_pr_err(...) pr_err(AQ_CFG_DRV_NAME ": " __VA_ARGS__)
26 #define aq_pr_trace(...) pr_info(AQ_CFG_DRV_NAME ": " __VA_ARGS__)
27 
28 struct aq_hw_s;
29 
30 void aq_hw_write_reg_bit(struct aq_hw_s *aq_hw, u32 addr, u32 msk,
31 			 u32 shift, u32 val);
32 u32 aq_hw_read_reg_bit(struct aq_hw_s *aq_hw, u32 addr, u32 msk, u32 shift);
33 u32 aq_hw_read_reg(struct aq_hw_s *hw, u32 reg);
34 void aq_hw_write_reg(struct aq_hw_s *hw, u32 reg, u32 value);
35 u64 aq_hw_read_reg64(struct aq_hw_s *hw, u32 reg);
36 int aq_hw_err_from_flags(struct aq_hw_s *hw);
37 
38 #endif /* AQ_HW_UTILS_H */
39