]>
git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/blob - drivers/net/ethernet/aquantia/atlantic/aq_hw_utils.c
22a1c784dc9c7305c571e053857e666540234c56
2 * aQuantia Corporation Network Driver
3 * Copyright (C) 2014-2017 aQuantia Corporation. All rights reserved
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.
10 /* File aq_hw_utils.c: Definitions of helper functions used across
14 #include "aq_hw_utils.h"
18 void aq_hw_write_reg_bit(struct aq_hw_s
*aq_hw
, u32 addr
, u32 msk
,
24 reg_old
= aq_hw_read_reg(aq_hw
, addr
);
25 reg_new
= (reg_old
& (~msk
)) | (val
<< shift
);
27 if (reg_old
!= reg_new
)
28 aq_hw_write_reg(aq_hw
, addr
, reg_new
);
30 aq_hw_write_reg(aq_hw
, addr
, val
);
34 u32
aq_hw_read_reg_bit(struct aq_hw_s
*aq_hw
, u32 addr
, u32 msk
, u32 shift
)
36 return ((aq_hw_read_reg(aq_hw
, addr
) & msk
) >> shift
);
39 u32
aq_hw_read_reg(struct aq_hw_s
*hw
, u32 reg
)
41 u32 value
= readl(hw
->mmio
+ reg
);
44 (~0U) == readl(hw
->mmio
+
45 hw
->aq_nic_cfg
->aq_hw_caps
->hw_alive_check_addr
))
46 aq_utils_obj_set(&hw
->flags
, AQ_HW_FLAG_ERR_UNPLUG
);
51 void aq_hw_write_reg(struct aq_hw_s
*hw
, u32 reg
, u32 value
)
53 writel(value
, hw
->mmio
+ reg
);
56 /* Most of 64-bit registers are in LSW, MSW form.
57 Counters are normally implemented by HW as latched pairs:
58 reading LSW first locks MSW, to overcome LSW overflow
60 u64
aq_hw_read_reg64(struct aq_hw_s
*hw
, u32 reg
)
62 u64 value
= aq_hw_read_reg(hw
, reg
);
64 value
|= (u64
)aq_hw_read_reg(hw
, reg
+ 4) << 32;
68 int aq_hw_err_from_flags(struct aq_hw_s
*hw
)
72 if (aq_utils_obj_test(&hw
->flags
, AQ_HW_FLAG_ERR_UNPLUG
)) {
76 if (aq_utils_obj_test(&hw
->flags
, AQ_HW_FLAG_ERR_HW
)) {