|
|
@@ -23,9 +23,9 @@
|
|
|
// SM1: Write data to SCSI bus
|
|
|
// SM2: For synchronous mode only, count ACK pulses
|
|
|
#define SCSI_DMA_PIO pio0
|
|
|
-#define SCSI_PARITY_SM 0
|
|
|
-#define SCSI_DATA_SM 1
|
|
|
-#define SCSI_SYNC_SM 2
|
|
|
+#define SCSI_PARITY_SM 1
|
|
|
+#define SCSI_DATA_SM 2
|
|
|
+#define SCSI_SYNC_SM 3
|
|
|
|
|
|
// SCSI bus write acceleration uses 3 or 4 DMA channels (data flow A->B->C->D):
|
|
|
// A: Bytes from RAM to scsi_parity PIO
|
|
|
@@ -38,10 +38,10 @@
|
|
|
// B: Lookup from g_scsi_parity_check_lookup and copy to scsi_read_parity PIO
|
|
|
// C: Addresses from scsi_accel_read PIO to lookup DMA READ_ADDR register
|
|
|
// D: From pacer to data state machine to trigger transfers
|
|
|
-#define SCSI_DMA_CH_A 4
|
|
|
-#define SCSI_DMA_CH_B 5
|
|
|
-#define SCSI_DMA_CH_C 6
|
|
|
-#define SCSI_DMA_CH_D 7
|
|
|
+#define SCSI_DMA_CH_A 6
|
|
|
+#define SCSI_DMA_CH_B 7
|
|
|
+#define SCSI_DMA_CH_C 8
|
|
|
+#define SCSI_DMA_CH_D 9
|
|
|
|
|
|
static struct {
|
|
|
uint8_t *app_buf; // Buffer provided by application
|
|
|
@@ -824,9 +824,32 @@ void scsi_accel_rp2040_init()
|
|
|
g_scsi_dma_state = SCSIDMA_IDLE;
|
|
|
scsidma_config_gpio();
|
|
|
|
|
|
- // Mark channels as being in use, unless it has been done already
|
|
|
- if (!g_channels_claimed)
|
|
|
- {
|
|
|
+ if (g_channels_claimed) {
|
|
|
+ // Un-claim all SCSI state machines
|
|
|
+ pio_sm_unclaim(SCSI_DMA_PIO, SCSI_PARITY_SM);
|
|
|
+ pio_sm_unclaim(SCSI_DMA_PIO, SCSI_DATA_SM);
|
|
|
+ pio_sm_unclaim(SCSI_DMA_PIO, SCSI_SYNC_SM);
|
|
|
+
|
|
|
+ // Remove all SCSI programs
|
|
|
+ pio_remove_program(SCSI_DMA_PIO, &scsi_parity_program, g_scsi_dma.pio_offset_parity);
|
|
|
+ pio_remove_program(SCSI_DMA_PIO, &scsi_accel_async_write_program, g_scsi_dma.pio_offset_async_write);
|
|
|
+ pio_remove_program(SCSI_DMA_PIO, &scsi_sync_write_pacer_program, g_scsi_dma.pio_offset_sync_write_pacer);
|
|
|
+ pio_remove_program(SCSI_DMA_PIO, &scsi_sync_write_program, g_scsi_dma.pio_offset_sync_write);
|
|
|
+ pio_remove_program(SCSI_DMA_PIO, &scsi_accel_read_program, g_scsi_dma.pio_offset_read);
|
|
|
+ pio_remove_program(SCSI_DMA_PIO, &scsi_sync_read_pacer_program, g_scsi_dma.pio_offset_sync_read_pacer);
|
|
|
+ pio_remove_program(SCSI_DMA_PIO, &scsi_read_parity_program, g_scsi_dma.pio_offset_read_parity);
|
|
|
+
|
|
|
+ // Un-claim all SCSI DMA channels
|
|
|
+ dma_channel_unclaim(SCSI_DMA_CH_A);
|
|
|
+ dma_channel_unclaim(SCSI_DMA_CH_B);
|
|
|
+ dma_channel_unclaim(SCSI_DMA_CH_C);
|
|
|
+ dma_channel_unclaim(SCSI_DMA_CH_D);
|
|
|
+
|
|
|
+ // Set flag to re-initialize SCSI PIO system
|
|
|
+ g_channels_claimed = false;
|
|
|
+ }
|
|
|
+ if (!g_channels_claimed) {
|
|
|
+ // Mark channels as being in use, unless it has been done already
|
|
|
pio_sm_claim(SCSI_DMA_PIO, SCSI_PARITY_SM);
|
|
|
pio_sm_claim(SCSI_DMA_PIO, SCSI_DATA_SM);
|
|
|
pio_sm_claim(SCSI_DMA_PIO, SCSI_SYNC_SM);
|
|
|
@@ -836,9 +859,6 @@ void scsi_accel_rp2040_init()
|
|
|
dma_channel_claim(SCSI_DMA_CH_D);
|
|
|
g_channels_claimed = true;
|
|
|
}
|
|
|
-
|
|
|
- // Load PIO programs
|
|
|
- pio_clear_instruction_memory(SCSI_DMA_PIO);
|
|
|
|
|
|
// Parity lookup generator
|
|
|
g_scsi_dma.pio_offset_parity = pio_add_program(SCSI_DMA_PIO, &scsi_parity_program);
|