Skip to content

Commit 6fe07aa

Browse files
Finn ThainJames Bottomley
authored andcommitted
[SCSI] m68k: new mac_esp scsi driver
Replace the mac_esp driver with a new one based on the esp_scsi core. For esp_scsi: add support for sync transfers for the PIO mode, add a new esp_driver_ops method to get the maximum dma transfer size (like the old NCR53C9x driver), and some cleanups. Signed-off-by: Finn Thain <[email protected]> Acked-by: David S. Miller <[email protected]> Signed-off-by: Geert Uytterhoeven <[email protected]> Signed-off-by: James Bottomley <[email protected]>
1 parent 6d9d63b commit 6fe07aa

File tree

5 files changed

+700
-12
lines changed

5 files changed

+700
-12
lines changed

drivers/scsi/Kconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1677,6 +1677,16 @@ config MAC_SCSI
16771677
SCSI-HOWTO, available from
16781678
<http://www.tldp.org/docs.html#howto>.
16791679

1680+
config SCSI_MAC_ESP
1681+
tristate "Macintosh NCR53c9[46] SCSI"
1682+
depends on MAC && SCSI
1683+
help
1684+
This is the NCR 53c9x SCSI controller found on most of the 68040
1685+
based Macintoshes.
1686+
1687+
To compile this driver as a module, choose M here: the module
1688+
will be called mac_esp.
1689+
16801690
config MVME147_SCSI
16811691
bool "WD33C93 SCSI driver for MVME147"
16821692
depends on MVME147 && SCSI=y

drivers/scsi/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ obj-$(CONFIG_MVME147_SCSI) += mvme147.o wd33c93.o
4646
obj-$(CONFIG_SGIWD93_SCSI) += sgiwd93.o wd33c93.o
4747
obj-$(CONFIG_ATARI_SCSI) += atari_scsi.o
4848
obj-$(CONFIG_MAC_SCSI) += mac_scsi.o
49+
obj-$(CONFIG_SCSI_MAC_ESP) += esp_scsi.o mac_esp.o
4950
obj-$(CONFIG_SUN3_SCSI) += sun3_scsi.o sun3_scsi_vme.o
5051
obj-$(CONFIG_MVME16x_SCSI) += 53c700.o mvme16x_scsi.o
5152
obj-$(CONFIG_BVME6000_SCSI) += 53c700.o bvme6000_scsi.o

drivers/scsi/esp_scsi.c

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -978,7 +978,7 @@ static int esp_check_spur_intr(struct esp *esp)
978978
*/
979979
if (!esp->ops->dma_error(esp)) {
980980
printk(KERN_ERR PFX "esp%d: Spurious irq, "
981-
"sreg=%x.\n",
981+
"sreg=%02x.\n",
982982
esp->host->unique_id, esp->sreg);
983983
return -1;
984984
}
@@ -1447,6 +1447,9 @@ static void esp_msgin_sdtr(struct esp *esp, struct esp_target_data *tp)
14471447
if (offset > 15)
14481448
goto do_reject;
14491449

