xref: /freebsd/sys/dev/xdma/xdma_if.m (revision a90b9d0159070121c221b966469c3e36d912bf82)
1#-
2# Copyright (c) 2016-2019 Ruslan Bukin <br@bsdpad.com>
3# All rights reserved.
4#
5# This software was developed by SRI International and the University of
6# Cambridge Computer Laboratory under DARPA/AFRL contract FA8750-10-C-0237
7# ("CTSRD"), as part of the DARPA CRASH research programme.
8#
9# Redistribution and use in source and binary forms, with or without
10# modification, are permitted provided that the following conditions
11# are met:
12# 1. Redistributions of source code must retain the above copyright
13#    notice, this list of conditions and the following disclaimer.
14# 2. Redistributions in binary form must reproduce the above copyright
15#    notice, this list of conditions and the following disclaimer in the
16#    documentation and/or other materials provided with the distribution.
17#
18# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28# SUCH DAMAGE.
29#
30#
31
32#include "opt_platform.h"
33
34#include <sys/malloc.h>
35
36#include <machine/bus.h>
37
38#ifdef FDT
39#include <dev/fdt/fdt_common.h>
40#include <dev/ofw/ofw_bus.h>
41#include <dev/ofw/ofw_bus_subr.h>
42#endif
43
44#include <dev/xdma/xdma.h>
45
46INTERFACE xdma;
47
48#
49# Request a transfer.
50#
51METHOD int channel_request {
52	device_t		dev;
53	struct xdma_channel	*xchan;
54	struct xdma_request	*req;
55};
56
57#
58# Prepare xDMA channel for a scatter-gather transfer.
59#
60METHOD int channel_prep_sg {
61	device_t		dev;
62	struct xdma_channel	*xchan;
63};
64
65#
66# Query DMA engine driver for the amount of free entries
67# (descriptors) are available.
68#
69METHOD int channel_capacity {
70	device_t			dev;
71	struct xdma_channel		*xchan;
72	uint32_t			*capacity;
73};
74
75#
76# Submit sglist list to DMA engine driver.
77#
78METHOD int channel_submit_sg {
79	device_t			dev;
80	struct xdma_channel		*xchan;
81	struct xdma_sglist		*sg;
82	uint32_t			sg_n;
83};
84
85#ifdef FDT
86#
87# Notify driver we have machine-dependend data.
88#
89METHOD int ofw_md_data {
90	device_t dev;
91	pcell_t *cells;
92	int ncells;
93	void **data;
94};
95#endif
96
97#
98# Allocate both virtual and harware channels.
99#
100METHOD int channel_alloc {
101	device_t dev;
102	struct xdma_channel *xchan;
103};
104
105#
106# Free the real hardware channel.
107#
108METHOD int channel_free {
109	device_t dev;
110	struct xdma_channel *xchan;
111};
112
113#
114# Begin, pause or terminate the channel operation.
115#
116METHOD int channel_control {
117	device_t dev;
118	struct xdma_channel *xchan;
119	int cmd;
120};
121
122# IOMMU interface
123
124#
125# pmap is initialized
126#
127METHOD int iommu_init {
128	device_t dev;
129	struct xdma_iommu *xio;
130};
131
132#
133# pmap is released
134#
135METHOD int iommu_release {
136	device_t dev;
137	struct xdma_iommu *xio;
138};
139
140#
141# Mapping entered
142#
143METHOD int iommu_enter {
144	device_t dev;
145	struct xdma_iommu *xio;
146	vm_offset_t va;
147	vm_offset_t pa;
148};
149
150#
151# Mapping removed
152#
153METHOD int iommu_remove {
154	device_t dev;
155	struct xdma_iommu *xio;
156	vm_offset_t va;
157};
158