Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2)  * Copyright (c) 2000-2001 Adaptec Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Redistribution and use in source and binary forms, with or without
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * modification, are permitted provided that the following conditions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * are met:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  * 1. Redistributions of source code must retain the above copyright
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  *    notice, this list of conditions, and the following disclaimer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  *    without modification.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  *    substantially similar to the "NO WARRANTY" disclaimer below
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  *    ("Disclaimer") and any redistribution must be conditioned upon
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  *    including a substantially similar Disclaimer requirement for further
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  *    binary redistribution.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  * 3. Neither the names of the above-listed copyright holders nor the names
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  *    of any contributors may be used to endorse or promote products derived
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  *    from this software without specific prior written permission.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  * Alternatively, this software may be distributed under the terms of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  * GNU General Public License ("GPL") version 2 as published by the Free
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  * Software Foundation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  * NO WARRANTY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31)  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32)  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33)  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34)  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35)  * POSSIBILITY OF SUCH DAMAGES.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37)  * String handling code courtesy of Gerard Roudier's <groudier@club-internet.fr>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38)  * sym driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)  * $Id: //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_proc.c#29 $
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) #include "aic7xxx_osm.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) #include "aic7xxx_inline.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) #include "aic7xxx_93cx6.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) static void	ahc_dump_target_state(struct ahc_softc *ahc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 				      struct seq_file *m,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 				      u_int our_id, char channel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 				      u_int target_id, u_int target_offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) static void	ahc_dump_device_state(struct seq_file *m,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 				      struct scsi_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54)  * Table of syncrates that don't follow the "divisible by 4"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55)  * rule. This table will be expanded in future SCSI specs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) static const struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	u_int period_factor;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	u_int period;	/* in 100ths of ns */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) } scsi_syncrates[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	{ 0x08, 625 },	/* FAST-160 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	{ 0x09, 1250 },	/* FAST-80 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	{ 0x0a, 2500 },	/* FAST-40 40MHz */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	{ 0x0b, 3030 },	/* FAST-40 33MHz */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	{ 0x0c, 5000 }	/* FAST-20 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69)  * Return the frequency in kHz corresponding to the given
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70)  * sync period factor.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) static u_int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) ahc_calc_syncsrate(u_int period_factor)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	/* See if the period is in the "exception" table */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	for (i = 0; i < ARRAY_SIZE(scsi_syncrates); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 		if (period_factor == scsi_syncrates[i].period_factor) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 			/* Period in kHz */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 			return (100000000 / scsi_syncrates[i].period);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	 * Wasn't in the table, so use the standard
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	 * 4 times conversion.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	return (10000000 / (period_factor * 4 * 10));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) ahc_format_transinfo(struct seq_file *m, struct ahc_transinfo *tinfo)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	u_int speed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	u_int freq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	u_int mb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)         speed = 3300;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)         freq = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	if (tinfo->offset != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 		freq = ahc_calc_syncsrate(tinfo->period);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 		speed = freq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	speed *= (0x01 << tinfo->width);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)         mb = speed / 1000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)         if (mb > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 		seq_printf(m, "%d.%03dMB/s transfers", mb, speed % 1000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)         else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 		seq_printf(m, "%dKB/s transfers", speed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	if (freq != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 		seq_printf(m, " (%d.%03dMHz%s, offset %d",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 			 freq / 1000, freq % 1000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 			 (tinfo->ppr_options & MSG_EXT_PPR_DT_REQ) != 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 			 ? " DT" : "", tinfo->offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	if (tinfo->width > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 		if (freq != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 			seq_puts(m, ", ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 			seq_puts(m, " (");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 		seq_printf(m, "%dbit)", 8 * (0x01 << tinfo->width));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	} else if (freq != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 		seq_putc(m, ')');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	seq_putc(m, '\n');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) ahc_dump_target_state(struct ahc_softc *ahc, struct seq_file *m,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 		      u_int our_id, char channel, u_int target_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 		      u_int target_offset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	struct	scsi_target *starget;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	struct	ahc_initiator_tinfo *tinfo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	struct	ahc_tmode_tstate *tstate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	int	lun;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	tinfo = ahc_fetch_transinfo(ahc, channel, our_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 				    target_id, &tstate);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	if ((ahc->features & AHC_TWIN) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 		seq_printf(m, "Channel %c ", channel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	seq_printf(m, "Target %d Negotiation Settings\n", target_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	seq_puts(m, "\tUser: ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	ahc_format_transinfo(m, &tinfo->user);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	starget = ahc->platform_data->starget[target_offset];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	if (!starget)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	seq_puts(m, "\tGoal: ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	ahc_format_transinfo(m, &tinfo->goal);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	seq_puts(m, "\tCurr: ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	ahc_format_transinfo(m, &tinfo->curr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	for (lun = 0; lun < AHC_NUM_LUNS; lun++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 		struct scsi_device *sdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 		sdev = scsi_device_lookup_by_target(starget, lun);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 		if (sdev == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 		ahc_dump_device_state(m, sdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) ahc_dump_device_state(struct seq_file *m, struct scsi_device *sdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	struct ahc_linux_device *dev = scsi_transport_device_data(sdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	seq_printf(m, "\tChannel %c Target %d Lun %d Settings\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 		  sdev->sdev_target->channel + 'A',
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 		   sdev->sdev_target->id, (u8)sdev->lun);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	seq_printf(m, "\t\tCommands Queued %ld\n", dev->commands_issued);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	seq_printf(m, "\t\tCommands Active %d\n", dev->active);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	seq_printf(m, "\t\tCommand Openings %d\n", dev->openings);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	seq_printf(m, "\t\tMax Tagged Openings %d\n", dev->maxtags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	seq_printf(m, "\t\tDevice Queue Frozen Count %d\n", dev->qfrozen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) ahc_proc_write_seeprom(struct Scsi_Host *shost, char *buffer, int length)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	struct	ahc_softc *ahc = *(struct ahc_softc **)shost->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	struct seeprom_descriptor sd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	int have_seeprom;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	u_long s;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	int paused;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	int written;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	/* Default to failure. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	written = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	ahc_lock(ahc, &s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	paused = ahc_is_paused(ahc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	if (!paused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 		ahc_pause(ahc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	if (length != sizeof(struct seeprom_config)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 		printk("ahc_proc_write_seeprom: incorrect buffer size\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 		goto done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	have_seeprom = ahc_verify_cksum((struct seeprom_config*)buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	if (have_seeprom == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 		printk("ahc_proc_write_seeprom: cksum verification failed\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 		goto done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	sd.sd_ahc = ahc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) #if AHC_PCI_CONFIG > 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	if ((ahc->chip & AHC_PCI) != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 		sd.sd_control_offset = SEECTL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 		sd.sd_status_offset = SEECTL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 		sd.sd_dataout_offset = SEECTL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 		if (ahc->flags & AHC_LARGE_SEEPROM)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 			sd.sd_chip = C56_66;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 			sd.sd_chip = C46;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 		sd.sd_MS = SEEMS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 		sd.sd_RDY = SEERDY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 		sd.sd_CS = SEECS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 		sd.sd_CK = SEECK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 		sd.sd_DO = SEEDO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 		sd.sd_DI = SEEDI;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 		have_seeprom = ahc_acquire_seeprom(ahc, &sd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	if ((ahc->chip & AHC_VL) != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 		sd.sd_control_offset = SEECTL_2840;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 		sd.sd_status_offset = STATUS_2840;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 		sd.sd_dataout_offset = STATUS_2840;		
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 		sd.sd_chip = C46;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 		sd.sd_MS = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 		sd.sd_RDY = EEPROM_TF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 		sd.sd_CS = CS_2840;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 		sd.sd_CK = CK_2840;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 		sd.sd_DO = DO_2840;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 		sd.sd_DI = DI_2840;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 		have_seeprom = TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 		printk("ahc_proc_write_seeprom: unsupported adapter type\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 		goto done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	if (!have_seeprom) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 		printk("ahc_proc_write_seeprom: No Serial EEPROM\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 		goto done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 		u_int start_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 		if (ahc->seep_config == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 			ahc->seep_config = kmalloc(sizeof(*ahc->seep_config), GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 			if (ahc->seep_config == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 				printk("aic7xxx: Unable to allocate serial "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 				       "eeprom buffer.  Write failing\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 				goto done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 		printk("aic7xxx: Writing Serial EEPROM\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 		start_addr = 32 * (ahc->channel - 'A');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 		ahc_write_seeprom(&sd, (u_int16_t *)buffer, start_addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 				  sizeof(struct seeprom_config)/2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 		ahc_read_seeprom(&sd, (uint16_t *)ahc->seep_config,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 				 start_addr, sizeof(struct seeprom_config)/2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) #if AHC_PCI_CONFIG > 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 		if ((ahc->chip & AHC_VL) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 			ahc_release_seeprom(&sd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 		written = length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) done:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 	if (!paused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 		ahc_unpause(ahc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 	ahc_unlock(ahc, &s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 	return (written);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286)  * Return information to handle /proc support for the driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) ahc_linux_show_info(struct seq_file *m, struct Scsi_Host *shost)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 	struct	ahc_softc *ahc = *(struct ahc_softc **)shost->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 	char	ahc_info[256];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 	u_int	max_targ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 	u_int	i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 	seq_printf(m, "Adaptec AIC7xxx driver version: %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 		  AIC7XXX_DRIVER_VERSION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 	seq_printf(m, "%s\n", ahc->description);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 	ahc_controller_info(ahc, ahc_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 	seq_printf(m, "%s\n", ahc_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 	seq_printf(m, "Allocated SCBs: %d, SG List Length: %d\n\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 		  ahc->scb_data->numscbs, AHC_NSEG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 	if (ahc->seep_config == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 		seq_puts(m, "No Serial EEPROM\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 	else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 		seq_puts(m, "Serial EEPROM:\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 		for (i = 0; i < sizeof(*ahc->seep_config)/2; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 			if (((i % 8) == 0) && (i != 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 				seq_putc(m, '\n');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 			seq_printf(m, "0x%.4x ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 				  ((uint16_t*)ahc->seep_config)[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 		seq_putc(m, '\n');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 	seq_putc(m, '\n');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 	max_targ = 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 	if ((ahc->features & (AHC_WIDE|AHC_TWIN)) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 		max_targ = 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 	for (i = 0; i < max_targ; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 		u_int our_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 		u_int target_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 		char channel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 		channel = 'A';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 		our_id = ahc->our_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 		target_id = i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 		if (i > 7 && (ahc->features & AHC_TWIN) != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 			channel = 'B';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 			our_id = ahc->our_id_b;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 			target_id = i % 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 		ahc_dump_target_state(ahc, m, our_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 				      channel, target_id, i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) }