si3124reg.h revision 12187:add6da833194
1279377Simp/* 2279377Simp * CDDL HEADER START 3279377Simp * 4279377Simp * The contents of this file are subject to the terms of the 5279377Simp * Common Development and Distribution License (the "License"). 6279377Simp * You may not use this file except in compliance with the License. 7279377Simp * 8279377Simp * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9279377Simp * or http://www.opensolaris.org/os/licensing. 10279377Simp * See the License for the specific language governing permissions 11279377Simp * and limitations under the License. 12279377Simp * 13279377Simp * When distributing Covered Code, include this CDDL HEADER in each 14279377Simp * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15279377Simp * If applicable, add the following below this CDDL HEADER, with the 16279377Simp * fields enclosed by brackets "[]" replaced with your own identifying 17279377Simp * information: Portions Copyright [yyyy] [name of copyright owner] 18279377Simp * 19279377Simp * CDDL HEADER END 20279377Simp */ 21279377Simp 22279377Simp/* 23279377Simp * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. 24279377Simp */ 25279377Simp 26279377Simp#ifndef _SI3124REG_H 27279377Simp#define _SI3124REG_H 28279377Simp 29279377Simp#ifdef __cplusplus 30279377Simpextern "C" { 31279377Simp#endif 32279377Simp 33279377Simp#pragma pack(1) 34279377Simp 35279377Simptypedef struct si_sge { 36279377Simp /* offset 0x00 */ 37279377Simp union { 38279377Simp uint64_t _sge_addr_ll; 39279377Simp uint32_t _sge_addr_la[2]; 40279377Simp } _sge_addr_un; 41279377Simp 42279377Simp#define sge_addr_low _sge_addr_un._sge_addr_la[0] 43279377Simp#define sge_addr_high _sge_addr_un._sge_addr_la[1] 44279377Simp#define sge_addr _sge_addr_un._sge_addr_ll 45279377Simp 46279377Simp /* offset 0x08 */ 47279377Simp uint32_t sge_data_count; 48279377Simp 49279377Simp /* offset 0x0c */ 50279377Simp uint32_t sge_trm_lnk_drd_xcf_rsvd; 51279377Simp 52279377Simp#define SET_SGE_LNK(sge) (sge.sge_trm_lnk_drd_xcf_rsvd = 0x40000000) 53279377Simp#define SET_SGE_TRM(sge) (sge.sge_trm_lnk_drd_xcf_rsvd = 0x80000000) 54279377Simp#define IS_SGE_TRM_SET(sge) (sge.sge_trm_lnk_drd_xcf_rsvd & 0x80000000) 55279377Simp 56279377Simp} si_sge_t; 57279377Simp 58279377Simp/* Scatter Gather Table consists of four SGE entries */ 59279377Simptypedef struct si_sgt { 60279377Simp si_sge_t sgt_sge[4]; 61279377Simp} si_sgt_t; 62279377Simp 63279377Simp 64279377Simp/* Register - Host to Device FIS (from SATA spec) */ 65279377Simptypedef struct fis_reg_h2d { 66279377Simp /* offset 0x00 */ 67279377Simp uint32_t fish_type_pmp_rsvd_cmddevctl_cmd_features; 68279377Simp 69279377Simp#define SET_FIS_TYPE(fis, type) \ 70279377Simp ((&fis)->fish_type_pmp_rsvd_cmddevctl_cmd_features |= (type & 0xff)) 71279377Simp 72279377Simp#define SET_FIS_PMP(fis, pmp) \ 73279377Simp ((&fis)->fish_type_pmp_rsvd_cmddevctl_cmd_features |= \ 74279377Simp ((pmp & 0xf) << 8)) 75279377Simp 76279377Simp#define SET_FIS_CDMDEVCTL(fis, cmddevctl) \ 77279377Simp ((&fis)->fish_type_pmp_rsvd_cmddevctl_cmd_features |= \ 78279377Simp ((cmddevctl & 0x1) << 15)) 79279377Simp 80279377Simp#define SET_FIS_COMMAND(fis, command) \ 81279377Simp ((&fis)->fish_type_pmp_rsvd_cmddevctl_cmd_features |= \ 82279377Simp ((command & 0xff) << 16)) 83279377Simp 84279377Simp#define GET_FIS_COMMAND(fis) \ 85279377Simp (((&fis)->fish_type_pmp_rsvd_cmddevctl_cmd_features >> 16) & 0xff) 86279377Simp 87279377Simp#define SET_FIS_FEATURES(fis, features) \ 88279377Simp ((&fis)->fish_type_pmp_rsvd_cmddevctl_cmd_features |= \ 89279377Simp ((features & 0xff) << 24)) 90279377Simp 91279377Simp#define GET_FIS_FEATURES(fis) \ 92279377Simp (((&fis)->fish_type_pmp_rsvd_cmddevctl_cmd_features >> 24) & 0xff) 93279377Simp 94279377Simp /* offset 0x04 */ 95279377Simp uint32_t fish_sector_cyllow_cylhi_devhead; 96279377Simp 97279377Simp#define SET_FIS_SECTOR(fis, sector) \ 98279377Simp ((&fis)->fish_sector_cyllow_cylhi_devhead |= ((sector & 0xff))) 99279377Simp 100279377Simp#define GET_FIS_SECTOR(fis) \ 101279377Simp ((&fis)->fish_sector_cyllow_cylhi_devhead & 0xff) 102279377Simp 103279377Simp#define SET_FIS_CYL_LOW(fis, cyl_low) \ 104279377Simp ((&fis)->fish_sector_cyllow_cylhi_devhead |= ((cyl_low & 0xff) << 8)) 105279377Simp 106279377Simp#define GET_FIS_CYL_LOW(fis) \ 107279377Simp (((&fis)->fish_sector_cyllow_cylhi_devhead >> 8) & 0xff) 108279377Simp 109279377Simp#define SET_FIS_CYL_HI(fis, cyl_hi) \ 110279377Simp ((&fis)->fish_sector_cyllow_cylhi_devhead |= ((cyl_hi & 0xff) << 16)) 111279377Simp 112279377Simp#define GET_FIS_CYL_HI(fis) \ 113279377Simp (((&fis)->fish_sector_cyllow_cylhi_devhead >> 16) & 0xff) 114279377Simp 115279377Simp#define SET_FIS_DEV_HEAD(fis, dev_head) \ 116279377Simp ((&fis)->fish_sector_cyllow_cylhi_devhead |= ((dev_head & 0xff) << 24)) 117279377Simp 118279377Simp#define GET_FIS_DEV_HEAD(fis) \ 119279377Simp (((&fis)->fish_sector_cyllow_cylhi_devhead >> 24) & 0xff) 120279377Simp 121279377Simp 122279377Simp /* offset 0x08 */ 123279377Simp uint32_t fish_sectexp_cyllowexp_cylhiexp_featuresexp; 124279377Simp 125279377Simp#define SET_FIS_SECTOR_EXP(fis, sectorexp) \ 126279377Simp ((&fis)->fish_sectexp_cyllowexp_cylhiexp_featuresexp |= \ 127279377Simp ((sectorexp & 0xff))) 128279377Simp 129279377Simp#define GET_FIS_SECTOR_EXP(fis) \ 130279377Simp ((&fis)->fish_sectexp_cyllowexp_cylhiexp_featuresexp & 0xff) 131279377Simp 132279377Simp#define SET_FIS_CYL_LOW_EXP(fis, cyllowexp) \ 133279377Simp ((&fis)->fish_sectexp_cyllowexp_cylhiexp_featuresexp |= \ 134279377Simp ((cyllowexp & 0xff) << 8)) 135279377Simp 136279377Simp#define GET_FIS_CYL_LOW_EXP(fis) \ 137279377Simp (((&fis)->fish_sectexp_cyllowexp_cylhiexp_featuresexp >> 8) & 0xff) 138279377Simp 139279377Simp#define SET_FIS_CYL_HI_EXP(fis, cylhiexp) \ 140279377Simp ((&fis)->fish_sectexp_cyllowexp_cylhiexp_featuresexp |= \ 141279377Simp ((cylhiexp & 0xff) << 16)) 142279377Simp 143279377Simp#define GET_FIS_CYL_HI_EXP(fis) \ 144279377Simp (((&fis)->fish_sectexp_cyllowexp_cylhiexp_featuresexp >> 16) & 0xff) 145279377Simp 146279377Simp#define SET_FIS_FEATURES_EXP(fis, features_exp) \ 147279377Simp ((&fis)->fish_sectexp_cyllowexp_cylhiexp_featuresexp |= \ 148279377Simp ((features_exp & 0xff) << 24)) 149279377Simp 150279377Simp /* offset 0x0c */ 151279377Simp uint32_t fish_sectcount_sectcountexp_rsvd_devctl; 152279377Simp 153279377Simp#define SET_FIS_SECTOR_COUNT(fis, sector_count) \ 154279377Simp ((&fis)->fish_sectcount_sectcountexp_rsvd_devctl |= \ 155279377Simp ((sector_count & 0xff))) 156279377Simp 157279377Simp#define GET_FIS_SECTOR_COUNT(fis) \ 158279377Simp ((&fis)->fish_sectcount_sectcountexp_rsvd_devctl & 0xff) 159279377Simp 160279377Simp#define SET_FIS_SECTOR_COUNT_EXP(fis, sector_count_exp) \ 161279377Simp ((&fis)->fish_sectcount_sectcountexp_rsvd_devctl |= \ 162279377Simp ((sector_count_exp & 0xff) << 8)) 163279377Simp 164279377Simp#define GET_FIS_SECTOR_COUNT_EXP(fis) \ 165279377Simp (((&fis)->fish_sectcount_sectcountexp_rsvd_devctl >> 8) & 0xff) 166279377Simp 167279377Simp#define SET_FIS_SECTOR_DEVCTL(fis, devctl) \ 168279377Simp ((&fis)->fish_sectcount_sectcountexp_rsvd_devctl |= \ 169279377Simp ((devctl & 0xff) << 24)) 170279377Simp 171279377Simp /* offset 0x10 */ 172279377Simp uint32_t fish_rsvd3; /* should be zero */ 173279377Simp} fis_reg_h2d_t; 174279377Simp 175279377Simp 176279377Simp 177279377Simp 178279377Simp/* 179279377Simp * Port Request Block 180279377Simp */ 181279377Simptypedef struct si_prb { 182279377Simp /* offset 0x00 */ 183279377Simp uint32_t prb_control_override; 184279377Simp 185279377Simp#define SET_PRB_CONTROL_PKT_READ(prb) \ 186279377Simp (prb->prb_control_override |= (0x1 << 4)) 187279377Simp 188279377Simp#define SET_PRB_CONTROL_PKT_WRITE(prb) \ 189279377Simp (prb->prb_control_override |= (0x1 << 5)) 190279377Simp 191279377Simp#define SET_PRB_CONTROL_SOFT_RESET(prb) \ 192279377Simp (prb->prb_control_override |= (0x1 << 7)) 193279377Simp 194279377Simp /* offset 0x04 */ 195279377Simp uint32_t prb_received_count; 196279377Simp 197279377Simp /* offset 0x08 */ 198279377Simp fis_reg_h2d_t prb_fis; /* this is of 0x14 bytes size */ 199279377Simp 200279377Simp /* offset 0x1c */ 201279377Simp uint32_t prb_rsvd3; 202279377Simp 203279377Simp /* offset 0x20 */ 204279377Simp si_sge_t prb_sge0; 205279377Simp 206279377Simp /* offset 0x30 */ 207279377Simp si_sge_t prb_sge1; 208279377Simp 209279377Simp} si_prb_t; 210279377Simp 211279377Simp#pragma pack() 212279377Simp 213279377Simp 214279377Simp/* Various interrupt bits */ 215279377Simp#define INTR_COMMAND_COMPLETE (0x1 << 0) 216279377Simp#define INTR_COMMAND_ERROR (0x1 << 1) 217279377Simp#define INTR_PORT_READY (0x1 << 2) 218279377Simp#define INTR_POWER_CHANGE (0x1 << 3) 219279377Simp#define INTR_PHYRDY_CHANGE (0x1 << 4) 220279377Simp#define INTR_COMWAKE_RECEIVED (0x1 << 5) 221279377Simp#define INTR_UNRECOG_FIS (0x1 << 6) 222279377Simp#define INTR_DEV_XCHANGED (0x1 << 7) 223279377Simp#define INTR_8B10B_DECODE_ERROR (0x1 << 8) 224279377Simp#define INTR_CRC_ERROR (0x1 << 9) 225279377Simp#define INTR_HANDSHAKE_ERROR (0x1 << 10) 226279377Simp#define INTR_SETDEVBITS_NOTIFY (0x1 << 11) 227279377Simp#define INTR_MASK (0xfff) 228279377Simp 229279377Simp/* Device signatures */ 230279377Simp#define SI_SIGNATURE_PORT_MULTIPLIER 0x96690101 231279377Simp#define SI_SIGNATURE_ATAPI 0xeb140101 232279377Simp#define SI_SIGNATURE_DISK 0x00000101 233279377Simp 234279377Simp 235279377Simp/* Global definitions */ 236279377Simp#define GLOBAL_OFFSET(si_ctlp) (si_ctlp->sictl_global_addr) 237279377Simp#define GLOBAL_CONTROL_REG(si_ctlp) (GLOBAL_OFFSET(si_ctlp)+0x40) 238279377Simp#define GLOBAL_INTERRUPT_STATUS(si_ctlp) (GLOBAL_OFFSET(si_ctlp)+0x44) 239279377Simp 240279377Simp/* Per port definitions */ 241279377Simp#define PORT_OFFSET(si_ctlp, port) (si_ctlp->sictl_port_addr + port*0x2000) 242279377Simp#define PORT_LRAM(si_ctlp, port, slot) \ 243279377Simp (PORT_OFFSET(si_ctlp, port) + 0x0 + slot*0x80) 244279377Simp#define PORT_CONTROL_SET(si_ctlp, port) \ 245279377Simp (PORT_OFFSET(si_ctlp, port) + 0x1000) 246279377Simp#define PORT_STATUS(si_ctlp, port) \ 247279377Simp (PORT_OFFSET(si_ctlp, port) + 0x1000) 248279377Simp#define PORT_CONTROL_CLEAR(si_ctlp, port) \ 249279377Simp (PORT_OFFSET(si_ctlp, port) + 0x1004) 250279377Simp#define PORT_INTERRUPT_STATUS(si_ctlp, port) \ 251279377Simp (PORT_OFFSET(si_ctlp, port) + 0x1008) 252279377Simp#define PORT_INTERRUPT_ENABLE_SET(si_ctlp, port) \ 253279377Simp (PORT_OFFSET(si_ctlp, port) + 0x1010) 254279377Simp#define PORT_INTERRUPT_ENABLE_CLEAR(si_ctlp, port) \ 255279377Simp (PORT_OFFSET(si_ctlp, port) + 0x1014) 256279377Simp#define PORT_COMMAND_ERROR(si_ctlp, port) \ 257279377Simp (PORT_OFFSET(si_ctlp, port) + 0x1024) 258279377Simp#define PORT_SLOT_STATUS(si_ctlp, port) (PORT_OFFSET(si_ctlp, port) + 0x1800) 259279377Simp 260279377Simp#define PORT_SCONTROL(si_ctlp, port) (PORT_OFFSET(si_ctlp, port) + 0x1f00) 261279377Simp#define PORT_SSTATUS(si_ctlp, port) (PORT_OFFSET(si_ctlp, port) + 0x1f04) 262279377Simp#define PORT_SERROR(si_ctlp, port) (PORT_OFFSET(si_ctlp, port) + 0x1f08) 263279377Simp#define PORT_SACTIVE(si_ctlp, port) (PORT_OFFSET(si_ctlp, port) + 0x1f0c) 264279377Simp 265279377Simp#define PORT_COMMAND_ACTIVATION(si_ctlp, port, slot) \ 266279377Simp (PORT_OFFSET(si_ctlp, port) + 0x1c00 + slot*0x8) 267279377Simp 268279377Simp#define PORT_SIGNATURE_MSB(si_ctlp, port, slot) \ 269279377Simp (PORT_OFFSET(si_ctlp, port) + slot*0x80 + 0x0c) 270279377Simp#define PORT_SIGNATURE_LSB(si_ctlp, port, slot) \ 271279377Simp (PORT_OFFSET(si_ctlp, port) + slot*0x80 + 0x14) 272279377Simp 273279377Simp/* Interesting bits of Port Control Set register */ 274279377Simp#define PORT_CONTROL_SET_BITS_PORT_RESET 0x1 275279377Simp#define PORT_CONTROL_SET_BITS_DEV_RESET 0x2 276279377Simp#define PORT_CONTROL_SET_BITS_PORT_INITIALIZE 0x4 277279377Simp#define PORT_CONTROL_SET_BITS_PACKET_LEN 0x20 278279377Simp#define PORT_CONTROL_SET_BITS_RESUME 0x40 279279377Simp#define PORT_CONTROL_SET_BITS_PM_ENABLE 0x2000 280279377Simp 281279377Simp/* Interesting bits of Port Control Clear register */ 282279377Simp#define PORT_CONTROL_CLEAR_BITS_PORT_RESET 0x1 283279377Simp#define PORT_CONTROL_CLEAR_BITS_INTR_NCoR 0x8 284279377Simp#define PORT_CONTROL_CLEAR_BITS_PACKET_LEN 0x20 285279377Simp#define PORT_CONTROL_CLEAR_BITS_RESUME 0x40 286279377Simp 287279377Simp/* Interesting bits of Port Status register */ 288279377Simp#define PORT_STATUS_BITS_PORT_READY 0x80000000 289279377Simp 290279377Simp/* Interesting bits of Global Control register */ 291279377Simp#define GLOBAL_CONTROL_REG_BITS_CLEAR 0x00000000 292279377Simp 293279377Simp#define POST_PRB_ADDR(si_ctlp, si_portp, port, slot) \ 294279377Simp (void) ddi_dma_sync(si_portp->siport_prbpool_dma_handle, \ 295279377Simp slot * sizeof (si_prb_t), \ 296279377Simp sizeof (si_prb_t), \ 297279377Simp DDI_DMA_SYNC_FORDEV); \ 298279377Simp \ 299279377Simp (void) ddi_dma_sync(si_portp->siport_sgbpool_dma_handle, \ 300279377Simp slot * sizeof (si_sgblock_t), \ 301279377Simp sizeof (si_sgblock_t), \ 302279377Simp DDI_DMA_SYNC_FORDEV); \ 303279377Simp \ 304279377Simp ddi_put64(si_ctlp->sictl_port_acc_handle, \ 305279377Simp (uint64_t *)PORT_COMMAND_ACTIVATION(si_ctlp, port, slot), \ 306279377Simp (uint64_t)(si_portp->siport_prbpool_physaddr + \ 307279377Simp slot*sizeof (si_prb_t))); 308279377Simp 309279377Simp#define SI_SLOT_MASK 0x7fffffff 310279377Simp#define SI_NUM_SLOTS 0x1f /* 31 */ 311279377Simp 312279377Simp#define ATTENTION_BIT 0x80000000 313279377Simp#define IS_ATTENTION_RAISED(slot_status) (slot_status & ATTENTION_BIT) 314279377Simp 315279377Simp#define SI3124_DEV_ID 0x3124 316279377Simp#define SI3132_DEV_ID 0x3132 317279377Simp 318279377Simp#define PM_CSR(devid) ((devid == SI3124_DEV_ID) ? 0x68 : 0x58) 319279377Simp 320279377Simp#define REGISTER_FIS_H2D 0x27 321279377Simp 322279377Simp#define SI31xx_INTR_PORT_MASK 0xf 323279377Simp 324279377Simp/* PCI BAR registers */ 325279377Simp#define PCI_BAR0 1 /* Contains global register set */ 326279377Simp#define PCI_BAR1 2 /* Contains port register set */ 327279377Simp 328279377Simp/* Port Status and Control Registers (from port multiplier spec) */ 329279377Simp#define PSCR_REG0 0 330279377Simp#define PSCR_REG1 1 331279377Simp#define PSCR_REG2 2 332279377Simp#define PSCR_REG3 3 333279377Simp 334279377Simp/* SStatus bit fields */ 335279377Simp#define SSTATUS_DET_MASK 0x0000000f 336279377Simp#define SSTATUS_SPD_MASK 0x000000f0 337279377Simp#define SSTATUS_SPD_SHIFT 4 338279377Simp#define SSTATUS_IPM_MASK 0x00000f00 339279377Simp#define SSTATUS_IPM_SHIFT 8 340279377Simp 341279377Simp 342279377Simp#define SSTATUS_DET_NODEV_NOPHY 0x0 /* No device, no PHY */ 343279377Simp#define SSTATUS_DET_DEVPRESENT_NOPHY 0x1 /* Dev present, no PHY */ 344279377Simp#define SSTATUS_DET_DEVPRESENT_PHYONLINE 0x3 /* Dev present, PHY online */ 345279377Simp 346279377Simp#define SSTATUS_IPM_NODEV_NOPHY 0x0 /* No dev, no PHY */ 347279377Simp#define SSTATUS_IPM_INTERFACE_ACTIVE 0x1 /* Interface active */ 348279377Simp#define SSTATUS_IPM_INTERFACE_POWERPARTIAL 0x2 /* partial power mgmnt */ 349279377Simp#define SSTATUS_IPM_INTERFACE_POWERSLUMBER 0x6 /* slumber power mgmt */ 350279377Simp 351279377Simp/* SControl bit fields */ 352279377Simp#define SCONTROL_DET_MASK 0x0000000f 353279377Simp 354279377Simp 355279377Simp 356279377Simp 357279377Simp/* Command Error codes */ 358279377Simp#define CMD_ERR_DEVICEERRROR 1 359279377Simp#define CMD_ERR_SDBERROR 2 360279377Simp#define CMD_ERR_DATAFISERROR 3 361279377Simp#define CMD_ERR_SENDFISERROR 4 362279377Simp#define CMD_ERR_INCONSISTENTSTATE 5 363279377Simp#define CMD_ERR_DIRECTIONERROR 6 364279377Simp#define CMD_ERR_UNDERRUNERROR 7 365279377Simp#define CMD_ERR_OVERRUNERROR 8 366279377Simp#define CMD_ERR_PACKETPROTOCOLERROR 11 367279377Simp#define CMD_ERR_PLDSGTERRORBOUNDARY 16 368279377Simp#define CMD_ERR_PLDSGTERRORTARETABORT 17 369279377Simp#define CMD_ERR_PLDSGTERRORMASTERABORT 18 370279377Simp#define CMD_ERR_PLDSGTERRORPCIERR 19 371279377Simp#define CMD_ERR_PLDCMDERRORBOUNDARY 24 372279377Simp#define CMD_ERR_PLDCMDERRORTARGETABORT 25 373279377Simp#define CMD_ERR_PLDCMDERRORMASTERABORT 26 374279377Simp#define CMD_ERR_PLDCMDERORPCIERR 27 375279377Simp#define CMD_ERR_PSDERRORTARGETABORT 33 376279377Simp#define CMD_ERR_PSDERRORMASTERABORT 34 377279377Simp#define CMD_ERR_PSDERRORPCIERR 35 378279377Simp#define CMD_ERR_SENDSERVICEERROR 36 379279377Simp 380279377Simp#ifdef __cplusplus 381279377Simp} 382279377Simp#endif 383279377Simp 384279377Simp#endif /* _SI3124REG_H */ 385279377Simp