aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/aic7xxx/aic79xx_core.c
diff options
context:
space:
mode:
authorAdrian Bunk <bunk@stusta.de>2006-10-20 17:47:57 -0400
committerJames Bottomley <jejb@mulgrave.il.steeleye.com>2006-10-25 18:14:21 -0400
commit289fe5b1f99c5e61ed32796cbed0a1ecc3589041 (patch)
treeca2b01a48263c817ea9c190f7218c48e7c7eb9cb /drivers/scsi/aic7xxx/aic79xx_core.c
parent6d07cb71fdacc710fd9816cddb5c2df0f7bd96b4 (diff)
[SCSI] aic7xxx: cleanups
- make needlessly global code static - #if 0 the following unused global functions: - aic79xx_core.c: ahd_print_scb - aic79xx_core.c: ahd_suspend - aic79xx_core.c: ahd_resume - aic79xx_core.c: ahd_dump_scbs - aic79xx_osm.c: ahd_softc_comp Signed-off-by: Adrian Bunk <bunk@stusta.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Acked-by: Hannes Reinecke <hare@suse.de> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi/aic7xxx/aic79xx_core.c')
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_core.c260
1 files changed, 164 insertions, 96 deletions
diff --git a/drivers/scsi/aic7xxx/aic79xx_core.c b/drivers/scsi/aic7xxx/aic79xx_core.c
index 6adcf7989ce7..7d53c6456d04 100644
--- a/drivers/scsi/aic7xxx/aic79xx_core.c
+++ b/drivers/scsi/aic7xxx/aic79xx_core.c
@@ -52,7 +52,7 @@
52 52
53 53
54/***************************** Lookup Tables **********************************/ 54/***************************** Lookup Tables **********************************/
55char *ahd_chip_names[] = 55static char *ahd_chip_names[] =
56{ 56{
57 "NONE", 57 "NONE",
58 "aic7901", 58 "aic7901",
@@ -237,10 +237,33 @@ static int ahd_handle_target_cmd(struct ahd_softc *ahd,
237 struct target_cmd *cmd); 237 struct target_cmd *cmd);
238#endif 238#endif
239 239
240static int ahd_abort_scbs(struct ahd_softc *ahd, int target,
241 char channel, int lun, u_int tag,
242 role_t role, uint32_t status);
243static void ahd_alloc_scbs(struct ahd_softc *ahd);
244static void ahd_busy_tcl(struct ahd_softc *ahd, u_int tcl,
245 u_int scbid);
246static void ahd_calc_residual(struct ahd_softc *ahd,
247 struct scb *scb);
248static void ahd_clear_critical_section(struct ahd_softc *ahd);
249static void ahd_clear_intstat(struct ahd_softc *ahd);
250static void ahd_enable_coalescing(struct ahd_softc *ahd,
251 int enable);
252static u_int ahd_find_busy_tcl(struct ahd_softc *ahd, u_int tcl);
253static void ahd_freeze_devq(struct ahd_softc *ahd,
254 struct scb *scb);
255static void ahd_handle_scb_status(struct ahd_softc *ahd,
256 struct scb *scb);
257static struct ahd_phase_table_entry* ahd_lookup_phase_entry(int phase);
258static void ahd_shutdown(void *arg);
259static void ahd_update_coalescing_values(struct ahd_softc *ahd,
260 u_int timer,
261 u_int maxcmds,
262 u_int mincmds);
263static int ahd_verify_vpd_cksum(struct vpd_config *vpd);
264static int ahd_wait_seeprom(struct ahd_softc *ahd);
265
240/******************************** Private Inlines *****************************/ 266/******************************** Private Inlines *****************************/
241static __inline void ahd_assert_atn(struct ahd_softc *ahd);
242static __inline int ahd_currently_packetized(struct ahd_softc *ahd);
243static __inline int ahd_set_active_fifo(struct ahd_softc *ahd);
244 267
245static __inline void 268static __inline void
246ahd_assert_atn(struct ahd_softc *ahd) 269ahd_assert_atn(struct ahd_softc *ahd)
@@ -294,11 +317,44 @@ ahd_set_active_fifo(struct ahd_softc *ahd)
294 } 317 }
295} 318}
296 319
320static __inline void
321ahd_unbusy_tcl(struct ahd_softc *ahd, u_int tcl)
322{
323 ahd_busy_tcl(ahd, tcl, SCB_LIST_NULL);
324}
325
326/*
327 * Determine whether the sequencer reported a residual
328 * for this SCB/transaction.
329 */
330static __inline void
331ahd_update_residual(struct ahd_softc *ahd, struct scb *scb)
332{
333 uint32_t sgptr;
334
335 sgptr = ahd_le32toh(scb->hscb->sgptr);
336 if ((sgptr & SG_STATUS_VALID) != 0)
337 ahd_calc_residual(ahd, scb);
338}
339
340static __inline void
341ahd_complete_scb(struct ahd_softc *ahd, struct scb *scb)
342{
343 uint32_t sgptr;
344
345 sgptr = ahd_le32toh(scb->hscb->sgptr);
346 if ((sgptr & SG_STATUS_VALID) != 0)
347 ahd_handle_scb_status(ahd, scb);
348 else
349 ahd_done(ahd, scb);
350}
351
352
297/************************* Sequencer Execution Control ************************/ 353/************************* Sequencer Execution Control ************************/
298/* 354/*
299 * Restart the sequencer program from address zero 355 * Restart the sequencer program from address zero
300 */ 356 */
301void 357static void
302ahd_restart(struct ahd_softc *ahd) 358ahd_restart(struct ahd_softc *ahd)
303{ 359{
304 360
@@ -342,7 +398,7 @@ ahd_restart(struct ahd_softc *ahd)
342 ahd_unpause(ahd); 398 ahd_unpause(ahd);
343} 399}
344 400
345void 401static void
346ahd_clear_fifo(struct ahd_softc *ahd, u_int fifo) 402ahd_clear_fifo(struct ahd_softc *ahd, u_int fifo)
347{ 403{
348 ahd_mode_state saved_modes; 404 ahd_mode_state saved_modes;
@@ -366,7 +422,7 @@ ahd_clear_fifo(struct ahd_softc *ahd, u_int fifo)
366 * Flush and completed commands that are sitting in the command 422 * Flush and completed commands that are sitting in the command
367 * complete queues down on the chip but have yet to be dma'ed back up. 423 * complete queues down on the chip but have yet to be dma'ed back up.
368 */ 424 */
369void 425static void
370ahd_flush_qoutfifo(struct ahd_softc *ahd) 426ahd_flush_qoutfifo(struct ahd_softc *ahd)
371{ 427{
372 struct scb *scb; 428 struct scb *scb;
@@ -905,6 +961,51 @@ ahd_handle_hwerrint(struct ahd_softc *ahd)
905 ahd_free(ahd); 961 ahd_free(ahd);
906} 962}
907 963
964#ifdef AHD_DEBUG
965static void
966ahd_dump_sglist(struct scb *scb)
967{
968 int i;
969
970 if (scb->sg_count > 0) {
971 if ((scb->ahd_softc->flags & AHD_64BIT_ADDRESSING) != 0) {
972 struct ahd_dma64_seg *sg_list;
973
974 sg_list = (struct ahd_dma64_seg*)scb->sg_list;
975 for (i = 0; i < scb->sg_count; i++) {
976 uint64_t addr;
977 uint32_t len;
978
979 addr = ahd_le64toh(sg_list[i].addr);
980 len = ahd_le32toh(sg_list[i].len);
981 printf("sg[%d] - Addr 0x%x%x : Length %d%s\n",
982 i,
983 (uint32_t)((addr >> 32) & 0xFFFFFFFF),
984 (uint32_t)(addr & 0xFFFFFFFF),
985 sg_list[i].len & AHD_SG_LEN_MASK,
986 (sg_list[i].len & AHD_DMA_LAST_SEG)
987 ? " Last" : "");
988 }
989 } else {
990 struct ahd_dma_seg *sg_list;
991
992 sg_list = (struct ahd_dma_seg*)scb->sg_list;
993 for (i = 0; i < scb->sg_count; i++) {
994 uint32_t len;
995
996 len = ahd_le32toh(sg_list[i].len);
997 printf("sg[%d] - Addr 0x%x%x : Length %d%s\n",
998 i,
999 (len & AHD_SG_HIGH_ADDR_MASK) >> 24,
1000 ahd_le32toh(sg_list[i].addr),
1001 len & AHD_SG_LEN_MASK,
1002 len & AHD_DMA_LAST_SEG ? " Last" : "");
1003 }
1004 }
1005 }
1006}
1007#endif /* AHD_DEBUG */
1008
908void 1009void
909ahd_handle_seqint(struct ahd_softc *ahd, u_int intstat) 1010ahd_handle_seqint(struct ahd_softc *ahd, u_int intstat)
910{ 1011{
@@ -2523,7 +2624,7 @@ ahd_force_renegotiation(struct ahd_softc *ahd, struct ahd_devinfo *devinfo)
2523} 2624}
2524 2625
2525#define AHD_MAX_STEPS 2000 2626#define AHD_MAX_STEPS 2000
2526void 2627static void
2527ahd_clear_critical_section(struct ahd_softc *ahd) 2628ahd_clear_critical_section(struct ahd_softc *ahd)
2528{ 2629{
2529 ahd_mode_state saved_modes; 2630 ahd_mode_state saved_modes;
@@ -2646,7 +2747,7 @@ ahd_clear_critical_section(struct ahd_softc *ahd)
2646/* 2747/*
2647 * Clear any pending interrupt status. 2748 * Clear any pending interrupt status.
2648 */ 2749 */
2649void 2750static void
2650ahd_clear_intstat(struct ahd_softc *ahd) 2751ahd_clear_intstat(struct ahd_softc *ahd)
2651{ 2752{
2652 AHD_ASSERT_MODES(ahd, ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK), 2753 AHD_ASSERT_MODES(ahd, ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK),
@@ -2677,6 +2778,8 @@ ahd_clear_intstat(struct ahd_softc *ahd)
2677#ifdef AHD_DEBUG 2778#ifdef AHD_DEBUG
2678uint32_t ahd_debug = AHD_DEBUG_OPTS; 2779uint32_t ahd_debug = AHD_DEBUG_OPTS;
2679#endif 2780#endif
2781
2782#if 0
2680void 2783void
2681ahd_print_scb(struct scb *scb) 2784ahd_print_scb(struct scb *scb)
2682{ 2785{
@@ -2701,49 +2804,7 @@ ahd_print_scb(struct scb *scb)
2701 SCB_GET_TAG(scb)); 2804 SCB_GET_TAG(scb));
2702 ahd_dump_sglist(scb); 2805 ahd_dump_sglist(scb);
2703} 2806}
2704 2807#endif /* 0 */
2705void
2706ahd_dump_sglist(struct scb *scb)
2707{
2708 int i;
2709
2710 if (scb->sg_count > 0) {
2711 if ((scb->ahd_softc->flags & AHD_64BIT_ADDRESSING) != 0) {
2712 struct ahd_dma64_seg *sg_list;
2713
2714 sg_list = (struct ahd_dma64_seg*)scb->sg_list;
2715 for (i = 0; i < scb->sg_count; i++) {
2716 uint64_t addr;
2717 uint32_t len;
2718
2719 addr = ahd_le64toh(sg_list[i].addr);
2720 len = ahd_le32toh(sg_list[i].len);
2721 printf("sg[%d] - Addr 0x%x%x : Length %d%s\n",
2722 i,
2723 (uint32_t)((addr >> 32) & 0xFFFFFFFF),
2724 (uint32_t)(addr & 0xFFFFFFFF),
2725 sg_list[i].len & AHD_SG_LEN_MASK,
2726 (sg_list[i].len & AHD_DMA_LAST_SEG)
2727 ? " Last" : "");
2728 }
2729 } else {
2730 struct ahd_dma_seg *sg_list;
2731
2732 sg_list = (struct ahd_dma_seg*)scb->sg_list;
2733 for (i = 0; i < scb->sg_count; i++) {
2734 uint32_t len;
2735
2736 len = ahd_le32toh(sg_list[i].len);
2737 printf("sg[%d] - Addr 0x%x%x : Length %d%s\n",
2738 i,
2739 (len & AHD_SG_HIGH_ADDR_MASK) >> 24,
2740 ahd_le32toh(sg_list[i].addr),
2741 len & AHD_SG_LEN_MASK,
2742 len & AHD_DMA_LAST_SEG ? " Last" : "");
2743 }
2744 }
2745 }
2746}
2747 2808
2748/************************* Transfer Negotiation *******************************/ 2809/************************* Transfer Negotiation *******************************/
2749/* 2810/*
@@ -2906,7 +2967,7 @@ ahd_find_syncrate(struct ahd_softc *ahd, u_int *period,
2906 * Truncate the given synchronous offset to a value the 2967 * Truncate the given synchronous offset to a value the
2907 * current adapter type and syncrate are capable of. 2968 * current adapter type and syncrate are capable of.
2908 */ 2969 */
2909void 2970static void
2910ahd_validate_offset(struct ahd_softc *ahd, 2971ahd_validate_offset(struct ahd_softc *ahd,
2911 struct ahd_initiator_tinfo *tinfo, 2972 struct ahd_initiator_tinfo *tinfo,
2912 u_int period, u_int *offset, int wide, 2973 u_int period, u_int *offset, int wide,
@@ -2937,7 +2998,7 @@ ahd_validate_offset(struct ahd_softc *ahd,
2937 * Truncate the given transfer width parameter to a value the 2998 * Truncate the given transfer width parameter to a value the
2938 * current adapter type is capable of. 2999 * current adapter type is capable of.
2939 */ 3000 */
2940void 3001static void
2941ahd_validate_width(struct ahd_softc *ahd, struct ahd_initiator_tinfo *tinfo, 3002ahd_validate_width(struct ahd_softc *ahd, struct ahd_initiator_tinfo *tinfo,
2942 u_int *bus_width, role_t role) 3003 u_int *bus_width, role_t role)
2943{ 3004{
@@ -3466,7 +3527,7 @@ ahd_print_devinfo(struct ahd_softc *ahd, struct ahd_devinfo *devinfo)
3466 devinfo->target, devinfo->lun); 3527 devinfo->target, devinfo->lun);
3467} 3528}
3468 3529
3469struct ahd_phase_table_entry* 3530static struct ahd_phase_table_entry*
3470ahd_lookup_phase_entry(int phase) 3531ahd_lookup_phase_entry(int phase)
3471{ 3532{
3472 struct ahd_phase_table_entry *entry; 3533 struct ahd_phase_table_entry *entry;
@@ -5351,7 +5412,7 @@ ahd_free(struct ahd_softc *ahd)
5351 return; 5412 return;
5352} 5413}
5353 5414
5354void 5415static void
5355ahd_shutdown(void *arg) 5416ahd_shutdown(void *arg)
5356{ 5417{
5357 struct ahd_softc *ahd; 5418 struct ahd_softc *ahd;
@@ -5480,7 +5541,7 @@ ahd_reset(struct ahd_softc *ahd, int reinit)
5480/* 5541/*
5481 * Determine the number of SCBs available on the controller 5542 * Determine the number of SCBs available on the controller
5482 */ 5543 */
5483int 5544static int
5484ahd_probe_scbs(struct ahd_softc *ahd) { 5545ahd_probe_scbs(struct ahd_softc *ahd) {
5485 int i; 5546 int i;
5486 5547
@@ -5929,7 +5990,7 @@ ahd_free_scb(struct ahd_softc *ahd, struct scb *scb)
5929 ahd_platform_scb_free(ahd, scb); 5990 ahd_platform_scb_free(ahd, scb);
5930} 5991}
5931 5992
5932void 5993static void
5933ahd_alloc_scbs(struct ahd_softc *ahd) 5994ahd_alloc_scbs(struct ahd_softc *ahd)
5934{ 5995{
5935 struct scb_data *scb_data; 5996 struct scb_data *scb_data;
@@ -6982,7 +7043,7 @@ ahd_intr_enable(struct ahd_softc *ahd, int enable)
6982 ahd_outb(ahd, HCNTRL, hcntrl); 7043 ahd_outb(ahd, HCNTRL, hcntrl);
6983} 7044}
6984 7045
6985void 7046static void
6986ahd_update_coalescing_values(struct ahd_softc *ahd, u_int timer, u_int maxcmds, 7047ahd_update_coalescing_values(struct ahd_softc *ahd, u_int timer, u_int maxcmds,
6987 u_int mincmds) 7048 u_int mincmds)
6988{ 7049{
@@ -7000,7 +7061,7 @@ ahd_update_coalescing_values(struct ahd_softc *ahd, u_int timer, u_int maxcmds,
7000 ahd_outb(ahd, INT_COALESCING_MINCMDS, -mincmds); 7061 ahd_outb(ahd, INT_COALESCING_MINCMDS, -mincmds);
7001} 7062}
7002 7063
7003void 7064static void
7004ahd_enable_coalescing(struct ahd_softc *ahd, int enable) 7065ahd_enable_coalescing(struct ahd_softc *ahd, int enable)
7005{ 7066{
7006 7067
@@ -7070,6 +7131,7 @@ ahd_pause_and_flushwork(struct ahd_softc *ahd)
7070 ahd->flags &= ~AHD_ALL_INTERRUPTS; 7131 ahd->flags &= ~AHD_ALL_INTERRUPTS;
7071} 7132}
7072 7133
7134#if 0
7073int 7135int
7074ahd_suspend(struct ahd_softc *ahd) 7136ahd_suspend(struct ahd_softc *ahd)
7075{ 7137{
@@ -7083,7 +7145,9 @@ ahd_suspend(struct ahd_softc *ahd)
7083 ahd_shutdown(ahd); 7145 ahd_shutdown(ahd);
7084 return (0); 7146 return (0);
7085} 7147}
7148#endif /* 0 */
7086 7149
7150#if 0
7087int 7151int
7088ahd_resume(struct ahd_softc *ahd) 7152ahd_resume(struct ahd_softc *ahd)
7089{ 7153{
@@ -7093,6 +7157,7 @@ ahd_resume(struct ahd_softc *ahd)
7093 ahd_restart(ahd); 7157 ahd_restart(ahd);
7094 return (0); 7158 return (0);
7095} 7159}
7160#endif /* 0 */
7096 7161
7097/************************** Busy Target Table *********************************/ 7162/************************** Busy Target Table *********************************/
7098/* 7163/*
@@ -7125,7 +7190,7 @@ ahd_index_busy_tcl(struct ahd_softc *ahd, u_int *saved_scbid, u_int tcl)
7125/* 7190/*
7126 * Return the untagged transaction id for a given target/channel lun. 7191 * Return the untagged transaction id for a given target/channel lun.
7127 */ 7192 */
7128u_int 7193static u_int
7129ahd_find_busy_tcl(struct ahd_softc *ahd, u_int tcl) 7194ahd_find_busy_tcl(struct ahd_softc *ahd, u_int tcl)
7130{ 7195{
7131 u_int scbid; 7196 u_int scbid;
@@ -7138,7 +7203,7 @@ ahd_find_busy_tcl(struct ahd_softc *ahd, u_int tcl)
7138 return (scbid); 7203 return (scbid);
7139} 7204}
7140 7205
7141void 7206static void
7142ahd_busy_tcl(struct ahd_softc *ahd, u_int tcl, u_int scbid) 7207ahd_busy_tcl(struct ahd_softc *ahd, u_int tcl, u_int scbid)
7143{ 7208{
7144 u_int scb_offset; 7209 u_int scb_offset;
@@ -7186,7 +7251,7 @@ ahd_match_scb(struct ahd_softc *ahd, struct scb *scb, int target,
7186 return match; 7251 return match;
7187} 7252}
7188 7253
7189void 7254static void
7190ahd_freeze_devq(struct ahd_softc *ahd, struct scb *scb) 7255ahd_freeze_devq(struct ahd_softc *ahd, struct scb *scb)
7191{ 7256{
7192 int target; 7257 int target;
@@ -7690,7 +7755,7 @@ ahd_add_scb_to_free_list(struct ahd_softc *ahd, u_int scbid)
7690 * been modified from CAM_REQ_INPROG. This routine assumes that the sequencer 7755 * been modified from CAM_REQ_INPROG. This routine assumes that the sequencer
7691 * is paused before it is called. 7756 * is paused before it is called.
7692 */ 7757 */
7693int 7758static int
7694ahd_abort_scbs(struct ahd_softc *ahd, int target, char channel, 7759ahd_abort_scbs(struct ahd_softc *ahd, int target, char channel,
7695 int lun, u_int tag, role_t role, uint32_t status) 7760 int lun, u_int tag, role_t role, uint32_t status)
7696{ 7761{
@@ -8019,18 +8084,8 @@ ahd_stat_timer(void *arg)
8019} 8084}
8020 8085
8021/****************************** Status Processing *****************************/ 8086/****************************** Status Processing *****************************/
8022void
8023ahd_handle_scb_status(struct ahd_softc *ahd, struct scb *scb)
8024{
8025 if (scb->hscb->shared_data.istatus.scsi_status != 0) {
8026 ahd_handle_scsi_status(ahd, scb);
8027 } else {
8028 ahd_calc_residual(ahd, scb);
8029 ahd_done(ahd, scb);
8030 }
8031}
8032 8087
8033void 8088static void
8034ahd_handle_scsi_status(struct ahd_softc *ahd, struct scb *scb) 8089ahd_handle_scsi_status(struct ahd_softc *ahd, struct scb *scb)
8035{ 8090{
8036 struct hardware_scb *hscb; 8091 struct hardware_scb *hscb;
@@ -8238,10 +8293,21 @@ ahd_handle_scsi_status(struct ahd_softc *ahd, struct scb *scb)
8238 } 8293 }
8239} 8294}
8240 8295
8296static void
8297ahd_handle_scb_status(struct ahd_softc *ahd, struct scb *scb)
8298{
8299 if (scb->hscb->shared_data.istatus.scsi_status != 0) {
8300 ahd_handle_scsi_status(ahd, scb);
8301 } else {
8302 ahd_calc_residual(ahd, scb);
8303 ahd_done(ahd, scb);
8304 }
8305}
8306
8241/* 8307/*
8242 * Calculate the residual for a just completed SCB. 8308 * Calculate the residual for a just completed SCB.
8243 */ 8309 */
8244void 8310static void
8245ahd_calc_residual(struct ahd_softc *ahd, struct scb *scb) 8311ahd_calc_residual(struct ahd_softc *ahd, struct scb *scb)
8246{ 8312{
8247 struct hardware_scb *hscb; 8313 struct hardware_scb *hscb;
@@ -9092,6 +9158,7 @@ ahd_dump_card_state(struct ahd_softc *ahd)
9092 ahd_unpause(ahd); 9158 ahd_unpause(ahd);
9093} 9159}
9094 9160
9161#if 0
9095void 9162void
9096ahd_dump_scbs(struct ahd_softc *ahd) 9163ahd_dump_scbs(struct ahd_softc *ahd)
9097{ 9164{
@@ -9117,6 +9184,7 @@ ahd_dump_scbs(struct ahd_softc *ahd)
9117 ahd_set_scbptr(ahd, saved_scb_index); 9184 ahd_set_scbptr(ahd, saved_scb_index);
9118 ahd_restore_modes(ahd, saved_modes); 9185 ahd_restore_modes(ahd, saved_modes);
9119} 9186}
9187#endif /* 0 */
9120 9188
9121/**************************** Flexport Logic **********************************/ 9189/**************************** Flexport Logic **********************************/
9122/* 9190/*
@@ -9219,7 +9287,7 @@ ahd_write_seeprom(struct ahd_softc *ahd, uint16_t *buf,
9219/* 9287/*
9220 * Wait ~100us for the serial eeprom to satisfy our request. 9288 * Wait ~100us for the serial eeprom to satisfy our request.
9221 */ 9289 */
9222int 9290static int
9223ahd_wait_seeprom(struct ahd_softc *ahd) 9291ahd_wait_seeprom(struct ahd_softc *ahd)
9224{ 9292{
9225 int cnt; 9293 int cnt;
@@ -9237,7 +9305,7 @@ ahd_wait_seeprom(struct ahd_softc *ahd)
9237 * Validate the two checksums in the per_channel 9305 * Validate the two checksums in the per_channel
9238 * vital product data struct. 9306 * vital product data struct.
9239 */ 9307 */
9240int 9308static int
9241ahd_verify_vpd_cksum(struct vpd_config *vpd) 9309ahd_verify_vpd_cksum(struct vpd_config *vpd)
9242{ 9310{
9243 int i; 9311 int i;
@@ -9316,6 +9384,24 @@ ahd_release_seeprom(struct ahd_softc *ahd)
9316 /* Currently a no-op */ 9384 /* Currently a no-op */
9317} 9385}
9318 9386
9387/*
9388 * Wait at most 2 seconds for flexport arbitration to succeed.
9389 */
9390static int
9391ahd_wait_flexport(struct ahd_softc *ahd)
9392{
9393 int cnt;
9394
9395 AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
9396 cnt = 1000000 * 2 / 5;
9397 while ((ahd_inb(ahd, BRDCTL) & FLXARBACK) == 0 && --cnt)
9398 ahd_delay(5);
9399
9400 if (cnt == 0)
9401 return (ETIMEDOUT);
9402 return (0);
9403}
9404
9319int 9405int
9320ahd_write_flexport(struct ahd_softc *ahd, u_int addr, u_int value) 9406ahd_write_flexport(struct ahd_softc *ahd, u_int addr, u_int value)
9321{ 9407{
@@ -9357,24 +9443,6 @@ ahd_read_flexport(struct ahd_softc *ahd, u_int addr, uint8_t *value)
9357 return (0); 9443 return (0);
9358} 9444}
9359 9445
9360/*
9361 * Wait at most 2 seconds for flexport arbitration to succeed.
9362 */
9363int
9364ahd_wait_flexport(struct ahd_softc *ahd)
9365{
9366 int cnt;
9367
9368 AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
9369 cnt = 1000000 * 2 / 5;
9370 while ((ahd_inb(ahd, BRDCTL) & FLXARBACK) == 0 && --cnt)
9371 ahd_delay(5);
9372
9373 if (cnt == 0)
9374 return (ETIMEDOUT);
9375 return (0);
9376}
9377
9378/************************* Target Mode ****************************************/ 9446/************************* Target Mode ****************************************/
9379#ifdef AHD_TARGET_MODE 9447#ifdef AHD_TARGET_MODE
9380cam_status 9448cam_status