ide: add support for CFA specified transfer modes
PATCH 2/2 ide: add support for CFA specified transfer modes
Add support for the CompactFlash specific PIO modes 5/6 and MWDMA modes 3/4.
---
This patch is against the current pata-2.6 series. Since there were no PIO5 capable hard drives produced and you also need 66 MHz input clock to actually get the difference WRT the setup timing programmed, I decided to simply replace the old non-standard PIO mode 5 timings with CFA specified ones. Phew, hopefully I haven't overlooked anything -- quite a lot had to be changed.
Stanislaw, please give it a try -- I don't have any CF hardware now.
drivers/ide/ide-dma.c | 8 ++++++++ drivers/ide/ide-iops.c | 8 ++++++++ drivers/ide/ide-timings.c | 12 ++++++++++-- drivers/ide/ide-xfer-mode.c | 15 +++++++++------ 4 files changed, 35 insertions(+), 8 deletions(-)
drivers/ide/ide-dma.c +8 -0
@@ -261,6 +261,14 @@ static unsigned int ide_get_mode_mask(idbreak ;case XFER_MW_DMA_0 : mask = id[ATA_ID_MWDMA_MODES ]; + +/* Also look for the CF specific MWDMA modes... */ +if (ata_id_is_cfa (id) && (id[ATA_ID_CFA_MODES ] &0x38 )) { +u8 mode = ((id[ATA_ID_CFA_MODES ] &0x38 ) >>3 ) -1 ; + + mask |= ((2 << mode) -1 ) <<3 ; + } +if (port_ops && port_ops->mdma_filter) mask &= port_ops->mdma_filter (drive);else
drivers/ide/ide-iops.c +8 -0
@@ -389,6 +389,8 @@ int ide_config_drive_speed(ide_drive_t * id[ATA_ID_UDMA_MODES ] &= ~0xFF00 ; id[ATA_ID_MWDMA_MODES ] &= ~0x0F00 ; id[ATA_ID_SWDMA_MODES ] &= ~0x0F00 ; +if (ata_id_is_cfa (id)) + id[ATA_ID_CFA_MODES ] &= ~0x0F30 ; skip: #ifdef CONFIG_BLK_DEV_IDEDMA
@@ -401,12 +403,18 @@ int ide_config_drive_speed(ide_drive_t *if (speed >=XFER_UDMA_0 ) { i =1 << (speed -XFER_UDMA_0 ); id[ATA_ID_UDMA_MODES ] |= (i <<8 | i); + }else if (ata_id_is_cfa (id) && speed >=XFER_MW_DMA_3 ) { + i = speed -XFER_MW_DMA_2 ; + id[ATA_ID_CFA_MODES ] |= i <<9 ; }else if (speed >=XFER_MW_DMA_0 ) { i =1 << (speed -XFER_MW_DMA_0 ); id[ATA_ID_MWDMA_MODES ] |= (i <<8 | i); }else if (speed >=XFER_SW_DMA_0 ) { i =1 << (speed -XFER_SW_DMA_0 ); id[ATA_ID_SWDMA_MODES ] |= (i <<8 | i); + }else if (ata_id_is_cfa (id) && speed >=XFER_PIO_5 ) { + i = speed -XFER_PIO_4 ; + id[ATA_ID_CFA_MODES ] |= i <<6 ; }if (!drive->init_speed)
drivers/ide/ide-timings.c +10 -2
@@ -43,6 +43,8 @@ static struct ide_timing ide_timing[] = { XFER_UDMA_1, 0, 0, 0, 0, 0, 0, 0, 80 }, { XFER_UDMA_0, 0, 0, 0, 0, 0, 0, 0, 120 }, + { XFER_MW_DMA_4, 25, 0, 0, 0, 55, 20, 80, 0 }, + { XFER_MW_DMA_3, 25, 0, 0, 0, 65, 25, 100, 0 }, { XFER_MW_DMA_2, 25, 0, 0, 0, 70, 25, 120, 0 }, { XFER_MW_DMA_1, 45, 0, 0, 0, 80, 50, 150, 0 }, { XFER_MW_DMA_0, 60, 0, 0, 0, 215, 215, 480, 0 },
@@ -51,7 +53,8 @@ static struct ide_timing ide_timing[] = { XFER_SW_DMA_1, 90, 0, 0, 0, 240, 240, 480, 0 }, { XFER_SW_DMA_0, 120, 0, 0, 0, 480, 480, 960, 0 }, - { XFER_PIO_5, 20, 50, 30, 100, 50, 30, 100, 0 }, + { XFER_PIO_6, 10, 55, 20, 80, 55, 20, 80, 0 }, + { XFER_PIO_5, 15, 65, 25, 100, 65, 25, 100, 0 }, { XFER_PIO_4, 25, 70, 25, 120, 70, 25, 120, 0 }, { XFER_PIO_3, 30, 80, 70, 180, 80, 70, 180, 0 },
@@ -90,6 +93,10 @@ u16 ide_pio_cycle_time(ide_drive_t *driv/* conservative "downgrade" for all pre-ATA2 drives */ if (pio <3 && cycle < t->cycle) cycle =0 ;/* use standard timing */ + +/* IORDY must be ignored for CF specific PIO modes */ +if (pio >4 &&ata_id_is_cfa (id)) + cycle =0 ;/* use standard timing */ }return cycle ? cycle : t->cycle;
@@ -161,7 +168,8 @@ int ide_timing_compute(ide_drive_t *drivif (speed <=XFER_PIO_2 ) p.cycle = p.cyc8b = id[ATA_ID_EIDE_PIO ]; -else if (speed <=XFER_PIO_5 ) +else if ((speed <=XFER_PIO_4 ) || + (speed ==XFER_PIO_5 && !ata_id_is_cfa (id))) p.cycle = p.cyc8b = id[ATA_ID_EIDE_PIO_IORDY ];else if (speed >=XFER_MW_DMA_0 && speed <=XFER_MW_DMA_2 ) p.cycle = id[ATA_ID_EIDE_DMA_MIN ];
drivers/ide/ide-xfer-mode.c +9 -6
@@ -9,11 +9,11 @@ static const char *udma_str[] = {"UDMA/16" ,"UDMA/25" ,"UDMA/33" ,"UDMA/44" , "UDMA/66", "UDMA/100", "UDMA/133", "UDMA7" };static const char *mwdma_str[] = - {"MWDMA0" ,"MWDMA1" ,"MWDMA2" }; + {"MWDMA0" ,"MWDMA1" ,"MWDMA2" ,"MWDMA3" ,"MWDMA4" };static const char *swdma_str[] = {"SWDMA0" ,"SWDMA1" ,"SWDMA2" };static const char *pio_str[] = - {"PIO0" ,"PIO1" ,"PIO2" ,"PIO3" ,"PIO4" ,"PIO5" }; + {"PIO0" ,"PIO1" ,"PIO2" ,"PIO3" ,"PIO4" ,"PIO5" ,"PIO6" };/** * ide_xfer_verbose - return IDE mode names
@@ -30,11 +30,11 @@ const char *ide_xfer_verbose(u8 mode)if (mode >=XFER_UDMA_0 && mode <=XFER_UDMA_7 ) s = udma_str[i]; -else if (mode >=XFER_MW_DMA_0 && mode <=XFER_MW_DMA_2 ) +else if (mode >=XFER_MW_DMA_0 && mode <=XFER_MW_DMA_4 ) s = mwdma_str[i];else if (mode >=XFER_SW_DMA_0 && mode <=XFER_SW_DMA_2 ) s = swdma_str[i]; -else if (mode >=XFER_PIO_0 && mode <=XFER_PIO_5 ) +else if (mode >=XFER_PIO_0 && mode <=XFER_PIO_6 ) s = pio_str[i &0x7 ];else if (mode ==XFER_PIO_SLOW ) s ="PIO SLOW" ;
@@ -79,7 +79,10 @@ u8 ide_get_best_pio_mode(ide_drive_t *dr }if (id[ATA_ID_FIELD_VALID ] &2 ) {/* ATA2? */ -if (ata_id_has_iordy (id)) { +if (ata_id_is_cfa (id) && (id[ATA_ID_CFA_MODES ] &7 )) + pio_mode =4 +min_t (int,2 , + id[ATA_ID_CFA_MODES ] &7 ); +else if (ata_id_has_iordy (id)) {if (id[ATA_ID_PIO_MODES ] &7 ) { overridden =0 ;if (id[ATA_ID_PIO_MODES ] &4 )
@@ -239,7 +242,7 @@ int ide_set_xfer_rate(ide_drive_t *driveBUG_ON (rate <XFER_PIO_0 ); -if (rate >=XFER_PIO_0 && rate <=XFER_PIO_5 ) +if (rate >=XFER_PIO_0 && rate <=XFER_PIO_6 )return ide_set_pio_mode (drive, rate);return ide_set_dma_mode (drive, rate);
Quoted 6 lines · Hello, I wrote:
Add support for the CompactFlash specific PIO modes 5/6 and MWDMA modes 3/4.
Signed-off-by Sergei Shtylyov <[email protected]>---
This patch is against the current pata-2.6 series.
Oh, and the identify word 62/63 patch that I've reposted today needs to be
applied too.
MBR, Sergei
Quoted 1 line · Sergei Shtylyov
Add support for the CompactFlash specific PIO modes 5/6 and MWDMA modes 3/4.
Thanks for picking this up.
Quoted 8 lines
Signed-off-by Sergei Shtylyov <[email protected]>---
This patch is against the current pata-2.6 series. Since there were no PIO5 capable hard drives produced and you also need 66 MHz input clock to actually get the difference WRT the setup timing programmed, I decided to simply replace the old non-standard PIO mode 5 timings with CFA specified ones. Phew, hopefully I haven't overlooked anything -- quite a lot had to be changed.
It looks fine overall, few comments below.
drivers/ide/ide-iops.c int ide_config_drive_speed(ide_drive_t * · line 393
Quoted 6 lines
drivers/ide/ide-iops.c +2
-0@@ -389,6 +389,8 @@ int ide_config_drive_speed(ide_drive_t * id[ATA_ID_UDMA_MODES ] &= ~0xFF00 ; id[ATA_ID_MWDMA_MODES ] &= ~0x0F00 ; id[ATA_ID_SWDMA_MODES ] &= ~0x0F00 ; +if (ata_id_is_cfa (id)) + id[ATA_ID_CFA_MODES ] &= ~0x0F30 ;
Shouldn't the mask be ~0x0FC0 here?
drivers/ide/ide-timings.c u16 ide_pio_cycle_time(ide_drive_t *driv · line 99
Quoted 8 lines
drivers/ide/ide-timings.c +4
-0@@ -90,6 +93,10 @@ u16 ide_pio_cycle_time(ide_drive_t *driv/* conservative "downgrade" for all pre-ATA2 drives */ if (pio <3 && cycle < t->cycle) cycle =0 ;/* use standard timing */ + +/* IORDY must be ignored for CF specific PIO modes */ +if (pio >4 &&ata_id_is_cfa (id)) + cycle =0 ;/* use standard timing */
This comment seems out of place for the code dealing with cycle timing.
When it comes to IORDY I recalled that some host drivers already support "harddisk" PIO5 so they may need to be updated to not force IORDY setting (seems like at least sl82c105.c is affected).
drivers/ide/ide-xfer-mode.c u8 ide_get_best_pio_mode(ide_drive_t *dr · line 85
Quoted 9 lines
drivers/ide/ide-xfer-mode.c +4
-1@@ -79,7 +79,10 @@ u8 ide_get_best_pio_mode(ide_drive_t *dr }if (id[ATA_ID_FIELD_VALID ] &2 ) {/* ATA2? */ -if (ata_id_has_iordy (id)) { +if (ata_id_is_cfa (id) && (id[ATA_ID_CFA_MODES ] &7 )) + pio_mode =4 +min_t (int,2 , + id[ATA_ID_CFA_MODES ] &7 ); +else if (ata_id_has_iordy (id)) {
Shouldn't this happen independently of id[ATA_ID_FIELD_VALID] & 2 value?
Hello.
Quoted 15 lines · Bartlomiej Zolnierkiewicz
Quoted 1 line
Add support for the CompactFlash specific PIO modes 5/6 and MWDMA modes 3/4.
Thanks for picking this up.
Quoted 8 lines
Signed-off-by Sergei Shtylyov <[email protected]>---
This patch is against the current pata-2.6 series. Since there were no PIO5 capable hard drives produced and you also need 66 MHz input clock to actually get the difference WRT the setup timing programmed, I decided to simply replace the old non-standard PIO mode 5 timings with CFA specified ones. Phew, hopefully I haven't overlooked anything -- quite a lot had to be changed.It looks fine overall, few comments below.
Quoted 8 lines
drivers/ide/ide-iops.c int ide_config_drive_speed(ide_drive_t * · line 393
Quoted 6 lines
drivers/ide/ide-iops.c +2
-0@@ -389,6 +389,8 @@ int ide_config_drive_speed(ide_drive_t * id[ATA_ID_UDMA_MODES ] &= ~0xFF00 ; id[ATA_ID_MWDMA_MODES ] &= ~0x0F00 ; id[ATA_ID_SWDMA_MODES ] &= ~0x0F00 ; +if (ata_id_is_cfa (id)) + id[ATA_ID_CFA_MODES ] &= ~0x0F30 ;Shouldn't the mask be ~0x0FC0 here?
Oops, indeed. :-<
Quoted 11 lines
drivers/ide/ide-timings.c u16 ide_pio_cycle_time(ide_drive_t *driv · line 99
Quoted 8 lines
drivers/ide/ide-timings.c +4
-0@@ -90,6 +93,10 @@ u16 ide_pio_cycle_time(ide_drive_t *driv/* conservative "downgrade" for all pre-ATA2 drives */ if (pio <3 && cycle < t->cycle) cycle =0 ;/* use standard timing */ + +/* IORDY must be ignored for CF specific PIO modes */ +if (pio >4 &&ata_id_is_cfa (id)) + cycle =0 ;/* use standard timing */ This comment seems out of place for the code dealing with cycle timing.
Quoted 3 lines
When it comes to IORDY I recalled that some host drivers already support "harddisk" PIO5 so they may need to be updated to not force IORDY setting (seems like at least
sl82c105.cis affected).
I thought I have taken care of this with the generic code... the need for
the driver-level CF specific changes looks iffy as not all these drivers ever drive CF. I need to think about it... won't be the part of this patch in any case.
Quoted 11 lines
drivers/ide/ide-xfer-mode.c u8 ide_get_best_pio_mode(ide_drive_t *dr · line 85
Quoted 9 lines
drivers/ide/ide-xfer-mode.c +4
-1@@ -79,7 +79,10 @@ u8 ide_get_best_pio_mode(ide_drive_t *dr }if (id[ATA_ID_FIELD_VALID ] &2 ) {/* ATA2? */ -if (ata_id_has_iordy (id)) { +if (ata_id_is_cfa (id) && (id[ATA_ID_CFA_MODES ] &7 )) + pio_mode =4 +min_t (int,2 , + id[ATA_ID_CFA_MODES ] &7 ); +else if (ata_id_has_iordy (id)) {Shouldn't this happen independently of id[ATA_ID_FIELD_VALID] & 2 value?
Not really. Support for PIO modes 5 and 6 means support for all the lower
modes too.
WBR, Sergei
Quoted 41 lines · Sergei Shtylyov
Hello.
Quoted 15 lines · Bartlomiej Zolnierkiewicz
Quoted 1 line
Add support for the CompactFlash specific PIO modes 5/6 and MWDMA modes 3/4.
Thanks for picking this up.
Quoted 8 lines
Signed-off-by Sergei Shtylyov <[email protected]>---
This patch is against the current pata-2.6 series. Since there were no PIO5 capable hard drives produced and you also need 66 MHz input clock to actually get the difference WRT the setup timing programmed, I decided to simply replace the old non-standard PIO mode 5 timings with CFA specified ones. Phew, hopefully I haven't overlooked anything -- quite a lot had to be changed.It looks fine overall, few comments below.
Quoted 8 lines
drivers/ide/ide-iops.c int ide_config_drive_speed(ide_drive_t * · line 393
Quoted 6 lines
drivers/ide/ide-iops.c +2
-0@@ -389,6 +389,8 @@ int ide_config_drive_speed(ide_drive_t * id[ATA_ID_UDMA_MODES ] &= ~0xFF00 ; id[ATA_ID_MWDMA_MODES ] &= ~0x0F00 ; id[ATA_ID_SWDMA_MODES ] &= ~0x0F00 ; +if (ata_id_is_cfa (id)) + id[ATA_ID_CFA_MODES ] &= ~0x0F30 ;Shouldn't the mask be ~0x0FC0 here?
Oops, indeed. :-<Quoted 10 lines
drivers/ide/ide-timings.c u16 ide_pio_cycle_time(ide_drive_t *driv · line 99
Quoted 8 lines
drivers/ide/ide-timings.c +4
-0@@ -90,6 +93,10 @@ u16 ide_pio_cycle_time(ide_drive_t *driv/* conservative "downgrade" for all pre-ATA2 drives */ if (pio <3 && cycle < t->cycle) cycle =0 ;/* use standard timing */ + +/* IORDY must be ignored for CF specific PIO modes */ +if (pio >4 &&ata_id_is_cfa (id)) + cycle =0 ;/* use standard timing */ This comment seems out of place for the code dealing with cycle timing.
Quoted 6 lines
Quoted 3 lines
When it comes to IORDY I recalled that some host drivers already support "harddisk" PIO5 so they may need to be updated to not force IORDY setting (seems like at least
sl82c105.cis affected).I thought I have taken care of this with the generic code... the need for
the driver-level CF specific changes looks iffy as not all these drivers ever
Theoretically all drivers can drive CF devices using IDE-CF adapters so we shouldn't be making any such assumptions. There are also some interesting hardware designs, i.e. Vortex 86SX SoC which uses ITE 8211 chipset for IDE (embedded x86 devices using this SoC are often equipped with CF slot).
Quoted 1 line
drive CF. I need to think about it... won't be the part of this patch in any case.
The problem is that <linux/ata.h> lacks ata_id_needs_iordy(id, pio) so drivers are using ata_id_has_iordy() which doesn't know about CF specific needs, i.e. sl82c105.c does:
if (pio > 2 || ata_id_has_iordy(drive->id))
iordy = 0x40;and since the driver declares PIO5 support once this patch gets applied PIO5 will be used also for CF devices.
Thanks,
Bart
Hello.
Quoted 15 lines · Bartlomiej Zolnierkiewicz
Quoted 15 lines
Quoted 15 lines
Quoted 2 lines
Add support for the CompactFlash specific PIO modes 5/6 and MWDMA modes 3/4.
Thanks for picking this up.
Quoted 9 lines
Signed-off-by Sergei Shtylyov <[email protected]>---
This patch is against the current pata-2.6 series. Since there were no PIO5 capable hard drives produced and you also need 66 MHz input clock to actually get the difference WRT the setup timing programmed, I decided to simply replace the old non-standard PIO mode 5 timings with CFA specified ones. Phew, hopefully I haven't overlooked anything -- quite a lot had to be changed.It looks fine overall, few comments below.
[...]
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
drivers/ide/ide-timings.c u16 ide_pio_cycle_time(ide_drive_t *driv · line 100
Quoted 9 lines
drivers/ide/ide-timings.c +4
-0@@ -90,6 +93,10 @@ u16 ide_pio_cycle_time(ide_drive_t *driv/* conservative "downgrade" for all pre-ATA2 drives */ if (pio <3 && cycle < t->cycle) cycle =0 ;/* use standard timing */ + +/* IORDY must be ignored for CF specific PIO modes */ +if (pio >4 &&ata_id_is_cfa (id)) + cycle =0 ;/* use standard timing */ This comment seems out of place for the code dealing with cycle timing.
When it comes to IORDY I recalled that some host drivers already support "harddisk" PIO5 so they may need to be updated to not force IORDY setting (seems like at least
sl82c105.cis affected).
Quoted 6 lines
Quoted 3 lines
I thought I have taken care of this with the generic code... the need for
the driver-level CF specific changes looks iffy as not all these drivers everTheoretically all drivers can drive CF devices using IDE-CF adapters so we
I keep forgetting about this crap^W nice pieces of hardware... :-/
Quoted 3 lines
shouldn't be making any such assumptions. There are also some interesting hardware designs, i.e. Vortex 86SX SoC which uses ITE 8211 chipset for IDE
Do we support it? Ah, I'm seeing. But I'm not seeig any IORDY related
logic in it821x.c...
Quoted 8 lines
(embedded x86 devices using this SoC are often equipped with CF slot).
Quoted 2 lines
drive CF. I need to think about it... won't be the part of this patch in any case.
The problem is that <
linux/ata.h> lacksata_id_needs_iordy(id, pio)so drivers are usingata_id_has_iordy()which doesn't know about CF specific
Still not all are using even this -- e.g. piix.c doesn't. Oh
horror... well, Russian has the saying, something like "the initiative should be punished"... :-)
Quoted 5 lines
needs, i.e.
sl82c105.cdoes:if (pio > 2 || ata_id_has_iordy(drive->id)) iordy = 0x40;
Yes, that's clear...
Quoted 3 lines
and since the driver declares PIO5 support once this patch gets applied PIO5 will be used also for CF devices.
Hm, indeed -- looks like I *did* miss some things. :-/
Quoted 3 lines
Thanks,
Bart
MBR, Sergei