xref: /rk3399_rockchip-uboot/include/fsl-mc/fsl_qbman_base.h (revision b939689c7b87773c44275a578ffc8674a867e39d)
1*a2a55e51SPrabhakar Kushwaha /*
2*a2a55e51SPrabhakar Kushwaha  * Copyright (C) 2014 Freescale Semiconductor
3*a2a55e51SPrabhakar Kushwaha  *
4*a2a55e51SPrabhakar Kushwaha  * SPDX-License-Identifier:	GPL-2.0+
5*a2a55e51SPrabhakar Kushwaha  */
6*a2a55e51SPrabhakar Kushwaha 
7*a2a55e51SPrabhakar Kushwaha #ifndef _FSL_QBMAN_BASE_H
8*a2a55e51SPrabhakar Kushwaha #define _FSL_QBMAN_BASE_H
9*a2a55e51SPrabhakar Kushwaha 
10*a2a55e51SPrabhakar Kushwaha /* Descriptor for a QBMan instance on the SoC. On partitions/targets that do not
11*a2a55e51SPrabhakar Kushwaha  * control this QBMan instance, these values may simply be place-holders. The
12*a2a55e51SPrabhakar Kushwaha  * idea is simply that we be able to distinguish between them, eg. so that SWP
13*a2a55e51SPrabhakar Kushwaha  * descriptors can identify which QBMan instance they belong to. */
14*a2a55e51SPrabhakar Kushwaha struct qbman_block_desc {
15*a2a55e51SPrabhakar Kushwaha 	void *ccsr_reg_bar; /* CCSR register map */
16*a2a55e51SPrabhakar Kushwaha 	int irq_rerr;  /* Recoverable error interrupt line */
17*a2a55e51SPrabhakar Kushwaha 	int irq_nrerr; /* Non-recoverable error interrupt line */
18*a2a55e51SPrabhakar Kushwaha };
19*a2a55e51SPrabhakar Kushwaha 
20*a2a55e51SPrabhakar Kushwaha /* Descriptor for a QBMan software portal, expressed in terms that make sense to
21*a2a55e51SPrabhakar Kushwaha  * the user context. Ie. on MC, this information is likely to be true-physical,
22*a2a55e51SPrabhakar Kushwaha  * and instantiated statically at compile-time. On GPP, this information is
23*a2a55e51SPrabhakar Kushwaha  * likely to be obtained via "discovery" over a partition's "layerscape bus"
24*a2a55e51SPrabhakar Kushwaha  * (ie. in response to a MC portal command), and would take into account any
25*a2a55e51SPrabhakar Kushwaha  * virtualisation of the GPP user's address space and/or interrupt numbering. */
26*a2a55e51SPrabhakar Kushwaha struct qbman_swp_desc {
27*a2a55e51SPrabhakar Kushwaha 	const struct qbman_block_desc *block; /* The QBMan instance */
28*a2a55e51SPrabhakar Kushwaha 	void *cena_bar; /* Cache-enabled portal register map */
29*a2a55e51SPrabhakar Kushwaha 	void *cinh_bar; /* Cache-inhibited portal register map */
30*a2a55e51SPrabhakar Kushwaha };
31*a2a55e51SPrabhakar Kushwaha 
32*a2a55e51SPrabhakar Kushwaha /* Driver object for managing a QBMan portal */
33*a2a55e51SPrabhakar Kushwaha struct qbman_swp;
34*a2a55e51SPrabhakar Kushwaha 
35*a2a55e51SPrabhakar Kushwaha /* Place-holder for FDs, we represent it via the simplest form that we need for
36*a2a55e51SPrabhakar Kushwaha  * now. Different overlays may be needed to support different options, etc. (It
37*a2a55e51SPrabhakar Kushwaha  * is impractical to define One True Struct, because the resulting encoding
38*a2a55e51SPrabhakar Kushwaha  * routines (lots of read-modify-writes) would be worst-case performance whether
39*a2a55e51SPrabhakar Kushwaha  * or not circumstances required them.)
40*a2a55e51SPrabhakar Kushwaha  *
41*a2a55e51SPrabhakar Kushwaha  * Note, as with all data-structures exchanged between software and hardware (be
42*a2a55e51SPrabhakar Kushwaha  * they located in the portal register map or DMA'd to and from main-memory),
43*a2a55e51SPrabhakar Kushwaha  * the driver ensures that the caller of the driver API sees the data-structures
44*a2a55e51SPrabhakar Kushwaha  * in host-endianness. "struct qbman_fd" is no exception. The 32-bit words
45*a2a55e51SPrabhakar Kushwaha  * contained within this structure are represented in host-endianness, even if
46*a2a55e51SPrabhakar Kushwaha  * hardware always treats them as little-endian. As such, if any of these fields
47*a2a55e51SPrabhakar Kushwaha  * are interpreted in a binary (rather than numerical) fashion by hardware
48*a2a55e51SPrabhakar Kushwaha  * blocks (eg. accelerators), then the user should be careful. We illustrate
49*a2a55e51SPrabhakar Kushwaha  * with an example;
50*a2a55e51SPrabhakar Kushwaha  *
51*a2a55e51SPrabhakar Kushwaha  * Suppose the desired behaviour of an accelerator is controlled by the "frc"
52*a2a55e51SPrabhakar Kushwaha  * field of the FDs that are sent to it. Suppose also that the behaviour desired
53*a2a55e51SPrabhakar Kushwaha  * by the user corresponds to an "frc" value which is expressed as the literal
54*a2a55e51SPrabhakar Kushwaha  * sequence of bytes 0xfe, 0xed, 0xab, and 0xba. So "frc" should be the 32-bit
55*a2a55e51SPrabhakar Kushwaha  * value in which 0xfe is the first byte and 0xba is the last byte, and as
56*a2a55e51SPrabhakar Kushwaha  * hardware is little-endian, this amounts to a 32-bit "value" of 0xbaabedfe. If
57*a2a55e51SPrabhakar Kushwaha  * the software is little-endian also, this can simply be achieved by setting
58*a2a55e51SPrabhakar Kushwaha  * frc=0xbaabedfe. On the other hand, if software is big-endian, it should set
59*a2a55e51SPrabhakar Kushwaha  * frc=0xfeedabba! The best away of avoiding trouble with this sort of thing is
60*a2a55e51SPrabhakar Kushwaha  * to treat the 32-bit words as numerical values, in which the offset of a field
61*a2a55e51SPrabhakar Kushwaha  * from the beginning of the first byte (as required or generated by hardware)
62*a2a55e51SPrabhakar Kushwaha  * is numerically encoded by a left-shift (ie. by raising the field to a
63*a2a55e51SPrabhakar Kushwaha  * corresponding power of 2).  Ie. in the current example, software could set
64*a2a55e51SPrabhakar Kushwaha  * "frc" in the following way, and it would work correctly on both little-endian
65*a2a55e51SPrabhakar Kushwaha  * and big-endian operation;
66*a2a55e51SPrabhakar Kushwaha  *    fd.frc = (0xfe << 0) | (0xed << 8) | (0xab << 16) | (0xba << 24);
67*a2a55e51SPrabhakar Kushwaha  */
68*a2a55e51SPrabhakar Kushwaha struct qbman_fd {
69*a2a55e51SPrabhakar Kushwaha 	union {
70*a2a55e51SPrabhakar Kushwaha 		uint32_t words[8];
71*a2a55e51SPrabhakar Kushwaha 		struct qbman_fd_simple {
72*a2a55e51SPrabhakar Kushwaha 			uint32_t addr_lo;
73*a2a55e51SPrabhakar Kushwaha 			uint32_t addr_hi;
74*a2a55e51SPrabhakar Kushwaha 			uint32_t len;
75*a2a55e51SPrabhakar Kushwaha 			/* offset in the MS 16 bits, BPID in the LS 16 bits */
76*a2a55e51SPrabhakar Kushwaha 			uint32_t bpid_offset;
77*a2a55e51SPrabhakar Kushwaha 			uint32_t frc; /* frame context */
78*a2a55e51SPrabhakar Kushwaha 			/* "err", "va", "cbmt", "asal", [...] */
79*a2a55e51SPrabhakar Kushwaha 			uint32_t ctrl;
80*a2a55e51SPrabhakar Kushwaha 			/* flow context */
81*a2a55e51SPrabhakar Kushwaha 			uint32_t flc_lo;
82*a2a55e51SPrabhakar Kushwaha 			uint32_t flc_hi;
83*a2a55e51SPrabhakar Kushwaha 		} simple;
84*a2a55e51SPrabhakar Kushwaha 	};
85*a2a55e51SPrabhakar Kushwaha };
86*a2a55e51SPrabhakar Kushwaha 
87*a2a55e51SPrabhakar Kushwaha #endif /* !_FSL_QBMAN_BASE_H */
88