1179055Sjfv/******************************************************************************
2171384Sjfv
3320897Serj  Copyright (c) 2001-2017, Intel Corporation
4171384Sjfv  All rights reserved.
5171384Sjfv
6171384Sjfv  Redistribution and use in source and binary forms, with or without
7171384Sjfv  modification, are permitted provided that the following conditions are met:
8171384Sjfv
9171384Sjfv   1. Redistributions of source code must retain the above copyright notice,
10171384Sjfv      this list of conditions and the following disclaimer.
11171384Sjfv
12171384Sjfv   2. Redistributions in binary form must reproduce the above copyright
13171384Sjfv      notice, this list of conditions and the following disclaimer in the
14171384Sjfv      documentation and/or other materials provided with the distribution.
15171384Sjfv
16171384Sjfv   3. Neither the name of the Intel Corporation nor the names of its
17171384Sjfv      contributors may be used to endorse or promote products derived from
18171384Sjfv      this software without specific prior written permission.
19171384Sjfv
20171384Sjfv  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21171384Sjfv  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22171384Sjfv  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23171384Sjfv  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24171384Sjfv  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25171384Sjfv  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26171384Sjfv  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27171384Sjfv  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28171384Sjfv  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29171384Sjfv  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30171384Sjfv  POSSIBILITY OF SUCH DAMAGE.
31171384Sjfv
32179055Sjfv******************************************************************************/
33179055Sjfv/*$FreeBSD: stable/11/sys/dev/ixgbe/ixgbe_osdep.c 320897 2017-07-11 21:25:07Z erj $*/
34292674Ssbruno
35292674Ssbruno#include "ixgbe.h"
36292674Ssbruno
37292674Ssbrunoinline u16
38292674Ssbrunoixgbe_read_pci_cfg(struct ixgbe_hw *hw, u32 reg)
39292674Ssbruno{
40320897Serj	return pci_read_config(((struct adapter *)hw->back)->dev, reg, 2);
41292674Ssbruno}
42292674Ssbruno
43292674Ssbrunoinline void
44292674Ssbrunoixgbe_write_pci_cfg(struct ixgbe_hw *hw, u32 reg, u16 value)
45292674Ssbruno{
46320897Serj	pci_write_config(((struct adapter *)hw->back)->dev, reg, value, 2);
47292674Ssbruno}
48292674Ssbruno
49292674Ssbrunoinline u32
50292674Ssbrunoixgbe_read_reg(struct ixgbe_hw *hw, u32 reg)
51292674Ssbruno{
52292674Ssbruno	return bus_space_read_4(((struct adapter *)hw->back)->osdep.mem_bus_space_tag,
53320897Serj	    ((struct adapter *)hw->back)->osdep.mem_bus_space_handle, reg);
54292674Ssbruno}
55292674Ssbruno
56292674Ssbrunoinline void
57292674Ssbrunoixgbe_write_reg(struct ixgbe_hw *hw, u32 reg, u32 val)
58292674Ssbruno{
59292674Ssbruno	bus_space_write_4(((struct adapter *)hw->back)->osdep.mem_bus_space_tag,
60292674Ssbruno	    ((struct adapter *)hw->back)->osdep.mem_bus_space_handle,
61292674Ssbruno	    reg, val);
62292674Ssbruno}
63292674Ssbruno
64292674Ssbrunoinline u32
65292674Ssbrunoixgbe_read_reg_array(struct ixgbe_hw *hw, u32 reg, u32 offset)
66292674Ssbruno{
67292674Ssbruno	return bus_space_read_4(((struct adapter *)hw->back)->osdep.mem_bus_space_tag,
68292674Ssbruno	    ((struct adapter *)hw->back)->osdep.mem_bus_space_handle,
69292674Ssbruno	    reg + (offset << 2));
70292674Ssbruno}
71292674Ssbruno
72292674Ssbrunoinline void
73292674Ssbrunoixgbe_write_reg_array(struct ixgbe_hw *hw, u32 reg, u32 offset, u32 val)
74292674Ssbruno{
75292674Ssbruno	bus_space_write_4(((struct adapter *)hw->back)->osdep.mem_bus_space_tag,
76292674Ssbruno	    ((struct adapter *)hw->back)->osdep.mem_bus_space_handle,
77292674Ssbruno	    reg + (offset << 2), val);
78292674Ssbruno}
79