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 
10 /* File aq_hw_utils.h: Declaration of helper functions used across hardware
11  * layer.
12  */
13 
14 #ifndef AQ_HW_UTILS_H
15 #define AQ_HW_UTILS_H
16 
17 #include <linux/iopoll.h>
18 
19 #include "aq_common.h"
20 
21 #ifndef HIDWORD
22 #define LODWORD(_qw)    ((u32)(_qw))
23 #define HIDWORD(_qw)    ((u32)(((_qw) >> 32) & 0xffffffff))
24 #endif
25 
26 #define AQ_HW_SLEEP(_US_) mdelay(_US_)
27 
28 #define aq_pr_err(...) pr_err(AQ_CFG_DRV_NAME ": " __VA_ARGS__)
29 #define aq_pr_trace(...) pr_info(AQ_CFG_DRV_NAME ": " __VA_ARGS__)
30 
31 struct aq_hw_s;
32 
33 void aq_hw_write_reg_bit(struct aq_hw_s *aq_hw, u32 addr, u32 msk,
34 			 u32 shift, u32 val);
35 u32 aq_hw_read_reg_bit(struct aq_hw_s *aq_hw, u32 addr, u32 msk, u32 shift);
36 u32 aq_hw_read_reg(struct aq_hw_s *hw, u32 reg);
37 void aq_hw_write_reg(struct aq_hw_s *hw, u32 reg, u32 value);
38 int aq_hw_err_from_flags(struct aq_hw_s *hw);
39 
40 #endif /* AQ_HW_UTILS_H */
41