diff options
author | Sergei Shtylyov <sshtylyov@ru.mvista.com> | 2010-05-07 14:47:50 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@redhat.com> | 2010-05-14 17:35:52 -0400 |
commit | 41dec29bcb05eb8ec396f70ce791c6e3e4ce4712 (patch) | |
tree | e76f63519031769e848dcc6eba63c9207cf4d84e /drivers/ata/libata-sff.c | |
parent | 55787183ade44c4f826f581a068f52a1a80c6a2e (diff) |
libata: introduce sff_set_devctl() method
The set of libata's taskfile access methods is clearly incomplete as
it lacks a method to write to the device control register -- which
forces drivers like 'pata_bf54x' and 'pata_scc' to implement more
"high level" (and more weighty) methods like freeze() and postreset().
So, introduce the optional sff_set_devctl() method which the drivers
only have to implement if the standard iowrite8() can't be used (just
like the existing sff_check_altstatus() method) and make use of it
in the freeze() and postreset() method implementations (I could also
have used it in softreset() method but it also reads other taskfile
registers without using tf_read() making that quite pointless);
this makes freeze() method implementations in the 'pata_bf54x' and
'pata_scc' methods virtually identical to ata_sff_freeze(), so we
can get rid of them completely.
Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/ata/libata-sff.c')
-rw-r--r-- | drivers/ata/libata-sff.c | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c index b31389605be..31b495fcd96 100644 --- a/drivers/ata/libata-sff.c +++ b/drivers/ata/libata-sff.c | |||
@@ -446,6 +446,27 @@ int ata_sff_wait_ready(struct ata_link *link, unsigned long deadline) | |||
446 | EXPORT_SYMBOL_GPL(ata_sff_wait_ready); | 446 | EXPORT_SYMBOL_GPL(ata_sff_wait_ready); |
447 | 447 | ||
448 | /** | 448 | /** |
449 | * ata_sff_set_devctl - Write device control reg | ||
450 | * @ap: port where the device is | ||
451 | * @ctl: value to write | ||
452 | * | ||
453 | * Writes ATA taskfile device control register. | ||
454 | * | ||
455 | * Note: may NOT be used as the sff_set_devctl() entry in | ||
456 | * ata_port_operations. | ||
457 | * | ||
458 | * LOCKING: | ||
459 | * Inherited from caller. | ||
460 | */ | ||
461 | static void ata_sff_set_devctl(struct ata_port *ap, u8 ctl) | ||
462 | { | ||
463 | if (ap->ops->sff_set_devctl) | ||
464 | ap->ops->sff_set_devctl(ap, ctl); | ||
465 | else | ||
466 | iowrite8(ctl, ap->ioaddr.ctl_addr); | ||
467 | } | ||
468 | |||
469 | /** | ||
449 | * ata_sff_dev_select - Select device 0/1 on ATA bus | 470 | * ata_sff_dev_select - Select device 0/1 on ATA bus |
450 | * @ap: ATA channel to manipulate | 471 | * @ap: ATA channel to manipulate |
451 | * @device: ATA device (numbered from zero) to select | 472 | * @device: ATA device (numbered from zero) to select |
@@ -1895,13 +1916,11 @@ EXPORT_SYMBOL_GPL(ata_sff_lost_interrupt); | |||
1895 | */ | 1916 | */ |
1896 | void ata_sff_freeze(struct ata_port *ap) | 1917 | void ata_sff_freeze(struct ata_port *ap) |
1897 | { | 1918 | { |
1898 | struct ata_ioports *ioaddr = &ap->ioaddr; | ||
1899 | |||
1900 | ap->ctl |= ATA_NIEN; | 1919 | ap->ctl |= ATA_NIEN; |
1901 | ap->last_ctl = ap->ctl; | 1920 | ap->last_ctl = ap->ctl; |
1902 | 1921 | ||
1903 | if (ioaddr->ctl_addr) | 1922 | if (ap->ops->sff_set_devctl || ap->ioaddr.ctl_addr) |
1904 | iowrite8(ap->ctl, ioaddr->ctl_addr); | 1923 | ata_sff_set_devctl(ap, ap->ctl); |
1905 | 1924 | ||
1906 | /* Under certain circumstances, some controllers raise IRQ on | 1925 | /* Under certain circumstances, some controllers raise IRQ on |
1907 | * ATA_NIEN manipulation. Also, many controllers fail to mask | 1926 | * ATA_NIEN manipulation. Also, many controllers fail to mask |
@@ -2301,8 +2320,8 @@ void ata_sff_postreset(struct ata_link *link, unsigned int *classes) | |||
2301 | } | 2320 | } |
2302 | 2321 | ||
2303 | /* set up device control */ | 2322 | /* set up device control */ |
2304 | if (ap->ioaddr.ctl_addr) { | 2323 | if (ap->ops->sff_set_devctl || ap->ioaddr.ctl_addr) { |
2305 | iowrite8(ap->ctl, ap->ioaddr.ctl_addr); | 2324 | ata_sff_set_devctl(ap, ap->ctl); |
2306 | ap->last_ctl = ap->ctl; | 2325 | ap->last_ctl = ap->ctl; |
2307 | } | 2326 | } |
2308 | } | 2327 | } |