18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * PMC-Sierra 8001/8081/8088/8089 SAS/SATA based host adapters driver
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Copyright (c) 2008-2009 USI Co., Ltd.
58c2ecf20Sopenharmony_ci * All rights reserved.
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci * Redistribution and use in source and binary forms, with or without
88c2ecf20Sopenharmony_ci * modification, are permitted provided that the following conditions
98c2ecf20Sopenharmony_ci * are met:
108c2ecf20Sopenharmony_ci * 1. Redistributions of source code must retain the above copyright
118c2ecf20Sopenharmony_ci *    notice, this list of conditions, and the following disclaimer,
128c2ecf20Sopenharmony_ci *    without modification.
138c2ecf20Sopenharmony_ci * 2. Redistributions in binary form must reproduce at minimum a disclaimer
148c2ecf20Sopenharmony_ci *    substantially similar to the "NO WARRANTY" disclaimer below
158c2ecf20Sopenharmony_ci *    ("Disclaimer") and any redistribution must be conditioned upon
168c2ecf20Sopenharmony_ci *    including a substantially similar Disclaimer requirement for further
178c2ecf20Sopenharmony_ci *    binary redistribution.
188c2ecf20Sopenharmony_ci * 3. Neither the names of the above-listed copyright holders nor the names
198c2ecf20Sopenharmony_ci *    of any contributors may be used to endorse or promote products derived
208c2ecf20Sopenharmony_ci *    from this software without specific prior written permission.
218c2ecf20Sopenharmony_ci *
228c2ecf20Sopenharmony_ci * Alternatively, this software may be distributed under the terms of the
238c2ecf20Sopenharmony_ci * GNU General Public License ("GPL") version 2 as published by the Free
248c2ecf20Sopenharmony_ci * Software Foundation.
258c2ecf20Sopenharmony_ci *
268c2ecf20Sopenharmony_ci * NO WARRANTY
278c2ecf20Sopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
288c2ecf20Sopenharmony_ci * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
298c2ecf20Sopenharmony_ci * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
308c2ecf20Sopenharmony_ci * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
318c2ecf20Sopenharmony_ci * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
328c2ecf20Sopenharmony_ci * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
338c2ecf20Sopenharmony_ci * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
348c2ecf20Sopenharmony_ci * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
358c2ecf20Sopenharmony_ci * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
368c2ecf20Sopenharmony_ci * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
378c2ecf20Sopenharmony_ci * POSSIBILITY OF SUCH DAMAGES.
388c2ecf20Sopenharmony_ci *
398c2ecf20Sopenharmony_ci */
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ci#ifndef _PM8001_DEFS_H_
428c2ecf20Sopenharmony_ci#define _PM8001_DEFS_H_
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_cienum chip_flavors {
458c2ecf20Sopenharmony_ci	chip_8001,
468c2ecf20Sopenharmony_ci	chip_8008,
478c2ecf20Sopenharmony_ci	chip_8009,
488c2ecf20Sopenharmony_ci	chip_8018,
498c2ecf20Sopenharmony_ci	chip_8019,
508c2ecf20Sopenharmony_ci	chip_8074,
518c2ecf20Sopenharmony_ci	chip_8076,
528c2ecf20Sopenharmony_ci	chip_8077,
538c2ecf20Sopenharmony_ci	chip_8006,
548c2ecf20Sopenharmony_ci	chip_8070,
558c2ecf20Sopenharmony_ci	chip_8072
568c2ecf20Sopenharmony_ci};
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_cienum phy_speed {
598c2ecf20Sopenharmony_ci	PHY_SPEED_15 = 0x01,
608c2ecf20Sopenharmony_ci	PHY_SPEED_30 = 0x02,
618c2ecf20Sopenharmony_ci	PHY_SPEED_60 = 0x04,
628c2ecf20Sopenharmony_ci	PHY_SPEED_120 = 0x08,
638c2ecf20Sopenharmony_ci};
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_cienum data_direction {
668c2ecf20Sopenharmony_ci	DATA_DIR_NONE = 0x0,	/* NO TRANSFER */
678c2ecf20Sopenharmony_ci	DATA_DIR_IN = 0x01,	/* INBOUND */
688c2ecf20Sopenharmony_ci	DATA_DIR_OUT = 0x02,	/* OUTBOUND */
698c2ecf20Sopenharmony_ci	DATA_DIR_BYRECIPIENT = 0x04, /* UNSPECIFIED */
708c2ecf20Sopenharmony_ci};
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_cienum port_type {
738c2ecf20Sopenharmony_ci	PORT_TYPE_SAS = (1L << 1),
748c2ecf20Sopenharmony_ci	PORT_TYPE_SATA = (1L << 0),
758c2ecf20Sopenharmony_ci};
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ci/* driver compile-time configuration */
788c2ecf20Sopenharmony_ci#define	PM8001_MAX_CCB		 1024	/* max ccbs supported */
798c2ecf20Sopenharmony_ci#define PM8001_MPI_QUEUE         1024   /* maximum mpi queue entries */
808c2ecf20Sopenharmony_ci#define	PM8001_MAX_INB_NUM	 64
818c2ecf20Sopenharmony_ci#define	PM8001_MAX_OUTB_NUM	 64
828c2ecf20Sopenharmony_ci#define	PM8001_CAN_QUEUE	 508	/* SCSI Queue depth */
838c2ecf20Sopenharmony_ci
848c2ecf20Sopenharmony_ci/* Inbound/Outbound queue size */
858c2ecf20Sopenharmony_ci#define IOMB_SIZE_SPC		64
868c2ecf20Sopenharmony_ci#define IOMB_SIZE_SPCV		128
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_ci/* unchangeable hardware details */
898c2ecf20Sopenharmony_ci#define	PM8001_MAX_PHYS		 16	/* max. possible phys */
908c2ecf20Sopenharmony_ci#define	PM8001_MAX_PORTS	 16	/* max. possible ports */
918c2ecf20Sopenharmony_ci#define	PM8001_MAX_DEVICES	 2048	/* max supported device */
928c2ecf20Sopenharmony_ci#define	PM8001_MAX_MSIX_VEC	 64	/* max msi-x int for spcv/ve */
938c2ecf20Sopenharmony_ci#define	PM8001_RESERVE_SLOT	 8
948c2ecf20Sopenharmony_ci
958c2ecf20Sopenharmony_ci#define	CONFIG_SCSI_PM8001_MAX_DMA_SG	528
968c2ecf20Sopenharmony_ci#define PM8001_MAX_DMA_SG	CONFIG_SCSI_PM8001_MAX_DMA_SG
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_cienum memory_region_num {
998c2ecf20Sopenharmony_ci	AAP1 = 0x0, /* application acceleration processor */
1008c2ecf20Sopenharmony_ci	IOP,	    /* IO processor */
1018c2ecf20Sopenharmony_ci	NVMD,	    /* NVM device */
1028c2ecf20Sopenharmony_ci	FW_FLASH,    /* memory for fw flash update */
1038c2ecf20Sopenharmony_ci	FORENSIC_MEM,  /* memory for fw forensic data */
1048c2ecf20Sopenharmony_ci	USI_MAX_MEMCNT_BASE
1058c2ecf20Sopenharmony_ci};
1068c2ecf20Sopenharmony_ci#define	PM8001_EVENT_LOG_SIZE	 (128 * 1024)
1078c2ecf20Sopenharmony_ci
1088c2ecf20Sopenharmony_ci/**
1098c2ecf20Sopenharmony_ci * maximum DMA memory regions(number of IBQ + number of IBQ CI
1108c2ecf20Sopenharmony_ci * + number of  OBQ + number of OBQ PI)
1118c2ecf20Sopenharmony_ci */
1128c2ecf20Sopenharmony_ci#define USI_MAX_MEMCNT	(USI_MAX_MEMCNT_BASE + ((2 * PM8001_MAX_INB_NUM) \
1138c2ecf20Sopenharmony_ci			+ (2 * PM8001_MAX_OUTB_NUM)))
1148c2ecf20Sopenharmony_ci/*error code*/
1158c2ecf20Sopenharmony_cienum mpi_err {
1168c2ecf20Sopenharmony_ci	MPI_IO_STATUS_SUCCESS = 0x0,
1178c2ecf20Sopenharmony_ci	MPI_IO_STATUS_BUSY = 0x01,
1188c2ecf20Sopenharmony_ci	MPI_IO_STATUS_FAIL = 0x02,
1198c2ecf20Sopenharmony_ci};
1208c2ecf20Sopenharmony_ci
1218c2ecf20Sopenharmony_ci/**
1228c2ecf20Sopenharmony_ci * Phy Control constants
1238c2ecf20Sopenharmony_ci */
1248c2ecf20Sopenharmony_cienum phy_control_type {
1258c2ecf20Sopenharmony_ci	PHY_LINK_RESET = 0x01,
1268c2ecf20Sopenharmony_ci	PHY_HARD_RESET = 0x02,
1278c2ecf20Sopenharmony_ci	PHY_NOTIFY_ENABLE_SPINUP = 0x10,
1288c2ecf20Sopenharmony_ci};
1298c2ecf20Sopenharmony_ci
1308c2ecf20Sopenharmony_cienum pm8001_hba_info_flags {
1318c2ecf20Sopenharmony_ci	PM8001F_INIT_TIME	= (1U << 0),
1328c2ecf20Sopenharmony_ci	PM8001F_RUN_TIME	= (1U << 1),
1338c2ecf20Sopenharmony_ci};
1348c2ecf20Sopenharmony_ci
1358c2ecf20Sopenharmony_ci/**
1368c2ecf20Sopenharmony_ci * Phy Status
1378c2ecf20Sopenharmony_ci */
1388c2ecf20Sopenharmony_ci#define PHY_LINK_DISABLE	0x00
1398c2ecf20Sopenharmony_ci#define PHY_LINK_DOWN		0x01
1408c2ecf20Sopenharmony_ci#define PHY_STATE_LINK_UP_SPCV	0x2
1418c2ecf20Sopenharmony_ci#define PHY_STATE_LINK_UP_SPC	0x1
1428c2ecf20Sopenharmony_ci
1438c2ecf20Sopenharmony_ci#endif
144