ide2libata
Subsystems (3)
cover ide2libata
Hi,
Here is a patchset (on top of atang-v3.1 tree) applying "out-of-the-box" thinking to duplicated libata PATA and IDE subsystem host driver sets. Namely, it modifies IDE API slightly to match libata's one more, adds a tiny source-code level translation layer (ide2libata.h header file which consists of only 17 lines of code) and then converts host drivers to use shared source code for low-level operations (all drivers have been carefully audited during porting to minimize the probability of adding regressions accidentally). As an end result it is much easier to maintain both driver sets (differences between 'new'/'old' drivers are now apparent and there is no longer a need to manually back-port many classes of bugfixes) and over 2500 LOC are gone.
The following changes since commit 7a4716f9084b32e32511cdea64ba538ac11e2c90:
Bartlomiej Zolnierkiewicz (1):
ide: ide_timing_compute() fixup
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/bart/misc.git atang-v4.0
Bartlomiej Zolnierkiewicz (68):
piix: add new short cable IDs
libata: CodingStyle fixes for ATA timings code
libata: move ATA timings code to ata-timings.c
ata: make ATA timings code independent of libata
ata: enable XFER_PIO_SLOW mode in ata_timing table
ide: switch to generic ATA timings code
pata_pcmcia: move IDs table to pata_pcmcia.h
ide-cs: use pata_pcmcia.h
ata_piix: factor out short cable detection code to ich_short_ata40()
ata_piix: move short cable handling to ata_piix.h
piix: use ata_piix.h
pata_ali: move short cable handling to pata_ali.h
alim15x3: use pata_ali.h
pata_sis: move short cable handling to pata_sis.h
sis5513: use pata_sis.h
pata_via: move short cable handling to pata_via.h
via82cxxx: use pata_via.h
ide: split host->dev table
ide: add hwif->port_no field
ide: add hwif->udma_mask field
ide: add hwif->private_data field
ide: add drive->devno field
ide: add drive->class field
ide: change ->cable_detect method return type to 'int'
it8213: always program control bits
piix: always program control bits
slc90e66: always program control bits
add ide2libata header file
ata_piix: move code to be re-used by ide2libata to ata_piix.h
piix: convert to ide2libata
pata_ali: move code to be re-used by ide2libata to pata_ali.h
alim15x3: convert to ide2libata
pata_amd: move code to be re-used by ide2libata to pata_amd.h
amd74xx: convert to ide2libata
pata_artop: move code to be re-used by ide2libata to pata_artop.h
aec62xx: convert to ide2libata
pata_atiixp: move code to be re-used by ide2libata to pata_atiixp.h
atiixp: convert to ide2libata
pata_cmd64x: documentation fix
pata_cmd64x: move code to be re-used by ide2libata to pata_cmd64x.h
pata_cmd64x: convert to ide2libata
pata_cs5520: move code to be re-used by ide2libata to pata_cs5520.h
cs5520: convert to ide2libata
pata_cs5530: move code to be re-used by ide2libata to pata_cs5530.h
cs5530: convert to ide2libata
pata_cs5535: move code to be re-used by ide2libata to pata_cs5535.h
cs5535: convert to ide2libata
pata_cypress: move code to be re-used by ide2libata to pata_cypress.h
cy82c693: convert to ide2libata
pata_efar: move code to be re-used by ide2libata to pata_efar.h
slc90e66: convert to ide2libata
pata_it8213: move code to be re-used by ide2libata to pata_it8213.h
it8213: convert to ide2libata
pata_it821x: move code to be re-used by ide2libata to pata_it821x.h
it821x: convert to ide2libata
pata_pdc202xx_old: move code to be re-used by ide2libata to pata_pdc202xx_old.h
pdc202xx_old: convert to ide2libata
pata_sc1200: move code to be re-used by ide2libata to pata_sc1200.h
sc1200: convert to ide2libata
pata_serverworks: move cable handling to pata_serverworks.h
serverworks: convert to ide2libata
pata_sl82c105: move code to be re-used by ide2libata to pata_sl82c105.h
sl82c105: convert to ide2libata
pata_triflex: move code to be re-used by ide2libata to pata_triflex.h
triflex: convert to ide2libata
pata_via: factor out code for finding ISA bridge
pata_via: move code to be re-used by ide2libata to pata_via.h
via82cxxx: convert to ide2libata
drivers/ata/Kconfig | 4 + drivers/ata/Makefile | 2 + drivers/ata/ata-timings.c | 178 ++++++++++++++++++ drivers/ata/ata_piix.c | 263 +--------------------------- drivers/ata/ata_piix.h | 278 +++++++++++++++++++++++++++++ drivers/ata/libata-core.c | 162 ----------------- drivers/ata/pata_ali.c | 270 +---------------------------- drivers/ata/pata_ali.h | 326 ++++++++++++++++++++++++++++++++++ drivers/ata/pata_amd.c | 89 +--------- drivers/ata/pata_amd.h | 94 ++++++++++ drivers/ata/pata_artop.c | 232 +------------------------ drivers/ata/pata_artop.h | 293 ++++++++++++++++++++++++++++++ drivers/ata/pata_at32.c | 8 +- drivers/ata/pata_at91.c | 18 +-- drivers/ata/pata_atiixp.c | 114 +------------ drivers/ata/pata_atiixp.h | 116 ++++++++++++ drivers/ata/pata_atp867x.c | 5 +- drivers/ata/pata_cmd640.c | 9 +- drivers/ata/pata_cmd64x.c | 216 +---------------------- drivers/ata/pata_cmd64x.h | 246 +++++++++++++++++++++++++ drivers/ata/pata_cs5520.c | 60 +------ drivers/ata/pata_cs5520.h | 60 ++++++ drivers/ata/pata_cs5530.c | 178 +------------------ drivers/ata/pata_cs5530.h | 185 +++++++++++++++++++ drivers/ata/pata_cs5535.c | 113 +------------ drivers/ata/pata_cs5535.h | 114 ++++++++++++ drivers/ata/pata_cypress.c | 91 +---------- drivers/ata/pata_cypress.h | 108 +++++++++++ drivers/ata/pata_efar.c | 151 +---------------- drivers/ata/pata_efar.h | 161 +++++++++++++++++ drivers/ata/pata_icside.c | 4 +- drivers/ata/pata_it8213.c | 150 +---------------- drivers/ata/pata_it8213.h | 157 ++++++++++++++++ drivers/ata/pata_it821x.c | 319 +--------------------------------- drivers/ata/pata_it821x.h | 337 +++++++++++++++++++++++++++++++++++ drivers/ata/pata_legacy.c | 32 ++-- drivers/ata/pata_ns87410.c | 7 +- drivers/ata/pata_ns87415.c | 2 +- drivers/ata/pata_octeon_cf.c | 4 +- drivers/ata/pata_pcmcia.c | 67 +------- drivers/ata/pata_pcmcia.h | 66 +++++++ drivers/ata/pata_pdc202xx_old.c | 109 +----------- drivers/ata/pata_pdc202xx_old.h | 121 +++++++++++++ drivers/ata/pata_sc1200.c | 108 +----------- drivers/ata/pata_sc1200.h | 112 ++++++++++++ drivers/ata/pata_serverworks.c | 282 +----------------------------- drivers/ata/pata_serverworks.h | 303 +++++++++++++++++++++++++++++++ drivers/ata/pata_sis.c | 30 +--- drivers/ata/pata_sis.h | 30 +++ drivers/ata/pata_sl82c105.c | 106 +----------- drivers/ata/pata_sl82c105.h | 110 ++++++++++++ drivers/ata/pata_triflex.c | 72 +-------- drivers/ata/pata_triflex.h | 69 +++++++ drivers/ata/pata_via.c | 255 +-------------------------- drivers/ata/pata_via.h | 269 ++++++++++++++++++++++++++++ drivers/ide/Kconfig | 1 + drivers/ide/Makefile | 1 - drivers/ide/aec62xx.c | 172 +----------------- drivers/ide/ali14xx.c | 2 +- drivers/ide/alim15x3.c | 295 ++----------------------------- drivers/ide/amd74xx.c | 90 +++------- drivers/ide/at91_ide.c | 9 +- drivers/ide/atiixp.c | 126 +------------- drivers/ide/cmd640.c | 4 +- drivers/ide/cmd64x.c | 196 +------------------- drivers/ide/cs5520.c | 44 +---- drivers/ide/cs5530.c | 149 ++-------------- drivers/ide/cs5535.c | 141 +-------------- drivers/ide/cs5536.c | 2 +- drivers/ide/cy82c693.c | 132 +------------- drivers/ide/hpt366.c | 8 +- drivers/ide/ht6560b.c | 3 +- drivers/ide/ide-cs.c | 68 +------- drivers/ide/ide-probe.c | 3 +- drivers/ide/ide-timings.c | 217 ---------------------- drivers/ide/ide-xfer-mode.c | 25 +++ drivers/ide/ide.c | 4 +- drivers/ide/it8213.c | 140 +-------------- drivers/ide/it821x.c | 375 +-------------------------------------- drivers/ide/jmicron.c | 2 +- drivers/ide/palm_bk3710.c | 9 +- drivers/ide/pdc202xx_new.c | 4 +- drivers/ide/pdc202xx_old.c | 80 +-------- drivers/ide/piix.c | 226 ++---------------------- drivers/ide/pmac.c | 8 +- drivers/ide/qd65xx.c | 2 +- drivers/ide/sc1200.c | 113 +----------- drivers/ide/scc_pata.c | 2 +- drivers/ide/serverworks.c | 281 ++--------------------------- drivers/ide/setup-pci.c | 6 +- drivers/ide/siimage.c | 2 +- drivers/ide/sis5513.c | 27 +--- drivers/ide/sl82c105.c | 105 +---------- drivers/ide/slc90e66.c | 117 +------------ drivers/ide/tc86c001.c | 2 +- drivers/ide/triflex.c | 57 +------ drivers/ide/tx4938ide.c | 2 +- drivers/ide/tx4939ide.c | 2 +- drivers/ide/via82cxxx.c | 290 +++--------------------------- include/linux/ata.h | 43 +++++ include/linux/ide.h | 66 +++---- include/linux/ide2libata.h | 17 ++ include/linux/libata.h | 37 ---- 103 files changed, 4147 insertions(+), 6825 deletions(-) create mode 100644 drivers/ata/ata-timings.c create mode 100644 drivers/ata/ata_piix.h create mode 100644 drivers/ata/pata_ali.h create mode 100644 drivers/ata/pata_amd.h create mode 100644 drivers/ata/pata_artop.h create mode 100644 drivers/ata/pata_atiixp.h create mode 100644 drivers/ata/pata_cmd64x.h create mode 100644 drivers/ata/pata_cs5520.h create mode 100644 drivers/ata/pata_cs5530.h create mode 100644 drivers/ata/pata_cs5535.h create mode 100644 drivers/ata/pata_cypress.h create mode 100644 drivers/ata/pata_efar.h create mode 100644 drivers/ata/pata_it8213.h create mode 100644 drivers/ata/pata_it821x.h create mode 100644 drivers/ata/pata_pcmcia.h create mode 100644 drivers/ata/pata_pdc202xx_old.h create mode 100644 drivers/ata/pata_sc1200.h create mode 100644 drivers/ata/pata_serverworks.h create mode 100644 drivers/ata/pata_sis.h create mode 100644 drivers/ata/pata_sl82c105.h create mode 100644 drivers/ata/pata_triflex.h create mode 100644 drivers/ata/pata_via.h delete mode 100644 drivers/ide/ide-timings.c create mode 100644 include/linux/ide2libata.h
PATCH 1/68 piix: add new short cable IDs
From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] piix: add new short cable IDs
Based on commits 6034734 and 760cdb7 for ata_piix.
--- drivers/ide/piix.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/ide/piix.c +3 -0
@@ -256,9 +256,12 @@ static const struct ich_laptop ich_lapto { 0x27DF, 0x1025, 0x0102 }, /* ICH7 on Acer 5602aWLMi */ { 0x27DF, 0x0005, 0x0280 }, /* ICH7 on Acer 5602WLMi */ { 0x27DF, 0x1025, 0x0110 }, /* ICH7 on Acer 3682WLMi */ + { 0x27DF, 0x1028, 0x02b0 }, /* ICH7 on unknown Dell */ { 0x27DF, 0x1043, 0x1267 }, /* ICH7 on Asus W5F */ { 0x27DF, 0x103C, 0x30A1 }, /* ICH7 on HP Compaq nc2400 */ + { 0x27DF, 0x103C, 0x361a }, /* ICH7 on unkown HP */ { 0x27DF, 0x1071, 0xD221 }, /* ICH7 on Hercules EC-900 */ + { 0x27DF, 0x152D, 0x0778 }, /* ICH7 on unknown Intel */ { 0x24CA, 0x1025, 0x0061 }, /* ICH4 on Acer Aspire 2023WLMi */ { 0x24CA, 0x1025, 0x003d }, /* ICH4 on ACER TM290 */ { 0x266F, 0x1025, 0x0066 }, /* ICH6 on ACER Aspire 1694WLMi */
PATCH 2/68 libata: CodingStyle fixes for ATA timings code
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] libata: CodingStyle fixes for ATA timings code
--- drivers/ata/libata-core.c | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-)
drivers/ata/libata-core.c +25 -14
@@ -3076,10 +3076,11 @@ static const struct ata_timing ata_timin { 0xFF } }; -#define ENOUGH (v, unit) (((v)-1)/(unit)+1) -#define EZ (v, unit) ((v)?ENOUGH(v, unit):0) +#define ENOUGH (v, unit) (((v) - 1) / (unit) + 1) +#define EZ (v, unit) ((v) ? ENOUGH(v, unit) : 0) -static void ata_timing_quantize (const struct ata_timing *t,struct ata_timing *q,int T ,int UT ) +static void ata_timing_quantize (const struct ata_timing *t, +struct ata_timing *q,int T ,int UT ) { q->setup =EZ (t->setup *1000 ,T ); q->act8b =EZ (t->act8b *1000 ,T );
@@ -3095,15 +3096,24 @@ static void ata_timing_quantize(const stvoid ata_timing_merge (const struct ata_timing *a,const struct ata_timing *b,struct ata_timing *m,unsigned int what) { -if (what &ATA_TIMING_SETUP ) m->setup =max (a->setup, b->setup); -if (what &ATA_TIMING_ACT8B ) m->act8b =max (a->act8b, b->act8b); -if (what &ATA_TIMING_REC8B ) m->rec8b =max (a->rec8b, b->rec8b); -if (what &ATA_TIMING_CYC8B ) m->cyc8b =max (a->cyc8b, b->cyc8b); -if (what &ATA_TIMING_ACTIVE ) m->active =max (a->active, b->active); -if (what &ATA_TIMING_RECOVER ) m->recover =max (a->recover, b->recover); -if (what &ATA_TIMING_DMACK_HOLD ) m->dmack_hold =max (a->dmack_hold, b->dmack_hold); -if (what &ATA_TIMING_CYCLE ) m->cycle =max (a->cycle, b->cycle); -if (what &ATA_TIMING_UDMA ) m->udma =max (a->udma, b->udma); +if (what &ATA_TIMING_SETUP ) + m->setup =max (a->setup, b->setup); +if (what &ATA_TIMING_ACT8B ) + m->act8b =max (a->act8b, b->act8b); +if (what &ATA_TIMING_REC8B ) + m->rec8b =max (a->rec8b, b->rec8b); +if (what &ATA_TIMING_CYC8B ) + m->cyc8b =max (a->cyc8b, b->cyc8b); +if (what &ATA_TIMING_ACTIVE ) + m->active =max (a->active, b->active); +if (what &ATA_TIMING_RECOVER ) + m->recover =max (a->recover, b->recover); +if (what &ATA_TIMING_DMACK_HOLD ) + m->dmack_hold =max (a->dmack_hold, b->dmack_hold); +if (what &ATA_TIMING_CYCLE ) + m->cycle =max (a->cycle, b->cycle); +if (what &ATA_TIMING_UDMA ) + m->udma =max (a->udma, b->udma); }const struct ata_timing *ata_timing_find_mode (u8 xfer_mode)
@@ -3129,7 +3139,8 @@ int ata_timing_compute(struct ata_device* Find the mode. */ -if (!(s =ata_timing_find_mode (speed))) + s =ata_timing_find_mode (speed); +if (!s)return -EINVAL ;memcpy (t, s,sizeof (*s));
@@ -3162,7 +3173,7 @@ int ata_timing_compute(struct ata_device/* * Even in DMA/UDMA modes we still use PIO access for IDENTIFY, -* S.M.A.R.T * and some other commands. We have to ensure that the +* S.M.A.R.T and some other commands. We have to ensure that the * DMA cycle timing is slower/equal than the fastest PIO timing. */
PATCH 3/68 libata: move ATA timings code to ata-timings.c
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] libata: move ATA timings code to ata-timings.c
--- drivers/ata/Makefile | 2 drivers/ata/ata-timings.c | 179 ++++++++++++++++++++++++++++++++++++++++++++++ drivers/ata/libata-core.c | 173 -------------------------------------------- 3 files changed, 180 insertions(+), 174 deletions(-)
drivers/ata/Makefile +1 -1
@@ -83,7 +83,7 @@ obj-$(CONFIG_ATA_GENERIC) += ata_generic # Should be last libata driver obj-$(CONFIG_PATA_LEGACY) += pata_legacy.o -libata-objs := libata-core.o libata-scsi.o libata-eh.o +libata-objs := ata-timings.o libata-core.o libata-scsi.o libata-eh.o libata-$(CONFIG_ATA_SFF) += libata-sff.o libata-$(CONFIG_SATA_PMP) += libata-pmp.o libata-$(CONFIG_ATA_ACPI) += libata-acpi.o
drivers/ata/ata-timings.c new file +179 -0
179 lines not on this page · raw message
drivers/ata/libata-core.c +0 -173
179 lines not on this page · raw message
PATCH 4/68 ata: make ATA timings code independent of libata
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] ata: make ATA timings code independent of libata
* Fix ata_timing_compute() arguments to be independent of libata.
* Move ATA timings enums and function declarations to <linux/ata.h>.
* Add CONFIG_ATA_TIMINGS config option.
* Remove bogus error checks from some host drivers while at it.
--- drivers/ata/Kconfig | 4 ++++ drivers/ata/Makefile | 4 +++- drivers/ata/ata-timings.c | 5 ++--- drivers/ata/pata_ali.c | 19 +++++++++++++------ drivers/ata/pata_amd.c | 8 +++----- drivers/ata/pata_at32.c | 8 ++------ drivers/ata/pata_at91.c | 18 ++++-------------- drivers/ata/pata_atp867x.c | 5 +++-- drivers/ata/pata_cmd640.c | 9 ++++----- drivers/ata/pata_cmd64x.c | 13 ++++++------- drivers/ata/pata_cypress.c | 5 +---- drivers/ata/pata_icside.c | 4 ++-- drivers/ata/pata_legacy.c | 32 +++++++++++++++++--------------- drivers/ata/pata_ns87410.c | 7 ++----- drivers/ata/pata_ns87415.c | 2 +- drivers/ata/pata_octeon_cf.c | 4 ++-- drivers/ata/pata_via.c | 5 +++-- include/linux/ata.h | 43 +++++++++++++++++++++++++++++++++++++++++++ include/linux/libata.h | 37 ------------------------------------- 19 files changed, 115 insertions(+), 117 deletions(-)
drivers/ata/Kconfig +4 -0
@@ -2,11 +2,15 @@ # SATA/PATA driver configuration # +config ATA_TIMINGS + bool + menuconfig ATA tristate "Serial ATA and Parallel ATA drivers" depends on HAS_IOMEM depends on BLOCK depends on !(M32R || M68K) || BROKEN + select ATA_TIMINGS select SCSI ---help--- If you want to use a ATA hard disk, ATA tape drive, ATA CD-ROM or
drivers/ata/Makefile +3 -1
@@ -1,4 +1,6 @@ +obj-$(CONFIG_ATA_TIMINGS) += ata-timings.o + obj-$(CONFIG_ATA) += libata.o obj-$(CONFIG_SATA_AHCI) += ahci.o
@@ -83,7 +85,7 @@ obj-$(CONFIG_ATA_GENERIC) += ata_generic # Should be last libata driver obj-$(CONFIG_PATA_LEGACY) += pata_legacy.o -libata-objs := ata-timings.o libata-core.o libata-scsi.o libata-eh.o +libata-objs := libata-core.o libata-scsi.o libata-eh.o libata-$(CONFIG_ATA_SFF) += libata-sff.o libata-$(CONFIG_SATA_PMP) += libata-pmp.o libata-$(CONFIG_ATA_ACPI) += libata-acpi.o
drivers/ata/ata-timings.c +2 -3
@@ -100,10 +100,9 @@ const struct ata_timing *ata_timing_find }EXPORT_SYMBOL_GPL (ata_timing_find_mode); -int ata_timing_compute (struct ata_device *adev,unsigned short speed, +int ata_timing_compute (const u16 *id,u8 speed,u8 pio_speed,struct ata_timing *t,int T ,int UT ) { -const u16 *id = adev->id;const struct ata_timing *s;struct ata_timing p;
@@ -150,7 +149,7 @@ int ata_timing_compute(struct ata_device*/ if (speed >XFER_PIO_6 ) { -ata_timing_compute (adev, adev->pio_mode, &p,T ,UT ); +ata_timing_compute (id, pio_speed, pio_speed, &p,T ,UT );ata_timing_merge (&p, t, t,ATA_TIMING_ALL ); }
drivers/ata/pata_ali.c +13 -6
@@ -210,13 +210,16 @@ static void ali_set_piomode(struct ata_pstruct ata_timing t;unsigned long T =1000000000 /33333 ;/* PCI clock based */ -ata_timing_compute (adev, adev->pio_mode, &t,T ,1 ); +ata_timing_compute (adev->id, adev->pio_mode, adev->pio_mode, &t,T ,1 );if (pair) {struct ata_timing p; -ata_timing_compute (pair, pair->pio_mode, &p,T ,1 ); + +ata_timing_compute (pair->id, pair->pio_mode, pair->pio_mode, + &p,T ,1 );ata_timing_merge (&p, &t, &t,ATA_TIMING_SETUP |ATA_TIMING_8BIT );if (pair->dma_mode) { -ata_timing_compute (pair, pair->dma_mode, &p,T ,1 ); +ata_timing_compute (pair->id, pair->dma_mode, + pair->pio_mode, &p,T ,1 );ata_timing_merge (&p, &t, &t,ATA_TIMING_SETUP |ATA_TIMING_8BIT ); } }
@@ -256,13 +259,17 @@ static void ali_set_dmamode(struct ata_ppci_write_config_byte (pdev,0x4B , reg4b); } }else { -ata_timing_compute (adev, adev->dma_mode, &t,T ,1 ); +ata_timing_compute (adev->id, adev->dma_mode, adev->pio_mode, + &t,T ,1 );if (pair) {struct ata_timing p; -ata_timing_compute (pair, pair->pio_mode, &p,T ,1 ); + +ata_timing_compute (pair->id, pair->pio_mode, + pair->pio_mode, &p,T ,1 );ata_timing_merge (&p, &t, &t,ATA_TIMING_SETUP |ATA_TIMING_8BIT );if (pair->dma_mode) { -ata_timing_compute (pair, pair->dma_mode, &p,T ,1 ); +ata_timing_compute (pair->id, pair->dma_mode, + pair->pio_mode, &p,T ,1 );ata_timing_merge (&p, &t, &t,ATA_TIMING_SETUP |ATA_TIMING_8BIT ); } }
drivers/ata/pata_amd.c +3 -5
@@ -59,13 +59,11 @@ static void timing_setup(struct ata_portif (clock >=2 )UT =T /2 ; -if (ata_timing_compute (adev, speed, &at,T ,UT ) <0 ) { -dev_printk (KERN_ERR , &pdev->dev,"unknown mode %d.\n" , speed); -return ; - } +ata_timing_compute (adev->id, speed, adev->pio_mode, &at,T ,UT );if (peer) { -ata_timing_compute (peer, peer->pio_mode, &apeer,T ,UT ); +ata_timing_compute (peer->id, peer->pio_mode, + peer->pio_mode, &apeer,T ,UT );ata_timing_merge (&apeer, &at, &at,ATA_TIMING_8BIT ); }
drivers/ata/pata_at32.c +2 -6
@@ -150,15 +150,11 @@ static void pata_at32_set_piomode(struct {struct ata_timing timing;struct at32_ide_info *info = ap->host->private_data; -int ret; +u8 mode = adev->pio_mode;/* Compute ATA timing */ - ret =ata_timing_compute (adev, adev->pio_mode, &timing,1000 ,0 ); -if (ret) { -dev_warn (ap->dev,"Failed to compute ATA timing %d\n" , ret); -return ; - } +ata_timing_compute (adev->id, mode, mode, &timing,1000 ,0 );/* Setup SMC to ATA timing */ ret =pata_at32_setup_timing (ap->dev, info, &timing);
drivers/ata/pata_at91.c +4 -14
@@ -48,9 +48,6 @@ struct at91_ide_info {void __iomem *alt_addr; }; -static const struct ata_timing initial_timing = - {XFER_PIO_0 ,70 ,290 ,240 ,600 ,165 ,150 ,600 ,0 }; -static unsigned long calc_mck_cycles (unsigned long ns,unsigned long mck_hz) {unsigned long mul;
@@ -148,22 +145,15 @@ static void pata_at91_set_piomode(struct {struct at91_ide_info *info = ap->host->private_data;struct ata_timing timing; -int ret; +u8 mode = adev->pio_mode;/* Compute ATA timing and set it to SMC */ - ret =ata_timing_compute (adev, adev->pio_mode, &timing,1000 ,0 ); -if (ret) { -dev_warn (ap->dev,"Failed to compute ATA timing %d, \ -set PIO_0 timing\n" , ret); -set_smc_timing (ap->dev, info, &initial_timing); - }else { -set_smc_timing (ap->dev, info, &timing); - } +ata_timing_compute (adev->id, mode, mode, &timing,1000 ,0 ); + +set_smc_timing (ap->dev, info, &timing);/* Setup SMC mode */ set_smc_mode (info); - -return ; } static unsigned int pata_at91_data_xfer_noirq(struct ata_device *dev,
drivers/ata/pata_atp867x.c +3 -2
@@ -223,9 +223,10 @@ static void atp867x_set_piomode(struct aT =1000000000 /33333 ;UT =T /4 ; -ata_timing_compute (adev, speed, &t,T ,UT ); +ata_timing_compute (adev->id, speed, adev->pio_mode, &t,T ,UT );if (peer && peer->pio_mode) { -ata_timing_compute (peer, peer->pio_mode, &p,T ,UT ); +ata_timing_compute (peer->id, peer->pio_mode, peer->pio_mode, + &p,T ,UT );ata_timing_merge (&p, &t, &t,ATA_TIMING_8BIT ); }
drivers/ata/pata_cmd640.c +4 -5
@@ -59,16 +59,15 @@ static void cmd640_set_piomode(struct atint arttim =ARTIM0 +2 * adev->devno;struct ata_device *pair =ata_dev_pair (adev); -if (ata_timing_compute (adev, adev->pio_mode, &t,T ,0 ) <0 ) { - printk(KERN_ERR DRV_NAME ": mode computation failed.\n"); -return ; - } +ata_timing_compute (adev->id, adev->pio_mode, adev->pio_mode, &t,T ,0 );/* The second channel has shared timings and the setup timing is messy to switch to merge it for worst case */ if (ap->port_no && pair) {struct ata_timing p; -ata_timing_compute (pair, pair->pio_mode, &p,T ,1 ); + +ata_timing_compute (pair->id, pair->pio_mode, pair->pio_mode, + &p,T ,1 );ata_timing_merge (&p, &t, &t,ATA_TIMING_SETUP ); }
drivers/ata/pata_cmd64x.c +6 -7
@@ -145,10 +145,8 @@ static void cmd64x_set_timing(struct ata/* ata_timing_compute is smart and will produce timings for MWDMA that don't violate the drives PIO capabilities. */ -if (ata_timing_compute (adev, mode, &t,T ,0 ) <0 ) { - printk(KERN_ERR DRV_NAME ": mode computation failed.\n"); -return ; - } +ata_timing_compute (adev->id, mode, adev->pio_mode, &t,T ,0 ); +if (ap->port_no) {/* Slave has shared address setup */ struct ata_device *pair =ata_dev_pair (adev);
@@ -156,11 +154,12 @@ static void cmd64x_set_timing(struct ataif (pair) {struct ata_timing tp; -ata_timing_compute (pair, pair->pio_mode, &tp,T ,0 ); +ata_timing_compute (pair->id, pair->pio_mode, + pair->pio_mode, &tp,T ,0 );ata_timing_merge (&t, &tp, &t,ATA_TIMING_SETUP );if (pair->dma_mode) { -ata_timing_compute (pair, pair->dma_mode, - &tp,T ,0 ); +ata_timing_compute (pair->id, pair->dma_mode, + pair->pio_mode, &tp,T ,0 );ata_timing_merge (&tp, &t, &t,ATA_TIMING_SETUP ); } }
drivers/ata/pata_cypress.c +1 -4
@@ -57,10 +57,7 @@ static void cy82c693_set_piomode(structshort time_16, time_8;u32 addr; -if (ata_timing_compute (adev, adev->pio_mode, &t,T ,1 ) <0 ) { - printk(KERN_ERR DRV_NAME ": mome computation failed.\n"); -return ; - } +ata_timing_compute (adev->id, adev->pio_mode, adev->pio_mode, &t,T ,1 ); time_16 =clamp_val (t.recover -1 ,0 ,15 ) | (clamp_val (t.active -1 ,0 ,15 ) <<4 );
drivers/ata/pata_icside.c +2 -2
@@ -186,6 +186,7 @@ static const expansioncard_ops_t pata_icstatic void pata_icside_set_dmamode (struct ata_port *ap,struct ata_device *adev) {struct pata_icside_state *state = ap->host->private_data; +const u16 *id = adev->id;struct ata_timing t;unsigned int cycle;char iomd_type;
@@ -193,8 +194,7 @@ static void pata_icside_set_dmamode(stru/* * DMA is based on a 16MHz clock */ -if (ata_timing_compute (adev, adev->dma_mode, &t,1000 ,1 )) -return ; +ata_timing_compute (id, adev->dma_mode, adev->pio_mode, &t,1000 ,1 );/* * Choose the IOMD cycle timing which ensure that the interface
drivers/ata/pata_legacy.c +17 -15
@@ -357,11 +357,11 @@ static struct ata_port_operations pdc202static void ht6560a_set_piomode (struct ata_port *ap,struct ata_device *adev) { -u8 active, recover; +u8 mode = adev->pio_mode, active, recover;struct ata_timing t;/* Get the timing data in cycles. For now play safe at 50Mhz */ -ata_timing_compute (adev, adev->pio_mode, &t,20000 ,1000 ); +ata_timing_compute (adev->id, mode, mode, &t,20000 ,1000 ); active =clamp_val (t.active,2 ,15 ); recover =clamp_val (t.recover,4 ,15 );
@@ -391,11 +391,11 @@ static struct ata_port_operations ht6560static void ht6560b_set_piomode (struct ata_port *ap,struct ata_device *adev) { -u8 active, recover; +u8 mode = adev->pio_mode, active, recover;struct ata_timing t;/* Get the timing data in cycles. For now play safe at 50Mhz */ -ata_timing_compute (adev, adev->pio_mode, &t,20000 ,1000 ); +ata_timing_compute (adev->id, mode, mode, &t,20000 ,1000 ); active =clamp_val (t.active,2 ,15 ); recover =clamp_val (t.recover,2 ,16 );
@@ -456,7 +456,7 @@ static u8 opti_syscfg(u8 reg)static void opti82c611a_set_piomode (struct ata_port *ap,struct ata_device *adev) { -u8 active, recover, setup; +u8 mode = adev->pio_mode, active, recover, setup;struct ata_timing t;struct ata_device *pair =ata_dev_pair (adev);int clock;
@@ -472,13 +472,14 @@ static void opti82c611a_set_piomode(stru clock =1000000000 / khz[ioread8 (ap->ioaddr.lbah_addr) &0x03 ];/* Get the timing data in cycles */ -ata_timing_compute (adev, adev->pio_mode, &t, clock,1000 ); +ata_timing_compute (adev->id, mode, mode, &t, clock,1000 );/* Setup timing is shared */ if (pair) {struct ata_timing tp; -ata_timing_compute (pair, pair->pio_mode, &tp, clock,1000 ); +ata_timing_compute (pair->id, pair->pio_mode, pair->pio_mode, + &tp, clock,1000 );ata_timing_merge (&t, &tp, &t,ATA_TIMING_SETUP ); }
@@ -531,7 +532,7 @@ static struct ata_port_operations opti82static void opti82c46x_set_piomode (struct ata_port *ap,struct ata_device *adev) { -u8 active, recover, setup; +u8 mode = adev->pio_mode, active, recover, setup;struct ata_timing t;struct ata_device *pair =ata_dev_pair (adev);int clock;
@@ -551,13 +552,14 @@ static void opti82c46x_set_piomode(struc clock =1000000000 / khz[sysclk];/* Get the timing data in cycles */ -ata_timing_compute (adev, adev->pio_mode, &t, clock,1000 ); +ata_timing_compute (adev->id, mode, mode, &t, clock,1000 );/* Setup timing is shared */ if (pair) {struct ata_timing tp; -ata_timing_compute (pair, pair->pio_mode, &tp, clock,1000 ); +ata_timing_compute (pair->id, pair->pio_mode, pair->pio_mode, + &tp, clock,1000 );ata_timing_merge (&t, &tp, &t,ATA_TIMING_SETUP ); }
@@ -651,10 +653,10 @@ static void qdi65x0_set_piomode(struct astruct ata_timing t;struct legacy_data *ld_qdi = ap->host->private_data;int active, recovery; -u8 timing; +u8 mode = adev->pio_mode, timing;/* Get the timing data in cycles */ -ata_timing_compute (adev, adev->pio_mode, &t,30303 ,1000 ); +ata_timing_compute (adev->id, mode, mode, &t,30303 ,1000 );if (ld_qdi->fast) { active =8 -clamp_val (t.active,1 ,8 );
@@ -786,16 +788,16 @@ static void winbond_set_piomode(struct astruct ata_timing t;struct legacy_data *ld_winbond = ap->host->private_data;int active, recovery; -u8 reg; +u8 mode = adev->pio_mode, reg;int timing =0x88 + (ap->port_no *4 ) + (adev->devno *2 ); reg =winbond_readcfg (ld_winbond->timing,0x81 );/* Get the timing data in cycles */ if (reg &0x40 )/* Fast VLB bus, assume 50MHz */ -ata_timing_compute (adev, adev->pio_mode, &t,20000 ,1000 ); +ata_timing_compute (adev->id, mode, mode, &t,20000 ,1000 );else -ata_timing_compute (adev, adev->pio_mode, &t,30303 ,1000 ); +ata_timing_compute (adev->id, mode, mode, &t,30303 ,1000 ); active = (clamp_val (t.active,3 ,17 ) -1 ) &0x0F ; recovery = (clamp_val (t.recover,1 ,15 ) +1 ) &0x0F ;
drivers/ata/pata_ns87410.c +2 -5
@@ -65,7 +65,7 @@ static void ns87410_set_piomode(struct a {struct pci_dev *pdev =to_pci_dev (ap->host->dev);int port =0x40 +4 * ap->port_no; -u8 idetcr, idefr; +u8 mode = adev->pio_mode, idetcr, idefr;struct ata_timing at;static const u8 activebits[15 ] = {
@@ -85,10 +85,7 @@ static void ns87410_set_piomode(struct aelse idefr &= ~0x04 ; -if (ata_timing_compute (adev, adev->pio_mode, &at,30303 ,1 ) <0 ) { -dev_printk (KERN_ERR , &pdev->dev,"unknown mode %d.\n" , adev->pio_mode); -return ; - } +ata_timing_compute (adev->id, mode, mode, &at,30303 ,1 ); at.active =clamp_val (at.active,2 ,16 ) -2 ; at.setup =clamp_val (at.setup,1 ,4 ) -1 ;
drivers/ata/pata_ns87415.c +1 -1
@@ -64,7 +64,7 @@ static void ns87415_set_mode(struct ata_/* Timing register format is 17 - low nybble read timing with the high nybble being 16 - x for recovery time in PCI clocks */ -ata_timing_compute (adev, adev->pio_mode, &t,T ,0 ); +ata_timing_compute (adev->id, adev->pio_mode, adev->pio_mode, &t,T ,0 ); clocking =17 -clamp_val (t.active,2 ,17 ); clocking |= (16 -clamp_val (t.recover,1 ,16 )) <<4 ;
drivers/ata/pata_octeon_cf.c +2 -2
@@ -104,11 +104,11 @@ static void octeon_cf_set_piomode(structint t1;int t2;int t2i; +u8 mode = dev->pio_mode;T = (int )(2000000000000LL /octeon_get_clock_rate ()); -if (ata_timing_compute (dev, dev->pio_mode, &timing,T ,T )) -BUG (); +ata_timing_compute (dev->id, mode, mode, &timing,T ,T ); t1 = timing.setup;if (t1)
drivers/ata/pata_via.c +3 -2
@@ -252,12 +252,13 @@ static void via_do_set_mode(struct ata_p }/* Calculate the timing values we require */ -ata_timing_compute (adev, mode, &t,T ,UT ); +ata_timing_compute (adev->id, mode, adev->pio_mode, &t,T ,UT );/* We share 8bit timing so we must merge the constraints */ if (peer) {if (peer->pio_mode) { -ata_timing_compute (peer, peer->pio_mode, &p,T ,UT ); +ata_timing_compute (peer->id, peer->pio_mode, + peer->pio_mode, &p,T ,UT );ata_timing_merge (&p, &t, &t,ATA_TIMING_8BIT ); } }
include/linux/ata.h +43 -0
47 lines not on this page · raw message
include/linux/libata.h +0 -37
@@ -390,24 +390,6 @@ enum {ATAPI_PASS_THRU =3 ,/* SAT pass-thru */ ATAPI_MISC =4 ,/* the rest */ -/* Timing constants */ -ATA_TIMING_SETUP = (1 <<0 ), -ATA_TIMING_ACT8B = (1 <<1 ), -ATA_TIMING_REC8B = (1 <<2 ), -ATA_TIMING_CYC8B = (1 <<3 ), -ATA_TIMING_8BIT =ATA_TIMING_ACT8B |ATA_TIMING_REC8B | -ATA_TIMING_CYC8B , -ATA_TIMING_ACTIVE = (1 <<4 ), -ATA_TIMING_RECOVER = (1 <<5 ), -ATA_TIMING_DMACK_HOLD = (1 <<6 ), -ATA_TIMING_CYCLE = (1 <<7 ), -ATA_TIMING_UDMA = (1 <<8 ), -ATA_TIMING_ALL =ATA_TIMING_SETUP |ATA_TIMING_ACT8B | -ATA_TIMING_REC8B |ATA_TIMING_CYC8B | -ATA_TIMING_ACTIVE |ATA_TIMING_RECOVER | -ATA_TIMING_DMACK_HOLD |ATA_TIMING_CYCLE | -ATA_TIMING_UDMA , -/* ACPI constants */ ATA_ACPI_FILTER_SETXFER =1 <<0 , ATA_ACPI_FILTER_LOCK = 1 << 1,
@@ -883,19 +865,6 @@ struct ata_port_info {void *private_data; }; -struct ata_timing { -unsigned short mode;/* ATA mode */ -unsigned short setup;/* t1 */ -unsigned short act8b;/* t2 for 8-bit I/O */ -unsigned short rec8b;/* t2i for 8-bit I/O */ -unsigned short cyc8b;/* t0 for 8-bit I/O */ -unsigned short active;/* t2 or tD */ -unsigned short recover;/* t2i or tK */ -unsigned short dmack_hold;/* tj */ -unsigned short cycle;/* t0 */ -unsigned short udma;/* t2CYCTYP/2 */ -}; -/* * Core layer - drivers/ata/libata-core.c */
@@ -1029,12 +998,6 @@ extern void ata_pio_queue_task(struct at/* Timing helpers */ extern unsigned int ata_pio_need_iordy (const struct ata_device *); -extern const struct ata_timing *ata_timing_find_mode (u8 xfer_mode); -extern int ata_timing_compute (struct ata_device *,unsigned short , -struct ata_timing *,int ,int ); -extern void ata_timing_merge (const struct ata_timing *, -const struct ata_timing *,struct ata_timing *, -unsigned int );extern u8 ata_timing_cycle2mode (unsigned int xfer_shift,int cycle);/* PCI */
PATCH 5/68 ata: enable XFER_PIO_SLOW mode in ata_timing table
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] ata: enable XFER_PIO_SLOW mode in ata_timing table
--- drivers/ata/ata-timings.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ata/ata-timings.c +1 -1
@@ -15,7 +15,7 @@*/ static const struct ata_timing ata_timing[] = { -/* { XFER_PIO_SLOW, 120, 290, 240, 960, 290, 240, 0, 960, 0 }, */ + {XFER_PIO_SLOW ,120 ,290 ,240 ,960 ,290 ,240 ,0 ,960 ,0 }, {XFER_PIO_0 ,70 ,290 ,240 ,600 ,165 ,150 ,0 ,600 ,0 }, {XFER_PIO_1 ,50 ,290 ,93 ,383 ,125 ,100 ,0 ,383 ,0 }, {XFER_PIO_2 ,30 ,290 ,40 ,330 ,100 ,90 ,0 ,240 ,0 },
PATCH 6/68 ide: switch to generic ATA timings code
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] ide: switch to generic ATA timings code
--- drivers/ide/Kconfig | 1 drivers/ide/Makefile | 1 drivers/ide/ali14xx.c | 2 drivers/ide/alim15x3.c | 45 +++++---- drivers/ide/amd74xx.c | 11 +- drivers/ide/at91_ide.c | 9 + drivers/ide/cmd640.c | 4 drivers/ide/cmd64x.c | 17 +-- drivers/ide/cy82c693.c | 6 - drivers/ide/ht6560b.c | 3 drivers/ide/ide-timings.c | 217 -------------------------------------------- drivers/ide/ide-xfer-mode.c | 25 +++++ drivers/ide/palm_bk3710.c | 7 - drivers/ide/pmac.c | 6 - drivers/ide/qd65xx.c | 2 drivers/ide/sl82c105.c | 2 drivers/ide/tx4938ide.c | 2 drivers/ide/via82cxxx.c | 11 +- include/linux/ide.h | 35 ------- 19 files changed, 94 insertions(+), 312 deletions(-)
drivers/ide/Kconfig +1 -0
@@ -61,6 +61,7 @@ config IDE_XFER_MODE config IDE_TIMINGS bool + select ATA_TIMINGS select IDE_XFER_MODE config IDE_ATAPI
drivers/ide/Makefile +0 -1
@@ -10,7 +10,6 @@ ide-core-y += ide.o ide-ioctls.o ide-io. # core IDE code ide-core-$(CONFIG_IDE_XFER_MODE) += ide-pio-blacklist.o ide-xfer-mode.o -ide-core-$(CONFIG_IDE_TIMINGS) += ide-timings.o ide-core-$(CONFIG_IDE_ATAPI) += ide-atapi.o ide-core-$(CONFIG_BLK_DEV_IDEPCI) += setup-pci.o ide-core-$(CONFIG_BLK_DEV_IDEDMA) += ide-dma.o
drivers/ide/ali14xx.c +1 -1
@@ -117,7 +117,7 @@ static void ali14xx_set_pio_mode(ide_hwiunsigned long flags;int bus_speed = ide_vlb_clk ? ide_vlb_clk :50 ;const u8 pio = drive->pio_mode -XFER_PIO_0 ; -struct ide_timing *t =ide_timing_find_mode (XFER_PIO_0 + pio); +const struct ata_timing *t =ata_timing_find_mode (XFER_PIO_0 + pio);/* calculate timing, according to PIO mode */ time1 =ide_pio_cycle_time (drive, pio);
drivers/ide/alim15x3.c +25 -20
72 lines not on this page · raw message
drivers/ide/amd74xx.c +6 -5
@@ -48,7 +48,7 @@ static inline u8 amd_offset(struct pci_d*/ static void amd_set_speed (struct pci_dev *dev,u8 dn,u8 udma_mask, -struct ide_timing *timing) +struct ata_timing *timing) {u8 t =0 , offset =amd_offset (dev);
@@ -83,7 +83,7 @@ static void amd_set_drive(ide_hwif_t *hw {struct pci_dev *dev =to_pci_dev (hwif->dev);ide_drive_t *peer =ide_get_pair_dev (drive); -struct ide_timing t, p; +struct ata_timing t, p;int T ,UT ;u8 udma_mask = hwif->ultra_mask;const u8 speed = drive->dma_mode;
@@ -91,11 +91,12 @@ static void amd_set_drive(ide_hwif_t *hwT =1000000000 / amd_clock;UT = (udma_mask ==ATA_UDMA2 ) ?T : (T /2 ); -ide_timing_compute (drive, speed, &t,T ,UT ); +ata_timing_compute (drive->id, speed, drive->pio_mode, &t,T ,UT );if (peer) { -ide_timing_compute (peer, peer->pio_mode, &p,T ,UT ); -ide_timing_merge (&p, &t, &t,IDE_TIMING_8BIT ); +ata_timing_compute (peer->id, peer->pio_mode, + peer->pio_mode, &p,T ,UT ); +ata_timing_merge (&p, &t, &t,ATA_TIMING_8BIT ); }if (speed ==XFER_UDMA_5 && amd_clock <=33333 ) t.udma =1 ;
drivers/ide/at91_ide.c +5 -4
@@ -107,7 +107,7 @@ static unsigned int calc_mck_cycles(unsi }static void apply_timings (const u8 chipselect,const u8 pio, -const struct ide_timing *timing,int use_iordy) +const struct ata_timing *timing,int use_iordy) {unsigned int t0, t1, t2, t6z;unsigned int cycle, setup, pulse, data_float;
@@ -174,14 +174,14 @@ static void at91_ide_output_data(ide_dristatic void at91_ide_set_pio_mode (ide_hwif_t *hwif,ide_drive_t *drive) { -struct ide_timing *timing; +const struct ata_timing *timing;u8 chipselect = hwif->select_data;int use_iordy =0 ;const u8 pio = drive->pio_mode -XFER_PIO_0 ;pdbg ("chipselect %u pio %u\n" , chipselect, pio); - timing =ide_timing_find_mode (XFER_PIO_0 + pio); + timing =ata_timing_find_mode (XFER_PIO_0 + pio);BUG_ON (!timing);if (ide_pio_need_iordy (drive, pio))
@@ -311,7 +311,8 @@ static int __init at91_ide_probe(struct }/* setup Static Memory Controller - PIO 0 as default */ -apply_timings (board->chipselect,0 ,ide_timing_find_mode (XFER_PIO_0 ),0 ); +apply_timings (board->chipselect,0 , +ata_timing_find_mode (XFER_PIO_0 ),0 );/* with GPIO interrupt we have to do quirks in handler */ if (board->irq_pin >=PIN_BASE )
drivers/ide/cmd640.c +2 -2
@@ -513,7 +513,7 @@ static void program_drive_counts(ide_dristatic void cmd640_set_mode (ide_drive_t *drive,unsigned int index,u8 pio_mode,unsigned int cycle_time) { -struct ide_timing *t; +const struct ata_timing *t;int setup_time, active_time, recovery_time, clock_time;u8 setup_count, active_count, recovery_count, recovery_count2, cycle_count;int bus_speed;
@@ -526,7 +526,7 @@ static void cmd640_set_mode(ide_drive_tif (pio_mode >5 ) pio_mode =5 ; - t =ide_timing_find_mode (XFER_PIO_0 + pio_mode); + t =ata_timing_find_mode (XFER_PIO_0 + pio_mode); setup_time = t->setup; active_time = t->active;
drivers/ide/cmd64x.c +9 -8
@@ -62,10 +62,10 @@ static void cmd64x_program_timings(ide_dstatic const u8 setup_values[] = {0x40 ,0x40 ,0x40 ,0x80 ,0 ,0xc0 };static const u8 arttim_regs[4 ] = {ARTTIM0 ,ARTTIM1 ,ARTTIM23 ,ARTTIM23 };static const u8 drwtim_regs[4 ] = {DRWTIM0 ,DRWTIM1 ,DRWTIM2 ,DRWTIM3 }; -struct ide_timing t; +struct ata_timing t;u8 arttim =0 ; -ide_timing_compute (drive, mode, &t,T ,0 ); +ata_timing_compute (drive->id, mode, drive->pio_mode, &t,T ,0 );/* * In case we've got too long recovery phase, try to lengthen
@@ -98,14 +98,15 @@ static void cmd64x_program_timings(ide_dide_drive_t *pair =ide_get_pair_dev (drive);if (pair) { -struct ide_timing tp; +struct ata_timing tp; -ide_timing_compute (pair, pair->pio_mode, &tp,T ,0 ); -ide_timing_merge (&t, &tp, &t,IDE_TIMING_SETUP ); +ata_timing_compute (pair->id, pair->pio_mode, + pair->pio_mode, &tp,T ,0 ); +ata_timing_merge (&t, &tp, &t,ATA_TIMING_SETUP );if (pair->dma_mode) { -ide_timing_compute (pair, pair->dma_mode, - &tp,T ,0 ); -ide_timing_merge (&tp, &t, &t,IDE_TIMING_SETUP ); +ata_timing_compute (pair->id, pair->dma_mode, + pair->pio_mode, &tp,T ,0 ); +ata_timing_merge (&tp, &t, &t,ATA_TIMING_SETUP ); } } }
drivers/ide/cy82c693.c +3 -3
@@ -86,8 +86,8 @@ static void cy82c693_set_pio_mode(ide_hwint bus_speed = ide_pci_clk ? ide_pci_clk :33 ;const unsigned long T =1000000 / bus_speed;unsigned int addrCtrl; -struct ide_timing t; -u8 time_16, time_8; +struct ata_timing t; +u8 mode = drive->pio_mode, time_16, time_8;/* select primary or secondary channel */ if (hwif->index >0 ) {/* drive is on the secondary channel */
@@ -100,7 +100,7 @@ static void cy82c693_set_pio_mode(ide_hw } } -ide_timing_compute (drive, drive->pio_mode, &t,T ,1 ); +ata_timing_compute (drive->id, mode, mode, &t,T ,1 ); time_16 =clamp_val (t.recover -1 ,0 ,15 ) | (clamp_val (t.active -1 ,0 ,15 ) <<4 );
drivers/ide/ht6560b.c +2 -1
@@ -205,7 +205,8 @@ static u8 ht_pio2timings(ide_drive_t *drif (pio) {unsigned int cycle_time; -struct ide_timing *t =ide_timing_find_mode (XFER_PIO_0 + pio); +const struct ata_timing *t = +ata_timing_find_mode (XFER_PIO_0 + pio); cycle_time =ide_pio_cycle_time (drive, pio);
drivers/ide/ide-timings.c deleted +0 -217
217 lines not on this page · raw message
drivers/ide/ide-xfer-mode.c +25 -0
@@ -118,6 +118,31 @@ int ide_pio_need_iordy(ide_drive_t *driv }EXPORT_SYMBOL_GPL (ide_pio_need_iordy); +u16 ide_pio_cycle_time (ide_drive_t *drive,u8 pio) +{ +u16 *id = drive->id; +const struct ata_timing *t =ata_timing_find_mode (XFER_PIO_0 + pio); +u16 cycle =0 ; + +if (id[ATA_ID_FIELD_VALID ] &2 ) { +if (ata_id_has_iordy (drive->id)) + cycle = id[ATA_ID_EIDE_PIO_IORDY ]; +else + cycle = id[ATA_ID_EIDE_PIO ]; + +/* conservative "downgrade" for all pre-ATA2 drives */ +if (pio <3 && cycle < t->cycle) + cycle =0 ;/* use standard timing */ + +/* Use the standard timing for the CF specific modes too */ +if (pio >4 &&ata_id_is_cfa (id)) + cycle =0 ; + } + +return cycle ? cycle : t->cycle; +} +EXPORT_SYMBOL_GPL (ide_pio_cycle_time); +int ide_set_pio_mode (ide_drive_t *drive,const u8 mode) {ide_hwif_t *hwif = drive->hwif;
drivers/ide/palm_bk3710.c +2 -5
@@ -112,13 +112,12 @@ static void palm_bk3710_setdmamode(void unsigned short min_cycle, unsigned int mode) { +const struct ata_timing *t =ata_timing_find_mode (mode);u8 td, tkw, t0;u32 val32;u16 val16; -struct ide_timing *t;int cycletime; - t =ide_timing_find_mode (mode); cycletime =max_t (int, t->cycle, min_cycle);/* DMA Data Setup */
@@ -144,11 +143,9 @@ static void palm_bk3710_setpiomode(void unsigned int dev, unsigned int cycletime, unsigned int mode) { + const struct ata_timing *t = ata_timing_find_mode(XFER_PIO_0 + mode);u8 t2, t2i, t0;u32 val32; -struct ide_timing *t; - - t =ide_timing_find_mode (XFER_PIO_0 + mode);/* PIO Data Setup */ t0 =DIV_ROUND_UP (cycletime, ideclk_period);
drivers/ide/pmac.c +3 -3
@@ -503,7 +503,7 @@ static void pmac_ide_set_pio_mode(ide_hwpmac_ide_hwif_t *pmif = (pmac_ide_hwif_t *)dev_get_drvdata (hwif->gendev.parent);const u8 pio = drive->pio_mode -XFER_PIO_0 ; -struct ide_timing *tim =ide_timing_find_mode (XFER_PIO_0 + pio); +const struct ata_timing *tim =ata_timing_find_mode (XFER_PIO_0 + pio);u32 *timings, t;unsigned accessTicks, recTicks;unsigned accessTime, recTime;
@@ -612,7 +612,7 @@ set_timings_udma_ata4(u32 *timings, u8 sstatic int set_timings_udma_ata6 (u32 *pio_timings,u32 *ultra_timings,u8 speed) { -struct ide_timing *t =ide_timing_find_mode (speed); +const struct ata_timing *t =ata_timing_find_mode (speed);u32 tr;if (speed >XFER_UDMA_5 || t ==NULL )
@@ -630,7 +630,7 @@ set_timings_udma_ata6(u32 *pio_timings,static int set_timings_udma_shasta (u32 *pio_timings,u32 *ultra_timings,u8 speed) { -struct ide_timing *t =ide_timing_find_mode (speed); +const struct ata_timing *t =ata_timing_find_mode (speed);u32 tr;if (speed >XFER_UDMA_6 || t ==NULL )
drivers/ide/qd65xx.c +1 -1
@@ -212,7 +212,7 @@ static void qd6500_set_pio_mode(ide_hwifstatic void qd6580_set_pio_mode (ide_hwif_t *hwif,ide_drive_t *drive) {const u8 pio = drive->pio_mode -XFER_PIO_0 ; -struct ide_timing *t =ide_timing_find_mode (XFER_PIO_0 + pio); +const struct ata_timing *t =ata_timing_find_mode (XFER_PIO_0 + pio);unsigned int cycle_time;int active_time =175 ;int recovery_time =415 ;/* worst case values from the dos driver */
drivers/ide/sl82c105.c +1 -1
@@ -41,7 +41,7 @@*/ static unsigned int get_pio_timings (ide_drive_t *drive,u8 pio) { -struct ide_timing *t =ide_timing_find_mode (XFER_PIO_0 + pio); +const struct ata_timing *t =ata_timing_find_mode (XFER_PIO_0 + pio);unsigned int cmd_on, cmd_off;u8 iordy =0 ;
drivers/ide/tx4938ide.c +1 -1
@@ -23,7 +23,7 @@ static void tx4938ide_tune_ebusc(unsigne unsigned int gbus_clock, u8 pio) { -struct ide_timing *t =ide_timing_find_mode (XFER_PIO_0 + pio); +const struct ata_timing *t =ata_timing_find_mode (XFER_PIO_0 + pio);u64 cr =__raw_readq (&tx4938_ebuscptr->cr[ebus_ch]);unsigned int sp = (cr >>4 ) &3 ;unsigned int clock = gbus_clock / (4 - sp);
drivers/ide/via82cxxx.c +6 -5
@@ -122,7 +122,7 @@ struct via82cxxx_dev* via_set_speed writes timing values to the chipset registers */ -static void via_set_speed (ide_hwif_t *hwif,u8 dn,struct ide_timing *timing) +static void via_set_speed (ide_hwif_t *hwif,u8 dn,struct ata_timing *timing) {struct pci_dev *dev =to_pci_dev (hwif->dev);struct ide_host *host =pci_get_drvdata (dev);
@@ -182,7 +182,7 @@ static void via_set_drive(ide_hwif_t *hwstruct pci_dev *dev =to_pci_dev (hwif->dev);struct ide_host *host =pci_get_drvdata (dev);struct via82cxxx_dev *vdev = host->host_priv; -struct ide_timing t, p; +struct ata_timing t, p;unsigned int T ,UT ;const u8 speed = drive->dma_mode;
@@ -196,11 +196,12 @@ static void via_set_drive(ide_hwif_t *hwdefault :UT =T ; } -ide_timing_compute (drive, speed, &t,T ,UT ); +ata_timing_compute (drive->id, speed, drive->pio_mode, &t,T ,UT );if (peer) { -ide_timing_compute (peer, peer->pio_mode, &p,T ,UT ); -ide_timing_merge (&p, &t, &t,IDE_TIMING_8BIT ); +ata_timing_compute (peer->id, peer->pio_mode, + peer->pio_mode, &p,T ,UT ); +ata_timing_merge (&p, &t, &t,ATA_TIMING_8BIT ); }via_set_speed (hwif, drive->dn, &t);
include/linux/ide.h +1 -34
@@ -1459,44 +1459,11 @@ extern void ide_toggle_bounce(ide_drive_u64 ide_get_lba_addr (struct ide_cmd *,int );u8 ide_dump_status (ide_drive_t *,const char *,u8 ); -struct ide_timing { -u8 mode; -u8 setup;/* t1 */ -u16 act8b;/* t2 for 8-bit io */ -u16 rec8b;/* t2i for 8-bit io */ -u16 cyc8b;/* t0 for 8-bit io */ -u16 active;/* t2 or tD */ -u16 recover;/* t2i or tK */ -u16 cycle;/* t0 */ -u16 udma;/* t2CYCTYP/2 */ -}; - -enum { -IDE_TIMING_SETUP = (1 <<0 ), -IDE_TIMING_ACT8B = (1 <<1 ), -IDE_TIMING_REC8B = (1 <<2 ), -IDE_TIMING_CYC8B = (1 <<3 ), -IDE_TIMING_8BIT =IDE_TIMING_ACT8B |IDE_TIMING_REC8B | -IDE_TIMING_CYC8B , -IDE_TIMING_ACTIVE = (1 <<4 ), -IDE_TIMING_RECOVER = (1 <<5 ), -IDE_TIMING_CYCLE = (1 <<6 ), -IDE_TIMING_UDMA = (1 <<7 ), -IDE_TIMING_ALL =IDE_TIMING_SETUP |IDE_TIMING_8BIT | -IDE_TIMING_ACTIVE |IDE_TIMING_RECOVER | -IDE_TIMING_CYCLE |IDE_TIMING_UDMA , -}; - -struct ide_timing *ide_timing_find_mode (u8 ); -u16 ide_pio_cycle_time (ide_drive_t *,u8 ); -void ide_timing_merge (struct ide_timing *,struct ide_timing *, -struct ide_timing *,unsigned int ); -int ide_timing_compute (ide_drive_t *,u8 ,struct ide_timing *,int ,int ); -#ifdef CONFIG_IDE_XFER_MODE int ide_scan_pio_blacklist (char *);const char *ide_xfer_verbose (u8 );int ide_pio_need_iordy (ide_drive_t *,const u8 ); +u16 ide_pio_cycle_time (ide_drive_t *,u8 );int ide_set_pio_mode (ide_drive_t *,u8 );int ide_set_dma_mode (ide_drive_t *,u8 );void ide_set_pio (ide_drive_t *,u8 );
PATCH 7/68 pata_pcmcia: move IDs table to pata_pcmcia.h
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] pata_pcmcia: move IDs table to pata_pcmcia.h
--- drivers/ata/pata_pcmcia.c | 67 ---------------------------------------------- drivers/ata/pata_pcmcia.h | 66 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 66 deletions(-)
drivers/ata/pata_pcmcia.c +1 -66
@@ -388,72 +388,7 @@ static void pcmcia_remove_one(struct pcmkfree (info); } -static struct pcmcia_device_id pcmcia_devices[] = { -PCMCIA_DEVICE_FUNC_ID (4 ), -PCMCIA_DEVICE_MANF_CARD (0x0000 ,0x0000 ),/* Corsair */ -PCMCIA_DEVICE_MANF_CARD (0x0007 ,0x0000 ),/* Hitachi */ -PCMCIA_DEVICE_MANF_CARD (0x000a ,0x0000 ),/* I-O Data CFA */ -PCMCIA_DEVICE_MANF_CARD (0x001c ,0x0001 ),/* Mitsubishi CFA */ -PCMCIA_DEVICE_MANF_CARD (0x0032 ,0x0704 ), -PCMCIA_DEVICE_MANF_CARD (0x0032 ,0x2904 ), -PCMCIA_DEVICE_MANF_CARD (0x0045 ,0x0401 ),/* SanDisk CFA */ -PCMCIA_DEVICE_MANF_CARD (0x004f ,0x0000 ),/* Kingston */ -PCMCIA_DEVICE_MANF_CARD (0x0097 ,0x1620 ),/* TI emulated */ -PCMCIA_DEVICE_MANF_CARD (0x0098 ,0x0000 ),/* Toshiba */ -PCMCIA_DEVICE_MANF_CARD (0x00a4 ,0x002d ), -PCMCIA_DEVICE_MANF_CARD (0x00ce ,0x0000 ),/* Samsung */ -PCMCIA_DEVICE_MANF_CARD (0x0319 ,0x0000 ),/* Hitachi */ -PCMCIA_DEVICE_MANF_CARD (0x2080 ,0x0001 ), -PCMCIA_DEVICE_MANF_CARD (0x4e01 ,0x0100 ),/* Viking CFA */ -PCMCIA_DEVICE_MANF_CARD (0x4e01 ,0x0200 ),/* Lexar, Viking CFA */ -PCMCIA_DEVICE_PROD_ID123 ("Caravelle" ,"PSC-IDE " ,"PSC000" ,0x8c36137c ,0xd0693ab8 ,0x2768a9f0 ), -PCMCIA_DEVICE_PROD_ID123 ("CDROM" ,"IDE" ,"MCD-601p" ,0x1b9179ca ,0xede88951 ,0x0d902f74 ), -PCMCIA_DEVICE_PROD_ID123 ("PCMCIA" ,"IDE CARD" ,"F1" ,0x281f1c5d ,0x1907960c ,0xf7fde8b9 ), -PCMCIA_DEVICE_PROD_ID12 ("ARGOSY" ,"CD-ROM" ,0x78f308dc ,0x66536591 ), -PCMCIA_DEVICE_PROD_ID12 ("ARGOSY" ,"PnPIDE" ,0x78f308dc ,0x0c694728 ), -PCMCIA_DEVICE_PROD_ID12 ("CNF " ,"CD-ROM" ,0x46d7db81 ,0x66536591 ), -PCMCIA_DEVICE_PROD_ID12 ("CNF CD-M" ,"CD-ROM" ,0x7d93b852 ,0x66536591 ), -PCMCIA_DEVICE_PROD_ID12 ("Creative Technology Ltd." ,"PCMCIA CD-ROM Interface Card" ,0xff8c8a45 ,0xfe8020c4 ), -PCMCIA_DEVICE_PROD_ID12 ("Digital Equipment Corporation." ,"Digital Mobile Media CD-ROM" ,0x17692a66 ,0xef1dcbde ), -PCMCIA_DEVICE_PROD_ID12 ("EXP" ,"CD+GAME" ,0x6f58c983 ,0x63c13aaf ), -PCMCIA_DEVICE_PROD_ID12 ("EXP " ,"CD-ROM" ,0x0a5c52fd ,0x66536591 ), -PCMCIA_DEVICE_PROD_ID12 ("EXP " ,"PnPIDE" ,0x0a5c52fd ,0x0c694728 ), -PCMCIA_DEVICE_PROD_ID12 ("FREECOM" ,"PCCARD-IDE" ,0x5714cbf7 ,0x48e0ab8e ), -PCMCIA_DEVICE_PROD_ID12 ("HITACHI" ,"FLASH" ,0xf4f43949 ,0x9eb86aae ), -PCMCIA_DEVICE_PROD_ID12 ("HITACHI" ,"microdrive" ,0xf4f43949 ,0xa6d76178 ), -PCMCIA_DEVICE_PROD_ID12 ("Hyperstone" ,"Model1" ,0x3d5b9ef5 ,0xca6ab420 ), -PCMCIA_DEVICE_PROD_ID12 ("IBM" ,"microdrive" ,0xb569a6e5 ,0xa6d76178 ), -PCMCIA_DEVICE_PROD_ID12 ("IBM" ,"IBM17JSSFP20" ,0xb569a6e5 ,0xf2508753 ), -PCMCIA_DEVICE_PROD_ID12 ("KINGSTON" ,"CF8GB" ,0x2e6d1829 ,0xacbe682e ), -PCMCIA_DEVICE_PROD_ID12 ("IO DATA" ,"CBIDE2 " ,0x547e66dc ,0x8671043b ), -PCMCIA_DEVICE_PROD_ID12 ("IO DATA" ,"PCIDE" ,0x547e66dc ,0x5c5ab149 ), -PCMCIA_DEVICE_PROD_ID12 ("IO DATA" ,"PCIDEII" ,0x547e66dc ,0xb3662674 ), -PCMCIA_DEVICE_PROD_ID12 ("LOOKMEET" ,"CBIDE2 " ,0xe37be2b5 ,0x8671043b ), -PCMCIA_DEVICE_PROD_ID12 ("M-Systems" ,"CF300" ,0x7ed2ad87 ,0x7e9e78ee ), -PCMCIA_DEVICE_PROD_ID12 ("M-Systems" ,"CF500" ,0x7ed2ad87 ,0x7a13045c ), -PCMCIA_DEVICE_PROD_ID2 ("NinjaATA-" ,0xebe0bd79 ), -PCMCIA_DEVICE_PROD_ID12 ("PCMCIA" ,"CD-ROM" ,0x281f1c5d ,0x66536591 ), -PCMCIA_DEVICE_PROD_ID12 ("PCMCIA" ,"PnPIDE" ,0x281f1c5d ,0x0c694728 ), -PCMCIA_DEVICE_PROD_ID12 ("SHUTTLE TECHNOLOGY LTD." ,"PCCARD-IDE/ATAPI Adapter" ,0x4a3f0ba0 ,0x322560e1 ), -PCMCIA_DEVICE_PROD_ID12 ("SEAGATE" ,"ST1" ,0x87c1b330 ,0xe1f30883 ), -PCMCIA_DEVICE_PROD_ID12 ("SAMSUNG" ,"04/05/06" ,0x43d74cb4 ,0x6a22777d ), -PCMCIA_DEVICE_PROD_ID12 ("SMI VENDOR" ,"SMI PRODUCT" ,0x30896c92 ,0x703cc5f6 ), -PCMCIA_DEVICE_PROD_ID12 ("TOSHIBA" ,"MK2001MPL" ,0xb4585a1a ,0x3489e003 ), -PCMCIA_DEVICE_PROD_ID1 ("TRANSCEND 512M " ,0xd0909443 ), -PCMCIA_DEVICE_PROD_ID12 ("TRANSCEND" ,"TS1GCF45" ,0x709b1bf1 ,0xf68b6f32 ), -PCMCIA_DEVICE_PROD_ID12 ("TRANSCEND" ,"TS1GCF80" ,0x709b1bf1 ,0x2a54d4b1 ), -PCMCIA_DEVICE_PROD_ID12 ("TRANSCEND" ,"TS2GCF120" ,0x709b1bf1 ,0x969aa4f2 ), -PCMCIA_DEVICE_PROD_ID12 ("TRANSCEND" ,"TS4GCF120" ,0x709b1bf1 ,0xf54a91c8 ), -PCMCIA_DEVICE_PROD_ID12 ("WIT" ,"IDE16" ,0x244e5994 ,0x3e232852 ), -PCMCIA_DEVICE_PROD_ID12 ("WEIDA" ,"TWTTI" ,0xcc7cf69c ,0x212bb918 ), -PCMCIA_DEVICE_PROD_ID1 ("STI Flash" ,0xe4a13209 ), -PCMCIA_DEVICE_PROD_ID12 ("STI" ,"Flash 5.0" ,0xbf2df18d ,0x8cb57a0e ), -PCMCIA_MFC_DEVICE_PROD_ID12 (1 ,"SanDisk" ,"ConnectPlus" ,0x7a954bd9 ,0x74be00c6 ), -PCMCIA_DEVICE_PROD_ID2 ("Flash Card" ,0x5a362506 ), -PCMCIA_DEVICE_NULL , -}; - -MODULE_DEVICE_TABLE (pcmcia, pcmcia_devices); +#include "pata_pcmcia.h" static struct pcmcia_driver pcmcia_driver = { .owner =THIS_MODULE ,
drivers/ata/pata_pcmcia.h new file +66 -0
66 lines not on this page · raw message
PATCH 8/68 ide-cs: use pata_pcmcia.h
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] ide-cs: use pata_pcmcia.h
--- drivers/ide/ide-cs.c | 68 +-------------------------------------------------- 1 file changed, 2 insertions(+), 66 deletions(-)
drivers/ide/ide-cs.c +2 -66
@@ -385,71 +385,7 @@ static void ide_release(struct pcmcia_de======================================================================*/ -static struct pcmcia_device_id ide_ids[] = { -PCMCIA_DEVICE_FUNC_ID (4 ), -PCMCIA_DEVICE_MANF_CARD (0x0000 ,0x0000 ),/* Corsair */ -PCMCIA_DEVICE_MANF_CARD (0x0007 ,0x0000 ),/* Hitachi */ -PCMCIA_DEVICE_MANF_CARD (0x000a ,0x0000 ),/* I-O Data CFA */ -PCMCIA_DEVICE_MANF_CARD (0x001c ,0x0001 ),/* Mitsubishi CFA */ -PCMCIA_DEVICE_MANF_CARD (0x0032 ,0x0704 ), -PCMCIA_DEVICE_MANF_CARD (0x0032 ,0x2904 ), -PCMCIA_DEVICE_MANF_CARD (0x0045 ,0x0401 ),/* SanDisk CFA */ -PCMCIA_DEVICE_MANF_CARD (0x004f ,0x0000 ),/* Kingston */ -PCMCIA_DEVICE_MANF_CARD (0x0097 ,0x1620 ),/* TI emulated */ -PCMCIA_DEVICE_MANF_CARD (0x0098 ,0x0000 ),/* Toshiba */ -PCMCIA_DEVICE_MANF_CARD (0x00a4 ,0x002d ), -PCMCIA_DEVICE_MANF_CARD (0x00ce ,0x0000 ),/* Samsung */ -PCMCIA_DEVICE_MANF_CARD (0x0319 ,0x0000 ),/* Hitachi */ -PCMCIA_DEVICE_MANF_CARD (0x2080 ,0x0001 ), -PCMCIA_DEVICE_MANF_CARD (0x4e01 ,0x0100 ),/* Viking CFA */ -PCMCIA_DEVICE_MANF_CARD (0x4e01 ,0x0200 ),/* Lexar, Viking CFA */ -PCMCIA_DEVICE_PROD_ID123 ("Caravelle" ,"PSC-IDE " ,"PSC000" ,0x8c36137c ,0xd0693ab8 ,0x2768a9f0 ), -PCMCIA_DEVICE_PROD_ID123 ("CDROM" ,"IDE" ,"MCD-601p" ,0x1b9179ca ,0xede88951 ,0x0d902f74 ), -PCMCIA_DEVICE_PROD_ID123 ("PCMCIA" ,"IDE CARD" ,"F1" ,0x281f1c5d ,0x1907960c ,0xf7fde8b9 ), -PCMCIA_DEVICE_PROD_ID12 ("ARGOSY" ,"CD-ROM" ,0x78f308dc ,0x66536591 ), -PCMCIA_DEVICE_PROD_ID12 ("ARGOSY" ,"PnPIDE" ,0x78f308dc ,0x0c694728 ), -PCMCIA_DEVICE_PROD_ID12 ("CNF " ,"CD-ROM" ,0x46d7db81 ,0x66536591 ), -PCMCIA_DEVICE_PROD_ID12 ("CNF CD-M" ,"CD-ROM" ,0x7d93b852 ,0x66536591 ), -PCMCIA_DEVICE_PROD_ID12 ("Creative Technology Ltd." ,"PCMCIA CD-ROM Interface Card" ,0xff8c8a45 ,0xfe8020c4 ), -PCMCIA_DEVICE_PROD_ID12 ("Digital Equipment Corporation." ,"Digital Mobile Media CD-ROM" ,0x17692a66 ,0xef1dcbde ), -PCMCIA_DEVICE_PROD_ID12 ("EXP" ,"CD+GAME" ,0x6f58c983 ,0x63c13aaf ), -PCMCIA_DEVICE_PROD_ID12 ("EXP " ,"CD-ROM" ,0x0a5c52fd ,0x66536591 ), -PCMCIA_DEVICE_PROD_ID12 ("EXP " ,"PnPIDE" ,0x0a5c52fd ,0x0c694728 ), -PCMCIA_DEVICE_PROD_ID12 ("FREECOM" ,"PCCARD-IDE" ,0x5714cbf7 ,0x48e0ab8e ), -PCMCIA_DEVICE_PROD_ID12 ("HITACHI" ,"FLASH" ,0xf4f43949 ,0x9eb86aae ), -PCMCIA_DEVICE_PROD_ID12 ("HITACHI" ,"microdrive" ,0xf4f43949 ,0xa6d76178 ), -PCMCIA_DEVICE_PROD_ID12 ("Hyperstone" ,"Model1" ,0x3d5b9ef5 ,0xca6ab420 ), -PCMCIA_DEVICE_PROD_ID12 ("IBM" ,"microdrive" ,0xb569a6e5 ,0xa6d76178 ), -PCMCIA_DEVICE_PROD_ID12 ("IBM" ,"IBM17JSSFP20" ,0xb569a6e5 ,0xf2508753 ), -PCMCIA_DEVICE_PROD_ID12 ("KINGSTON" ,"CF8GB" ,0x2e6d1829 ,0xacbe682e ), -PCMCIA_DEVICE_PROD_ID12 ("IO DATA" ,"CBIDE2 " ,0x547e66dc ,0x8671043b ), -PCMCIA_DEVICE_PROD_ID12 ("IO DATA" ,"PCIDE" ,0x547e66dc ,0x5c5ab149 ), -PCMCIA_DEVICE_PROD_ID12 ("IO DATA" ,"PCIDEII" ,0x547e66dc ,0xb3662674 ), -PCMCIA_DEVICE_PROD_ID12 ("LOOKMEET" ,"CBIDE2 " ,0xe37be2b5 ,0x8671043b ), -PCMCIA_DEVICE_PROD_ID12 ("M-Systems" ,"CF300" ,0x7ed2ad87 ,0x7e9e78ee ), -PCMCIA_DEVICE_PROD_ID12 ("M-Systems" ,"CF500" ,0x7ed2ad87 ,0x7a13045c ), -PCMCIA_DEVICE_PROD_ID2 ("NinjaATA-" ,0xebe0bd79 ), -PCMCIA_DEVICE_PROD_ID12 ("PCMCIA" ,"CD-ROM" ,0x281f1c5d ,0x66536591 ), -PCMCIA_DEVICE_PROD_ID12 ("PCMCIA" ,"PnPIDE" ,0x281f1c5d ,0x0c694728 ), -PCMCIA_DEVICE_PROD_ID12 ("SHUTTLE TECHNOLOGY LTD." ,"PCCARD-IDE/ATAPI Adapter" ,0x4a3f0ba0 ,0x322560e1 ), -PCMCIA_DEVICE_PROD_ID12 ("SEAGATE" ,"ST1" ,0x87c1b330 ,0xe1f30883 ), -PCMCIA_DEVICE_PROD_ID12 ("SAMSUNG" ,"04/05/06" ,0x43d74cb4 ,0x6a22777d ), -PCMCIA_DEVICE_PROD_ID12 ("SMI VENDOR" ,"SMI PRODUCT" ,0x30896c92 ,0x703cc5f6 ), -PCMCIA_DEVICE_PROD_ID12 ("TOSHIBA" ,"MK2001MPL" ,0xb4585a1a ,0x3489e003 ), -PCMCIA_DEVICE_PROD_ID1 ("TRANSCEND 512M " ,0xd0909443 ), -PCMCIA_DEVICE_PROD_ID12 ("TRANSCEND" ,"TS1GCF45" ,0x709b1bf1 ,0xf68b6f32 ), -PCMCIA_DEVICE_PROD_ID12 ("TRANSCEND" ,"TS1GCF80" ,0x709b1bf1 ,0x2a54d4b1 ), -PCMCIA_DEVICE_PROD_ID12 ("TRANSCEND" ,"TS2GCF120" ,0x709b1bf1 ,0x969aa4f2 ), -PCMCIA_DEVICE_PROD_ID12 ("TRANSCEND" ,"TS4GCF120" ,0x709b1bf1 ,0xf54a91c8 ), -PCMCIA_DEVICE_PROD_ID12 ("WIT" ,"IDE16" ,0x244e5994 ,0x3e232852 ), -PCMCIA_DEVICE_PROD_ID12 ("WEIDA" ,"TWTTI" ,0xcc7cf69c ,0x212bb918 ), -PCMCIA_DEVICE_PROD_ID1 ("STI Flash" ,0xe4a13209 ), -PCMCIA_DEVICE_PROD_ID12 ("STI" ,"Flash 5.0" ,0xbf2df18d ,0x8cb57a0e ), -PCMCIA_MFC_DEVICE_PROD_ID12 (1 ,"SanDisk" ,"ConnectPlus" ,0x7a954bd9 ,0x74be00c6 ), -PCMCIA_DEVICE_PROD_ID2 ("Flash Card" ,0x5a362506 ), -PCMCIA_DEVICE_NULL , -}; -MODULE_DEVICE_TABLE (pcmcia, ide_ids); +#include "../ata/pata_pcmcia.h" static struct pcmcia_driver ide_cs_driver = { .owner =THIS_MODULE ,
@@ -458,7 +394,7 @@ static struct pcmcia_driver ide_cs_drive }, .probe = ide_probe, .remove = ide_detach, - .id_table = ide_ids, + .id_table = pcmcia_devices, };static int __init init_ide_cs (void )
PATCH 9/68 ata_piix: factor out short cable detection code to ich_short_ata40()
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] ata_piix: factor out short cable detection code to ich_short_ata40()
Fix up ich_pata_cable_detect() documentation while at it.
--- drivers/ata/ata_piix.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-)
drivers/ata/ata_piix.c +18 -10
@@ -611,6 +611,21 @@ static const struct ich_laptop ich_lapto { 0, } }; +static int ich_short_ata40 (struct pci_dev *pdev) +{ +const struct ich_laptop *lap = &ich_laptop[0 ]; + +while (lap->device) { +if (lap->device == pdev->device && + lap->subvendor == pdev->subsystem_vendor && + lap->subdevice == pdev->subsystem_device) +return 1 ; + lap++; + } + +return 0 ; +} +/** * ich_pata_cable_detect - Probe host controller cable detect info * @ap: Port for which cable detect info is desired
@@ -626,18 +641,11 @@ static int ich_pata_cable_detect(struct {struct pci_dev *pdev =to_pci_dev (ap->host->dev);struct piix_host_priv *hpriv = ap->host->private_data; -const struct ich_laptop *lap = &ich_laptop[0 ];u8 mask; -/* Check for specials - Acer Aspire 5602WLMi */ -while (lap->device) { -if (lap->device == pdev->device && - lap->subvendor == pdev->subsystem_vendor && - lap->subdevice == pdev->subsystem_device) -return ATA_CBL_PATA40_SHORT ; - - lap++; - } +/* check for specials */ +if (ich_short_ata40 (pdev)) +return ATA_CBL_PATA40_SHORT ;/* check BIOS cable detect results */ mask = ap->port_no ==0 ?PIIX_80C_PRI :PIIX_80C_SEC ;
PATCH 10/68 ata_piix: move short cable handling to ata_piix.h
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] ata_piix: move short cable handling to ata_piix.h
It is a generic code and can be shared between ata_piix & piix drivers.
--- drivers/ata/ata_piix.c | 45 +-------------------------------------------- drivers/ata/ata_piix.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 44 deletions(-)
drivers/ata/ata_piix.c +1 -44
@@ -581,50 +581,7 @@ MODULE_LICENSE("GPL");MODULE_DEVICE_TABLE (pci, piix_pci_tbl);MODULE_VERSION (DRV_VERSION ); -struct ich_laptop { -u16 device; -u16 subvendor; -u16 subdevice; -}; - -/* -* List of laptops that use short cables rather than 80 wire -*/ - -static const struct ich_laptop ich_laptop[] = { -/* devid, subvendor, subdev */ - {0x27DF ,0x0005 ,0x0280 },/* ICH7 on Acer 5602WLMi */ - {0x27DF ,0x1025 ,0x0102 },/* ICH7 on Acer 5602aWLMi */ - {0x27DF ,0x1025 ,0x0110 },/* ICH7 on Acer 3682WLMi */ - {0x27DF ,0x1028 ,0x02b0 },/* ICH7 on unknown Dell */ - {0x27DF ,0x1043 ,0x1267 },/* ICH7 on Asus W5F */ - {0x27DF ,0x103C ,0x30A1 },/* ICH7 on HP Compaq nc2400 */ - {0x27DF ,0x103C ,0x361a },/* ICH7 on unkown HP */ - {0x27DF ,0x1071 ,0xD221 },/* ICH7 on Hercules EC-900 */ - {0x27DF ,0x152D ,0x0778 },/* ICH7 on unknown Intel */ - {0x24CA ,0x1025 ,0x0061 },/* ICH4 on ACER Aspire 2023WLMi */ - {0x24CA ,0x1025 ,0x003d },/* ICH4 on ACER TM290 */ - {0x266F ,0x1025 ,0x0066 },/* ICH6 on ACER Aspire 1694WLMi */ - {0x2653 ,0x1043 ,0x82D8 },/* ICH6M on Asus Eee 701 */ - {0x27df ,0x104d ,0x900e },/* ICH7 on Sony TZ-90 */ -/* end marker */ - {0 , } -}; - -static int ich_short_ata40 (struct pci_dev *pdev) -{ -const struct ich_laptop *lap = &ich_laptop[0 ]; - -while (lap->device) { -if (lap->device == pdev->device && - lap->subvendor == pdev->subsystem_vendor && - lap->subdevice == pdev->subsystem_device) -return 1 ; - lap++; - } - -return 0 ; -} +#include "ata_piix.h" /** * ich_pata_cable_detect - Probe host controller cable detect info
drivers/ata/ata_piix.h new file +45 -0
45 lines not on this page · raw message
PATCH 11/68 piix: use ata_piix.h
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] piix: use ata_piix.h
--- drivers/ide/piix.c | 41 +++-------------------------------------- 1 file changed, 3 insertions(+), 38 deletions(-)
drivers/ide/piix.c +3 -38
@@ -241,51 +241,16 @@ static void ich_clear_irq(ide_drive_t *doutb (dma_stat, hwif->dma_base +ATA_DMA_STATUS ); } -struct ich_laptop { -u16 device; -u16 subvendor; -u16 subdevice; -}; - -/* -* List of laptops that use short cables rather than 80 wire -*/ - -static const struct ich_laptop ich_laptop[] = { -/* devid, subvendor, subdev */ - {0x27DF ,0x1025 ,0x0102 },/* ICH7 on Acer 5602aWLMi */ - {0x27DF ,0x0005 ,0x0280 },/* ICH7 on Acer 5602WLMi */ - {0x27DF ,0x1025 ,0x0110 },/* ICH7 on Acer 3682WLMi */ - {0x27DF ,0x1028 ,0x02b0 },/* ICH7 on unknown Dell */ - {0x27DF ,0x1043 ,0x1267 },/* ICH7 on Asus W5F */ - {0x27DF ,0x103C ,0x30A1 },/* ICH7 on HP Compaq nc2400 */ - {0x27DF ,0x103C ,0x361a },/* ICH7 on unkown HP */ - {0x27DF ,0x1071 ,0xD221 },/* ICH7 on Hercules EC-900 */ - {0x27DF ,0x152D ,0x0778 },/* ICH7 on unknown Intel */ - {0x24CA ,0x1025 ,0x0061 },/* ICH4 on Acer Aspire 2023WLMi */ - {0x24CA ,0x1025 ,0x003d },/* ICH4 on ACER TM290 */ - {0x266F ,0x1025 ,0x0066 },/* ICH6 on ACER Aspire 1694WLMi */ - {0x2653 ,0x1043 ,0x82D8 },/* ICH6M on Asus Eee 701 */ - {0x27df ,0x104d ,0x900e },/* ICH7 on Sony TZ-90 */ -/* end marker */ - {0 , } -}; +#include "../ata/ata_piix.h" static u8 piix_cable_detect (ide_hwif_t *hwif) {struct pci_dev *pdev =to_pci_dev (hwif->dev); -const struct ich_laptop *lap = &ich_laptop[0 ];u8 reg54h =0 , mask = hwif->channel ?0xc0 :0x30 ;/* check for specials */ -while (lap->device) { -if (lap->device == pdev->device && - lap->subvendor == pdev->subsystem_vendor && - lap->subdevice == pdev->subsystem_device) { -return ATA_CBL_PATA40_SHORT ; - } - lap++; - } +if (ich_short_ata40 (pdev)) +return ATA_CBL_PATA40_SHORT ;pci_read_config_byte (pdev,0x54 , ®54h);
PATCH 12/68 pata_ali: move short cable handling to pata_ali.h
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] pata_ali: move short cable handling to pata_ali.h
It is a generic code and can be shared between pata_ali & alim15x3 drivers.
Fix typo while at it ("Satelite" -> "Satellite").
--- drivers/ata/pata_ali.c | 37 +------------------------------------ drivers/ata/pata_ali.h | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 36 deletions(-)
drivers/ata/pata_ali.c +1 -36
@@ -32,7 +32,6 @@#include <linux/delay.h> #include <scsi/scsi_host.h> #include <linux/libata.h> -#include <linux/dmi.h> #define DRV_NAME "pata_ali"#define DRV_VERSION "0.7.8"
@@ -43,41 +42,7 @@ MODULE_PARM_DESC(atapi_dma, "Enable ATAPstatic struct pci_dev *ali_isa_bridge; -/* -* Cable special cases -*/ - -static const struct dmi_system_id cable_dmi_table[] = { - { - .ident ="HP Pavilion N5430" , - .matches = { -DMI_MATCH (DMI_BOARD_VENDOR ,"Hewlett-Packard" ), -DMI_MATCH (DMI_BOARD_VERSION ,"OmniBook N32N-736" ), - }, - }, - { - .ident ="Toshiba Satelite S1800-814" , - .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"TOSHIBA" ), -DMI_MATCH (DMI_PRODUCT_NAME ,"S1800-814" ), - }, - }, - { } -}; - -static int ali_cable_override (struct pci_dev *pdev) -{ -/* Fujitsu P2000 */ -if (pdev->subsystem_vendor ==0x10CF && pdev->subsystem_device ==0x10AF ) -return 1 ; -/* Mitac 8317 (Winbook-A) and relatives */ -if (pdev->subsystem_vendor ==0x1071 && pdev->subsystem_device ==0x8317 ) -return 1 ; -/* Systems by DMI */ -if (dmi_check_system (cable_dmi_table)) -return 1 ; -return 0 ; -} +#include "pata_ali.h" /** * ali_c2_cable_detect - cable detection
drivers/ata/pata_ali.h new file +40 -0
@@ -0,0 +1,40 @@ + +#include <linux/dmi.h> + +/* +* Cable special cases +*/ + +static const struct dmi_system_id cable_dmi_table[] = { + { + .ident ="HP Pavilion N5430" , + .matches = { +DMI_MATCH (DMI_BOARD_VENDOR ,"Hewlett-Packard" ), +DMI_MATCH (DMI_BOARD_VERSION ,"OmniBook N32N-736" ), + }, + }, + { + .ident ="Toshiba Satellite S1800-814" , + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"TOSHIBA" ), +DMI_MATCH (DMI_PRODUCT_NAME ,"S1800-814" ), + }, + }, + { } +}; + +static int ali_cable_override (struct pci_dev *pdev) +{ +/* Fujitsu P2000 */ +if (pdev->subsystem_vendor ==0x10CF && + pdev->subsystem_device ==0x10AF ) +return 1 ; +/* Mitac 8317 (Winbook-A) and relatives */ +if (pdev->subsystem_vendor ==0x1071 && + pdev->subsystem_device ==0x8317 ) +return 1 ; +/* Systems by DMI */ +if (dmi_check_system (cable_dmi_table)) +return 1 ; +return 0 ; +}
PATCH 13/68 alim15x3: use pata_ali.h
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] alim15x3: use pata_ali.h
--- drivers/ide/alim15x3.c | 42 +----------------------------------------- 1 file changed, 1 insertion(+), 41 deletions(-)
drivers/ide/alim15x3.c +1 -41
@@ -33,7 +33,6 @@#include <linux/pci.h> #include <linux/ide.h> #include <linux/init.h> -#include <linux/dmi.h> #include <asm/io.h>
@@ -308,46 +307,7 @@ out:return 0 ; } -/* -* Cable special cases -*/ - -static const struct dmi_system_id cable_dmi_table[] = { - { - .ident ="HP Pavilion N5430" , - .matches = { -DMI_MATCH (DMI_BOARD_VENDOR ,"Hewlett-Packard" ), -DMI_MATCH (DMI_BOARD_VERSION ,"OmniBook N32N-736" ), - }, - }, - { - .ident ="Toshiba Satellite S1800-814" , - .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"TOSHIBA" ), -DMI_MATCH (DMI_PRODUCT_NAME ,"S1800-814" ), - }, - }, - { } -}; - -static int ali_cable_override (struct pci_dev *pdev) -{ -/* Fujitsu P2000 */ -if (pdev->subsystem_vendor ==0x10CF && - pdev->subsystem_device ==0x10AF ) -return 1 ; - -/* Mitac 8317 (Winbook-A) and relatives */ -if (pdev->subsystem_vendor ==0x1071 && - pdev->subsystem_device ==0x8317 ) -return 1 ; - -/* Systems by DMI */ -if (dmi_check_system (cable_dmi_table)) -return 1 ; - -return 0 ; -} +#include "../ata/pata_ali.h" /** * ali_cable_detect - cable detection
PATCH 14/68 pata_sis: move short cable handling to pata_sis.h
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] pata_sis: move short cable handling to pata_sis.h
It is a generic code and can be shared between pata_sis & sis5513 drivers.
--- drivers/ata/pata_sis.c | 30 +----------------------------- drivers/ata/pata_sis.h | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 29 deletions(-)
drivers/ata/pata_sis.c +1 -29
@@ -45,35 +45,7 @@ struct sis_chipset {up code later */ }; -struct sis_laptop { -u16 device; -u16 subvendor; -u16 subdevice; -}; - -static const struct sis_laptop sis_laptop[] = { -/* devid, subvendor, subdev */ - {0x5513 ,0x1043 ,0x1107 },/* ASUS A6K */ - {0x5513 ,0x1734 ,0x105F },/* FSC Amilo A1630 */ - {0x5513 ,0x1071 ,0x8640 },/* EasyNote K5305 */ -/* end marker */ - {0 , } -}; - -static int sis_short_ata40 (struct pci_dev *dev) -{ -const struct sis_laptop *lap = &sis_laptop[0 ]; - -while (lap->device) { -if (lap->device == dev->device && - lap->subvendor == dev->subsystem_vendor && - lap->subdevice == dev->subsystem_device) -return 1 ; - lap++; - } - -return 0 ; -} +#include "pata_sis.h" /** * sis_old_port_base - return PCI configuration base for dev
drivers/ata/pata_sis.h new file +30 -0
@@ -0,0 +1,30 @@ + +struct sis_laptop { +u16 device; +u16 subvendor; +u16 subdevice; +}; + +static const struct sis_laptop sis_laptop[] = { +/* devid, subvendor, subdev */ + {0x5513 ,0x1043 ,0x1107 },/* ASUS A6K */ + {0x5513 ,0x1734 ,0x105F },/* FSC Amilo A1630 */ + {0x5513 ,0x1071 ,0x8640 },/* EasyNote K5305 */ +/* end marker */ + {0 , } +}; + +static int sis_short_ata40 (struct pci_dev *dev) +{ +const struct sis_laptop *lap = &sis_laptop[0 ]; + +while (lap->device) { +if (lap->device == dev->device && + lap->subvendor == dev->subsystem_vendor && + lap->subdevice == dev->subsystem_device) +return 1 ; + lap++; + } + +return 0 ; +}
PATCH 15/68 sis5513: use pata_sis.h
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] sis5513: use pata_sis.h
--- drivers/ide/sis5513.c | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-)
drivers/ide/sis5513.c +3 -22
@@ -506,34 +506,15 @@ static int init_chipset_sis5513(struct preturn 0 ; } -struct sis_laptop { -u16 device; -u16 subvendor; -u16 subdevice; -}; - -static const struct sis_laptop sis_laptop[] = { -/* devid, subvendor, subdev */ - {0x5513 ,0x1043 ,0x1107 },/* ASUS A6K */ - {0x5513 ,0x1734 ,0x105f },/* FSC Amilo A1630 */ - {0x5513 ,0x1071 ,0x8640 },/* EasyNote K5305 */ -/* end marker */ - {0 , } -}; +#include "../ata/pata_sis.h" static u8 sis_cable_detect (ide_hwif_t *hwif) {struct pci_dev *pdev =to_pci_dev (hwif->dev); -const struct sis_laptop *lap = &sis_laptop[0 ];u8 ata66 =0 ; -while (lap->device) { -if (lap->device == pdev->device && - lap->subvendor == pdev->subsystem_vendor && - lap->subdevice == pdev->subsystem_device) -return ATA_CBL_PATA40_SHORT ; - lap++; - } +if (sis_short_ata40 (pdev)) +return ATA_CBL_PATA40_SHORT ;if (chipset_family >=ATA_133 ) {u16 regw =0 ;
PATCH 16/68 pata_via: move short cable handling to pata_via.h
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] pata_via: move short cable handling to pata_via.h
It is a generic code and can be shared between pata_via & via82cxxx drivers.
--- drivers/ata/pata_via.c | 28 +--------------------------- drivers/ata/pata_via.h | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 27 deletions(-)
drivers/ata/pata_via.c +1 -27
@@ -60,7 +60,6 @@#include <linux/delay.h> #include <scsi/scsi_host.h> #include <linux/libata.h> -#include <linux/dmi.h> #define DRV_NAME "pata_via"#define DRV_VERSION "0.3.4"
@@ -127,32 +126,7 @@ struct via_port {u8 cached_device; }; -/* -* Cable special cases -*/ - -static const struct dmi_system_id cable_dmi_table[] = { - { - .ident ="Acer Ferrari 3400" , - .matches = { -DMI_MATCH (DMI_BOARD_VENDOR ,"Acer,Inc." ), -DMI_MATCH (DMI_BOARD_NAME ,"Ferrari 3400" ), - }, - }, - { } -}; - -static int via_cable_override (struct pci_dev *pdev) -{ -/* Systems by DMI */ -if (dmi_check_system (cable_dmi_table)) -return 1 ; -/* Arima W730-K8/Targa Visionary 811/... */ -if (pdev->subsystem_vendor ==0x161F && pdev->subsystem_device ==0x2032 ) -return 1 ; -return 0 ; -} - +#include "pata_via.h" /** * via_cable_detect - cable detection
drivers/ata/pata_via.h new file +29 -0
@@ -0,0 +1,29 @@ + +#include <linux/dmi.h> + +/* +* Cable special cases +*/ + +static const struct dmi_system_id cable_dmi_table[] = { + { + .ident ="Acer Ferrari 3400" , + .matches = { +DMI_MATCH (DMI_BOARD_VENDOR ,"Acer,Inc." ), +DMI_MATCH (DMI_BOARD_NAME ,"Ferrari 3400" ), + }, + }, + { } +}; + +static int via_cable_override (struct pci_dev *pdev) +{ +/* Systems by DMI */ +if (dmi_check_system (cable_dmi_table)) +return 1 ; +/* Arima W730-K8/Targa Visionary 811/... */ +if (pdev->subsystem_vendor ==0x161F && + pdev->subsystem_device ==0x2032 ) +return 1 ; +return 0 ; +}
PATCH 17/68 via82cxxx: use pata_via.h
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] via82cxxx: use pata_via.h
--- drivers/ide/via82cxxx.c | 30 +----------------------------- 1 file changed, 1 insertion(+), 29 deletions(-)
drivers/ide/via82cxxx.c +1 -29
@@ -29,7 +29,6 @@#include <linux/pci.h> #include <linux/init.h> #include <linux/ide.h> -#include <linux/dmi.h> #ifdef CONFIG_PPC_CHRP #include <asm/processor.h>
@@ -351,34 +350,7 @@ static int init_chipset_via82cxxx(structreturn 0 ; } -/* -* Cable special cases -*/ - -static const struct dmi_system_id cable_dmi_table[] = { - { - .ident ="Acer Ferrari 3400" , - .matches = { -DMI_MATCH (DMI_BOARD_VENDOR ,"Acer,Inc." ), -DMI_MATCH (DMI_BOARD_NAME ,"Ferrari 3400" ), - }, - }, - { } -}; - -static int via_cable_override (struct pci_dev *pdev) -{ -/* Systems by DMI */ -if (dmi_check_system (cable_dmi_table)) -return 1 ; - -/* Arima W730-K8/Targa Visionary 811/... */ -if (pdev->subsystem_vendor ==0x161F && - pdev->subsystem_device ==0x2032 ) -return 1 ; - -return 0 ; -} +#include "../ata/pata_via.h" static u8 via82cxxx_cable_detect (ide_hwif_t *hwif) {
PATCH 18/68 ide: split host->dev table
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] ide: split host->dev table
Split dev table in struct ide_host on dev and dev2 fields to match corresponding fields used in struct ata_host.
--- drivers/ide/cy82c693.c | 2 +- drivers/ide/hpt366.c | 6 +++--- drivers/ide/ide-probe.c | 2 +- drivers/ide/ide.c | 4 ++-- drivers/ide/pdc202xx_new.c | 2 +- drivers/ide/setup-pci.c | 6 +++--- include/linux/ide.h | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-)
drivers/ide/cy82c693.c +1 -1
@@ -179,7 +179,7 @@ static int __devinit cy82c693_init_one(s static void __devexit cy82c693_remove(struct pci_dev *dev) {struct ide_host *host =pci_get_drvdata (dev); -struct pci_dev *dev2 = host->dev[1 ] ?to_pci_dev (host->dev[1 ]) :NULL ; +struct pci_dev *dev2 = host->dev2 ?to_pci_dev (host->dev2) :NULL ;ide_pci_remove (dev);pci_dev_put (dev2);
drivers/ide/hpt366.c +3 -3
@@ -610,7 +610,7 @@ static struct hpt_info *hpt3xx_get_info(struct ide_host *host =dev_get_drvdata (dev);struct hpt_info *info = (struct hpt_info *)host->host_priv; -return dev == host->dev[1 ] ? info +1 : info; +return dev == host->dev2 ? info +1 : info; }/*
@@ -943,7 +943,7 @@ static int hpt37x_calibrate_dpll(structstatic void hpt3xx_disable_fast_irq (struct pci_dev *dev,u8 mcr_addr) {struct ide_host *host =pci_get_drvdata (dev); -struct hpt_info *info = host->host_priv + (&dev->dev == host->dev[1 ]); +struct hpt_info *info = host->host_priv + (&dev->dev == host->dev2);u8 chip_type = info->chip_type;u8 new_mcr, old_mcr =0 ;
@@ -1567,7 +1567,7 @@ static void __devexit hpt366_remove(stru {struct ide_host *host =pci_get_drvdata (dev);struct ide_info *info = host->host_priv; -struct pci_dev *dev2 = host->dev[1 ] ?to_pci_dev (host->dev[1 ]) :NULL ; +struct pci_dev *dev2 = host->dev2 ?to_pci_dev (host->dev2) :NULL ;ide_pci_remove (dev);pci_dev_put (dev2);
drivers/ide/ide-probe.c +1 -1
@@ -1334,7 +1334,7 @@ struct ide_host *ide_host_alloc(const streturn NULL ; } - host->dev[0 ] = dev; + host->dev = dev;if (d) { host->init_chipset = d->init_chipset;
drivers/ide/ide.c +2 -2
@@ -77,7 +77,7 @@ int ide_device_get(ide_drive_t *drive)if (!get_device (&drive->gendev))return -ENXIO ; - host_dev = drive->hwif->host->dev[0 ]; + host_dev = drive->hwif->host->dev; module = host_dev ? host_dev->driver->owner :NULL ;if (module && !try_module_get (module)) {
@@ -99,7 +99,7 @@ EXPORT_SYMBOL_GPL(ide_device_get);void ide_device_put (ide_drive_t *drive) {#ifdef CONFIG_MODULE_UNLOAD -struct device *host_dev = drive->hwif->host->dev[0 ]; +struct device *host_dev = drive->hwif->host->dev;struct module *module = host_dev ? host_dev->driver->owner :NULL ;if (module)
drivers/ide/pdc202xx_new.c +1 -1
@@ -517,7 +517,7 @@ static int __devinit pdc202new_init_one( static void __devexit pdc202new_remove(struct pci_dev *dev) {struct ide_host *host =pci_get_drvdata (dev); -struct pci_dev *dev2 = host->dev[1 ] ?to_pci_dev (host->dev[1 ]) :NULL ; +struct pci_dev *dev2 = host->dev2 ?to_pci_dev (host->dev2) :NULL ;ide_pci_remove (dev);pci_dev_put (dev2);
drivers/ide/setup-pci.c +3 -3
@@ -556,9 +556,9 @@ int ide_pci_init_two(struct pci_dev *dev goto out; } - host->dev[0 ] = &dev1->dev; + host->dev = &dev1->dev;if (dev2) - host->dev[1 ] = &dev2->dev; + host->dev2 = &dev2->dev; host->host_priv = priv; host->irq_flags =IRQF_SHARED ;
@@ -603,7 +603,7 @@ EXPORT_SYMBOL_GPL(ide_pci_init_one);void ide_pci_remove (struct pci_dev *dev) {struct ide_host *host =pci_get_drvdata (dev); -struct pci_dev *dev2 = host->dev[1 ] ?to_pci_dev (host->dev[1 ]) :NULL ; +struct pci_dev *dev2 = host->dev2 ?to_pci_dev (host->dev2) :NULL ;int bars;if (host->host_flags &IDE_HFLAG_SINGLE )
include/linux/ide.h +1 -1
@@ -775,7 +775,7 @@ typedef struct hwif_s {struct ide_host {ide_hwif_t *ports[MAX_HOST_PORTS +1 ];unsigned int n_ports; -struct device *dev[2 ]; +struct device *dev, *dev2;int (*init_chipset)(struct pci_dev *);
PATCH 19/68 ide: add hwif->port_no field
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] ide: add hwif->port_no field
Add port_no field to ide_hwif_t matching port_no field used in struct ata_port.
--- include/linux/ide.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
include/linux/ide.h +6 -1
@@ -682,7 +682,12 @@ typedef struct hwif_s {u8 major;/* our major number */ u8 index;/* 0 for ide0; 1 for ide1; ... */ -u8 channel;/* for dual-port chips: 0=primary, 1=secondary */ + +union { +/* for dual-port chips: 0=primary, 1=secondary */ +u8 channel; +u8 port_no; + };u32 host_flags;
PATCH 20/68 ide: add hwif->udma_mask field
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] ide: add hwif->udma_mask field
Add udma_mask field to ide_hwif_t to match udma_mask field used in struct ata_port.
--- include/linux/ide.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
include/linux/ide.h +4 -1
@@ -693,7 +693,10 @@ typedef struct hwif_s {u8 pio_mask; -u8 ultra_mask; +union { +u8 ultra_mask; +u8 udma_mask; + };u8 mwdma_mask;u8 swdma_mask;
PATCH 21/68 ide: add hwif->private_data field
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] ide: add hwif->private_data field
Add private_data field to ide_hwif_t matching private_data field used in struct ata_port.
--- include/linux/ide.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
include/linux/ide.h +5 -1
@@ -747,7 +747,11 @@ typedef struct hwif_s {struct completion gendev_rel_comp;/* To deal with device release() */ -void *hwif_data;/* extra hwif data */ +/* extra port data */ +union { +void *hwif_data; +void *private_data; + };#ifdef CONFIG_BLK_DEV_IDEACPI struct ide_acpi_hwif_link *acpidata;
PATCH 22/68 ide: add drive->devno field
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] ide: add drive->devno field
Add devno field to ide_drive_t matching devno field used in struct ata_device.
--- drivers/ide/ide-probe.c | 1 + include/linux/ide.h | 1 + 2 files changed, 2 insertions(+)
drivers/ide/ide-probe.c +1 -0
@@ -1033,6 +1033,7 @@ static void ide_port_init_devices(ide_hwide_port_for_each_dev (i, drive, hwif) { drive->dn = i + hwif->channel *2 ; + drive->devno = i;if (hwif->host_flags &IDE_HFLAG_IO_32BIT ) drive->io_32bit =1 ;
include/linux/ide.h +1 -0
@@ -518,6 +518,7 @@ struct ide_drive_s {u8 pio_mode;/* for ->set_pio_mode _only_ */ u8 dma_mode;/* for ->dma_pio_mode _only_ */ u8 dn;/* now wide spread use */ +u8 devno;/* 0 or 1 */ u8 acoustic;/* acoustic management */ u8 media;/* disk, cdrom, tape, floppy, ... */ u8 ready_stat;/* min status value for drive ready */
PATCH 23/68 ide: add drive->class field
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] ide: add drive->class field
Add class field to ide_drive_t matching class field used in struct ata_device.
--- include/linux/ide.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
include/linux/ide.h +7 -1
@@ -520,7 +520,13 @@ struct ide_drive_s {u8 dn;/* now wide spread use */ u8 devno;/* 0 or 1 */ u8 acoustic;/* acoustic management */ -u8 media;/* disk, cdrom, tape, floppy, ... */ + +/* disk, cdrom, tape, floppy, ... */ +union { +u8 media; +u8 class; + }; +u8 ready_stat;/* min status value for drive ready */ u8 mult_count;/* current multiple sector setting */ u8 mult_req;/* requested multiple sector setting */
PATCH 24/68 ide: change ->cable_detect method return type to 'int'
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] ide: change ->cable_detect method return type to 'int'
Change ->cable_detect method return type to match ->cable_detect method used in struct ata_port_operations.
--- drivers/ide/aec62xx.c | 2 +- drivers/ide/alim15x3.c | 2 +- drivers/ide/amd74xx.c | 2 +- drivers/ide/atiixp.c | 2 +- drivers/ide/cmd64x.c | 2 +- drivers/ide/cs5535.c | 2 +- drivers/ide/cs5536.c | 2 +- drivers/ide/hpt366.c | 2 +- drivers/ide/it8213.c | 2 +- drivers/ide/it821x.c | 2 +- drivers/ide/jmicron.c | 2 +- drivers/ide/palm_bk3710.c | 2 +- drivers/ide/pdc202xx_new.c | 2 +- drivers/ide/pdc202xx_old.c | 2 +- drivers/ide/piix.c | 2 +- drivers/ide/pmac.c | 2 +- drivers/ide/scc_pata.c | 2 +- drivers/ide/serverworks.c | 2 +- drivers/ide/siimage.c | 2 +- drivers/ide/sis5513.c | 2 +- drivers/ide/slc90e66.c | 2 +- drivers/ide/tc86c001.c | 2 +- drivers/ide/tx4939ide.c | 2 +- drivers/ide/via82cxxx.c | 2 +- include/linux/ide.h | 2 +- 25 files changed, 25 insertions(+), 25 deletions(-)
drivers/ide/aec62xx.c +1 -1
@@ -160,7 +160,7 @@ static int init_chipset_aec62xx(struct preturn 0 ; } -static u8 atp86x_cable_detect (ide_hwif_t *hwif) +static int atp86x_cable_detect (ide_hwif_t *hwif) {struct pci_dev *dev =to_pci_dev (hwif->dev);u8 ata66 =0 , mask = hwif->channel ?0x02 :0x01 ;
drivers/ide/alim15x3.c +1 -1
@@ -317,7 +317,7 @@ out:* of UDMA66 transfers. It doesn't check the drives. */ -static u8 ali_cable_detect (ide_hwif_t *hwif) +static int ali_cable_detect (ide_hwif_t *hwif) {struct pci_dev *dev =to_pci_dev (hwif->dev);u8 cbl =ATA_CBL_PATA40 , tmpbyte;
drivers/ide/amd74xx.c +1 -1
@@ -178,7 +178,7 @@ static int init_chipset_amd74xx(struct preturn 0 ; } -static u8 amd_cable_detect (ide_hwif_t *hwif) +static int amd_cable_detect (ide_hwif_t *hwif) {if ((amd_80w >> hwif->channel) &1 )return ATA_CBL_PATA80 ;
drivers/ide/atiixp.c +1 -1
@@ -120,7 +120,7 @@ static void atiixp_set_dma_mode(ide_hwifspin_unlock_irqrestore (&atiixp_lock, flags); } -static u8 atiixp_cable_detect (ide_hwif_t *hwif) +static int atiixp_cable_detect (ide_hwif_t *hwif) {struct pci_dev *pdev =to_pci_dev (hwif->dev);u8 udma_mode =0 , ch = hwif->channel;
drivers/ide/cmd64x.c +1 -1
@@ -312,7 +312,7 @@ static int init_chipset_cmd64x(struct pcreturn 0 ; } -static u8 cmd64x_cable_detect (ide_hwif_t *hwif) +static int cmd64x_cable_detect (ide_hwif_t *hwif) {struct pci_dev *dev =to_pci_dev (hwif->dev);u8 bmidecsr =0 , mask = hwif->channel ?0x02 :0x01 ;
drivers/ide/cs5535.c +1 -1
@@ -153,7 +153,7 @@ static void cs5535_set_pio_mode(ide_hwifcs5535_set_speed (drive, drive->pio_mode); } -static u8 cs5535_cable_detect (ide_hwif_t *hwif) +static int cs5535_cable_detect (ide_hwif_t *hwif) {struct pci_dev *dev =to_pci_dev (hwif->dev);u8 bit;
drivers/ide/cs5536.c +1 -1
@@ -110,7 +110,7 @@ static void cs5536_program_dtc(ide_drive* Returns a cable type. */ -static u8 cs5536_cable_detect (ide_hwif_t *hwif) +static int cs5536_cable_detect (ide_hwif_t *hwif) {struct pci_dev *pdev =to_pci_dev (hwif->dev);u32 cfg;
drivers/ide/hpt366.c +1 -1
@@ -1215,7 +1215,7 @@ static int init_chipset_hpt366(struct pcreturn 0 ; } -static u8 hpt3xx_cable_detect (ide_hwif_t *hwif) +static int hpt3xx_cable_detect (ide_hwif_t *hwif) {struct pci_dev *dev =to_pci_dev (hwif->dev);struct hpt_info *info =hpt3xx_get_info (hwif->dev);
drivers/ide/it8213.c +1 -1
@@ -140,7 +140,7 @@ static void it8213_set_dma_mode(ide_hwif } } -static u8 it8213_cable_detect (ide_hwif_t *hwif) +static int it8213_cable_detect (ide_hwif_t *hwif) {struct pci_dev *dev =to_pci_dev (hwif->dev);u8 reg42h =0 ;
drivers/ide/it821x.c +1 -1
@@ -423,7 +423,7 @@ static void it821x_set_dma_mode(ide_hwif* the needed logic onboard. */ -static u8 it821x_cable_detect (ide_hwif_t *hwif) +static int it821x_cable_detect (ide_hwif_t *hwif) {/* The reference driver also only does disk side */ return ATA_CBL_PATA80 ;
drivers/ide/jmicron.c +1 -1
@@ -26,7 +26,7 @@ typedef enum {* Returns the cable type. */ -static u8 jmicron_cable_detect (ide_hwif_t *hwif) +static int jmicron_cable_detect (ide_hwif_t *hwif) {struct pci_dev *pdev =to_pci_dev (hwif->dev);
drivers/ide/palm_bk3710.c +1 -1
@@ -274,7 +274,7 @@ static void __devinit palm_bk3710_chipinpalm_bk3710_setpiomode (base,NULL ,1 ,600 ,0 ); } -static u8 palm_bk3710_cable_detect (ide_hwif_t *hwif) +static int palm_bk3710_cable_detect (ide_hwif_t *hwif) {return ATA_CBL_PATA80 ; }
drivers/ide/pdc202xx_new.c +1 -1
@@ -180,7 +180,7 @@ static void pdcnew_set_pio_mode(ide_hwif } } -static u8 pdcnew_cable_detect (ide_hwif_t *hwif) +static int pdcnew_cable_detect (ide_hwif_t *hwif) {if (get_indexed_reg (hwif,0x0b ) &0x04 )return ATA_CBL_PATA40 ;
drivers/ide/pdc202xx_old.c +1 -1
@@ -103,7 +103,7 @@ static int pdc202xx_test_irq(ide_hwif_t } } -static u8 pdc2026x_cable_detect (ide_hwif_t *hwif) +static int pdc2026x_cable_detect (ide_hwif_t *hwif) {struct pci_dev *dev =to_pci_dev (hwif->dev);u16 CIS , mask = hwif->channel ? (1 <<11 ) : (1 <<10 );
drivers/ide/piix.c +1 -1
@@ -243,7 +243,7 @@ static void ich_clear_irq(ide_drive_t *d#include "../ata/ata_piix.h" -static u8 piix_cable_detect (ide_hwif_t *hwif) +static int piix_cable_detect (ide_hwif_t *hwif) {struct pci_dev *pdev =to_pci_dev (hwif->dev);u8 reg54h =0 , mask = hwif->channel ?0xc0 :0x30 ;
drivers/ide/pmac.c +1 -1
@@ -912,7 +912,7 @@ static int pmac_ide_do_resume(pmac_ide_hreturn 0 ; } -static u8 pmac_ide_cable_detect (ide_hwif_t *hwif) +static int pmac_ide_cable_detect (ide_hwif_t *hwif) {pmac_ide_hwif_t *pmif = (pmac_ide_hwif_t *)dev_get_drvdata (hwif->gendev.parent);
drivers/ide/scc_pata.c +1 -1
@@ -754,7 +754,7 @@ static int __devinit scc_init_dma(ide_hwreturn ide_allocate_dma_engine (hwif); } -static u8 scc_cable_detect (ide_hwif_t *hwif) +static int scc_cable_detect (ide_hwif_t *hwif) {return ATA_CBL_PATA80 ; }
drivers/ide/serverworks.c +1 -1
@@ -301,7 +301,7 @@ static u8 ata66_svwks_cobalt(ide_hwif_treturn ATA_CBL_PATA40 ; } -static u8 svwks_cable_detect (ide_hwif_t *hwif) +static int svwks_cable_detect (ide_hwif_t *hwif) {struct pci_dev *dev =to_pci_dev (hwif->dev);
drivers/ide/siimage.c +1 -1
@@ -667,7 +667,7 @@ static void __devinit init_iops_siimage(* Check for the presence of an ATA66 capable cable on the interface. */ -static u8 sil_cable_detect (ide_hwif_t *hwif) +static int sil_cable_detect (ide_hwif_t *hwif) {struct pci_dev *dev =to_pci_dev (hwif->dev);unsigned long addr =siimage_selreg (hwif,0 );
drivers/ide/sis5513.c +1 -1
@@ -508,7 +508,7 @@ static int init_chipset_sis5513(struct p#include "../ata/pata_sis.h" -static u8 sis_cable_detect (ide_hwif_t *hwif) +static int sis_cable_detect (ide_hwif_t *hwif) {struct pci_dev *pdev =to_pci_dev (hwif->dev);u8 ata66 =0 ;
drivers/ide/slc90e66.c +1 -1
@@ -115,7 +115,7 @@ static void slc90e66_set_dma_mode(ide_hw } } -static u8 slc90e66_cable_detect (ide_hwif_t *hwif) +static int slc90e66_cable_detect (ide_hwif_t *hwif) {struct pci_dev *dev =to_pci_dev (hwif->dev);u8 reg47 =0 , mask = hwif->channel ?0x01 :0x02 ;
drivers/ide/tc86c001.c +1 -1
@@ -130,7 +130,7 @@ static void tc86c001_dma_start(ide_driveide_dma_start (drive); } -static u8 tc86c001_cable_detect (ide_hwif_t *hwif) +static int tc86c001_cable_detect (ide_hwif_t *hwif) {struct pci_dev *dev =to_pci_dev (hwif->dev);unsigned long sc_base =pci_resource_start (dev,5 );
drivers/ide/tx4939ide.c +1 -1
@@ -189,7 +189,7 @@ static void tx4939ide_clear_irq(ide_drivtx4939ide_writew (ctl, base, TX4939IDE_Int_Ctl); } -static u8 tx4939ide_cable_detect (ide_hwif_t *hwif) +static int tx4939ide_cable_detect (ide_hwif_t *hwif) {void __iomem *base =TX4939IDE_BASE (hwif);
drivers/ide/via82cxxx.c +1 -1
@@ -352,7 +352,7 @@ static int init_chipset_via82cxxx(struct#include "../ata/pata_via.h" -static u8 via82cxxx_cable_detect (ide_hwif_t *hwif) +static int via82cxxx_cable_detect (ide_hwif_t *hwif) {struct pci_dev *pdev =to_pci_dev (hwif->dev);struct ide_host *host =pci_get_drvdata (pdev);
include/linux/ide.h +1 -1
@@ -644,7 +644,7 @@ struct ide_port_ops {u8 (*mdma_filter)(ide_drive_t *);u8 (*udma_filter)(ide_drive_t *); -u8 (*cable_detect)(struct hwif_s *); +int (*cable_detect)(struct hwif_s *); };struct ide_dma_ops {
PATCH 25/68 it8213: always program control bits
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] it8213: always program control bits
This matches behavior of libata pata_it8213 host driver.
--- drivers/ide/it8213.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/ide/it8213.c +2 -4
@@ -55,15 +55,13 @@ static void it8213_set_pio_mode(ide_hwifif (is_slave) { master_data |=0x4000 ; master_data &= ~0x0070 ; -if (pio >1 ) - master_data = master_data | (control <<4 ); + master_data = master_data | (control <<4 );pci_read_config_byte (dev, slave_port, &slave_data); slave_data = slave_data &0xf0 ; slave_data = slave_data | (timings[pio][0 ] <<2 ) | timings[pio][1 ]; }else { master_data &= ~0x3307 ; -if (pio >1 ) - master_data = master_data | control; + master_data = master_data | control; master_data = master_data | (timings[pio][0 ] <<12 ) | (timings[pio][1 ] <<8 ); }pci_write_config_word (dev, master_port, master_data);
Re: [PATCH 25/68] it8213: always program control bits
Hello.
Quoted 15 lines · Bartlomiej Zolnierkiewicz
From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] it8213: always program control bitsThis matches behavior of libata
pata_it8213host driver.Signed-off-by Bartlomiej Zolnierkiewicz <[email protected]>--- drivers/ide/it8213.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)Index:
b/drivers/ide/it8213.c
===================================================================
drivers/ide/it8213.c static void it8213_set_pio_mode(ide_hwif · line 59
Quoted 7 lines
drivers/ide/it8213.c +1
-2@@ -55,15 +55,13 @@ static void it8213_set_pio_mode(ide_hwifif (is_slave) { master_data |=0x4000 ; master_data &= ~0x0070 ; -if (pio >1 ) - master_data = master_data | (control <<4 ); + master_data = master_data | (control <<4 );
master_data |= control << 4; /* it's C after all */
drivers/ide/it8213.c static void it8213_set_pio_mode(ide_hwif
Quoted 9 lines
drivers/ide/it8213.c +1
-2pci_read_config_byte (dev, slave_port, &slave_data); slave_data = slave_data &0xf0 ; slave_data = slave_data | (timings[pio][0 ] <<2 ) | timings[pio][1 ]; }else { master_data &= ~0x3307 ; -if (pio >1 ) - master_data = master_data | control; + master_data = master_data | control;
master_data |= control;
drivers/ide/it8213.c static void it8213_set_pio_mode(ide_hwif · line 65
Quoted 2 lines
drivers/ide/it8213.c +0
-0master_data = master_data | (timings[pio][0 ] <<12 ) | (timings[pio][1 ] <<8 );
MBR, Sergei
PATCH 26/68 piix: always program control bits
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] piix: always program control bits
This matches behavior of libata ata_piix host driver.
--- drivers/ide/piix.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/ide/piix.c +4 -8
@@ -103,20 +103,16 @@ static void piix_set_pio_mode(ide_hwif_tif (is_slave) { master_data |=0x4000 ; master_data &= ~0x0070 ; -if (pio >1 ) { -/* Set PPE, IE and TIME */ - master_data |= control <<4 ; - } +/* Set PPE, IE and TIME */ + master_data |= control <<4 ;pci_read_config_byte (dev, slave_port, &slave_data); slave_data &= hwif->channel ?0x0f :0xf0 ; slave_data |= ((timings[pio][0 ] <<2 ) | timings[pio][1 ]) << (hwif->channel ?4 :0 ); }else { master_data &= ~0x3307 ; -if (pio >1 ) { -/* enable PPE, IE and TIME */ - master_data |= control; - } +/* enable PPE, IE and TIME */ + master_data |= control; master_data |= (timings[pio][0 ] <<12 ) | (timings[pio][1 ] <<8 ); }pci_write_config_word (dev, master_port, master_data);
PATCH 27/68 slc90e66: always program control bits
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] slc90e66: always program control bits
This matches behavior of libata pata_efar host driver.
--- drivers/ide/slc90e66.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/ide/slc90e66.c +4 -8
@@ -50,20 +50,16 @@ static void slc90e66_set_pio_mode(ide_hwif (is_slave) { master_data |=0x4000 ; master_data &= ~0x0070 ; -if (pio >1 ) { -/* Set PPE, IE and TIME */ - master_data |= control <<4 ; - } +/* Set PPE, IE and TIME */ + master_data |= control <<4 ;pci_read_config_byte (dev, slave_port, &slave_data); slave_data &= hwif->channel ?0x0f :0xf0 ; slave_data |= ((timings[pio][0 ] <<2 ) | timings[pio][1 ]) << (hwif->channel ?4 :0 ); }else { master_data &= ~0x3307 ; -if (pio >1 ) { -/* enable PPE, IE and TIME */ - master_data |= control; - } +/* enable PPE, IE and TIME */ + master_data |= control; master_data |= (timings[pio][0 ] <<12 ) | (timings[pio][1 ] <<8 ); }pci_write_config_word (dev, master_port, master_data);
PATCH 28/68 add ide2libata header file
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] add ide2libata header file
--- include/linux/ide2libata.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
include/linux/ide2libata.h new file +17 -0
@@ -0,0 +1,17 @@ +#ifndef __IDE2LIBATA_H +#define __IDE2LIBATA_H + +#include <linux/ide.h> + +#define __IDE2LIBATA 1 + +#define ATA_DEV_ATA ide_disk + +#define ata_host ide_host +#define ata_port hwif_s +#define ata_device ide_drive_s + +#define ata_pio_need_iordy (d) ide_pio_need_iordy(d, d->pio_mode - XFER_PIO_0) +#define ata_dev_pair ide_get_pair_dev + +#endif /* __IDE2LIBATA_H */
PATCH 29/68 ata_piix: move code to be re-used by ide2libata to ata_piix.h
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] ata_piix: move code to be re-used by ide2libata to ata_piix.h
--- drivers/ata/ata_piix.c | 220 ----------------------------------------------- drivers/ata/ata_piix.h | 226 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 226 insertions(+), 220 deletions(-)
drivers/ata/ata_piix.c +0 -220
@@ -629,178 +629,6 @@ static int piix_pata_prereset(struct atareturn ata_sff_prereset (link, deadline); } -static DEFINE_SPINLOCK (piix_lock); - -static void piix_set_timings (struct ata_port *ap,struct ata_device *adev, -u8 pio,bool use_mwdma) -{ -struct pci_dev *dev =to_pci_dev (ap->host->dev); -unsigned long flags; -unsigned int is_slave = (adev->devno !=0 ); -unsigned int master_port= ap->port_no ?0x42 :0x40 ; -unsigned int slave_port =0x44 ; -u16 master_data; -u8 slave_data; -u8 udma_enable; -int control =0 ; - -/* -* See Intel Document 298600-004 for the timing programing rules -* for ICH controllers. -*/ - -static const /* ISP RTC */ -u8 timings[][2 ] = { {0 ,0 }, - {0 ,0 }, - {1 ,0 }, - {2 ,1 }, - {2 ,3 }, }; - -if (pio >=2 || use_mwdma) - control |=1 ;/* TIME1 enable */ -if (ata_pio_need_iordy (adev) || use_mwdma) - control |=2 ;/* IE enable */ -/* Intel specifies that the PPE functionality is for disk only */ -if (adev->class ==ATA_DEV_ATA ) - control |=4 ;/* PPE enable */ -/* If the drive MWDMA is faster than it can do PIO then -we must force PIO into PIO0 */ -if (use_mwdma && adev->pio_mode < (XFER_PIO_0 + pio)) -/* Enable DMA timing only */ - control |=8 ;/* PIO cycles in PIO0 */ - -spin_lock_irqsave (&piix_lock, flags); - -/* PIO configuration clears DTE unconditionally. It will be -* programmed in set_dmamode which is guaranteed to be called -* after set_piomode if any DMA mode is available. -*/ -pci_read_config_word (dev, master_port, &master_data); -if (is_slave) { -/* clear TIME1|IE1|PPE1|DTE1 */ - master_data &=0xff0f ; -/* Enable SITRE (separate slave timing register) */ - master_data |=0x4000 ; -/* enable PPE1, IE1 and TIME1 as needed */ - master_data |= (control <<4 ); -pci_read_config_byte (dev, slave_port, &slave_data); - slave_data &= (ap->port_no ?0x0f :0xf0 ); -/* Load the timing nibble for this slave */ - slave_data |= ((timings[pio][0 ] <<2 ) | timings[pio][1 ]) - << (ap->port_no ?4 :0 ); - }else { -/* clear ISP|RCT|TIME0|IE0|PPE0|DTE0 */ - master_data &=0xccf0 ; -/* Enable PPE, IE and TIME as appropriate */ - master_data |= control; -/* load ISP and RCT */ - master_data |= - (timings[pio][0 ] <<12 ) | - (timings[pio][1 ] <<8 ); - } -pci_write_config_word (dev, master_port, master_data); -if (is_slave) -pci_write_config_byte (dev, slave_port, slave_data); - -/* Ensure the UDMA bit is off - it will be turned back on if -UDMA is selected */ - -if (ap->udma_mask) { -pci_read_config_byte (dev,0x48 , &udma_enable); - udma_enable &= ~(1 << (2 * ap->port_no + adev->devno)); -pci_write_config_byte (dev,0x48 , udma_enable); - } - -spin_unlock_irqrestore (&piix_lock, flags); -} - -/** -* piix_set_piomode - Initialize host controller PATA PIO timings -* @ap: Port whose timings we are configuring -* @adev: Drive in question -* -* Set PIO mode for device, in host controller PCI config space. -* -* LOCKING: -* None (inherited from caller). -*/ - -static void piix_set_piomode (struct ata_port *ap,struct ata_device *adev) -{ -piix_set_timings (ap, adev, adev->pio_mode -XFER_PIO_0 ,0 ); -} - -/** -* do_pata_set_dmamode - Initialize host controller PATA PIO timings -* @ap: Port whose timings we are configuring -* @adev: Drive in question -* @isich: set if the chip is an ICH device -* -* Set UDMA mode for device, in host controller PCI config space. -* -* LOCKING: -* None (inherited from caller). -*/ - -static void do_pata_set_dmamode (struct ata_port *ap,struct ata_device *adev,int isich) -{ -struct pci_dev *dev =to_pci_dev (ap->host->dev); -unsigned long flags; -u8 speed = adev->dma_mode; -int devid = adev->devno +2 * ap->port_no; -u8 udma_enable =0 ; - -if (speed >=XFER_UDMA_0 ) { -unsigned int udma = speed -XFER_UDMA_0 ; -u16 udma_timing; -u16 ideconf; -int u_clock, u_speed; - -spin_lock_irqsave (&piix_lock, flags); - -pci_read_config_byte (dev,0x48 , &udma_enable); - -/* -* UDMA is handled by a combination of clock switching and -* selection of dividers -* -* Handy rule: Odd modes are UDMATIMx 01, even are 02 -* except UDMA0 which is 00 -*/ - u_speed =min (2 - (udma &1 ), udma); -if (udma ==5 ) - u_clock =0x1000 ;/* 100Mhz */ -else if (udma >2 ) - u_clock =1 ;/* 66Mhz */ -else - u_clock =0 ;/* 33Mhz */ - - udma_enable |= (1 << devid); - -/* Load the CT/RP selection */ -pci_read_config_word (dev,0x4A , &udma_timing); - udma_timing &= ~(3 << (4 * devid)); - udma_timing |= u_speed << (4 * devid); -pci_write_config_word (dev,0x4A , udma_timing); - -if (isich) { -/* Select a 33/66/100Mhz clock */ -pci_read_config_word (dev,0x54 , &ideconf); - ideconf &= ~(0x1001 << devid); - ideconf |= u_clock << devid; -/* For ICH or later we should set bit 10 for better -performance (WR_PingPong_En) */ -pci_write_config_word (dev,0x54 , ideconf); - } - -pci_write_config_byte (dev,0x48 , udma_enable); - -spin_unlock_irqrestore (&piix_lock, flags); - }else -/* MWDMA is driven by the PIO timings. */ -piix_set_timings (ap, adev,ata_mwdma_to_pio (speed),1 ); -} -/** * piix_set_dmamode - Initialize host controller PATA DMA timings * @ap: Port whose timings we are configuring
@@ -817,22 +645,6 @@ static void piix_set_dmamode(struct ata_do_pata_set_dmamode (ap, adev,0 ); } -/** -* ich_set_dmamode - Initialize host controller PATA DMA timings -* @ap: Port whose timings we are configuring -* @adev: um -* -* Set MW/UDMA mode for device, in host controller PCI config space. -* -* LOCKING: -* None (inherited from caller). -*/ - -static void ich_set_dmamode (struct ata_port *ap,struct ata_device *adev) -{ -do_pata_set_dmamode (ap, adev,1 ); -} -/* * Serial ATA Index/Data Pair Superset Registers access *
@@ -1145,38 +957,6 @@ static int piix_disable_ahci(struct pci_return rc; } -/** -* piix_check_450nx_errata - Check for problem 450NX setup -* @ata_dev: the PCI device to check -* -* Check for the present of 450NX errata #19 and errata #25. If -* they are found return an error code so we can turn off DMA -*/ - -static int __devinit piix_check_450nx_errata (struct pci_dev *ata_dev) -{ -struct pci_dev *pdev =NULL ; -u16 cfg; -int no_piix_dma =0 ; - -while ((pdev =pci_get_device (PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_INTEL_82454NX , pdev)) !=NULL ) { -/* Look for 450NX PXB. Check for problem configurations -A PCI quirk checks bit 6 already */ -pci_read_config_word (pdev,0x41 , &cfg); -/* Only on the original revision: IDE DMA can hang */ -if (pdev->revision ==0x00 ) - no_piix_dma =1 ; -/* On all revisions below 5 PXB bus lock must be disabled for IDE */ -else if (cfg & (1 <<14 ) && pdev->revision <5 ) - no_piix_dma =2 ; - } -if (no_piix_dma) -dev_printk (KERN_WARNING , &ata_dev->dev,"450NX errata present, disabling IDE DMA.\n" ); -if (no_piix_dma ==2 ) -dev_printk (KERN_WARNING , &ata_dev->dev,"A BIOS update may resolve this.\n" ); -return no_piix_dma; -} -static void __devinit piix_init_pcs (struct ata_host *host,const struct piix_map_db *map_db) {
drivers/ata/ata_piix.h +226 -0
229 lines not on this page · raw message
PATCH 30/68 piix: convert to ide2libata
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] piix: convert to ide2libata
--- drivers/ata/ata_piix.h | 15 ++-- drivers/ide/piix.c | 182 ++----------------------------------------------- 2 files changed, 19 insertions(+), 178 deletions(-)
drivers/ata/ata_piix.h +11 -4
@@ -44,7 +44,6 @@ static int ich_short_ata40(struct pci_dereturn 0 ; } -#ifdef __LINUX_LIBATA_H__static DEFINE_SPINLOCK (piix_lock); static void piix_set_timings(struct ata_port *ap, struct ata_device *adev,
@@ -213,9 +212,18 @@ static void do_pata_set_dmamode(struct apci_write_config_byte (dev,0x48 , udma_enable);spin_unlock_irqrestore (&piix_lock, flags); - }else -/* MWDMA is driven by the PIO timings. */ + }else { +/* Normal DMA is driven by the PIO timings. */ +#ifdef __IDE2LIBATA +if (speed >=XFER_MW_DMA_0 ) + adev->pio_mode =ata_mwdma_to_pio (speed) +XFER_PIO_0 ; +else + adev->pio_mode =XFER_PIO_2 ;/* for SWDMA2 */ +piix_set_timings (ap, adev, adev->pio_mode -XFER_PIO_0 ,1 ); +#else piix_set_timings (ap, adev,ata_mwdma_to_pio (speed),1 ); +#endif + } }/**
@@ -268,4 +276,3 @@ static int __devinit piix_check_450nx_er "A BIOS update may resolve this.\n");return no_piix_dma; } -#endif
drivers/ide/piix.c +8 -174
223 lines not on this page · raw message
PATCH 31/68 pata_ali: move code to be re-used by ide2libata to pata_ali.h
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] pata_ali: move code to be re-used by ide2libata to pata_ali.h
--- drivers/ata/pata_ali.c | 240 ------------------------------------------------ drivers/ata/pata_ali.h | 241 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 241 insertions(+), 240 deletions(-)
drivers/ata/pata_ali.c +0 -240
@@ -45,33 +45,6 @@ static struct pci_dev *ali_isa_bridge;#include "pata_ali.h" /** -* ali_c2_cable_detect - cable detection -* @ap: ATA port -* -* Perform cable detection for C2 and later revisions -*/ - -static int ali_c2_cable_detect (struct ata_port *ap) -{ -struct pci_dev *pdev =to_pci_dev (ap->host->dev); -u8 ata66; - -/* Certain laptops use short but suitable cables and don't -implement the detect logic */ - -if (ali_cable_override (pdev)) -return ATA_CBL_PATA40_SHORT ; - -/* Host view cable detect 0x4A bit 0 primary bit 1 secondary -Bit set for 40 pin */ -pci_read_config_byte (pdev,0x4A , &ata66); -if (ata66 & (1 << ap->port_no)) -return ATA_CBL_PATA40 ; -else -return ATA_CBL_PATA80 ; -} - -/** * ali_20_filter - filter for earlier ALI DMA * @ap: ALi ATA port * @adev: attached device
@@ -93,156 +66,6 @@ static unsigned long ali_20_filter(struc }/** -* ali_fifo_control - FIFO manager -* @ap: ALi channel to control -* @adev: device for FIFO control -* @on: 0 for off 1 for on -* -* Enable or disable the FIFO on a given device. Because of the way the -* ALi FIFO works it provides a boost on ATA disk but can be confused by -* ATAPI and we must therefore manage it. -*/ - -static void ali_fifo_control (struct ata_port *ap,struct ata_device *adev,int on) -{ -struct pci_dev *pdev =to_pci_dev (ap->host->dev); -int pio_fifo =0x54 + ap->port_no; -u8 fifo; -int shift =4 * adev->devno; - -/* ATA - FIFO on set nibble to 0x05, ATAPI - FIFO off, set nibble to -0x00. Not all the docs agree but the behaviour we now use is the -one stated in the BIOS Programming Guide */ - -pci_read_config_byte (pdev, pio_fifo, &fifo); - fifo &= ~(0x0F << shift); - fifo |= (on << shift); -pci_write_config_byte (pdev, pio_fifo, fifo); -} - -/** -* ali_program_modes - load mode registers -* @ap: ALi channel to load -* @adev: Device the timing is for -* @t: timing data -* @ultra: UDMA timing or zero for off -* -* Loads the timing registers for cmd/data and disable UDMA if -* ultra is zero. If ultra is set then load and enable the UDMA -* timing but do not touch the command/data timing. -*/ - -static void ali_program_modes (struct ata_port *ap,struct ata_device *adev,struct ata_timing *t,u8 ultra) -{ -struct pci_dev *pdev =to_pci_dev (ap->host->dev); -int cas =0x58 +4 * ap->port_no;/* Command timing */ -int cbt =0x59 +4 * ap->port_no;/* Command timing */ -int drwt =0x5A +4 * ap->port_no + adev->devno;/* R/W timing */ -int udmat =0x56 + ap->port_no;/* UDMA timing */ -int shift =4 * adev->devno; -u8 udma; - -if (t !=NULL ) { - t->setup =clamp_val (t->setup,1 ,8 ) &7 ; - t->act8b =clamp_val (t->act8b,1 ,8 ) &7 ; - t->rec8b =clamp_val (t->rec8b,1 ,16 ) &15 ; - t->active =clamp_val (t->active,1 ,8 ) &7 ; - t->recover =clamp_val (t->recover,1 ,16 ) &15 ; - -pci_write_config_byte (pdev, cas, t->setup); -pci_write_config_byte (pdev, cbt, (t->act8b <<4 ) | t->rec8b); -pci_write_config_byte (pdev, drwt, (t->active <<4 ) | t->recover); - } - -/* Set up the UDMA enable */ -pci_read_config_byte (pdev, udmat, &udma); - udma &= ~(0x0F << shift); - udma |= ultra << shift; -pci_write_config_byte (pdev, udmat, udma); -} - -/** -* ali_set_piomode - set initial PIO mode data -* @ap: ATA interface -* @adev: ATA device -* -* Program the ALi registers for PIO mode. -*/ - -static void ali_set_piomode (struct ata_port *ap,struct ata_device *adev) -{ -struct ata_device *pair =ata_dev_pair (adev); -struct ata_timing t; -unsigned long T =1000000000 /33333 ;/* PCI clock based */ - -ata_timing_compute (adev->id, adev->pio_mode, adev->pio_mode, &t,T ,1 ); -if (pair) { -struct ata_timing p; - -ata_timing_compute (pair->id, pair->pio_mode, pair->pio_mode, - &p,T ,1 ); -ata_timing_merge (&p, &t, &t,ATA_TIMING_SETUP |ATA_TIMING_8BIT ); -if (pair->dma_mode) { -ata_timing_compute (pair->id, pair->dma_mode, - pair->pio_mode, &p,T ,1 ); -ata_timing_merge (&p, &t, &t,ATA_TIMING_SETUP |ATA_TIMING_8BIT ); - } - } - -/* PIO FIFO is only permitted on ATA disk */ -ali_fifo_control (ap, adev, (adev->class ==ATA_DEV_ATA ) ?0x05 :0x00 ); - -ali_program_modes (ap, adev, &t,0 ); -} - -/** -* ali_set_dmamode - set initial DMA mode data -* @ap: ATA interface -* @adev: ATA device -* -* Program the ALi registers for DMA mode. -*/ - -static void ali_set_dmamode (struct ata_port *ap,struct ata_device *adev) -{ -static u8 udma_timing[7 ] = {0xC ,0xB ,0xA ,0x9 ,0x8 ,0xF ,0xD }; -struct ata_device *pair =ata_dev_pair (adev); -struct ata_timing t; -unsigned long T =1000000000 /33333 ;/* PCI clock based */ -struct pci_dev *pdev =to_pci_dev (ap->host->dev); - - -if (adev->class ==ATA_DEV_ATA ) -ali_fifo_control (ap, adev,0x08 ); - -if (adev->dma_mode >=XFER_UDMA_0 ) { -ali_program_modes (ap, adev,NULL , udma_timing[adev->dma_mode -XFER_UDMA_0 ]); -if (adev->dma_mode >=XFER_UDMA_3 ) { -u8 reg4b; -pci_read_config_byte (pdev,0x4B , ®4b); - reg4b |=1 ; -pci_write_config_byte (pdev,0x4B , reg4b); - } - }else { -ata_timing_compute (adev->id, adev->dma_mode, adev->pio_mode, - &t,T ,1 ); -if (pair) { -struct ata_timing p; - -ata_timing_compute (pair->id, pair->pio_mode, - pair->pio_mode, &p,T ,1 ); -ata_timing_merge (&p, &t, &t,ATA_TIMING_SETUP |ATA_TIMING_8BIT ); -if (pair->dma_mode) { -ata_timing_compute (pair->id, pair->dma_mode, - pair->pio_mode, &p,T ,1 ); -ata_timing_merge (&p, &t, &t,ATA_TIMING_SETUP |ATA_TIMING_8BIT ); - } - } -ali_program_modes (ap, adev, &t,0 ); - } -} - -/** * ali_warn_atapi_dma - Warn about ATAPI DMA disablement * @adev: Device *
@@ -388,69 +211,6 @@ static struct ata_port_operations ali_c5 .cable_detect = ali_c2_cable_detect, }; - -/** -* ali_init_chipset - chip setup function -* @dev: device of ATA controller -* -* Perform the setup on the device that must be done both at boot -* and at resume time. -*/ - -static int ali_init_chipset (struct device *dev) -{ -struct pci_dev *pdev =to_pci_dev (dev); -u8 tmp; -struct pci_dev *north; - -/* -* The chipset revision selects the driver operations and -* mode data. -*/ - -if (pdev->revision <=0x20 ) { -pci_read_config_byte (pdev,0x53 , &tmp); - tmp |=0x03 ; -pci_write_config_byte (pdev,0x53 , tmp); - }else { -pci_read_config_byte (pdev,0x4a , &tmp); -pci_write_config_byte (pdev,0x4a , tmp |0x20 ); -pci_read_config_byte (pdev,0x4B , &tmp); -if (pdev->revision <0xC2 ) -/* 1543-E/F, 1543C-C, 1543C-D, 1543C-E */ -/* Clear CD-ROM DMA write bit */ - tmp &=0x7F ; -/* Cable and UDMA */ -if (pdev->revision >=0xc2 ) - tmp |=0x01 ; -pci_write_config_byte (pdev,0x4B , tmp |0x08 ); -/* -* CD_ROM DMA on (0x53 bit 0). Enable this even if we want -* to use PIO. 0x53 bit 1 (rev 20 only) - enable FIFO control -* via 0x54/55. -*/ -pci_read_config_byte (pdev,0x53 , &tmp); -if (pdev->revision >=0xc7 ) - tmp |=0x03 ; -else - tmp |=0x01 ;/* CD_ROM enable for DMA */ -pci_write_config_byte (pdev,0x53 , tmp); - } - north =pci_get_bus_and_slot (0 ,PCI_DEVFN (0 ,0 )); -if (north && north->vendor ==PCI_VENDOR_ID_AL && ali_isa_bridge) { -/* Configure the ALi bridge logic. For non ALi rely on BIOS. -Set the south bridge enable bit */ -pci_read_config_byte (ali_isa_bridge,0x79 , &tmp); -if (pdev->revision ==0xC2 ) -pci_write_config_byte (ali_isa_bridge,0x79 , tmp |0x04 ); -else if (pdev->revision >0xC2 && pdev->revision <0xC5 ) -pci_write_config_byte (ali_isa_bridge,0x79 , tmp |0x02 ); - } -pci_dev_put (north); -ata_pci_bmdma_clear_simplex (pdev); -return 0 ; -} -/** * ali_init_one - discovery callback * @pdev: PCI device ID
drivers/ata/pata_ali.h +241 -0
244 lines not on this page · raw message
PATCH 32/68 alim15x3: convert to ide2libata
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] alim15x3: convert to ide2libata
--- drivers/ata/pata_ali.h | 55 +++++++++- drivers/ide/alim15x3.c | 260 ++----------------------------------------------- 2 files changed, 61 insertions(+), 254 deletions(-)
drivers/ata/pata_ali.h +50 -5
@@ -39,7 +39,6 @@ static int ali_cable_override(struct pcireturn 0 ; } -#ifdef __LINUX_LIBATA_H__/** * ali_c2_cable_detect - cable detection * @ap: ATA port
@@ -148,7 +147,12 @@ static void ali_set_piomode(struct ata_p {struct ata_device *pair =ata_dev_pair (adev);struct ata_timing t; +#ifndef __IDE2LIBATAunsigned long T =1000000000 /33333 ;/* PCI clock based */ +#else +int bus_speed = ide_pci_clk ? ide_pci_clk :33 ; +unsigned long T =1000000 / bus_speed;/* PCI clock based */ +#endif ata_timing_compute (adev->id, adev->pio_mode, adev->pio_mode, &t,T ,1 );if (pair) {
@@ -183,12 +187,18 @@ static void ali_set_dmamode(struct ata_pstatic u8 udma_timing[7 ] = {0xC ,0xB ,0xA ,0x9 ,0x8 ,0xF ,0xD };struct ata_device *pair =ata_dev_pair (adev);struct ata_timing t; +#ifndef __IDE2LIBATAunsigned long T =1000000000 /33333 ;/* PCI clock based */ +#else +int bus_speed = ide_pci_clk ? ide_pci_clk :33 ; +unsigned long T =1000000 / bus_speed;/* PCI clock based */ +#endif struct pci_dev *pdev =to_pci_dev (ap->host->dev); - +#ifndef __IDE2LIBATAif (adev->class ==ATA_DEV_ATA )ali_fifo_control (ap, adev,0x08 ); +#endif if (adev->dma_mode >=XFER_UDMA_0 ) {ali_program_modes (ap, adev,NULL , udma_timing[adev->dma_mode -XFER_UDMA_0 ]);
@@ -230,39 +240,73 @@ static int ali_init_chipset(struct devicstruct pci_dev *pdev =to_pci_dev (dev);u8 tmp;struct pci_dev *north; - +#ifdef __IDE2LIBATA +struct pci_dev *ali_isa_bridge = isa_dev; +#endif /* * The chipset revision selects the driver operations and * mode data. */ if (pdev->revision <=0x20 ) { +#ifdef __IDE2LIBATA +pci_read_config_byte (pdev,0x4b , &tmp); +pci_write_config_byte (pdev,0x4b , tmp &0x7F ); +if (pdev->revision ==0x20 ) { +pci_read_config_byte (pdev,0x53 , &tmp); + tmp = (tmp & ~0x02 ) |0x01 ; +pci_write_config_byte (pdev,0x53 , tmp); +if (isa_dev) { +pci_read_config_byte (isa_dev,0x5e , &tmp); + chip_is_1543c_e = ((tmp &0x1e ) ==0x12 ) ?1 :0 ; + } + } +#else pci_read_config_byte (pdev,0x53 , &tmp); tmp |=0x03 ;pci_write_config_byte (pdev,0x53 , tmp); +#endif }else { +#ifndef __IDE2LIBATApci_read_config_byte (pdev,0x4a , &tmp);pci_write_config_byte (pdev,0x4a , tmp |0x20 ); +#endif pci_read_config_byte (pdev,0x4B , &tmp);if (pdev->revision <0xC2 )/* 1543-E/F, 1543C-C, 1543C-D, 1543C-E */ /* Clear CD-ROM DMA write bit */ tmp &=0x7F ;/* Cable and UDMA */ +#ifdef __IDE2LIBATA +if (pdev->revision >=0xc2 ) + tmp |=0x08 ; +#else if (pdev->revision >=0xc2 ) tmp |=0x01 ; -pci_write_config_byte (pdev,0x4B , tmp |0x08 ); + tmp |=0x08 ; +#endif +pci_write_config_byte (pdev,0x4B , tmp);/* * CD_ROM DMA on (0x53 bit 0). Enable this even if we want * to use PIO. 0x53 bit 1 (rev 20 only) - enable FIFO control * via 0x54/55. */ pci_read_config_byte (pdev,0x53 , &tmp); +#ifdef __IDE2LIBATA +if (pdev->revision ==0xc7 || pdev->revision ==0xc8 ) +#elseif (pdev->revision >=0xc7 ) +#endif tmp |=0x03 ;else tmp |=0x01 ;/* CD_ROM enable for DMA */ pci_write_config_byte (pdev,0x53 , tmp); +#ifdef __IDE2LIBATA +if (pdev->revision <0xC2 && isa_dev) { +pci_read_config_byte (isa_dev,0x5e , &tmp); + chip_is_1543c_e = ((tmp &0x1e ) ==0x12 ) ?1 :0 ; + } +#endif } north =pci_get_bus_and_slot (0 ,PCI_DEVFN (0 ,0 ));if (north && north->vendor ==PCI_VENDOR_ID_AL && ali_isa_bridge) {
@@ -275,7 +319,8 @@ static int ali_init_chipset(struct devicpci_write_config_byte (ali_isa_bridge,0x79 , tmp |0x02 ); }pci_dev_put (north); +#ifndef __IDE2LIBATAata_pci_bmdma_clear_simplex (pdev); +#endif return 0 ; } -#endif
drivers/ide/alim15x3.c +11 -249
307 lines not on this page · raw message
PATCH 33/68 pata_amd: move code to be re-used by ide2libata to pata_amd.h
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] pata_amd: move code to be re-used by ide2libata to pata_amd.h
--- drivers/ata/pata_amd.c | 87 ---------------------------------------------- drivers/ata/pata_amd.h | 92 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+), 86 deletions(-)
drivers/ata/pata_amd.c +1 -86
@@ -26,92 +26,7 @@#define DRV_NAME "pata_amd"#define DRV_VERSION "0.4.1" -/** -* timing_setup - shared timing computation and load -* @ap: ATA port being set up -* @adev: drive being configured -* @offset: port offset -* @speed: target speed -* @clock: clock multiplier (number of times 33MHz for this part) -* -* Perform the actual timing set up for Nvidia or AMD PATA devices. -* The actual devices vary so they all call into this helper function -* providing the clock multipler and offset (because AMD and Nvidia put -* the ports at different locations). -*/ - -static void timing_setup (struct ata_port *ap,struct ata_device *adev,int offset,int speed,int clock) -{ -static const unsigned char amd_cyc2udma[] = { -6 ,6 ,5 ,4 ,0 ,1 ,1 ,2 ,2 ,3 ,3 ,3 ,3 ,3 ,3 ,7 - }; - -struct pci_dev *pdev =to_pci_dev (ap->host->dev); -struct ata_device *peer =ata_dev_pair (adev); -int dn = ap->port_no *2 + adev->devno; -struct ata_timing at, apeer; -int T ,UT ; -const int amd_clock =33333 ;/* KHz. */ -u8 t; - -T =1000000000 / amd_clock; -UT =T ; -if (clock >=2 ) -UT =T /2 ; - -ata_timing_compute (adev->id, speed, adev->pio_mode, &at,T ,UT ); - -if (peer) { -ata_timing_compute (peer->id, peer->pio_mode, - peer->pio_mode, &apeer,T ,UT ); -ata_timing_merge (&apeer, &at, &at,ATA_TIMING_8BIT ); - } - -if (speed ==XFER_UDMA_5 && amd_clock <=33333 ) at.udma =1 ; -if (speed ==XFER_UDMA_6 && amd_clock <=33333 ) at.udma =15 ; - -/* -* Now do the setup work -*/ - -/* Configure the address set up timing */ -pci_read_config_byte (pdev, offset +0x0C , &t); - t = (t & ~(3 << ((3 - dn) <<1 ))) | ((clamp_val (at.setup,1 ,4 ) -1 ) << ((3 - dn) <<1 )); -pci_write_config_byte (pdev, offset +0x0C , t); - -/* Configure the 8bit I/O timing */ -pci_write_config_byte (pdev, offset +0x0E + (1 - (dn >>1 )), - ((clamp_val (at.act8b,1 ,16 ) -1 ) <<4 ) | (clamp_val (at.rec8b,1 ,16 ) -1 )); - -/* Drive timing */ -pci_write_config_byte (pdev, offset +0x08 + (3 - dn), - ((clamp_val (at.active,1 ,16 ) -1 ) <<4 ) | (clamp_val (at.recover,1 ,16 ) -1 )); - -switch (clock) { -case 1 : - t = at.udma ? (0xc0 | (clamp_val (at.udma,2 ,5 ) -2 )) :0x03 ; -break ; - -case 2 : - t = at.udma ? (0xc0 | amd_cyc2udma[clamp_val (at.udma,2 ,10 )]) :0x03 ; -break ; - -case 3 : - t = at.udma ? (0xc0 | amd_cyc2udma[clamp_val (at.udma,1 ,10 )]) :0x03 ; -break ; - -case 4 : - t = at.udma ? (0xc0 | amd_cyc2udma[clamp_val (at.udma,1 ,15 )]) :0x03 ; -break ; - -default : -return ; - } - -/* UDMA timing */ -if (at.udma) -pci_write_config_byte (pdev, offset +0x10 + (3 - dn), t); -} +#include "pata_amd.h" /** * amd_pre_reset - perform reset handling
drivers/ata/pata_amd.h new file +92 -0
92 lines not on this page · raw message
PATCH 34/68 amd74xx: convert to ide2libata
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] amd74xx: convert to ide2libata
--- drivers/ata/pata_amd.h | 2 + drivers/ide/amd74xx.c | 85 +++++++++++++------------------------------------ 2 files changed, 25 insertions(+), 62 deletions(-)
drivers/ata/pata_amd.h +2 -0
@@ -25,7 +25,9 @@ static void timing_setup(struct ata_portint dn = ap->port_no *2 + adev->devno;struct ata_timing at, apeer;int T ,UT ; +#ifndef __IDE2LIBATAconst int amd_clock =33333 ;/* KHz. */ +#endif u8 t;T =1000000000 / amd_clock;
drivers/ide/amd74xx.c +23 -62
122 lines not on this page · raw message
PATCH 35/68 pata_artop: move code to be re-used by ide2libata to pata_artop.h
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] pata_artop: move code to be re-used by ide2libata to pata_artop.h
--- drivers/ata/pata_artop.c | 232 ----------------------------------------------- drivers/ata/pata_artop.h | 230 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 231 insertions(+), 231 deletions(-)
drivers/ata/pata_artop.c +1 -231
@@ -56,205 +56,7 @@ static int atp8xx_prereset(struct ata_lireturn ata_sff_prereset (link, deadline); } -/** -* atp86x_cable_detect - identify cable type -* @ap: Port -* -* Identify the cable type for the ARTOP interface in question -*/ - -static int atp86x_cable_detect (struct ata_port *ap) -{ -struct pci_dev *pdev =to_pci_dev (ap->host->dev); -u8 tmp; -pci_read_config_byte (pdev,0x49 , &tmp); -if (tmp & (1 << ap->port_no)) -return ATA_CBL_PATA40 ; -return ATA_CBL_PATA80 ; -} - -/** -* atp850_load_piomode - Load a set of PATA PIO timings -* @ap: Port whose timings we are configuring -* @adev: Device -* @pio: PIO mode -* -* Set PIO mode for device, in host controller PCI config space. This -* is used both to set PIO timings in PIO mode and also to set the -* matching PIO clocking for UDMA, as well as the MWDMA timings. -* -* LOCKING: -* None (inherited from caller). -*/ - -static void atp850_load_piomode (struct ata_port *ap,struct ata_device *adev, -unsigned int pio) -{ -struct pci_dev *pdev =to_pci_dev (ap->host->dev); -int dn = adev->devno +2 * ap->port_no; -const u16 timing[5 ] = - {0x0000 ,0x000A ,0x0008 ,0x0303 ,0x0301 }; - -/* Load the PIO timing active/recovery bits */ -pci_write_config_word (pdev,0x40 +2 * dn, timing[pio]); -} - -/** -* atp850_set_piomode - Initialize host controller PATA PIO timings -* @ap: Port whose timings we are configuring -* @adev: Device we are configuring -* -* Set PIO mode for device, in host controller PCI config space. For -* ARTOP we must also clear the UDMA bits if we are not doing UDMA. In -* the event UDMA is used the later call to set_dmamode will set the -* bits as required. -* -* LOCKING: -* None (inherited from caller). -*/ - -static void atp850_set_piomode (struct ata_port *ap,struct ata_device *adev) -{ -struct pci_dev *pdev =to_pci_dev (ap->host->dev); -int dn = adev->devno +2 * ap->port_no; -u8 ultra; - -atp850_load_piomode (ap, adev, adev->pio_mode -XFER_PIO_0 ); - -/* Clear the UDMA mode bits (set_dmamode will redo this if needed) */ -pci_read_config_byte (pdev,0x54 , &ultra); - ultra &= ~(3 << (2 * dn)); -pci_write_config_byte (pdev,0x54 , ultra); -} - -/** -* atp86x_load_piomode - Initialize host controller PATA PIO timings -* @ap: Port whose timings we are configuring -* @adev: Device we are configuring -* @pio: PIO mode -* -* Set PIO mode for device, in host controller PCI config space. -* The ATP860 and relatives store the timing data differently. -* -* LOCKING: -* None (inherited from caller). -*/ - -static void atp86x_load_piomode (struct ata_port *ap,struct ata_device *adev, -unsigned int pio) -{ -struct pci_dev *pdev =to_pci_dev (ap->host->dev); -int dn = adev->devno +2 * ap->port_no; -const u8 timing[5 ] = - {0x00 ,0x0A ,0x08 ,0x33 ,0x31 }; - -/* Load the PIO timing active/recovery bits */ -pci_write_config_byte (pdev,0x40 + dn, timing[pio]); -} - -/** -* atp86x_set_piomode - Initialize host controller PATA PIO timings -* @ap: Port whose timings we are configuring -* @adev: Device we are configuring -* -* Set PIO mode for device, in host controller PCI config space. For -* ARTOP we must also clear the UDMA bits if we are not doing UDMA. In -* the event UDMA is used the later call to set_dmamode will set the -* bits as required. -* -* LOCKING: -* None (inherited from caller). -*/ - -static void atp86x_set_piomode (struct ata_port *ap,struct ata_device *adev) -{ -struct pci_dev *pdev =to_pci_dev (ap->host->dev); -u8 ultra; - -atp86x_load_piomode (ap, adev, adev->pio_mode -XFER_PIO_0 ); - -/* Clear the UDMA mode bits (set_dmamode will redo this if needed) */ -pci_read_config_byte (pdev,0x44 + ap->port_no, &ultra); - ultra &= ~(7 << (4 * adev->devno));/* One nibble per drive */ -pci_write_config_byte (pdev,0x44 + ap->port_no, ultra); -} - -/** -* atp850_set_dmamode - Initialize host controller PATA PIO timings -* @ap: Port whose timings we are configuring -* @adev: Device whose timings we are configuring -* -* Set DMA mode for device, in host controller PCI config space. -* -* LOCKING: -* None (inherited from caller). -*/ - -static void atp850_set_dmamode (struct ata_port *ap,struct ata_device *adev) -{ -unsigned int pio; -struct pci_dev *pdev =to_pci_dev (ap->host->dev); -int dn = adev->devno +2 * ap->port_no; -u8 ultra; - -if (adev->dma_mode ==XFER_MW_DMA_0 ) - pio =1 ; -else - pio =4 ; - -/* Load the PIO timing active/recovery bits */ -atp850_load_piomode (ap, adev, pio); - -pci_read_config_byte (pdev,0x54 , &ultra); - ultra &= ~(3 << (2 * dn)); - -/* Add ultra DMA bits if in UDMA mode */ -if (adev->dma_mode >=XFER_UDMA_0 ) { -u8 mode = (adev->dma_mode -XFER_UDMA_0 ) +1 ; -if (mode ==0 ) - mode =1 ; - ultra |= (mode << (2 * dn)); - } -pci_write_config_byte (pdev,0x54 , ultra); -} - -/** -* atp86x_set_dmamode - Initialize host controller PATA PIO timings -* @ap: Port whose timings we are configuring -* @adev: Device we are configuring -* -* Set DMA mode for device, in host controller PCI config space. -* The ATP860 and relatives store the timing data differently. -* -* LOCKING: -* None (inherited from caller). -*/ - -static void atp86x_set_dmamode (struct ata_port *ap,struct ata_device *adev) -{ -unsigned int pio = adev->pio_mode -XFER_PIO_0 ; -struct pci_dev *pdev =to_pci_dev (ap->host->dev); -u8 ultra; - -if (adev->dma_mode ==XFER_MW_DMA_0 ) - pio =1 ; -else - pio =4 ; - -/* Load the PIO timing active/recovery bits */ -atp86x_load_piomode (ap, adev, pio); - -/* Add ultra DMA bits if in UDMA mode */ -pci_read_config_byte (pdev,0x44 + ap->port_no, &ultra); - ultra &= ~(7 << (4 * adev->devno));/* One nibble per drive */ -if (adev->dma_mode >=XFER_UDMA_0 ) { -u8 mode = adev->dma_mode -XFER_UDMA_0 +1 ; -if (mode ==0 ) - mode =1 ; - ultra |= (mode << (4 * adev->devno)); - } -pci_write_config_byte (pdev,0x44 + ap->port_no, ultra); -} +#include "pata_artop.h" /** * atp850_qc_defer - implement serialization
@@ -302,38 +104,6 @@ static struct ata_port_operations atp86x .prereset = atp8xx_prereset, }; -static int atp8xx_fixup (struct device *dev) -{ -struct pci_dev *pdev =to_pci_dev (dev); - -if (pdev->device ==0x0005 ) -/* BIOS may have left us in UDMA, clear it before probe */ -pci_write_config_byte (pdev,0x54 ,0 ); -else if (pdev->device ==0x0008 || pdev->device ==0x0009 ) { -u8 reg; - -/* Mac systems come up with some registers not set as we -will need them */ - -/* Clear reset & test bits */ -pci_read_config_byte (pdev,0x49 , ®); -pci_write_config_byte (pdev,0x49 , reg & ~0x30 ); - -/* PCI latency must be > 0x80 for burst mode, tweak it -* if required. -*/ -pci_read_config_byte (pdev,PCI_LATENCY_TIMER , ®); -if (reg <=0x80 ) -pci_write_config_byte (pdev,PCI_LATENCY_TIMER ,0x90 ); - -/* Enable IRQ output and burst mode */ -pci_read_config_byte (pdev,0x4a , ®); -pci_write_config_byte (pdev,0x4a , (reg & ~0x01 ) |0x80 ); - } - -return 0 ; -} -/** * artop_init_one - Register ARTOP ATA PCI device with kernel services * @pdev: PCI device to register
drivers/ata/pata_artop.h new file +230 -0
230 lines not on this page · raw message
PATCH 36/68 aec62xx: convert to ide2libata
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] aec62xx: convert to ide2libata
--- drivers/ata/pata_artop.h | 97 +++++++++++++++++++++----- drivers/ide/aec62xx.c | 172 ++--------------------------------------------- 2 files changed, 90 insertions(+), 179 deletions(-)
drivers/ata/pata_artop.h +80 -17
@@ -16,11 +16,15 @@ static int atp86x_cable_detect(struct atreturn ATA_CBL_PATA80 ; } +/* The ARTOP has 33 Mhz and "over clocked" timing tables. */ +static int clock; +/** * atp850_load_piomode - Load a set of PATA PIO timings * @ap: Port whose timings we are configuring * @adev: Device * @pio: PIO mode +* @set_mwdma: set MWDMA mode flag * * Set PIO mode for device, in host controller PCI config space. This * is used both to set PIO timings in PIO mode and also to set the
@@ -31,14 +35,21 @@ static int atp86x_cable_detect(struct at*/ static void atp850_load_piomode (struct ata_port *ap,struct ata_device *adev, -unsigned int pio) +unsigned int pio,bool set_mwdma) {struct pci_dev *pdev =to_pci_dev (ap->host->dev);int dn = adev->devno +2 * ap->port_no; -const u16 timing[5 ] = {0x0000 ,0x000A ,0x0008 ,0x0303 ,0x0301 }; +const u16 timing[2 ][5 ] = { + {0x0000 ,0x000A ,0x0008 ,0x0303 ,0x0301 }, + {0x0700 ,0x070A ,0x0708 ,0x0403 ,0x0401 } + }; +u16 t = timing[clock][pio]; + +if (clock && set_mwdma && adev->dma_mode ==XFER_MW_DMA_1 ) + t =0x0402 ;/* Load the PIO timing active/recovery bits */ -pci_write_config_word (pdev,0x40 +2 * dn, timing[pio]); +pci_write_config_word (pdev,0x40 +2 * dn, t); }/**
@@ -58,15 +69,25 @@ static void atp850_load_piomode(struct astatic void atp850_set_piomode (struct ata_port *ap,struct ata_device *adev) {struct pci_dev *pdev =to_pci_dev (ap->host->dev); +#ifdef __IDE2LIBATA +unsigned long flags; +#endif int dn = adev->devno +2 * ap->port_no;u8 ultra; -atp850_load_piomode (ap, adev, adev->pio_mode -XFER_PIO_0 ); +#ifdef __IDE2LIBATA +local_irq_save (flags); +#endif +atp850_load_piomode (ap, adev, adev->pio_mode -XFER_PIO_0 ,0 );/* Clear the UDMA mode bits (set_dmamode will redo this if needed) */ pci_read_config_byte (pdev,0x54 , &ultra); ultra &= ~(3 << (2 * dn));pci_write_config_byte (pdev,0x54 , ultra); + +#ifdef __IDE2LIBATA +local_irq_restore (flags); +#endif }/**
@@ -74,6 +95,7 @@ static void atp850_set_piomode(struct at* @ap: Port whose timings we are configuring * @adev: Device we are configuring * @pio: PIO mode +* @set_mwdma: set MWDMA mode flag * * Set PIO mode for device, in host controller PCI config space. * The ATP860 and relatives store the timing data differently.
@@ -83,14 +105,22 @@ static void atp850_set_piomode(struct at*/ static void atp86x_load_piomode (struct ata_port *ap,struct ata_device *adev, -unsigned int pio) +unsigned int pio,bool set_mwdma) {struct pci_dev *pdev =to_pci_dev (ap->host->dev);int dn = adev->devno +2 * ap->port_no; -const u8 timing[5 ] = {0x00 ,0x0A ,0x08 ,0x33 ,0x31 }; +const u8 timing[2 ][5 ] = { + {0x00 ,0x0A ,0x08 ,0x33 ,0x31 }, + {0x70 ,0x7A ,0x78 ,0x43 ,0x41 } + + }; +u16 t = timing[clock][pio]; + +if (clock && set_mwdma && adev->dma_mode ==XFER_MW_DMA_1 ) + t =0x42 ;/* Load the PIO timing active/recovery bits */ -pci_write_config_byte (pdev,0x40 + dn, timing[pio]); +pci_write_config_byte (pdev,0x40 + dn, t); }/**
@@ -110,14 +140,24 @@ static void atp86x_load_piomode(struct astatic void atp86x_set_piomode (struct ata_port *ap,struct ata_device *adev) {struct pci_dev *pdev =to_pci_dev (ap->host->dev); +#ifdef __IDE2LIBATA +unsigned long flags; +#endif u8 ultra; -atp86x_load_piomode (ap, adev, adev->pio_mode -XFER_PIO_0 ); +#ifdef __IDE2LIBATA +local_irq_save (flags); +#endif +atp86x_load_piomode (ap, adev, adev->pio_mode -XFER_PIO_0 ,0 );/* Clear the UDMA mode bits (set_dmamode will redo this if needed) */ pci_read_config_byte (pdev,0x44 + ap->port_no, &ultra); ultra &= ~(7 << (4 * adev->devno));/* One nibble per drive */ pci_write_config_byte (pdev,0x44 + ap->port_no, ultra); + +#ifdef __IDE2LIBATA +local_irq_restore (flags); +#endif }/**
@@ -133,8 +173,11 @@ static void atp86x_set_piomode(struct atstatic void atp850_set_dmamode (struct ata_port *ap,struct ata_device *adev) { -unsigned int pio;struct pci_dev *pdev =to_pci_dev (ap->host->dev); +#ifdef __IDE2LIBATA +unsigned long flags; +#endif +unsigned int pio;int dn = adev->devno +2 * ap->port_no;u8 ultra;
@@ -143,20 +186,27 @@ static void atp850_set_dmamode(struct atelse pio =4 ; +#ifdef __IDE2LIBATA +local_irq_save (flags); +#endif /* Load the PIO timing active/recovery bits */ -atp850_load_piomode (ap, adev, pio); +atp850_load_piomode (ap, adev, pio,1 );pci_read_config_byte (pdev,0x54 , &ultra); ultra &= ~(3 << (2 * dn));/* Add ultra DMA bits if in UDMA mode */ if (adev->dma_mode >=XFER_UDMA_0 ) { -u8 mode = (adev->dma_mode -XFER_UDMA_0 ) +1 ; +u8 mode = (adev->dma_mode -XFER_UDMA_0 ) +1 - clock;if (mode ==0 ) mode =1 ; ultra |= (mode << (2 * dn)); }pci_write_config_byte (pdev,0x54 , ultra); + +#ifdef __IDE2LIBATA +local_irq_restore (flags); +#endif }/**
@@ -173,8 +223,11 @@ static void atp850_set_dmamode(struct atstatic void atp86x_set_dmamode (struct ata_port *ap,struct ata_device *adev) { -unsigned int pio = adev->pio_mode -XFER_PIO_0 ;struct pci_dev *pdev =to_pci_dev (ap->host->dev); +#ifdef __IDE2LIBATA +unsigned long flags; +#endif +unsigned int pio;u8 ultra;if (adev->dma_mode ==XFER_MW_DMA_0 )
@@ -182,29 +235,38 @@ static void atp86x_set_dmamode(struct atelse pio =4 ; +#ifdef __IDE2LIBATA +local_irq_save (flags); +#endif /* Load the PIO timing active/recovery bits */ -atp86x_load_piomode (ap, adev, pio); +atp86x_load_piomode (ap, adev, pio,1 );/* Add ultra DMA bits if in UDMA mode */ pci_read_config_byte (pdev,0x44 + ap->port_no, &ultra); ultra &= ~(7 << (4 * adev->devno));/* One nibble per drive */ if (adev->dma_mode >=XFER_UDMA_0 ) { -u8 mode = adev->dma_mode -XFER_UDMA_0 +1 ; +u8 mode = adev->dma_mode -XFER_UDMA_0 +1 - clock;if (mode ==0 ) mode =1 ; ultra |= (mode << (4 * adev->devno)); }pci_write_config_byte (pdev,0x44 + ap->port_no, ultra); + +#ifdef __IDE2LIBATA +local_irq_restore (flags); +#endif }static int atp8xx_fixup (struct device *dev) {struct pci_dev *pdev =to_pci_dev (dev); -if (pdev->device ==0x0005 ) +if (pdev->device ==0x0005 ) {/* BIOS may have left us in UDMA, clear it before probe */ +#ifndef __IDE2LIBATApci_write_config_byte (pdev,0x54 ,0 ); -else if (pdev->device ==0x0008 || pdev->device ==0x0009 ) { +#endif + }else if (pdev->device ==0x0008 || pdev->device ==0x0009 ) {u8 reg;/* Mac systems come up with some registers not set as we
@@ -217,10 +279,11 @@ static int atp8xx_fixup(struct device *d/* PCI latency must be > 0x80 for burst mode, tweak it * if required. */ +#ifndef __IDE2LIBATApci_read_config_byte (pdev,PCI_LATENCY_TIMER , ®);if (reg <=0x80 )pci_write_config_byte (pdev,PCI_LATENCY_TIMER ,0x90 ); - +#endif /* Enable IRQ output and burst mode */ pci_read_config_byte (pdev,0x4a , ®);pci_write_config_byte (pdev,0x4a , (reg & ~0x01 ) |0x80 );
drivers/ide/aec62xx.c +10 -162
203 lines not on this page · raw message
PATCH 37/68 pata_atiixp: move code to be re-used by ide2libata to pata_atiixp.h
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] pata_atiixp: move code to be re-used by ide2libata to pata_atiixp.h
--- drivers/ata/pata_atiixp.c | 114 --------------------------------------------- drivers/ata/pata_atiixp.h | 116 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 117 insertions(+), 113 deletions(-)
drivers/ata/pata_atiixp.c +1 -113
@@ -24,28 +24,6 @@#define DRV_NAME "pata_atiixp"#define DRV_VERSION "0.4.6" -enum { -ATIIXP_IDE_PIO_TIMING =0x40 , -ATIIXP_IDE_MWDMA_TIMING =0x44 , -ATIIXP_IDE_PIO_CONTROL =0x48 , -ATIIXP_IDE_PIO_MODE =0x4a , -ATIIXP_IDE_UDMA_CONTROL =0x54 , -ATIIXP_IDE_UDMA_MODE =0x56 -}; - -static int atiixp_cable_detect (struct ata_port *ap) -{ -struct pci_dev *pdev =to_pci_dev (ap->host->dev); -u8 udma; - -/* Hack from drivers/ide/pci. Really we want to know how to do the -raw detection not play follow the bios mode guess */ -pci_read_config_byte (pdev,ATIIXP_IDE_UDMA_MODE + ap->port_no, &udma); -if ((udma &0x07 ) >=0x04 || (udma &0x70 ) >=0x40 ) -return ATA_CBL_PATA80 ; -return ATA_CBL_PATA40 ; -} -/** * atiixp_prereset - perform reset handling * @link: ATA link
@@ -71,97 +49,7 @@ static int atiixp_prereset(struct ata_lireturn ata_sff_prereset (link, deadline); } -static DEFINE_SPINLOCK (atiixp_lock); - -/** -* atiixp_set_piomode - set PIO mode data -* @ap: ATA interface -* @adev: ATA device -* -* Called to set the controller timings for PIO transfers. We must -* load both the mode number and timing values into the controller. -*/ - -static void atiixp_set_piomode (struct ata_port *ap,struct ata_device *adev) -{ -static u8 pio_timings[5 ] = {0x5D ,0x47 ,0x34 ,0x22 ,0x20 }; - -struct pci_dev *pdev =to_pci_dev (ap->host->dev); -unsigned long flags; -int dn =2 * ap->port_no + adev->devno; -int timing_shift = (16 * ap->port_no) +8 * (adev->devno ^1 ); -int pio = adev->pio_mode -XFER_PIO_0 ; -u32 pio_timing_data; -u16 pio_mode_data; - -spin_lock_irqsave (&atiixp_lock, flags); - -pci_read_config_word (pdev,ATIIXP_IDE_PIO_MODE , &pio_mode_data); - pio_mode_data &= ~(0x7 << (4 * dn)); - pio_mode_data |= pio << (4 * dn); -pci_write_config_word (pdev,ATIIXP_IDE_PIO_MODE , pio_mode_data); - -pci_read_config_dword (pdev,ATIIXP_IDE_PIO_TIMING , &pio_timing_data); - pio_timing_data &= ~(0xFF << timing_shift); - pio_timing_data |= (pio_timings[pio] << timing_shift); -pci_write_config_dword (pdev,ATIIXP_IDE_PIO_TIMING , pio_timing_data); - -spin_unlock_irqrestore (&atiixp_lock, flags); -} - -/** -* atiixp_set_dmamode - set DMA mode data -* @ap: ATA interface -* @adev: ATA device -* -* Called to do the DMA mode setup. -*/ - -static void atiixp_set_dmamode (struct ata_port *ap,struct ata_device *adev) -{ -static u8 mwdma_timings[5 ] = {0x77 ,0x21 ,0x20 }; - -struct pci_dev *pdev =to_pci_dev (ap->host->dev); -unsigned long flags; -int dma = adev->dma_mode; -int dn =2 * ap->port_no + adev->devno; -u16 tmp16; - -spin_lock_irqsave (&atiixp_lock, flags); - -pci_read_config_word (pdev,ATIIXP_IDE_UDMA_CONTROL , &tmp16); - -if (adev->dma_mode >=XFER_UDMA_0 ) { -u16 udma_mode_data; - - dma -=XFER_UDMA_0 ; - -pci_read_config_word (pdev,ATIIXP_IDE_UDMA_MODE , &udma_mode_data); - udma_mode_data &= ~(0x7 << (4 * dn)); - udma_mode_data |= dma << (4 * dn); -pci_write_config_word (pdev,ATIIXP_IDE_UDMA_MODE , udma_mode_data); - - tmp16 |= (1 << dn); - }else { -int timing_shift = (16 * ap->port_no) +8 * (adev->devno ^1 ); -u32 mwdma_timing_data; - - dma -=XFER_MW_DMA_0 ; - -pci_read_config_dword (pdev,ATIIXP_IDE_MWDMA_TIMING , - &mwdma_timing_data); - mwdma_timing_data &= ~(0xFF << timing_shift); - mwdma_timing_data |= (mwdma_timings[dma] << timing_shift); -pci_write_config_dword (pdev,ATIIXP_IDE_MWDMA_TIMING , - mwdma_timing_data); - - tmp16 &= ~(1 << dn); - } - -pci_write_config_word (pdev,ATIIXP_IDE_UDMA_CONTROL , tmp16); - -spin_unlock_irqrestore (&atiixp_lock, flags); -} +#include "pata_atiixp.h" static struct scsi_host_template atiixp_sht = {ATA_BMDMA_SHT (DRV_NAME ),
drivers/ata/pata_atiixp.h new file +116 -0
116 lines not on this page · raw message
PATCH 38/68 atiixp: convert to ide2libata
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] atiixp: convert to ide2libata
--- drivers/ide/atiixp.c | 126 +-------------------------------------------------- 1 file changed, 4 insertions(+), 122 deletions(-)
drivers/ide/atiixp.c +4 -122
@@ -12,130 +12,12 @@#define DRV_NAME "atiixp" -#define ATIIXP_IDE_PIO_TIMING 0x40 -#define ATIIXP_IDE_MDMA_TIMING 0x44 -#define ATIIXP_IDE_PIO_CONTROL 0x48 -#define ATIIXP_IDE_PIO_MODE 0x4a -#define ATIIXP_IDE_UDMA_CONTROL 0x54 -#define ATIIXP_IDE_UDMA_MODE 0x56 - -typedef struct { -u8 command_width; -u8 recover_width; -}atiixp_ide_timing ; - -static atiixp_ide_timing pio_timing[] = { - {0x05 ,0x0d }, - {0x04 ,0x07 }, - {0x03 ,0x04 }, - {0x02 ,0x02 }, - {0x02 ,0x00 }, -}; - -static atiixp_ide_timing mdma_timing[] = { - {0x07 ,0x07 }, - {0x02 ,0x01 }, - {0x02 ,0x00 }, -}; - -static DEFINE_SPINLOCK (atiixp_lock); - -/** -* atiixp_set_pio_mode - set host controller for PIO mode -* @hwif: port -* @drive: drive -* -* Set the interface PIO mode. -*/ - -static void atiixp_set_pio_mode (ide_hwif_t *hwif,ide_drive_t *drive) -{ -struct pci_dev *dev =to_pci_dev (hwif->dev); -unsigned long flags; -int timing_shift = (drive->dn ^1 ) *8 ; -u32 pio_timing_data; -u16 pio_mode_data; -const u8 pio = drive->pio_mode -XFER_PIO_0 ; - -spin_lock_irqsave (&atiixp_lock, flags); - -pci_read_config_word (dev,ATIIXP_IDE_PIO_MODE , &pio_mode_data); - pio_mode_data &= ~(0x07 << (drive->dn *4 )); - pio_mode_data |= (pio << (drive->dn *4 )); -pci_write_config_word (dev,ATIIXP_IDE_PIO_MODE , pio_mode_data); - -pci_read_config_dword (dev,ATIIXP_IDE_PIO_TIMING , &pio_timing_data); - pio_timing_data &= ~(0xff << timing_shift); - pio_timing_data |= (pio_timing[pio].recover_width << timing_shift) | - (pio_timing[pio].command_width << (timing_shift +4 )); -pci_write_config_dword (dev,ATIIXP_IDE_PIO_TIMING , pio_timing_data); - -spin_unlock_irqrestore (&atiixp_lock, flags); -} - -/** -* atiixp_set_dma_mode - set host controller for DMA mode -* @hwif: port -* @drive: drive -* -* Set a ATIIXP host controller to the desired DMA mode. This involves -* programming the right timing data into the PCI configuration space. -*/ - -static void atiixp_set_dma_mode (ide_hwif_t *hwif,ide_drive_t *drive) -{ -struct pci_dev *dev =to_pci_dev (hwif->dev); -unsigned long flags; -int timing_shift = (drive->dn ^1 ) *8 ; -u32 tmp32; -u16 tmp16; -u16 udma_ctl =0 ; -const u8 speed = drive->dma_mode; - -spin_lock_irqsave (&atiixp_lock, flags); - -pci_read_config_word (dev,ATIIXP_IDE_UDMA_CONTROL , &udma_ctl); - -if (speed >=XFER_UDMA_0 ) { -pci_read_config_word (dev,ATIIXP_IDE_UDMA_MODE , &tmp16); - tmp16 &= ~(0x07 << (drive->dn *4 )); - tmp16 |= ((speed &0x07 ) << (drive->dn *4 )); -pci_write_config_word (dev,ATIIXP_IDE_UDMA_MODE , tmp16); - - udma_ctl |= (1 << drive->dn); - }else if (speed >=XFER_MW_DMA_0 ) { -u8 i = speed &0x03 ; - -pci_read_config_dword (dev,ATIIXP_IDE_MDMA_TIMING , &tmp32); - tmp32 &= ~(0xff << timing_shift); - tmp32 |= (mdma_timing[i].recover_width << timing_shift) | - (mdma_timing[i].command_width << (timing_shift +4 )); -pci_write_config_dword (dev,ATIIXP_IDE_MDMA_TIMING , tmp32); - - udma_ctl &= ~(1 << drive->dn); - } - -pci_write_config_word (dev,ATIIXP_IDE_UDMA_CONTROL , udma_ctl); - -spin_unlock_irqrestore (&atiixp_lock, flags); -} - -static int atiixp_cable_detect (ide_hwif_t *hwif) -{ -struct pci_dev *pdev =to_pci_dev (hwif->dev); -u8 udma_mode =0 , ch = hwif->channel; - -pci_read_config_byte (pdev,ATIIXP_IDE_UDMA_MODE + ch, &udma_mode); - -if ((udma_mode &0x07 ) >=0x04 || (udma_mode &0x70 ) >=0x40 ) -return ATA_CBL_PATA80 ; -else -return ATA_CBL_PATA40 ; -} +#include <linux/ide2libata.h> +#include <../ata/pata_atiixp.h> static const struct ide_port_ops atiixp_port_ops = { - .set_pio_mode = atiixp_set_pio_mode, - .set_dma_mode = atiixp_set_dma_mode, + .set_pio_mode = atiixp_set_piomode, + .set_dma_mode = atiixp_set_dmamode, .cable_detect = atiixp_cable_detect, };
PATCH 39/68 pata_cmd64x: documentation fix
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] pata_cmd64x: documentation fix
--- drivers/ata/pata_cmd64x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ata/pata_cmd64x.c +1 -1
@@ -113,7 +113,7 @@ out: }/** -* cmd64x_set_piomode - set PIO and MWDMA timing +* cmd64x_set_timing - set PIO and MWDMA timing * @ap: ATA interface * @adev: ATA device * @mode: mode
PATCH 40/68 pata_cmd64x: move code to be re-used by ide2libata to pata_cmd64x.h
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] pata_cmd64x: move code to be re-used by ide2libata to pata_cmd64x.h
--- drivers/ata/pata_cmd64x.c | 215 ---------------------------------------------- drivers/ata/pata_cmd64x.h | 215 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 216 insertions(+), 214 deletions(-)
drivers/ata/pata_cmd64x.c +1 -214
@@ -34,49 +34,7 @@#define DRV_NAME "pata_cmd64x"#define DRV_VERSION "0.2.5" -/* -* CMD64x specific registers definition. -*/ - -enum { -CFR =0x50 , -CFR_INTR_CH0 =0x04 , -CMDTIM =0x52 , -ARTTIM0 =0x53 , -DRWTIM0 =0x54 , -ARTTIM1 =0x55 , -DRWTIM1 =0x56 , -ARTTIM23 =0x57 , -ARTTIM23_DIS_RA2 =0x04 , -ARTTIM23_DIS_RA3 =0x08 , -ARTTIM23_INTR_CH1 =0x10 , -DRWTIM2 =0x58 , -BRST =0x59 , -DRWTIM3 =0x5b , -BMIDECR0 =0x70 , -MRDMODE =0x71 , -MRDMODE_INTR_CH0 =0x04 , -MRDMODE_INTR_CH1 =0x08 , -BMIDESR0 =0x72 , -UDIDETCR0 =0x73 , -DTPR0 =0x74 , -BMIDECR1 =0x78 , -BMIDECSR =0x79 , -UDIDETCR1 =0x7B , -DTPR1 =0x7C -}; - -static int cmd648_cable_detect (struct ata_port *ap) -{ -struct pci_dev *pdev =to_pci_dev (ap->host->dev); -u8 r; - -/* Check cable detect bits */ -pci_read_config_byte (pdev,BMIDECSR , &r); -if (r & (1 << ap->port_no)) -return ATA_CBL_PATA80 ; -return ATA_CBL_PATA40 ; -} +#include "pata_cmd64x.h" /** * cmd64x_prereset - perform reset handling
@@ -113,158 +71,6 @@ out: }/** -* cmd64x_set_timing - set PIO and MWDMA timing -* @ap: ATA interface -* @adev: ATA device -* @mode: mode -* -* Called to do the PIO and MWDMA mode setup. -*/ - -static void cmd64x_set_timing (struct ata_port *ap,struct ata_device *adev,u8 mode) -{ -struct pci_dev *pdev =to_pci_dev (ap->host->dev); -struct ata_timing t; -const unsigned long T =1000000 /33 ; -const u8 setup_data[] = {0x40 ,0x40 ,0x40 ,0x80 ,0x00 }; - -u8 reg; - -/* Port layout is not logical so use a table */ -const u8 arttim_port[2 ][2 ] = { - {ARTTIM0 ,ARTTIM1 }, - {ARTTIM23 ,ARTTIM23 } - }; -const u8 drwtim_port[2 ][2 ] = { - {DRWTIM0 ,DRWTIM1 }, - {DRWTIM2 ,DRWTIM3 } - }; - -int arttim = arttim_port[ap->port_no][adev->devno]; -int drwtim = drwtim_port[ap->port_no][adev->devno]; - -/* ata_timing_compute is smart and will produce timings for MWDMA -that don't violate the drives PIO capabilities. */ -ata_timing_compute (adev->id, mode, adev->pio_mode, &t,T ,0 ); - -if (ap->port_no) { -/* Slave has shared address setup */ -struct ata_device *pair =ata_dev_pair (adev); - -if (pair) { -struct ata_timing tp; - -ata_timing_compute (pair->id, pair->pio_mode, - pair->pio_mode, &tp,T ,0 ); -ata_timing_merge (&t, &tp, &t,ATA_TIMING_SETUP ); -if (pair->dma_mode) { -ata_timing_compute (pair->id, pair->dma_mode, - pair->pio_mode, &tp,T ,0 ); -ata_timing_merge (&tp, &t, &t,ATA_TIMING_SETUP ); - } - } - } - - printk(KERN_DEBUG DRV_NAME ": active %d recovery %d setup %d.\n", - t.active, t.recover, t.setup); -if (t.recover >16 ) { - t.active += t.recover -16 ; - t.recover =16 ; - } -if (t.active >16 ) - t.active =16 ; - -/* Now convert the clocks into values we can actually stuff into -the chip */ - -if (t.recover ==16 ) - t.recover =0 ; -else if (t.recover >1 ) - t.recover--; -else - t.recover =15 ; - -if (t.setup >4 ) - t.setup =0xC0 ; -else - t.setup = setup_data[t.setup]; - - t.active &=0x0F ;/* 0 = 16 */ - -/* Load setup timing */ -pci_read_config_byte (pdev, arttim, ®); - reg &=0x3F ; - reg |= t.setup; -pci_write_config_byte (pdev, arttim, reg); - -/* Load active/recovery */ -pci_write_config_byte (pdev, drwtim, (t.active <<4 ) | t.recover); -} - -/** -* cmd64x_set_piomode - set initial PIO mode data -* @ap: ATA interface -* @adev: ATA device -* -* Used when configuring the devices ot set the PIO timings. All the -* actual work is done by the PIO/MWDMA setting helper -*/ - -static void cmd64x_set_piomode (struct ata_port *ap,struct ata_device *adev) -{ -cmd64x_set_timing (ap, adev, adev->pio_mode); -} - -/** -* cmd64x_set_dmamode - set initial DMA mode data -* @ap: ATA interface -* @adev: ATA device -* -* Called to do the DMA mode setup. -*/ - -static void cmd64x_set_dmamode (struct ata_port *ap,struct ata_device *adev) -{ -static const u8 udma_data[] = { -0x30 ,0x20 ,0x10 ,0x20 ,0x10 ,0x00 - }; - -struct pci_dev *pdev =to_pci_dev (ap->host->dev); -u8 regU, regD; - -int pciU =UDIDETCR0 +8 * ap->port_no; -int pciD =BMIDESR0 +8 * ap->port_no; -int shift =2 * adev->devno; - -pci_read_config_byte (pdev, pciD, ®D); -pci_read_config_byte (pdev, pciU, ®U); - -/* DMA bits off */ - regD &= ~(0x20 << adev->devno); -/* DMA control bits */ - regU &= ~(0x30 << shift); -/* DMA timing bits */ - regU &= ~(0x05 << adev->devno); - -if (adev->dma_mode >=XFER_UDMA_0 ) { -/* Merge the timing value */ - regU |= udma_data[adev->dma_mode -XFER_UDMA_0 ] << shift; -/* Merge the control bits */ - regU |=1 << adev->devno;/* UDMA on */ -if (adev->dma_mode >XFER_UDMA_2 )/* 15nS timing */ - regU |=4 << adev->devno; - }else { - regU &= ~ (1 << adev->devno);/* UDMA off */ -cmd64x_set_timing (ap, adev, adev->dma_mode); - } - - regD |=0x20 << adev->devno; - -pci_write_config_byte (pdev, pciU, regU); -pci_write_config_byte (pdev, pciD, regD); -} - -/** * cmd648_dma_stop - DMA stop callback * @qc: Command in progress *
@@ -325,25 +131,6 @@ static struct ata_port_operations cmd648 .cable_detect = cmd648_cable_detect, }; -static int cmd64x_fixup (struct device *dev) -{ -struct pci_dev *pdev =to_pci_dev (dev); -u8 mrdmode; - -pci_write_config_byte (pdev,PCI_LATENCY_TIMER ,64 ); -pci_read_config_byte (pdev,MRDMODE , &mrdmode); - mrdmode &= ~0x30 ;/* IRQ set up */ - mrdmode |=0x02 ;/* Memory read line enable */ -pci_write_config_byte (pdev,MRDMODE , mrdmode); - -/* PPC specific fixup copied from old driver */ -#ifdef CONFIG_PPC -pci_write_config_byte (pdev,UDIDETCR0 ,0xF0 ); -#endif - -return 0 ; -} -static int cmd64x_init_one (struct pci_dev *pdev,const struct pci_device_id *id) {static const struct ata_port_info cmd_info[6 ] = {
drivers/ata/pata_cmd64x.h new file +215 -0
215 lines not on this page · raw message
PATCH 41/68 pata_cmd64x: convert to ide2libata
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] pata_cmd64x: convert to ide2libata
--- drivers/ata/pata_cmd64x.h | 35 +++++++- drivers/ide/cmd64x.c | 195 +--------------------------------------------- 2 files changed, 41 insertions(+), 189 deletions(-)
drivers/ata/pata_cmd64x.h +33 -2
@@ -56,7 +56,12 @@ static void cmd64x_set_timing(struct ata {struct pci_dev *pdev =to_pci_dev (ap->host->dev);struct ata_timing t; +#ifndef __IDE2LIBATAconst unsigned long T =1000000 /33 ; +#else +int bus_speed = ide_pci_clk ? ide_pci_clk :33 ; +const unsigned long T =1000000 / bus_speed; +#endif const u8 setup_data[] = {0x40 ,0x40 ,0x40 ,0x80 ,0x00 };u8 reg;
@@ -124,6 +129,11 @@ static void cmd64x_set_timing(struct ata/* Load setup timing */ pci_read_config_byte (pdev, arttim, ®); +#ifdef __IDE2LIBATA +/* Avoid clearing the secondary channel's interrupt bit. */ +if (ap->port_no) + reg &= ~ARTTIM23_INTR_CH1 ; +#endif reg &=0x3F ; reg |= t.setup;pci_write_config_byte (pdev, arttim, reg);
@@ -143,6 +153,13 @@ static void cmd64x_set_timing(struct atastatic void cmd64x_set_piomode (struct ata_port *ap,struct ata_device *adev) { +#ifdef __IDE2LIBATA +const u8 pio = adev->pio_mode -XFER_PIO_0 ; + +/* Filter out the prefetch control values. */ +if (pio ==8 || pio ==9 ) +return ; +#endif cmd64x_set_timing (ap, adev, adev->pio_mode); }
@@ -161,13 +178,17 @@ static void cmd64x_set_dmamode(struct at };struct pci_dev *pdev =to_pci_dev (ap->host->dev); -u8 regU, regD; +u8 regU, regD =0 ;int pciU =UDIDETCR0 +8 * ap->port_no; +#ifndef __IDE2LIBATAint pciD =BMIDESR0 +8 * ap->port_no; +#endif int shift =2 * adev->devno; +#ifndef __IDE2LIBATApci_read_config_byte (pdev, pciD, ®D); +#endif pci_read_config_byte (pdev, pciU, ®U);/* DMA bits off */
@@ -192,7 +213,9 @@ static void cmd64x_set_dmamode(struct at regD |=0x20 << adev->devno;pci_write_config_byte (pdev, pciU, regU); +#ifndef __IDE2LIBATApci_write_config_byte (pdev, pciD, regD); +#endif }static int cmd64x_fixup (struct device *dev)
@@ -201,15 +224,23 @@ static int cmd64x_fixup(struct device *du8 mrdmode;pci_write_config_byte (pdev,PCI_LATENCY_TIMER ,64 ); +/* FIXME: pci_set_master() to ensure a good latency timer value */ + +/* +* NOTE: although not mentioned in the PCI0646U specs, +* bits 0-1 are write only and won't be read back as +* set or not -- PCI0646U2 specs clarify this point. +*/ pci_read_config_byte (pdev,MRDMODE , &mrdmode); mrdmode &= ~0x30 ;/* IRQ set up */ mrdmode |=0x02 ;/* Memory read line enable */ pci_write_config_byte (pdev,MRDMODE , mrdmode); +#ifndef __IDE2LIBATA/* PPC specific fixup copied from old driver */ #ifdef CONFIG_PPC pci_write_config_byte (pdev,UDIDETCR0 ,0xF0 );#endif - +#endif return 0 ; }
drivers/ide/cmd64x.c +8 -187
228 lines not on this page · raw message
PATCH 42/68 pata_cs5520: move code to be re-used by ide2libata to pata_cs5520.h
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] pata_cs5520: move code to be re-used by ide2libata to pata_cs5520.h
--- drivers/ata/pata_cs5520.c | 60 ---------------------------------------------- drivers/ata/pata_cs5520.h | 60 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 59 deletions(-)
drivers/ata/pata_cs5520.c +1 -59
@@ -43,65 +43,7 @@#define DRV_NAME "pata_cs5520"#define DRV_VERSION "0.6.6" -struct pio_clocks -{ -int address; -int assert; -int recovery; -}; - -static const struct pio_clocks cs5520_pio_clocks[]={ - {3 ,6 ,11 }, - {2 ,5 ,6 }, - {1 ,4 ,3 }, - {1 ,3 ,2 }, - {1 ,2 ,1 } -}; - -/** -* cs5520_set_timings - program PIO timings -* @ap: ATA port -* @adev: ATA device -* -* Program the PIO mode timings for the controller according to the pio -* clocking table. -*/ - -static void cs5520_set_timings (struct ata_port *ap,struct ata_device *adev,int pio) -{ -struct pci_dev *pdev =to_pci_dev (ap->host->dev); -int slave = adev->devno; - - pio -=XFER_PIO_0 ; - -/* Channel command timing */ -pci_write_config_byte (pdev,0x62 + ap->port_no, - (cs5520_pio_clocks[pio].recovery <<4 ) | - (cs5520_pio_clocks[pio].assert)); -/* FIXME: should these use address ? */ -/* Read command timing */ -pci_write_config_byte (pdev,0x64 +4 *ap->port_no + slave, - (cs5520_pio_clocks[pio].recovery <<4 ) | - (cs5520_pio_clocks[pio].assert)); -/* Write command timing */ -pci_write_config_byte (pdev,0x66 +4 *ap->port_no + slave, - (cs5520_pio_clocks[pio].recovery <<4 ) | - (cs5520_pio_clocks[pio].assert)); -} - -/** -* cs5520_set_piomode - program PIO timings -* @ap: ATA port -* @adev: ATA device -* -* Program the PIO mode timings for the controller according to the pio -* clocking table. -*/ - -static void cs5520_set_piomode (struct ata_port *ap,struct ata_device *adev) -{ -cs5520_set_timings (ap, adev, adev->pio_mode); -} +#include "pata_cs5520.h" static struct scsi_host_template cs5520_sht = {ATA_BMDMA_SHT (DRV_NAME ),
drivers/ata/pata_cs5520.h new file +60 -0
60 lines not on this page · raw message
PATCH 43/68 cs5520: convert to ide2libata
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] cs5520: convert to ide2libata
--- drivers/ide/cs5520.c | 44 ++++---------------------------------------- 1 file changed, 4 insertions(+), 40 deletions(-)
drivers/ide/cs5520.c +4 -40
@@ -42,55 +42,19 @@#define DRV_NAME "cs5520" -struct pio_clocks -{ -int address; -int assert; -int recovery; -}; - -static struct pio_clocks cs5520_pio_clocks[]={ - {3 ,6 ,11 }, - {2 ,5 ,6 }, - {1 ,4 ,3 }, - {1 ,3 ,2 }, - {1 ,2 ,1 } -}; - -static void cs5520_set_pio_mode (ide_hwif_t *hwif,ide_drive_t *drive) -{ -struct pci_dev *pdev =to_pci_dev (hwif->dev); -int controller = drive->dn >1 ?1 :0 ; -const u8 pio = drive->pio_mode -XFER_PIO_0 ; - -/* 8bit CAT/CRT - 8bit command timing for channel */ -pci_write_config_byte (pdev,0x62 + controller, - (cs5520_pio_clocks[pio].recovery <<4 ) | - (cs5520_pio_clocks[pio].assert)); - -/* 0x64 - 16bit Primary, 0x68 - 16bit Secondary */ - -/* FIXME: should these use address ? */ -/* Data read timing */ -pci_write_config_byte (pdev,0x64 +4 *controller + (drive->dn&1 ), - (cs5520_pio_clocks[pio].recovery <<4 ) | - (cs5520_pio_clocks[pio].assert)); -/* Write command timing */ -pci_write_config_byte (pdev,0x66 +4 *controller + (drive->dn&1 ), - (cs5520_pio_clocks[pio].recovery <<4 ) | - (cs5520_pio_clocks[pio].assert)); -} +#include <linux/ide2libata.h> +#include "../ata/pata_cs5520.h" static void cs5520_set_dma_mode (ide_hwif_t *hwif,ide_drive_t *drive) {printk (KERN_ERR "cs55x0: bad ide timing.\n" ); drive->pio_mode =XFER_PIO_0 +0 ; -cs5520_set_pio_mode (hwif, drive); +cs5520_set_piomode (hwif, drive); }static const struct ide_port_ops cs5520_port_ops = { - .set_pio_mode = cs5520_set_pio_mode, + .set_pio_mode = cs5520_set_piomode, .set_dma_mode = cs5520_set_dma_mode, };
PATCH 44/68 pata_cs5530: move code to be re-used by ide2libata to pata_cs5530.h
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] pata_cs5530: move code to be re-used by ide2libata to pata_cs5530.h
--- drivers/ata/pata_cs5530.c | 178 -------------------------------------------- drivers/ata/pata_cs5530.h | 183 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 184 insertions(+), 177 deletions(-)
drivers/ata/pata_cs5530.c +1 -177
@@ -43,93 +43,7 @@ static void __iomem *cs5530_port_base(streturn (void __iomem *)((bmdma & ~0x0F ) +0x20 +0x10 * ap->port_no); } -/** -* cs5530_set_piomode - PIO setup -* @ap: ATA interface -* @adev: device on the interface -* -* Set our PIO requirements. This is fairly simple on the CS5530 -* chips. -*/ - -static void cs5530_set_piomode (struct ata_port *ap,struct ata_device *adev) -{ -static const unsigned int cs5530_pio_timings[2 ][5 ] = { - {0x00009172 ,0x00012171 ,0x00020080 ,0x00032010 ,0x00040010 }, - {0xd1329172 ,0x71212171 ,0x30200080 ,0x20102010 ,0x00100010 } - }; -void __iomem *base =cs5530_port_base (ap); -u32 tuning; -int format; - -/* Find out which table to use */ - tuning =ioread32 (base +0x04 ); - format = (tuning &0x80000000UL ) ?1 :0 ; - -/* Now load the right timing register */ -if (adev->devno) - base +=0x08 ; - -iowrite32 (cs5530_pio_timings[format][adev->pio_mode -XFER_PIO_0 ], base); -} - -/** -* cs5530_set_dmamode - DMA timing setup -* @ap: ATA interface -* @adev: Device being configured -* -* We cannot mix MWDMA and UDMA without reloading timings each switch -* master to slave. We track the last DMA setup in order to minimise -* reloads. -*/ - -static void cs5530_set_dmamode (struct ata_port *ap,struct ata_device *adev) -{ -void __iomem *base =cs5530_port_base (ap); -u32 tuning, timing =0 ; -u8 reg; - -/* Find out which table to use */ - tuning =ioread32 (base +0x04 ); - -switch (adev->dma_mode) { -case XFER_UDMA_0 : - timing =0x00921250 ;break ; -case XFER_UDMA_1 : - timing =0x00911140 ;break ; -case XFER_UDMA_2 : - timing =0x00911030 ;break ; -case XFER_MW_DMA_0 : - timing =0x00077771 ;break ; -case XFER_MW_DMA_1 : - timing =0x00012121 ;break ; -case XFER_MW_DMA_2 : - timing =0x00002020 ;break ; -default : -BUG (); - } -/* Merge in the PIO format bit */ - timing |= (tuning &0x80000000UL ); -if (adev->devno ==0 )/* Master */ -iowrite32 (timing, base +0x04 ); -else { -if (timing &0x00100000 ) - tuning |=0x00100000 ;/* UDMA for both */ -else - tuning &= ~0x00100000 ;/* MWDMA for both */ -iowrite32 (tuning, base +0x04 ); -iowrite32 (timing, base +0x0C ); - } - -/* Set the DMA capable bit in the BMDMA area */ - reg =ioread8 (ap->ioaddr.bmdma_addr +ATA_DMA_STATUS ); - reg |= (1 << (5 + adev->devno)); -iowrite8 (reg, ap->ioaddr.bmdma_addr +ATA_DMA_STATUS ); - -/* Remember the last DMA setup we did */ - - ap->private_data = adev; -} +#include "pata_cs5530.h" /** * cs5530_qc_issue - command issue
@@ -195,96 +109,6 @@ static int cs5530_is_palmax(void)return 0 ; } - -/** -* cs5530_init_chip - Chipset init -* @gendev: device -* -* Perform the chip initialisation work that is shared between both -* setup and resume paths -*/ - -static int cs5530_init_chip (struct device *gendev) -{ -struct pci_dev *master_0 =NULL , *cs5530_0 =NULL , *dev =NULL ; - -while ((dev =pci_get_device (PCI_VENDOR_ID_CYRIX ,PCI_ANY_ID , dev)) !=NULL ) { -switch (dev->device) { -case PCI_DEVICE_ID_CYRIX_PCI_MASTER : - master_0 =pci_dev_get (dev); -break ; -case PCI_DEVICE_ID_CYRIX_5530_LEGACY : - cs5530_0 =pci_dev_get (dev); -break ; - } - } -if (!master_0) { - printk(KERN_ERR DRV_NAME ": unable to locate PCI MASTER function\n"); - goto fail_put; - } -if (!cs5530_0) { - printk(KERN_ERR DRV_NAME ": unable to locate CS5530 LEGACY function\n"); - goto fail_put; - } - -pci_set_master (cs5530_0); -pci_try_set_mwi (cs5530_0); - -/* -* Set PCI CacheLineSize to 16-bytes: -* --> Write 0x04 into 8-bit PCI CACHELINESIZE reg of function 0 of the cs5530 -* -* Note: This value is constant because the 5530 is only a Geode companion -*/ - -pci_write_config_byte (cs5530_0,PCI_CACHE_LINE_SIZE ,0x04 ); - -/* -* Disable trapping of UDMA register accesses (Win98 hack): -* --> Write 0x5006 into 16-bit reg at offset 0xd0 of function 0 of the cs5530 -*/ - -pci_write_config_word (cs5530_0,0xd0 ,0x5006 ); - -/* -* Bit-1 at 0x40 enables MemoryWriteAndInvalidate on internal X-bus: -* The other settings are what is necessary to get the register -* into a sane state for IDE DMA operation. -*/ - -pci_write_config_byte (master_0,0x40 ,0x1e ); - -/* -* Set max PCI burst size (16-bytes seems to work best): -* 16bytes: set bit-1 at 0x41 (reg value of 0x16) -* all others: clear bit-1 at 0x41, and do: -* 128bytes: OR 0x00 at 0x41 -* 256bytes: OR 0x04 at 0x41 -* 512bytes: OR 0x08 at 0x41 -* 1024bytes: OR 0x0c at 0x41 -*/ - -pci_write_config_byte (master_0,0x41 ,0x14 ); - -/* -* These settings are necessary to get the chip -* into a sane state for IDE DMA operation. -*/ - -pci_write_config_byte (master_0,0x42 ,0x00 ); -pci_write_config_byte (master_0,0x43 ,0xc1 ); - -pci_dev_put (master_0); -pci_dev_put (cs5530_0); -return 0 ; -fail_put: -if (master_0) -pci_dev_put (master_0); -if (cs5530_0) -pci_dev_put (cs5530_0); -return -EIO ; -} -/** * cs5530_init_one - Initialise a CS5530 * @dev: PCI device
drivers/ata/pata_cs5530.h new file +183 -0
183 lines not on this page · raw message
PATCH 45/68 cs5530: convert to ide2libata
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] cs5530: convert to ide2libata
--- drivers/ata/pata_cs5530.h | 16 ++-- drivers/ide/cs5530.c | 149 ++++------------------------------------------ 2 files changed, 25 insertions(+), 140 deletions(-)
drivers/ata/pata_cs5530.h +9 -7
@@ -1,4 +1,9 @@ +static const unsigned int cs5530_pio_timings[2 ][5 ] = { + {0x00009172 ,0x00012171 ,0x00020080 ,0x00032010 ,0x00040010 }, + {0xd1329172 ,0x71212171 ,0x30200080 ,0x20102010 ,0x00100010 } +}; +/** * cs5530_set_piomode - PIO setup * @ap: ATA interface
@@ -10,10 +15,6 @@static void cs5530_set_piomode (struct ata_port *ap,struct ata_device *adev) { -static const unsigned int cs5530_pio_timings[2 ][5 ] = { - {0x00009172 ,0x00012171 ,0x00020080 ,0x00032010 ,0x00040010 }, - {0xd1329172 ,0x71212171 ,0x30200080 ,0x20102010 ,0x00100010 } - };void __iomem *base =cs5530_port_base (ap);u32 tuning;int format;
@@ -44,8 +45,9 @@ static void cs5530_set_dmamode(struct at {void __iomem *base =cs5530_port_base (ap);u32 tuning, timing =0 ; +#ifndef __IDE2LIBATAu8 reg; - +#endif /* Find out which table to use */ tuning =ioread32 (base +0x04 );
@@ -77,15 +79,15 @@ static void cs5530_set_dmamode(struct atiowrite32 (tuning, base +0x04 );iowrite32 (timing, base +0x0C ); } - +#ifndef __IDE2LIBATA/* Set the DMA capable bit in the BMDMA area */ reg =ioread8 (ap->ioaddr.bmdma_addr +ATA_DMA_STATUS ); reg |= (1 << (5 + adev->devno));iowrite8 (reg, ap->ioaddr.bmdma_addr +ATA_DMA_STATUS );/* Remember the last DMA setup we did */ - ap->private_data = adev; +#endif }
drivers/ide/cs5530.c +16 -133
183 lines not on this page · raw message
PATCH 46/68 pata_cs5535: move code to be re-used by ide2libata to pata_cs5535.h
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] pata_cs5535: move code to be re-used by ide2libata to pata_cs5535.h
--- drivers/ata/pata_cs5535.c | 113 --------------------------------------------- drivers/ata/pata_cs5535.h | 114 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 115 insertions(+), 112 deletions(-)
drivers/ata/pata_cs5535.c +1 -112
@@ -41,118 +41,7 @@#define DRV_NAME "cs5535"#define DRV_VERSION "0.2.12" -/* -* The Geode (Aka Athlon GX now) uses an internal MSR based -* bus system for control. Demented but there you go. -*/ - -#define MSR_ATAC_BASE 0x51300000 -#define ATAC_GLD_MSR_CAP (MSR_ATAC_BASE+0) -#define ATAC_GLD_MSR_CONFIG (MSR_ATAC_BASE+0x01) -#define ATAC_GLD_MSR_SMI (MSR_ATAC_BASE+0x02) -#define ATAC_GLD_MSR_ERROR (MSR_ATAC_BASE+0x03) -#define ATAC_GLD_MSR_PM (MSR_ATAC_BASE+0x04) -#define ATAC_GLD_MSR_DIAG (MSR_ATAC_BASE+0x05) -#define ATAC_IO_BAR (MSR_ATAC_BASE+0x08) -#define ATAC_RESET (MSR_ATAC_BASE+0x10) -#define ATAC_CH0D0_PIO (MSR_ATAC_BASE+0x20) -#define ATAC_CH0D0_DMA (MSR_ATAC_BASE+0x21) -#define ATAC_CH0D1_PIO (MSR_ATAC_BASE+0x22) -#define ATAC_CH0D1_DMA (MSR_ATAC_BASE+0x23) -#define ATAC_PCI_ABRTERR (MSR_ATAC_BASE+0x24) - -#define ATAC_BM0_CMD_PRIM 0x00 -#define ATAC_BM0_STS_PRIM 0x02 -#define ATAC_BM0_PRD 0x04 - -#define CS5535_CABLE_DETECT 0x48 - -/** -* cs5535_cable_detect - detect cable type -* @ap: Port to detect on -* -* Perform cable detection for ATA66 capable cable. Return a libata -* cable type. -*/ - -static int cs5535_cable_detect (struct ata_port *ap) -{ -u8 cable; -struct pci_dev *pdev =to_pci_dev (ap->host->dev); - -pci_read_config_byte (pdev,CS5535_CABLE_DETECT , &cable); -if (cable &1 ) -return ATA_CBL_PATA80 ; -else -return ATA_CBL_PATA40 ; -} - -/** -* cs5535_set_piomode - PIO setup -* @ap: ATA interface -* @adev: device on the interface -* -* Set our PIO requirements. The CS5535 is pretty clean about all this -*/ - -static void cs5535_set_piomode (struct ata_port *ap,struct ata_device *adev) -{ -static const u16 pio_timings[5 ] = { -0xF7F4 ,0xF173 ,0x8141 ,0x5131 ,0x1131 - }; -static const u16 pio_cmd_timings[5 ] = { -0xF7F4 ,0x53F3 ,0x13F1 ,0x5131 ,0x1131 - }; -u32 reg, dummy; -struct ata_device *pair =ata_dev_pair (adev); - -int mode = adev->pio_mode -XFER_PIO_0 ; -int cmdmode = mode; - -/* Command timing has to be for the lowest of the pair of devices */ -if (pair) { -int pairmode = pair->pio_mode -XFER_PIO_0 ; - cmdmode =min (mode, pairmode); -/* Write the other drive timing register if it changed */ -if (cmdmode < pairmode) -wrmsr (ATAC_CH0D0_PIO +2 * pair->devno, - pio_cmd_timings[cmdmode] <<16 | pio_timings[pairmode],0 ); - } -/* Write the drive timing register */ -wrmsr (ATAC_CH0D0_PIO +2 * adev->devno, - pio_cmd_timings[cmdmode] <<16 | pio_timings[mode],0 ); - -/* Set the PIO "format 1" bit in the DMA timing register */ -rdmsr (ATAC_CH0D0_DMA +2 * adev->devno, reg, dummy); -wrmsr (ATAC_CH0D0_DMA +2 * adev->devno, reg |0x80000000UL ,0 ); -} - -/** -* cs5535_set_dmamode - DMA timing setup -* @ap: ATA interface -* @adev: Device being configured -* -*/ - -static void cs5535_set_dmamode (struct ata_port *ap,struct ata_device *adev) -{ -static const u32 udma_timings[5 ] = { -0x7F7436A1 ,0x7F733481 ,0x7F723261 ,0x7F713161 ,0x7F703061 - }; -static const u32 mwdma_timings[3 ] = { -0x7F0FFFF3 ,0x7F035352 ,0x7F024241 - }; -u32 reg, dummy; -int mode = adev->dma_mode; - -rdmsr (ATAC_CH0D0_DMA +2 * adev->devno, reg, dummy); - reg &=0x80000000UL ; -if (mode >=XFER_UDMA_0 ) - reg |= udma_timings[mode -XFER_UDMA_0 ]; -else - reg |= mwdma_timings[mode -XFER_MW_DMA_0 ]; -wrmsr (ATAC_CH0D0_DMA +2 * adev->devno, reg,0 ); -} +#include "pata_cs5535.h" static struct scsi_host_template cs5535_sht = {ATA_BMDMA_SHT (DRV_NAME ),
drivers/ata/pata_cs5535.h new file +114 -0
114 lines not on this page · raw message
PATCH 47/68 cs5535: convert to ide2libata
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] cs5535: convert to ide2libata
--- drivers/ide/cs5535.c | 141 +-------------------------------------------------- 1 file changed, 4 insertions(+), 137 deletions(-)
drivers/ide/cs5535.c +4 -137
@@ -28,145 +28,12 @@#define DRV_NAME "cs5535" -#define MSR_ATAC_BASE 0x51300000 -#define ATAC_GLD_MSR_CAP (MSR_ATAC_BASE+0) -#define ATAC_GLD_MSR_CONFIG (MSR_ATAC_BASE+0x01) -#define ATAC_GLD_MSR_SMI (MSR_ATAC_BASE+0x02) -#define ATAC_GLD_MSR_ERROR (MSR_ATAC_BASE+0x03) -#define ATAC_GLD_MSR_PM (MSR_ATAC_BASE+0x04) -#define ATAC_GLD_MSR_DIAG (MSR_ATAC_BASE+0x05) -#define ATAC_IO_BAR (MSR_ATAC_BASE+0x08) -#define ATAC_RESET (MSR_ATAC_BASE+0x10) -#define ATAC_CH0D0_PIO (MSR_ATAC_BASE+0x20) -#define ATAC_CH0D0_DMA (MSR_ATAC_BASE+0x21) -#define ATAC_CH0D1_PIO (MSR_ATAC_BASE+0x22) -#define ATAC_CH0D1_DMA (MSR_ATAC_BASE+0x23) -#define ATAC_PCI_ABRTERR (MSR_ATAC_BASE+0x24) -#define ATAC_BM0_CMD_PRIM 0x00 -#define ATAC_BM0_STS_PRIM 0x02 -#define ATAC_BM0_PRD 0x04 -#define CS5535_CABLE_DETECT 0x48 - -/* Format I PIO settings. We separate out cmd and data for safer timings */ - -static unsigned int cs5535_pio_cmd_timings[5 ] = -{0xF7F4 ,0x53F3 ,0x13F1 ,0x5131 ,0x1131 }; -static unsigned int cs5535_pio_dta_timings[5 ] = -{0xF7F4 ,0xF173 ,0x8141 ,0x5131 ,0x1131 }; - -static unsigned int cs5535_mwdma_timings[3 ] = -{0x7F0FFFF3 ,0x7F035352 ,0x7f024241 }; - -static unsigned int cs5535_udma_timings[5 ] = -{0x7F7436A1 ,0x7F733481 ,0x7F723261 ,0x7F713161 ,0x7F703061 }; - -/* Macros to check if the register is the reset value - reset value is an -invalid timing and indicates the register has not been set previously */ - -#define CS5535_BAD_PIO (timings) ( (timings&~0x80000000UL) == 0x00009172 ) -#define CS5535_BAD_DMA (timings) ( (timings & 0x000FFFFF) == 0x00077771 ) - -/**** -* cs5535_set_speed - Configure the chipset to the new speed -* @drive: Drive to set up -* @speed: desired speed -* -* cs5535_set_speed() configures the chipset to a new speed. -*/ -static void cs5535_set_speed (ide_drive_t *drive,const u8 speed) -{ -u32 reg =0 , dummy; -u8 unit = drive->dn &1 ; - -/* Set the PIO timings */ -if (speed <XFER_SW_DMA_0 ) { -ide_drive_t *pair =ide_get_pair_dev (drive); -u8 cmd, pioa; - - cmd = pioa = speed -XFER_PIO_0 ; - -if (pair) { -u8 piob = pair->pio_mode -XFER_PIO_0 ; - -if (piob < cmd) - cmd = piob; - } - -/* Write the speed of the current drive */ - reg = (cs5535_pio_cmd_timings[cmd] <<16 ) | - cs5535_pio_dta_timings[pioa]; -wrmsr (unit ?ATAC_CH0D1_PIO :ATAC_CH0D0_PIO , reg,0 ); - -/* And if nessesary - change the speed of the other drive */ -rdmsr (unit ?ATAC_CH0D0_PIO :ATAC_CH0D1_PIO , reg, dummy); - -if (((reg >>16 ) & cs5535_pio_cmd_timings[cmd]) != - cs5535_pio_cmd_timings[cmd]) { - reg &=0x0000FFFF ; - reg |= cs5535_pio_cmd_timings[cmd] <<16 ; -wrmsr (unit ?ATAC_CH0D0_PIO :ATAC_CH0D1_PIO , reg,0 ); - } - -/* Set bit 31 of the DMA register for PIO format 1 timings */ -rdmsr (unit ?ATAC_CH0D1_DMA :ATAC_CH0D0_DMA , reg, dummy); -wrmsr (unit ?ATAC_CH0D1_DMA :ATAC_CH0D0_DMA , - reg |0x80000000UL ,0 ); - }else { -rdmsr (unit ?ATAC_CH0D1_DMA :ATAC_CH0D0_DMA , reg, dummy); - - reg &=0x80000000UL ;/* Preserve the PIO format bit */ - -if (speed >=XFER_UDMA_0 && speed <=XFER_UDMA_4 ) - reg |= cs5535_udma_timings[speed -XFER_UDMA_0 ]; -else if (speed >=XFER_MW_DMA_0 && speed <=XFER_MW_DMA_2 ) - reg |= cs5535_mwdma_timings[speed -XFER_MW_DMA_0 ]; -else -return ; - -wrmsr (unit ?ATAC_CH0D1_DMA :ATAC_CH0D0_DMA , reg,0 ); - } -} - -/** -* cs5535_set_dma_mode - set host controller for DMA mode -* @hwif: port -* @drive: drive -* -* Programs the chipset for DMA mode. -*/ - -static void cs5535_set_dma_mode (ide_hwif_t *hwif,ide_drive_t *drive) -{ -cs5535_set_speed (drive, drive->dma_mode); -} - -/** -* cs5535_set_pio_mode - set host controller for PIO mode -* @hwif: port -* @drive: drive -* -* A callback from the upper layers for PIO-only tuning. -*/ - -static void cs5535_set_pio_mode (ide_hwif_t *hwif,ide_drive_t *drive) -{ -cs5535_set_speed (drive, drive->pio_mode); -} - -static int cs5535_cable_detect (ide_hwif_t *hwif) -{ -struct pci_dev *dev =to_pci_dev (hwif->dev); -u8 bit; - -/* if a 80 wire cable was detected */ -pci_read_config_byte (dev,CS5535_CABLE_DETECT , &bit); - -return (bit &1 ) ?ATA_CBL_PATA80 :ATA_CBL_PATA40 ; -} +#include <linux/ide2libata.h> +#include "../ata/pata_cs5535.h" static const struct ide_port_ops cs5535_port_ops = { - .set_pio_mode = cs5535_set_pio_mode, - .set_dma_mode = cs5535_set_dma_mode, + .set_pio_mode = cs5535_set_piomode, + .set_dma_mode = cs5535_set_dmamode, .cable_detect = cs5535_cable_detect, };
PATCH 48/68 pata_cypress: move code to be re-used by ide2libata to pata_cypress.h
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] pata_cypress: move code to be re-used by ide2libata to pata_cypress.h
--- drivers/ata/pata_cypress.c | 88 --------------------------------------------- drivers/ata/pata_cypress.h | 88 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+), 87 deletions(-)
drivers/ata/pata_cypress.c +1 -87
@@ -20,93 +20,7 @@#define DRV_NAME "pata_cypress"#define DRV_VERSION "0.1.5" -/* here are the offset definitions for the registers */ - -enum { -CY82_IDE_CMDREG =0x04 , -CY82_IDE_ADDRSETUP =0x48 , -CY82_IDE_MASTER_IOR =0x4C , -CY82_IDE_MASTER_IOW =0x4D , -CY82_IDE_SLAVE_IOR =0x4E , -CY82_IDE_SLAVE_IOW =0x4F , -CY82_IDE_MASTER_8BIT =0x50 , -CY82_IDE_SLAVE_8BIT =0x51 , - -CY82_INDEX_PORT =0x22 , -CY82_DATA_PORT =0x23 , - -CY82_INDEX_CTRLREG1 =0x01 , -CY82_INDEX_CHANNEL0 =0x30 , -CY82_INDEX_CHANNEL1 =0x31 , -CY82_INDEX_TIMEOUT =0x32 -}; - -/** -* cy82c693_set_piomode - set initial PIO mode data -* @ap: ATA interface -* @adev: ATA device -* -* Called to do the PIO mode setup. -*/ - -static void cy82c693_set_piomode (struct ata_port *ap,struct ata_device *adev) -{ -struct pci_dev *pdev =to_pci_dev (ap->host->dev); -struct ata_timing t; -const unsigned long T =1000000 /33 ; -short time_16, time_8; -u32 addr; - -ata_timing_compute (adev->id, adev->pio_mode, adev->pio_mode, &t,T ,1 ); - - time_16 =clamp_val (t.recover -1 ,0 ,15 ) | - (clamp_val (t.active -1 ,0 ,15 ) <<4 ); - time_8 =clamp_val (t.act8b -1 ,0 ,15 ) | - (clamp_val (t.rec8b -1 ,0 ,15 ) <<4 ); - -if (adev->devno ==0 ) { -pci_read_config_dword (pdev,CY82_IDE_ADDRSETUP , &addr); - - addr &= ~0x0F ;/* Mask bits */ - addr |=clamp_val (t.setup -1 ,0 ,15 ); - -pci_write_config_dword (pdev,CY82_IDE_ADDRSETUP , addr); -pci_write_config_byte (pdev,CY82_IDE_MASTER_IOR , time_16); -pci_write_config_byte (pdev,CY82_IDE_MASTER_IOW , time_16); -pci_write_config_byte (pdev,CY82_IDE_MASTER_8BIT , time_8); - }else { -pci_read_config_dword (pdev,CY82_IDE_ADDRSETUP , &addr); - - addr &= ~0xF0 ;/* Mask bits */ - addr |= (clamp_val (t.setup -1 ,0 ,15 ) <<4 ); - -pci_write_config_dword (pdev,CY82_IDE_ADDRSETUP , addr); -pci_write_config_byte (pdev,CY82_IDE_SLAVE_IOR , time_16); -pci_write_config_byte (pdev,CY82_IDE_SLAVE_IOW , time_16); -pci_write_config_byte (pdev,CY82_IDE_SLAVE_8BIT , time_8); - } -} - -/** -* cy82c693_set_dmamode - set initial DMA mode data -* @ap: ATA interface -* @adev: ATA device -* -* Called to do the DMA mode setup. -*/ - -static void cy82c693_set_dmamode (struct ata_port *ap,struct ata_device *adev) -{ -int reg =CY82_INDEX_CHANNEL0 + ap->port_no; - -/* Be afraid, be very afraid. Magic registers in low I/O space */ -outb (reg,0x22 ); -outb (adev->dma_mode -XFER_MW_DMA_0 ,0x23 ); - -/* 0x50 gives the best behaviour on the Alpha's using this chip */ -outb (CY82_INDEX_TIMEOUT ,0x22 ); -outb (0x50 ,0x23 ); -} +#include "pata_cypress.h" static struct scsi_host_template cy82c693_sht = {ATA_BMDMA_SHT (DRV_NAME ),
drivers/ata/pata_cypress.h new file +88 -0
88 lines not on this page · raw message
PATCH 49/68 cy82c693: convert to ide2libata
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] cy82c693: convert to ide2libata
--- drivers/ata/pata_cypress.h | 30 ++++++++-- drivers/ide/cy82c693.c | 130 +-------------------------------------------- 2 files changed, 29 insertions(+), 131 deletions(-)
drivers/ata/pata_cypress.h +25 -5
@@ -30,12 +30,31 @@ enum {static void cy82c693_set_piomode (struct ata_port *ap,struct ata_device *adev) { +#ifndef __IDE2LIBATAstruct pci_dev *pdev =to_pci_dev (ap->host->dev); +int bus_speed =33 ; +#else +struct pci_dev *pdev = ap->port_no ?to_pci_dev (ap->host->dev2) + :to_pci_dev (ap->host->dev); +int bus_speed = ide_pci_clk ? ide_pci_clk :33 ; +#endif +const unsigned long T =1000000 / bus_speed;struct ata_timing t; -const unsigned long T =1000000 /33 ;short time_16, time_8;u32 addr; +#ifdef __IDE2LIBATA +/* select primary or secondary channel */ +if (ap->port_no >0 ) {/* drive is on the secondary channel */ + pdev =pci_get_slot (pdev->bus, pdev->devfn +1 ); +if (!pdev) { +printk (KERN_ERR "%s: tune_drive: " +"Cannot find secondary interface!\n" , + adev->name); +return ; + } + } +#endif ata_timing_compute (adev->id, adev->pio_mode, adev->pio_mode, &t,T ,1 ); time_16 = clamp_val(t.recover - 1, 0, 15) |
@@ -79,10 +98,11 @@ static void cy82c693_set_dmamode(structint reg =CY82_INDEX_CHANNEL0 + ap->port_no;/* Be afraid, be very afraid. Magic registers in low I/O space */ -outb (reg,0x22 ); -outb (adev->dma_mode -XFER_MW_DMA_0 ,0x23 ); +outb (reg,CY82_INDEX_PORT ); +outb ((adev->dma_mode -XFER_MW_DMA_0 ) | + ((adev->dma_mode &0x10 ) >>2 ),CY82_DATA_PORT );/* 0x50 gives the best behaviour on the Alpha's using this chip */ -outb (CY82_INDEX_TIMEOUT ,0x22 ); -outb (0x50 ,0x23 ); +outb (CY82_INDEX_TIMEOUT ,CY82_INDEX_PORT ); +outb (0x50 ,CY82_DATA_PORT ); }
drivers/ide/cy82c693.c +4 -126
142 lines not on this page · raw message
PATCH 50/68 pata_efar: move code to be re-used by ide2libata to pata_efar.h
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] pata_efar: move code to be re-used by ide2libata to pata_efar.h
--- drivers/ata/pata_efar.c | 151 ----------------------------------------------- drivers/ata/pata_efar.h | 152 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 153 insertions(+), 150 deletions(-)
drivers/ata/pata_efar.c +1 -150
@@ -49,156 +49,7 @@ static int efar_pre_reset(struct ata_linreturn ata_sff_prereset (link, deadline); } -/** -* efar_cable_detect - check for 40/80 pin -* @ap: Port -* -* Perform cable detection for the EFAR ATA interface. This is -* different to the PIIX arrangement -*/ - -static int efar_cable_detect (struct ata_port *ap) -{ -struct pci_dev *pdev =to_pci_dev (ap->host->dev); -u8 tmp; - -pci_read_config_byte (pdev,0x47 , &tmp); -if (tmp & (2 >> ap->port_no)) -return ATA_CBL_PATA40 ; -return ATA_CBL_PATA80 ; -} - -static DEFINE_SPINLOCK (efar_lock); - -static void efar_set_timings (struct ata_port *ap,struct ata_device *adev, -u8 pio,bool use_mwdma) -{ -struct pci_dev *dev =to_pci_dev (ap->host->dev); -unsigned long flags; -unsigned int is_slave = (adev->devno !=0 ); -u8 master_port = ap->port_no ?0x42 :0x40 ; -u16 master_data; -u8 slave_data; -u8 udma_enable; -int control =0 ; - -/* -* See Intel Document 298600-004 for the timing programing rules -* for PIIX/ICH. The EFAR is a clone so very similar -*/ - -static const /* ISP RTC */ -u8 timings[][2 ] = { {0 ,0 }, - {0 ,0 }, - {1 ,0 }, - {2 ,1 }, - {2 ,3 }, }; - -if (pio >1 || use_mwdma) - control |=1 ;/* TIME */ -if (ata_pio_need_iordy (adev) || use_mwdma) - control |=2 ;/* IE */ -/* Intel specifies that the prefetch/posting is for disk only */ -if (adev->class ==ATA_DEV_ATA ) - control |=4 ;/* PPE */ -/* If the drive MWDMA is faster than it can do PIO then -we must force PIO into PIO0 */ -if (use_mwdma && adev->pio_mode < (XFER_PIO_0 + pio)) -/* Enable DMA timing only */ - control |=8 ;/* PIO cycles in PIO0 */ - -spin_lock_irqsave (&efar_lock, flags); - -pci_read_config_word (dev, master_port, &master_data); - -/* Set PPE, IE, and TIME as appropriate */ -if (is_slave ==0 ) { - master_data &=0xCCF0 ; - master_data |= control; - master_data |= (timings[pio][0 ] <<12 ) | - (timings[pio][1 ] <<8 ); - }else { -int shift =4 * ap->port_no; - - master_data &=0xFF0F ; - master_data |= (control <<4 ); - -/* Slave timing in separate register */ -pci_read_config_byte (dev,0x44 , &slave_data); - slave_data &= ap->port_no ?0x0F :0xF0 ; - slave_data |= ((timings[pio][0 ] <<2 ) | timings[pio][1 ]) << shift; - } - - master_data |=0x4000 ;/* Ensure SITRE is set */ -pci_write_config_word (dev, master_port, master_data); -if (is_slave) -pci_write_config_byte (dev,0x44 , slave_data); - -pci_read_config_byte (dev,0x48 , &udma_enable); - udma_enable &= ~(1 << (2 * ap->port_no + adev->devno)); -pci_write_config_byte (dev,0x48 , udma_enable); - -spin_unlock_irqrestore (&efar_lock, flags); -} - -/** -* efar_set_piomode - Initialize host controller PATA PIO timings -* @ap: Port whose timings we are configuring -* @adev: Device to program -* -* Set PIO mode for device, in host controller PCI config space. -* -* LOCKING: -* None (inherited from caller). -*/ - -static void efar_set_piomode (struct ata_port *ap,struct ata_device *adev) -{ -efar_set_timings (ap, adev, adev->pio_mode -XFER_PIO_0 ,0 ); -} - -/** -* efar_set_dmamode - Initialize host controller PATA DMA timings -* @ap: Port whose timings we are configuring -* @adev: Device to program -* -* Set UDMA/MWDMA mode for device, in host controller PCI config space. -* -* LOCKING: -* None (inherited from caller). -*/ - -static void efar_set_dmamode (struct ata_port *ap,struct ata_device *adev) -{ -struct pci_dev *dev =to_pci_dev (ap->host->dev); -unsigned long flags; -u8 speed = adev->dma_mode; -int devid = adev->devno +2 * ap->port_no; -u8 udma_enable; - -if (speed >=XFER_UDMA_0 ) { -unsigned int udma = speed -XFER_UDMA_0 ; -u16 udma_timing; - -spin_lock_irqsave (&efar_lock, flags); - -pci_read_config_byte (dev,0x48 , &udma_enable); - - udma_enable |= (1 << devid); - -/* Load the UDMA mode number */ -pci_read_config_word (dev,0x4A , &udma_timing); - udma_timing &= ~(7 << (4 * devid)); - udma_timing |= udma << (4 * devid); -pci_write_config_word (dev,0x4A , udma_timing); - -pci_write_config_byte (dev,0x48 , udma_enable); - -spin_unlock_irqrestore (&efar_lock, flags); - }else -/* MWDMA is driven by the PIO timings. */ -efar_set_timings (ap, adev,ata_mwdma_to_pio (speed),1 ); -} +#include "pata_efar.h" static struct scsi_host_template efar_sht = {ATA_BMDMA_SHT (DRV_NAME ),
drivers/ata/pata_efar.h new file +152 -0
152 lines not on this page · raw message
PATCH 51/68 slc90e66: convert to ide2libata
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] slc90e66: convert to ide2libata
--- drivers/ata/pata_efar.h | 13 ++++- drivers/ide/slc90e66.c | 113 ++---------------------------------------------- 2 files changed, 16 insertions(+), 110 deletions(-)
drivers/ata/pata_efar.h +11 -2
@@ -146,7 +146,16 @@ static void efar_set_dmamode(struct ata_pci_write_config_byte (dev,0x48 , udma_enable);spin_unlock_irqrestore (&efar_lock, flags); - }else -/* MWDMA is driven by the PIO timings. */ + }else { +/* Normal DMA is driven by the PIO timings. */ +#ifdef __IDE2LIBATA +if (speed >=XFER_MW_DMA_0 ) + adev->pio_mode =ata_mwdma_to_pio (speed) +XFER_PIO_0 ; +else + adev->pio_mode =XFER_PIO_2 ;/* for SWDMA2 */ +efar_set_timings (ap, adev, adev->pio_mode -XFER_PIO_0 ,1 ); +#else efar_set_timings (ap, adev,ata_mwdma_to_pio (speed),1 ); +#endif + } }
drivers/ide/slc90e66.c +5 -108
121 lines not on this page · raw message
PATCH 52/68 pata_it8213: move code to be re-used by ide2libata to pata_it8213.h
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] pata_it8213: move code to be re-used by ide2libata to pata_it8213.h
--- drivers/ata/pata_it8213.c | 150 ---------------------------------------------- drivers/ata/pata_it8213.h | 150 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 151 insertions(+), 149 deletions(-)
drivers/ata/pata_it8213.c +1 -149
@@ -43,155 +43,7 @@ static int it8213_pre_reset(struct ata_lreturn ata_sff_prereset (link, deadline); } -/** -* it8213_cable_detect - check for 40/80 pin -* @ap: Port -* -* Perform cable detection for the 8213 ATA interface. This is -* different to the PIIX arrangement -*/ - -static int it8213_cable_detect (struct ata_port *ap) -{ -struct pci_dev *pdev =to_pci_dev (ap->host->dev); -u8 tmp; -pci_read_config_byte (pdev,0x42 , &tmp); -if (tmp &2 )/* The initial docs are incorrect */ -return ATA_CBL_PATA40 ; -return ATA_CBL_PATA80 ; -} - -static void it8213_set_timings (struct ata_port *ap,struct ata_device *adev, -u8 pio,bool use_mwdma) -{ -struct pci_dev *dev =to_pci_dev (ap->host->dev); -u8 master_port = ap->port_no ?0x42 :0x40 ; -u16 master_data; -int control =0 ; - -/* -* See Intel Document 298600-004 for the timing programing rules -* for PIIX/ICH. The 8213 is a clone so very similar -*/ - -static const /* ISP RTC */ -u8 timings[][2 ] = { {0 ,0 }, - {0 ,0 }, - {1 ,0 }, - {2 ,1 }, - {2 ,3 }, }; - -if (pio >1 || use_mwdma) - control |=1 ;/* TIME */ -if (ata_pio_need_iordy (adev) || use_mwdma) - control |=2 ;/* IE */ -/* Bit 2 is set for ATAPI on the IT8213 - reverse of ICH/PIIX */ -if (adev->class !=ATA_DEV_ATA ) - control |=4 ;/* PPE */ -/* If the drive MWDMA is faster than it can do PIO then -we must force PIO into PIO0 */ -if (use_mwdma && adev->pio_mode < (XFER_PIO_0 + pio)) -/* Enable DMA timing only */ - control |=8 ;/* PIO cycles in PIO0 */ - -pci_read_config_word (dev, master_port, &master_data); - -/* Set PPE, IE, and TIME as appropriate */ -if (adev->devno ==0 ) { - master_data &=0xCCF0 ; - master_data |= control; - master_data |= (timings[pio][0 ] <<12 ) | - (timings[pio][1 ] <<8 ); - }else { -u8 slave_data; - - master_data &=0xFF0F ; - master_data |= (control <<4 ); - -/* Slave timing in separate register */ -pci_read_config_byte (dev,0x44 , &slave_data); - slave_data &=0xF0 ; - slave_data |= (timings[pio][0 ] <<2 ) | timings[pio][1 ]; -pci_write_config_byte (dev,0x44 , slave_data); - } - - master_data |=0x4000 ;/* Ensure SITRE is set */ -pci_write_config_word (dev, master_port, master_data); -} - -/** -* it8213_set_piomode - Initialize host controller PATA PIO timings -* @ap: Port whose timings we are configuring -* @adev: Device whose timings we are configuring -* -* Set PIO mode for device, in host controller PCI config space. -* -* LOCKING: -* None (inherited from caller). -*/ - -static void it8213_set_piomode (struct ata_port *ap,struct ata_device *adev) -{ -it8213_set_timings (ap, adev, adev->pio_mode -XFER_PIO_0 ,0 ); -} - -/** -* it8213_set_dmamode - Initialize host controller PATA DMA timings -* @ap: Port whose timings we are configuring -* @adev: Device to program -* -* Set UDMA/MWDMA mode for device, in host controller PCI config space. -* This device is basically an ICH alike. -* -* LOCKING: -* None (inherited from caller). -*/ - -static void it8213_set_dmamode (struct ata_port *ap,struct ata_device *adev) -{ -struct pci_dev *dev =to_pci_dev (ap->host->dev); -u8 speed = adev->dma_mode; -int devid = adev->devno; -u8 udma_enable; - -pci_read_config_byte (dev,0x48 , &udma_enable); - -if (speed >=XFER_UDMA_0 ) { -unsigned int udma = speed -XFER_UDMA_0 ; -u16 udma_timing; -u16 ideconf; -int u_clock, u_speed; - -/* Clocks follow the PIIX style */ - u_speed =min (2 - (udma &1 ), udma); -if (udma >4 ) - u_clock =0x1000 ;/* 100Mhz */ -else if (udma >2 ) - u_clock =1 ;/* 66Mhz */ -else - u_clock =0 ;/* 33Mhz */ - - udma_enable |= (1 << devid); - -/* Load the UDMA cycle time */ -pci_read_config_word (dev,0x4A , &udma_timing); - udma_timing &= ~(3 << (4 * devid)); - udma_timing |= u_speed << (4 * devid); -pci_write_config_word (dev,0x4A , udma_timing); - -/* Load the clock selection */ -pci_read_config_word (dev,0x54 , &ideconf); - ideconf &= ~(0x1001 << devid); - ideconf |= u_clock << devid; -pci_write_config_word (dev,0x54 , ideconf); - }else { -/* MWDMA is driven by the PIO timings. */ -it8213_set_timings (ap, adev,ata_mwdma_to_pio (speed),1 ); - - udma_enable &= ~(1 << devid); - } -pci_write_config_byte (dev,0x48 , udma_enable); -} +#include "pata_it8213.h" static struct scsi_host_template it8213_sht = {ATA_BMDMA_SHT (DRV_NAME ),
drivers/ata/pata_it8213.h new file +150 -0
150 lines not on this page · raw message
PATCH 53/68 it8213: convert to ide2libata
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] it8213: convert to ide2libata
--- drivers/ata/pata_it8213.h | 11 +++ drivers/ide/it8213.c | 138 +--------------------------------------------- 2 files changed, 13 insertions(+), 136 deletions(-)
drivers/ata/pata_it8213.h +9 -2
@@ -141,9 +141,16 @@ static void it8213_set_dmamode(struct at ideconf |= u_clock << devid;pci_write_config_word (dev,0x54 , ideconf); }else { -/* MWDMA is driven by the PIO timings. */ +/* Normal DMA is driven by the PIO timings. */ +#ifdef __IDE2LIBATA +if (speed >=XFER_MW_DMA_0 ) + adev->pio_mode =ata_mwdma_to_pio (speed) +XFER_PIO_0 ; +else + adev->pio_mode =XFER_PIO_2 ;/* for SWDMA2 */ +it8213_set_timings (ap, adev, adev->pio_mode -XFER_PIO_0 ,1 ); +#else it8213_set_timings (ap, adev,ata_mwdma_to_pio (speed),1 ); - +#endif udma_enable &= ~(1 << devid); }pci_write_config_byte (dev,0x48 , udma_enable);
drivers/ide/it8213.c +4 -134
146 lines not on this page · raw message
PATCH 54/68 pata_it821x: move code to be re-used by ide2libata to pata_it821x.h
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] pata_it821x: move code to be re-used by ide2libata to pata_it821x.h
--- drivers/ata/pata_it821x.c | 319 ---------------------------------------------- drivers/ata/pata_it821x.h | 318 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 319 insertions(+), 318 deletions(-)
drivers/ata/pata_it821x.c +1 -318
@@ -19,51 +19,6 @@* http://www.ite.com.tw/pc/IT8212F_V04.pdf * Some other documents are NDA. * -* The ITE8212 isn't exactly a standard IDE controller. It has two -* modes. In pass through mode then it is an IDE controller. In its smart -* mode its actually quite a capable hardware raid controller disguised -* as an IDE controller. Smart mode only understands DMA read/write and -* identify, none of the fancier commands apply. The IT8211 is identical -* in other respects but lacks the raid mode. -* -* Errata: -* o Rev 0x10 also requires master/slave hold the same DMA timings and -* cannot do ATAPI MWDMA. -* o The identify data for raid volumes lacks CHS info (technically ok) -* but also fails to set the LBA28 and other bits. We fix these in -* the IDE probe quirk code. -* o If you write LBA48 sized I/O's (ie > 256 sector) in smart mode -* raid then the controller firmware dies -* o Smart mode without RAID doesn't clear all the necessary identify -* bits to reduce the command set to the one used -* -* This has a few impacts on the driver -* - In pass through mode we do all the work you would expect -* - In smart mode the clocking set up is done by the controller generally -* but we must watch the other limits and filter. -* - There are a few extra vendor commands that actually talk to the -* controller but only work PIO with no IRQ. -* -* Vendor areas of the identify block in smart mode are used for the -* timing and policy set up. Each HDD in raid mode also has a serial -* block on the disk. The hardware extra commands are get/set chip status, -* rebuild, get rebuild status. -* -* In Linux the driver supports pass through mode as if the device was -* just another IDE controller. If the smart mode is running then -* volumes are managed by the controller firmware and each IDE "disk" -* is a raid volume. Even more cute - the controller can do automated -* hotplug and rebuild. -* -* The pass through controller itself is a little demented. It has a -* flaw that it has a single set of PIO/MWDMA timings per channel so -* non UDMA devices restrict each others performance. It also has a -* single clock source per channel so mixed UDMA100/133 performance -* isn't perfect and we have to pick a clock. Thankfully none of this -* matters in smart mode. ATAPI DMA is not currently supported. -* -* It seems the smart mode is a win for RAID1/RAID10 but otherwise not. -* * TODO * - ATAPI and other speed filtering * - RAID configuration ioctls
@@ -78,260 +33,10 @@#include <scsi/scsi_host.h> #include <linux/libata.h> -#define DRV_NAME "pata_it821x"#define DRV_VERSION "0.4.2" -struct it821x_dev -{ -unsigned int smart:1 ,/* Are we in smart raid mode */ - timing10:1 ;/* Rev 0x10 */ -u8 clock_mode;/* 0, ATA_50 or ATA_66 */ -u8 want[2 ][2 ];/* Mode/Pri log for master slave */ -/* We need these for switching the clock when DMA goes on/off -The high byte is the 66Mhz timing */ -u16 pio[2 ];/* Cached PIO values */ -u16 mwdma[2 ];/* Cached MWDMA values */ -u16 udma[2 ];/* Cached UDMA values (per drive) */ -u16 last_device;/* Master or slave loaded ? */ -}; - -#define ATA_66 0 -#define ATA_50 1 -#define ATA_ANY 2 - -#define UDMA_OFF 0 -#define MWDMA_OFF 0 - -/* -* We allow users to force the card into non raid mode without -* flashing the alternative BIOS. This is also necessary right now -* for embedded platforms that cannot run a PC BIOS but are using this -* device. -*/ - -static int it8212_noraid; - -/** -* it821x_program - program the PIO/MWDMA registers -* @ap: ATA port -* @adev: Device to program -* @timing: Timing value (66Mhz in top 8bits, 50 in the low 8) -* -* Program the PIO/MWDMA timing for this channel according to the -* current clock. These share the same register so are managed by -* the DMA start/stop sequence as with the old driver. -*/ - -static void it821x_program (struct ata_port *ap,struct ata_device *adev,u16 timing) -{ -struct pci_dev *pdev =to_pci_dev (ap->host->dev); -struct it821x_dev *itdev = ap->private_data; -int channel = ap->port_no; -u8 conf; - -/* Program PIO/MWDMA timing bits */ -if (itdev->clock_mode ==ATA_66 ) - conf = timing >>8 ; -else - conf = timing &0xFF ; -pci_write_config_byte (pdev,0x54 +4 * channel, conf); -} - - -/** -* it821x_program_udma - program the UDMA registers -* @ap: ATA port -* @adev: ATA device to update -* @timing: Timing bits. Top 8 are for 66Mhz bottom for 50Mhz -* -* Program the UDMA timing for this drive according to the -* current clock. Handles the dual clocks and also knows about -* the errata on the 0x10 revision. The UDMA errata is partly handled -* here and partly in start_dma. -*/ - -static void it821x_program_udma (struct ata_port *ap,struct ata_device *adev,u16 timing) -{ -struct it821x_dev *itdev = ap->private_data; -struct pci_dev *pdev =to_pci_dev (ap->host->dev); -int channel = ap->port_no; -int unit = adev->devno; -u8 conf; - -/* Program UDMA timing bits */ -if (itdev->clock_mode ==ATA_66 ) - conf = timing >>8 ; -else - conf = timing &0xFF ; -if (itdev->timing10 ==0 ) -pci_write_config_byte (pdev,0x56 +4 * channel + unit, conf); -else { -/* Early revision must be programmed for both together */ -pci_write_config_byte (pdev,0x56 +4 * channel, conf); -pci_write_config_byte (pdev,0x56 +4 * channel +1 , conf); - } -} - -/** -* it821x_clock_strategy -* @ap: ATA interface -* @adev: ATA device being updated -* -* Select between the 50 and 66Mhz base clocks to get the best -* results for this interface. -*/ - -static void it821x_clock_strategy (struct ata_port *ap,struct ata_device *adev) -{ -struct pci_dev *pdev =to_pci_dev (ap->host->dev); -struct it821x_dev *itdev = ap->private_data; -u8 unit = adev->devno; -struct ata_device *pair =ata_dev_pair (adev); - -int clock, altclock; -u8 v; -int sel =0 ; - -/* Look for the most wanted clocking */ -if (itdev->want[0 ][0 ] > itdev->want[1 ][0 ]) { - clock = itdev->want[0 ][1 ]; - altclock = itdev->want[1 ][1 ]; - }else { - clock = itdev->want[1 ][1 ]; - altclock = itdev->want[0 ][1 ]; - } - -/* Master doesn't care does the slave ? */ -if (clock ==ATA_ANY ) - clock = altclock; - -/* Nobody cares - keep the same clock */ -if (clock ==ATA_ANY ) -return ; -/* No change */ -if (clock == itdev->clock_mode) -return ; - -/* Load this into the controller */ -if (clock ==ATA_66 ) - itdev->clock_mode =ATA_66 ; -else { - itdev->clock_mode =ATA_50 ; - sel =1 ; - } -pci_read_config_byte (pdev,0x50 , &v); - v &= ~(1 << (1 + ap->port_no)); - v |= sel << (1 + ap->port_no); -pci_write_config_byte (pdev,0x50 , v); - -/* -* Reprogram the UDMA/PIO of the pair drive for the switch -* MWDMA will be dealt with by the dma switcher -*/ -if (pair && itdev->udma[1 -unit] !=UDMA_OFF ) { -it821x_program_udma (ap, pair, itdev->udma[1 -unit]); -it821x_program (ap, pair, itdev->pio[1 -unit]); - } -/* -* Reprogram the UDMA/PIO of our drive for the switch. -* MWDMA will be dealt with by the dma switcher -*/ -if (itdev->udma[unit] !=UDMA_OFF ) { -it821x_program_udma (ap, adev, itdev->udma[unit]); -it821x_program (ap, adev, itdev->pio[unit]); - } -} - -/** -* it821x_passthru_set_piomode - set PIO mode data -* @ap: ATA interface -* @adev: ATA device -* -* Configure for PIO mode. This is complicated as the register is -* shared by PIO and MWDMA and for both channels. -*/ - -static void it821x_passthru_set_piomode (struct ata_port *ap,struct ata_device *adev) -{ -/* Spec says 89 ref driver uses 88 */ -static const u16 pio[] = {0xAA88 ,0xA382 ,0xA181 ,0x3332 ,0x3121 }; -static const u8 pio_want[] = {ATA_66 ,ATA_66 ,ATA_66 ,ATA_66 ,ATA_ANY }; - -struct it821x_dev *itdev = ap->private_data; -int unit = adev->devno; -int mode_wanted = adev->pio_mode -XFER_PIO_0 ; - -/* We prefer 66Mhz clock for PIO 0-3, don't care for PIO4 */ - itdev->want[unit][1 ] = pio_want[mode_wanted]; - itdev->want[unit][0 ] =1 ;/* PIO is lowest priority */ - itdev->pio[unit] = pio[mode_wanted]; -it821x_clock_strategy (ap, adev); -it821x_program (ap, adev, itdev->pio[unit]); -} - -/** -* it821x_passthru_set_dmamode - set initial DMA mode data -* @ap: ATA interface -* @adev: ATA device -* -* Set up the DMA modes. The actions taken depend heavily on the mode -* to use. If UDMA is used as is hopefully the usual case then the -* timing register is private and we need only consider the clock. If -* we are using MWDMA then we have to manage the setting ourself as -* we switch devices and mode. -*/ - -static void it821x_passthru_set_dmamode (struct ata_port *ap,struct ata_device *adev) -{ -static const u16 dma[] = {0x8866 ,0x3222 ,0x3121 }; -static const u8 mwdma_want[] = {ATA_ANY ,ATA_66 ,ATA_ANY }; -static const u16 udma[] = {0x4433 ,0x4231 ,0x3121 ,0x2121 ,0x1111 ,0x2211 ,0x1111 }; -static const u8 udma_want[] = {ATA_ANY ,ATA_50 ,ATA_ANY ,ATA_66 ,ATA_66 ,ATA_50 ,ATA_66 }; - -struct pci_dev *pdev =to_pci_dev (ap->host->dev); -struct it821x_dev *itdev = ap->private_data; -int channel = ap->port_no; -int unit = adev->devno; -u8 conf; - -if (adev->dma_mode >=XFER_UDMA_0 ) { -int mode_wanted = adev->dma_mode -XFER_UDMA_0 ; - - itdev->want[unit][1 ] = udma_want[mode_wanted]; - itdev->want[unit][0 ] =3 ;/* UDMA is high priority */ - itdev->mwdma[unit] =MWDMA_OFF ; - itdev->udma[unit] = udma[mode_wanted]; -if (mode_wanted >=5 ) - itdev->udma[unit] |=0x8080 ;/* UDMA 5/6 select on */ - -/* UDMA on. Again revision 0x10 must do the pair */ -pci_read_config_byte (pdev,0x50 , &conf); -if (itdev->timing10) - conf &= channel ?0x9F :0xE7 ; -else - conf &= ~ (1 << (3 +2 * channel + unit)); -pci_write_config_byte (pdev,0x50 , conf); -it821x_clock_strategy (ap, adev); -it821x_program_udma (ap, adev, itdev->udma[unit]); - }else { -int mode_wanted = adev->dma_mode -XFER_MW_DMA_0 ; - - itdev->want[unit][1 ] = mwdma_want[mode_wanted]; - itdev->want[unit][0 ] =2 ;/* MWDMA is low priority */ - itdev->mwdma[unit] = dma[mode_wanted]; - itdev->udma[unit] =UDMA_OFF ; - -/* UDMA bits off - Revision 0x10 do them in pairs */ -pci_read_config_byte (pdev,0x50 , &conf); -if (itdev->timing10) - conf |= channel ?0x60 :0x18 ; -else - conf |=1 << (3 +2 * channel + unit); -pci_write_config_byte (pdev,0x50 , conf); -it821x_clock_strategy (ap, adev); - } -} +#include "pata_it821x.h" /** * it821x_passthru_dma_start - DMA start callback
@@ -846,28 +551,6 @@ static struct ata_port_operations it821x .port_start = it821x_port_start, }; -static void it821x_disable_raid (struct pci_dev *pdev) -{ -/* Neither the RDC nor the IT8211 */ -if (pdev->vendor !=PCI_VENDOR_ID_ITE || - pdev->device !=PCI_DEVICE_ID_ITE_8212 ) -return ; - -/* Reset local CPU, and set BIOS not ready */ -pci_write_config_byte (pdev,0x5E ,0x01 ); - -/* Set to bypass mode, and reset PCI bus */ -pci_write_config_byte (pdev,0x50 ,0x00 ); -pci_write_config_word (pdev,PCI_COMMAND , -PCI_COMMAND_PARITY |PCI_COMMAND_IO | -PCI_COMMAND_MEMORY |PCI_COMMAND_MASTER ); -pci_write_config_word (pdev,0x40 ,0xA0F3 ); - -pci_write_config_dword (pdev,0x4C ,0x02040204 ); -pci_write_config_byte (pdev,0x42 ,0x36 ); -pci_write_config_byte (pdev,PCI_LATENCY_TIMER ,0x20 ); -} -static int it821x_fixup (struct device *dev) {struct pci_dev *pdev =to_pci_dev (dev);
drivers/ata/pata_it821x.h new file +318 -0
318 lines not on this page · raw message
PATCH 55/68 it821x: convert to ide2libata
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] it821x: convert to ide2libata
--- drivers/ata/pata_it821x.h | 21 ++ drivers/ide/it821x.c | 373 ---------------------------------------------- 2 files changed, 28 insertions(+), 366 deletions(-)
drivers/ata/pata_it821x.h +20 -1
@@ -55,7 +55,11 @@ struct it821x_dev {u16 pio[2 ];/* Cached PIO values */ u16 mwdma[2 ];/* Cached MWDMA values */ u16 udma[2 ];/* Cached UDMA values (per drive) */ +#ifndef __IDE2LIBATAu16 last_device;/* Master or slave loaded ? */ +#else +u16 quirks; +#endif };#define ATA_66 0
@@ -223,7 +227,21 @@ static void it821x_passthru_set_piomode(struct it821x_dev *itdev = ap->private_data;int unit = adev->devno;int mode_wanted = adev->pio_mode -XFER_PIO_0 ; +#ifdef __IDE2LIBATA +struct ata_device *pair =ata_dev_pair (adev); +/* +* Compute the best PIO mode we can for a given device. We must +* pick a speed that does not cause problems with the other device +* on the cable. +*/ +if (pair) { +u8 pair_pio = pair->pio_mode -XFER_PIO_0 ; +/* trim PIO to the slowest of the master/slave */ +if (pair_pio < mode_wanted) + mode_wanted = pair_pio; + } +#endif /* We prefer 66Mhz clock for PIO 0-3, don't care for PIO4 */ itdev->want[unit][1 ] = pio_want[mode_wanted]; itdev->want[unit][0 ] =1 ;/* PIO is lowest priority */
@@ -297,11 +315,12 @@ static void it821x_passthru_set_dmamode(static void it821x_disable_raid (struct pci_dev *pdev) { +#ifndef __IDE2LIBATA/* Neither the RDC nor the IT8211 */ if (pdev->vendor !=PCI_VENDOR_ID_ITE || pdev->device !=PCI_DEVICE_ID_ITE_8212 )return ; - +#endif /* Reset local CPU, and set BIOS not ready */ pci_write_config_byte (pdev,0x5E ,0x01 );
drivers/ide/it821x.c +8 -365
420 lines not on this page · raw message
PATCH 56/68 pata_pdc202xx_old: move code to be re-used by ide2libata to pata_pdc202xx_old.h
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] pata_pdc202xx_old: move code to be re-used by ide2libata to pata_pdc202xx_old.h
--- drivers/ata/pata_pdc202xx_old.c | 109 ---------------------------------------- drivers/ata/pata_pdc202xx_old.h | 109 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+), 108 deletions(-)
drivers/ata/pata_pdc202xx_old.c +1 -108
@@ -24,114 +24,7 @@#define DRV_NAME "pata_pdc202xx_old"#define DRV_VERSION "0.4.3" -static int pdc2026x_cable_detect (struct ata_port *ap) -{ -struct pci_dev *pdev =to_pci_dev (ap->host->dev); -u16 cis; - -pci_read_config_word (pdev,0x50 , &cis); -if (cis & (1 << (10 + ap->port_no))) -return ATA_CBL_PATA40 ; -return ATA_CBL_PATA80 ; -} - -/** -* pdc202xx_configure_piomode - set chip PIO timing -* @ap: ATA interface -* @adev: ATA device -* @pio: PIO mode -* -* Called to do the PIO mode setup. Our timing registers are shared -* so a configure_dmamode call will undo any work we do here and vice -* versa -*/ - -static void pdc202xx_configure_piomode (struct ata_port *ap,struct ata_device *adev,int pio) -{ -struct pci_dev *pdev =to_pci_dev (ap->host->dev); -int port =0x60 +8 * ap->port_no +4 * adev->devno; -static u16 pio_timing[5 ] = { -0x0913 ,0x050C ,0x0308 ,0x0206 ,0x0104 - }; -u8 r_ap, r_bp; - -pci_read_config_byte (pdev, port, &r_ap); -pci_read_config_byte (pdev, port +1 , &r_bp); - r_ap &= ~0x3F ;/* Preserve ERRDY_EN, SYNC_IN */ - r_bp &= ~0x1F ; - r_ap |= (pio_timing[pio] >>8 ); - r_bp |= (pio_timing[pio] &0xFF ); - -if (ata_pio_need_iordy (adev)) - r_ap |=0x20 ;/* IORDY enable */ -if (adev->class ==ATA_DEV_ATA ) - r_ap |=0x10 ;/* FIFO enable */ -pci_write_config_byte (pdev, port, r_ap); -pci_write_config_byte (pdev, port +1 , r_bp); -} - -/** -* pdc202xx_set_piomode - set initial PIO mode data -* @ap: ATA interface -* @adev: ATA device -* -* Called to do the PIO mode setup. Our timing registers are shared -* but we want to set the PIO timing by default. -*/ - -static void pdc202xx_set_piomode (struct ata_port *ap,struct ata_device *adev) -{ -pdc202xx_configure_piomode (ap, adev, adev->pio_mode -XFER_PIO_0 ); -} - -/** -* pdc202xx_configure_dmamode - set DMA mode in chip -* @ap: ATA interface -* @adev: ATA device -* -* Load DMA cycle times into the chip ready for a DMA transfer -* to occur. -*/ - -static void pdc202xx_set_dmamode (struct ata_port *ap,struct ata_device *adev) -{ -struct pci_dev *pdev =to_pci_dev (ap->host->dev); -int port =0x60 +8 * ap->port_no +4 * adev->devno; -static u8 udma_timing[6 ][2 ] = { - {0x60 ,0x03 },/* 33 Mhz Clock */ - {0x40 ,0x02 }, - {0x20 ,0x01 }, - {0x40 ,0x02 },/* 66 Mhz Clock */ - {0x20 ,0x01 }, - {0x20 ,0x01 } - }; -static u8 mdma_timing[3 ][2 ] = { - {0xe0 ,0x0f }, - {0x60 ,0x04 }, - {0x60 ,0x03 }, - }; -u8 r_bp, r_cp; - -pci_read_config_byte (pdev, port +1 , &r_bp); -pci_read_config_byte (pdev, port +2 , &r_cp); - - r_bp &= ~0xE0 ; - r_cp &= ~0x0F ; - -if (adev->dma_mode >=XFER_UDMA_0 ) { -int speed = adev->dma_mode -XFER_UDMA_0 ; - r_bp |= udma_timing[speed][0 ]; - r_cp |= udma_timing[speed][1 ]; - - }else { -int speed = adev->dma_mode -XFER_MW_DMA_0 ; - r_bp |= mdma_timing[speed][0 ]; - r_cp |= mdma_timing[speed][1 ]; - } -pci_write_config_byte (pdev, port +1 , r_bp); -pci_write_config_byte (pdev, port +2 , r_cp); - -} +#include "pata_pdc202xx_old.h" /** * pdc2026x_bmdma_start - DMA engine begin
drivers/ata/pata_pdc202xx_old.h new file +109 -0
109 lines not on this page · raw message
PATCH 57/68 pdc202xx_old: convert to ide2libata
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] pdc202xx_old: convert to ide2libata
--- drivers/ata/pata_pdc202xx_old.h | 12 ++++++ drivers/ide/pdc202xx_old.c | 80 +++------------------------------------- 2 files changed, 18 insertions(+), 74 deletions(-)
drivers/ata/pata_pdc202xx_old.h +12 -0
@@ -1,7 +1,11 @@static int pdc2026x_cable_detect (struct ata_port *ap) { +#ifndef __IDE2LIBATAstruct pci_dev *pdev =to_pci_dev (ap->host->dev); +#else +struct pci_dev *pdev =to_pci_dev (ap->dev); +#endif u16 cis;pci_read_config_word (pdev,0x50 , &cis);
@@ -23,7 +27,11 @@ static int pdc2026x_cable_detect(structstatic void pdc202xx_configure_piomode (struct ata_port *ap,struct ata_device *adev,int pio) { +#ifndef __IDE2LIBATAstruct pci_dev *pdev =to_pci_dev (ap->host->dev); +#else +struct pci_dev *pdev =to_pci_dev (ap->dev); +#endif int port =0x60 +8 * ap->port_no +4 * adev->devno;static u16 pio_timing[5 ] = {0x0913 ,0x050C ,0x0308 ,0x0206 ,0x0104
@@ -70,7 +78,11 @@ static void pdc202xx_set_piomode(structstatic void pdc202xx_set_dmamode (struct ata_port *ap,struct ata_device *adev) { +#ifndef __IDE2LIBATAstruct pci_dev *pdev =to_pci_dev (ap->host->dev); +#else +struct pci_dev *pdev =to_pci_dev (ap->dev); +#endif int port =0x60 +8 * ap->port_no +4 * adev->devno;static u8 udma_timing[6 ][2 ] = { {0x60 ,0x03 },/* 33 Mhz Clock */
drivers/ide/pdc202xx_old.c +6 -74
102 lines not on this page · raw message
PATCH 58/68 pata_sc1200: move code to be re-used by ide2libata to pata_sc1200.h
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] pata_sc1200: move code to be re-used by ide2libata to pata_sc1200.h
Convert C99 style comments while at it.
--- drivers/ata/pata_sc1200.c | 108 -------------------------------------------- drivers/ata/pata_sc1200.h | 112 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 113 insertions(+), 107 deletions(-)
drivers/ata/pata_sc1200.c +1 -107
@@ -41,113 +41,7 @@#define DRV_NAME "sc1200"#define DRV_VERSION "0.2.6" -#define SC1200_REV_A 0x00 -#define SC1200_REV_B1 0x01 -#define SC1200_REV_B3 0x02 -#define SC1200_REV_C1 0x03 -#define SC1200_REV_D1 0x04 - -/** -* sc1200_clock - PCI clock -* -* Return the PCI bus clocking for the SC1200 chipset configuration -* in use. We return 0 for 33MHz 1 for 48MHz and 2 for 66Mhz -*/ - -static int sc1200_clock (void ) -{ -/* Magic registers that give us the chipset data */ -u8 chip_id =inb (0x903C ); -u8 silicon_rev =inb (0x903D ); -u16 pci_clock; - -if (chip_id ==0x04 && silicon_rev <SC1200_REV_B1 ) -return 0 ;/* 33 MHz mode */ - -/* Clock generator configuration 0x901E its 8/9 are the PCI clocking -0/3 is 33Mhz 1 is 48 2 is 66 */ - - pci_clock =inw (0x901E ); - pci_clock >>=8 ; - pci_clock &=0x03 ; -if (pci_clock ==3 ) - pci_clock =0 ; -return pci_clock; -} - -/** -* sc1200_set_piomode - PIO setup -* @ap: ATA interface -* @adev: device on the interface -* -* Set our PIO requirements. This is fairly simple on the SC1200 -*/ - -static void sc1200_set_piomode (struct ata_port *ap,struct ata_device *adev) -{ -static const u32 pio_timings[4 ][5 ] = { - {0x00009172 ,0x00012171 ,0x00020080 ,0x00032010 ,0x00040010 },// format0 33Mhz - {0xd1329172 ,0x71212171 ,0x30200080 ,0x20102010 ,0x00100010 },// format1, 33Mhz - {0xfaa3f4f3 ,0xc23232b2 ,0x513101c1 ,0x31213121 ,0x10211021 },// format1, 48Mhz - {0xfff4fff4 ,0xf35353d3 ,0x814102f1 ,0x42314231 ,0x11311131 }// format1, 66Mhz - }; - -struct pci_dev *pdev =to_pci_dev (ap->host->dev); -u32 format; -unsigned int reg =0x40 +0x10 * ap->port_no; -int mode = adev->pio_mode -XFER_PIO_0 ; - -pci_read_config_dword (pdev, reg +4 , &format); - format >>=31 ; - format +=sc1200_clock (); -pci_write_config_dword (pdev, reg +8 * adev->devno, - pio_timings[format][mode]); -} - -/** -* sc1200_set_dmamode - DMA timing setup -* @ap: ATA interface -* @adev: Device being configured -* -* We cannot mix MWDMA and UDMA without reloading timings each switch -* master to slave. -*/ - -static void sc1200_set_dmamode (struct ata_port *ap,struct ata_device *adev) -{ -static const u32 udma_timing[3 ][3 ] = { - {0x00921250 ,0x00911140 ,0x00911030 }, - {0x00932470 ,0x00922260 ,0x00922140 }, - {0x009436A1 ,0x00933481 ,0x00923261 } - }; - -static const u32 mwdma_timing[3 ][3 ] = { - {0x00077771 ,0x00012121 ,0x00002020 }, - {0x000BBBB2 ,0x00024241 ,0x00013131 }, - {0x000FFFF3 ,0x00035352 ,0x00015151 } - }; - -int clock =sc1200_clock (); -struct pci_dev *pdev =to_pci_dev (ap->host->dev); -unsigned int reg =0x40 +0x10 * ap->port_no; -int mode = adev->dma_mode; -u32 format; - -if (mode >=XFER_UDMA_0 ) - format = udma_timing[clock][mode -XFER_UDMA_0 ]; -else - format = mwdma_timing[clock][mode -XFER_MW_DMA_0 ]; - -if (adev->devno ==0 ) { -u32 timings; - -pci_read_config_dword (pdev, reg +4 , &timings); - timings &=0x80000000UL ; - timings |= format; -pci_write_config_dword (pdev, reg +4 , timings); - }else -pci_write_config_dword (pdev, reg +12 , format); -} +#include "pata_sc1200.h" /** * sc1200_qc_issue - command issue
drivers/ata/pata_sc1200.h new file +112 -0
112 lines not on this page · raw message
PATCH 59/68 sc1200: convert to ide2libata
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] sc1200: convert to ide2libata
--- drivers/ide/sc1200.c | 113 +-------------------------------------------------- 1 file changed, 4 insertions(+), 109 deletions(-)
drivers/ide/sc1200.c +4 -109
@@ -23,73 +23,8 @@#define DRV_NAME "sc1200" -#define SC1200_REV_A 0x00 -#define SC1200_REV_B1 0x01 -#define SC1200_REV_B3 0x02 -#define SC1200_REV_C1 0x03 -#define SC1200_REV_D1 0x04 - -#define PCI_CLK_33 0x00 -#define PCI_CLK_48 0x01 -#define PCI_CLK_66 0x02 -#define PCI_CLK_33A 0x03 - -static unsigned short sc1200_get_pci_clock (void ) -{ -unsigned char chip_id, silicon_revision; -unsigned int pci_clock; -/* -* Check the silicon revision, as not all versions of the chip -* have the register with the fast PCI bus timings. -*/ - chip_id =inb (0x903c ); - silicon_revision =inb (0x903d ); - -// Read the fast pci clock frequency -if (chip_id ==0x04 && silicon_revision <SC1200_REV_B1 ) { - pci_clock =PCI_CLK_33 ; - }else { -// check clock generator configuration (cfcc) -// the clock is in bits 8 and 9 of this word - - pci_clock =inw (0x901e ); - pci_clock >>=8 ; - pci_clock &=0x03 ; -if (pci_clock ==PCI_CLK_33A ) - pci_clock =PCI_CLK_33 ; - } -return pci_clock; -} - -/* -* Here are the standard PIO mode 0-4 timings for each "format". -* Format-0 uses fast data reg timings, with slower command reg timings. -* Format-1 uses fast timings for all registers, but won't work with all drives. -*/ -static const unsigned int sc1200_pio_timings[4 ][5 ] = - {{0x00009172 ,0x00012171 ,0x00020080 ,0x00032010 ,0x00040010 },// format0 33Mhz - {0xd1329172 ,0x71212171 ,0x30200080 ,0x20102010 ,0x00100010 },// format1, 33Mhz - {0xfaa3f4f3 ,0xc23232b2 ,0x513101c1 ,0x31213121 ,0x10211021 },// format1, 48Mhz - {0xfff4fff4 ,0xf35353d3 ,0x814102f1 ,0x42314231 ,0x11311131 }};// format1, 66Mhz - -/* -* After chip reset, the PIO timings are set to 0x00009172, which is not valid. -*/ -//#define SC1200_BAD_PIO(timings) (((timings)&~0x80000000)==0x00009172) - -static void sc1200_tunepio (ide_drive_t *drive,u8 pio) -{ -ide_hwif_t *hwif = drive->hwif; -struct pci_dev *pdev =to_pci_dev (hwif->dev); -unsigned int basereg = hwif->channel ?0x50 :0x40 , format =0 ; - -pci_read_config_dword (pdev, basereg +4 , &format); - format = (format >>31 ) &1 ; -if (format) - format +=sc1200_get_pci_clock (); -pci_write_config_dword (pdev, basereg + ((drive->dn &1 ) <<3 ), - sc1200_pio_timings[format][pio]); -} +#include <linux/ide2libata.h> +#include "../ata/pata_sc1200.h" /* * The SC1200 specifies that two drives sharing a cable cannot mix
@@ -122,46 +57,6 @@ out:return mask; } -static void sc1200_set_dma_mode (ide_hwif_t *hwif,ide_drive_t *drive) -{ -struct pci_dev *dev =to_pci_dev (hwif->dev); -unsigned int reg, timings; -unsigned short pci_clock; -unsigned int basereg = hwif->channel ?0x50 :0x40 ; -const u8 mode = drive->dma_mode; - -static const u32 udma_timing[3 ][3 ] = { - {0x00921250 ,0x00911140 ,0x00911030 }, - {0x00932470 ,0x00922260 ,0x00922140 }, - {0x009436a1 ,0x00933481 ,0x00923261 }, - }; - -static const u32 mwdma_timing[3 ][3 ] = { - {0x00077771 ,0x00012121 ,0x00002020 }, - {0x000bbbb2 ,0x00024241 ,0x00013131 }, - {0x000ffff3 ,0x00035352 ,0x00015151 }, - }; - - pci_clock =sc1200_get_pci_clock (); - -/* -* Note that each DMA mode has several timings associated with it. -* The correct timing depends on the fast PCI clock freq. -*/ - -if (mode >=XFER_UDMA_0 ) - timings = udma_timing[pci_clock][mode -XFER_UDMA_0 ]; -else - timings = mwdma_timing[pci_clock][mode -XFER_MW_DMA_0 ]; - -if ((drive->dn &1 ) ==0 ) { -pci_read_config_dword (dev, basereg +4 , ®); - timings |= reg &0x80000000 ;/* preserve PIO format bit */ -pci_write_config_dword (dev, basereg +4 , timings); - }else -pci_write_config_dword (dev, basereg +12 , timings); -} -/* Replacement for the standard ide_dma_end action in * dma_proc. *
@@ -218,7 +113,7 @@ static void sc1200_set_pio_mode(ide_hwifreturn ; } -sc1200_tunepio (drive, pio); +sc1200_set_piomode (hwif, drive); }#ifdef CONFIG_PM
@@ -275,7 +170,7 @@ static int sc1200_resume (struct pci_devstatic const struct ide_port_ops sc1200_port_ops = { .set_pio_mode = sc1200_set_pio_mode, - .set_dma_mode = sc1200_set_dma_mode, + .set_dma_mode = sc1200_set_dmamode, .udma_filter = sc1200_udma_filter, };
PATCH 60/68 pata_serverworks: move cable handling to pata_serverworks.h
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] pata_serverworks: move cable handling to pata_serverworks.h
--- drivers/ata/pata_serverworks.c | 282 ---------------------------------------- drivers/ata/pata_serverworks.h | 283 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 284 insertions(+), 281 deletions(-)
drivers/ata/pata_serverworks.c +1 -281
@@ -14,18 +14,6 @@* * RCC/ServerWorks IDE driver for Linux * -* OSB4: `Open South Bridge' IDE Interface (fn 1) -* supports UDMA mode 2 (33 MB/s) -* -* CSB5: `Champion South Bridge' IDE Interface (fn 1) -* all revisions support UDMA mode 4 (66 MB/s) -* revision A2.0 and up support UDMA mode 5 (100 MB/s) -* -* *** The CSB5 does not provide ANY register *** -* *** to detect 80-conductor cable presence. *** -* -* CSB6: `Champion South Bridge' IDE Interface (optional: third channel) -* * Documentation: * Available under NDA only. Errata info very hard to get. */
@@ -42,102 +30,7 @@#define DRV_NAME "pata_serverworks"#define DRV_VERSION "0.4.3" -#define SVWKS_CSB5_REVISION_NEW 0x92/* min PCI_REVISION_ID for UDMA5 (A2.0) */ -#define SVWKS_CSB6_REVISION 0xa0/* min PCI_REVISION_ID for UDMA4 (A1.0) */ - -/* Seagate Barracuda ATA IV Family drives in UDMA mode 5 -* can overrun their FIFOs when used with the CSB5 */ - -static const char *csb_bad_ata100[] = { -"ST320011A" , -"ST340016A" , -"ST360021A" , -"ST380021A" , -NULL -}; - -/** -* oem_cable - Dell/Sun serverworks cable detection -* @ap: ATA port to do cable detect -* -* Dell PowerEdge and Sun Cobalt 'Alpine' hide the 40/80 pin select -* for their interfaces in the top two bits of the subsystem ID. -*/ - -static int oem_cable (struct ata_port *ap) -{ -struct pci_dev *pdev =to_pci_dev (ap->host->dev); - -if (pdev->subsystem_device & (1 << (ap->port_no +14 ))) -return ATA_CBL_PATA80 ; -return ATA_CBL_PATA40 ; -} - -struct sv_cable_table { -int device; -int subvendor; -int (*cable_detect)(struct ata_port *ap); -}; - -static struct sv_cable_table cable_detect[] = { - {PCI_DEVICE_ID_SERVERWORKS_CSB5IDE ,PCI_VENDOR_ID_DELL , oem_cable }, - {PCI_DEVICE_ID_SERVERWORKS_CSB6IDE ,PCI_VENDOR_ID_DELL , oem_cable }, - {PCI_DEVICE_ID_SERVERWORKS_CSB5IDE ,PCI_VENDOR_ID_SUN , oem_cable }, - {PCI_DEVICE_ID_SERVERWORKS_OSB4IDE ,PCI_ANY_ID , ata_cable_40wire }, - {PCI_DEVICE_ID_SERVERWORKS_CSB5IDE ,PCI_ANY_ID , ata_cable_unknown }, - {PCI_DEVICE_ID_SERVERWORKS_CSB6IDE ,PCI_ANY_ID , ata_cable_unknown }, - {PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2 ,PCI_ANY_ID , ata_cable_unknown }, - {PCI_DEVICE_ID_SERVERWORKS_HT1000IDE ,PCI_ANY_ID , ata_cable_unknown }, - { } -}; - -/** -* serverworks_cable_detect - cable detection -* @ap: ATA port -* -* Perform cable detection according to the device and subvendor -* identifications -*/ - -static int serverworks_cable_detect (struct ata_port *ap) -{ -struct pci_dev *pdev =to_pci_dev (ap->host->dev); -struct sv_cable_table *cb = cable_detect; - -while (cb->device) { -if (cb->device == pdev->device && - (cb->subvendor == pdev->subsystem_vendor || - cb->subvendor ==PCI_ANY_ID )) { -return cb->cable_detect (ap); - } - cb++; - } - -BUG (); -return -1 ;/* kill compiler warning */ -} - -/** -* serverworks_is_csb - Check for CSB or OSB -* @pdev: PCI device to check -* -* Returns true if the device being checked is known to be a CSB -* series device. -*/ - -static u8 serverworks_is_csb (struct pci_dev *pdev) -{ -switch (pdev->device) { -case PCI_DEVICE_ID_SERVERWORKS_CSB5IDE : -case PCI_DEVICE_ID_SERVERWORKS_CSB6IDE : -case PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2 : -case PCI_DEVICE_ID_SERVERWORKS_HT1000IDE : -return 1 ; -default : -break ; - } -return 0 ; -} +#include "pata_serverworks.h" /** * serverworks_osb4_filter - mode selection filter
@@ -156,7 +49,6 @@ static unsigned long serverworks_osb4_fireturn ata_bmdma_mode_filter (adev, mask); } -/** * serverworks_csb_filter - mode selection filter * @adev: ATA device
@@ -185,72 +77,6 @@ static unsigned long serverworks_csb_filreturn ata_bmdma_mode_filter (adev, mask); } -/** -* serverworks_set_piomode - set initial PIO mode data -* @ap: ATA interface -* @adev: ATA device -* -* Program the OSB4/CSB5 timing registers for PIO. The PIO register -* load is done as a simple lookup. -*/ -static void serverworks_set_piomode (struct ata_port *ap,struct ata_device *adev) -{ -static const u8 pio_mode[] = {0x5d ,0x47 ,0x34 ,0x22 ,0x20 }; -int offset =1 +2 * ap->port_no - adev->devno; -int devbits = (2 * ap->port_no + adev->devno) *4 ; -u16 csb5_pio; -struct pci_dev *pdev =to_pci_dev (ap->host->dev); -int pio = adev->pio_mode -XFER_PIO_0 ; - -pci_write_config_byte (pdev,0x40 + offset, pio_mode[pio]); - -/* The OSB4 just requires the timing but the CSB series want the -mode number as well */ -if (serverworks_is_csb (pdev)) { -pci_read_config_word (pdev,0x4A , &csb5_pio); - csb5_pio &= ~(0x0F << devbits); -pci_write_config_word (pdev,0x4A , csb5_pio | (pio << devbits)); - } -} - -/** -* serverworks_set_dmamode - set initial DMA mode data -* @ap: ATA interface -* @adev: ATA device -* -* Program the MWDMA/UDMA modes for the serverworks OSB4/CSB5 -* chipset. The MWDMA mode values are pulled from a lookup table -* while the chipset uses mode number for UDMA. -*/ - -static void serverworks_set_dmamode (struct ata_port *ap,struct ata_device *adev) -{ -static const u8 dma_mode[] = {0x77 ,0x21 ,0x20 }; -int offset =1 +2 * ap->port_no - adev->devno; -int devbits =2 * ap->port_no + adev->devno; -u8 ultra; -u8 ultra_cfg; -struct pci_dev *pdev =to_pci_dev (ap->host->dev); - -pci_read_config_byte (pdev,0x54 , &ultra_cfg); -pci_read_config_byte (pdev,0x56 + ap->port_no, &ultra); - ultra &= ~(0x0F << (adev->devno *4 )); - -if (adev->dma_mode >=XFER_UDMA_0 ) { -pci_write_config_byte (pdev,0x44 + offset,0x20 ); - - ultra |= (adev->dma_mode -XFER_UDMA_0 ) - << (adev->devno *4 ); - ultra_cfg |= (1 << devbits); - }else { -pci_write_config_byte (pdev,0x44 + offset, - dma_mode[adev->dma_mode -XFER_MW_DMA_0 ]); - ultra_cfg &= ~(1 << devbits); - } -pci_write_config_byte (pdev,0x56 + ap->port_no, ultra); -pci_write_config_byte (pdev,0x54 , ultra_cfg); -} -static struct scsi_host_template serverworks_sht = {ATA_BMDMA_SHT (DRV_NAME ), };
@@ -268,112 +94,6 @@ static struct ata_port_operations server .mode_filter = serverworks_csb_filter, }; -static int serverworks_fixup_osb4 (struct pci_dev *pdev) -{ -u32 reg; -struct pci_dev *isa_dev =pci_get_device (PCI_VENDOR_ID_SERVERWORKS , -PCI_DEVICE_ID_SERVERWORKS_OSB4 ,NULL ); -if (isa_dev) { -pci_read_config_dword (isa_dev,0x64 , ®); - reg &= ~0x00002000 ;/* disable 600ns interrupt mask */ -if (!(reg &0x00004000 )) - printk(KERN_DEBUG DRV_NAME ": UDMA not BIOS enabled.\n"); - reg |=0x00004000 ;/* enable UDMA/33 support */ -pci_write_config_dword (isa_dev,0x64 , reg); -pci_dev_put (isa_dev); -return 0 ; - } - printk(KERN_WARNING DRV_NAME ": Unable to find bridge.\n"); -return -ENODEV ; -} - -static int serverworks_fixup_csb (struct pci_dev *pdev) -{ -u8 btr; - -/* Third Channel Test */ -if (!(PCI_FUNC (pdev->devfn) &1 )) { -struct pci_dev * findev =NULL ; -u32 reg4c =0 ; - findev =pci_get_device (PCI_VENDOR_ID_SERVERWORKS , -PCI_DEVICE_ID_SERVERWORKS_CSB5 ,NULL ); -if (findev) { -pci_read_config_dword (findev,0x4C , ®4c); - reg4c &= ~0x000007FF ; - reg4c |=0x00000040 ; - reg4c |=0x00000020 ; -pci_write_config_dword (findev,0x4C , reg4c); -pci_dev_put (findev); - } - }else { -struct pci_dev * findev =NULL ; -u8 reg41 =0 ; - - findev =pci_get_device (PCI_VENDOR_ID_SERVERWORKS , -PCI_DEVICE_ID_SERVERWORKS_CSB6 ,NULL ); -if (findev) { -pci_read_config_byte (findev,0x41 , ®41); - reg41 &= ~0x40 ; -pci_write_config_byte (findev,0x41 , reg41); -pci_dev_put (findev); - } - } -/* setup the UDMA Control register -* -* 1. clear bit 6 to enable DMA -* 2. enable DMA modes with bits 0-1 -* 00 : legacy -* 01 : udma2 -* 10 : udma2/udma4 -* 11 : udma2/udma4/udma5 -*/ -pci_read_config_byte (pdev,0x5A , &btr); - btr &= ~0x40 ; -if (!(PCI_FUNC (pdev->devfn) &1 )) - btr |=0x2 ; -else - btr |= (pdev->revision >=SVWKS_CSB5_REVISION_NEW ) ?0x3 :0x2 ; -pci_write_config_byte (pdev,0x5A , btr); - -return btr; -} - -static void serverworks_fixup_ht1000 (struct pci_dev *pdev) -{ -u8 btr; -/* Setup HT1000 SouthBridge Controller - Single Channel Only */ -pci_read_config_byte (pdev,0x5A , &btr); - btr &= ~0x40 ; - btr |=0x3 ; -pci_write_config_byte (pdev,0x5A , btr); -} - -static int serverworks_fixup (struct pci_dev *pdev) -{ -int rc =0 ; - -/* Force master latency timer to 64 PCI clocks */ -pci_write_config_byte (pdev,PCI_LATENCY_TIMER ,0x40 ); - -switch (pdev->device) { -case PCI_DEVICE_ID_SERVERWORKS_OSB4IDE : - rc =serverworks_fixup_osb4 (pdev); -break ; -case PCI_DEVICE_ID_SERVERWORKS_CSB5IDE : -ata_pci_bmdma_clear_simplex (pdev); -/* fall through */ -case PCI_DEVICE_ID_SERVERWORKS_CSB6IDE : -case PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2 : - rc =serverworks_fixup_csb (pdev); -break ; -case PCI_DEVICE_ID_SERVERWORKS_HT1000IDE : -serverworks_fixup_ht1000 (pdev); -break ; - } - -return rc; -} -static int serverworks_init_one (struct pci_dev *pdev,const struct pci_device_id *id) {static const struct ata_port_info info[4 ] = {
drivers/ata/pata_serverworks.h new file +283 -0
283 lines not on this page · raw message
PATCH 61/68 serverworks: convert to ide2libata
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] serverworks: convert to ide2libata
--- drivers/ata/pata_serverworks.h | 20 ++ drivers/ide/serverworks.c | 281 ++--------------------------------------- 2 files changed, 40 insertions(+), 261 deletions(-)
drivers/ata/pata_serverworks.h +20 -0
@@ -11,6 +11,9 @@* *** to detect 80-conductor cable presence. *** * * CSB6: `Champion South Bridge' IDE Interface (optional: third channel) +* +* HT1000: AKA BCM5785 - Hypertransport Southbridge for Opteron systems. IDE +* controller same as the CSB6. Single channel ATA100 only. */ #define SVWKS_CSB5_REVISION_NEW 0x92/* min PCI_REVISION_ID for UDMA5 (A2.0) */
@@ -213,6 +216,10 @@ static int serverworks_fixup_csb(structpci_write_config_dword (findev,0x4C , reg4c);pci_dev_put (findev); } +#ifdef __IDE2LIBATA +outb_p (0x06 ,0x0c00 ); + pdev->irq =inb_p (0x0c01 ); +#endif }else {struct pci_dev *findev =NULL ;u8 reg41 =0 ;
@@ -225,6 +232,17 @@ static int serverworks_fixup_csb(structpci_write_config_byte (findev,0x41 , reg41);pci_dev_put (findev); } +#ifdef __IDE2LIBATA +/* +* This is a device pin issue on CSB6. +* Since there will be a future raid mode, +* early versions of the chipset require the +* interrupt pin to be set, and it is a compatibility +* mode issue. +*/ +if ((pdev->class >>8 ) ==PCI_CLASS_STORAGE_IDE ) + pdev->irq =0 ; +#endif }/* setup the UDMA Control register *
@@ -268,7 +286,9 @@ static int serverworks_fixup(struct pci_ rc =serverworks_fixup_osb4 (pdev);break ;case PCI_DEVICE_ID_SERVERWORKS_CSB5IDE : +#ifndef __IDE2LIBATAata_pci_bmdma_clear_simplex (pdev); +#endif /* fall through */ case PCI_DEVICE_ID_SERVERWORKS_CSB6IDE :case PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2 :
drivers/ide/serverworks.c +20 -261
322 lines not on this page · raw message
PATCH 62/68 pata_sl82c105: move code to be re-used by ide2libata to pata_sl82c105.h
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] pata_sl82c105: move code to be re-used by ide2libata to pata_sl82c105.h
--- drivers/ata/pata_sl82c105.c | 106 -------------------------------------------- drivers/ata/pata_sl82c105.h | 106 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 107 insertions(+), 105 deletions(-)
drivers/ata/pata_sl82c105.c +1 -105
@@ -28,18 +28,7 @@#define DRV_NAME "pata_sl82c105"#define DRV_VERSION "0.3.3" -enum { -/* -* SL82C105 PCI config register 0x40 bits. -*/ -CTRL_IDE_IRQB = (1 <<30 ), -CTRL_IDE_IRQA = (1 <<28 ), -CTRL_LEGIRQ = (1 <<11 ), -CTRL_P1F16 = (1 <<5 ), -CTRL_P1EN = (1 <<4 ), -CTRL_P0F16 = (1 <<1 ), -CTRL_P0EN = (1 <<0 ) -}; +#include "pata_sl82c105.h" /** * sl82c105_pre_reset - probe begin
@@ -104,50 +93,6 @@ static void sl82c105_set_piomode(struct }/** -* sl82c105_configure_dmamode - set DMA mode in chip -* @ap: ATA interface -* @adev: ATA device -* -* Load DMA cycle times into the chip ready for a DMA transfer -* to occur. -*/ - -static void sl82c105_configure_dmamode (struct ata_port *ap,struct ata_device *adev) -{ -struct pci_dev *pdev =to_pci_dev (ap->host->dev); -static u16 dma_timing[3 ] = { -0x707 ,0x201 ,0x200 - }; -u16 dummy; -int timing =0x44 + (8 * ap->port_no) + (4 * adev->devno); -int dma = adev->dma_mode -XFER_MW_DMA_0 ; - -pci_write_config_word (pdev, timing, dma_timing[dma]); -/* Can we lose this oddity of the old driver */ -pci_read_config_word (pdev, timing, &dummy); -} - -/** -* sl82c105_reset_engine - Reset the DMA engine -* @ap: ATA interface -* -* The sl82c105 has some serious problems with the DMA engine -* when transfers don't run as expected or ATAPI is used. The -* recommended fix is to reset the engine each use using a chip -* test register. -*/ - -static void sl82c105_reset_engine (struct ata_port *ap) -{ -struct pci_dev *pdev =to_pci_dev (ap->host->dev); -u16 val; - -pci_read_config_word (pdev,0x7E , &val); -pci_write_config_word (pdev,0x7E , val |4 ); -pci_write_config_word (pdev,0x7E , val & ~4 ); -} - -/** * sl82c105_bmdma_start - DMA engine begin * @qc: ATA command *
@@ -242,55 +187,6 @@ static struct ata_port_operations sl82c1 .prereset = sl82c105_pre_reset, }; -/** -* sl82c105_bridge_revision - find bridge version -* @pdev: PCI device for the ATA function -* -* Locates the PCI bridge associated with the ATA function and -* providing it is a Winbond 553 reports the revision. If it cannot -* find a revision or the right device it returns -1 -*/ - -static int sl82c105_bridge_revision (struct pci_dev *pdev) -{ -struct pci_dev *bridge; - -/* -* The bridge should be part of the same device, but function 0. -*/ - bridge =pci_get_slot (pdev->bus, -PCI_DEVFN (PCI_SLOT (pdev->devfn),0 )); -if (!bridge) -return -1 ; - -/* -* Make sure it is a Winbond 553 and is an ISA bridge. -*/ -if (bridge->vendor !=PCI_VENDOR_ID_WINBOND || - bridge->device !=PCI_DEVICE_ID_WINBOND_83C553 || - bridge->class >>8 !=PCI_CLASS_BRIDGE_ISA ) { -pci_dev_put (bridge); -return -1 ; - } -/* -* We need to find function 0's revision, not function 1 -*/ -pci_dev_put (bridge); -return bridge->revision; -} - -static int sl82c105_fixup (struct device *dev) -{ -struct pci_dev *pdev =to_pci_dev (dev); -u32 val; - -pci_read_config_dword (pdev,0x40 , &val); - val |=CTRL_P0EN |CTRL_P0F16 |CTRL_P1F16 ; -pci_write_config_dword (pdev,0x40 , val); - -return 0 ; -} -static int sl82c105_init_one (struct pci_dev *dev,const struct pci_device_id *id) {static const struct ata_port_info info_dma = {
drivers/ata/pata_sl82c105.h new file +106 -0
106 lines not on this page · raw message
PATCH 63/68 sl82c105: convert to ide2libata
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] sl82c105: convert to ide2libata
--- drivers/ata/pata_sl82c105.h | 4 + drivers/ide/sl82c105.c | 103 +++----------------------------------------- 2 files changed, 12 insertions(+), 95 deletions(-)
drivers/ata/pata_sl82c105.h +4 -0
@@ -27,13 +27,17 @@ static void sl82c105_configure_dmamode(sstatic u16 dma_timing[3 ] = {0x707 ,0x201 ,0x200 }; +#ifndef __IDE2LIBATAu16 dummy; +#endif int timing =0x44 + (8 * ap->port_no) + (4 * adev->devno);int dma = adev->dma_mode -XFER_MW_DMA_0 ;pci_write_config_word (pdev, timing, dma_timing[dma]); +#ifndef __IDE2LIBATA/* Can we lose this oddity of the old driver */ pci_read_config_word (pdev, timing, &dummy); +#endif }/**
drivers/ide/sl82c105.c +8 -95
153 lines not on this page · raw message
PATCH 64/68 pata_triflex: move code to be re-used by ide2libata to pata_triflex.h
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] pata_triflex: move code to be re-used by ide2libata to pata_triflex.h
--- drivers/ata/pata_triflex.c | 72 --------------------------------------------- drivers/ata/pata_triflex.h | 69 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 71 deletions(-)
drivers/ata/pata_triflex.c +1 -71
@@ -69,77 +69,7 @@ static int triflex_prereset(struct ata_lreturn ata_sff_prereset (link, deadline); } - - -/** -* triflex_load_timing - timing configuration -* @ap: ATA interface -* @adev: Device on the bus -* @speed: speed to configure -* -* The Triflex has one set of timings per device per channel. This -* means we must do some switching. As the PIO and DMA timings don't -* match we have to do some reloading unlike PIIX devices where tuning -* tricks can avoid it. -*/ - -static void triflex_load_timing (struct ata_port *ap,struct ata_device *adev,int speed) -{ -struct pci_dev *pdev =to_pci_dev (ap->host->dev); -u32 timing =0 ; -u32 triflex_timing, old_triflex_timing; -int channel_offset = ap->port_no ?0x74 :0x70 ; -unsigned int is_slave = (adev->devno !=0 ); - - -pci_read_config_dword (pdev, channel_offset, &old_triflex_timing); - triflex_timing = old_triflex_timing; - -switch (speed) - { -case XFER_MW_DMA_2 : - timing =0x0103 ;break ; -case XFER_MW_DMA_1 : - timing =0x0203 ;break ; -case XFER_MW_DMA_0 : - timing =0x0808 ;break ; -case XFER_SW_DMA_2 : -case XFER_SW_DMA_1 : -case XFER_SW_DMA_0 : - timing =0x0F0F ;break ; -case XFER_PIO_4 : - timing =0x0202 ;break ; -case XFER_PIO_3 : - timing =0x0204 ;break ; -case XFER_PIO_2 : - timing =0x0404 ;break ; -case XFER_PIO_1 : - timing =0x0508 ;break ; -case XFER_PIO_0 : - timing =0x0808 ;break ; -default : -BUG (); - } - triflex_timing &= ~ (0xFFFF << (16 * is_slave)); - triflex_timing |= (timing << (16 * is_slave)); - -if (triflex_timing != old_triflex_timing) -pci_write_config_dword (pdev, channel_offset, triflex_timing); -} - -/** -* triflex_set_piomode - set initial PIO mode data -* @ap: ATA interface -* @adev: ATA device -* -* Use the timing loader to set up the PIO mode. We have to do this -* because DMA start/stop will only be called once DMA occurs. If there -* has been no DMA then the PIO timings are still needed. -*/ -static void triflex_set_piomode (struct ata_port *ap,struct ata_device *adev) -{ -triflex_load_timing (ap, adev, adev->pio_mode); -} +#include "pata_triflex.h" /** * triflex_dma_start - DMA start callback
drivers/ata/pata_triflex.h new file +69 -0
69 lines not on this page · raw message
PATCH 65/68 triflex: convert to ide2libata
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] triflex: convert to ide2libata
--- drivers/ide/triflex.c | 57 +++++--------------------------------------------- 1 file changed, 6 insertions(+), 51 deletions(-)
drivers/ide/triflex.c +6 -51
@@ -34,62 +34,17 @@#define DRV_NAME "triflex" -static void triflex_set_mode (ide_hwif_t *hwif,ide_drive_t *drive) -{ -struct pci_dev *dev =to_pci_dev (hwif->dev); -u32 triflex_timings =0 ; -u16 timing =0 ; -u8 channel_offset = hwif->channel ?0x74 :0x70 , unit = drive->dn &1 ; - -pci_read_config_dword (dev, channel_offset, &triflex_timings); - -switch (drive->dma_mode) { -case XFER_MW_DMA_2 : - timing =0x0103 ; -break ; -case XFER_MW_DMA_1 : - timing =0x0203 ; -break ; -case XFER_MW_DMA_0 : - timing =0x0808 ; -break ; -case XFER_SW_DMA_2 : -case XFER_SW_DMA_1 : -case XFER_SW_DMA_0 : - timing =0x0f0f ; -break ; -case XFER_PIO_4 : - timing =0x0202 ; -break ; -case XFER_PIO_3 : - timing =0x0204 ; -break ; -case XFER_PIO_2 : - timing =0x0404 ; -break ; -case XFER_PIO_1 : - timing =0x0508 ; -break ; -case XFER_PIO_0 : - timing =0x0808 ; -break ; - } - - triflex_timings &= ~(0xFFFF << (16 * unit)); - triflex_timings |= (timing << (16 * unit)); - -pci_write_config_dword (dev, channel_offset, triflex_timings); -} +#include <linux/ide2libata.h> +#include "../ata/pata_triflex.h" -static void triflex_set_pio_mode (ide_hwif_t *hwif,ide_drive_t *drive) +static void triflex_set_dmamode (ide_hwif_t *hwif,ide_drive_t *drive) { - drive->dma_mode = drive->pio_mode; -triflex_set_mode (hwif, drive); +triflex_load_timing (hwif, drive, drive->dma_mode); }static const struct ide_port_ops triflex_port_ops = { - .set_pio_mode = triflex_set_pio_mode, - .set_dma_mode = triflex_set_mode, + .set_pio_mode = triflex_set_piomode, + .set_dma_mode = triflex_set_dmamode, };static const struct ide_port_info triflex_device__devinitdata = {
PATCH 66/68 pata_via: factor out code for finding ISA bridge
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] pata_via: factor out code for finding ISA bridge
--- drivers/ata/pata_via.c | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-)
drivers/ata/pata_via.c +23 -12
@@ -431,6 +431,28 @@ static struct ata_port_operations via_po .sff_data_xfer = ata_sff_data_xfer_noirq, }; +static const struct via_isa_bridge *via_config_find (void ) +{ +const struct via_isa_bridge *config; +struct pci_dev *isa; + +for (config = via_isa_bridges; config->id !=PCI_DEVICE_ID_VIA_ANON ; + config++) { + isa =pci_get_device (PCI_VENDOR_ID_VIA + + !!(config->flags &VIA_BAD_ID ), config->id,NULL ); +if (isa) { +u8 rev = isa->revision; + +pci_dev_put (isa); + +if (rev >= config->rev_min && rev <= config->rev_max) +break ; + } + } + +return config; +} +/** * via_config_fifo - set up the FIFO * @pdev: PCI device
@@ -544,7 +566,6 @@ static int via_init_one(struct pci_dev * .port_ops = &via_port_ops };const struct ata_port_info *ppi[] = {NULL ,NULL }; -struct pci_dev *isa;const struct via_isa_bridge *config;static int printed_version;u8 enable;
@@ -563,17 +584,7 @@ static int via_init_one(struct pci_dev */* To find out how the IDE will behave and what features we actually have to look at the bridge not the IDE controller */ -for (config = via_isa_bridges; config->id !=PCI_DEVICE_ID_VIA_ANON ; - config++) -if ((isa =pci_get_device (PCI_VENDOR_ID_VIA + - !!(config->flags &VIA_BAD_ID ), - config->id,NULL ))) { -u8 rev = isa->revision; -pci_dev_put (isa); - -if (rev >= config->rev_min && rev <= config->rev_max) -break ; - } + config =via_config_find ();if (!(config->flags &VIA_NO_ENABLES )) {/* 0x40 low bits indicate enabled channels */
PATCH 67/68 pata_via: move code to be re-used by ide2libata to pata_via.h
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] pata_via: move code to be re-used by ide2libata to pata_via.h
--- drivers/ata/pata_via.c | 237 ----------------------------------------------- drivers/ata/pata_via.h | 242 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 242 insertions(+), 237 deletions(-)
drivers/ata/pata_via.c +0 -237
@@ -64,64 +64,6 @@#define DRV_NAME "pata_via"#define DRV_VERSION "0.3.4" -enum { -VIA_BAD_PREQ =0x01 ,/* Crashes if PREQ# till DDACK# set */ -VIA_BAD_CLK66 =0x02 ,/* 66 MHz clock doesn't work correctly */ -VIA_SET_FIFO =0x04 ,/* Needs to have FIFO split set */ -VIA_NO_UNMASK =0x08 ,/* Doesn't work with IRQ unmasking on */ -VIA_BAD_ID =0x10 ,/* Has wrong vendor ID (0x1107) */ -VIA_BAD_AST =0x20 ,/* Don't touch Address Setup Timing */ -VIA_NO_ENABLES =0x40 ,/* Has no enablebits */ -VIA_SATA_PATA =0x80 ,/* SATA/PATA combined configuration */ -}; - -enum { -VIA_IDFLAG_SINGLE = (1 <<0 ),/* single channel controller) */ -}; - -/* -* VIA SouthBridge chips. -*/ - -static const struct via_isa_bridge { -const char *name; -u16 id; -u8 rev_min; -u8 rev_max; -u8 udma_mask; -u8 flags; -} via_isa_bridges[] = { - {"vx855" ,PCI_DEVICE_ID_VIA_VX855 ,0x00 ,0x2f ,ATA_UDMA6 ,VIA_BAD_AST |VIA_SATA_PATA }, - {"vx800" ,PCI_DEVICE_ID_VIA_VX800 ,0x00 ,0x2f ,ATA_UDMA6 ,VIA_BAD_AST |VIA_SATA_PATA }, - {"vt8261" ,PCI_DEVICE_ID_VIA_8261 ,0x00 ,0x2f ,ATA_UDMA6 ,VIA_BAD_AST }, - {"vt8237s" ,PCI_DEVICE_ID_VIA_8237S ,0x00 ,0x2f ,ATA_UDMA6 ,VIA_BAD_AST }, - {"vt8251" ,PCI_DEVICE_ID_VIA_8251 ,0x00 ,0x2f ,ATA_UDMA6 ,VIA_BAD_AST }, - {"cx700" ,PCI_DEVICE_ID_VIA_CX700 ,0x00 ,0x2f ,ATA_UDMA6 ,VIA_BAD_AST |VIA_SATA_PATA }, - {"vt6410" ,PCI_DEVICE_ID_VIA_6410 ,0x00 ,0x2f ,ATA_UDMA6 ,VIA_BAD_AST |VIA_NO_ENABLES }, - {"vt6415" ,PCI_DEVICE_ID_VIA_6415 ,0x00 ,0xff ,ATA_UDMA6 ,VIA_BAD_AST |VIA_NO_ENABLES }, - {"vt8237a" ,PCI_DEVICE_ID_VIA_8237A ,0x00 ,0x2f ,ATA_UDMA6 ,VIA_BAD_AST }, - {"vt8237" ,PCI_DEVICE_ID_VIA_8237 ,0x00 ,0x2f ,ATA_UDMA6 ,VIA_BAD_AST }, - {"vt8235" ,PCI_DEVICE_ID_VIA_8235 ,0x00 ,0x2f ,ATA_UDMA6 ,VIA_BAD_AST }, - {"vt8233a" ,PCI_DEVICE_ID_VIA_8233A ,0x00 ,0x2f ,ATA_UDMA6 ,VIA_BAD_AST }, - {"vt8233c" ,PCI_DEVICE_ID_VIA_8233C_0 ,0x00 ,0x2f ,ATA_UDMA5 , }, - {"vt8233" ,PCI_DEVICE_ID_VIA_8233_0 ,0x00 ,0x2f ,ATA_UDMA5 , }, - {"vt8231" ,PCI_DEVICE_ID_VIA_8231 ,0x00 ,0x2f ,ATA_UDMA5 , }, - {"vt82c686b" ,PCI_DEVICE_ID_VIA_82C686 ,0x40 ,0x4f ,ATA_UDMA5 , }, - {"vt82c686a" ,PCI_DEVICE_ID_VIA_82C686 ,0x10 ,0x2f ,ATA_UDMA4 , }, - {"vt82c686" ,PCI_DEVICE_ID_VIA_82C686 ,0x00 ,0x0f ,ATA_UDMA2 ,VIA_BAD_CLK66 }, - {"vt82c596b" ,PCI_DEVICE_ID_VIA_82C596 ,0x10 ,0x2f ,ATA_UDMA4 , }, - {"vt82c596a" ,PCI_DEVICE_ID_VIA_82C596 ,0x00 ,0x0f ,ATA_UDMA2 ,VIA_BAD_CLK66 }, - {"vt82c586b" ,PCI_DEVICE_ID_VIA_82C586_0 ,0x47 ,0x4f ,ATA_UDMA2 ,VIA_SET_FIFO }, - {"vt82c586b" ,PCI_DEVICE_ID_VIA_82C586_0 ,0x40 ,0x46 ,ATA_UDMA2 ,VIA_SET_FIFO |VIA_BAD_PREQ }, - {"vt82c586b" ,PCI_DEVICE_ID_VIA_82C586_0 ,0x30 ,0x3f ,ATA_UDMA2 ,VIA_SET_FIFO }, - {"vt82c586a" ,PCI_DEVICE_ID_VIA_82C586_0 ,0x20 ,0x2f ,ATA_UDMA2 ,VIA_SET_FIFO }, - {"vt82c586" ,PCI_DEVICE_ID_VIA_82C586_0 ,0x00 ,0x0f ,0x00 ,VIA_SET_FIFO }, - {"vt82c576" ,PCI_DEVICE_ID_VIA_82C576 ,0x00 ,0x2f ,0x00 ,VIA_SET_FIFO |VIA_NO_UNMASK }, - {"vt82c576" ,PCI_DEVICE_ID_VIA_82C576 ,0x00 ,0x2f ,0x00 ,VIA_SET_FIFO |VIA_NO_UNMASK |VIA_BAD_ID }, - {"vtxxxx" ,PCI_DEVICE_ID_VIA_ANON ,0x00 ,0x2f ,ATA_UDMA6 ,VIA_BAD_AST }, - {NULL } -}; -struct via_port {u8 cached_device; };
@@ -188,108 +130,6 @@ static int via_pre_reset(struct ata_linkreturn ata_sff_prereset (link, deadline); } - -/** -* via_do_set_mode - set transfer mode data -* @ap: ATA interface -* @adev: ATA device -* @mode: ATA mode being programmed -* @set_ast: Set to program address setup -* @udma_type: UDMA mode/format of registers -* -* Program the VIA registers for DMA and PIO modes. Uses the ata timing -* support in order to compute modes. -* -* FIXME: Hotplug will require we serialize multiple mode changes -* on the two channels. -*/ - -static void via_do_set_mode (struct ata_port *ap,struct ata_device *adev, -int mode,int set_ast,int udma_type) -{ -struct pci_dev *pdev =to_pci_dev (ap->host->dev); -struct ata_device *peer =ata_dev_pair (adev); -struct ata_timing t, p; -static int via_clock =33333 ;/* Bus clock in kHZ */ -unsigned long T =1000000000 / via_clock; -unsigned long UT =T ; -int ut; -int offset =3 - (2 *ap->port_no) - adev->devno; - -switch (udma_type) { -case ATA_UDMA4 : -UT =T /2 ;break ; -case ATA_UDMA5 : -UT =T /3 ;break ; -case ATA_UDMA6 : -UT =T /4 ;break ; - } - -/* Calculate the timing values we require */ -ata_timing_compute (adev->id, mode, adev->pio_mode, &t,T ,UT ); - -/* We share 8bit timing so we must merge the constraints */ -if (peer) { -if (peer->pio_mode) { -ata_timing_compute (peer->id, peer->pio_mode, - peer->pio_mode, &p,T ,UT ); -ata_timing_merge (&p, &t, &t,ATA_TIMING_8BIT ); - } - } - -/* Address setup is programmable but breaks on UDMA133 setups */ -if (set_ast) { -u8 setup;/* 2 bits per drive */ -int shift =2 * offset; - -pci_read_config_byte (pdev,0x4C , &setup); - setup &= ~(3 << shift); - setup |= (clamp_val (t.setup,1 ,4 ) -1 ) << shift; -pci_write_config_byte (pdev,0x4C , setup); - } - -/* Load the PIO mode bits */ -pci_write_config_byte (pdev,0x4F - ap->port_no, - ((clamp_val (t.act8b,1 ,16 ) -1 ) <<4 ) | (clamp_val (t.rec8b,1 ,16 ) -1 )); -pci_write_config_byte (pdev,0x48 + offset, - ((clamp_val (t.active,1 ,16 ) -1 ) <<4 ) | (clamp_val (t.recover,1 ,16 ) -1 )); - -/* Load the UDMA bits according to type */ -switch (udma_type) { -case ATA_UDMA2 : -default : - ut = t.udma ? (0xe0 | (clamp_val (t.udma,2 ,5 ) -2 )) :0x03 ; -break ; -case ATA_UDMA4 : - ut = t.udma ? (0xe8 | (clamp_val (t.udma,2 ,9 ) -2 )) :0x0f ; -break ; -case ATA_UDMA5 : - ut = t.udma ? (0xe0 | (clamp_val (t.udma,2 ,9 ) -2 )) :0x07 ; -break ; -case ATA_UDMA6 : - ut = t.udma ? (0xe0 | (clamp_val (t.udma,2 ,9 ) -2 )) :0x07 ; -break ; - } - -/* Set UDMA unless device is not UDMA capable */ -if (udma_type) { -u8 udma_etc; - -pci_read_config_byte (pdev,0x50 + offset, &udma_etc); - -/* clear transfer mode bit */ - udma_etc &= ~0x20 ; - -if (t.udma) { -/* preserve 80-wire cable detection bit */ - udma_etc &=0x10 ; - udma_etc |= ut; - } - -pci_write_config_byte (pdev,0x50 + offset, udma_etc); - } -} -static void via_set_piomode (struct ata_port *ap,struct ata_device *adev) {const struct via_isa_bridge *config = ap->host->private_data;
@@ -431,83 +271,6 @@ static struct ata_port_operations via_po .sff_data_xfer = ata_sff_data_xfer_noirq, }; -static const struct via_isa_bridge *via_config_find (void ) -{ -const struct via_isa_bridge *config; -struct pci_dev *isa; - -for (config = via_isa_bridges; config->id !=PCI_DEVICE_ID_VIA_ANON ; - config++) { - isa =pci_get_device (PCI_VENDOR_ID_VIA + - !!(config->flags &VIA_BAD_ID ), config->id,NULL ); -if (isa) { -u8 rev = isa->revision; - -pci_dev_put (isa); - -if (rev >= config->rev_min && rev <= config->rev_max) -break ; - } - } - -return config; -} - -/** -* via_config_fifo - set up the FIFO -* @pdev: PCI device -* @flags: configuration flags -* -* Set the FIFO properties for this device if necessary. Used both on -* set up and on and the resume path -*/ - -static void via_config_fifo (struct pci_dev *pdev,unsigned int flags) -{ -u8 enable; - -/* 0x40 low bits indicate enabled channels */ -pci_read_config_byte (pdev,0x40 , &enable); - enable &=3 ; - -if (flags &VIA_SET_FIFO ) { -static const u8 fifo_setting[4 ] = {0x00 ,0x60 ,0x00 ,0x20 }; -u8 fifo; - -pci_read_config_byte (pdev,0x43 , &fifo); - -/* Clear PREQ# until DDACK# for errata */ -if (flags &VIA_BAD_PREQ ) - fifo &=0x7F ; -else - fifo &=0x9f ; -/* Turn on FIFO for enabled channels */ - fifo |= fifo_setting[enable]; -pci_write_config_byte (pdev,0x43 , fifo); - } -} - -static void via_fixup (struct pci_dev *pdev,const struct via_isa_bridge *config) -{ -u32 timing; - -/* Initialise the FIFO for the enabled channels. */ -via_config_fifo (pdev, config->flags); - -if (config->udma_mask ==ATA_UDMA4 ) { -/* The 66 MHz devices require we enable the clock */ -pci_read_config_dword (pdev,0x50 , &timing); - timing |=0x80008 ; -pci_write_config_dword (pdev,0x50 , timing); - } -if (config->flags &VIA_BAD_CLK66 ) { -/* Disable the 66MHz clock on problem devices */ -pci_read_config_dword (pdev,0x50 , &timing); - timing &= ~0x80008 ; -pci_write_config_dword (pdev,0x50 , timing); - } -} -/** * via_init_one - discovery callback * @pdev: PCI device
drivers/ata/pata_via.h +242 -0
249 lines not on this page · raw message
PATCH 68/68 via82cxxx: convert to ide2libata
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] via82cxxx: convert to ide2libata
--- drivers/ata/pata_via.h | 8 - drivers/ide/via82cxxx.c | 261 ++++-------------------------------------------- 2 files changed, 28 insertions(+), 241 deletions(-)
drivers/ata/pata_via.h +3 -5
@@ -1,5 +1,4 @@ -#ifdef __LINUX_LIBATA_H__enum {VIA_BAD_PREQ =0x01 ,/* Crashes if PREQ# till DDACK# set */ VIA_BAD_CLK66 =0x02 ,/* 66 MHz clock doesn't work correctly */
@@ -12,7 +11,7 @@ enum { };enum { -VIA_IDFLAG_SINGLE = (1 <<0 ),/* single channel controller */ +VIA_IDFLAG_SINGLE = (1 <<1 ),/* single channel controller */ };/*
@@ -57,7 +56,6 @@ static const struct via_isa_bridge { { "vtxxxx", PCI_DEVICE_ID_VIA_ANON, 0x00, 0x2f, ATA_UDMA6, VIA_BAD_AST }, { NULL } }; -#endif #include <linux/dmi.h>
@@ -88,7 +86,6 @@ static int via_cable_override(struct pcireturn 0 ; } -#ifdef __LINUX_LIBATA_H__/** * via_do_set_mode - set transfer mode data * @ap: ATA interface
@@ -110,7 +107,9 @@ static void via_do_set_mode(struct ata_pstruct pci_dev *pdev =to_pci_dev (ap->host->dev);struct ata_device *peer =ata_dev_pair (adev);struct ata_timing t, p; +#ifndef __IDE2LIBATAstatic int via_clock =33333 ;/* Bus clock in kHZ */ +#endif unsigned long T =1000000000 / via_clock;unsigned long UT =T ;int ut;
@@ -268,4 +267,3 @@ static void via_fixup(struct pci_dev *pdpci_write_config_dword (pdev,0x50 , timing); } } -#endif
drivers/ide/via82cxxx.c +25 -236
329 lines not on this page · raw message
Quoted 13 lines · Bartlomiej Zolnierkiewicz
Hi,
Here is a patchset (on top of atang-v3.1 tree) applying "out-of-the-box" thinking to duplicated libata PATA and IDE subsystem host driver sets. Namely, it modifies IDE API slightly to match libata's one more, adds a tiny source-code level translation layer (
ide2libata.hheader file which consists of only 17 lines of code) and then converts host drivers to use shared source code for low-level operations (all drivers have been carefully audited during porting to minimize the probability of adding regressions accidentally). As an end result it is much easier to maintain both driver sets (differences between 'new'/'old' drivers are now apparent and there is no longer a need to manually back-port many classes of bugfixes) and over 2500 LOC are gone.
Interesting.
I'm fine with applying patches 2-5, but I am definitely interested to hear what others think about this. Clearly, LOC is reduced, but that's not the only factor in code maintenance.
With regards to libata and old-IDE, I have always thought the ideal scenario was to leave old-IDE in bugfix-only mode, with next-to-no API or driver churn besides that which is absolutely required for the fix.
En masse backporting bug fixes is what's known as a one-time cost. Once the majority of libata PATA drivers reach bugfix and feature parity, the need for code sharing is reduced greatly.
The ide2libata proposal creates on-going costs, not just a one-time cost, because the old-IDE drivers will have -increased- potential for problems when a libata PATA driver is modified. Such is the -cost- of heavily intertwined code sharing. A single header change implies that two, not one, drivers might break. That weakens the "leave it alone" stability promise of old-IDE.
Waiting for other comments... this patchset is not an onerous burden to libata, but I think it creates nasty cross-tree issues, potentially perturbing old-IDE.
Jeff
Quoted 29 lines · Jeff Garzik
Quoted 13 lines · Bartlomiej Zolnierkiewicz
Hi,
Here is a patchset (on top of atang-v3.1 tree) applying "out-of-the-box" thinking to duplicated libata PATA and IDE subsystem host driver sets. Namely, it modifies IDE API slightly to match libata's one more, adds a tiny source-code level translation layer (
ide2libata.hheader file which consists of only 17 lines of code) and then converts host drivers to use shared source code for low-level operations (all drivers have been carefully audited during porting to minimize the probability of adding regressions accidentally). As an end result it is much easier to maintain both driver sets (differences between 'new'/'old' drivers are now apparent and there is no longer a need to manually back-port many classes of bugfixes) and over 2500 LOC are gone.Interesting.
I'm fine with applying patches 2-5, but I am definitely interested to hear what others think about this. Clearly, LOC is reduced, but that's not the only factor in code maintenance.
With regards to libata and old-IDE, I have always thought the ideal scenario was to leave old-IDE in bugfix-only mode, with next-to-no API or driver churn besides that which is absolutely required for the fix.
En masse backporting bug fixes is what's known as a one-time cost. Once the majority of libata PATA drivers reach bugfix and feature parity, the need for code sharing is reduced greatly.
Quoted 6 lines
The ide2libata proposal creates on-going costs, not just a one-time cost, because the old-IDE drivers will have -increased- potential for problems when a libata PATA driver is modified. Such is the -cost- of heavily intertwined code sharing. A single header change implies that two, not one, drivers might break. That weakens the "leave it alone" stability promise of old-IDE.
I understand your concerns (especially given that libata PATA drivers are unmaintained) but this patchset is for atang tree which is what I use personally and I have no problem with maintaining it as long as I find it useful (porting few hundreds patches once in few months against upstream is much cheaper in terms of time/sanity than obligatory discussions on whether to document known end-user visible limitations in driver's Kconfig help text or in driver's source code how etc.).
Starting with 2.6.33 kernel.org users will be covered with a dedicated patch and if distribution users want some changes that are in atang they should ping their distribution about it, not me (if some distribution would like to pay for the work on integrating some changes and/or getting other ATA changes integrated please contact me in private).
IOW I'm just doing what I find useful/interesting for me and I don't care much personally if it ever reaches upstream. I post patches mainly for an extra review and to prevent duplication of efforts. If people find them useful, great. If not, well, not a big deal (having 2000 commits upstream changes a perspective a bit)..
Quoted 3 lines
Waiting for other comments... this patchset is not an onerous burden to libata, but I think it creates nasty cross-tree issues, potentially perturbing old-IDE.
I'm rather time constrained these days so I think that I'll skip such type of discussion entirely (though technical comments like bugs in patches etc. are warmly welcomed and appreciated)..
--
Bartlomiej Zolnierkiewicz
Quoted 3 lines
I'm fine with applying patches 2-5, but I am definitely interested to hear what others think about this. Clearly, LOC is reduced, but that's not the only factor in code maintenance.
I think it will be a nightmare for maintenance with all the includes and the like plus the ifdefs making it very hard to read the drivers and maintain them.
Some of it could be cleanly split. The 40wire lists for example could all be merged into one with a function taking the pci_dev of the controller which did a lookup based on vendor/dev/svid/sdid. That would put them all in one logical clean C file and makes sense as a split point for the code.
Quoted 3 lines
En masse backporting bug fixes is what's known as a one-time cost. Once the majority of libata PATA drivers reach bugfix and feature parity, the need for code sharing is reduced greatly.
One problem is telling which of the bits in the old IDE stack are
- bug fixes
- bugs
- cargo culting
- irrelevant
So I think its an extremely useful exercise to figure out what subtle differences there are between the drivers. It's not then a trivial assumption that they can just be pasted over. The include stuff though is too ugly to merge even if its an excellent research project to identify the differences and quirks.
The old IDE "maintenance mode" seems to be drifting - the rate of change is rather high for that claim.
Alan
Quoted 3 lines · Alan Cox
So I think its an extremely useful exercise to figure out what subtle differences there are between the drivers. It's not then a trivial assumption that they can just be pasted over. The include stuff though is
Fully agreed, that is why a fair deal of review work went into making sure that porting of a each driver to ide2libata doesn't cause functionality changes.
Quoted 2 lines
too ugly to merge even if its an excellent research project to identify the differences and quirks.
Well, looks acceptable to me when the alternative is a duplicated code (though I don't insists on getting it merged anyway)..
--
Bartlomiej Zolnierkiewicz
From: Alan Cox <[email protected]>
Date: Fri, 29 Jan 2010 23:25:40 +0000
Quoted 2 lines
The old IDE "maintenance mode" seems to be drifting - the rate of change is rather high for that claim.
I think there's another angle to this.
By making the IDE layer build from the same code as the ATA driver, the legacy IDE layer gets an indirect tester base.
I like that.
However what I don't like is how this is implemented. We shouldn't pretend the data structures are the same by using macros in some header file, we should truly abstract out the data types properly such that these drivers in fact use the same datastructures.
For the price of a few series of data structure morphs, we eliminate the tester-base issue of legacy IDE. There's one driver for both ATA and legacy IDE, the stuff in front is just a presentation and probing layer, nothing more.
The cost and risk is testing the morphing changes, but I think the scales tip towards making this truly worth it.
Bart, thanks for working on this and publishing what you came up with.
Quoted 4 lines · David Miller
However what I don't like is how this is implemented. We shouldn't pretend the data structures are the same by using macros in some header file, we should truly abstract out the data types properly such that these drivers in fact use the same datastructures.
The hardest part is done and the idea is proved so this indeed would be a natural next step..
Quoted 4 lines
For the price of a few series of data structure morphs, we eliminate the tester-base issue of legacy IDE. There's one driver for both ATA and legacy IDE, the stuff in front is just a presentation and probing layer, nothing more.
Hmm.. sounds exactly like the direction in which IDE has been going for the last few years.. :)
--
Bartlomiej Zolnierkiewicz
Quoted 2 lines
The cost and risk is testing the morphing changes, but I think the scales tip towards making this truly worth it.
The cost and risk is taking two stable and quite maintainable stacks and turning them into one unmaintainable broken one..
I'm a little surprised that the old IDE layer which was supposed to be maintenance only is getting this treatment - except for the research value of seeing what the differences are in the drivers.
I'm amazed that you'd suggest trashing the current ATA stack to make the maintenance of the old ones easier - which aren't supposed to be in flux in the first place.
Alan
From: Alan Cox <[email protected]>
Date: Mon, 1 Feb 2010 11:07:23 +0000
Quoted 3 lines
I'm amazed that you'd suggest trashing the current ATA stack to make the maintenance of the old ones easier - which aren't supposed to be in flux in the first place.
I'm not, I'm saying leave the ATA stack as it is, but make the IDE legacy layer such that PATA drivers can compile into it.
Quoted 9 lines · On Mon, 01 Feb 2010 03:17:25 -0800 (PST) David Miller <[email protected]>…
From: Alan Cox <[email protected]>
Date: Mon, 1 Feb 2010 11:07:23 +0000Quoted 3 lines
I'm amazed that you'd suggest trashing the current ATA stack to make the maintenance of the old ones easier - which aren't supposed to be in flux in the first place.
I'm not, I'm saying leave the ATA stack as it is, but make the IDE legacy layer such that PATA drivers can compile into it.
I don't see the use of that either. The work has sone use in figuring out what the technical differences are between the old and new, and to review differences to see why the exist and if they matter.
The only way around that would actually be remotely useful for doing odd debug checks would be the ability to run the old stack drivers under libata. Even then it would probably be far simpler to move differences over one by one and test them so as to understand what is actually going on and fix a bug.
The old drivers contain a fair amount of crap, magic and gueswork so a good deal of human analysis and testing is needed to move any change around and prove it's real and valid not guesswork and fudging.
Alan
From: Alan Cox <[email protected]>
Date: Mon, 1 Feb 2010 11:48:24 +0000
Quoted 10 lines
Quoted 7 lines · On Mon, 01 Feb 2010 03:17:25 -0800 (PST) David Miller <[email protected]>…
From: Alan Cox <[email protected]>
Date: Mon, 1 Feb 2010 11:07:23 +0000Quoted 3 lines
I'm amazed that you'd suggest trashing the current ATA stack to make the maintenance of the old ones easier - which aren't supposed to be in flux in the first place.
Quoted 6 lines
Quoted 2 lines
I'm not, I'm saying leave the ATA stack as it is, but make the IDE legacy layer such that PATA drivers can compile into it.
I don't see the use of that either. The work has sone use in figuring out what the technical differences are between the old and new, and to review differences to see why the exist and if they matter.
And if you find the differences and that they matter, what are you going to do, only fix things in one direction?
That won't make any sense.
And if the goal is to sort things out and keep things in sync, what better way than to keep then physically in sync?
Quoted 3 lines
The old drivers contain a fair amount of crap, magic and gueswork so a good deal of human analysis and testing is needed to move any change around and prove it's real and valid not guesswork and fudging.
And then once that hard work is done, we kind of just toss it for one side of the equation?
Quoted 6 lines
Quoted 3 lines
The old drivers contain a fair amount of crap, magic and gueswork so a good deal of human analysis and testing is needed to move any change around and prove it's real and valid not guesswork and fudging.
And then once that hard work is done, we kind of just toss it for one side of the equation?
I don't where you got that idea from.
The "merge" makes it harder to maintain both, adds lots of ifdefs and artificial divisions of code stuffed into include files. Its ugly as sin and makes *both* sets of drivers harder to maintain.
So it's quite clearly cheaper and more efficient to propogate any relevant fixes both directions than produce a single ifdef and include filled turdpile that can't be maintained at all. It's not as if either set of drivers change on a regular basis.
Plus I'd point out the calling patterns, locking and the assumptions of the two stacks are not quite the same. There are also things the old stack can't do (eg hotplug, queued commands, intelligent serializing of command sequences) or that the current stack can't do (generally because they make no sense moving forward but also stuff like user issued SETXFER snooping)
Alan
From: Alan Cox <[email protected]>
Date: Mon, 1 Feb 2010 12:58:45 +0000
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
The old drivers contain a fair amount of crap, magic and gueswork so a good deal of human analysis and testing is needed to move any change around and prove it's real and valid not guesswork and fudging.
Quoted 8 lines
Quoted 2 lines
And then once that hard work is done, we kind of just toss it for one side of the equation?
I don't where you got that idea from.
The "merge" makes it harder to maintain both, adds lots of ifdefs and artificial divisions of code stuffed into include files. Its ugly as sin and makes *both* sets of drivers harder to maintain.
I have not advocated the ifdef implementation.
I have advocated one where the data structures are actually the same, and there are no ifdefs.
Please reread my initial reply.
Quoted 2 lines · David Miller
And then once that hard work is done, we kind of just toss it for one side of the equation?
[...]
Quoted 4 lines · David Miller
I have not advocated the ifdef implementation.
I have advocated one where the data structures are actually the same, and there are no ifdefs.
It all sounds like the exact opposite of what you said seven months ago:
I'm going to treat IDE as pure legacy, rather than as competition with the PATA drivers which is what people whould be moving over to.
And more importantly I refuse to apply any driver patch that isn't actually tested on said hardware.
It's either legacy, or it isn't. It's either bug-fixes-only, or it isn't. Touching, quite literally, _100%_ of the IDE drivers does not meet the criteria of "pure legacy" nor likely "actually tested on said hardware."
But hey... if you want to accept patches slowly turning IDE into libata, that's your call :) It just seems quite contrary to what has been sold to the remaining IDE users.
Jeff
From: Jeff Garzik <[email protected]>
Date: Tue, 02 Feb 2010 18:10:07 -0500
Quoted 3 lines
But hey... if you want to accept patches slowly turning IDE into libata, that's your call :) It just seems quite contrary to what has been sold to the remaining IDE users.
What I said back then was based upon the presumption that the drivers has a small tester base, thus any change to any particular driver isn't likely to get much testing.
If the drivers get truly shared between IDE and ATA, that presumption is entirely removed, the ATA testers will be hitting the same driver code that whatever remaining IDE users will be.
So if the sharing can be done in a sane manner, I'm OK with that kind of plan.
What Bart has posted with all of the ifdefs and stuff, I've stated over and over I don't agree with and don't think is sane.
Doing it by making the data structures actually be the same, and not using any ifdefs, that would be sane to me.
Quoted 4 lines
If the drivers get truly shared between IDE and ATA, that presumption is entirely removed, the ATA testers will be hitting the same driver code that whatever remaining IDE users will be.
Assuming the data structures matching does that is a bit like assuming you can test one TCP stack using another one because they use the same packet format.
From: Alan Cox <[email protected]>
Date: Tue, 2 Feb 2010 23:27:48 +0000
Quoted 8 lines
Quoted 4 lines
If the drivers get truly shared between IDE and ATA, that presumption is entirely removed, the ATA testers will be hitting the same driver code that whatever remaining IDE users will be.
Assuming the data structures matching does that is a bit like assuming you can test one TCP stack using another one because they use the same packet format.
I don't really think those two situations are the same.
And Bart's patch set show that things are pretty darn close already.