1*4882a593Smuzhiyun /* Copyright 2008 - 2016 Freescale Semiconductor, Inc. 2*4882a593Smuzhiyun * 3*4882a593Smuzhiyun * Redistribution and use in source and binary forms, with or without 4*4882a593Smuzhiyun * modification, are permitted provided that the following conditions are met: 5*4882a593Smuzhiyun * * Redistributions of source code must retain the above copyright 6*4882a593Smuzhiyun * notice, this list of conditions and the following disclaimer. 7*4882a593Smuzhiyun * * Redistributions in binary form must reproduce the above copyright 8*4882a593Smuzhiyun * notice, this list of conditions and the following disclaimer in the 9*4882a593Smuzhiyun * documentation and/or other materials provided with the distribution. 10*4882a593Smuzhiyun * * Neither the name of Freescale Semiconductor nor the 11*4882a593Smuzhiyun * names of its contributors may be used to endorse or promote products 12*4882a593Smuzhiyun * derived from this software without specific prior written permission. 13*4882a593Smuzhiyun * 14*4882a593Smuzhiyun * ALTERNATIVELY, this software may be distributed under the terms of the 15*4882a593Smuzhiyun * GNU General Public License ("GPL") as published by the Free Software 16*4882a593Smuzhiyun * Foundation, either version 2 of that License or (at your option) any 17*4882a593Smuzhiyun * later version. 18*4882a593Smuzhiyun * 19*4882a593Smuzhiyun * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY 20*4882a593Smuzhiyun * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21*4882a593Smuzhiyun * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22*4882a593Smuzhiyun * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY 23*4882a593Smuzhiyun * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24*4882a593Smuzhiyun * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25*4882a593Smuzhiyun * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26*4882a593Smuzhiyun * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27*4882a593Smuzhiyun * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28*4882a593Smuzhiyun * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29*4882a593Smuzhiyun */ 30*4882a593Smuzhiyun 31*4882a593Smuzhiyun #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 32*4882a593Smuzhiyun 33*4882a593Smuzhiyun #include "dpaa_sys.h" 34*4882a593Smuzhiyun 35*4882a593Smuzhiyun #include <soc/fsl/bman.h> 36*4882a593Smuzhiyun 37*4882a593Smuzhiyun /* Portal processing (interrupt) sources */ 38*4882a593Smuzhiyun #define BM_PIRQ_RCRI 0x00000002 /* RCR Ring (below threshold) */ 39*4882a593Smuzhiyun 40*4882a593Smuzhiyun /* Revision info (for errata and feature handling) */ 41*4882a593Smuzhiyun #define BMAN_REV10 0x0100 42*4882a593Smuzhiyun #define BMAN_REV20 0x0200 43*4882a593Smuzhiyun #define BMAN_REV21 0x0201 44*4882a593Smuzhiyun extern u16 bman_ip_rev; /* 0 if uninitialised, otherwise BMAN_REVx */ 45*4882a593Smuzhiyun 46*4882a593Smuzhiyun extern struct gen_pool *bm_bpalloc; 47*4882a593Smuzhiyun 48*4882a593Smuzhiyun struct bm_portal_config { 49*4882a593Smuzhiyun /* Portal addresses */ 50*4882a593Smuzhiyun void *addr_virt_ce; 51*4882a593Smuzhiyun void __iomem *addr_virt_ci; 52*4882a593Smuzhiyun /* Allow these to be joined in lists */ 53*4882a593Smuzhiyun struct list_head list; 54*4882a593Smuzhiyun struct device *dev; 55*4882a593Smuzhiyun /* User-visible portal configuration settings */ 56*4882a593Smuzhiyun /* portal is affined to this cpu */ 57*4882a593Smuzhiyun int cpu; 58*4882a593Smuzhiyun /* portal interrupt line */ 59*4882a593Smuzhiyun int irq; 60*4882a593Smuzhiyun }; 61*4882a593Smuzhiyun 62*4882a593Smuzhiyun struct bman_portal *bman_create_affine_portal( 63*4882a593Smuzhiyun const struct bm_portal_config *config); 64*4882a593Smuzhiyun /* 65*4882a593Smuzhiyun * The below bman_p_***() variant might be called in a situation that the cpu 66*4882a593Smuzhiyun * which the portal affine to is not online yet. 67*4882a593Smuzhiyun * @bman_portal specifies which portal the API will use. 68*4882a593Smuzhiyun */ 69*4882a593Smuzhiyun int bman_p_irqsource_add(struct bman_portal *p, u32 bits); 70*4882a593Smuzhiyun 71*4882a593Smuzhiyun /* 72*4882a593Smuzhiyun * Used by all portal interrupt registers except 'inhibit' 73*4882a593Smuzhiyun * This mask contains all the "irqsource" bits visible to API users 74*4882a593Smuzhiyun */ 75*4882a593Smuzhiyun #define BM_PIRQ_VISIBLE BM_PIRQ_RCRI 76*4882a593Smuzhiyun 77*4882a593Smuzhiyun const struct bm_portal_config * 78*4882a593Smuzhiyun bman_get_bm_portal_config(const struct bman_portal *portal); 79*4882a593Smuzhiyun 80*4882a593Smuzhiyun int bman_requires_cleanup(void); 81*4882a593Smuzhiyun void bman_done_cleanup(void); 82*4882a593Smuzhiyun 83*4882a593Smuzhiyun int bm_shutdown_pool(u32 bpid); 84