1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright © 2021-2022 Dmitry Salychev
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27
28 #ifndef _DPAA2_IO_H
29 #define _DPAA2_IO_H
30
31 #include <sys/rman.h>
32 #include <sys/bus.h>
33 #include <sys/queue.h>
34
35 #include "dpaa2_types.h"
36 #include "dpaa2_mcp.h"
37
38 /* Maximum resources per DPIO: 3 SYS_MEM + 1 DPMCP. */
39 #define DPAA2_IO_MAX_RESOURCES 4
40 /* Maximum number of MSIs supported by the DPIO objects. */
41 #define DPAA2_IO_MSI_COUNT 1
42
43 enum dpaa2_io_chan_mode {
44 DPAA2_IO_NO_CHANNEL,
45 DPAA2_IO_LOCAL_CHANNEL
46 };
47
48 /**
49 * @brief Attributes of the DPIO object.
50 *
51 * swp_ce_paddr: Physical address of the cache-enabled area.
52 * swp_ci_paddr: Physical address of the cache-inhibited area.
53 * swp_version: Hardware IP version of the software portal.
54 * swp_clk: QBMAN clock frequency value in Hz.
55 * id: DPIO object ID.
56 * swp_id: Software portal ID.
57 * priors_num: Number of priorities for the notification channel (1-8);
58 * relevant only if channel mode is "local channel".
59 * chan_mode: Notification channel mode.
60 */
61 struct dpaa2_io_attr {
62 uint64_t swp_ce_paddr;
63 uint64_t swp_ci_paddr;
64 uint32_t swp_version;
65 uint32_t swp_clk;
66 uint32_t id;
67 uint16_t swp_id;
68 uint8_t priors_num;
69 enum dpaa2_io_chan_mode chan_mode;
70 };
71
72 /**
73 * @brief Context used by DPIO to configure data availability notifications
74 * (CDAN) on a particular WQ channel.
75 */
76 struct dpaa2_io_notif_ctx {
77 void (*poll)(void *);
78
79 device_t io_dev;
80 void *channel;
81 uint64_t qman_ctx;
82 uint16_t fq_chan_id;
83 bool cdan_en;
84 };
85
86 /**
87 * @brief Software context for the DPAA2 I/O driver.
88 */
89 struct dpaa2_io_softc {
90 device_t dev;
91 struct dpaa2_swp_desc swp_desc;
92 struct dpaa2_swp *swp;
93 struct dpaa2_io_attr attr;
94
95 /* Help to send commands to MC. */
96 struct dpaa2_cmd *cmd;
97 uint16_t rc_token;
98 uint16_t io_token;
99
100 struct resource *res[DPAA2_IO_MAX_RESOURCES];
101 struct resource_map map[DPAA2_IO_MAX_RESOURCES];
102
103 int irq_rid[DPAA2_IO_MSI_COUNT];
104 struct resource *irq_resource;
105 void *intr; /* interrupt handle */
106 };
107
108 extern struct resource_spec dpaa2_io_spec[];
109
110 #endif /* _DPAA2_IO_H */
Cache object: 9ee8a1f08d69ade866c03d1c1792b492
|