1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright (c) 1999-2000 by Sun Microsystems, Inc. 24 * All rights reserved. 25 */ 26 27 #ifndef _SYS_1394_ADAPTERS_HCI1394_OHCI_H 28 #define _SYS_1394_ADAPTERS_HCI1394_OHCI_H 29 30 #pragma ident "%Z%%M% %I% %E% SMI" 31 32 /* 33 * hci1394_ohci.h 34 * Provides access macros and routines to the OpenHCI HW. 35 */ 36 37 #ifdef __cplusplus 38 extern "C" { 39 #endif 40 41 #include <sys/ddi.h> 42 #include <sys/modctl.h> 43 #include <sys/sunddi.h> 44 #include <sys/types.h> 45 #include <sys/note.h> 46 47 #include <sys/1394/adapters/hci1394_def.h> 48 #include <sys/1394/adapters/hci1394_buf.h> 49 50 51 #define OHCI_MAX_SELFID_SIZE 2048 52 #define OHCI_BUSGEN_MAX 0xFF 53 54 55 /* Misc */ 56 #define OHCI_REG_SET 1 /* ddi_regs_map_setup */ 57 #define OHCI_CHIP_RESET_TIME_IN_uSEC ((clock_t)100) /* 100uS */ 58 #define OHCI_BUS_RESET_TIME_IN_uSEC ((clock_t)100000) /* 100mS */ 59 #define OHCI_MAX_COOKIE 16 60 #define OHCI_uS_PER_BUS_CYCLE 125 61 #define OHCI_nS_PER_BUS_CYCLE 125000 62 #define OHCI_BUS_CYCLE_TO_uS(cycles) (cycles * OHCI_uS_PER_BUS_CYCLE) 63 #define OHCI_BUS_CYCLE_TO_nS(cycles) (cycles * OHCI_nS_PER_BUS_CYCLE) 64 #define OHCI_CYCLE_SEC_SHIFT 13 65 #define OHCI_CYCLE_SEC_MASK 0xE000 66 #define OHCI_CYCLE_CNT_MASK 0x1FFF 67 #define OHCI_MAX_CYCLE_CNT 8000 68 #define OHCI_TIMESTAMP_MASK 0xFFFF 69 #define OHCI_REG_ADDR_MASK 0x7FC 70 71 /* OpenHCI Global Swap location in PCI space */ 72 #define OHCI_PCI_HCI_CONTROL_REG ((off_t)0x40) 73 #define OHCI_PCI_GLOBAL_SWAP 0x00000001 74 75 76 /* PHY Register #1 */ 77 #define OHCI_PHY_RHB 0x80 78 #define OHCI_PHY_IBR 0x40 79 #define OHCI_PHY_MAX_GAP 0x3F 80 81 /* PHY Register #4 */ 82 #define OHCI_PHY_EXTND_MASK 0xE0 83 #define OHCI_PHY_EXTND 0xE0 84 85 /* PHY Register #4 */ 86 #define OHCI_PHY_CNTDR 0x40 87 88 /* PHY Register #5 */ 89 #define OHCI_PHY_ISBR 0x40 90 #define OHCI_PHY_LOOP_ERR 0x20 91 #define OHCI_PHY_PWRFAIL_ERR 0x10 92 #define OHCI_PHY_TIMEOUT_ERR 0x08 93 #define OHCI_PHY_PORTEVT_ERR 0x04 94 #define OHCI_PHY_ENBL_ACCEL 0x02 95 #define OHCI_PHY_ENBL_MULTI 0x01 96 97 /* OpenHCI Event Codes. Refer to OHCI 1.0 section 3.1.1 */ 98 #define OHCI_EVT_NO_STATUS 0x0 99 #define OHCI_EVT_LONG_PACKET 0x2 100 #define OHCI_EVT_MISSING_ACK 0x3 101 #define OHCI_EVT_UNDERRUN 0x4 102 #define OHCI_EVT_OVERRUN 0x5 103 #define OHCI_EVT_DESCRIPTOR_READ 0x6 104 #define OHCI_EVT_DATA_READ 0x7 105 #define OHCI_EVT_DATA_WRITE 0x8 106 #define OHCI_EVT_BUS_RESET 0x9 107 #define OHCI_EVT_TIMEOUT 0xA 108 #define OHCI_EVT_TCODE_ERR 0xB 109 #define OHCI_EVT_UNKNOWN 0xE 110 #define OHCI_EVT_FLUSHED 0xF 111 #define OHCI_ACK_COMPLETE 0x11 112 #define OHCI_ACK_PENDING 0x12 113 #define OHCI_ACK_BUSY_X 0x14 114 #define OHCI_ACK_BUSY_A 0x15 115 #define OHCI_ACK_BUSY_B 0x16 116 #define OHCI_ACK_TARDY 0x1B 117 #define OHCI_ACK_CONFLICT_ERROR 0x1C 118 #define OHCI_ACK_DATA_ERROR 0x1D 119 #define OHCI_ACK_TYPE_ERROR 0x1E 120 #define OHCI_ACK_ADDRESS_ERROR 0x1F 121 122 #define OHCI_REG_NODEID_ROOT 0x40000000 123 #define OHCI_REG_BUSOPTIONS_CMC 0x40000000 124 125 /* hci_regs_s.ir_ctxt_regs.ctxt_match */ 126 #define OHCI_MTC_TAG3_MASK 0x80000000 127 #define OHCI_MTC_TAG3_SHIFT 31 128 #define OHCI_MTC_TAG2_MASK 0x40000000 129 #define OHCI_MTC_TAG2_SHIFT 30 130 #define OHCI_MTC_TAG1_MASK 0x20000000 131 #define OHCI_MTC_TAG1_SHIFT 29 132 #define OHCI_MTC_TAG0_MASK 0x10000000 133 #define OHCI_MTC_TAG0_SHIFT 28 134 #define OHCI_MTC_MATCH_MASK 0x07FFF000 135 #define OHCI_MTC_MATCH_SHIFT 12 136 #define OHCI_MTC_SYNC_MASK 0x00000F00 137 #define OHCI_MTC_SYNC_SHIFT 8 138 #define OHCI_MTC_TAG1SY_MASK 0x00000040 139 #define OHCI_MTC_TAG1SY_SHIFT 6 140 #define OHCI_MTC_CHAN_MASK 0x0000003F 141 #define OHCI_MTC_CHAN_SHIFT 0 142 143 /* hci_regs_s.self_id_buflo - See OpenHCI 1.00 section 11.1 */ 144 #define OHCI_SLF_BUF_LO 0xFFFFF800 145 146 /* hci_regs_s.self_id_count - See OpenHCI 1.00 section 11.2 */ 147 #define OHCI_SLFC_ERROR 0x80000000 148 #define OHCI_SLFC_GEN_MASK 0x00FF0000 149 #define OHCI_SLFC_GEN_SHIFT 16 150 #define OHCI_SLFC_NUM_QUADS_MASK 0x00001FFC 151 152 153 /* 154 * hci_regs_s.int_event_* and hci_regs_s.int_mask_* 155 * See OpenHCI 1.00 section 6 156 */ 157 #define OHCI_INTR_REQ_TX_CMPLT 0x00000001 158 #define OHCI_INTR_RESP_TX_CMPLT 0x00000002 159 #define OHCI_INTR_ARRQ 0x00000004 160 #define OHCI_INTR_ARRS 0x00000008 161 #define OHCI_INTR_RQPKT 0x00000010 162 #define OHCI_INTR_RSPKT 0x00000020 163 #define OHCI_INTR_ISOCH_TX 0x00000040 /* RO */ 164 #define OHCI_INTR_ISOCH_RX 0x00000080 /* RO */ 165 #define OHCI_INTR_POST_WR_ERR 0x00000100 166 #define OHCI_INTR_LOCK_RESP_ERR 0x00000200 167 #define OHCI_INTR_SELFID_CMPLT 0x00010000 168 #define OHCI_INTR_BUS_RESET 0x00020000 169 #define OHCI_INTR_PHY 0x00080000 170 #define OHCI_INTR_CYC_SYNCH 0x00100000 171 #define OHCI_INTR_CYC_64_SECS 0x00200000 172 #define OHCI_INTR_CYC_LOST 0x00400000 173 #define OHCI_INTR_CYC_INCONSISTENT 0x00800000 174 #define OHCI_INTR_UNRECOVERABLE_ERR 0x01000000 175 #define OHCI_INTR_CYC_TOO_LONG 0x02000000 176 #define OHCI_INTR_PHY_REG_RCVD 0x04000000 177 #define OHCI_INTR_VENDOR_SPECIFIC 0x40000000 178 #define OHCI_INTR_MASTER_INTR_ENBL 0x80000000 /* int_mask_* only */ 179 180 /* hci_regs_s.fairness_ctrl - See OpenHCI 1.00 section 5.8 */ 181 #define OHCI_FAIR_PRI_REQ 0x000000FF 182 183 /* hci_regs_s.link_ctrl_set/clr - See OpenHCI 1.00 section 5.9 */ 184 #define OHCI_LC_CYC_SRC 0x00400000 185 #define OHCI_LC_CYC_MAST 0x00200000 186 #define OHCI_LC_CTIME_ENBL 0x00100000 187 #define OHCI_LC_RCV_PHY 0x00000400 188 #define OHCI_LC_RCV_SELF 0x00000200 189 #define OHCI_LC_CYC_SYNC 0x00000010 190 191 /* Defines for registers in HCI register space */ 192 /* Note: bits are read/write unless otherwise noted (RO-read only) */ 193 194 /* hci_regs_s.version - See OpenHCI 1.00 section 5.2 */ 195 #define OHCI_VER_GUID_ROM 0x01000000 196 #define OHCI_VER_VERSION_MASK 0x00FF0000 197 #define OHCI_VER_VERSION_SHIFT 16 198 #define OHCI_VER_REVISION_MASK 0x000000FF 199 #define OHCI_VERSION(version) \ 200 ((version & OHCI_VER_VERSION_MASK) >> OHCI_VER_VERSION_SHIFT) 201 #define OHCI_REVISION(revision) \ 202 (revision & OHCI_VER_REVISION_MASK) 203 204 /* hci_regs_s.guid_rom - See OpenHCI 1.00 section 5.3 */ 205 #define OHCI_GROM_ADDR_RESET 0x80000000 /* 1-initiate reset */ 206 #define OHCI_GROM_RD_START 0x02000000 /* 1-start byte read */ 207 #define OHCI_GROM_RD_DATA 0x00FF0000 /* RO */ 208 209 /* hci_regs_s.at_retries - See OpenHCI 1.00 section 5.4 */ 210 #define OHCI_RET_SECLIM_MASK 0xE0000000 /* dual-phase retry */ 211 #define OHCI_RET_SECLIM_SHIFT 29 212 #define OHCI_RET_CYCLLIM_MASK 0xFFFF0000 /* dual-phase retry */ 213 #define OHCI_RET_CYCLLIM_SHIFT 16 214 #define OHCI_RET_MAX_PHYS_RESP_MASK 0x00000F00 /* physical resp rtry */ 215 #define OHCI_RET_MAX_PHYS_RESP_SHIFT 8 216 #define OHCI_RET_MAX_ATRESP_MASK 0x000000F0 /* AT response retry */ 217 #define OHCI_RET_MAX_ATRESP_SHIFT 4 218 #define OHCI_RET_MAX_ATREQ_MASK 0x0000000F /* AT request retry */ 219 #define OHCI_RET_MAX_ATREQ_SHIFT 0 220 221 /* hci_regs_s.csr_ctrl - See OpenHCI 1.00 section 5.5.1 */ 222 #define OHCI_CSR_DONE 0x80000000 /* RO 1-cmp_swap complete */ 223 #define OHCI_CSR_SELECT 0x00000003 224 225 #define OHCI_CSR_SEL_BUS_MGR_ID 0 /* bus manager ID register */ 226 #define OHCI_CSR_SEL_BANDWIDTH_AVAIL 1 /* bandwidth available reg */ 227 #define OHCI_CSR_SEL_CHANS_AVAIL_HI 2 /* channels_available_hi reg */ 228 #define OHCI_CSR_SEL_CHANS_AVAIL_LO 3 /* channels_available_lo reg */ 229 230 /* hci_regs_s.config_rom_hdr - See OpenHCI 1.00 section 5.5.6 */ 231 #define OHCI_CROM_INFO_LEN 0xFF000000 232 #define OHCI_CROM_CRC_LEN 0x00FF0000 233 #define OHCI_CROM_ROM_CRC_VAL 0x0000FFFF 234 235 /* hci_regs_s.bus_options - See OpenHCI 1.00 section 5.5.4 */ 236 #define OHCI_BOPT_IRMC 0x80000000 /* Isoch resrce mgr capable */ 237 #define OHCI_BOPT_CMC 0x40000000 /* cycle master capable */ 238 #define OHCI_BOPT_ISC 0x20000000 /* isochronous data capable */ 239 #define OHCI_BOPT_BMC 0x10000000 /* bus manager capable */ 240 #define OHCI_BOPT_PMC 0x80000000 /* power manager capable */ 241 #define OHCI_BOPT_CYC_CLK_ACC 0x00FF0000 242 #define OHCI_BOPT_MAX_REC 0x0000F000 243 #define OHCI_BOPT_GEN 0x000000C0 244 #define OHCI_BOPT_LINK_SPD 0x00000007 245 246 /* hci_regs_s.guid_hi - See OpenHCI 1.00 section 5.5.5 */ 247 #define OHCI_GUID_NODE_VENDOR_ID 0xFFFFFF00 248 #define OHCI_GUID_CHIP_ID_HI 0x000000FF 249 250 /* hci_regs_s.config_rom_maplo - See OpenHCI 1.00 section 5.5.6 */ 251 #define OHCI_CMAP_ADDR 0xFFFFFF00 /* 1k aligned */ 252 253 /* hci_regs_s.posted_write_addrhi - See OpenHCI 1.00 section 13.2.8.1 */ 254 #define OHCI_POST_SOURCE_ID 0xFFFF0000 255 #define OHCI_POST_OFFSET_HI 0x0000FFFF 256 257 /* hci_regs_s.vendor_id - See OpenHCI 1.00 section 5.2 */ 258 #define OHCI_VEND_ID 0x00FFFFFF 259 #define OHCI_VEND_UNIQUE 0xFF000000 260 261 /* hci_regs_s.hc_ctrl_set/clr - See OpenHCI 1.00 section 5.7 */ 262 #define OHCI_HC_NO_BSWAP 0x40000000 /* 1-big endian,0-little end */ 263 #define OHCI_HC_PROG_PHY_ENBL 0x00800000 /* 1-prog phy capabilities */ 264 #define OHCI_HC_APHY_ENBL 0x00040000 /* 1-Aphy enhancements enbld */ 265 #define OHCI_HC_LPS 0x00080000 /* 1-link pwr on, 0-off */ 266 #define OHCI_HC_POSTWR_ENBL 0x00040000 /* 1-enabled, 0-disabled */ 267 #define OHCI_HC_LINK_ENBL 0x00020000 /* 1-enabled, 0-disabled */ 268 #define OHCI_HC_SOFT_RESET 0x00010000 /* 1-reset in prog, 0-done */ 269 270 /* hci_regs_s.node_id - See OpenHCI 1.00 section 5.10 */ 271 #define OHCI_NDID_IDVALID 0x80000000 272 #define OHCI_NDID_ROOT_MASK 0x40000000 273 #define OHCI_NDID_ROOT_SHIFT 30 274 #define OHCI_NDID_CPS_MASK 0x08000000 275 #define OHCI_NDID_CPS_SHIFT 27 276 #define OHCI_NDID_BUSNUM_MASK 0x0000FFC0 277 #define OHCI_NDID_BUSNUM_SHIFT 6 278 #define OHCI_NDID_NODENUM_MASK 0x0000003F 279 #define OHCI_NDID_NODENUM_SHIFT 0 280 281 /* hci_regs_s.phy_ctrl - See OpenHCI 1.00 section 5.11, 1394-1994 J.4.1 */ 282 #define OHCI_PHYC_RDDONE 0x80000000 283 #define OHCI_PHYC_RDREG 0x00008000 284 #define OHCI_PHYC_WRREG 0x00004000 285 #define OHCI_PHYC_RDADDR_MASK 0x0F000000 286 #define OHCI_PHYC_RDADDR_SHIFT 24 287 #define OHCI_PHYC_RDDATA_MASK 0x00FF0000 288 #define OHCI_PHYC_RDDATA_SHIFT 16 289 #define OHCI_PHYC_REGADDR_MASK 0x00000F00 290 #define OHCI_PHYC_REGADDR_SHIFT 8 291 #define OHCI_PHYC_WRDATA_MASK 0x000000FF 292 #define OHCI_PHYC_WRDATA_SHIFT 0 293 294 /* hci_regs_s.context_ctrl -- several contexts */ 295 #define OHCI_CC_RUN_MASK 0x00008000 296 #define OHCI_CC_RUN_SHIFT 15 297 #define OHCI_CC_WAKE_MASK 0x00001000 298 #define OHCI_CC_WAKE_SHIFT 12 299 #define OHCI_CC_DEAD_MASK 0x00000800 300 #define OHCI_CC_DEAD_SHIFT 11 301 #define OHCI_CC_ACTIVE_MASK 0x00000400 302 #define OHCI_CC_ACTIVE_SHIFT 10 303 304 #define OHCI_CC_SPD_MASK 0x000000E0 305 #define OHCI_CC_SPD_SHIFT 5 306 #define OHCI_CC_EVT_MASK 0x0000001F 307 #define OHCI_CC_EVT_SHIFT 0 308 309 /* hci_regs context_ctrl for IR */ 310 #define OHCI_IRCTL_BFILL_MASK 0x80000000 311 #define OHCI_IRCTL_BFILL_SHIFT 31 312 #define OHCI_IRCTL_IHDR_MASK 0x40000000 313 #define OHCI_IRCTL_IHDR_SHIFT 30 314 #define OHCI_IRCTL_MTC_ENBL_MASK 0x20000000 315 #define OHCI_IRCTL_MTC_ENBL_SHIFT 29 316 #define OHCI_IRCTL_MULTI_MASK 0x10000000 317 #define OHCI_IRCTL_MULTI_SHIFT 28 318 319 /* hci_regs context_ctrl for IT */ 320 #define OHCI_ITCTL_MTC_ENBL_MASK 0x80000000 321 #define OHCI_ITCTL_MTC_ENBL_SHIFT 31 322 #define OHCI_ITCTL_MATCH_MASK 0x7FFF0000 323 #define OHCI_ITCTL_MATCH_SHIFT 16 324 325 326 #define HCI1394_IS_ARRESP(tcode) \ 327 ((tcode == IEEE1394_TCODE_WRITE_RESP) || \ 328 (tcode == IEEE1394_TCODE_READ_QUADLET_RESP) || \ 329 (tcode == IEEE1394_TCODE_READ_BLOCK_RESP) || \ 330 (tcode == IEEE1394_TCODE_LOCK_RESP)) 331 332 #define HCI1394_IS_ARREQ(tcode) \ 333 ((tcode == IEEE1394_TCODE_READ_QUADLET) || \ 334 (tcode == IEEE1394_TCODE_WRITE_QUADLET) || \ 335 (tcode == IEEE1394_TCODE_READ_BLOCK) || \ 336 (tcode == IEEE1394_TCODE_WRITE_BLOCK) || \ 337 (tcode == IEEE1394_TCODE_LOCK) || \ 338 (tcode == IEEE1394_TCODE_PHY)) 339 340 #define HCI1394_IRCTXT_CTRL_SET(HCIP, I, BFFILL, IHDR, MATCHENBL, MULTI, RUN, \ 341 WAKE) (ddi_put32((HCIP)->ohci->ohci_reg_handle, \ 342 &(HCIP)->ohci->ohci_regs->ir[(I)].ctxt_ctrl_set, \ 343 0 | (((BFFILL) << OHCI_IRCTL_BFILL_SHIFT) & OHCI_IRCTL_BFILL_MASK) | \ 344 (((IHDR) << OHCI_IRCTL_IHDR_SHIFT) & OHCI_IRCTL_IHDR_MASK) | \ 345 (((MATCHENBL) << OHCI_IRCTL_MTC_ENBL_SHIFT) & \ 346 OHCI_IRCTL_MTC_ENBL_MASK) | \ 347 (((MULTI) << OHCI_IRCTL_MULTI_SHIFT) & OHCI_IRCTL_MULTI_MASK) | \ 348 (((RUN) << OHCI_CC_RUN_SHIFT) & OHCI_CC_RUN_MASK) | \ 349 (((WAKE) << OHCI_CC_WAKE_SHIFT) & OHCI_CC_WAKE_MASK))) 350 351 #define HCI1394_IRCTXT_CTRL_CLR(HCIP, I, BFFILL, IHDR, MATCHENBL, MULTI, RUN) \ 352 (ddi_put32((HCIP)->ohci->ohci_reg_handle, \ 353 &(HCIP)->ohci->ohci_regs->ir[(I)].ctxt_ctrl_clr, \ 354 0 | (((BFFILL) << OHCI_IRCTL_BFILL_SHIFT) & OHCI_IRCTL_BFILL_MASK) | \ 355 (((IHDR) << OHCI_IRCTL_IHDR_SHIFT) & OHCI_IRCTL_IHDR_MASK) | \ 356 (((MATCHENBL) << OHCI_IRCTL_MTC_ENBL_SHIFT) & \ 357 OHCI_IRCTL_MTC_ENBL_MASK) | \ 358 (((MULTI) << OHCI_IRCTL_MULTI_SHIFT) & OHCI_IRCTL_MULTI_MASK) | \ 359 (((RUN) << OHCI_CC_RUN_SHIFT) & OHCI_CC_RUN_MASK))) 360 361 #define HCI1394_ITCTXT_CTRL_SET(HCIP, I, MATCHENBL, MATCH, RUN, WAKE) \ 362 (ddi_put32((HCIP)->ohci->ohci_reg_handle, \ 363 &(HCIP)->ohci->ohci_regs->it[(I)].ctxt_ctrl_set, 0 | \ 364 (((MATCHENBL) << OHCI_ITCTL_MTC_ENBL_SHIFT) & \ 365 OHCI_ITCTL_MTC_ENBL_MASK) | \ 366 (((MATCH) << OHCI_ITCTL_MATCH_SHIFT) & OHCI_ITCTL_MATCH_MASK) | \ 367 (((RUN) << OHCI_CC_RUN_SHIFT) & OHCI_CC_RUN_MASK) | \ 368 (((WAKE) << OHCI_CC_WAKE_SHIFT) & OHCI_CC_WAKE_MASK))) 369 370 #define HCI1394_ITCTXT_CTRL_CLR(HCIP, I, MATCHENBL, MATCH, RUN) \ 371 (ddi_put32((HCIP)->ohci->ohci_reg_handle, \ 372 &(HCIP)->ohci->ohci_regs->it[(I)].ctxt_ctrl_clr, 0 | \ 373 (((MATCHENBL) << OHCI_ITCTL_MTC_ENBL_SHIFT) & \ 374 OHCI_ITCTL_MTC_ENBL_MASK) | \ 375 (((MATCH) << OHCI_ITCTL_MATCH_SHIFT) & OHCI_ITCTL_MATCH_MASK) | \ 376 (((RUN) << OHCI_CC_RUN_SHIFT) & OHCI_CC_RUN_MASK))) 377 378 379 #define HCI1394_IRCTXT_MATCH_WRITE(HCIP, I, TAG3, TAG2, TAG1, TAG0, MATCH, \ 380 SYNC, TAG1SYNC, CHAN) (ddi_put32((HCIP)->ohci->ohci_reg_handle, \ 381 &(HCIP)->ohci->ohci_regs->ir[(I)].ctxt_match, 0 | \ 382 (((TAG3) << OHCI_MTC_TAG3_SHIFT) & OHCI_MTC_TAG3_MASK) | \ 383 (((TAG2) << OHCI_MTC_TAG2_SHIFT) & OHCI_MTC_TAG2_MASK) | \ 384 (((TAG1) << OHCI_MTC_TAG1_SHIFT) & OHCI_MTC_TAG1_MASK) | \ 385 (((TAG0) << OHCI_MTC_TAG0_SHIFT) & OHCI_MTC_TAG0_MASK) | \ 386 (((MATCH) << OHCI_MTC_MATCH_SHIFT) & OHCI_MTC_MATCH_MASK) | \ 387 (((SYNC) << OHCI_MTC_SYNC_SHIFT) & OHCI_MTC_SYNC_MASK) | \ 388 (((TAG1SYNC) << OHCI_MTC_TAG1SY_SHIFT) & OHCI_MTC_TAG1SY_MASK) | \ 389 (((CHAN) << OHCI_MTC_CHAN_SHIFT) & OHCI_MTC_CHAN_MASK))) 390 391 #define HCI1394_ISOCH_CTXT_ACTIVE(SOFTSTATEP, CTXTP) \ 392 (ddi_get32((SOFTSTATEP)->ohci->ohci_reg_handle, \ 393 &(CTXTP)->ctxt_regsp->ctxt_ctrl_set) & OHCI_CC_ACTIVE_MASK) 394 395 #define HCI1394_ISOCH_CTXT_RUN(SOFTSTATEP, CTXTP) \ 396 (ddi_get32((SOFTSTATEP)->ohci->ohci_reg_handle, \ 397 &(CTXTP)->ctxt_regsp->ctxt_ctrl_set) & OHCI_CC_RUN_MASK) 398 399 #define HCI1394_ISOCH_CTXT_CMD_PTR(SOFTSTATEP, CTXTP) \ 400 (ddi_get32((SOFTSTATEP)->ohci->ohci_reg_handle, \ 401 &(CTXTP)->ctxt_regsp->cmd_ptrlo)) 402 403 /* 404 * 1394 OpenHCI 1.0 general context register layout 405 * All contexts except for Isoch Receive have the following layout 406 * See the OpenHCI v1.0 specification for register definitions. 407 */ 408 typedef struct hci1394_ctxt_regs_s { 409 uint32_t ctxt_ctrl_set; 410 uint32_t ctxt_ctrl_clr; 411 uint32_t reserved; 412 uint32_t cmd_ptrlo; 413 } hci1394_ctxt_regs_t; 414 415 /* 416 * 1394 OpenHCI 1.0 Isochronous Receive context register layout 417 * See the OpenHCI v1.0 specification for register definitions. 418 */ 419 typedef struct hci1394_ir_ctxt_regs_s { 420 uint32_t ctxt_ctrl_set; 421 uint32_t ctxt_ctrl_clr; 422 uint32_t reserved0; 423 uint32_t cmd_ptrlo; 424 uint32_t ctxt_match; 425 uint32_t reserved1[3]; 426 } hci1394_ir_ctxt_regs_t; 427 428 /* 429 * 1394 OpenHCI 1.0 registers 430 * See the OpenHCI v1.0 specification for register definitions. 431 */ 432 typedef struct hci1394_regs_s { 433 uint32_t version; 434 uint32_t guid_rom; 435 uint32_t at_retries; 436 uint32_t csr_data; 437 uint32_t csr_compare_data; 438 uint32_t csr_ctrl; 439 uint32_t config_rom_hdr; 440 uint32_t bus_id; 441 uint32_t bus_options; 442 uint32_t guid_hi; 443 uint32_t guid_lo; 444 uint32_t reserved01; 445 uint32_t reserved02; 446 uint32_t config_rom_maplo; 447 uint32_t posted_write_addrlo; 448 uint32_t posted_write_addrhi; 449 uint32_t vendor_id; 450 uint32_t reserved03[3]; 451 uint32_t hc_ctrl_set; 452 uint32_t hc_ctrl_clr; 453 uint32_t reserved06[2]; 454 uint32_t reserved08; 455 uint32_t self_id_buflo; 456 uint32_t self_id_count; 457 uint32_t reserved09; 458 uint32_t ir_multi_maskhi_set; 459 uint32_t ir_multi_maskhi_clr; 460 uint32_t ir_multi_masklo_set; 461 uint32_t ir_multi_masklo_clr; 462 uint32_t intr_event_set; 463 uint32_t intr_event_clr; 464 uint32_t intr_mask_set; 465 uint32_t intr_mask_clr; 466 uint32_t it_intr_event_set; 467 uint32_t it_intr_event_clr; 468 uint32_t it_intr_mask_set; 469 uint32_t it_intr_mask_clr; 470 uint32_t ir_intr_event_set; 471 uint32_t ir_intr_event_clr; 472 uint32_t ir_intr_mask_set; 473 uint32_t ir_intr_mask_clr; 474 uint32_t reserved10[11]; 475 uint32_t fairness_ctrl; 476 uint32_t link_ctrl_set; 477 uint32_t link_ctrl_clr; 478 uint32_t node_id; 479 uint32_t phy_ctrl; 480 uint32_t isoch_cycle_timer; 481 uint32_t reserved21[3]; 482 uint32_t ar_req_filterhi_set; 483 uint32_t ar_req_filterhi_clr; 484 uint32_t ar_req_filterlo_set; 485 uint32_t ar_req_filterlo_clr; 486 uint32_t phys_req_filterhi_set; 487 uint32_t phys_req_filterhi_clr; 488 uint32_t phys_req_filterlo_set; 489 uint32_t phys_req_filterlo_clr; 490 uint32_t phys_upper_bound; 491 uint32_t reserved24[23]; 492 hci1394_ctxt_regs_t at_req; 493 uint32_t reserved47[4]; 494 hci1394_ctxt_regs_t at_resp; 495 uint32_t reserved51[4]; 496 hci1394_ctxt_regs_t ar_req; 497 uint32_t reserved55[4]; 498 hci1394_ctxt_regs_t ar_resp; 499 uint32_t reserved59[4]; 500 hci1394_ctxt_regs_t it[HCI1394_MAX_ISOCH_CONTEXTS]; 501 hci1394_ir_ctxt_regs_t ir[HCI1394_MAX_ISOCH_CONTEXTS]; 502 } hci1394_regs_t; 503 504 505 /* private structure to keep track of OpenHCI */ 506 typedef struct hci1394_ohci_s { 507 /* config ROM and selfid buffers */ 508 hci1394_buf_handle_t ohci_cfgrom_handle; 509 hci1394_buf_handle_t ohci_selfid_handle; 510 511 /* 512 * Phy register #1 cached settings. These are only used for 1394-1995 513 * phy's. When setting the root holdoff bit and gap count in 1394, 514 * you send out a PHY configuration packet. The 1995 PHY's will 515 * not look at the PHY packet if we sent it out which means we have 516 * to write directly to PHY register 1. This creates some ugly race 517 * conditions. Since we will be following up these settings with a bus 518 * reset shortly, we "cache" them until we generate the bus reset. This 519 * solution is not perfect, but it is the best of a bad thing. 520 */ 521 boolean_t ohci_set_root_holdoff; 522 boolean_t ohci_set_gap_count; 523 uint_t ohci_gap_count; 524 525 /* 526 * The bus time is kept using the cycle timer and then counting the 527 * rollovers via the cycle 64 seconds interrupt. (NOTE: every 2 528 * interrupts is one rollover) We do not wish to be interrupting 529 * the CPU if there is nothing plugged into the bus (since bus time 530 * really isn't used for anything yet (maybe when bridges come out?)). 531 * We will start with the interrupt disabled, if the bus master writes 532 * to the CSR bus time register, we will enable the interrupt. These 533 * fields keep track of the rollover and whether or not the interrupt 534 * is enabled. 535 */ 536 volatile uint_t ohci_bustime_count; 537 boolean_t ohci_bustime_enabled; 538 539 /* whether we have a 1394-1995 or 1394A phy */ 540 h1394_phy_t ohci_phy; 541 542 /* General Driver Info */ 543 hci1394_drvinfo_t *ohci_drvinfo; 544 545 /* 546 * self id buffer and config rom info. These are towards bottom of the 547 * structure to make debugging easier. 548 */ 549 hci1394_buf_info_t ohci_selfid; 550 hci1394_buf_info_t ohci_cfgrom; 551 552 /* OpenHCI registers */ 553 ddi_acc_handle_t ohci_reg_handle; 554 hci1394_regs_t *ohci_regs; 555 556 /* 557 * This mutex is used to protect "atomic" operations to the OpenHCI 558 * hardware. This includes reads and writes to the PHY, cswap 559 * operations to the HW implemented CSR registers, and any read/modify/ 560 * write operations such as updating atreq retries. 561 */ 562 kmutex_t ohci_mutex; 563 564 hci1394_state_t *soft_state; 565 } hci1394_ohci_t; 566 567 _NOTE(SCHEME_PROTECTS_DATA("Single thread modifies", \ 568 hci1394_ohci_s::ohci_bustime_count \ 569 hci1394_ohci_s::ohci_bustime_enabled \ 570 hci1394_ohci_s::ohci_gap_count \ 571 hci1394_ohci_s::ohci_set_gap_count \ 572 hci1394_ohci_s::ohci_set_root_holdoff)) 573 574 /* handle passed back from init() and used for rest of functions */ 575 typedef hci1394_ohci_t *hci1394_ohci_handle_t; 576 577 578 int hci1394_ohci_init(hci1394_state_t *soft_state, hci1394_drvinfo_t *drvinfo, 579 hci1394_ohci_handle_t *ohci_hdl); 580 void hci1394_ohci_fini(hci1394_ohci_handle_t *ohci_hdl); 581 582 void hci1394_ohci_reg_read(hci1394_ohci_handle_t ohci_hdl, uint_t offset, 583 uint32_t *data); 584 void hci1394_ohci_reg_write(hci1394_ohci_handle_t ohci_hdl, uint_t offset, 585 uint32_t data); 586 int hci1394_ohci_phy_init(hci1394_ohci_handle_t ohci_hdl); 587 int hci1394_ohci_phy_set(hci1394_ohci_handle_t ohci_hdl, uint_t regAddr, 588 uint_t bits); 589 int hci1394_ohci_phy_clr(hci1394_ohci_handle_t ohci_hdl, uint_t regAddr, 590 uint_t bits); 591 int hci1394_ohci_phy_read(hci1394_ohci_handle_t ohci_hdl, uint_t regAddr, 592 uint_t *rdData); 593 int hci1394_ohci_phy_write(hci1394_ohci_handle_t ohci_hdl, uint_t regAddr, 594 uint_t wrData); 595 int hci1394_ohci_phy_info(hci1394_ohci_handle_t ohci_hdl, uint32_t *info); 596 void hci1394_ohci_intr_master_enable(hci1394_ohci_handle_t ohci_hdl); 597 void hci1394_ohci_intr_master_disable(hci1394_ohci_handle_t ohci_hdl); 598 uint32_t hci1394_ohci_intr_asserted(hci1394_ohci_handle_t ohci_hdl); 599 void hci1394_ohci_intr_enable(hci1394_ohci_handle_t ohci_hdl, 600 uint32_t intr_mask); 601 void hci1394_ohci_intr_disable(hci1394_ohci_handle_t ohci_hdl, 602 uint32_t intr_mask); 603 void hci1394_ohci_intr_clear(hci1394_ohci_handle_t ohci_hdl, 604 uint32_t intr_mask); 605 uint32_t hci1394_ohci_it_intr_asserted(hci1394_ohci_handle_t ohci_hdl); 606 void hci1394_ohci_it_intr_enable(hci1394_ohci_handle_t ohci_hdl, 607 uint32_t intr_mask); 608 void hci1394_ohci_it_intr_disable(hci1394_ohci_handle_t ohci_hdl, 609 uint32_t intr_mask); 610 void hci1394_ohci_it_intr_clear(hci1394_ohci_handle_t ohci_hdl, 611 uint32_t intr_mask); 612 int hci1394_ohci_it_ctxt_count_get(hci1394_ohci_handle_t ohci_hdl); 613 void hci1394_ohci_it_cmd_ptr_set(hci1394_ohci_handle_t ohci_hdl, 614 uint_t context_number, uint32_t io_addr); 615 uint32_t hci1394_ohci_ir_intr_asserted(hci1394_ohci_handle_t ohci_hdl); 616 void hci1394_ohci_ir_intr_enable(hci1394_ohci_handle_t ohci_hdl, 617 uint32_t intr_mask); 618 void hci1394_ohci_ir_intr_disable(hci1394_ohci_handle_t ohci_hdl, 619 uint32_t intr_mask); 620 void hci1394_ohci_ir_intr_clear(hci1394_ohci_handle_t ohci_hdl, 621 uint32_t intr_mask); 622 int hci1394_ohci_ir_ctxt_count_get(hci1394_ohci_handle_t ohci_hdl); 623 void hci1394_ohci_ir_cmd_ptr_set(hci1394_ohci_handle_t ohci_hdl, 624 uint_t context_number, uint32_t io_addr); 625 void hci1394_ohci_link_enable(hci1394_ohci_handle_t ohci_hdl); 626 void hci1394_ohci_link_disable(hci1394_ohci_handle_t ohci_hdl); 627 uint_t hci1394_ohci_current_busgen(hci1394_ohci_handle_t ohci_hdl); 628 int hci1394_ohci_soft_reset(hci1394_ohci_handle_t ohci_hdl); 629 int hci1394_ohci_startup(hci1394_ohci_handle_t ohci_hdl); 630 uint64_t hci1394_ohci_guid(hci1394_ohci_handle_t ohci_hdl); 631 int hci1394_ohci_csr_read(hci1394_ohci_handle_t ohci_hdl, uint_t offset, 632 uint32_t *data); 633 int hci1394_ohci_csr_cswap(hci1394_ohci_handle_t ohci_hdl, uint_t generation, 634 uint_t offset, uint32_t compare, uint32_t swap, uint32_t *old); 635 int hci1394_ohci_bus_reset(hci1394_ohci_handle_t ohci_hdl); 636 int hci1394_ohci_bus_reset_short(hci1394_ohci_handle_t ohci_hdl); 637 void hci1394_ohci_postwr_addr(hci1394_ohci_handle_t ohci_hdl, uint64_t *addr); 638 int hci1394_ohci_contender_enable(hci1394_ohci_handle_t ohci_hdl); 639 int hci1394_ohci_root_holdoff_enable(hci1394_ohci_handle_t ohci_hdl); 640 int hci1394_ohci_gap_count_set(hci1394_ohci_handle_t ohci_hdl, 641 uint_t gap_count); 642 int hci1394_ohci_phy_filter_set(hci1394_ohci_handle_t ohci_hdl, 643 uint64_t mask, uint_t generation); 644 int hci1394_ohci_phy_filter_clr(hci1394_ohci_handle_t ohci_hdl, 645 uint64_t mask, uint_t generation); 646 void hci1394_ohci_cfgrom_update(hci1394_ohci_handle_t ohci_hdl, 647 void *local_buf, uint_t quadlet_count); 648 void hci1394_ohci_selfid_enable(hci1394_ohci_handle_t ohci_hdl); 649 void hci1394_ohci_selfid_read(hci1394_ohci_handle_t ohci_hdl, uint_t offset, 650 uint32_t *data); 651 void hci1394_ohci_selfid_info(hci1394_ohci_handle_t ohci_hdl, uint_t *busgen, 652 uint_t *size, boolean_t *error); 653 boolean_t hci1394_ohci_selfid_buf_current(hci1394_ohci_handle_t ohci_hdl); 654 void hci1394_ohci_selfid_sync(hci1394_ohci_handle_t ohci_hdl); 655 void hci1394_ohci_nodeid_set(hci1394_ohci_handle_t ohci_hdl, uint_t nodeid); 656 void hci1394_ohci_nodeid_get(hci1394_ohci_handle_t ohci_hdl, uint_t *nodeid); 657 void hci1394_ohci_nodeid_info(hci1394_ohci_handle_t ohci_hdl, 658 uint_t *nodeid, boolean_t *error); 659 void hci1394_ohci_cycletime_get(hci1394_ohci_handle_t ohci_hdl, 660 uint32_t *cycle_time); 661 void hci1394_ohci_cycletime_set(hci1394_ohci_handle_t ohci_hdl, 662 uint32_t cycle_time); 663 void hci1394_ohci_bustime_get(hci1394_ohci_handle_t ohci_hdl, 664 uint32_t *bus_time); 665 void hci1394_ohci_bustime_set(hci1394_ohci_handle_t ohci_hdl, 666 uint32_t bus_time); 667 void hci1394_ohci_atreq_retries_get(hci1394_ohci_handle_t ohci_hdl, 668 uint_t *atreq_retries); 669 void hci1394_ohci_atreq_retries_set(hci1394_ohci_handle_t ohci_hdl, 670 uint_t atreq_retries); 671 void hci1394_ohci_isr_cycle64seconds(hci1394_ohci_handle_t ohci_hdl); 672 void hci1394_ohci_isr_phy(hci1394_ohci_handle_t ohci_hdl); 673 boolean_t hci1394_ohci_root_check(hci1394_ohci_handle_t ohci_hdl); 674 boolean_t hci1394_ohci_cmc_check(hci1394_ohci_handle_t ohci_hdl); 675 void hci1394_ohci_cycle_master_enable(hci1394_ohci_handle_t ohci_hdl); 676 void hci1394_ohci_cycle_master_disable(hci1394_ohci_handle_t ohci_hdl); 677 int hci1394_ohci_resume(hci1394_ohci_handle_t ohci_hdl); 678 void hci1394_ohci_bus_capabilities(hci1394_ohci_handle_t ohci_hdl, 679 uint32_t *bus_capabilities); 680 boolean_t hci1394_ohci_at_active(hci1394_ohci_handle_t ohci_hdl); 681 void hci1394_ohci_atreq_start(hci1394_ohci_handle_t ohci_hdl, 682 uint32_t cmdptr); 683 void hci1394_ohci_atreq_wake(hci1394_ohci_handle_t ohci_hdl); 684 void hci1394_ohci_atreq_stop(hci1394_ohci_handle_t ohci_hdl); 685 void hci1394_ohci_arresp_start(hci1394_ohci_handle_t ohci_hdl, 686 uint32_t cmdptr); 687 void hci1394_ohci_arresp_wake(hci1394_ohci_handle_t ohci_hdl); 688 void hci1394_ohci_arresp_stop(hci1394_ohci_handle_t ohci_hdl); 689 void hci1394_ohci_arreq_start(hci1394_ohci_handle_t ohci_hdl, 690 uint32_t cmdptr); 691 void hci1394_ohci_arreq_wake(hci1394_ohci_handle_t ohci_hdl); 692 void hci1394_ohci_arreq_stop(hci1394_ohci_handle_t ohci_hdl); 693 void hci1394_ohci_atresp_start(hci1394_ohci_handle_t ohci_hdl, 694 uint32_t cmdptr); 695 void hci1394_ohci_atresp_wake(hci1394_ohci_handle_t ohci_hdl); 696 void hci1394_ohci_atresp_stop(hci1394_ohci_handle_t ohci_hdl); 697 698 699 #ifdef __cplusplus 700 } 701 #endif 702 703 #endif /* _SYS_1394_ADAPTERS_HCI1394_OHCI_H */ 704