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
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.
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]
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
31 * The interface into the HAL from the services layer.
36 #include <sys/modctl.h>
38 #include <sys/sunddi.h>
39 #include <sys/cmn_err.h>
41 #include <sys/1394/h1394.h>
42 #include <sys/1394/ixl1394.h>
43 #include <sys/1394/adapters/hci1394.h>
46 static void hci1394_s1394if_shutdown(void *hal_private
);
47 static int hci1394_s1394if_phy(void *hal_private
, cmd1394_cmd_t
*cmd_id
,
48 h1394_cmd_priv_t
*cmd_private
, int *result
);
49 static int hci1394_s1394if_write(void *hal_private
, cmd1394_cmd_t
*cmd_id
,
50 h1394_cmd_priv_t
*cmd_private
, int *result
);
51 static int hci1394_s1394if_read(void *hal_private
, cmd1394_cmd_t
*cmd_id
,
52 h1394_cmd_priv_t
*cmd_private
, int *result
);
53 static int hci1394_s1394if_lock(void *hal_private
, cmd1394_cmd_t
*cmd_id
,
54 h1394_cmd_priv_t
*cmd_private
, int *result
);
55 static int hci1394_s1394if_write_response(void *hal_private
,
56 cmd1394_cmd_t
*cmd_id
, h1394_cmd_priv_t
*cmd_private
, int *result
);
57 static int hci1394_s1394if_read_response(void *hal_private
,
58 cmd1394_cmd_t
*cmd_id
, h1394_cmd_priv_t
*cmd_private
, int *result
);
59 static int hci1394_s1394if_lock_response(void *hal_private
,
60 cmd1394_cmd_t
*cmd_id
, h1394_cmd_priv_t
*cmd_private
, int *result
);
61 static void hci1394_s1394if_response_complete(void *hal_private
,
62 cmd1394_cmd_t
*cmd_id
, h1394_cmd_priv_t
*cmd_private
);
63 static int hci1394_s1394if_reset_bus(void *hal_private
);
64 static int hci1394_s1394if_set_contender_bit(void *hal_private
);
65 static int hci1394_s1394if_set_root_holdoff_bit(void *hal_private
);
66 static int hci1394_s1394if_set_gap_count(void *hal_private
, uint_t gap_count
);
67 static int hci1394_s1394if_update_config_rom(void *hal_private
,
68 void *local_buf
, uint_t quadlet_count
);
69 static int hci1394_s1394if_phy_filter_set(void *hal_private
,
70 uint64_t mask
, uint_t generation
);
71 static int hci1394_s1394if_phy_filter_clr(void *hal_private
,
72 uint64_t mask
, uint_t generation
);
73 static int hci1394_s1394if_short_bus_reset(void *hal_private
);
74 static int hci1394_s1394if_csr_read(void *hal_private
,
75 uint_t offset
, uint32_t *data
);
76 static int hci1394_s1394if_csr_write(void *hal_private
,
77 uint_t offset
, uint32_t data
);
78 static int hci1394_s1394if_csr_cswap32(void *hal_private
, uint_t generation
,
79 uint_t offset
, uint32_t compare
, uint32_t swap
, uint32_t *old
);
80 static void hci1394_s1394if_power_state_change(void *hal_private
,
81 h1394_node_pwr_flags_t nodeflags
);
84 /* entry points into HAL from Services Layer */
85 h1394_evts_t hci1394_evts
= {
86 H1394_EVTS_V1
, /* hal_version */
88 hci1394_s1394if_shutdown
, /* shutdown */
89 hci1394_s1394if_phy
, /* send_phy_config_pkt */
90 hci1394_s1394if_read
, /* read */
91 hci1394_s1394if_read_response
, /* read_response */
92 hci1394_s1394if_write
, /* write */
93 hci1394_s1394if_write_response
, /* write_response */
94 hci1394_s1394if_response_complete
, /* response_complete */
95 hci1394_s1394if_lock
, /* lock */
96 hci1394_s1394if_lock_response
, /* lock_response */
97 hci1394_alloc_isoch_dma
, /* allocate_isoch_dma */
98 hci1394_free_isoch_dma
, /* free_isoch_dma */
99 hci1394_start_isoch_dma
, /* start_isoch_dma */
100 hci1394_stop_isoch_dma
, /* stop_isoch_dma */
101 hci1394_update_isoch_dma
, /* update_isoch_dma */
102 hci1394_s1394if_update_config_rom
, /* update_config_rom */
103 hci1394_s1394if_reset_bus
, /* bus_reset */
104 hci1394_s1394if_short_bus_reset
, /* short_bus_reset */
105 hci1394_s1394if_set_contender_bit
, /* set_contender_bit */
106 hci1394_s1394if_set_root_holdoff_bit
, /* set_root_holdoff_bit */
107 hci1394_s1394if_set_gap_count
, /* set_gap_count */
108 hci1394_s1394if_csr_read
, /* csr_read */
109 hci1394_s1394if_csr_write
, /* csr_write */
110 hci1394_s1394if_csr_cswap32
, /* csr_cswap32 */
111 hci1394_s1394if_phy_filter_set
, /* phys_arreq_enable_set */
112 hci1394_s1394if_phy_filter_clr
, /* phys_arreq_enable_clr */
113 hci1394_s1394if_power_state_change
/* node_power_state_change */
118 * hci1394_s1394if_shutdown()
119 * Shutdown the HAL. This is called when a critical error has been detected.
120 * This routine should shutdown the HAL so that it will no longer send or
121 * receive information to/from the 1394 bus. The purpose of this function is
122 * to try and keep the machine from crashing.
125 hci1394_s1394if_shutdown(void *hal_private
)
127 hci1394_state_t
*soft_state
;
130 ASSERT(hal_private
!= NULL
);
132 soft_state
= (hci1394_state_t
*)hal_private
;
133 hci1394_shutdown(soft_state
->drvinfo
.di_dip
);
138 * hci1394_s1394if_phy()
139 * write a phy packet out to the 1394 bus. A phy packet consists of one
143 hci1394_s1394if_phy(void *hal_private
, cmd1394_cmd_t
*cmd_id
,
144 h1394_cmd_priv_t
*cmd_private
, int *result
)
146 hci1394_state_t
*soft_state
;
150 ASSERT(hal_private
!= NULL
);
152 soft_state
= (hci1394_state_t
*)hal_private
;
154 /* make sure we are not in a bus reset or shutdown */
155 if (hci1394_state(&soft_state
->drvinfo
) != HCI1394_NORMAL
) {
156 if (hci1394_state(&soft_state
->drvinfo
) == HCI1394_BUS_RESET
) {
157 *result
= H1394_STATUS_INVALID_BUSGEN
;
159 *result
= H1394_STATUS_INTERNAL_ERROR
;
161 return (DDI_FAILURE
);
164 status
= hci1394_async_phy(soft_state
->async
, cmd_id
, cmd_private
,
166 if (status
!= DDI_SUCCESS
) {
167 return (DDI_FAILURE
);
170 return (DDI_SUCCESS
);
175 * hci1394_s1394if_write()
176 * Perform a 1394 write operation. This can be either a quadlet or block
180 hci1394_s1394if_write(void *hal_private
, cmd1394_cmd_t
*cmd_id
,
181 h1394_cmd_priv_t
*cmd_private
, int *result
)
183 hci1394_state_t
*soft_state
;
187 ASSERT(hal_private
!= NULL
);
189 soft_state
= (hci1394_state_t
*)hal_private
;
191 /* make sure we are not in a bus reset or shutdown */
192 if (hci1394_state(&soft_state
->drvinfo
) != HCI1394_NORMAL
) {
193 if (hci1394_state(&soft_state
->drvinfo
) == HCI1394_BUS_RESET
) {
194 *result
= H1394_STATUS_INVALID_BUSGEN
;
196 *result
= H1394_STATUS_INTERNAL_ERROR
;
198 return (DDI_FAILURE
);
201 status
= hci1394_async_write(soft_state
->async
, cmd_id
, cmd_private
,
203 if (status
!= DDI_SUCCESS
) {
204 return (DDI_FAILURE
);
207 return (DDI_SUCCESS
);
212 * hci1394_s1394if_read()
213 * Perform a 1394 read operation. This can be either a quadlet or block
217 hci1394_s1394if_read(void *hal_private
, cmd1394_cmd_t
*cmd_id
,
218 h1394_cmd_priv_t
*cmd_private
, int *result
)
220 hci1394_state_t
*soft_state
;
224 ASSERT(hal_private
!= NULL
);
226 soft_state
= (hci1394_state_t
*)hal_private
;
228 /* make sure we are not in a bus reset or shutdown */
229 if (hci1394_state(&soft_state
->drvinfo
) != HCI1394_NORMAL
) {
230 if (hci1394_state(&soft_state
->drvinfo
) == HCI1394_BUS_RESET
) {
231 *result
= H1394_STATUS_INVALID_BUSGEN
;
233 *result
= H1394_STATUS_INTERNAL_ERROR
;
235 return (DDI_FAILURE
);
238 status
= hci1394_async_read(soft_state
->async
, cmd_id
, cmd_private
,
240 if (status
!= DDI_SUCCESS
) {
241 return (DDI_FAILURE
);
244 return (DDI_SUCCESS
);
249 * hci1394_s1394if_lock()
250 * Perform a 1394/1212 lock operation. This can be one of the following lock
251 * operations: (CMD1394_LOCK_MASK_SWAP, CMD1394_LOCK_COMPARE_SWAP
252 * CMD1394_LOCK_FETCH_ADD, CMD1394_LOCK_LITTLE_ADD, CMD1394_LOCK_BOUNDED_ADD
253 * CMD1394_LOCK_WRAP_ADD)
256 hci1394_s1394if_lock(void *hal_private
, cmd1394_cmd_t
*cmd_id
,
257 h1394_cmd_priv_t
*cmd_private
, int *result
)
259 hci1394_state_t
*soft_state
;
263 ASSERT(hal_private
!= NULL
);
265 soft_state
= (hci1394_state_t
*)hal_private
;
267 /* make sure we are not in a bus reset or shutdown */
268 if (hci1394_state(&soft_state
->drvinfo
) != HCI1394_NORMAL
) {
269 if (hci1394_state(&soft_state
->drvinfo
) == HCI1394_BUS_RESET
) {
270 *result
= H1394_STATUS_INVALID_BUSGEN
;
272 *result
= H1394_STATUS_INTERNAL_ERROR
;
274 return (DDI_FAILURE
);
277 status
= hci1394_async_lock(soft_state
->async
, cmd_id
, cmd_private
,
279 if (status
!= DDI_SUCCESS
) {
280 return (DDI_FAILURE
);
283 return (DDI_SUCCESS
);
288 * hci1394_s1394if_write_response()
289 * Send a response to a write request received off of the 1394 bus. This
290 * could have been with a quadlet or block write request.
293 hci1394_s1394if_write_response(void *hal_private
, cmd1394_cmd_t
*cmd_id
,
294 h1394_cmd_priv_t
*cmd_private
, int *result
)
296 hci1394_state_t
*soft_state
;
300 ASSERT(hal_private
!= NULL
);
302 soft_state
= (hci1394_state_t
*)hal_private
;
304 /* make sure we are not in a bus reset or shutdown */
305 if (hci1394_state(&soft_state
->drvinfo
) != HCI1394_NORMAL
) {
306 if (hci1394_state(&soft_state
->drvinfo
) == HCI1394_BUS_RESET
) {
307 *result
= H1394_STATUS_INVALID_BUSGEN
;
309 *result
= H1394_STATUS_INTERNAL_ERROR
;
311 return (DDI_FAILURE
);
314 status
= hci1394_async_write_response(soft_state
->async
, cmd_id
,
315 cmd_private
, result
);
316 if (status
!= DDI_SUCCESS
) {
317 return (DDI_FAILURE
);
320 return (DDI_SUCCESS
);
325 * hci1394_s1394if_read_response()
326 * Send a response to a read request received off of the 1394 bus. This
327 * could have been with a quadlet or block read request.
330 hci1394_s1394if_read_response(void *hal_private
, cmd1394_cmd_t
*cmd_id
,
331 h1394_cmd_priv_t
*cmd_private
, int *result
)
333 hci1394_state_t
*soft_state
;
337 ASSERT(hal_private
!= NULL
);
339 soft_state
= (hci1394_state_t
*)hal_private
;
341 /* make sure we are not in a bus reset or shutdown */
342 if (hci1394_state(&soft_state
->drvinfo
) != HCI1394_NORMAL
) {
343 if (hci1394_state(&soft_state
->drvinfo
) == HCI1394_BUS_RESET
) {
344 *result
= H1394_STATUS_INVALID_BUSGEN
;
346 *result
= H1394_STATUS_INTERNAL_ERROR
;
348 return (DDI_FAILURE
);
351 status
= hci1394_async_read_response(soft_state
->async
, cmd_id
,
352 cmd_private
, result
);
353 if (status
!= DDI_SUCCESS
) {
354 return (DDI_FAILURE
);
357 return (DDI_SUCCESS
);
362 * hci1394_s1394if_lock_response()
363 * Send a response to a lock request received off of the 1394 bus. This
364 * could have been one of the following lock operations:
365 * (CMD1394_LOCK_MASK_SWAP, CMD1394_LOCK_COMPARE_SWAP CMD1394_LOCK_FETCH_ADD,
366 * CMD1394_LOCK_LITTLE_ADD, CMD1394_LOCK_BOUNDED_ADD, CMD1394_LOCK_WRAP_ADD)
369 hci1394_s1394if_lock_response(void *hal_private
, cmd1394_cmd_t
*cmd_id
,
370 h1394_cmd_priv_t
*cmd_private
, int *result
)
372 hci1394_state_t
*soft_state
;
376 ASSERT(hal_private
!= NULL
);
378 soft_state
= (hci1394_state_t
*)hal_private
;
380 /* make sure we are not in a bus reset or shutdown */
381 if (hci1394_state(&soft_state
->drvinfo
) != HCI1394_NORMAL
) {
382 if (hci1394_state(&soft_state
->drvinfo
) == HCI1394_BUS_RESET
) {
383 *result
= H1394_STATUS_INVALID_BUSGEN
;
385 *result
= H1394_STATUS_INTERNAL_ERROR
;
387 return (DDI_FAILURE
);
390 status
= hci1394_async_lock_response(soft_state
->async
, cmd_id
,
391 cmd_private
, result
);
392 if (status
!= DDI_SUCCESS
) {
393 return (DDI_FAILURE
);
396 return (DDI_SUCCESS
);
401 * hci1394_s1394if_response_complete()
402 * This notifies the HAL that the services layer and target driver are done
403 * with a command that was received off of the 1394 bus. This will usually
404 * be called after the response to the command has been command_complete'd.
405 * The HAL is free to re-use the command or free up the memory from this
406 * command after this call has returned. This should only be called for
410 hci1394_s1394if_response_complete(void *hal_private
, cmd1394_cmd_t
*cmd_id
,
411 h1394_cmd_priv_t
*cmd_private
)
413 hci1394_state_t
*soft_state
;
415 ASSERT(hal_private
!= NULL
);
416 soft_state
= (hci1394_state_t
*)hal_private
;
417 hci1394_async_response_complete(soft_state
->async
, cmd_id
, cmd_private
);
422 * hci1394_s1394if_reset_bus()
423 * This routine resets the 1394 bus. It performs a "long" bus reset. It
424 * should work on all OpenHCI adapters.
427 hci1394_s1394if_reset_bus(void *hal_private
)
429 hci1394_state_t
*soft_state
;
433 ASSERT(hal_private
!= NULL
);
435 soft_state
= (hci1394_state_t
*)hal_private
;
437 /* make sure we are not shutdown */
438 if (hci1394_state(&soft_state
->drvinfo
) == HCI1394_SHUTDOWN
) {
439 return (DDI_FAILURE
);
442 status
= hci1394_ohci_bus_reset(soft_state
->ohci
);
443 if (status
!= DDI_SUCCESS
) {
444 return (DDI_FAILURE
);
447 return (DDI_SUCCESS
);
452 * hci1394_s1394if_set_contender_bit()
453 * This routine sets up the PHY so that the selfid contender bit will be set
454 * on subsequent bus resets. This routine will fail when we have a 1394-1995
455 * PHY since this PHY does not have a SW controllable contender bit.
458 hci1394_s1394if_set_contender_bit(void *hal_private
)
460 hci1394_state_t
*soft_state
;
464 ASSERT(hal_private
!= NULL
);
466 soft_state
= (hci1394_state_t
*)hal_private
;
468 /* make sure we are not shutdown */
469 if (hci1394_state(&soft_state
->drvinfo
) == HCI1394_SHUTDOWN
) {
470 return (DDI_FAILURE
);
473 if (soft_state
->halinfo
.phy
== H1394_PHY_1995
) {
474 return (DDI_FAILURE
);
477 status
= hci1394_ohci_contender_enable(soft_state
->ohci
);
478 if (status
!= DDI_SUCCESS
) {
479 return (DDI_FAILURE
);
482 return (DDI_SUCCESS
);
487 * hci1394_s1394if_set_root_holdoff_bit()
488 * This routine will set the root holdoff bit in the PHY. The Services Layer
489 * should send out a PHY configuration packet first to tell everyone which
490 * node to set the root holdoff bit on. If it is our root holdoff bit we
491 * are setting, the PHY will automatically set it unless we have an old
492 * (1394-1995) PHY. If we have a 1394-1995 PHY, the SL needs to call this
493 * routine after sending the PHY configuration packet. The SL also needs to
494 * call this if they want to perform a long bus reset and have the root
495 * holdoff bit set. We do this so that we do not have to do a read before
496 * the write. A PHY register write has less of a chance of failing.
499 hci1394_s1394if_set_root_holdoff_bit(void *hal_private
)
501 hci1394_state_t
*soft_state
;
505 ASSERT(hal_private
!= NULL
);
507 soft_state
= (hci1394_state_t
*)hal_private
;
509 /* make sure we are not shutdown */
510 if (hci1394_state(&soft_state
->drvinfo
) == HCI1394_SHUTDOWN
) {
511 return (DDI_FAILURE
);
514 status
= hci1394_ohci_root_holdoff_enable(soft_state
->ohci
);
515 if (status
!= DDI_SUCCESS
) {
516 return (DDI_FAILURE
);
519 return (DDI_SUCCESS
);
524 * hci1394_s1394if_set_gap_count()
525 * This routine will set the gap count bit in the PHY. The Services Layer
526 * should send out a PHY configuration packet first to tell everyone what
527 * gap count to use. Our PHY will automatically set the gap count unless we
528 * have an old (1394-1995) PHY. If we have a 1394-1995 PHY, the SL needs to
529 * call this routine after sending the PHY configuration packet and before
530 * generating a bus reset. The SL also needs to call before the they call to
531 * perform a long bus reset. We do this so that we do not have to do a PHY
532 * read before the write. A PHY register write has less of a chance of
536 hci1394_s1394if_set_gap_count(void *hal_private
, uint_t gap_count
)
538 hci1394_state_t
*soft_state
;
542 ASSERT(hal_private
!= NULL
);
544 soft_state
= (hci1394_state_t
*)hal_private
;
546 /* make sure we are not shutdown */
547 if (hci1394_state(&soft_state
->drvinfo
) == HCI1394_SHUTDOWN
) {
548 return (DDI_FAILURE
);
551 status
= hci1394_ohci_gap_count_set(soft_state
->ohci
, gap_count
);
552 if (status
!= DDI_SUCCESS
) {
553 return (DDI_FAILURE
);
556 return (DDI_SUCCESS
);
561 * hci1394_s1394if_phy_filter_set()
562 * reads/writes to physically mapped memory from devices on the bus are
563 * disabled by default. They can be enabled on a node by node basis. All
564 * physical accesses are disabled every bus reset so they must be re-enabled
565 * every bus reset (This is due to the fact the the node ids change every bus
566 * reset). A 64-bit mask is passed in to enable nodes to be able to rd/wr
567 * physically mapped memory over the 1394 bus. A bit = to 1 enables that
568 * node's physical accesses, a bit = to 0 does nothing (i.e. a bitwise or is
569 * performed). The LSB of the mask (bit 0), maps to node #0, bit #62, maps to
570 * node 62. The MSB (#63) is not used since the can only be 63 nodes
571 * (0 - 62) on the bus.
573 * hci1394_s1394if_phy_filter_clr() is used to disable access to physical
574 * memory. This is only required if the node had previously been enabled.
576 * generation is used to verify that we are have not gotten a bus reset since
577 * the mask was built.
580 hci1394_s1394if_phy_filter_set(void *hal_private
,
581 uint64_t mask
, uint_t generation
)
583 hci1394_state_t
*soft_state
;
587 ASSERT(hal_private
!= NULL
);
589 soft_state
= (hci1394_state_t
*)hal_private
;
591 /* make sure we are not shutdown */
592 if (hci1394_state(&soft_state
->drvinfo
) == HCI1394_SHUTDOWN
) {
593 return (DDI_FAILURE
);
596 status
= hci1394_ohci_phy_filter_set(soft_state
->ohci
, mask
,
598 if (status
!= DDI_SUCCESS
) {
599 return (DDI_FAILURE
);
602 return (DDI_SUCCESS
);
607 * hci1394_s1394if_phy_filter_clr()
608 * reads/writes to physically mapped memory from devices on the bus are
609 * disabled by default. They can be enabled/disabled on a node by node basis.
610 * All physical accesses are disabled every bus reset so they must be
611 * re-enabled every bus reset (This is due to the fact the the node ids
612 * change every bus reset). Only nodes which have been enabled and no longer
613 * need access to physical memory need to be disabled.
615 * A 64-bit mask is passed in to disable nodes from being able to rd/wr
616 * physically mapped memory over the 1394 bus. A bit = to 1 disables that
617 * node's physical accesses, a bit = to 0 does nothing (i.e. a bitwise or is
618 * performed). The LSB of the mask (bit 0), maps to node #0, bit #62, maps to
619 * node 62. The MSB (#63) is not used since there can only be 63 nodes
620 * (0 - 62) on the bus.
622 * hci1394_s1394if_phy_filter_set() is used to enable access to physical
625 * generation is used to verify that we are have not gotten a bus reset since
626 * the mask was build.
629 hci1394_s1394if_phy_filter_clr(void *hal_private
,
630 uint64_t mask
, uint_t generation
)
632 hci1394_state_t
*soft_state
;
636 ASSERT(hal_private
!= NULL
);
638 soft_state
= (hci1394_state_t
*)hal_private
;
640 /* make sure we are not shutdown */
641 if (hci1394_state(&soft_state
->drvinfo
) == HCI1394_SHUTDOWN
) {
642 return (DDI_FAILURE
);
645 status
= hci1394_ohci_phy_filter_clr(soft_state
->ohci
, mask
,
647 if (status
!= DDI_SUCCESS
) {
648 return (DDI_FAILURE
);
651 return (DDI_SUCCESS
);
656 * hci1394_s1394if_short_bus_reset()
657 * This routine resets the 1394 bus. It performs a "short" bus reset. It
658 * will only work on adapters with a 1394A or later PHY. Calling this routine
659 * when we have a 1394-1995 PHY is an error.
662 hci1394_s1394if_short_bus_reset(void *hal_private
)
664 hci1394_state_t
*soft_state
;
668 ASSERT(hal_private
!= NULL
);
670 soft_state
= (hci1394_state_t
*)hal_private
;
672 /* make sure we are not shutdown */
673 if (hci1394_state(&soft_state
->drvinfo
) == HCI1394_SHUTDOWN
) {
674 return (DDI_FAILURE
);
677 if (soft_state
->halinfo
.phy
== H1394_PHY_1995
) {
678 return (DDI_FAILURE
);
681 status
= hci1394_ohci_bus_reset_short(soft_state
->ohci
);
682 if (status
!= DDI_SUCCESS
) {
683 return (DDI_FAILURE
);
686 return (DDI_SUCCESS
);
691 * hci1394_s1394if_update_config_rom()
692 * This routine updates the configuration ROM. It copies "quadlet_count"
693 * 32-bit words from "local_buf" to the config ROM starting at the first
694 * location in config ROM. This routine is meant to update the entire config
695 * ROM and not meant for a partial update.
698 hci1394_s1394if_update_config_rom(void *hal_private
,
699 void *local_buf
, uint_t quadlet_count
)
701 hci1394_state_t
*soft_state
;
704 ASSERT(hal_private
!= NULL
);
705 ASSERT(local_buf
!= NULL
);
707 soft_state
= (hci1394_state_t
*)hal_private
;
709 /* make sure we are not shutdown */
710 if (hci1394_state(&soft_state
->drvinfo
) == HCI1394_SHUTDOWN
) {
711 return (DDI_FAILURE
);
714 hci1394_ohci_cfgrom_update(soft_state
->ohci
, local_buf
, quadlet_count
);
716 return (DDI_SUCCESS
);
721 * hci1394_s1394if_csr_read()
722 * CSR register read interface
723 * For more information on CSR registers, see
727 * IEEE P1394A Draft 3.0
728 * sections 10.32,10.33
731 hci1394_s1394if_csr_read(void *hal_private
, uint_t offset
, uint32_t *data
)
733 hci1394_state_t
*soft_state
;
737 ASSERT(hal_private
!= NULL
);
738 ASSERT(data
!= NULL
);
740 soft_state
= (hci1394_state_t
*)hal_private
;
742 /* make sure we are not shutdown */
743 if (hci1394_state(&soft_state
->drvinfo
) == HCI1394_SHUTDOWN
) {
744 return (DDI_FAILURE
);
748 case CSR_STATE_CLEAR
:
749 hci1394_csr_state_get(soft_state
->csr
, data
);
750 status
= DDI_SUCCESS
;
753 /* Write Only Register */
754 status
= DDI_FAILURE
;
757 hci1394_ohci_nodeid_get(soft_state
->ohci
, data
);
758 status
= DDI_SUCCESS
;
760 case CSR_RESET_START
:
762 status
= DDI_FAILURE
;
764 case CSR_SPLIT_TIMEOUT_HI
:
765 hci1394_csr_split_timeout_hi_get(soft_state
->csr
, data
);
766 status
= DDI_SUCCESS
;
768 case CSR_SPLIT_TIMEOUT_LO
:
769 hci1394_csr_split_timeout_lo_get(soft_state
->csr
, data
);
770 status
= DDI_SUCCESS
;
773 /* CYCLE_TIME is implemented in HW */
774 hci1394_ohci_cycletime_get(soft_state
->ohci
, data
);
775 status
= DDI_SUCCESS
;
778 /* BUS_TIME is implemented in the hci1394_ohci_* SW */
779 hci1394_ohci_bustime_get(soft_state
->ohci
, data
);
780 status
= DDI_SUCCESS
;
782 case CSR_BUSY_TIMEOUT
:
783 hci1394_ohci_atreq_retries_get(soft_state
->ohci
, data
);
784 status
= DDI_SUCCESS
;
786 case CSR_BUS_MANAGER_ID
:
787 /* BUS_MANAGER_ID is implemented in HW */
788 status
= hci1394_ohci_csr_read(soft_state
->ohci
, 0, data
);
790 case CSR_BANDWIDTH_AVAILABLE
:
791 /* BANDWIDTH_AVAILABLE is implemented in HW */
792 status
= hci1394_ohci_csr_read(soft_state
->ohci
, 1, data
);
794 case CSR_CHANNELS_AVAILABLE_HI
:
795 /* CHANNELS_AVAILABLE_HI is implemented in HW */
796 status
= hci1394_ohci_csr_read(soft_state
->ohci
, 2, data
);
798 case CSR_CHANNELS_AVAILABLE_LO
:
799 /* CHANNELS_AVAILABLE_LO is implemented in HW */
800 status
= hci1394_ohci_csr_read(soft_state
->ohci
, 3, data
);
803 status
= DDI_FAILURE
;
812 * hci1394_s1394if_csr_write()
813 * CSR register write interface
814 * For more information on CSR registers, see
818 * IEEE P1394A Draft 3.0
819 * sections 10.32,10.33
822 hci1394_s1394if_csr_write(void *hal_private
, uint_t offset
, uint32_t data
)
824 hci1394_state_t
*soft_state
;
828 ASSERT(hal_private
!= NULL
);
830 soft_state
= (hci1394_state_t
*)hal_private
;
832 /* make sure we are not shutdown */
833 if (hci1394_state(&soft_state
->drvinfo
) == HCI1394_SHUTDOWN
) {
834 return (DDI_FAILURE
);
838 case CSR_STATE_CLEAR
:
839 hci1394_csr_state_bclr(soft_state
->csr
, data
);
840 status
= DDI_SUCCESS
;
843 hci1394_csr_state_bset(soft_state
->csr
, data
);
844 status
= DDI_SUCCESS
;
847 hci1394_ohci_nodeid_set(soft_state
->ohci
, data
);
848 status
= DDI_SUCCESS
;
850 case CSR_RESET_START
:
852 status
= DDI_FAILURE
;
856 * there is a race condition when updating the split timeout
857 * due to the nature of the interface. (i.e. having a separate
860 case CSR_SPLIT_TIMEOUT_HI
:
861 hci1394_csr_split_timeout_hi_set(soft_state
->csr
, data
);
863 * update the pending list timeout value. The split timeout
864 * is stored in 1394 bus cycles and the timeout is specified in
865 * nS. Therefore, we need to convert the split timeout into nS.
867 hci1394_async_pending_timeout_update(soft_state
->async
,
868 OHCI_BUS_CYCLE_TO_nS(hci1394_csr_split_timeout_get(
870 status
= DDI_SUCCESS
;
872 case CSR_SPLIT_TIMEOUT_LO
:
873 hci1394_csr_split_timeout_lo_set(soft_state
->csr
, data
);
875 * update the pending list timeout value. The split timeout
876 * is stored in 1394 bus cycles and the timeout is specified in
877 * nS. Therefore, we need to convert the split timeout into nS.
879 hci1394_async_pending_timeout_update(soft_state
->async
,
880 OHCI_BUS_CYCLE_TO_nS(hci1394_csr_split_timeout_get(
882 status
= DDI_SUCCESS
;
886 hci1394_ohci_cycletime_set(soft_state
->ohci
, data
);
887 status
= DDI_SUCCESS
;
890 hci1394_ohci_bustime_set(soft_state
->ohci
, data
);
891 status
= DDI_SUCCESS
;
893 case CSR_BUSY_TIMEOUT
:
894 hci1394_ohci_atreq_retries_set(soft_state
->ohci
, data
);
895 status
= DDI_SUCCESS
;
897 case CSR_BUS_MANAGER_ID
:
898 /* Invalid access, only read/cswap32 allowed */
899 status
= DDI_FAILURE
;
901 case CSR_BANDWIDTH_AVAILABLE
:
902 /* Invalid access, only read/cswap32 allowed */
903 status
= DDI_FAILURE
;
905 case CSR_CHANNELS_AVAILABLE_HI
:
906 /* Invalid access, only read/cswap32 allowed */
907 status
= DDI_FAILURE
;
909 case CSR_CHANNELS_AVAILABLE_LO
:
910 /* Invalid access, only read/cswap32 allowed */
911 status
= DDI_FAILURE
;
914 status
= DDI_FAILURE
;
923 * hci1394_s1394if_csr_cswap32()
924 * CSR register cswap32 interface
925 * For more information on CSR registers, see
929 * IEEE P1394A Draft 3.0
930 * sections 10.32,10.33
933 hci1394_s1394if_csr_cswap32(void *hal_private
, uint_t generation
, uint_t offset
,
934 uint32_t compare
, uint32_t swap
, uint32_t *old
)
936 hci1394_state_t
*soft_state
;
940 ASSERT(hal_private
!= NULL
);
943 soft_state
= (hci1394_state_t
*)hal_private
;
945 /* make sure we are not shutdown */
946 if (hci1394_state(&soft_state
->drvinfo
) == HCI1394_SHUTDOWN
) {
947 return (DDI_FAILURE
);
951 case CSR_STATE_CLEAR
:
952 /* Invalid access, only read/write allowed */
953 status
= DDI_FAILURE
;
956 /* Invalid access, only write allowed */
957 status
= DDI_FAILURE
;
960 /* Invalid access, only read/write allowed */
961 status
= DDI_FAILURE
;
963 case CSR_RESET_START
:
964 /* Invalid access, only read/write allowed */
965 status
= DDI_FAILURE
;
967 case CSR_SPLIT_TIMEOUT_HI
:
968 /* Invalid access, only read/write allowed */
969 status
= DDI_FAILURE
;
971 case CSR_SPLIT_TIMEOUT_LO
:
972 /* Invalid access, only read/write allowed */
973 status
= DDI_FAILURE
;
976 /* Invalid access, only read/write allowed */
977 status
= DDI_FAILURE
;
980 /* Invalid access, only read/write allowed */
981 status
= DDI_FAILURE
;
983 case CSR_BUSY_TIMEOUT
:
984 /* Invalid access, only read/write allowed */
985 status
= DDI_FAILURE
;
987 case CSR_BUS_MANAGER_ID
:
988 /* BUS_MANAGER_ID is implemented in HW */
989 status
= hci1394_ohci_csr_cswap(soft_state
->ohci
, generation
,
990 OHCI_CSR_SEL_BUS_MGR_ID
, compare
, swap
, old
);
992 case CSR_BANDWIDTH_AVAILABLE
:
993 /* BANDWIDTH_AVAILABLE is implemented in HW */
994 status
= hci1394_ohci_csr_cswap(soft_state
->ohci
, generation
,
995 OHCI_CSR_SEL_BANDWIDTH_AVAIL
, compare
, swap
, old
);
997 case CSR_CHANNELS_AVAILABLE_HI
:
998 /* CHANNELS_AVAILABLE_HI is implemented in HW */
999 status
= hci1394_ohci_csr_cswap(soft_state
->ohci
, generation
,
1000 OHCI_CSR_SEL_CHANS_AVAIL_HI
, compare
, swap
, old
);
1002 case CSR_CHANNELS_AVAILABLE_LO
:
1003 /* CHANNELS_AVAILABLE_LO is implemented in HW */
1004 status
= hci1394_ohci_csr_cswap(soft_state
->ohci
, generation
,
1005 OHCI_CSR_SEL_CHANS_AVAIL_LO
, compare
, swap
, old
);
1008 status
= DDI_FAILURE
;
1017 * hci1394_s1394if_power_state_change()
1018 * Signals that a change in the bus topology has taken place which may affect
1023 hci1394_s1394if_power_state_change(void *hal_private
,
1024 h1394_node_pwr_flags_t nodeflags
)
1026 /* not implemented */