diff options
Diffstat (limited to 'drivers/firewire/ohci.c')
-rw-r--r-- | drivers/firewire/ohci.c | 57 |
1 files changed, 29 insertions, 28 deletions
diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c index bf5e11284421..c3eb471d22f7 100644 --- a/drivers/firewire/ohci.c +++ b/drivers/firewire/ohci.c | |||
@@ -1795,60 +1795,61 @@ static int ohci_enable_phys_dma(struct fw_card *card, | |||
1795 | #endif /* CONFIG_FIREWIRE_OHCI_REMOTE_DMA */ | 1795 | #endif /* CONFIG_FIREWIRE_OHCI_REMOTE_DMA */ |
1796 | } | 1796 | } |
1797 | 1797 | ||
1798 | static inline u32 cycle_timer_ticks(u32 cycle_timer) | 1798 | static u32 cycle_timer_ticks(u32 cycle_timer) |
1799 | { | 1799 | { |
1800 | u32 ticks; | 1800 | u32 ticks; |
1801 | 1801 | ||
1802 | ticks = cycle_timer & 0xfff; | 1802 | ticks = cycle_timer & 0xfff; |
1803 | ticks += 3072 * ((cycle_timer >> 12) & 0x1fff); | 1803 | ticks += 3072 * ((cycle_timer >> 12) & 0x1fff); |
1804 | ticks += (3072 * 8000) * (cycle_timer >> 25); | 1804 | ticks += (3072 * 8000) * (cycle_timer >> 25); |
1805 | |||
1805 | return ticks; | 1806 | return ticks; |
1806 | } | 1807 | } |
1807 | 1808 | ||
1809 | /* | ||
1810 | * Some controllers exhibit one or more of the following bugs when updating the | ||
1811 | * iso cycle timer register: | ||
1812 | * - When the lowest six bits are wrapping around to zero, a read that happens | ||
1813 | * at the same time will return garbage in the lowest ten bits. | ||
1814 | * - When the cycleOffset field wraps around to zero, the cycleCount field is | ||
1815 | * not incremented for about 60 ns. | ||
1816 | * - Occasionally, the entire register reads zero. | ||
1817 | * | ||
1818 | * To catch these, we read the register three times and ensure that the | ||
1819 | * difference between each two consecutive reads is approximately the same, i.e. | ||
1820 | * less than twice the other. Furthermore, any negative difference indicates an | ||
1821 | * error. (A PCI read should take at least 20 ticks of the 24.576 MHz timer to | ||
1822 | * execute, so we have enough precision to compute the ratio of the differences.) | ||
1823 | */ | ||
1808 | static u64 ohci_get_bus_time(struct fw_card *card) | 1824 | static u64 ohci_get_bus_time(struct fw_card *card) |
1809 | { | 1825 | { |
1810 | struct fw_ohci *ohci = fw_ohci(card); | 1826 | struct fw_ohci *ohci = fw_ohci(card); |
1811 | u32 c0, c1, c2; | 1827 | u32 c0, c1, c2; |
1812 | u32 t0, t1, t2; | 1828 | u32 t0, t1, t2; |
1813 | s32 diff01, diff12; | 1829 | s32 diff01, diff12; |
1814 | u64 bus_time; | 1830 | int i; |
1815 | 1831 | ||
1816 | if (!ohci->iso_cycle_timer_quirk) { | 1832 | c2 = reg_read(ohci, OHCI1394_IsochronousCycleTimer); |
1833 | |||
1834 | if (ohci->iso_cycle_timer_quirk) { | ||
1835 | i = 0; | ||
1836 | c1 = c2; | ||
1817 | c2 = reg_read(ohci, OHCI1394_IsochronousCycleTimer); | 1837 | c2 = reg_read(ohci, OHCI1394_IsochronousCycleTimer); |
1818 | } else { | ||
1819 | /* | ||
1820 | * Some controllers exhibit one or more of the following bugs | ||
1821 | * when updating the iso cycle timer register: | ||
1822 | * - When the lowest six bits are wrapping around to zero, | ||
1823 | * a read that happens at the same time will return garbage | ||
1824 | * in the lowest ten bits. | ||
1825 | * - When the cycleOffset field wraps around to zero, the | ||
1826 | * cycleCount field is not incremented for about 60 ns. | ||
1827 | * - Occasionally, the entire register reads zero. | ||
1828 | * | ||
1829 | * To catch these, we read the register three times and ensure | ||
1830 | * that the difference between each two consecutive reads is | ||
1831 | * approximately the same, i.e., less than twice the other. | ||
1832 | * Furthermore, any negative difference indicates an error. | ||
1833 | * (A PCI read should take at least 20 ticks of the 24.576 MHz | ||
1834 | * timer to execute, so we have enough precision to compute the | ||
1835 | * ratio of the differences.) | ||
1836 | */ | ||
1837 | do { | 1838 | do { |
1838 | c0 = reg_read(ohci, OHCI1394_IsochronousCycleTimer); | 1839 | c0 = c1; |
1839 | c1 = reg_read(ohci, OHCI1394_IsochronousCycleTimer); | 1840 | c1 = c2; |
1840 | c2 = reg_read(ohci, OHCI1394_IsochronousCycleTimer); | 1841 | c2 = reg_read(ohci, OHCI1394_IsochronousCycleTimer); |
1841 | t0 = cycle_timer_ticks(c0); | 1842 | t0 = cycle_timer_ticks(c0); |
1842 | t1 = cycle_timer_ticks(c1); | 1843 | t1 = cycle_timer_ticks(c1); |
1843 | t2 = cycle_timer_ticks(c2); | 1844 | t2 = cycle_timer_ticks(c2); |
1844 | diff01 = t1 - t0; | 1845 | diff01 = t1 - t0; |
1845 | diff12 = t2 - t1; | 1846 | diff12 = t2 - t1; |
1846 | } while (diff01 <= 0 || diff12 <= 0 || | 1847 | } while ((diff01 <= 0 || diff12 <= 0 || |
1847 | diff01 / diff12 >= 2 || diff12 / diff01 >= 2); | 1848 | diff01 / diff12 >= 2 || diff12 / diff01 >= 2) |
1849 | && i++ < 20); | ||
1848 | } | 1850 | } |
1849 | bus_time = ((u64)atomic_read(&ohci->bus_seconds) << 32) | c2; | ||
1850 | 1851 | ||
1851 | return bus_time; | 1852 | return ((u64)atomic_read(&ohci->bus_seconds) << 32) | c2; |
1852 | } | 1853 | } |
1853 | 1854 | ||
1854 | static void copy_iso_headers(struct iso_context *ctx, void *p) | 1855 | static void copy_iso_headers(struct iso_context *ctx, void *p) |