1450+
if (esp->flags & ESP_FLAG_DISABLE_SYNC)
1451+
offset = 0;
1452+
14501453
if (offset) {
14511454
int rounded_up, one_clock;
14521455

@@ -1697,7 +1700,12 @@ static int esp_process_event(struct esp *esp)
16971700
else
16981701
ent->flags &= ~ESP_CMD_FLAG_WRITE;
16991702

1700-
dma_len = esp_dma_length_limit(esp, dma_addr, dma_len);
1703+
if (esp->ops->dma_length_limit)
1704+
dma_len = esp->ops->dma_length_limit(esp, dma_addr,
1705+
dma_len);
1706+
else
1707+
dma_len = esp_dma_length_limit(esp, dma_addr, dma_len);
1708+
17011709
esp->data_dma_len = dma_len;
17021710

17031711
if (!dma_len) {
@@ -1761,7 +1769,6 @@ static int esp_process_event(struct esp *esp)
17611769
esp_advance_dma(esp, ent, cmd, bytes_sent);
17621770
esp_event(esp, ESP_EVENT_CHECK_PHASE);
17631771
goto again;
1764-
break;
17651772
}
17661773

17671774
case ESP_EVENT_STATUS: {
@@ -2235,7 +2242,7 @@ static void esp_bootup_reset(struct esp *esp)
22352242

22362243
static void esp_set_clock_params(struct esp *esp)
22372244
{
2238-
int fmhz;
2245+
int fhz;
22392246
u8 ccf;
22402247

22412248
/* This is getting messy but it has to be done correctly or else
@@ -2270,9 +2277,9 @@ static void esp_set_clock_params(struct esp *esp)
22702277
* This entails the smallest and largest sync period we could ever
22712278
* handle on this ESP.
22722279
*/
2273-
fmhz = esp->cfreq;
2280+
fhz = esp->cfreq;
22742281

2275-
ccf = ((fmhz / 1000000) + 4) / 5;
2282+
ccf = ((fhz / 1000000) + 4) / 5;
22762283
if (ccf == 1)
22772284
ccf = 2;
22782285

@@ -2281,16 +2288,16 @@ static void esp_set_clock_params(struct esp *esp)
22812288
* been unable to find the clock-frequency PROM property. All
22822289
* other machines provide useful values it seems.
22832290
*/
2284-
if (fmhz <= 5000000 || ccf < 1 || ccf > 8) {
2285-
fmhz = 20000000;
2291+
if (fhz <= 5000000 || ccf < 1 || ccf > 8) {
2292+
fhz = 20000000;
22862293
ccf = 4;
22872294
}
22882295

22892296
esp->cfact = (ccf == 8 ? 0 : ccf);
2290-
esp->cfreq = fmhz;
2291-
esp->ccycle = ESP_MHZ_TO_CYCLE(fmhz);
2297+
esp->cfreq = fhz;
2298+
esp->ccycle = ESP_HZ_TO_CYCLE(fhz);
22922299
esp->ctick = ESP_TICK(ccf, esp->ccycle);
2293-
esp->neg_defp = ESP_NEG_DEFP(fmhz, ccf);
2300+
esp->neg_defp = ESP_NEG_DEFP(fhz, ccf);
22942301
esp->sync_defp = SYNC_DEFP_SLOW;
22952302
}
22962303

@@ -2382,6 +2389,12 @@ static int esp_slave_configure(struct scsi_device *dev)
23822389
struct esp_target_data *tp = &esp->target[dev->id];
23832390
int goal_tags, queue_depth;
23842391

2392+
if (esp->flags & ESP_FLAG_DISABLE_SYNC) {
2393+
/* Bypass async domain validation */
2394+
dev->ppr = 0;
2395+
dev->sdtr = 0;
2396+
}
2397+
23852398
goal_tags = 0;
23862399

23872400
if (dev->tagged_supported) {

drivers/scsi/esp_scsi.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@
224224
#define ESP_TIMEO_CONST 8192
225225
#define ESP_NEG_DEFP(mhz, cfact) \
226226
((ESP_BUS_TIMEOUT * ((mhz) / 1000)) / (8192 * (cfact)))
227-
#define ESP_MHZ_TO_CYCLE(mhertz) ((1000000000) / ((mhertz) / 1000))
227+
#define ESP_HZ_TO_CYCLE(hertz) ((1000000000) / ((hertz) / 1000))
228228
#define ESP_TICK(ccf, cycle) ((7682 * (ccf) * (cycle) / 1000))
229229

230230
/* For slow to medium speed input clock rates we shoot for 5mb/s, but for high
@@ -368,6 +368,12 @@ struct esp_driver_ops {
368368
*/
369369
int (*irq_pending)(struct esp *esp);
370370

371+
/* Return the maximum allowable size of a DMA transfer for a
372+
* given buffer.
373+
*/
374+
u32 (*dma_length_limit)(struct esp *esp, u32 dma_addr,
375+
u32 dma_len);
376+
371377
/* Reset the DMA engine entirely. On return, ESP interrupts
372378
* should be enabled. Often the interrupt enabling is
373379
* controlled in the DMA engine.
@@ -471,6 +477,7 @@ struct esp {
471477
#define ESP_FLAG_DOING_SLOWCMD 0x00000004
472478
#define ESP_FLAG_WIDE_CAPABLE 0x00000008
473479
#define ESP_FLAG_QUICKIRQ_CHECK 0x00000010
480+
#define ESP_FLAG_DISABLE_SYNC 0x00000020
474481

475482
u8 select_state;
476483
#define ESP_SELECT_NONE 0x00 /* Not selecting */

0 commit comments

Comments
 (0)