diff options
author | Tejun Heo <htejun@gmail.com> | 2007-12-18 02:33:05 -0500 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2008-01-23 05:24:12 -0500 |
commit | a0f79b929acaba10d4780acd2543eff20bf4b5b0 (patch) | |
tree | e637c1d9388a3991cd71c5be339c2ead59c460a2 /drivers/ata/libata-core.c | |
parent | 5df91a25df08d85700fef5fd59bb1873273e5ef5 (diff) |
libata: implement ata_timing_cycle2mode() and use it in libata-acpi and pata_acpi
libata-acpi is using separate timing tables for transfer modes
although libata-core has the complete ata_timing table. Implement
ata_timing_cycle2mode() to look for matching mode given transfer type
and cycle duration and use it in libata-acpi and pata_acpi to replace
private timing tables.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/ata/libata-core.c')
-rw-r--r-- | drivers/ata/libata-core.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 62c4b328b0b6..f01c1734b1d0 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c | |||
@@ -2903,6 +2903,57 @@ int ata_timing_compute(struct ata_device *adev, unsigned short speed, | |||
2903 | } | 2903 | } |
2904 | 2904 | ||
2905 | /** | 2905 | /** |
2906 | * ata_timing_cycle2mode - find xfer mode for the specified cycle duration | ||
2907 | * @xfer_shift: ATA_SHIFT_* value for transfer type to examine. | ||
2908 | * @cycle: cycle duration in ns | ||
2909 | * | ||
2910 | * Return matching xfer mode for @cycle. The returned mode is of | ||
2911 | * the transfer type specified by @xfer_shift. If @cycle is too | ||
2912 | * slow for @xfer_shift, 0xff is returned. If @cycle is faster | ||
2913 | * than the fastest known mode, the fasted mode is returned. | ||
2914 | * | ||
2915 | * LOCKING: | ||
2916 | * None. | ||
2917 | * | ||
2918 | * RETURNS: | ||
2919 | * Matching xfer_mode, 0xff if no match found. | ||
2920 | */ | ||
2921 | u8 ata_timing_cycle2mode(unsigned int xfer_shift, int cycle) | ||
2922 | { | ||
2923 | u8 base_mode = 0xff, last_mode = 0xff; | ||
2924 | const struct ata_xfer_ent *ent; | ||
2925 | const struct ata_timing *t; | ||
2926 | |||
2927 | for (ent = ata_xfer_tbl; ent->shift >= 0; ent++) | ||
2928 | if (ent->shift == xfer_shift) | ||
2929 | base_mode = ent->base; | ||
2930 | |||
2931 | for (t = ata_timing_find_mode(base_mode); | ||
2932 | t && ata_xfer_mode2shift(t->mode) == xfer_shift; t++) { | ||
2933 | unsigned short this_cycle; | ||
2934 | |||
2935 | switch (xfer_shift) { | ||
2936 | case ATA_SHIFT_PIO: | ||
2937 | case ATA_SHIFT_MWDMA: | ||
2938 | this_cycle = t->cycle; | ||
2939 | break; | ||
2940 | case ATA_SHIFT_UDMA: | ||
2941 | this_cycle = t->udma; | ||
2942 | break; | ||
2943 | default: | ||
2944 | return 0xff; | ||
2945 | } | ||
2946 | |||
2947 | if (cycle > this_cycle) | ||
2948 | break; | ||
2949 | |||
2950 | last_mode = t->mode; | ||
2951 | } | ||
2952 | |||
2953 | return last_mode; | ||
2954 | } | ||
2955 | |||
2956 | /** | ||
2906 | * ata_down_xfermask_limit - adjust dev xfer masks downward | 2957 | * ata_down_xfermask_limit - adjust dev xfer masks downward |
2907 | * @dev: Device to adjust xfer masks | 2958 | * @dev: Device to adjust xfer masks |
2908 | * @sel: ATA_DNXFER_* selector | 2959 | * @sel: ATA_DNXFER_* selector |
@@ -7630,6 +7681,7 @@ EXPORT_SYMBOL_GPL(ata_pio_need_iordy); | |||
7630 | EXPORT_SYMBOL_GPL(ata_timing_find_mode); | 7681 | EXPORT_SYMBOL_GPL(ata_timing_find_mode); |
7631 | EXPORT_SYMBOL_GPL(ata_timing_compute); | 7682 | EXPORT_SYMBOL_GPL(ata_timing_compute); |
7632 | EXPORT_SYMBOL_GPL(ata_timing_merge); | 7683 | EXPORT_SYMBOL_GPL(ata_timing_merge); |
7684 | EXPORT_SYMBOL_GPL(ata_timing_cycle2mode); | ||
7633 | 7685 | ||
7634 | #ifdef CONFIG_PCI | 7686 | #ifdef CONFIG_PCI |
7635 | EXPORT_SYMBOL_GPL(pci_test_config_bits); | 7687 | EXPORT_SYMBOL_GPL(pci_test_config_bits); |