1 /*
2  * Copyright 2014 Freescale Semiconductor, Inc.
3  *
4  * SPDX-License-Identifier:	GPL-2.0+
5  *
6  */
7 #ifndef __FSL_STREAM_ID_H
8 #define __FSL_STREAM_ID_H
9 
10 /*
11  * Stream IDs on NXP Chassis-3 (for example ls2080a, ls1088a, ls2088a)
12  * devices are not hardwired and are programmed by sw. There are a limited
13  * number of stream IDs available, and the partitioning of them is scenario
14  * dependent. This header defines the partitioning between legacy,
15  * PCI, and DPAA2 devices.
16  *
17  * This partitioning can be customized in this file depending
18  * on the specific hardware config:
19  *
20  *  -non-PCI legacy, platform devices (USB, SD/MMC, SATA, DMA)
21  *     -all legacy devices get a unique stream ID assigned and programmed in
22  *      their AMQR registers by u-boot
23  *
24  *  -PCIe
25  *     -there is a range of stream IDs set aside for PCI in this
26  *      file.  U-boot will scan the PCI bus and for each device discovered:
27  *         -allocate a streamID
28  *         -set a PEXn LUT table entry mapping 'requester ID' to 'stream ID'
29  *         -set a msi-map entry in the PEXn controller node in the
30  *          device tree (see Documentation/devicetree/bindings/pci/pci-msi.txt
31  *          for more info on the msi-map definition)
32  *         -set a iommu-map entry in the PEXn controller node in the
33  *          device tree (see Documentation/devicetree/bindings/pci/pci-iommu.txt
34  *          for more info on the iommu-map definition)
35  *
36  *  -DPAA2
37  *     -u-boot will allocate a range of stream IDs to be used by the Management
38  *      Complex for containers and will set these values in the MC DPC image.
39  *     -the MC is responsible for allocating and setting up 'isolation context
40  *      IDs (ICIDs) based on the allocated stream IDs for all DPAA2 devices.
41  *
42  * On Chasis-3 SoCs stream IDs are programmed in AMQ registers (32-bits) for
43  * each of the different bus masters.  The relationship between
44  * the AMQ registers and stream IDs is defined in the table below:
45  *          AMQ bit    streamID bit
46  *      ---------------------------
47  *           PL[18]         9        // privilege bit
48  *          BMT[17]         8        // bypass translation
49  *           VA[16]         7        // reserved
50  *             [15]         -        // unused
51  *         ICID[14:7]       -        // unused
52  *         ICID[6:0]        6-0      // isolation context id
53  *     ----------------------------
54  *
55  */
56 
57 #define AMQ_PL_MASK			(0x1 << 18)   /* priviledge bit */
58 #define AMQ_BMT_MASK			(0x1 << 17)   /* bypass bit */
59 
60 #define FSL_INVALID_STREAM_ID		0
61 
62 #define FSL_BYPASS_AMQ			(AMQ_PL_MASK | AMQ_BMT_MASK)
63 
64 /* legacy devices */
65 #define FSL_USB1_STREAM_ID		1
66 #define FSL_USB2_STREAM_ID		2
67 #define FSL_SDMMC_STREAM_ID		3
68 #define FSL_SATA1_STREAM_ID		4
69 #define FSL_SATA2_STREAM_ID		5
70 #define FSL_DMA_STREAM_ID		6
71 
72 /* PCI - programmed in PEXn_LUT */
73 #define FSL_PEX_STREAM_ID_START		7
74 #define FSL_PEX_STREAM_ID_END		22
75 
76 /* DPAA2 - set in MC DPC and alloced by MC */
77 #define FSL_DPAA2_STREAM_ID_START	23
78 #define FSL_DPAA2_STREAM_ID_END		63
79 
80 #endif
81