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 int aq_hw_err_from_flags(struct aq_hw_s *hw)
60 if (aq_utils_obj_test(&hw->flags, AQ_HW_FLAG_ERR_UNPLUG)) {
64 if (aq_utils_obj_test(&hw->flags, AQ_HW_FLAG_ERR_HW)) {