1 // SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
2 /* Copyright (C) 2014-2017 aQuantia Corporation. */
4 /* File aq_hw_utils.c: Definitions of helper functions used across
8 #include "atl_hw_regs.h"
11 #include <rte_byteorder.h>
13 void aq_hw_write_reg_bit(struct aq_hw_s *aq_hw, u32 addr, u32 msk,
19 reg_old = aq_hw_read_reg(aq_hw, addr);
20 reg_new = (reg_old & (~msk)) | (val << shift);
22 if (reg_old != reg_new)
23 aq_hw_write_reg(aq_hw, addr, reg_new);
25 aq_hw_write_reg(aq_hw, addr, val);
29 u32 aq_hw_read_reg_bit(struct aq_hw_s *aq_hw, u32 addr, u32 msk, u32 shift)
31 return ((aq_hw_read_reg(aq_hw, addr) & msk) >> shift);
34 u32 aq_hw_read_reg(struct aq_hw_s *hw, u32 reg)
36 return rte_le_to_cpu_32(rte_read32((u8 *)hw->mmio + reg));
39 void aq_hw_write_reg(struct aq_hw_s *hw, u32 reg, u32 value)
41 rte_write32((rte_cpu_to_le_32(value)), (u8 *)hw->mmio + reg);
44 int aq_hw_err_from_flags(struct aq_hw_s *hw)
48 if (aq_hw_read_reg(hw, 0x10U) == ~0U)