xref: /freebsd/sys/dev/pci/pci_dw_if.m (revision 031beb4e239bfce798af17f5fe8dba8bcaf13d99)
1*26abae3fSMichal Meloun#-
2*26abae3fSMichal Meloun# Copyright (c) 2019 Michal Meloun <mmel@FreeBSD.org>
3*26abae3fSMichal Meloun# All rights reserved.
4*26abae3fSMichal Meloun#
5*26abae3fSMichal Meloun# Redistribution and use in source and binary forms, with or without
6*26abae3fSMichal Meloun# modification, are permitted provided that the following conditions
7*26abae3fSMichal Meloun# are met:
8*26abae3fSMichal Meloun# 1. Redistributions of source code must retain the above copyright
9*26abae3fSMichal Meloun#    notice, this list of conditions and the following disclaimer.
10*26abae3fSMichal Meloun# 2. Redistributions in binary form must reproduce the above copyright
11*26abae3fSMichal Meloun#    notice, this list of conditions and the following disclaimer in the
12*26abae3fSMichal Meloun#    documentation and/or other materials provided with the distribution.
13*26abae3fSMichal Meloun#
14*26abae3fSMichal Meloun# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15*26abae3fSMichal Meloun# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16*26abae3fSMichal Meloun# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17*26abae3fSMichal Meloun# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18*26abae3fSMichal Meloun# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19*26abae3fSMichal Meloun# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20*26abae3fSMichal Meloun# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21*26abae3fSMichal Meloun# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22*26abae3fSMichal Meloun# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23*26abae3fSMichal Meloun# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24*26abae3fSMichal Meloun# SUCH DAMAGE.
25*26abae3fSMichal Meloun#
26*26abae3fSMichal Meloun#
27*26abae3fSMichal Meloun
28*26abae3fSMichal Meloun#include <machine/bus.h>
29*26abae3fSMichal Meloun
30*26abae3fSMichal MelounINTERFACE pci_dw;
31*26abae3fSMichal Meloun
32*26abae3fSMichal Meloun
33*26abae3fSMichal Meloun/**
34*26abae3fSMichal Meloun * Read from dbi space.
35*26abae3fSMichal Meloun * The reg argument is a byte offset into dbi space.
36*26abae3fSMichal Meloun * The width argument (which should be 1, 2 or 4) specifies how
37*26abae3fSMichal Meloun * many bytes  to read from that offset.
38*26abae3fSMichal Meloun */
39*26abae3fSMichal MelounMETHOD  uint32_t dbi_read{
40*26abae3fSMichal Meloun	device_t	dev;
41*26abae3fSMichal Meloun	u_int		reg;
42*26abae3fSMichal Meloun	int		width;
43*26abae3fSMichal Meloun};
44*26abae3fSMichal Meloun
45*26abae3fSMichal Meloun/**
46*26abae3fSMichal Meloun * Write to dbi space.
47*26abae3fSMichal Meloun * The reg argument is a byte offset into dbi space.
48*26abae3fSMichal Meloun * The width argument (which should be 1, 2 or 4) specifies how
49*26abae3fSMichal Meloun * many bytes  to write to that offset.
50*26abae3fSMichal Meloun */
51*26abae3fSMichal MelounMETHOD void dbi_write{
52*26abae3fSMichal Meloun	device_t	dev;
53*26abae3fSMichal Meloun	u_int		reg;
54*26abae3fSMichal Meloun	uint32_t	value;
55*26abae3fSMichal Meloun	int		width;
56*26abae3fSMichal Meloun};
57*26abae3fSMichal Meloun
58*26abae3fSMichal Meloun/**
59*26abae3fSMichal Meloun * Start or stop link
60*26abae3fSMichal Meloun */
61*26abae3fSMichal MelounMETHOD int set_link{
62*26abae3fSMichal Meloun	device_t	dev;
63*26abae3fSMichal Meloun	bool		start;
64*26abae3fSMichal Meloun};
65*26abae3fSMichal Meloun
66*26abae3fSMichal Meloun/**
67*26abae3fSMichal Meloun * Query link status (up/down)
68*26abae3fSMichal Meloun */
69*26abae3fSMichal MelounMETHOD int get_link{
70*26abae3fSMichal Meloun	device_t	dev;
71*26abae3fSMichal Meloun	bool		*status;
72*26abae3fSMichal Meloun};
73