summaryrefslogtreecommitdiff
path: root/firmware/target/arm/as3525/ata_sd_as3525.c
diff options
context:
space:
mode:
authorRafaël Carré <rafael.carre@gmail.com>2008-12-04 20:48:19 +0000
committerRafaël Carré <rafael.carre@gmail.com>2008-12-04 20:48:19 +0000
commit1ab08e6879b1fe50102fe68a1326db05891e6faa (patch)
treeb066febe812ae945fe1c91781338b0334edf0a00 /firmware/target/arm/as3525/ata_sd_as3525.c
parent76617c8f9444bfc24744e6e4faeff06d25372fa8 (diff)
downloadrockbox-1ab08e6879b1fe50102fe68a1326db05891e6faa.tar.gz
rockbox-1ab08e6879b1fe50102fe68a1326db05891e6faa.zip
Sansa AMS: updates DMA API
* Adds a callback to be called on end of transfer * Add a function to disable a channel * Services the 2 channels if both are active in the isr SD driver: panics on error git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19333 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/as3525/ata_sd_as3525.c')
-rw-r--r--firmware/target/arm/as3525/ata_sd_as3525.c49
1 files changed, 43 insertions, 6 deletions
diff --git a/firmware/target/arm/as3525/ata_sd_as3525.c b/firmware/target/arm/as3525/ata_sd_as3525.c
index b2d8e3c1f3..3ec1892542 100644
--- a/firmware/target/arm/as3525/ata_sd_as3525.c
+++ b/firmware/target/arm/as3525/ata_sd_as3525.c
@@ -129,6 +129,37 @@ static void mci_set_clock_divider(const int drive, int divider)
129 mci_delay(); 129 mci_delay();
130} 130}
131 131
132static void sd_panic(IF_MV2(const int drive,) const int status)
133{
134 char error[32];
135 error[0] = '\0';
136
137#ifdef HAVE_MULTIVOLUME
138 snprintf(error, sizeof(error),
139 (drive == INTERNAL_AS3525) ? "Internal storage : " : "SD Slot : " );
140#endif
141
142 panicf("SD : %s%s%s%s%s%s%s", error,
143 (status & MCI_DATA_CRC_FAIL) ? "DATA CRC FAIL, " : "",
144 (status & MCI_DATA_TIMEOUT) ? "DATA TIMEOUT, " : "",
145 (status & MCI_RX_OVERRUN) ? "RX OVERRUN, " : "",
146 (status & MCI_TX_UNDERRUN) ? "TX UNDERRUN, " : "",
147 (status & MCI_RX_FIFO_FULL) ? "RXR FIFO FULL, " : "",
148 (status & MCI_TX_FIFO_EMPTY) ? "TX FIFO EMPTY" : "");
149}
150
151void INT_NAND(void)
152{
153 sd_panic(IF_MV2(INTERNAL_AS3525,) MCI_STATUS(INTERNAL_AS3525));
154}
155
156#ifdef HAVE_MULTIVOLUME
157void INT_MCI0(void)
158{
159 sd_panic(SD_SLOT_AS3525, MCI_STATUS(SD_SLOT_AS3525));
160}
161#endif
162
132static bool send_cmd(const int drive, const int cmd, const int arg, 163static bool send_cmd(const int drive, const int cmd, const int arg,
133 const int flags, int *response) 164 const int flags, int *response)
134{ 165{
@@ -362,7 +393,14 @@ static void init_pl180_controller(const int drive)
362 MCI_COMMAND(drive) = MCI_DATA_CTRL(drive) = 0; 393 MCI_COMMAND(drive) = MCI_DATA_CTRL(drive) = 0;
363 MCI_CLEAR(drive) = 0x7ff; 394 MCI_CLEAR(drive) = 0x7ff;
364 395
365 MCI_MASK0(drive) = MCI_MASK1(drive) = 0; /* disable all interrupts */ 396 MCI_MASK0(drive) = MCI_MASK1(drive) = MCI_DATA_CRC_FAIL | MCI_DATA_TIMEOUT |
397 MCI_RX_OVERRUN | MCI_TX_UNDERRUN | MCI_RX_FIFO_FULL | MCI_TX_FIFO_EMPTY;
398
399 VIC_INT_ENABLE |= INTERRUPT_NAND
400#ifdef HAVE_MULTIVOLUME
401 | INTERRUPT_MCI0
402#endif
403 ;
366 404
367 MCI_POWER(drive) = MCI_POWER_UP|(10 /*voltage*/ << 2); /* use OF voltage */ 405 MCI_POWER(drive) = MCI_POWER_UP|(10 /*voltage*/ << 2); /* use OF voltage */
368 mci_delay(); 406 mci_delay();
@@ -378,7 +416,6 @@ static void init_pl180_controller(const int drive)
378 /* set MCLK divider */ 416 /* set MCLK divider */
379 mci_set_clock_divider(drive, 417 mci_set_clock_divider(drive,
380 CLK_DIV(AS3525_PCLK_FREQ, AS3525_SD_IDENT_FREQ)); 418 CLK_DIV(AS3525_PCLK_FREQ, AS3525_SD_IDENT_FREQ));
381
382} 419}
383 420
384int sd_init(void) 421int sd_init(void)
@@ -552,12 +589,12 @@ static int sd_transfer_sectors(IF_MV2(int drive,) unsigned long start,
552 589
553 if(write) 590 if(write)
554 dma_enable_channel(0, buf, MCI_FIFO(drive), 591 dma_enable_channel(0, buf, MCI_FIFO(drive),
555 (drive == INTERNAL_AS3525) ? DMA_PERI_SD : DMA_PERI_SD_SLOT, 592 (drive == INTERNAL_AS3525) ? DMA_PERI_SD : DMA_PERI_SD_SLOT,
556 DMAC_FLOWCTRL_PERI_MEM_TO_PERI, true, false, 0, DMA_S8); 593 DMAC_FLOWCTRL_PERI_MEM_TO_PERI, true, false, 0, DMA_S8, NULL);
557 else 594 else
558 dma_enable_channel(0, MCI_FIFO(drive), buf, 595 dma_enable_channel(0, MCI_FIFO(drive), buf,
559 (drive == INTERNAL_AS3525) ? DMA_PERI_SD : DMA_PERI_SD_SLOT, 596 (drive == INTERNAL_AS3525) ? DMA_PERI_SD : DMA_PERI_SD_SLOT,
560 DMAC_FLOWCTRL_PERI_PERI_TO_MEM, false, true, 0, DMA_S8); 597 DMAC_FLOWCTRL_PERI_PERI_TO_MEM, false, true, 0, DMA_S8, NULL);
561 598
562 MCI_DATA_TIMER(drive) = 0x1000000; /* FIXME: arbitrary */ 599 MCI_DATA_TIMER(drive) = 0x1000000; /* FIXME: arbitrary */
563 MCI_DATA_LENGTH(drive) = transfer * card_info[drive].block_size; 600 MCI_DATA_LENGTH(drive) = transfer * card_info[drive].block_size;