18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Marvell 88SE64xx hardware specific head file
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright 2007 Red Hat, Inc.
68c2ecf20Sopenharmony_ci * Copyright 2008 Marvell. <kewei@marvell.com>
78c2ecf20Sopenharmony_ci * Copyright 2009-2011 Marvell. <yuxiangl@marvell.com>
88c2ecf20Sopenharmony_ci*/
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#ifndef _MVS64XX_REG_H_
118c2ecf20Sopenharmony_ci#define _MVS64XX_REG_H_
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci#include <linux/types.h>
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci#define MAX_LINK_RATE		SAS_LINK_RATE_3_0_GBPS
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci/* enhanced mode registers (BAR4) */
188c2ecf20Sopenharmony_cienum hw_registers {
198c2ecf20Sopenharmony_ci	MVS_GBL_CTL		= 0x04,  /* global control */
208c2ecf20Sopenharmony_ci	MVS_GBL_INT_STAT	= 0x08,  /* global irq status */
218c2ecf20Sopenharmony_ci	MVS_GBL_PI		= 0x0C,  /* ports implemented bitmask */
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci	MVS_PHY_CTL		= 0x40,  /* SOC PHY Control */
248c2ecf20Sopenharmony_ci	MVS_PORTS_IMP		= 0x9C,  /* SOC Port Implemented */
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci	MVS_GBL_PORT_TYPE	= 0xa0,  /* port type */
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci	MVS_CTL			= 0x100, /* SAS/SATA port configuration */
298c2ecf20Sopenharmony_ci	MVS_PCS			= 0x104, /* SAS/SATA port control/status */
308c2ecf20Sopenharmony_ci	MVS_CMD_LIST_LO		= 0x108, /* cmd list addr */
318c2ecf20Sopenharmony_ci	MVS_CMD_LIST_HI		= 0x10C,
328c2ecf20Sopenharmony_ci	MVS_RX_FIS_LO		= 0x110, /* RX FIS list addr */
338c2ecf20Sopenharmony_ci	MVS_RX_FIS_HI		= 0x114,
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci	MVS_TX_CFG		= 0x120, /* TX configuration */
368c2ecf20Sopenharmony_ci	MVS_TX_LO		= 0x124, /* TX (delivery) ring addr */
378c2ecf20Sopenharmony_ci	MVS_TX_HI		= 0x128,
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci	MVS_TX_PROD_IDX		= 0x12C, /* TX producer pointer */
408c2ecf20Sopenharmony_ci	MVS_TX_CONS_IDX		= 0x130, /* TX consumer pointer (RO) */
418c2ecf20Sopenharmony_ci	MVS_RX_CFG		= 0x134, /* RX configuration */
428c2ecf20Sopenharmony_ci	MVS_RX_LO		= 0x138, /* RX (completion) ring addr */
438c2ecf20Sopenharmony_ci	MVS_RX_HI		= 0x13C,
448c2ecf20Sopenharmony_ci	MVS_RX_CONS_IDX		= 0x140, /* RX consumer pointer (RO) */
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ci	MVS_INT_COAL		= 0x148, /* Int coalescing config */
478c2ecf20Sopenharmony_ci	MVS_INT_COAL_TMOUT	= 0x14C, /* Int coalescing timeout */
488c2ecf20Sopenharmony_ci	MVS_INT_STAT		= 0x150, /* Central int status */
498c2ecf20Sopenharmony_ci	MVS_INT_MASK		= 0x154, /* Central int enable */
508c2ecf20Sopenharmony_ci	MVS_INT_STAT_SRS_0	= 0x158, /* SATA register set status */
518c2ecf20Sopenharmony_ci	MVS_INT_MASK_SRS_0	= 0x15C,
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_ci					 /* ports 1-3 follow after this */
548c2ecf20Sopenharmony_ci	MVS_P0_INT_STAT		= 0x160, /* port0 interrupt status */
558c2ecf20Sopenharmony_ci	MVS_P0_INT_MASK		= 0x164, /* port0 interrupt mask */
568c2ecf20Sopenharmony_ci					 /* ports 5-7 follow after this */
578c2ecf20Sopenharmony_ci	MVS_P4_INT_STAT		= 0x200, /* Port4 interrupt status */
588c2ecf20Sopenharmony_ci	MVS_P4_INT_MASK		= 0x204, /* Port4 interrupt enable mask */
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ci					 /* ports 1-3 follow after this */
618c2ecf20Sopenharmony_ci	MVS_P0_SER_CTLSTAT	= 0x180, /* port0 serial control/status */
628c2ecf20Sopenharmony_ci					 /* ports 5-7 follow after this */
638c2ecf20Sopenharmony_ci	MVS_P4_SER_CTLSTAT	= 0x220, /* port4 serial control/status */
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ci	MVS_CMD_ADDR		= 0x1B8, /* Command register port (addr) */
668c2ecf20Sopenharmony_ci	MVS_CMD_DATA		= 0x1BC, /* Command register port (data) */
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_ci					 /* ports 1-3 follow after this */
698c2ecf20Sopenharmony_ci	MVS_P0_CFG_ADDR		= 0x1C0, /* port0 phy register address */
708c2ecf20Sopenharmony_ci	MVS_P0_CFG_DATA		= 0x1C4, /* port0 phy register data */
718c2ecf20Sopenharmony_ci					 /* ports 5-7 follow after this */
728c2ecf20Sopenharmony_ci	MVS_P4_CFG_ADDR		= 0x230, /* Port4 config address */
738c2ecf20Sopenharmony_ci	MVS_P4_CFG_DATA		= 0x234, /* Port4 config data */
748c2ecf20Sopenharmony_ci
758c2ecf20Sopenharmony_ci					 /* ports 1-3 follow after this */
768c2ecf20Sopenharmony_ci	MVS_P0_VSR_ADDR		= 0x1E0, /* port0 VSR address */
778c2ecf20Sopenharmony_ci	MVS_P0_VSR_DATA		= 0x1E4, /* port0 VSR data */
788c2ecf20Sopenharmony_ci					 /* ports 5-7 follow after this */
798c2ecf20Sopenharmony_ci	MVS_P4_VSR_ADDR		= 0x250, /* port4 VSR addr */
808c2ecf20Sopenharmony_ci	MVS_P4_VSR_DATA		= 0x254, /* port4 VSR data */
818c2ecf20Sopenharmony_ci};
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_cienum pci_cfg_registers {
848c2ecf20Sopenharmony_ci	PCR_PHY_CTL		= 0x40,
858c2ecf20Sopenharmony_ci	PCR_PHY_CTL2		= 0x90,
868c2ecf20Sopenharmony_ci	PCR_DEV_CTRL		= 0xE8,
878c2ecf20Sopenharmony_ci	PCR_LINK_STAT		= 0xF2,
888c2ecf20Sopenharmony_ci};
898c2ecf20Sopenharmony_ci
908c2ecf20Sopenharmony_ci/*  SAS/SATA Vendor Specific Port Registers */
918c2ecf20Sopenharmony_cienum sas_sata_vsp_regs {
928c2ecf20Sopenharmony_ci	VSR_PHY_STAT		= 0x00, /* Phy Status */
938c2ecf20Sopenharmony_ci	VSR_PHY_MODE1		= 0x01, /* phy tx */
948c2ecf20Sopenharmony_ci	VSR_PHY_MODE2		= 0x02, /* tx scc */
958c2ecf20Sopenharmony_ci	VSR_PHY_MODE3		= 0x03, /* pll */
968c2ecf20Sopenharmony_ci	VSR_PHY_MODE4		= 0x04, /* VCO */
978c2ecf20Sopenharmony_ci	VSR_PHY_MODE5		= 0x05, /* Rx */
988c2ecf20Sopenharmony_ci	VSR_PHY_MODE6		= 0x06, /* CDR */
998c2ecf20Sopenharmony_ci	VSR_PHY_MODE7		= 0x07, /* Impedance */
1008c2ecf20Sopenharmony_ci	VSR_PHY_MODE8		= 0x08, /* Voltage */
1018c2ecf20Sopenharmony_ci	VSR_PHY_MODE9		= 0x09, /* Test */
1028c2ecf20Sopenharmony_ci	VSR_PHY_MODE10		= 0x0A, /* Power */
1038c2ecf20Sopenharmony_ci	VSR_PHY_MODE11		= 0x0B, /* Phy Mode */
1048c2ecf20Sopenharmony_ci	VSR_PHY_VS0		= 0x0C, /* Vednor Specific 0 */
1058c2ecf20Sopenharmony_ci	VSR_PHY_VS1		= 0x0D, /* Vednor Specific 1 */
1068c2ecf20Sopenharmony_ci};
1078c2ecf20Sopenharmony_ci
1088c2ecf20Sopenharmony_cienum chip_register_bits {
1098c2ecf20Sopenharmony_ci	PHY_MIN_SPP_PHYS_LINK_RATE_MASK = (0xF << 8),
1108c2ecf20Sopenharmony_ci	PHY_MAX_SPP_PHYS_LINK_RATE_MASK = (0xF << 12),
1118c2ecf20Sopenharmony_ci	PHY_NEG_SPP_PHYS_LINK_RATE_MASK_OFFSET = (16),
1128c2ecf20Sopenharmony_ci	PHY_NEG_SPP_PHYS_LINK_RATE_MASK =
1138c2ecf20Sopenharmony_ci			(0xF << PHY_NEG_SPP_PHYS_LINK_RATE_MASK_OFFSET),
1148c2ecf20Sopenharmony_ci};
1158c2ecf20Sopenharmony_ci
1168c2ecf20Sopenharmony_ci#define MAX_SG_ENTRY		64
1178c2ecf20Sopenharmony_ci
1188c2ecf20Sopenharmony_cistruct mvs_prd {
1198c2ecf20Sopenharmony_ci	__le64			addr;		/* 64-bit buffer address */
1208c2ecf20Sopenharmony_ci	__le32			reserved;
1218c2ecf20Sopenharmony_ci	__le32			len;		/* 16-bit length */
1228c2ecf20Sopenharmony_ci};
1238c2ecf20Sopenharmony_ci
1248c2ecf20Sopenharmony_ci#define SPI_CTRL_REG				0xc0
1258c2ecf20Sopenharmony_ci#define SPI_CTRL_VENDOR_ENABLE		(1U<<29)
1268c2ecf20Sopenharmony_ci#define SPI_CTRL_SPIRDY         		(1U<<22)
1278c2ecf20Sopenharmony_ci#define SPI_CTRL_SPISTART			(1U<<20)
1288c2ecf20Sopenharmony_ci
1298c2ecf20Sopenharmony_ci#define SPI_CMD_REG		0xc4
1308c2ecf20Sopenharmony_ci#define SPI_DATA_REG		0xc8
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_ci#define SPI_CTRL_REG_64XX		0x10
1338c2ecf20Sopenharmony_ci#define SPI_CMD_REG_64XX		0x14
1348c2ecf20Sopenharmony_ci#define SPI_DATA_REG_64XX		0x18
1358c2ecf20Sopenharmony_ci
1368c2ecf20Sopenharmony_ci#endif
137