18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * This file is part of the Chelsio FCoE driver for Linux.
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Copyright (c) 2008-2013 Chelsio Communications, Inc. All rights reserved.
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * This software is available to you under a choice of one of two
78c2ecf20Sopenharmony_ci * licenses.  You may choose to be licensed under the terms of the GNU
88c2ecf20Sopenharmony_ci * General Public License (GPL) Version 2, available from the file
98c2ecf20Sopenharmony_ci * OpenIB.org BSD license below:
108c2ecf20Sopenharmony_ci *
118c2ecf20Sopenharmony_ci *     Redistribution and use in source and binary forms, with or
128c2ecf20Sopenharmony_ci *     without modification, are permitted provided that the following
138c2ecf20Sopenharmony_ci *     conditions are met:
148c2ecf20Sopenharmony_ci *
158c2ecf20Sopenharmony_ci *      - Redistributions of source code must retain the above
168c2ecf20Sopenharmony_ci *        copyright notice, this list of conditions and the following
178c2ecf20Sopenharmony_ci *        disclaimer.
188c2ecf20Sopenharmony_ci *
198c2ecf20Sopenharmony_ci *      - Redistributions in binary form must reproduce the above
208c2ecf20Sopenharmony_ci *        copyright notice, this list of conditions and the following
218c2ecf20Sopenharmony_ci *        disclaimer in the documentation and/or other materials
228c2ecf20Sopenharmony_ci *        provided with the distribution.
238c2ecf20Sopenharmony_ci *
248c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
258c2ecf20Sopenharmony_ci * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
268c2ecf20Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
278c2ecf20Sopenharmony_ci * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
288c2ecf20Sopenharmony_ci * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
298c2ecf20Sopenharmony_ci * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
308c2ecf20Sopenharmony_ci * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
318c2ecf20Sopenharmony_ci * SOFTWARE.
328c2ecf20Sopenharmony_ci */
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci#ifndef __CSIO_HW_CHIP_H__
358c2ecf20Sopenharmony_ci#define __CSIO_HW_CHIP_H__
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ci#include "csio_defs.h"
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci/* Define MACRO values */
408c2ecf20Sopenharmony_ci#define CSIO_HW_T5				0x5000
418c2ecf20Sopenharmony_ci#define CSIO_T5_FCOE_ASIC			0x5600
428c2ecf20Sopenharmony_ci#define CSIO_HW_T6				0x6000
438c2ecf20Sopenharmony_ci#define CSIO_T6_FCOE_ASIC			0x6600
448c2ecf20Sopenharmony_ci#define CSIO_HW_CHIP_MASK			0xF000
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ci#define T5_REGMAP_SIZE				(332 * 1024)
478c2ecf20Sopenharmony_ci#define FW_FNAME_T5				"cxgb4/t5fw.bin"
488c2ecf20Sopenharmony_ci#define FW_CFG_NAME_T5				"cxgb4/t5-config.txt"
498c2ecf20Sopenharmony_ci#define FW_FNAME_T6				"cxgb4/t6fw.bin"
508c2ecf20Sopenharmony_ci#define FW_CFG_NAME_T6				"cxgb4/t6-config.txt"
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci#define CHELSIO_CHIP_CODE(version, revision) (((version) << 4) | (revision))
538c2ecf20Sopenharmony_ci#define CHELSIO_CHIP_FPGA          0x100
548c2ecf20Sopenharmony_ci#define CHELSIO_CHIP_VERSION(code) (((code) >> 12) & 0xf)
558c2ecf20Sopenharmony_ci#define CHELSIO_CHIP_RELEASE(code) ((code) & 0xf)
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci#define CHELSIO_T5		0x5
588c2ecf20Sopenharmony_ci#define CHELSIO_T6		0x6
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_cienum chip_type {
618c2ecf20Sopenharmony_ci	T5_A0 = CHELSIO_CHIP_CODE(CHELSIO_T5, 0),
628c2ecf20Sopenharmony_ci	T5_A1 = CHELSIO_CHIP_CODE(CHELSIO_T5, 1),
638c2ecf20Sopenharmony_ci	T5_FIRST_REV	= T5_A0,
648c2ecf20Sopenharmony_ci	T5_LAST_REV	= T5_A1,
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ci	T6_A0 = CHELSIO_CHIP_CODE(CHELSIO_T6, 0),
678c2ecf20Sopenharmony_ci	T6_FIRST_REV    = T6_A0,
688c2ecf20Sopenharmony_ci	T6_LAST_REV     = T6_A0,
698c2ecf20Sopenharmony_ci};
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_cistatic inline int csio_is_t5(uint16_t chip)
728c2ecf20Sopenharmony_ci{
738c2ecf20Sopenharmony_ci	return (chip == CSIO_HW_T5);
748c2ecf20Sopenharmony_ci}
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_cistatic inline int csio_is_t6(uint16_t chip)
778c2ecf20Sopenharmony_ci{
788c2ecf20Sopenharmony_ci	return (chip == CSIO_HW_T6);
798c2ecf20Sopenharmony_ci}
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_ci/* Define MACRO DEFINITIONS */
828c2ecf20Sopenharmony_ci#define CSIO_DEVICE(devid, idx)						\
838c2ecf20Sopenharmony_ci	{ PCI_VENDOR_ID_CHELSIO, (devid), PCI_ANY_ID, PCI_ANY_ID, 0, 0, (idx) }
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_ci#include "t4fw_api.h"
868c2ecf20Sopenharmony_ci#include "t4fw_version.h"
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_ci#define FW_VERSION(chip) ( \
898c2ecf20Sopenharmony_ci		FW_HDR_FW_VER_MAJOR_G(chip##FW_VERSION_MAJOR) | \
908c2ecf20Sopenharmony_ci		FW_HDR_FW_VER_MINOR_G(chip##FW_VERSION_MINOR) | \
918c2ecf20Sopenharmony_ci		FW_HDR_FW_VER_MICRO_G(chip##FW_VERSION_MICRO) | \
928c2ecf20Sopenharmony_ci		FW_HDR_FW_VER_BUILD_G(chip##FW_VERSION_BUILD))
938c2ecf20Sopenharmony_ci#define FW_INTFVER(chip, intf) (FW_HDR_INTFVER_##intf)
948c2ecf20Sopenharmony_ci
958c2ecf20Sopenharmony_cistruct fw_info {
968c2ecf20Sopenharmony_ci	u8 chip;
978c2ecf20Sopenharmony_ci	char *fs_name;
988c2ecf20Sopenharmony_ci	char *fw_mod_name;
998c2ecf20Sopenharmony_ci	struct fw_hdr fw_hdr;
1008c2ecf20Sopenharmony_ci};
1018c2ecf20Sopenharmony_ci
1028c2ecf20Sopenharmony_ci/* Declare ENUMS */
1038c2ecf20Sopenharmony_cienum { MEM_EDC0, MEM_EDC1, MEM_MC, MEM_MC0 = MEM_MC, MEM_MC1 };
1048c2ecf20Sopenharmony_ci
1058c2ecf20Sopenharmony_cienum {
1068c2ecf20Sopenharmony_ci	MEMWIN_APERTURE = 2048,
1078c2ecf20Sopenharmony_ci	MEMWIN_BASE     = 0x1b800,
1088c2ecf20Sopenharmony_ci};
1098c2ecf20Sopenharmony_ci
1108c2ecf20Sopenharmony_ci/* Slow path handlers */
1118c2ecf20Sopenharmony_cistruct intr_info {
1128c2ecf20Sopenharmony_ci	unsigned int mask;       /* bits to check in interrupt status */
1138c2ecf20Sopenharmony_ci	const char *msg;         /* message to print or NULL */
1148c2ecf20Sopenharmony_ci	short stat_idx;          /* stat counter to increment or -1 */
1158c2ecf20Sopenharmony_ci	unsigned short fatal;    /* whether the condition reported is fatal */
1168c2ecf20Sopenharmony_ci};
1178c2ecf20Sopenharmony_ci
1188c2ecf20Sopenharmony_ci/* T4/T5 Chip specific ops */
1198c2ecf20Sopenharmony_cistruct csio_hw;
1208c2ecf20Sopenharmony_cistruct csio_hw_chip_ops {
1218c2ecf20Sopenharmony_ci	int (*chip_set_mem_win)(struct csio_hw *, uint32_t);
1228c2ecf20Sopenharmony_ci	void (*chip_pcie_intr_handler)(struct csio_hw *);
1238c2ecf20Sopenharmony_ci	uint32_t (*chip_flash_cfg_addr)(struct csio_hw *);
1248c2ecf20Sopenharmony_ci	int (*chip_mc_read)(struct csio_hw *, int, uint32_t,
1258c2ecf20Sopenharmony_ci					__be32 *, uint64_t *);
1268c2ecf20Sopenharmony_ci	int (*chip_edc_read)(struct csio_hw *, int, uint32_t,
1278c2ecf20Sopenharmony_ci					__be32 *, uint64_t *);
1288c2ecf20Sopenharmony_ci	int (*chip_memory_rw)(struct csio_hw *, u32, int, u32,
1298c2ecf20Sopenharmony_ci					u32, uint32_t *, int);
1308c2ecf20Sopenharmony_ci	void (*chip_dfs_create_ext_mem)(struct csio_hw *);
1318c2ecf20Sopenharmony_ci};
1328c2ecf20Sopenharmony_ci
1338c2ecf20Sopenharmony_ciextern struct csio_hw_chip_ops t5_ops;
1348c2ecf20Sopenharmony_ci
1358c2ecf20Sopenharmony_ci#endif /* #ifndef __CSIO_HW_CHIP_H__ */
136