armv8: ls1046a: initial icid setup support
[platform/kernel/u-boot.git] / arch / arm / include / asm / arch-fsl-layerscape / fsl_icid.h
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * Copyright 2018 NXP
4  */
5
6 #ifndef _FSL_ICID_H_
7 #define _FSL_ICID_H_
8
9 #include <asm/types.h>
10 #include <fsl_qbman.h>
11
12 struct icid_id_table {
13         const char *compat;
14         u32 id;
15         u32 reg;
16         phys_addr_t compat_addr;
17         phys_addr_t reg_addr;
18 };
19
20 u32 get_ppid_icid(int ppid_tbl_idx, int ppid);
21 int fdt_get_smmu_phandle(void *blob);
22 int fdt_set_iommu_prop(void *blob, int off, int smmu_ph, u32 *ids, int num_ids);
23 void set_icids(void);
24 void fdt_fixup_icid(void *blob);
25
26 #define SET_ICID_ENTRY(name, idA, regA, addr, compataddr) \
27         { .compat = name, \
28           .id = idA, \
29           .reg = regA, \
30           .compat_addr = compataddr, \
31           .reg_addr = addr, \
32         }
33
34 #define SET_SCFG_ICID(compat, streamid, name, compataddr) \
35         SET_ICID_ENTRY(compat, streamid, (((streamid) << 24) | (1 << 23)), \
36                 offsetof(struct ccsr_scfg, name) + CONFIG_SYS_FSL_SCFG_ADDR, \
37                 compataddr)
38
39 #define SET_USB_ICID(usb_num, compat, streamid) \
40         SET_SCFG_ICID(compat, streamid, usb##usb_num##_icid,\
41                 CONFIG_SYS_XHCI_USB##usb_num##_ADDR)
42
43 #define SET_SATA_ICID(compat, streamid) \
44         SET_SCFG_ICID(compat, streamid, sata_icid,\
45                 AHCI_BASE_ADDR)
46
47 #define SET_SDHC_ICID(streamid) \
48         SET_SCFG_ICID("fsl,esdhc", streamid, sdhc_icid,\
49                 CONFIG_SYS_FSL_ESDHC_ADDR)
50
51 #define SET_QDMA_ICID(compat, streamid) \
52         SET_SCFG_ICID(compat, streamid, dma_icid,\
53                 QDMA_BASE_ADDR)
54
55 #define SET_EDMA_ICID(streamid) \
56         SET_SCFG_ICID("fsl,vf610-edma", streamid, edma_icid,\
57                 EDMA_BASE_ADDR)
58
59 #define SET_ETR_ICID(streamid) \
60         SET_SCFG_ICID(NULL, streamid, etr_icid, 0)
61
62 #define SET_DEBUG_ICID(streamid) \
63         SET_SCFG_ICID(NULL, streamid, debug_icid, 0)
64
65 #define SET_QMAN_ICID(streamid) \
66         SET_ICID_ENTRY("fsl,qman", streamid, streamid, \
67                 offsetof(struct ccsr_qman, liodnr) + \
68                 CONFIG_SYS_FSL_QMAN_ADDR, \
69                 CONFIG_SYS_FSL_QMAN_ADDR)
70
71 #define SET_BMAN_ICID(streamid) \
72         SET_ICID_ENTRY("fsl,bman", streamid, streamid, \
73                 offsetof(struct ccsr_bman, liodnr) + \
74                 CONFIG_SYS_FSL_BMAN_ADDR, \
75                 CONFIG_SYS_FSL_BMAN_ADDR)
76
77 extern struct icid_id_table icid_tbl[];
78 extern int icid_tbl_sz;
79
80 #endif