blob: 5be50a17ab8e10818e7044ad89e8f15cc33b7eed [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>
11
12struct 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
Laurentiu Tudordcb7f3d2018-08-09 15:19:48 +030020struct fman_icid_id_table {
21 u32 port_id;
22 u32 icid;
23};
24
Laurentiu Tudor512d13e2018-08-09 15:19:46 +030025u32 get_ppid_icid(int ppid_tbl_idx, int ppid);
26int fdt_get_smmu_phandle(void *blob);
27int fdt_set_iommu_prop(void *blob, int off, int smmu_ph, u32 *ids, int num_ids);
28void set_icids(void);
29void fdt_fixup_icid(void *blob);
30
31#define SET_ICID_ENTRY(name, idA, regA, addr, compataddr) \
32 { .compat = name, \
33 .id = idA, \
34 .reg = regA, \
35 .compat_addr = compataddr, \
36 .reg_addr = addr, \
37 }
38
39#define SET_SCFG_ICID(compat, streamid, name, compataddr) \
40 SET_ICID_ENTRY(compat, streamid, (((streamid) << 24) | (1 << 23)), \
41 offsetof(struct ccsr_scfg, name) + CONFIG_SYS_FSL_SCFG_ADDR, \
42 compataddr)
43
44#define SET_USB_ICID(usb_num, compat, streamid) \
45 SET_SCFG_ICID(compat, streamid, usb##usb_num##_icid,\
46 CONFIG_SYS_XHCI_USB##usb_num##_ADDR)
47
48#define SET_SATA_ICID(compat, streamid) \
49 SET_SCFG_ICID(compat, streamid, sata_icid,\
50 AHCI_BASE_ADDR)
51
52#define SET_SDHC_ICID(streamid) \
53 SET_SCFG_ICID("fsl,esdhc", streamid, sdhc_icid,\
54 CONFIG_SYS_FSL_ESDHC_ADDR)
55
56#define SET_QDMA_ICID(compat, streamid) \
57 SET_SCFG_ICID(compat, streamid, dma_icid,\
58 QDMA_BASE_ADDR)
59
60#define SET_EDMA_ICID(streamid) \
61 SET_SCFG_ICID("fsl,vf610-edma", streamid, edma_icid,\
62 EDMA_BASE_ADDR)
63
64#define SET_ETR_ICID(streamid) \
65 SET_SCFG_ICID(NULL, streamid, etr_icid, 0)
66
67#define SET_DEBUG_ICID(streamid) \
68 SET_SCFG_ICID(NULL, streamid, debug_icid, 0)
69
70#define SET_QMAN_ICID(streamid) \
71 SET_ICID_ENTRY("fsl,qman", streamid, streamid, \
72 offsetof(struct ccsr_qman, liodnr) + \
73 CONFIG_SYS_FSL_QMAN_ADDR, \
74 CONFIG_SYS_FSL_QMAN_ADDR)
75
76#define SET_BMAN_ICID(streamid) \
77 SET_ICID_ENTRY("fsl,bman", streamid, streamid, \
78 offsetof(struct ccsr_bman, liodnr) + \
79 CONFIG_SYS_FSL_BMAN_ADDR, \
80 CONFIG_SYS_FSL_BMAN_ADDR)
81
Laurentiu Tudordcb7f3d2018-08-09 15:19:48 +030082#define SET_FMAN_ICID_ENTRY(_port_id, streamid) \
83 { .port_id = (_port_id), .icid = (streamid) }
84
Laurentiu Tudor512d13e2018-08-09 15:19:46 +030085extern struct icid_id_table icid_tbl[];
Laurentiu Tudordcb7f3d2018-08-09 15:19:48 +030086extern struct fman_icid_id_table fman_icid_tbl[];
Laurentiu Tudor512d13e2018-08-09 15:19:46 +030087extern int icid_tbl_sz;
Laurentiu Tudordcb7f3d2018-08-09 15:19:48 +030088extern int fman_icid_tbl_sz;
Laurentiu Tudor512d13e2018-08-09 15:19:46 +030089
90#endif