blob: e7a880126265512924a7fb0aa00cea2881cfc218 [file] [log] [blame]
Laurentiu Tudor512d13e2018-08-09 15:19:46 +03001/* 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>
Laurentiu Tudor3987b042018-08-09 15:19:49 +030011#include <fsl_sec.h>
Laurentiu Tudor512d13e2018-08-09 15:19:46 +030012
13struct icid_id_table {
14 const char *compat;
15 u32 id;
16 u32 reg;
17 phys_addr_t compat_addr;
18 phys_addr_t reg_addr;
19};
20
Laurentiu Tudordcb7f3d2018-08-09 15:19:48 +030021struct fman_icid_id_table {
22 u32 port_id;
23 u32 icid;
24};
25
Laurentiu Tudor512d13e2018-08-09 15:19:46 +030026u32 get_ppid_icid(int ppid_tbl_idx, int ppid);
27int fdt_get_smmu_phandle(void *blob);
28int fdt_set_iommu_prop(void *blob, int off, int smmu_ph, u32 *ids, int num_ids);
29void set_icids(void);
30void fdt_fixup_icid(void *blob);
31
32#define SET_ICID_ENTRY(name, idA, regA, addr, compataddr) \
33 { .compat = name, \
34 .id = idA, \
35 .reg = regA, \
36 .compat_addr = compataddr, \
37 .reg_addr = addr, \
38 }
39
40#define SET_SCFG_ICID(compat, streamid, name, compataddr) \
41 SET_ICID_ENTRY(compat, streamid, (((streamid) << 24) | (1 << 23)), \
42 offsetof(struct ccsr_scfg, name) + CONFIG_SYS_FSL_SCFG_ADDR, \
43 compataddr)
44
45#define SET_USB_ICID(usb_num, compat, streamid) \
46 SET_SCFG_ICID(compat, streamid, usb##usb_num##_icid,\
47 CONFIG_SYS_XHCI_USB##usb_num##_ADDR)
48
49#define SET_SATA_ICID(compat, streamid) \
50 SET_SCFG_ICID(compat, streamid, sata_icid,\
51 AHCI_BASE_ADDR)
52
53#define SET_SDHC_ICID(streamid) \
54 SET_SCFG_ICID("fsl,esdhc", streamid, sdhc_icid,\
55 CONFIG_SYS_FSL_ESDHC_ADDR)
56
57#define SET_QDMA_ICID(compat, streamid) \
Laurentiu Tudore03b4852018-12-12 13:45:51 +020058 SET_ICID_ENTRY(compat, streamid, (1 << 31) | (streamid), \
59 QDMA_BASE_ADDR + QMAN_CQSIDR_REG, \
60 QDMA_BASE_ADDR), \
61 SET_ICID_ENTRY(NULL, streamid, (1 << 31) | (streamid), \
62 QDMA_BASE_ADDR + QMAN_CQSIDR_REG + 4, \
Laurentiu Tudor512d13e2018-08-09 15:19:46 +030063 QDMA_BASE_ADDR)
64
65#define SET_EDMA_ICID(streamid) \
66 SET_SCFG_ICID("fsl,vf610-edma", streamid, edma_icid,\
67 EDMA_BASE_ADDR)
68
69#define SET_ETR_ICID(streamid) \
70 SET_SCFG_ICID(NULL, streamid, etr_icid, 0)
71
72#define SET_DEBUG_ICID(streamid) \
73 SET_SCFG_ICID(NULL, streamid, debug_icid, 0)
74
Laurentiu Tudor22012d52018-08-27 17:33:59 +030075#define SET_QE_ICID(streamid) \
76 SET_SCFG_ICID("fsl,qe", streamid, qe_icid,\
77 QE_BASE_ADDR)
78
Laurentiu Tudor512d13e2018-08-09 15:19:46 +030079#define SET_QMAN_ICID(streamid) \
80 SET_ICID_ENTRY("fsl,qman", streamid, streamid, \
81 offsetof(struct ccsr_qman, liodnr) + \
82 CONFIG_SYS_FSL_QMAN_ADDR, \
83 CONFIG_SYS_FSL_QMAN_ADDR)
84
85#define SET_BMAN_ICID(streamid) \
86 SET_ICID_ENTRY("fsl,bman", streamid, streamid, \
87 offsetof(struct ccsr_bman, liodnr) + \
88 CONFIG_SYS_FSL_BMAN_ADDR, \
89 CONFIG_SYS_FSL_BMAN_ADDR)
90
Laurentiu Tudordcb7f3d2018-08-09 15:19:48 +030091#define SET_FMAN_ICID_ENTRY(_port_id, streamid) \
92 { .port_id = (_port_id), .icid = (streamid) }
93
Laurentiu Tudor3987b042018-08-09 15:19:49 +030094#define SET_SEC_QI_ICID(streamid) \
95 SET_ICID_ENTRY("fsl,sec-v4.0", streamid, \
Laurentiu Tudor8aee3d62019-02-26 13:18:33 +020096 0, offsetof(ccsr_sec_t, qilcr_ls) + \
Laurentiu Tudor3987b042018-08-09 15:19:49 +030097 CONFIG_SYS_FSL_SEC_ADDR, \
98 CONFIG_SYS_FSL_SEC_ADDR)
99
100#define SET_SEC_JR_ICID_ENTRY(jr_num, streamid) \
101 SET_ICID_ENTRY("fsl,sec-v4.0-job-ring", streamid, \
102 (((streamid) << 16) | (streamid)), \
103 offsetof(ccsr_sec_t, jrliodnr[jr_num].ls) + \
104 CONFIG_SYS_FSL_SEC_ADDR, \
105 FSL_SEC_JR##jr_num##_BASE_ADDR)
106
107#define SET_SEC_DECO_ICID_ENTRY(deco_num, streamid) \
108 SET_ICID_ENTRY(NULL, streamid, (((streamid) << 16) | (streamid)), \
109 offsetof(ccsr_sec_t, decoliodnr[deco_num].ls) + \
110 CONFIG_SYS_FSL_SEC_ADDR, 0)
111
112#define SET_SEC_RTIC_ICID_ENTRY(rtic_num, streamid) \
113 SET_ICID_ENTRY(NULL, streamid, (((streamid) << 16) | (streamid)), \
114 offsetof(ccsr_sec_t, rticliodnr[rtic_num].ls) + \
115 CONFIG_SYS_FSL_SEC_ADDR, 0)
116
Laurentiu Tudor512d13e2018-08-09 15:19:46 +0300117extern struct icid_id_table icid_tbl[];
Laurentiu Tudordcb7f3d2018-08-09 15:19:48 +0300118extern struct fman_icid_id_table fman_icid_tbl[];
Laurentiu Tudor512d13e2018-08-09 15:19:46 +0300119extern int icid_tbl_sz;
Laurentiu Tudordcb7f3d2018-08-09 15:19:48 +0300120extern int fman_icid_tbl_sz;
Laurentiu Tudor512d13e2018-08-09 15:19:46 +0300121
122#endif