source: rtems-libbsd/linux/drivers/soc/fsl/qbman/qman_priv.h @ 28ee86a

55-freebsd-126-freebsd-12
Last change on this file since 28ee86a was 28ee86a, checked in by Sebastian Huber <sebastian.huber@…>, on 04/27/16 at 09:58:19

Import DPAA driver snapshot

Imported from Freescale Linux repository

git://git.freescale.com/ppc/upstream/linux.git

commit 2774c204cd8bfc56a200ff4dcdfc9cdf5b6fc161.

Linux compatibility layer is partly from FreeBSD.

  • Property mode set to 100644
File size: 10.7 KB
Line 
1/* Copyright 2008 - 2015 Freescale Semiconductor, Inc.
2 *
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions are met:
5 *     * Redistributions of source code must retain the above copyright
6 *       notice, this list of conditions and the following disclaimer.
7 *     * Redistributions in binary form must reproduce the above copyright
8 *       notice, this list of conditions and the following disclaimer in the
9 *       documentation and/or other materials provided with the distribution.
10 *     * Neither the name of Freescale Semiconductor nor the
11 *       names of its contributors may be used to endorse or promote products
12 *       derived from this software without specific prior written permission.
13 *
14 * ALTERNATIVELY, this software may be distributed under the terms of the
15 * GNU General Public License ("GPL") as published by the Free Software
16 * Foundation, either version 2 of that License or (at your option) any
17 * later version.
18 *
19 * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
20 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
23 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
32
33#include "dpaa_sys.h"
34
35#include <soc/fsl/qman.h>
36#include <linux/iommu.h>
37#include <asm/fsl_pamu_stash.h>
38
39/* Congestion Groups */
40
41/* This wrapper represents a bit-array for the state of the 256 QMan congestion
42 * groups. Is also used as a *mask* for congestion groups, eg. so we ignore
43 * those that don't concern us. We harness the structure and accessor details
44 * already used in the management command to query congestion groups.
45 */
46struct qman_cgrs {
47        struct __qm_mcr_querycongestion q;
48};
49static inline void qman_cgrs_init(struct qman_cgrs *c)
50{
51        memset(c, 0, sizeof(*c));
52}
53static inline void qman_cgrs_fill(struct qman_cgrs *c)
54{
55        memset(c, 0xff, sizeof(*c));
56}
57static inline int qman_cgrs_get(struct qman_cgrs *c, int num)
58{
59        return QM_MCR_QUERYCONGESTION(&c->q, num);
60}
61static inline void qman_cgrs_set(struct qman_cgrs *c, int num)
62{
63        c->q.__state[__CGR_WORD(num)] |= (0x80000000 >> __CGR_SHIFT(num));
64}
65static inline void qman_cgrs_unset(struct qman_cgrs *c, int num)
66{
67        c->q.__state[__CGR_WORD(num)] &= ~(0x80000000 >> __CGR_SHIFT(num));
68}
69static inline int qman_cgrs_next(struct qman_cgrs *c, int num)
70{
71        while ((++num < __CGR_NUM) && !qman_cgrs_get(c, num))
72                ;
73        return num;
74}
75static inline void qman_cgrs_cp(struct qman_cgrs *dest,
76                                const struct qman_cgrs *src)
77{
78        *dest = *src;
79}
80static inline void qman_cgrs_and(struct qman_cgrs *dest,
81                        const struct qman_cgrs *a, const struct qman_cgrs *b)
82{
83        int ret;
84        u32 *_d = dest->q.__state;
85        const u32 *_a = a->q.__state;
86        const u32 *_b = b->q.__state;
87
88        for (ret = 0; ret < 8; ret++)
89                *(_d++) = *(_a++) & *(_b++);
90}
91static inline void qman_cgrs_xor(struct qman_cgrs *dest,
92                        const struct qman_cgrs *a, const struct qman_cgrs *b)
93{
94        int ret;
95        u32 *_d = dest->q.__state;
96        const u32 *_a = a->q.__state;
97        const u32 *_b = b->q.__state;
98
99        for (ret = 0; ret < 8; ret++)
100                *(_d++) = *(_a++) ^ *(_b++);
101}
102
103/* used by CCSR and portal interrupt code */
104enum qm_isr_reg {
105        qm_isr_status = 0,
106        qm_isr_enable = 1,
107        qm_isr_disable = 2,
108        qm_isr_inhibit = 3
109};
110
111struct qm_portal_config {
112        /* Corenet portal addresses;
113         * [0]==cache-enabled, [1]==cache-inhibited. */
114        __iomem void *addr_virt[2];
115#ifndef __rtems__
116        struct resource addr_phys[2];
117        struct device dev;
118        struct iommu_domain *iommu_domain;
119        /* Allow these to be joined in lists */
120        struct list_head list;
121#endif /* __rtems__ */
122        /* User-visible portal configuration settings */
123        struct qman_portal_config public_cfg;
124};
125
126/* Revision info (for errata and feature handling) */
127#define QMAN_REV11 0x0101
128#define QMAN_REV12 0x0102
129#define QMAN_REV20 0x0200
130#define QMAN_REV30 0x0300
131#define QMAN_REV31 0x0301
132extern u16 qman_ip_rev; /* 0 if uninitialised, otherwise QMAN_REVx */
133
134extern u16 qman_portal_max;
135
136#ifdef CONFIG_FSL_QMAN_CONFIG
137/* Hooks from qman_driver.c to qman_config.c */
138int qman_init_ccsr(struct device_node *node);
139void qman_liodn_fixup(u16 channel);
140int qman_set_sdest(u16 channel, unsigned int cpu_idx);
141size_t qman_fqd_size(void);
142#endif
143
144int qm_set_wpm(int wpm);
145int qm_get_wpm(int *wpm);
146
147/* Hooks from qman_driver.c in to qman_high.c */
148struct qman_portal *qman_create_portal(
149                        struct qman_portal *portal,
150                        const struct qm_portal_config *config,
151                        const struct qman_cgrs *cgrs);
152
153struct qman_portal *qman_create_affine_portal(
154                        const struct qm_portal_config *config,
155                        const struct qman_cgrs *cgrs);
156struct qman_portal *qman_create_affine_slave(struct qman_portal *redirect,
157                                                                int cpu);
158const struct qm_portal_config *qman_destroy_affine_portal(void);
159void qman_destroy_portal(struct qman_portal *qm);
160
161/* This CGR feature is supported by h/w and required by unit-tests and the
162 * debugfs hooks, so is implemented in the driver. However it allows an explicit
163 * corruption of h/w fields by s/w that are usually incorruptible (because the
164 * counters are usually maintained entirely within h/w). As such, we declare
165 * this API internally. */
166int qman_testwrite_cgr(struct qman_cgr *cgr, u64 i_bcnt,
167        struct qm_mcr_cgrtestwrite *result);
168
169#ifdef CONFIG_FSL_QMAN_FQ_LOOKUP
170/* If the fq object pointer is greater than the size of context_b field,
171 * than a lookup table is required. */
172int qman_setup_fq_lookup_table(size_t num_entries);
173#endif
174
175
176/*************************************************/
177/*   QMan s/w corenet portal, low-level i/face   */
178/*************************************************/
179
180/* Note: most functions are only used by the high-level interface, so are
181 * inlined from qman.h. The stuff below is for use by other parts of the
182 * driver. */
183
184/* For qm_dqrr_sdqcr_set(); Choose one SOURCE. Choose one COUNT. Choose one
185 * dequeue TYPE. Choose TOKEN (8-bit).
186 * If SOURCE == CHANNELS,
187 *   Choose CHANNELS_DEDICATED and/or CHANNELS_POOL(n).
188 *   You can choose DEDICATED_PRECEDENCE if the portal channel should have
189 *   priority.
190 * If SOURCE == SPECIFICWQ,
191 *     Either select the work-queue ID with SPECIFICWQ_WQ(), or select the
192 *     channel (SPECIFICWQ_DEDICATED or SPECIFICWQ_POOL()) and specify the
193 *     work-queue priority (0-7) with SPECIFICWQ_WQ() - either way, you get the
194 *     same value.
195 */
196#define QM_SDQCR_SOURCE_CHANNELS        0x0
197#define QM_SDQCR_SOURCE_SPECIFICWQ      0x40000000
198#define QM_SDQCR_COUNT_EXACT1           0x0
199#define QM_SDQCR_COUNT_UPTO3            0x20000000
200#define QM_SDQCR_DEDICATED_PRECEDENCE   0x10000000
201#define QM_SDQCR_TYPE_MASK              0x03000000
202#define QM_SDQCR_TYPE_NULL              0x0
203#define QM_SDQCR_TYPE_PRIO_QOS          0x01000000
204#define QM_SDQCR_TYPE_ACTIVE_QOS        0x02000000
205#define QM_SDQCR_TYPE_ACTIVE            0x03000000
206#define QM_SDQCR_TOKEN_MASK             0x00ff0000
207#define QM_SDQCR_TOKEN_SET(v)           (((v) & 0xff) << 16)
208#define QM_SDQCR_TOKEN_GET(v)           (((v) >> 16) & 0xff)
209#define QM_SDQCR_CHANNELS_DEDICATED     0x00008000
210#define QM_SDQCR_SPECIFICWQ_MASK        0x000000f7
211#define QM_SDQCR_SPECIFICWQ_DEDICATED   0x00000000
212#define QM_SDQCR_SPECIFICWQ_POOL(n)     ((n) << 4)
213#define QM_SDQCR_SPECIFICWQ_WQ(n)       (n)
214
215/* For qm_dqrr_vdqcr_set(): use FQID(n) to fill in the frame queue ID */
216#define QM_VDQCR_FQID_MASK              0x00ffffff
217#define QM_VDQCR_FQID(n)                ((n) & QM_VDQCR_FQID_MASK)
218
219/* For qm_dqrr_pdqcr_set(); Choose one MODE. Choose one COUNT.
220 * If MODE==SCHEDULED
221 *   Choose SCHEDULED_CHANNELS or SCHEDULED_SPECIFICWQ. Choose one dequeue TYPE.
222 *   If CHANNELS,
223 *     Choose CHANNELS_DEDICATED and/or CHANNELS_POOL() channels.
224 *     You can choose DEDICATED_PRECEDENCE if the portal channel should have
225 *     priority.
226 *   If SPECIFICWQ,
227 *     Either select the work-queue ID with SPECIFICWQ_WQ(), or select the
228 *     channel (SPECIFICWQ_DEDICATED or SPECIFICWQ_POOL()) and specify the
229 *     work-queue priority (0-7) with SPECIFICWQ_WQ() - either way, you get the
230 *     same value.
231 * If MODE==UNSCHEDULED
232 *     Choose FQID().
233 */
234#define QM_PDQCR_MODE_SCHEDULED         0x0
235#define QM_PDQCR_MODE_UNSCHEDULED       0x80000000
236#define QM_PDQCR_SCHEDULED_CHANNELS     0x0
237#define QM_PDQCR_SCHEDULED_SPECIFICWQ   0x40000000
238#define QM_PDQCR_COUNT_EXACT1           0x0
239#define QM_PDQCR_COUNT_UPTO3            0x20000000
240#define QM_PDQCR_DEDICATED_PRECEDENCE   0x10000000
241#define QM_PDQCR_TYPE_MASK              0x03000000
242#define QM_PDQCR_TYPE_NULL              0x0
243#define QM_PDQCR_TYPE_PRIO_QOS          0x01000000
244#define QM_PDQCR_TYPE_ACTIVE_QOS        0x02000000
245#define QM_PDQCR_TYPE_ACTIVE            0x03000000
246#define QM_PDQCR_CHANNELS_DEDICATED     0x00008000
247#define QM_PDQCR_CHANNELS_POOL(n)       (0x00008000 >> (n))
248#define QM_PDQCR_SPECIFICWQ_MASK        0x000000f7
249#define QM_PDQCR_SPECIFICWQ_DEDICATED   0x00000000
250#define QM_PDQCR_SPECIFICWQ_POOL(n)     ((n) << 4)
251#define QM_PDQCR_SPECIFICWQ_WQ(n)       (n)
252#define QM_PDQCR_FQID(n)                ((n) & 0xffffff)
253
254/* Used by all portal interrupt registers except 'inhibit'
255 * Channels with frame availability
256 */
257#define QM_PIRQ_DQAVAIL 0x0000ffff
258
259/* The DQAVAIL interrupt fields break down into these bits; */
260#define QM_DQAVAIL_PORTAL       0x8000          /* Portal channel */
261#define QM_DQAVAIL_POOL(n)      (0x8000 >> (n)) /* Pool channel, n==[1..15] */
262#define QM_DQAVAIL_MASK         0xffff
263/* This mask contains all the "irqsource" bits visible to API users */
264#define QM_PIRQ_VISIBLE (QM_PIRQ_SLOW | QM_PIRQ_DQRI)
265
266/* These are qm_<reg>_<verb>(). So for example, qm_disable_write() means "write
267 * the disable register" rather than "disable the ability to write". */
268#define qm_isr_status_read(qm)          __qm_isr_read(qm, qm_isr_status)
269#define qm_isr_status_clear(qm, m)      __qm_isr_write(qm, qm_isr_status, m)
270#define qm_isr_enable_read(qm)          __qm_isr_read(qm, qm_isr_enable)
271#define qm_isr_enable_write(qm, v)      __qm_isr_write(qm, qm_isr_enable, v)
272#define qm_isr_disable_read(qm)         __qm_isr_read(qm, qm_isr_disable)
273#define qm_isr_disable_write(qm, v)     __qm_isr_write(qm, qm_isr_disable, v)
274/* TODO: unfortunate name-clash here, reword? */
275#define qm_isr_inhibit(qm)              __qm_isr_write(qm, qm_isr_inhibit, 1)
276#define qm_isr_uninhibit(qm)            __qm_isr_write(qm, qm_isr_inhibit, 0)
277
278#ifdef CONFIG_FSL_QMAN_CONFIG
279int qman_have_ccsr(void);
280#else
281#define qman_have_ccsr  0
282#endif
283
284#ifndef __rtems__
285__init int qman_init(void);
286#else /* __rtems__ */
287int qman_init(struct device_node *dn);
288#endif /* __rtems__ */
289__init int qman_resource_init(void);
290
291extern void *affine_portals[NR_CPUS];
292const struct qm_portal_config *qman_get_qm_portal_config(
293                                                struct qman_portal *portal);
Note: See TracBrowser for help on using the repository browser.