2 * This file is provided under a dual BSD/GPLv2 license. When using or
3 * redistributing this file, you may do so under either license.
7 * Copyright 2008-2016 Freescale Semiconductor Inc.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions are met:
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * 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 * * Neither the name of the above-listed copyright holders nor the
18 * names of any contributors may be used to endorse or promote products
19 * derived from this software without specific prior written permission.
23 * ALTERNATIVELY, this software may be distributed under the terms of the
24 * GNU General Public License ("GPL") as published by the Free Software
25 * Foundation, either version 2 of that License or (at your option) any
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
29 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
32 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
33 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
34 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
35 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
36 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
37 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38 * POSSIBILITY OF SUCH DAMAGE.
47 /* Revision info (for errata and feature handling) */
48 #define BMAN_REV10 0x0100
49 #define BMAN_REV20 0x0200
50 #define BMAN_REV21 0x0201
52 #define BMAN_PORTAL_IRQ_PATH "/dev/fsl-usdpaa-irq"
53 #define BMAN_CCSR_MAP "/dev/mem"
55 /* This mask contains all the "irqsource" bits visible to API users */
56 #define BM_PIRQ_VISIBLE (BM_PIRQ_RCRI | BM_PIRQ_BSCN)
58 /* These are bm_<reg>_<verb>(). So for example, bm_disable_write() means "write
59 * the disable register" rather than "disable the ability to write".
61 #define bm_isr_status_read(bm) __bm_isr_read(bm, bm_isr_status)
62 #define bm_isr_status_clear(bm, m) __bm_isr_write(bm, bm_isr_status, m)
63 #define bm_isr_enable_read(bm) __bm_isr_read(bm, bm_isr_enable)
64 #define bm_isr_enable_write(bm, v) __bm_isr_write(bm, bm_isr_enable, v)
65 #define bm_isr_disable_read(bm) __bm_isr_read(bm, bm_isr_disable)
66 #define bm_isr_disable_write(bm, v) __bm_isr_write(bm, bm_isr_disable, v)
67 #define bm_isr_inhibit(bm) __bm_isr_write(bm, bm_isr_inhibit, 1)
68 #define bm_isr_uninhibit(bm) __bm_isr_write(bm, bm_isr_inhibit, 0)
71 * Global variables of the max portal/pool number this bman version supported
73 extern u16 bman_pool_max;
75 /* used by CCSR and portal interrupt code */
83 struct bm_portal_config {
85 * Corenet portal addresses;
86 * [0]==cache-enabled, [1]==cache-inhibited.
88 void __iomem *addr_virt[2];
89 /* Allow these to be joined in lists */
90 struct list_head list;
91 /* User-visible portal configuration settings */
92 /* This is used for any "core-affine" portals, ie. default portals
93 * associated to the corresponding cpu. -1 implies that there is no
94 * core affinity configured.
97 /* portal interrupt line */
99 /* the unique index of this portal */
101 /* Is this portal shared? (If so, it has coarser locking and demuxes
102 * processing on behalf of other CPUs.).
105 /* These are the buffer pool IDs that may be used via this portal. */
106 struct bman_depletion mask;
110 int bman_init_ccsr(const struct device_node *node);
112 struct bman_portal *bman_create_affine_portal(
113 const struct bm_portal_config *config);
114 const struct bm_portal_config *bman_destroy_affine_portal(void);
116 /* Set depletion thresholds associated with a buffer pool. Requires that the
117 * operating system have access to Bman CCSR (ie. compiled in support and
118 * run-time access courtesy of the device-tree).
120 int bm_pool_set(u32 bpid, const u32 *thresholds);
122 /* Read the free buffer count for a given buffer */
123 u32 bm_pool_free_buffers(u32 bpid);
125 #endif /* __BMAN_PRIV_H */