162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Marvell 88SE64xx hardware specific head file
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * Copyright 2007 Red Hat, Inc.
662306a36Sopenharmony_ci * Copyright 2008 Marvell. <kewei@marvell.com>
762306a36Sopenharmony_ci * Copyright 2009-2011 Marvell. <yuxiangl@marvell.com>
862306a36Sopenharmony_ci*/
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci#ifndef _MVS64XX_REG_H_
1162306a36Sopenharmony_ci#define _MVS64XX_REG_H_
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci#include <linux/types.h>
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci#define MAX_LINK_RATE		SAS_LINK_RATE_3_0_GBPS
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_ci/* enhanced mode registers (BAR4) */
1862306a36Sopenharmony_cienum hw_registers {
1962306a36Sopenharmony_ci	MVS_GBL_CTL		= 0x04,  /* global control */
2062306a36Sopenharmony_ci	MVS_GBL_INT_STAT	= 0x08,  /* global irq status */
2162306a36Sopenharmony_ci	MVS_GBL_PI		= 0x0C,  /* ports implemented bitmask */
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_ci	MVS_PHY_CTL		= 0x40,  /* SOC PHY Control */
2462306a36Sopenharmony_ci	MVS_PORTS_IMP		= 0x9C,  /* SOC Port Implemented */
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_ci	MVS_GBL_PORT_TYPE	= 0xa0,  /* port type */
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_ci	MVS_CTL			= 0x100, /* SAS/SATA port configuration */
2962306a36Sopenharmony_ci	MVS_PCS			= 0x104, /* SAS/SATA port control/status */
3062306a36Sopenharmony_ci	MVS_CMD_LIST_LO		= 0x108, /* cmd list addr */
3162306a36Sopenharmony_ci	MVS_CMD_LIST_HI		= 0x10C,
3262306a36Sopenharmony_ci	MVS_RX_FIS_LO		= 0x110, /* RX FIS list addr */
3362306a36Sopenharmony_ci	MVS_RX_FIS_HI		= 0x114,
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ci	MVS_TX_CFG		= 0x120, /* TX configuration */
3662306a36Sopenharmony_ci	MVS_TX_LO		= 0x124, /* TX (delivery) ring addr */
3762306a36Sopenharmony_ci	MVS_TX_HI		= 0x128,
3862306a36Sopenharmony_ci
3962306a36Sopenharmony_ci	MVS_TX_PROD_IDX		= 0x12C, /* TX producer pointer */
4062306a36Sopenharmony_ci	MVS_TX_CONS_IDX		= 0x130, /* TX consumer pointer (RO) */
4162306a36Sopenharmony_ci	MVS_RX_CFG		= 0x134, /* RX configuration */
4262306a36Sopenharmony_ci	MVS_RX_LO		= 0x138, /* RX (completion) ring addr */
4362306a36Sopenharmony_ci	MVS_RX_HI		= 0x13C,
4462306a36Sopenharmony_ci	MVS_RX_CONS_IDX		= 0x140, /* RX consumer pointer (RO) */
4562306a36Sopenharmony_ci
4662306a36Sopenharmony_ci	MVS_INT_COAL		= 0x148, /* Int coalescing config */
4762306a36Sopenharmony_ci	MVS_INT_COAL_TMOUT	= 0x14C, /* Int coalescing timeout */
4862306a36Sopenharmony_ci	MVS_INT_STAT		= 0x150, /* Central int status */
4962306a36Sopenharmony_ci	MVS_INT_MASK		= 0x154, /* Central int enable */
5062306a36Sopenharmony_ci	MVS_INT_STAT_SRS_0	= 0x158, /* SATA register set status */
5162306a36Sopenharmony_ci	MVS_INT_MASK_SRS_0	= 0x15C,
5262306a36Sopenharmony_ci
5362306a36Sopenharmony_ci					 /* ports 1-3 follow after this */
5462306a36Sopenharmony_ci	MVS_P0_INT_STAT		= 0x160, /* port0 interrupt status */
5562306a36Sopenharmony_ci	MVS_P0_INT_MASK		= 0x164, /* port0 interrupt mask */
5662306a36Sopenharmony_ci					 /* ports 5-7 follow after this */
5762306a36Sopenharmony_ci	MVS_P4_INT_STAT		= 0x200, /* Port4 interrupt status */
5862306a36Sopenharmony_ci	MVS_P4_INT_MASK		= 0x204, /* Port4 interrupt enable mask */
5962306a36Sopenharmony_ci
6062306a36Sopenharmony_ci					 /* ports 1-3 follow after this */
6162306a36Sopenharmony_ci	MVS_P0_SER_CTLSTAT	= 0x180, /* port0 serial control/status */
6262306a36Sopenharmony_ci					 /* ports 5-7 follow after this */
6362306a36Sopenharmony_ci	MVS_P4_SER_CTLSTAT	= 0x220, /* port4 serial control/status */
6462306a36Sopenharmony_ci
6562306a36Sopenharmony_ci	MVS_CMD_ADDR		= 0x1B8, /* Command register port (addr) */
6662306a36Sopenharmony_ci	MVS_CMD_DATA		= 0x1BC, /* Command register port (data) */
6762306a36Sopenharmony_ci
6862306a36Sopenharmony_ci					 /* ports 1-3 follow after this */
6962306a36Sopenharmony_ci	MVS_P0_CFG_ADDR		= 0x1C0, /* port0 phy register address */
7062306a36Sopenharmony_ci	MVS_P0_CFG_DATA		= 0x1C4, /* port0 phy register data */
7162306a36Sopenharmony_ci					 /* ports 5-7 follow after this */
7262306a36Sopenharmony_ci	MVS_P4_CFG_ADDR		= 0x230, /* Port4 config address */
7362306a36Sopenharmony_ci	MVS_P4_CFG_DATA		= 0x234, /* Port4 config data */
7462306a36Sopenharmony_ci
7562306a36Sopenharmony_ci					 /* ports 1-3 follow after this */
7662306a36Sopenharmony_ci	MVS_P0_VSR_ADDR		= 0x1E0, /* port0 VSR address */
7762306a36Sopenharmony_ci	MVS_P0_VSR_DATA		= 0x1E4, /* port0 VSR data */
7862306a36Sopenharmony_ci					 /* ports 5-7 follow after this */
7962306a36Sopenharmony_ci	MVS_P4_VSR_ADDR		= 0x250, /* port4 VSR addr */
8062306a36Sopenharmony_ci	MVS_P4_VSR_DATA		= 0x254, /* port4 VSR data */
8162306a36Sopenharmony_ci};
8262306a36Sopenharmony_ci
8362306a36Sopenharmony_cienum pci_cfg_registers {
8462306a36Sopenharmony_ci	PCR_PHY_CTL		= 0x40,
8562306a36Sopenharmony_ci	PCR_PHY_CTL2		= 0x90,
8662306a36Sopenharmony_ci	PCR_DEV_CTRL		= 0xE8,
8762306a36Sopenharmony_ci	PCR_LINK_STAT		= 0xF2,
8862306a36Sopenharmony_ci};
8962306a36Sopenharmony_ci
9062306a36Sopenharmony_ci/*  SAS/SATA Vendor Specific Port Registers */
9162306a36Sopenharmony_cienum sas_sata_vsp_regs {
9262306a36Sopenharmony_ci	VSR_PHY_STAT		= 0x00, /* Phy Status */
9362306a36Sopenharmony_ci	VSR_PHY_MODE1		= 0x01, /* phy tx */
9462306a36Sopenharmony_ci	VSR_PHY_MODE2		= 0x02, /* tx scc */
9562306a36Sopenharmony_ci	VSR_PHY_MODE3		= 0x03, /* pll */
9662306a36Sopenharmony_ci	VSR_PHY_MODE4		= 0x04, /* VCO */
9762306a36Sopenharmony_ci	VSR_PHY_MODE5		= 0x05, /* Rx */
9862306a36Sopenharmony_ci	VSR_PHY_MODE6		= 0x06, /* CDR */
9962306a36Sopenharmony_ci	VSR_PHY_MODE7		= 0x07, /* Impedance */
10062306a36Sopenharmony_ci	VSR_PHY_MODE8		= 0x08, /* Voltage */
10162306a36Sopenharmony_ci	VSR_PHY_MODE9		= 0x09, /* Test */
10262306a36Sopenharmony_ci	VSR_PHY_MODE10		= 0x0A, /* Power */
10362306a36Sopenharmony_ci	VSR_PHY_MODE11		= 0x0B, /* Phy Mode */
10462306a36Sopenharmony_ci	VSR_PHY_VS0		= 0x0C, /* Vednor Specific 0 */
10562306a36Sopenharmony_ci	VSR_PHY_VS1		= 0x0D, /* Vednor Specific 1 */
10662306a36Sopenharmony_ci};
10762306a36Sopenharmony_ci
10862306a36Sopenharmony_cienum chip_register_bits {
10962306a36Sopenharmony_ci	PHY_MIN_SPP_PHYS_LINK_RATE_MASK = (0xF << 8),
11062306a36Sopenharmony_ci	PHY_MAX_SPP_PHYS_LINK_RATE_MASK = (0xF << 12),
11162306a36Sopenharmony_ci	PHY_NEG_SPP_PHYS_LINK_RATE_MASK_OFFSET = (16),
11262306a36Sopenharmony_ci	PHY_NEG_SPP_PHYS_LINK_RATE_MASK =
11362306a36Sopenharmony_ci			(0xF << PHY_NEG_SPP_PHYS_LINK_RATE_MASK_OFFSET),
11462306a36Sopenharmony_ci};
11562306a36Sopenharmony_ci
11662306a36Sopenharmony_ci#define MAX_SG_ENTRY		64
11762306a36Sopenharmony_ci
11862306a36Sopenharmony_cistruct mvs_prd {
11962306a36Sopenharmony_ci	__le64			addr;		/* 64-bit buffer address */
12062306a36Sopenharmony_ci	__le32			reserved;
12162306a36Sopenharmony_ci	__le32			len;		/* 16-bit length */
12262306a36Sopenharmony_ci};
12362306a36Sopenharmony_ci
12462306a36Sopenharmony_ci#define SPI_CTRL_REG				0xc0
12562306a36Sopenharmony_ci#define SPI_CTRL_VENDOR_ENABLE		(1U<<29)
12662306a36Sopenharmony_ci#define SPI_CTRL_SPIRDY         		(1U<<22)
12762306a36Sopenharmony_ci#define SPI_CTRL_SPISTART			(1U<<20)
12862306a36Sopenharmony_ci
12962306a36Sopenharmony_ci#define SPI_CMD_REG		0xc4
13062306a36Sopenharmony_ci#define SPI_DATA_REG		0xc8
13162306a36Sopenharmony_ci
13262306a36Sopenharmony_ci#define SPI_CTRL_REG_64XX		0x10
13362306a36Sopenharmony_ci#define SPI_CMD_REG_64XX		0x14
13462306a36Sopenharmony_ci#define SPI_DATA_REG_64XX		0x18
13562306a36Sopenharmony_ci
13662306a36Sopenharmony_ci#endif
137