1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /* Atlantic Network Driver
3  *
4  * Copyright (C) 2014-2019 aQuantia Corporation
5  * Copyright (C) 2019-2020 Marvell International Ltd.
6  */
7 
8 /* File aq_hw_utils.h: Declaration of helper functions used across hardware
9  * layer.
10  */
11 
12 #ifndef AQ_HW_UTILS_H
13 #define AQ_HW_UTILS_H
14 
15 #include <linux/iopoll.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_pr_err(...) pr_err(AQ_CFG_DRV_NAME ": " __VA_ARGS__)
27 #define aq_pr_trace(...) pr_info(AQ_CFG_DRV_NAME ": " __VA_ARGS__)
28 
29 struct aq_hw_s;
30 
31 void aq_hw_write_reg_bit(struct aq_hw_s *aq_hw, u32 addr, u32 msk,
32 			 u32 shift, u32 val);
33 u32 aq_hw_read_reg_bit(struct aq_hw_s *aq_hw, u32 addr, u32 msk, u32 shift);
34 u32 aq_hw_read_reg(struct aq_hw_s *hw, u32 reg);
35 void aq_hw_write_reg(struct aq_hw_s *hw, u32 reg, u32 value);
36 u64 aq_hw_read_reg64(struct aq_hw_s *hw, u32 reg);
37 void aq_hw_write_reg64(struct aq_hw_s *hw, u32 reg, u64 value);
38 int aq_hw_err_from_flags(struct aq_hw_s *hw);
39 int aq_hw_num_tcs(struct aq_hw_s *hw);
40 int aq_hw_q_per_tc(struct aq_hw_s *hw);
41 
42 #endif /* AQ_HW_UTILS_H */
43