162306a36Sopenharmony_ci/* 262306a36Sopenharmony_ci * This file is provided under a dual BSD/GPLv2 license. When using or 362306a36Sopenharmony_ci * redistributing this file, you may do so under either license. 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * GPL LICENSE SUMMARY 662306a36Sopenharmony_ci * 762306a36Sopenharmony_ci * Copyright(c) 2012-2017 Intel Corporation. All rights reserved. 862306a36Sopenharmony_ci * 962306a36Sopenharmony_ci * This program is free software; you can redistribute it and/or modify 1062306a36Sopenharmony_ci * it under the terms of version 2 of the GNU General Public License as 1162306a36Sopenharmony_ci * published by the Free Software Foundation. 1262306a36Sopenharmony_ci * 1362306a36Sopenharmony_ci * BSD LICENSE 1462306a36Sopenharmony_ci * 1562306a36Sopenharmony_ci * Copyright(c) 2012-2017 Intel Corporation. All rights reserved. 1662306a36Sopenharmony_ci * 1762306a36Sopenharmony_ci * Redistribution and use in source and binary forms, with or without 1862306a36Sopenharmony_ci * modification, are permitted provided that the following conditions 1962306a36Sopenharmony_ci * are met: 2062306a36Sopenharmony_ci * 2162306a36Sopenharmony_ci * * Redistributions of source code must retain the above copyright 2262306a36Sopenharmony_ci * notice, this list of conditions and the following disclaimer. 2362306a36Sopenharmony_ci * * Redistributions in binary form must reproduce the above copy 2462306a36Sopenharmony_ci * notice, this list of conditions and the following disclaimer in 2562306a36Sopenharmony_ci * the documentation and/or other materials provided with the 2662306a36Sopenharmony_ci * distribution. 2762306a36Sopenharmony_ci * * Neither the name of Intel Corporation nor the names of its 2862306a36Sopenharmony_ci * contributors may be used to endorse or promote products derived 2962306a36Sopenharmony_ci * from this software without specific prior written permission. 3062306a36Sopenharmony_ci * 3162306a36Sopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 3262306a36Sopenharmony_ci * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 3362306a36Sopenharmony_ci * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 3462306a36Sopenharmony_ci * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 3562306a36Sopenharmony_ci * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 3662306a36Sopenharmony_ci * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 3762306a36Sopenharmony_ci * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 3862306a36Sopenharmony_ci * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 3962306a36Sopenharmony_ci * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 4062306a36Sopenharmony_ci * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 4162306a36Sopenharmony_ci * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 4262306a36Sopenharmony_ci */ 4362306a36Sopenharmony_ci 4462306a36Sopenharmony_ci#ifndef _NTB_INTEL_GEN1_H_ 4562306a36Sopenharmony_ci#define _NTB_INTEL_GEN1_H_ 4662306a36Sopenharmony_ci 4762306a36Sopenharmony_ci#include "ntb_hw_intel.h" 4862306a36Sopenharmony_ci 4962306a36Sopenharmony_ci/* Intel Gen1 Xeon hardware */ 5062306a36Sopenharmony_ci#define XEON_PBAR23LMT_OFFSET 0x0000 5162306a36Sopenharmony_ci#define XEON_PBAR45LMT_OFFSET 0x0008 5262306a36Sopenharmony_ci#define XEON_PBAR4LMT_OFFSET 0x0008 5362306a36Sopenharmony_ci#define XEON_PBAR5LMT_OFFSET 0x000c 5462306a36Sopenharmony_ci#define XEON_PBAR23XLAT_OFFSET 0x0010 5562306a36Sopenharmony_ci#define XEON_PBAR45XLAT_OFFSET 0x0018 5662306a36Sopenharmony_ci#define XEON_PBAR4XLAT_OFFSET 0x0018 5762306a36Sopenharmony_ci#define XEON_PBAR5XLAT_OFFSET 0x001c 5862306a36Sopenharmony_ci#define XEON_SBAR23LMT_OFFSET 0x0020 5962306a36Sopenharmony_ci#define XEON_SBAR45LMT_OFFSET 0x0028 6062306a36Sopenharmony_ci#define XEON_SBAR4LMT_OFFSET 0x0028 6162306a36Sopenharmony_ci#define XEON_SBAR5LMT_OFFSET 0x002c 6262306a36Sopenharmony_ci#define XEON_SBAR23XLAT_OFFSET 0x0030 6362306a36Sopenharmony_ci#define XEON_SBAR45XLAT_OFFSET 0x0038 6462306a36Sopenharmony_ci#define XEON_SBAR4XLAT_OFFSET 0x0038 6562306a36Sopenharmony_ci#define XEON_SBAR5XLAT_OFFSET 0x003c 6662306a36Sopenharmony_ci#define XEON_SBAR0BASE_OFFSET 0x0040 6762306a36Sopenharmony_ci#define XEON_SBAR23BASE_OFFSET 0x0048 6862306a36Sopenharmony_ci#define XEON_SBAR45BASE_OFFSET 0x0050 6962306a36Sopenharmony_ci#define XEON_SBAR4BASE_OFFSET 0x0050 7062306a36Sopenharmony_ci#define XEON_SBAR5BASE_OFFSET 0x0054 7162306a36Sopenharmony_ci#define XEON_SBDF_OFFSET 0x005c 7262306a36Sopenharmony_ci#define XEON_NTBCNTL_OFFSET 0x0058 7362306a36Sopenharmony_ci#define XEON_PDOORBELL_OFFSET 0x0060 7462306a36Sopenharmony_ci#define XEON_PDBMSK_OFFSET 0x0062 7562306a36Sopenharmony_ci#define XEON_SDOORBELL_OFFSET 0x0064 7662306a36Sopenharmony_ci#define XEON_SDBMSK_OFFSET 0x0066 7762306a36Sopenharmony_ci#define XEON_USMEMMISS_OFFSET 0x0070 7862306a36Sopenharmony_ci#define XEON_SPAD_OFFSET 0x0080 7962306a36Sopenharmony_ci#define XEON_PBAR23SZ_OFFSET 0x00d0 8062306a36Sopenharmony_ci#define XEON_PBAR45SZ_OFFSET 0x00d1 8162306a36Sopenharmony_ci#define XEON_PBAR4SZ_OFFSET 0x00d1 8262306a36Sopenharmony_ci#define XEON_SBAR23SZ_OFFSET 0x00d2 8362306a36Sopenharmony_ci#define XEON_SBAR45SZ_OFFSET 0x00d3 8462306a36Sopenharmony_ci#define XEON_SBAR4SZ_OFFSET 0x00d3 8562306a36Sopenharmony_ci#define XEON_PPD_OFFSET 0x00d4 8662306a36Sopenharmony_ci#define XEON_PBAR5SZ_OFFSET 0x00d5 8762306a36Sopenharmony_ci#define XEON_SBAR5SZ_OFFSET 0x00d6 8862306a36Sopenharmony_ci#define XEON_WCCNTRL_OFFSET 0x00e0 8962306a36Sopenharmony_ci#define XEON_UNCERRSTS_OFFSET 0x014c 9062306a36Sopenharmony_ci#define XEON_CORERRSTS_OFFSET 0x0158 9162306a36Sopenharmony_ci#define XEON_LINK_STATUS_OFFSET 0x01a2 9262306a36Sopenharmony_ci#define XEON_SPCICMD_OFFSET 0x0504 9362306a36Sopenharmony_ci#define XEON_DEVCTRL_OFFSET 0x0598 9462306a36Sopenharmony_ci#define XEON_DEVSTS_OFFSET 0x059a 9562306a36Sopenharmony_ci#define XEON_SLINK_STATUS_OFFSET 0x05a2 9662306a36Sopenharmony_ci#define XEON_B2B_SPAD_OFFSET 0x0100 9762306a36Sopenharmony_ci#define XEON_B2B_DOORBELL_OFFSET 0x0140 9862306a36Sopenharmony_ci#define XEON_B2B_XLAT_OFFSETL 0x0144 9962306a36Sopenharmony_ci#define XEON_B2B_XLAT_OFFSETU 0x0148 10062306a36Sopenharmony_ci#define XEON_PPD_CONN_MASK 0x03 10162306a36Sopenharmony_ci#define XEON_PPD_CONN_TRANSPARENT 0x00 10262306a36Sopenharmony_ci#define XEON_PPD_CONN_B2B 0x01 10362306a36Sopenharmony_ci#define XEON_PPD_CONN_RP 0x02 10462306a36Sopenharmony_ci#define XEON_PPD_DEV_MASK 0x10 10562306a36Sopenharmony_ci#define XEON_PPD_DEV_USD 0x00 10662306a36Sopenharmony_ci#define XEON_PPD_DEV_DSD 0x10 10762306a36Sopenharmony_ci#define XEON_PPD_SPLIT_BAR_MASK 0x40 10862306a36Sopenharmony_ci 10962306a36Sopenharmony_ci#define XEON_PPD_TOPO_MASK (XEON_PPD_CONN_MASK | XEON_PPD_DEV_MASK) 11062306a36Sopenharmony_ci#define XEON_PPD_TOPO_PRI_USD (XEON_PPD_CONN_RP | XEON_PPD_DEV_USD) 11162306a36Sopenharmony_ci#define XEON_PPD_TOPO_PRI_DSD (XEON_PPD_CONN_RP | XEON_PPD_DEV_DSD) 11262306a36Sopenharmony_ci#define XEON_PPD_TOPO_SEC_USD (XEON_PPD_CONN_TRANSPARENT | XEON_PPD_DEV_USD) 11362306a36Sopenharmony_ci#define XEON_PPD_TOPO_SEC_DSD (XEON_PPD_CONN_TRANSPARENT | XEON_PPD_DEV_DSD) 11462306a36Sopenharmony_ci#define XEON_PPD_TOPO_B2B_USD (XEON_PPD_CONN_B2B | XEON_PPD_DEV_USD) 11562306a36Sopenharmony_ci#define XEON_PPD_TOPO_B2B_DSD (XEON_PPD_CONN_B2B | XEON_PPD_DEV_DSD) 11662306a36Sopenharmony_ci 11762306a36Sopenharmony_ci#define XEON_MW_COUNT 2 11862306a36Sopenharmony_ci#define HSX_SPLIT_BAR_MW_COUNT 3 11962306a36Sopenharmony_ci#define XEON_DB_COUNT 15 12062306a36Sopenharmony_ci#define XEON_DB_LINK 15 12162306a36Sopenharmony_ci#define XEON_DB_LINK_BIT BIT_ULL(XEON_DB_LINK) 12262306a36Sopenharmony_ci#define XEON_DB_MSIX_VECTOR_COUNT 4 12362306a36Sopenharmony_ci#define XEON_DB_MSIX_VECTOR_SHIFT 5 12462306a36Sopenharmony_ci#define XEON_DB_TOTAL_SHIFT 16 12562306a36Sopenharmony_ci#define XEON_SPAD_COUNT 16 12662306a36Sopenharmony_ci 12762306a36Sopenharmony_ci/* Use the following addresses for translation between b2b ntb devices in case 12862306a36Sopenharmony_ci * the hardware default values are not reliable. */ 12962306a36Sopenharmony_ci#define XEON_B2B_BAR0_ADDR 0x1000000000000000ull 13062306a36Sopenharmony_ci#define XEON_B2B_BAR2_ADDR64 0x2000000000000000ull 13162306a36Sopenharmony_ci#define XEON_B2B_BAR4_ADDR64 0x4000000000000000ull 13262306a36Sopenharmony_ci#define XEON_B2B_BAR4_ADDR32 0x20000000u 13362306a36Sopenharmony_ci#define XEON_B2B_BAR5_ADDR32 0x40000000u 13462306a36Sopenharmony_ci 13562306a36Sopenharmony_ci/* The peer ntb secondary config space is 32KB fixed size */ 13662306a36Sopenharmony_ci#define XEON_B2B_MIN_SIZE 0x8000 13762306a36Sopenharmony_ci 13862306a36Sopenharmony_ci/* flags to indicate hardware errata */ 13962306a36Sopenharmony_ci#define NTB_HWERR_SDOORBELL_LOCKUP BIT_ULL(0) 14062306a36Sopenharmony_ci#define NTB_HWERR_SB01BASE_LOCKUP BIT_ULL(1) 14162306a36Sopenharmony_ci#define NTB_HWERR_B2BDOORBELL_BIT14 BIT_ULL(2) 14262306a36Sopenharmony_ci#define NTB_HWERR_MSIX_VECTOR32_BAD BIT_ULL(3) 14362306a36Sopenharmony_ci#define NTB_HWERR_BAR_ALIGN BIT_ULL(4) 14462306a36Sopenharmony_ci#define NTB_HWERR_LTR_BAD BIT_ULL(5) 14562306a36Sopenharmony_ci 14662306a36Sopenharmony_ciextern struct intel_b2b_addr xeon_b2b_usd_addr; 14762306a36Sopenharmony_ciextern struct intel_b2b_addr xeon_b2b_dsd_addr; 14862306a36Sopenharmony_ci 14962306a36Sopenharmony_ciint ndev_init_isr(struct intel_ntb_dev *ndev, int msix_min, int msix_max, 15062306a36Sopenharmony_ci int msix_shift, int total_shift); 15162306a36Sopenharmony_cienum ntb_topo xeon_ppd_topo(struct intel_ntb_dev *ndev, u8 ppd); 15262306a36Sopenharmony_civoid ndev_db_addr(struct intel_ntb_dev *ndev, 15362306a36Sopenharmony_ci phys_addr_t *db_addr, resource_size_t *db_size, 15462306a36Sopenharmony_ci phys_addr_t reg_addr, unsigned long reg); 15562306a36Sopenharmony_ciu64 ndev_db_read(struct intel_ntb_dev *ndev, void __iomem *mmio); 15662306a36Sopenharmony_ciint ndev_db_write(struct intel_ntb_dev *ndev, u64 db_bits, 15762306a36Sopenharmony_ci void __iomem *mmio); 15862306a36Sopenharmony_ciint ndev_mw_to_bar(struct intel_ntb_dev *ndev, int idx); 15962306a36Sopenharmony_ciint intel_ntb_mw_count(struct ntb_dev *ntb, int pidx); 16062306a36Sopenharmony_ciint intel_ntb_mw_get_align(struct ntb_dev *ntb, int pidx, int idx, 16162306a36Sopenharmony_ci resource_size_t *addr_align, resource_size_t *size_align, 16262306a36Sopenharmony_ci resource_size_t *size_max); 16362306a36Sopenharmony_ciint intel_ntb_peer_mw_count(struct ntb_dev *ntb); 16462306a36Sopenharmony_ciint intel_ntb_peer_mw_get_addr(struct ntb_dev *ntb, int idx, 16562306a36Sopenharmony_ci phys_addr_t *base, resource_size_t *size); 16662306a36Sopenharmony_ciu64 intel_ntb_link_is_up(struct ntb_dev *ntb, enum ntb_speed *speed, 16762306a36Sopenharmony_ci enum ntb_width *width); 16862306a36Sopenharmony_ciint intel_ntb_link_disable(struct ntb_dev *ntb); 16962306a36Sopenharmony_ciu64 intel_ntb_db_valid_mask(struct ntb_dev *ntb); 17062306a36Sopenharmony_ciint intel_ntb_db_vector_count(struct ntb_dev *ntb); 17162306a36Sopenharmony_ciu64 intel_ntb_db_vector_mask(struct ntb_dev *ntb, int db_vector); 17262306a36Sopenharmony_ciint intel_ntb_db_set_mask(struct ntb_dev *ntb, u64 db_bits); 17362306a36Sopenharmony_ciint intel_ntb_db_clear_mask(struct ntb_dev *ntb, u64 db_bits); 17462306a36Sopenharmony_ciint intel_ntb_spad_is_unsafe(struct ntb_dev *ntb); 17562306a36Sopenharmony_ciint intel_ntb_spad_count(struct ntb_dev *ntb); 17662306a36Sopenharmony_ciu32 intel_ntb_spad_read(struct ntb_dev *ntb, int idx); 17762306a36Sopenharmony_ciint intel_ntb_spad_write(struct ntb_dev *ntb, int idx, u32 val); 17862306a36Sopenharmony_ciu32 intel_ntb_peer_spad_read(struct ntb_dev *ntb, int pidx, int sidx); 17962306a36Sopenharmony_ciint intel_ntb_peer_spad_write(struct ntb_dev *ntb, int pidx, int sidx, 18062306a36Sopenharmony_ci u32 val); 18162306a36Sopenharmony_ciint intel_ntb_peer_spad_addr(struct ntb_dev *ntb, int pidx, int sidx, 18262306a36Sopenharmony_ci phys_addr_t *spad_addr); 18362306a36Sopenharmony_ciint xeon_link_is_up(struct intel_ntb_dev *ndev); 18462306a36Sopenharmony_ci 18562306a36Sopenharmony_ci#endif 186