|
| 1 | +/* |
| 2 | + * Copyright (c) 2021 Intel Corporation. |
| 3 | + * |
| 4 | + * SPDX-License-Identifier: Apache-2.0 |
| 5 | + */ |
| 6 | + |
| 7 | +#ifndef ZEPHYR_DRIVERS_PCIE_HOST_VC_H_ |
| 8 | +#define ZEPHYR_DRIVERS_PCIE_HOST_VC_H_ |
| 9 | + |
| 10 | +#define PCIE_VC_MAX_COUNT 8 |
| 11 | + |
| 12 | +#define PCIE_VC_CAP_REG_1_OFFSET 0x04U |
| 13 | +#define PCIE_VC_CAP_REG_2_OFFSET 0x08U |
| 14 | +#define PCIE_VC_CTRL_STATUS_REG_OFFSET 0x0CU |
| 15 | + |
| 16 | +/** Virtual Channel capability and control Registers */ |
| 17 | +struct pcie_vc_regs { |
| 18 | + union { |
| 19 | + struct { |
| 20 | + /** Virtual Channel Count */ |
| 21 | + uint32_t vc_count : 3; |
| 22 | + uint32_t _reserved1 : 1; |
| 23 | + /** Low Priority Virtual Channel Count */ |
| 24 | + uint32_t lpvc_count : 3; |
| 25 | + uint32_t _reserved2 : 1; |
| 26 | + /** Reference Clock */ |
| 27 | + uint32_t reference_clock : 2; |
| 28 | + /** Port Arbitration Table Entry Size */ |
| 29 | + uint32_t pat_entry_size : 3; |
| 30 | + uint32_t _reserved3 : 19; |
| 31 | + }; |
| 32 | + uint32_t raw; |
| 33 | + } cap_reg_1; |
| 34 | + |
| 35 | + union { |
| 36 | + struct { |
| 37 | + /** Virtual Channel Arbitration Capability */ |
| 38 | + uint32_t vca_cap : 8; |
| 39 | + uint32_t _reserved1 : 16; |
| 40 | + /** Virtual Channel Arbitration Table Offset */ |
| 41 | + uint32_t vca_table_offset : 8; |
| 42 | + }; |
| 43 | + uint32_t raw; |
| 44 | + } cap_reg_2; |
| 45 | + |
| 46 | + union { |
| 47 | + struct { |
| 48 | + /** Load Virtual Channel Arbitration Table */ |
| 49 | + uint32_t load_vca_table : 1; |
| 50 | + /** Virtual Channel Arbitration Select */ |
| 51 | + uint32_t vca_select : 3; |
| 52 | + uint32_t _reserved1 : 12; |
| 53 | + /** Virtual Channel Arbitration Table Status */ |
| 54 | + uint32_t vca_table_status : 1; |
| 55 | + uint32_t _reserved2 : 15; |
| 56 | + }; |
| 57 | + uint32_t raw; |
| 58 | + } ctrl_reg; |
| 59 | +}; |
| 60 | + |
| 61 | +#define PCIE_VC_RES_CAP_REG_OFFSET(_vc) (0x10U + _vc * 0X0CU) |
| 62 | +#define PCIE_VC_RES_CTRL_REG_OFFSET(_vc) (0x14U + _vc * 0X0CU) |
| 63 | +#define PCIE_VC_RES_STATUS_REG_OFFSET(_vc) (0x18U + _vc * 0X0CU) |
| 64 | + |
| 65 | +/** Virtual Channel Resource Registers */ |
| 66 | +struct pcie_vc_resource_regs { |
| 67 | + union { |
| 68 | + struct { |
| 69 | + /** Port Arbitration Capability */ |
| 70 | + uint32_t pa_cap : 8; |
| 71 | + uint32_t _reserved1 : 6; |
| 72 | + uint32_t undefined : 1; |
| 73 | + /** Reject Snoop Transactions */ |
| 74 | + uint32_t rst : 1; |
| 75 | + /** Maximum Time Slots */ |
| 76 | + uint32_t max_time_slots : 7; |
| 77 | + uint32_t _reserved2 : 1; |
| 78 | + /** Port Arbitration Table Offset */ |
| 79 | + uint32_t pa_table_offset : 8; |
| 80 | + }; |
| 81 | + uint32_t raw; |
| 82 | + } cap_reg; |
| 83 | + |
| 84 | + union { |
| 85 | + struct { |
| 86 | + /** Traffic Class to Virtual Channel Map */ |
| 87 | + uint32_t tc_vc_map : 8; |
| 88 | + uint32_t _reserved1 : 8; |
| 89 | + /** Load Port Arbitration Table */ |
| 90 | + uint32_t load_pa_table : 1; |
| 91 | + /** Port Arbitration Select */ |
| 92 | + uint32_t pa_select : 3; |
| 93 | + uint32_t _reserved2 : 4; |
| 94 | + /** Virtual Channel ID */ |
| 95 | + uint32_t vc_id : 3; |
| 96 | + uint32_t _reserved3 : 4; |
| 97 | + /** Virtual Channel Enable */ |
| 98 | + uint32_t vc_enable : 1; |
| 99 | + }; |
| 100 | + uint32_t raw; |
| 101 | + } ctrl_reg; |
| 102 | + |
| 103 | + union { |
| 104 | + struct { |
| 105 | + uint32_t _reserved1 : 16; |
| 106 | + /** Port Arbitration Table Status */ |
| 107 | + uint32_t pa_table_status : 1; |
| 108 | + /** Virtual Channel Negociation Pending */ |
| 109 | + uint32_t vc_negocation_pending : 1; |
| 110 | + uint32_t _reserved2 : 14; |
| 111 | + }; |
| 112 | + uint32_t raw; |
| 113 | + } status_reg; |
| 114 | +}; |
| 115 | + |
| 116 | +uint32_t pcie_vc_cap_lookup(pcie_bdf_t bdf, struct pcie_vc_regs *regs); |
| 117 | + |
| 118 | +void pcie_vc_load_resources_regs(pcie_bdf_t bdf, |
| 119 | + uint32_t base, |
| 120 | + struct pcie_vc_resource_regs *regs, |
| 121 | + int nb_regs); |
| 122 | + |
| 123 | +#endif /* ZEPHYR_DRIVERS_PCIE_HOST_VC_H_ */ |
0 commit comments