162306a36Sopenharmony_ci/*
262306a36Sopenharmony_ci * PMC-Sierra 8001/8081/8088/8089 SAS/SATA based host adapters driver
362306a36Sopenharmony_ci *
462306a36Sopenharmony_ci * Copyright (c) 2008-2009 USI Co., Ltd.
562306a36Sopenharmony_ci * All rights reserved.
662306a36Sopenharmony_ci *
762306a36Sopenharmony_ci * Redistribution and use in source and binary forms, with or without
862306a36Sopenharmony_ci * modification, are permitted provided that the following conditions
962306a36Sopenharmony_ci * are met:
1062306a36Sopenharmony_ci * 1. Redistributions of source code must retain the above copyright
1162306a36Sopenharmony_ci *    notice, this list of conditions, and the following disclaimer,
1262306a36Sopenharmony_ci *    without modification.
1362306a36Sopenharmony_ci * 2. Redistributions in binary form must reproduce at minimum a disclaimer
1462306a36Sopenharmony_ci *    substantially similar to the "NO WARRANTY" disclaimer below
1562306a36Sopenharmony_ci *    ("Disclaimer") and any redistribution must be conditioned upon
1662306a36Sopenharmony_ci *    including a substantially similar Disclaimer requirement for further
1762306a36Sopenharmony_ci *    binary redistribution.
1862306a36Sopenharmony_ci * 3. Neither the names of the above-listed copyright holders nor the names
1962306a36Sopenharmony_ci *    of any contributors may be used to endorse or promote products derived
2062306a36Sopenharmony_ci *    from this software without specific prior written permission.
2162306a36Sopenharmony_ci *
2262306a36Sopenharmony_ci * Alternatively, this software may be distributed under the terms of the
2362306a36Sopenharmony_ci * GNU General Public License ("GPL") version 2 as published by the Free
2462306a36Sopenharmony_ci * Software Foundation.
2562306a36Sopenharmony_ci *
2662306a36Sopenharmony_ci * NO WARRANTY
2762306a36Sopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2862306a36Sopenharmony_ci * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2962306a36Sopenharmony_ci * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
3062306a36Sopenharmony_ci * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
3162306a36Sopenharmony_ci * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3262306a36Sopenharmony_ci * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3362306a36Sopenharmony_ci * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3462306a36Sopenharmony_ci * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
3562306a36Sopenharmony_ci * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
3662306a36Sopenharmony_ci * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3762306a36Sopenharmony_ci * POSSIBILITY OF SUCH DAMAGES.
3862306a36Sopenharmony_ci *
3962306a36Sopenharmony_ci */
4062306a36Sopenharmony_ci
4162306a36Sopenharmony_ci#ifndef _PM8001_DEFS_H_
4262306a36Sopenharmony_ci#define _PM8001_DEFS_H_
4362306a36Sopenharmony_ci
4462306a36Sopenharmony_cienum chip_flavors {
4562306a36Sopenharmony_ci	chip_8001,
4662306a36Sopenharmony_ci	chip_8008,
4762306a36Sopenharmony_ci	chip_8009,
4862306a36Sopenharmony_ci	chip_8018,
4962306a36Sopenharmony_ci	chip_8019,
5062306a36Sopenharmony_ci	chip_8074,
5162306a36Sopenharmony_ci	chip_8076,
5262306a36Sopenharmony_ci	chip_8077,
5362306a36Sopenharmony_ci	chip_8006,
5462306a36Sopenharmony_ci	chip_8070,
5562306a36Sopenharmony_ci	chip_8072
5662306a36Sopenharmony_ci};
5762306a36Sopenharmony_ci
5862306a36Sopenharmony_cienum phy_speed {
5962306a36Sopenharmony_ci	PHY_SPEED_15 = 0x01,
6062306a36Sopenharmony_ci	PHY_SPEED_30 = 0x02,
6162306a36Sopenharmony_ci	PHY_SPEED_60 = 0x04,
6262306a36Sopenharmony_ci	PHY_SPEED_120 = 0x08,
6362306a36Sopenharmony_ci};
6462306a36Sopenharmony_ci
6562306a36Sopenharmony_cienum data_direction {
6662306a36Sopenharmony_ci	DATA_DIR_NONE = 0x0,	/* NO TRANSFER */
6762306a36Sopenharmony_ci	DATA_DIR_IN = 0x01,	/* INBOUND */
6862306a36Sopenharmony_ci	DATA_DIR_OUT = 0x02,	/* OUTBOUND */
6962306a36Sopenharmony_ci	DATA_DIR_BYRECIPIENT = 0x04, /* UNSPECIFIED */
7062306a36Sopenharmony_ci};
7162306a36Sopenharmony_ci
7262306a36Sopenharmony_cienum port_type {
7362306a36Sopenharmony_ci	PORT_TYPE_SAS = (1L << 1),
7462306a36Sopenharmony_ci	PORT_TYPE_SATA = (1L << 0),
7562306a36Sopenharmony_ci};
7662306a36Sopenharmony_ci
7762306a36Sopenharmony_ci/* driver compile-time configuration */
7862306a36Sopenharmony_ci#define	PM8001_MAX_CCB		 1024	/* max ccbs supported */
7962306a36Sopenharmony_ci#define PM8001_MPI_QUEUE         1024   /* maximum mpi queue entries */
8062306a36Sopenharmony_ci#define	PM8001_MAX_INB_NUM	 64
8162306a36Sopenharmony_ci#define	PM8001_MAX_OUTB_NUM	 64
8262306a36Sopenharmony_ci#define	PM8001_CAN_QUEUE	 508	/* SCSI Queue depth */
8362306a36Sopenharmony_ci
8462306a36Sopenharmony_ci/* Inbound/Outbound queue size */
8562306a36Sopenharmony_ci#define IOMB_SIZE_SPC		64
8662306a36Sopenharmony_ci#define IOMB_SIZE_SPCV		128
8762306a36Sopenharmony_ci
8862306a36Sopenharmony_ci/* unchangeable hardware details */
8962306a36Sopenharmony_ci#define	PM8001_MAX_PHYS		 16	/* max. possible phys */
9062306a36Sopenharmony_ci#define	PM8001_MAX_PORTS	 16	/* max. possible ports */
9162306a36Sopenharmony_ci#define	PM8001_MAX_DEVICES	 2048	/* max supported device */
9262306a36Sopenharmony_ci#define	PM8001_MAX_MSIX_VEC	 64	/* max msi-x int for spcv/ve */
9362306a36Sopenharmony_ci#define	PM8001_RESERVE_SLOT	 8
9462306a36Sopenharmony_ci
9562306a36Sopenharmony_ci#define	CONFIG_SCSI_PM8001_MAX_DMA_SG	528
9662306a36Sopenharmony_ci#define PM8001_MAX_DMA_SG	CONFIG_SCSI_PM8001_MAX_DMA_SG
9762306a36Sopenharmony_ci
9862306a36Sopenharmony_cienum memory_region_num {
9962306a36Sopenharmony_ci	AAP1 = 0x0, /* application acceleration processor */
10062306a36Sopenharmony_ci	IOP,	    /* IO processor */
10162306a36Sopenharmony_ci	NVMD,	    /* NVM device */
10262306a36Sopenharmony_ci	FW_FLASH,    /* memory for fw flash update */
10362306a36Sopenharmony_ci	FORENSIC_MEM,  /* memory for fw forensic data */
10462306a36Sopenharmony_ci	USI_MAX_MEMCNT_BASE
10562306a36Sopenharmony_ci};
10662306a36Sopenharmony_ci#define	PM8001_EVENT_LOG_SIZE	 (128 * 1024)
10762306a36Sopenharmony_ci
10862306a36Sopenharmony_ci/**
10962306a36Sopenharmony_ci * maximum DMA memory regions(number of IBQ + number of IBQ CI
11062306a36Sopenharmony_ci * + number of  OBQ + number of OBQ PI)
11162306a36Sopenharmony_ci */
11262306a36Sopenharmony_ci#define USI_MAX_MEMCNT	(USI_MAX_MEMCNT_BASE + ((2 * PM8001_MAX_INB_NUM) \
11362306a36Sopenharmony_ci			+ (2 * PM8001_MAX_OUTB_NUM)))
11462306a36Sopenharmony_ci/*error code*/
11562306a36Sopenharmony_cienum mpi_err {
11662306a36Sopenharmony_ci	MPI_IO_STATUS_SUCCESS = 0x0,
11762306a36Sopenharmony_ci	MPI_IO_STATUS_BUSY = 0x01,
11862306a36Sopenharmony_ci	MPI_IO_STATUS_FAIL = 0x02,
11962306a36Sopenharmony_ci};
12062306a36Sopenharmony_ci
12162306a36Sopenharmony_ci/**
12262306a36Sopenharmony_ci * Phy Control constants
12362306a36Sopenharmony_ci */
12462306a36Sopenharmony_cienum phy_control_type {
12562306a36Sopenharmony_ci	PHY_LINK_RESET = 0x01,
12662306a36Sopenharmony_ci	PHY_HARD_RESET = 0x02,
12762306a36Sopenharmony_ci	PHY_NOTIFY_ENABLE_SPINUP = 0x10,
12862306a36Sopenharmony_ci};
12962306a36Sopenharmony_ci
13062306a36Sopenharmony_cienum pm8001_hba_info_flags {
13162306a36Sopenharmony_ci	PM8001F_INIT_TIME	= (1U << 0),
13262306a36Sopenharmony_ci	PM8001F_RUN_TIME	= (1U << 1),
13362306a36Sopenharmony_ci};
13462306a36Sopenharmony_ci
13562306a36Sopenharmony_ci/**
13662306a36Sopenharmony_ci * Phy Status
13762306a36Sopenharmony_ci */
13862306a36Sopenharmony_ci#define PHY_LINK_DISABLE	0x00
13962306a36Sopenharmony_ci#define PHY_LINK_DOWN		0x01
14062306a36Sopenharmony_ci#define PHY_STATE_LINK_UP_SPCV	0x2
14162306a36Sopenharmony_ci#define PHY_STATE_LINK_UP_SPC	0x1
14262306a36Sopenharmony_ci
14362306a36Sopenharmony_ci#endif
144