18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Marvell 88SE94xx 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 _MVS94XX_REG_H_
118c2ecf20Sopenharmony_ci#define _MVS94XX_REG_H_
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci#include <linux/types.h>
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci#define MAX_LINK_RATE		SAS_LINK_RATE_6_0_GBPS
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_cienum VANIR_REVISION_ID {
188c2ecf20Sopenharmony_ci	VANIR_A0_REV		= 0xA0,
198c2ecf20Sopenharmony_ci	VANIR_B0_REV		= 0x01,
208c2ecf20Sopenharmony_ci	VANIR_C0_REV		= 0x02,
218c2ecf20Sopenharmony_ci	VANIR_C1_REV		= 0x03,
228c2ecf20Sopenharmony_ci	VANIR_C2_REV		= 0xC2,
238c2ecf20Sopenharmony_ci};
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_cienum host_registers {
268c2ecf20Sopenharmony_ci	MVS_HST_CHIP_CONFIG	= 0x10104,	/* chip configuration */
278c2ecf20Sopenharmony_ci};
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_cienum hw_registers {
308c2ecf20Sopenharmony_ci	MVS_GBL_CTL		= 0x04,  /* global control */
318c2ecf20Sopenharmony_ci	MVS_GBL_INT_STAT	= 0x00,  /* global irq status */
328c2ecf20Sopenharmony_ci	MVS_GBL_PI		= 0x0C,  /* ports implemented bitmask */
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci	MVS_PHY_CTL		= 0x40,  /* SOC PHY Control */
358c2ecf20Sopenharmony_ci	MVS_PORTS_IMP		= 0x9C,  /* SOC Port Implemented */
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ci	MVS_GBL_PORT_TYPE	= 0xa0,  /* port type */
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci	MVS_CTL			= 0x100, /* SAS/SATA port configuration */
408c2ecf20Sopenharmony_ci	MVS_PCS			= 0x104, /* SAS/SATA port control/status */
418c2ecf20Sopenharmony_ci	MVS_CMD_LIST_LO		= 0x108, /* cmd list addr */
428c2ecf20Sopenharmony_ci	MVS_CMD_LIST_HI		= 0x10C,
438c2ecf20Sopenharmony_ci	MVS_RX_FIS_LO		= 0x110, /* RX FIS list addr */
448c2ecf20Sopenharmony_ci	MVS_RX_FIS_HI		= 0x114,
458c2ecf20Sopenharmony_ci	MVS_STP_REG_SET_0	= 0x118, /* STP/SATA Register Set Enable */
468c2ecf20Sopenharmony_ci	MVS_STP_REG_SET_1	= 0x11C,
478c2ecf20Sopenharmony_ci	MVS_TX_CFG		= 0x120, /* TX configuration */
488c2ecf20Sopenharmony_ci	MVS_TX_LO		= 0x124, /* TX (delivery) ring addr */
498c2ecf20Sopenharmony_ci	MVS_TX_HI		= 0x128,
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ci	MVS_TX_PROD_IDX		= 0x12C, /* TX producer pointer */
528c2ecf20Sopenharmony_ci	MVS_TX_CONS_IDX		= 0x130, /* TX consumer pointer (RO) */
538c2ecf20Sopenharmony_ci	MVS_RX_CFG		= 0x134, /* RX configuration */
548c2ecf20Sopenharmony_ci	MVS_RX_LO		= 0x138, /* RX (completion) ring addr */
558c2ecf20Sopenharmony_ci	MVS_RX_HI		= 0x13C,
568c2ecf20Sopenharmony_ci	MVS_RX_CONS_IDX		= 0x140, /* RX consumer pointer (RO) */
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_ci	MVS_INT_COAL		= 0x148, /* Int coalescing config */
598c2ecf20Sopenharmony_ci	MVS_INT_COAL_TMOUT	= 0x14C, /* Int coalescing timeout */
608c2ecf20Sopenharmony_ci	MVS_INT_STAT		= 0x150, /* Central int status */
618c2ecf20Sopenharmony_ci	MVS_INT_MASK		= 0x154, /* Central int enable */
628c2ecf20Sopenharmony_ci	MVS_INT_STAT_SRS_0	= 0x158, /* SATA register set status */
638c2ecf20Sopenharmony_ci	MVS_INT_MASK_SRS_0	= 0x15C,
648c2ecf20Sopenharmony_ci	MVS_INT_STAT_SRS_1	= 0x160,
658c2ecf20Sopenharmony_ci	MVS_INT_MASK_SRS_1	= 0x164,
668c2ecf20Sopenharmony_ci	MVS_NON_NCQ_ERR_0	= 0x168, /* SRS Non-specific NCQ Error */
678c2ecf20Sopenharmony_ci	MVS_NON_NCQ_ERR_1	= 0x16C,
688c2ecf20Sopenharmony_ci	MVS_CMD_ADDR		= 0x170, /* Command register port (addr) */
698c2ecf20Sopenharmony_ci	MVS_CMD_DATA		= 0x174, /* Command register port (data) */
708c2ecf20Sopenharmony_ci	MVS_MEM_PARITY_ERR	= 0x178, /* Memory parity error */
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ci					 /* ports 1-3 follow after this */
738c2ecf20Sopenharmony_ci	MVS_P0_INT_STAT		= 0x180, /* port0 interrupt status */
748c2ecf20Sopenharmony_ci	MVS_P0_INT_MASK		= 0x184, /* port0 interrupt mask */
758c2ecf20Sopenharmony_ci					 /* ports 5-7 follow after this */
768c2ecf20Sopenharmony_ci	MVS_P4_INT_STAT		= 0x1A0, /* Port4 interrupt status */
778c2ecf20Sopenharmony_ci	MVS_P4_INT_MASK		= 0x1A4, /* Port4 interrupt enable mask */
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_ci					 /* ports 1-3 follow after this */
808c2ecf20Sopenharmony_ci	MVS_P0_SER_CTLSTAT	= 0x1D0, /* port0 serial control/status */
818c2ecf20Sopenharmony_ci					 /* ports 5-7 follow after this */
828c2ecf20Sopenharmony_ci	MVS_P4_SER_CTLSTAT	= 0x1E0, /* port4 serial control/status */
838c2ecf20Sopenharmony_ci
848c2ecf20Sopenharmony_ci					 /* ports 1-3 follow after this */
858c2ecf20Sopenharmony_ci	MVS_P0_CFG_ADDR		= 0x200, /* port0 phy register address */
868c2ecf20Sopenharmony_ci	MVS_P0_CFG_DATA		= 0x204, /* port0 phy register data */
878c2ecf20Sopenharmony_ci					 /* ports 5-7 follow after this */
888c2ecf20Sopenharmony_ci	MVS_P4_CFG_ADDR		= 0x220, /* Port4 config address */
898c2ecf20Sopenharmony_ci	MVS_P4_CFG_DATA		= 0x224, /* Port4 config data */
908c2ecf20Sopenharmony_ci
918c2ecf20Sopenharmony_ci					 /* phys 1-3 follow after this */
928c2ecf20Sopenharmony_ci	MVS_P0_VSR_ADDR		= 0x250, /* phy0 VSR address */
938c2ecf20Sopenharmony_ci	MVS_P0_VSR_DATA		= 0x254, /* phy0 VSR data */
948c2ecf20Sopenharmony_ci					 /* phys 1-3 follow after this */
958c2ecf20Sopenharmony_ci					 /* multiplexing */
968c2ecf20Sopenharmony_ci	MVS_P4_VSR_ADDR 	= 0x250, /* phy4 VSR address */
978c2ecf20Sopenharmony_ci	MVS_P4_VSR_DATA 	= 0x254, /* phy4 VSR data */
988c2ecf20Sopenharmony_ci	MVS_PA_VSR_ADDR		= 0x290, /* All port VSR addr */
998c2ecf20Sopenharmony_ci	MVS_PA_VSR_PORT		= 0x294, /* All port VSR data */
1008c2ecf20Sopenharmony_ci	MVS_COMMAND_ACTIVE	= 0x300,
1018c2ecf20Sopenharmony_ci};
1028c2ecf20Sopenharmony_ci
1038c2ecf20Sopenharmony_cienum pci_cfg_registers {
1048c2ecf20Sopenharmony_ci	PCR_PHY_CTL		= 0x40,
1058c2ecf20Sopenharmony_ci	PCR_PHY_CTL2		= 0x90,
1068c2ecf20Sopenharmony_ci	PCR_DEV_CTRL		= 0x78,
1078c2ecf20Sopenharmony_ci	PCR_LINK_STAT		= 0x82,
1088c2ecf20Sopenharmony_ci};
1098c2ecf20Sopenharmony_ci
1108c2ecf20Sopenharmony_ci/*  SAS/SATA Vendor Specific Port Registers */
1118c2ecf20Sopenharmony_cienum sas_sata_vsp_regs {
1128c2ecf20Sopenharmony_ci	VSR_PHY_STAT		= 0x00 * 4, /* Phy Interrupt Status */
1138c2ecf20Sopenharmony_ci	VSR_PHY_MODE1		= 0x01 * 4, /* phy Interrupt Enable */
1148c2ecf20Sopenharmony_ci	VSR_PHY_MODE2		= 0x02 * 4, /* Phy Configuration */
1158c2ecf20Sopenharmony_ci	VSR_PHY_MODE3		= 0x03 * 4, /* Phy Status */
1168c2ecf20Sopenharmony_ci	VSR_PHY_MODE4		= 0x04 * 4, /* Phy Counter 0 */
1178c2ecf20Sopenharmony_ci	VSR_PHY_MODE5		= 0x05 * 4, /* Phy Counter 1 */
1188c2ecf20Sopenharmony_ci	VSR_PHY_MODE6		= 0x06 * 4, /* Event Counter Control */
1198c2ecf20Sopenharmony_ci	VSR_PHY_MODE7		= 0x07 * 4, /* Event Counter Select */
1208c2ecf20Sopenharmony_ci	VSR_PHY_MODE8		= 0x08 * 4, /* Event Counter 0 */
1218c2ecf20Sopenharmony_ci	VSR_PHY_MODE9		= 0x09 * 4, /* Event Counter 1 */
1228c2ecf20Sopenharmony_ci	VSR_PHY_MODE10		= 0x0A * 4, /* Event Counter 2 */
1238c2ecf20Sopenharmony_ci	VSR_PHY_MODE11		= 0x0B * 4, /* Event Counter 3 */
1248c2ecf20Sopenharmony_ci	VSR_PHY_ACT_LED		= 0x0C * 4, /* Activity LED control */
1258c2ecf20Sopenharmony_ci
1268c2ecf20Sopenharmony_ci	VSR_PHY_FFE_CONTROL	= 0x10C,
1278c2ecf20Sopenharmony_ci	VSR_PHY_DFE_UPDATE_CRTL	= 0x110,
1288c2ecf20Sopenharmony_ci	VSR_REF_CLOCK_CRTL	= 0x1A0,
1298c2ecf20Sopenharmony_ci};
1308c2ecf20Sopenharmony_ci
1318c2ecf20Sopenharmony_cienum chip_register_bits {
1328c2ecf20Sopenharmony_ci	PHY_MIN_SPP_PHYS_LINK_RATE_MASK = (0x7 << 8),
1338c2ecf20Sopenharmony_ci	PHY_MAX_SPP_PHYS_LINK_RATE_MASK = (0x7 << 12),
1348c2ecf20Sopenharmony_ci	PHY_NEG_SPP_PHYS_LINK_RATE_MASK_OFFSET = (16),
1358c2ecf20Sopenharmony_ci	PHY_NEG_SPP_PHYS_LINK_RATE_MASK =
1368c2ecf20Sopenharmony_ci			(0x3 << PHY_NEG_SPP_PHYS_LINK_RATE_MASK_OFFSET),
1378c2ecf20Sopenharmony_ci};
1388c2ecf20Sopenharmony_ci
1398c2ecf20Sopenharmony_cienum pci_interrupt_cause {
1408c2ecf20Sopenharmony_ci	/*  MAIN_IRQ_CAUSE (R10200) Bits*/
1418c2ecf20Sopenharmony_ci	MVS_IRQ_COM_IN_I2O_IOP0        = (1 << 0),
1428c2ecf20Sopenharmony_ci	MVS_IRQ_COM_IN_I2O_IOP1        = (1 << 1),
1438c2ecf20Sopenharmony_ci	MVS_IRQ_COM_IN_I2O_IOP2        = (1 << 2),
1448c2ecf20Sopenharmony_ci	MVS_IRQ_COM_IN_I2O_IOP3        = (1 << 3),
1458c2ecf20Sopenharmony_ci	MVS_IRQ_COM_OUT_I2O_HOS0       = (1 << 4),
1468c2ecf20Sopenharmony_ci	MVS_IRQ_COM_OUT_I2O_HOS1       = (1 << 5),
1478c2ecf20Sopenharmony_ci	MVS_IRQ_COM_OUT_I2O_HOS2       = (1 << 6),
1488c2ecf20Sopenharmony_ci	MVS_IRQ_COM_OUT_I2O_HOS3       = (1 << 7),
1498c2ecf20Sopenharmony_ci	MVS_IRQ_PCIF_TO_CPU_DRBL0      = (1 << 8),
1508c2ecf20Sopenharmony_ci	MVS_IRQ_PCIF_TO_CPU_DRBL1      = (1 << 9),
1518c2ecf20Sopenharmony_ci	MVS_IRQ_PCIF_TO_CPU_DRBL2      = (1 << 10),
1528c2ecf20Sopenharmony_ci	MVS_IRQ_PCIF_TO_CPU_DRBL3      = (1 << 11),
1538c2ecf20Sopenharmony_ci	MVS_IRQ_PCIF_DRBL0             = (1 << 12),
1548c2ecf20Sopenharmony_ci	MVS_IRQ_PCIF_DRBL1             = (1 << 13),
1558c2ecf20Sopenharmony_ci	MVS_IRQ_PCIF_DRBL2             = (1 << 14),
1568c2ecf20Sopenharmony_ci	MVS_IRQ_PCIF_DRBL3             = (1 << 15),
1578c2ecf20Sopenharmony_ci	MVS_IRQ_XOR_A                  = (1 << 16),
1588c2ecf20Sopenharmony_ci	MVS_IRQ_XOR_B                  = (1 << 17),
1598c2ecf20Sopenharmony_ci	MVS_IRQ_SAS_A                  = (1 << 18),
1608c2ecf20Sopenharmony_ci	MVS_IRQ_SAS_B                  = (1 << 19),
1618c2ecf20Sopenharmony_ci	MVS_IRQ_CPU_CNTRL              = (1 << 20),
1628c2ecf20Sopenharmony_ci	MVS_IRQ_GPIO                   = (1 << 21),
1638c2ecf20Sopenharmony_ci	MVS_IRQ_UART                   = (1 << 22),
1648c2ecf20Sopenharmony_ci	MVS_IRQ_SPI                    = (1 << 23),
1658c2ecf20Sopenharmony_ci	MVS_IRQ_I2C                    = (1 << 24),
1668c2ecf20Sopenharmony_ci	MVS_IRQ_SGPIO                  = (1 << 25),
1678c2ecf20Sopenharmony_ci	MVS_IRQ_COM_ERR                = (1 << 29),
1688c2ecf20Sopenharmony_ci	MVS_IRQ_I2O_ERR                = (1 << 30),
1698c2ecf20Sopenharmony_ci	MVS_IRQ_PCIE_ERR               = (1 << 31),
1708c2ecf20Sopenharmony_ci};
1718c2ecf20Sopenharmony_ci
1728c2ecf20Sopenharmony_ciunion reg_phy_cfg {
1738c2ecf20Sopenharmony_ci	u32 v;
1748c2ecf20Sopenharmony_ci	struct {
1758c2ecf20Sopenharmony_ci		u32 phy_reset:1;
1768c2ecf20Sopenharmony_ci		u32 sas_support:1;
1778c2ecf20Sopenharmony_ci		u32 sata_support:1;
1788c2ecf20Sopenharmony_ci		u32 sata_host_mode:1;
1798c2ecf20Sopenharmony_ci		/*
1808c2ecf20Sopenharmony_ci		 * bit 2: 6Gbps support
1818c2ecf20Sopenharmony_ci		 * bit 1: 3Gbps support
1828c2ecf20Sopenharmony_ci		 * bit 0: 1.5Gbps support
1838c2ecf20Sopenharmony_ci		 */
1848c2ecf20Sopenharmony_ci		u32 speed_support:3;
1858c2ecf20Sopenharmony_ci		u32 snw_3_support:1;
1868c2ecf20Sopenharmony_ci		u32 tx_lnk_parity:1;
1878c2ecf20Sopenharmony_ci		/*
1888c2ecf20Sopenharmony_ci		 * bit 5: G1 (1.5Gbps) Without SSC
1898c2ecf20Sopenharmony_ci		 * bit 4: G1 (1.5Gbps) with SSC
1908c2ecf20Sopenharmony_ci		 * bit 3: G2 (3.0Gbps) Without SSC
1918c2ecf20Sopenharmony_ci		 * bit 2: G2 (3.0Gbps) with SSC
1928c2ecf20Sopenharmony_ci		 * bit 1: G3 (6.0Gbps) without SSC
1938c2ecf20Sopenharmony_ci		 * bit 0: G3 (6.0Gbps) with SSC
1948c2ecf20Sopenharmony_ci		 */
1958c2ecf20Sopenharmony_ci		u32 tx_spt_phs_lnk_rate:6;
1968c2ecf20Sopenharmony_ci		/* 8h: 1.5Gbps 9h: 3Gbps Ah: 6Gbps */
1978c2ecf20Sopenharmony_ci		u32 tx_lgcl_lnk_rate:4;
1988c2ecf20Sopenharmony_ci		u32 tx_ssc_type:1;
1998c2ecf20Sopenharmony_ci		u32 sata_spin_up_spt:1;
2008c2ecf20Sopenharmony_ci		u32 sata_spin_up_en:1;
2018c2ecf20Sopenharmony_ci		u32 bypass_oob:1;
2028c2ecf20Sopenharmony_ci		u32 disable_phy:1;
2038c2ecf20Sopenharmony_ci		u32 rsvd:8;
2048c2ecf20Sopenharmony_ci	} u;
2058c2ecf20Sopenharmony_ci};
2068c2ecf20Sopenharmony_ci
2078c2ecf20Sopenharmony_ci#define MAX_SG_ENTRY		255
2088c2ecf20Sopenharmony_ci
2098c2ecf20Sopenharmony_cistruct mvs_prd_imt {
2108c2ecf20Sopenharmony_ci#ifndef __BIG_ENDIAN
2118c2ecf20Sopenharmony_ci	__le32			len:22;
2128c2ecf20Sopenharmony_ci	u8			_r_a:2;
2138c2ecf20Sopenharmony_ci	u8			misc_ctl:4;
2148c2ecf20Sopenharmony_ci	u8			inter_sel:4;
2158c2ecf20Sopenharmony_ci#else
2168c2ecf20Sopenharmony_ci	u32			inter_sel:4;
2178c2ecf20Sopenharmony_ci	u32			misc_ctl:4;
2188c2ecf20Sopenharmony_ci	u32			_r_a:2;
2198c2ecf20Sopenharmony_ci	u32			len:22;
2208c2ecf20Sopenharmony_ci#endif
2218c2ecf20Sopenharmony_ci};
2228c2ecf20Sopenharmony_ci
2238c2ecf20Sopenharmony_cistruct mvs_prd {
2248c2ecf20Sopenharmony_ci	/* 64-bit buffer address */
2258c2ecf20Sopenharmony_ci	__le64			addr;
2268c2ecf20Sopenharmony_ci	/* 22-bit length */
2278c2ecf20Sopenharmony_ci	__le32			im_len;
2288c2ecf20Sopenharmony_ci} __attribute__ ((packed));
2298c2ecf20Sopenharmony_ci
2308c2ecf20Sopenharmony_cienum sgpio_registers {
2318c2ecf20Sopenharmony_ci	MVS_SGPIO_HOST_OFFSET	= 0x100,	/* offset between hosts */
2328c2ecf20Sopenharmony_ci
2338c2ecf20Sopenharmony_ci	MVS_SGPIO_CFG0	= 0xc200,
2348c2ecf20Sopenharmony_ci	MVS_SGPIO_CFG0_ENABLE	= (1 << 0),	/* enable pins */
2358c2ecf20Sopenharmony_ci	MVS_SGPIO_CFG0_BLINKB	= (1 << 1),	/* blink generators */
2368c2ecf20Sopenharmony_ci	MVS_SGPIO_CFG0_BLINKA	= (1 << 2),
2378c2ecf20Sopenharmony_ci	MVS_SGPIO_CFG0_INVSCLK	= (1 << 3),	/* invert signal? */
2388c2ecf20Sopenharmony_ci	MVS_SGPIO_CFG0_INVSLOAD	= (1 << 4),
2398c2ecf20Sopenharmony_ci	MVS_SGPIO_CFG0_INVSDOUT	= (1 << 5),
2408c2ecf20Sopenharmony_ci	MVS_SGPIO_CFG0_SLOAD_FALLEDGE = (1 << 6),	/* rise/fall edge? */
2418c2ecf20Sopenharmony_ci	MVS_SGPIO_CFG0_SDOUT_FALLEDGE = (1 << 7),
2428c2ecf20Sopenharmony_ci	MVS_SGPIO_CFG0_SDIN_RISEEDGE = (1 << 8),
2438c2ecf20Sopenharmony_ci	MVS_SGPIO_CFG0_MAN_BITLEN_SHIFT = 18,	/* bits/frame manual mode */
2448c2ecf20Sopenharmony_ci	MVS_SGPIO_CFG0_AUT_BITLEN_SHIFT = 24,	/* bits/frame auto mode */
2458c2ecf20Sopenharmony_ci
2468c2ecf20Sopenharmony_ci	MVS_SGPIO_CFG1	= 0xc204,	/* blink timing register */
2478c2ecf20Sopenharmony_ci	MVS_SGPIO_CFG1_LOWA_SHIFT	= 0,	/* A off time */
2488c2ecf20Sopenharmony_ci	MVS_SGPIO_CFG1_HIA_SHIFT	= 4,	/* A on time */
2498c2ecf20Sopenharmony_ci	MVS_SGPIO_CFG1_LOWB_SHIFT	= 8,	/* B off time */
2508c2ecf20Sopenharmony_ci	MVS_SGPIO_CFG1_HIB_SHIFT	= 12,	/* B on time */
2518c2ecf20Sopenharmony_ci	MVS_SGPIO_CFG1_MAXACTON_SHIFT	= 16,	/* max activity on time */
2528c2ecf20Sopenharmony_ci
2538c2ecf20Sopenharmony_ci		/* force activity off time */
2548c2ecf20Sopenharmony_ci	MVS_SGPIO_CFG1_FORCEACTOFF_SHIFT	= 20,
2558c2ecf20Sopenharmony_ci		/* stretch activity on time */
2568c2ecf20Sopenharmony_ci	MVS_SGPIO_CFG1_STRCHACTON_SHIFT	= 24,
2578c2ecf20Sopenharmony_ci		/* stretch activiity off time */
2588c2ecf20Sopenharmony_ci	MVS_SGPIO_CFG1_STRCHACTOFF_SHIFT	= 28,
2598c2ecf20Sopenharmony_ci
2608c2ecf20Sopenharmony_ci
2618c2ecf20Sopenharmony_ci	MVS_SGPIO_CFG2	= 0xc208,	/* clock speed register */
2628c2ecf20Sopenharmony_ci	MVS_SGPIO_CFG2_CLK_SHIFT	= 0,
2638c2ecf20Sopenharmony_ci	MVS_SGPIO_CFG2_BLINK_SHIFT	= 20,
2648c2ecf20Sopenharmony_ci
2658c2ecf20Sopenharmony_ci	MVS_SGPIO_CTRL	= 0xc20c,	/* SDOUT/SDIN mode control */
2668c2ecf20Sopenharmony_ci	MVS_SGPIO_CTRL_SDOUT_AUTO	= 2,
2678c2ecf20Sopenharmony_ci	MVS_SGPIO_CTRL_SDOUT_SHIFT	= 2,
2688c2ecf20Sopenharmony_ci
2698c2ecf20Sopenharmony_ci	MVS_SGPIO_DSRC	= 0xc220,	/* map ODn bits to drives */
2708c2ecf20Sopenharmony_ci
2718c2ecf20Sopenharmony_ci	MVS_SGPIO_DCTRL	= 0xc238,
2728c2ecf20Sopenharmony_ci	MVS_SGPIO_DCTRL_ERR_SHIFT	= 0,
2738c2ecf20Sopenharmony_ci	MVS_SGPIO_DCTRL_LOC_SHIFT	= 3,
2748c2ecf20Sopenharmony_ci	MVS_SGPIO_DCTRL_ACT_SHIFT	= 5,
2758c2ecf20Sopenharmony_ci};
2768c2ecf20Sopenharmony_ci
2778c2ecf20Sopenharmony_cienum sgpio_led_status {
2788c2ecf20Sopenharmony_ci	LED_OFF	= 0,
2798c2ecf20Sopenharmony_ci	LED_ON	= 1,
2808c2ecf20Sopenharmony_ci	LED_BLINKA	= 2,
2818c2ecf20Sopenharmony_ci	LED_BLINKA_INV	= 3,
2828c2ecf20Sopenharmony_ci	LED_BLINKA_SOF	= 4,
2838c2ecf20Sopenharmony_ci	LED_BLINKA_EOF	= 5,
2848c2ecf20Sopenharmony_ci	LED_BLINKB	= 6,
2858c2ecf20Sopenharmony_ci	LED_BLINKB_INV	= 7,
2868c2ecf20Sopenharmony_ci};
2878c2ecf20Sopenharmony_ci
2888c2ecf20Sopenharmony_ci#define DEFAULT_SGPIO_BITS ((LED_BLINKA_SOF << \
2898c2ecf20Sopenharmony_ci				MVS_SGPIO_DCTRL_ACT_SHIFT) << (8 * 3) | \
2908c2ecf20Sopenharmony_ci			(LED_BLINKA_SOF << \
2918c2ecf20Sopenharmony_ci				MVS_SGPIO_DCTRL_ACT_SHIFT) << (8 * 2) | \
2928c2ecf20Sopenharmony_ci			(LED_BLINKA_SOF << \
2938c2ecf20Sopenharmony_ci				MVS_SGPIO_DCTRL_ACT_SHIFT) << (8 * 1) | \
2948c2ecf20Sopenharmony_ci			(LED_BLINKA_SOF << \
2958c2ecf20Sopenharmony_ci				MVS_SGPIO_DCTRL_ACT_SHIFT) << (8 * 0))
2968c2ecf20Sopenharmony_ci
2978c2ecf20Sopenharmony_ci/*
2988c2ecf20Sopenharmony_ci * these registers are accessed through port vendor
2998c2ecf20Sopenharmony_ci * specific address/data registers
3008c2ecf20Sopenharmony_ci */
3018c2ecf20Sopenharmony_cienum sas_sata_phy_regs {
3028c2ecf20Sopenharmony_ci	GENERATION_1_SETTING		= 0x118,
3038c2ecf20Sopenharmony_ci	GENERATION_1_2_SETTING		= 0x11C,
3048c2ecf20Sopenharmony_ci	GENERATION_2_3_SETTING		= 0x120,
3058c2ecf20Sopenharmony_ci	GENERATION_3_4_SETTING		= 0x124,
3068c2ecf20Sopenharmony_ci};
3078c2ecf20Sopenharmony_ci
3088c2ecf20Sopenharmony_ci#define SPI_CTRL_REG_94XX           	0xc800
3098c2ecf20Sopenharmony_ci#define SPI_ADDR_REG_94XX            	0xc804
3108c2ecf20Sopenharmony_ci#define SPI_WR_DATA_REG_94XX         0xc808
3118c2ecf20Sopenharmony_ci#define SPI_RD_DATA_REG_94XX         	0xc80c
3128c2ecf20Sopenharmony_ci#define SPI_CTRL_READ_94XX         	(1U << 2)
3138c2ecf20Sopenharmony_ci#define SPI_ADDR_VLD_94XX         	(1U << 1)
3148c2ecf20Sopenharmony_ci#define SPI_CTRL_SpiStart_94XX     	(1U << 0)
3158c2ecf20Sopenharmony_ci
3168c2ecf20Sopenharmony_cistatic inline int
3178c2ecf20Sopenharmony_cimv_ffc64(u64 v)
3188c2ecf20Sopenharmony_ci{
3198c2ecf20Sopenharmony_ci	u64 x = ~v;
3208c2ecf20Sopenharmony_ci	return x ? __ffs64(x) : -1;
3218c2ecf20Sopenharmony_ci}
3228c2ecf20Sopenharmony_ci
3238c2ecf20Sopenharmony_ci#define r_reg_set_enable(i) \
3248c2ecf20Sopenharmony_ci	(((i) > 31) ? mr32(MVS_STP_REG_SET_1) : \
3258c2ecf20Sopenharmony_ci	mr32(MVS_STP_REG_SET_0))
3268c2ecf20Sopenharmony_ci
3278c2ecf20Sopenharmony_ci#define w_reg_set_enable(i, tmp) \
3288c2ecf20Sopenharmony_ci	(((i) > 31) ? mw32(MVS_STP_REG_SET_1, tmp) : \
3298c2ecf20Sopenharmony_ci	mw32(MVS_STP_REG_SET_0, tmp))
3308c2ecf20Sopenharmony_ci
3318c2ecf20Sopenharmony_ciextern const struct mvs_dispatch mvs_94xx_dispatch;
3328c2ecf20Sopenharmony_ci#endif
3338c2ecf20Sopenharmony_ci
334