firewire: cdev: add PHY packet reception
[pandora-kernel.git] / drivers / firewire / ohci.c
index a61571c..08afccc 100644 (file)
@@ -18,6 +18,7 @@
  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
+#include <linux/bug.h>
 #include <linux/compiler.h>
 #include <linux/delay.h>
 #include <linux/device.h>
 #include <linux/mm.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
+#include <linux/mutex.h>
 #include <linux/pci.h>
 #include <linux/pci_ids.h>
 #include <linux/spinlock.h>
 #include <linux/string.h>
 
-#include <asm/atomic.h>
 #include <asm/byteorder.h>
 #include <asm/page.h>
 #include <asm/system.h>
@@ -73,20 +74,6 @@ struct descriptor {
        __le16 transfer_status;
 } __attribute__((aligned(16)));
 
-struct db_descriptor {
-       __le16 first_size;
-       __le16 control;
-       __le16 second_req_count;
-       __le16 first_req_count;
-       __le32 branch_address;
-       __le16 second_res_count;
-       __le16 first_res_count;
-       __le32 reserved0;
-       __le32 first_buffer;
-       __le32 second_buffer;
-       __le32 reserved1;
-} __attribute__((aligned(16)));
-
 #define CONTROL_SET(regs)      (regs)
 #define CONTROL_CLEAR(regs)    ((regs) + 4)
 #define COMMAND_PTR(regs)      ((regs) + 12)
@@ -181,31 +168,22 @@ struct fw_ohci {
        struct fw_card card;
 
        __iomem char *registers;
-       dma_addr_t self_id_bus;
-       __le32 *self_id_cpu;
-       struct tasklet_struct bus_reset_tasklet;
        int node_id;
        int generation;
        int request_generation; /* for timestamping incoming requests */
-       atomic_t bus_seconds;
-
-       bool use_dualbuffer;
-       bool old_uninorth;
-       bool bus_reset_packet_quirk;
+       unsigned quirks;
+       unsigned int pri_req_max;
+       u32 bus_time;
+       bool is_root;
+       bool csr_state_setclear_abdicate;
 
        /*
         * Spinlock for accessing fw_ohci data.  Never call out of
         * this driver with this lock held.
         */
        spinlock_t lock;
-       u32 self_id_buffer[512];
 
-       /* Config rom buffers */
-       __be32 *config_rom;
-       dma_addr_t config_rom_bus;
-       __be32 *next_config_rom;
-       dma_addr_t next_config_rom_bus;
-       __be32 next_header;
+       struct mutex phy_reg_mutex;
 
        struct ar_context ar_request_ctx;
        struct ar_context ar_response_ctx;
@@ -217,6 +195,18 @@ struct fw_ohci {
        u64 ir_context_channels;
        u32 ir_context_mask;
        struct iso_context *ir_context_list;
+
+       __be32    *config_rom;
+       dma_addr_t config_rom_bus;
+       __be32    *next_config_rom;
+       dma_addr_t next_config_rom_bus;
+       __be32     next_header;
+
+       __le32    *self_id_cpu;
+       dma_addr_t self_id_bus;
+       struct tasklet_struct bus_reset_tasklet;
+
+       u32 self_id_buffer[512];
 };
 
 static inline struct fw_ohci *fw_ohci(struct fw_card *card)
@@ -249,13 +239,48 @@ static inline struct fw_ohci *fw_ohci(struct fw_card *card)
 
 static char ohci_driver_name[] = KBUILD_MODNAME;
 
-#ifdef CONFIG_FIREWIRE_OHCI_DEBUG
+#define PCI_DEVICE_ID_JMICRON_JMB38X_FW        0x2380
+#define PCI_DEVICE_ID_TI_TSB12LV22     0x8009
+
+#define QUIRK_CYCLE_TIMER              1
+#define QUIRK_RESET_PACKET             2
+#define QUIRK_BE_HEADERS               4
+#define QUIRK_NO_1394A                 8
+#define QUIRK_NO_MSI                   16
+
+/* In case of multiple matches in ohci_quirks[], only the first one is used. */
+static const struct {
+       unsigned short vendor, device, flags;
+} ohci_quirks[] = {
+       {PCI_VENDOR_ID_TI,      PCI_DEVICE_ID_TI_TSB12LV22, QUIRK_CYCLE_TIMER |
+                                                           QUIRK_RESET_PACKET |
+                                                           QUIRK_NO_1394A},
+       {PCI_VENDOR_ID_TI,      PCI_ANY_ID,     QUIRK_RESET_PACKET},
+       {PCI_VENDOR_ID_AL,      PCI_ANY_ID,     QUIRK_CYCLE_TIMER},
+       {PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB38X_FW, QUIRK_NO_MSI},
+       {PCI_VENDOR_ID_NEC,     PCI_ANY_ID,     QUIRK_CYCLE_TIMER},
+       {PCI_VENDOR_ID_VIA,     PCI_ANY_ID,     QUIRK_CYCLE_TIMER},
+       {PCI_VENDOR_ID_APPLE,   PCI_DEVICE_ID_APPLE_UNI_N_FW, QUIRK_BE_HEADERS},
+};
+
+/* This overrides anything that was found in ohci_quirks[]. */
+static int param_quirks;
+module_param_named(quirks, param_quirks, int, 0644);
+MODULE_PARM_DESC(quirks, "Chip quirks (default = 0"
+       ", nonatomic cycle timer = "    __stringify(QUIRK_CYCLE_TIMER)
+       ", reset packet generation = "  __stringify(QUIRK_RESET_PACKET)
+       ", AR/selfID endianess = "      __stringify(QUIRK_BE_HEADERS)
+       ", no 1394a enhancements = "    __stringify(QUIRK_NO_1394A)
+       ", disable MSI = "              __stringify(QUIRK_NO_MSI)
+       ")");
 
 #define OHCI_PARAM_DEBUG_AT_AR         1
 #define OHCI_PARAM_DEBUG_SELFIDS       2
 #define OHCI_PARAM_DEBUG_IRQS          4
 #define OHCI_PARAM_DEBUG_BUSRESETS     8 /* only effective before chip init */
 
+#ifdef CONFIG_FIREWIRE_OHCI_DEBUG
+
 static int param_debug;
 module_param_named(debug, param_debug, int, 0644);
 MODULE_PARM_DESC(debug, "Verbose logging (default = 0"
@@ -430,9 +455,10 @@ static void log_ar_at_event(char dir, int speed, u32 *header, int evt)
 
 #else
 
-#define log_irqs(evt)
-#define log_selfids(node_id, generation, self_id_count, sid)
-#define log_ar_at_event(dir, speed, header, evt)
+#define param_debug 0
+static inline void log_irqs(u32 evt) {}
+static inline void log_selfids(int node_id, int generation, int self_id_count, u32 *s) {}
+static inline void log_ar_at_event(char dir, int speed, u32 *header, int evt) {}
 
 #endif /* CONFIG_FIREWIRE_OHCI_DEBUG */
 
@@ -452,27 +478,99 @@ static inline void flush_writes(const struct fw_ohci *ohci)
        reg_read(ohci, OHCI1394_Version);
 }
 
-static int ohci_update_phy_reg(struct fw_card *card, int addr,
-                              int clear_bits, int set_bits)
+static int read_phy_reg(struct fw_ohci *ohci, int addr)
 {
-       struct fw_ohci *ohci = fw_ohci(card);
-       u32 val, old;
+       u32 val;
+       int i;
 
        reg_write(ohci, OHCI1394_PhyControl, OHCI1394_PhyControl_Read(addr));
-       flush_writes(ohci);
-       msleep(2);
-       val = reg_read(ohci, OHCI1394_PhyControl);
-       if ((val & OHCI1394_PhyControl_ReadDone) == 0) {
-               fw_error("failed to set phy reg bits.\n");
-               return -EBUSY;
+       for (i = 0; i < 3 + 100; i++) {
+               val = reg_read(ohci, OHCI1394_PhyControl);
+               if (val & OHCI1394_PhyControl_ReadDone)
+                       return OHCI1394_PhyControl_ReadData(val);
+
+               /*
+                * Try a few times without waiting.  Sleeping is necessary
+                * only when the link/PHY interface is busy.
+                */
+               if (i >= 3)
+                       msleep(1);
        }
+       fw_error("failed to read phy reg\n");
+
+       return -EBUSY;
+}
+
+static int write_phy_reg(const struct fw_ohci *ohci, int addr, u32 val)
+{
+       int i;
 
-       old = OHCI1394_PhyControl_ReadData(val);
-       old = (old & ~clear_bits) | set_bits;
        reg_write(ohci, OHCI1394_PhyControl,
-                 OHCI1394_PhyControl_Write(addr, old));
+                 OHCI1394_PhyControl_Write(addr, val));
+       for (i = 0; i < 3 + 100; i++) {
+               val = reg_read(ohci, OHCI1394_PhyControl);
+               if (!(val & OHCI1394_PhyControl_WritePending))
+                       return 0;
 
-       return 0;
+               if (i >= 3)
+                       msleep(1);
+       }
+       fw_error("failed to write phy reg\n");
+
+       return -EBUSY;
+}
+
+static int update_phy_reg(struct fw_ohci *ohci, int addr,
+                         int clear_bits, int set_bits)
+{
+       int ret = read_phy_reg(ohci, addr);
+       if (ret < 0)
+               return ret;
+
+       /*
+        * The interrupt status bits are cleared by writing a one bit.
+        * Avoid clearing them unless explicitly requested in set_bits.
+        */
+       if (addr == 5)
+               clear_bits |= PHY_INT_STATUS_BITS;
+
+       return write_phy_reg(ohci, addr, (ret & ~clear_bits) | set_bits);
+}
+
+static int read_paged_phy_reg(struct fw_ohci *ohci, int page, int addr)
+{
+       int ret;
+
+       ret = update_phy_reg(ohci, 7, PHY_PAGE_SELECT, page << 5);
+       if (ret < 0)
+               return ret;
+
+       return read_phy_reg(ohci, addr);
+}
+
+static int ohci_read_phy_reg(struct fw_card *card, int addr)
+{
+       struct fw_ohci *ohci = fw_ohci(card);
+       int ret;
+
+       mutex_lock(&ohci->phy_reg_mutex);
+       ret = read_phy_reg(ohci, addr);
+       mutex_unlock(&ohci->phy_reg_mutex);
+
+       return ret;
+}
+
+static int ohci_update_phy_reg(struct fw_card *card, int addr,
+                              int clear_bits, int set_bits)
+{
+       struct fw_ohci *ohci = fw_ohci(card);
+       int ret;
+
+       mutex_lock(&ohci->phy_reg_mutex);
+       ret = update_phy_reg(ohci, addr, clear_bits, set_bits);
+       mutex_unlock(&ohci->phy_reg_mutex);
+
+       return ret;
 }
 
 static int ar_context_add_page(struct ar_context *ctx)
@@ -524,7 +622,7 @@ static void ar_context_release(struct ar_context *ctx)
 
 #if defined(CONFIG_PPC_PMAC) && defined(CONFIG_PPC32)
 #define cond_le32_to_cpu(v) \
-       (ohci->old_uninorth ? (__force __u32)(v) : le32_to_cpu(v))
+       (ohci->quirks & QUIRK_BE_HEADERS ? (__force __u32)(v) : le32_to_cpu(v))
 #else
 #define cond_le32_to_cpu(v) le32_to_cpu(v)
 #endif
@@ -605,7 +703,7 @@ static __le32 *handle_ar_packet(struct ar_context *ctx, __le32 *buffer)
         * at a slightly incorrect time (in bus_reset_tasklet).
         */
        if (evt == OHCI1394_evt_bus_reset) {
-               if (!ohci->bus_reset_packet_quirk)
+               if (!(ohci->quirks & QUIRK_RESET_PACKET))
                        ohci->request_generation = (p.header[2] >> 16) & 0xff;
        } else if (ctx == &ohci->ar_request_ctx) {
                fw_core_handle_request(&ohci->card, &p);
@@ -1250,6 +1348,78 @@ static void at_context_transmit(struct context *ctx, struct fw_packet *packet)
 
 }
 
+static u32 cycle_timer_ticks(u32 cycle_timer)
+{
+       u32 ticks;
+
+       ticks = cycle_timer & 0xfff;
+       ticks += 3072 * ((cycle_timer >> 12) & 0x1fff);
+       ticks += (3072 * 8000) * (cycle_timer >> 25);
+
+       return ticks;
+}
+
+/*
+ * Some controllers exhibit one or more of the following bugs when updating the
+ * iso cycle timer register:
+ *  - When the lowest six bits are wrapping around to zero, a read that happens
+ *    at the same time will return garbage in the lowest ten bits.
+ *  - When the cycleOffset field wraps around to zero, the cycleCount field is
+ *    not incremented for about 60 ns.
+ *  - Occasionally, the entire register reads zero.
+ *
+ * To catch these, we read the register three times and ensure that the
+ * difference between each two consecutive reads is approximately the same, i.e.
+ * less than twice the other.  Furthermore, any negative difference indicates an
+ * error.  (A PCI read should take at least 20 ticks of the 24.576 MHz timer to
+ * execute, so we have enough precision to compute the ratio of the differences.)
+ */
+static u32 get_cycle_time(struct fw_ohci *ohci)
+{
+       u32 c0, c1, c2;
+       u32 t0, t1, t2;
+       s32 diff01, diff12;
+       int i;
+
+       c2 = reg_read(ohci, OHCI1394_IsochronousCycleTimer);
+
+       if (ohci->quirks & QUIRK_CYCLE_TIMER) {
+               i = 0;
+               c1 = c2;
+               c2 = reg_read(ohci, OHCI1394_IsochronousCycleTimer);
+               do {
+                       c0 = c1;
+                       c1 = c2;
+                       c2 = reg_read(ohci, OHCI1394_IsochronousCycleTimer);
+                       t0 = cycle_timer_ticks(c0);
+                       t1 = cycle_timer_ticks(c1);
+                       t2 = cycle_timer_ticks(c2);
+                       diff01 = t1 - t0;
+                       diff12 = t2 - t1;
+               } while ((diff01 <= 0 || diff12 <= 0 ||
+                         diff01 / diff12 >= 2 || diff12 / diff01 >= 2)
+                        && i++ < 20);
+       }
+
+       return c2;
+}
+
+/*
+ * This function has to be called at least every 64 seconds.  The bus_time
+ * field stores not only the upper 25 bits of the BUS_TIME register but also
+ * the most significant bit of the cycle timer in bit 6 so that we can detect
+ * changes in this bit.
+ */
+static u32 update_bus_time(struct fw_ohci *ohci)
+{
+       u32 cycle_time_seconds = get_cycle_time(ohci) >> 25;
+
+       if ((ohci->bus_time & 0x40) != (cycle_time_seconds & 0x40))
+               ohci->bus_time += 0x40;
+
+       return ohci->bus_time | cycle_time_seconds;
+}
+
 static void bus_reset_tasklet(unsigned long data)
 {
        struct fw_ohci *ohci = (struct fw_ohci *)data;
@@ -1258,6 +1428,7 @@ static void bus_reset_tasklet(unsigned long data)
        unsigned long flags;
        void *free_rom = NULL;
        dma_addr_t free_rom_bus = 0;
+       bool is_new_root;
 
        reg = reg_read(ohci, OHCI1394_NodeID);
        if (!(reg & OHCI1394_NodeID_idValid)) {
@@ -1271,6 +1442,12 @@ static void bus_reset_tasklet(unsigned long data)
        ohci->node_id = reg & (OHCI1394_NodeID_busNumber |
                               OHCI1394_NodeID_nodeNumber);
 
+       is_new_root = (reg & OHCI1394_NodeID_root) != 0;
+       if (!(ohci->is_root && is_new_root))
+               reg_write(ohci, OHCI1394_LinkControlSet,
+                         OHCI1394_LinkControl_cycleMaster);
+       ohci->is_root = is_new_root;
+
        reg = reg_read(ohci, OHCI1394_SelfIDCount);
        if (reg & OHCI1394_SelfIDCount_selfIDError) {
                fw_notify("inconsistent self IDs\n");
@@ -1329,7 +1506,7 @@ static void bus_reset_tasklet(unsigned long data)
        context_stop(&ohci->at_response_ctx);
        reg_write(ohci, OHCI1394_IntEventClear, OHCI1394_busReset);
 
-       if (ohci->bus_reset_packet_quirk)
+       if (ohci->quirks & QUIRK_RESET_PACKET)
                ohci->request_generation = generation;
 
        /*
@@ -1378,13 +1555,15 @@ static void bus_reset_tasklet(unsigned long data)
                    self_id_count, ohci->self_id_buffer);
 
        fw_core_handle_bus_reset(&ohci->card, ohci->node_id, generation,
-                                self_id_count, ohci->self_id_buffer);
+                                self_id_count, ohci->self_id_buffer,
+                                ohci->csr_state_setclear_abdicate);
+       ohci->csr_state_setclear_abdicate = false;
 }
 
 static irqreturn_t irq_handler(int irq, void *data)
 {
        struct fw_ohci *ohci = data;
-       u32 event, iso_event, cycle_time;
+       u32 event, iso_event;
        int i;
 
        event = reg_read(ohci, OHCI1394_IntEventClear);
@@ -1455,9 +1634,9 @@ static irqreturn_t irq_handler(int irq, void *data)
        }
 
        if (event & OHCI1394_cycle64Seconds) {
-               cycle_time = reg_read(ohci, OHCI1394_IsochronousCycleTimer);
-               if ((cycle_time & 0x80000000) == 0)
-                       atomic_inc(&ohci->bus_seconds);
+               spin_lock(&ohci->lock);
+               update_bus_time(ohci);
+               spin_unlock(&ohci->lock);
        }
 
        return IRQ_HANDLED;
@@ -1488,13 +1667,64 @@ static void copy_config_rom(__be32 *dest, const __be32 *src, size_t length)
                memset(&dest[length], 0, CONFIG_ROM_SIZE - size);
 }
 
+static int configure_1394a_enhancements(struct fw_ohci *ohci)
+{
+       bool enable_1394a;
+       int ret, clear, set, offset;
+
+       /* Check if the driver should configure link and PHY. */
+       if (!(reg_read(ohci, OHCI1394_HCControlSet) &
+             OHCI1394_HCControl_programPhyEnable))
+               return 0;
+
+       /* Paranoia: check whether the PHY supports 1394a, too. */
+       enable_1394a = false;
+       ret = read_phy_reg(ohci, 2);
+       if (ret < 0)
+               return ret;
+       if ((ret & PHY_EXTENDED_REGISTERS) == PHY_EXTENDED_REGISTERS) {
+               ret = read_paged_phy_reg(ohci, 1, 8);
+               if (ret < 0)
+                       return ret;
+               if (ret >= 1)
+                       enable_1394a = true;
+       }
+
+       if (ohci->quirks & QUIRK_NO_1394A)
+               enable_1394a = false;
+
+       /* Configure PHY and link consistently. */
+       if (enable_1394a) {
+               clear = 0;
+               set = PHY_ENABLE_ACCEL | PHY_ENABLE_MULTI;
+       } else {
+               clear = PHY_ENABLE_ACCEL | PHY_ENABLE_MULTI;
+               set = 0;
+       }
+       ret = update_phy_reg(ohci, 5, clear, set);
+       if (ret < 0)
+               return ret;
+
+       if (enable_1394a)
+               offset = OHCI1394_HCControlSet;
+       else
+               offset = OHCI1394_HCControlClear;
+       reg_write(ohci, offset, OHCI1394_HCControl_aPhyEnhanceEnable);
+
+       /* Clean up: configuration has been taken care of. */
+       reg_write(ohci, OHCI1394_HCControlClear,
+                 OHCI1394_HCControl_programPhyEnable);
+
+       return 0;
+}
+
 static int ohci_enable(struct fw_card *card,
                       const __be32 *config_rom, size_t length)
 {
        struct fw_ohci *ohci = fw_ohci(card);
        struct pci_dev *dev = to_pci_dev(card->device);
-       u32 lps;
-       int i;
+       u32 lps, seconds, version, irqs;
+       int i, ret;
 
        if (software_reset(ohci)) {
                fw_error("Failed to reset ohci card.\n");
@@ -1529,17 +1759,34 @@ static int ohci_enable(struct fw_card *card,
                  OHCI1394_HCControl_noByteSwapData);
 
        reg_write(ohci, OHCI1394_SelfIDBuffer, ohci->self_id_bus);
-       reg_write(ohci, OHCI1394_LinkControlClear,
-                 OHCI1394_LinkControl_rcvPhyPkt);
        reg_write(ohci, OHCI1394_LinkControlSet,
                  OHCI1394_LinkControl_rcvSelfID |
+                 OHCI1394_LinkControl_rcvPhyPkt |
                  OHCI1394_LinkControl_cycleTimerEnable |
                  OHCI1394_LinkControl_cycleMaster);
 
        reg_write(ohci, OHCI1394_ATRetries,
                  OHCI1394_MAX_AT_REQ_RETRIES |
                  (OHCI1394_MAX_AT_RESP_RETRIES << 4) |
-                 (OHCI1394_MAX_PHYS_RESP_RETRIES << 8));
+                 (OHCI1394_MAX_PHYS_RESP_RETRIES << 8) |
+                 (200 << 16));
+
+       seconds = lower_32_bits(get_seconds());
+       reg_write(ohci, OHCI1394_IsochronousCycleTimer, seconds << 25);
+       ohci->bus_time = seconds & ~0x3f;
+
+       version = reg_read(ohci, OHCI1394_Version) & 0x00ff00ff;
+       if (version >= OHCI_VERSION_1_1) {
+               reg_write(ohci, OHCI1394_InitialChannelsAvailableHi,
+                         0xfffffffe);
+               card->broadcast_channel_auto_allocated = true;
+       }
+
+       /* Get implemented bits of the priority arbitration request counter. */
+       reg_write(ohci, OHCI1394_FairnessControl, 0x3f);
+       ohci->pri_req_max = reg_read(ohci, OHCI1394_FairnessControl) & 0x3f;
+       reg_write(ohci, OHCI1394_FairnessControl, 0);
+       card->priority_budget_implemented = ohci->pri_req_max != 0;
 
        ar_context_run(&ohci->ar_request_ctx);
        ar_context_run(&ohci->ar_response_ctx);
@@ -1547,22 +1794,15 @@ static int ohci_enable(struct fw_card *card,
        reg_write(ohci, OHCI1394_PhyUpperBound, 0x00010000);
        reg_write(ohci, OHCI1394_IntEventClear, ~0);
        reg_write(ohci, OHCI1394_IntMaskClear, ~0);
-       reg_write(ohci, OHCI1394_IntMaskSet,
-                 OHCI1394_selfIDComplete |
-                 OHCI1394_RQPkt | OHCI1394_RSPkt |
-                 OHCI1394_reqTxComplete | OHCI1394_respTxComplete |
-                 OHCI1394_isochRx | OHCI1394_isochTx |
-                 OHCI1394_postedWriteErr | OHCI1394_cycleTooLong |
-                 OHCI1394_cycleInconsistent |
-                 OHCI1394_cycle64Seconds | OHCI1394_regAccessFail |
-                 OHCI1394_masterIntEnable);
-       if (param_debug & OHCI_PARAM_DEBUG_BUSRESETS)
-               reg_write(ohci, OHCI1394_IntMaskSet, OHCI1394_busReset);
+
+       ret = configure_1394a_enhancements(ohci);
+       if (ret < 0)
+               return ret;
 
        /* Activate link_on bit and contender bit in our self ID packets.*/
-       if (ohci_update_phy_reg(card, 4, 0,
-                               PHY_LINK_ACTIVE | PHY_CONTENDER) < 0)
-               return -EIO;
+       ret = ohci_update_phy_reg(card, 4, 0, PHY_LINK_ACTIVE | PHY_CONTENDER);
+       if (ret < 0)
+               return ret;
 
        /*
         * When the link is not yet enabled, the atomic config rom
@@ -1610,26 +1850,38 @@ static int ohci_enable(struct fw_card *card,
 
        reg_write(ohci, OHCI1394_AsReqFilterHiSet, 0x80000000);
 
+       if (!(ohci->quirks & QUIRK_NO_MSI))
+               pci_enable_msi(dev);
        if (request_irq(dev->irq, irq_handler,
-                       IRQF_SHARED, ohci_driver_name, ohci)) {
-               fw_error("Failed to allocate shared interrupt %d.\n",
-                        dev->irq);
+                       pci_dev_msi_enabled(dev) ? 0 : IRQF_SHARED,
+                       ohci_driver_name, ohci)) {
+               fw_error("Failed to allocate interrupt %d.\n", dev->irq);
+               pci_disable_msi(dev);
                dma_free_coherent(ohci->card.device, CONFIG_ROM_SIZE,
                                  ohci->config_rom, ohci->config_rom_bus);
                return -EIO;
        }
 
+       irqs =  OHCI1394_reqTxComplete | OHCI1394_respTxComplete |
+               OHCI1394_RQPkt | OHCI1394_RSPkt |
+               OHCI1394_isochTx | OHCI1394_isochRx |
+               OHCI1394_postedWriteErr |
+               OHCI1394_selfIDComplete |
+               OHCI1394_regAccessFail |
+               OHCI1394_cycle64Seconds |
+               OHCI1394_cycleInconsistent | OHCI1394_cycleTooLong |
+               OHCI1394_masterIntEnable;
+       if (param_debug & OHCI_PARAM_DEBUG_BUSRESETS)
+               irqs |= OHCI1394_busReset;
+       reg_write(ohci, OHCI1394_IntMaskSet, irqs);
+
        reg_write(ohci, OHCI1394_HCControlSet,
                  OHCI1394_HCControl_linkEnable |
                  OHCI1394_HCControl_BIBimageValid);
        flush_writes(ohci);
 
-       /*
-        * We are ready to go, initiate bus reset to finish the
-        * initialization.
-        */
-
-       fw_core_initiate_bus_reset(&ohci->card, 1);
+       /* We are ready to go, reset bus to finish initialization. */
+       fw_schedule_bus_reset(&ohci->card, false, true);
 
        return 0;
 }
@@ -1704,7 +1956,7 @@ static int ohci_set_config_rom(struct fw_card *card,
         * takes effect.
         */
        if (ret == 0)
-               fw_core_initiate_bus_reset(&ohci->card, 1);
+               fw_schedule_bus_reset(&ohci->card, true, true);
        else
                dma_free_coherent(ohci->card.device, CONFIG_ROM_SIZE,
                                  next_config_rom, next_config_rom_bus);
@@ -1794,16 +2046,117 @@ static int ohci_enable_phys_dma(struct fw_card *card,
 #endif /* CONFIG_FIREWIRE_OHCI_REMOTE_DMA */
 }
 
-static u64 ohci_get_bus_time(struct fw_card *card)
+static u32 ohci_read_csr(struct fw_card *card, int csr_offset)
 {
        struct fw_ohci *ohci = fw_ohci(card);
-       u32 cycle_time;
-       u64 bus_time;
+       unsigned long flags;
+       u32 value;
+
+       switch (csr_offset) {
+       case CSR_STATE_CLEAR:
+       case CSR_STATE_SET:
+               if (ohci->is_root &&
+                   (reg_read(ohci, OHCI1394_LinkControlSet) &
+                    OHCI1394_LinkControl_cycleMaster))
+                       value = CSR_STATE_BIT_CMSTR;
+               else
+                       value = 0;
+               if (ohci->csr_state_setclear_abdicate)
+                       value |= CSR_STATE_BIT_ABDICATE;
+
+               return value;
+
+       case CSR_NODE_IDS:
+               return reg_read(ohci, OHCI1394_NodeID) << 16;
+
+       case CSR_CYCLE_TIME:
+               return get_cycle_time(ohci);
+
+       case CSR_BUS_TIME:
+               /*
+                * We might be called just after the cycle timer has wrapped
+                * around but just before the cycle64Seconds handler, so we
+                * better check here, too, if the bus time needs to be updated.
+                */
+               spin_lock_irqsave(&ohci->lock, flags);
+               value = update_bus_time(ohci);
+               spin_unlock_irqrestore(&ohci->lock, flags);
+               return value;
+
+       case CSR_BUSY_TIMEOUT:
+               value = reg_read(ohci, OHCI1394_ATRetries);
+               return (value >> 4) & 0x0ffff00f;
+
+       case CSR_PRIORITY_BUDGET:
+               return (reg_read(ohci, OHCI1394_FairnessControl) & 0x3f) |
+                       (ohci->pri_req_max << 8);
+
+       default:
+               WARN_ON(1);
+               return 0;
+       }
+}
+
+static void ohci_write_csr(struct fw_card *card, int csr_offset, u32 value)
+{
+       struct fw_ohci *ohci = fw_ohci(card);
+       unsigned long flags;
+
+       switch (csr_offset) {
+       case CSR_STATE_CLEAR:
+               if ((value & CSR_STATE_BIT_CMSTR) && ohci->is_root) {
+                       reg_write(ohci, OHCI1394_LinkControlClear,
+                                 OHCI1394_LinkControl_cycleMaster);
+                       flush_writes(ohci);
+               }
+               if (value & CSR_STATE_BIT_ABDICATE)
+                       ohci->csr_state_setclear_abdicate = false;
+               break;
+
+       case CSR_STATE_SET:
+               if ((value & CSR_STATE_BIT_CMSTR) && ohci->is_root) {
+                       reg_write(ohci, OHCI1394_LinkControlSet,
+                                 OHCI1394_LinkControl_cycleMaster);
+                       flush_writes(ohci);
+               }
+               if (value & CSR_STATE_BIT_ABDICATE)
+                       ohci->csr_state_setclear_abdicate = true;
+               break;
+
+       case CSR_NODE_IDS:
+               reg_write(ohci, OHCI1394_NodeID, value >> 16);
+               flush_writes(ohci);
+               break;
+
+       case CSR_CYCLE_TIME:
+               reg_write(ohci, OHCI1394_IsochronousCycleTimer, value);
+               reg_write(ohci, OHCI1394_IntEventSet,
+                         OHCI1394_cycleInconsistent);
+               flush_writes(ohci);
+               break;
+
+       case CSR_BUS_TIME:
+               spin_lock_irqsave(&ohci->lock, flags);
+               ohci->bus_time = (ohci->bus_time & 0x7f) | (value & ~0x7f);
+               spin_unlock_irqrestore(&ohci->lock, flags);
+               break;
+
+       case CSR_BUSY_TIMEOUT:
+               value = (value & 0xf) | ((value & 0xf) << 4) |
+                       ((value & 0xf) << 8) | ((value & 0x0ffff000) << 4);
+               reg_write(ohci, OHCI1394_ATRetries, value);
+               flush_writes(ohci);
+               break;
 
-       cycle_time = reg_read(ohci, OHCI1394_IsochronousCycleTimer);
-       bus_time = ((u64)atomic_read(&ohci->bus_seconds) << 32) | cycle_time;
+       case CSR_PRIORITY_BUDGET:
+               reg_write(ohci, OHCI1394_FairnessControl, value & 0x3f);
+               flush_writes(ohci);
+               break;
 
-       return bus_time;
+       default:
+               WARN_ON(1);
+               break;
+       }
 }
 
 static void copy_iso_headers(struct iso_context *ctx, void *p)
@@ -1828,52 +2181,6 @@ static void copy_iso_headers(struct iso_context *ctx, void *p)
        ctx->header_length += ctx->base.header_size;
 }
 
-static int handle_ir_dualbuffer_packet(struct context *context,
-                                      struct descriptor *d,
-                                      struct descriptor *last)
-{
-       struct iso_context *ctx =
-               container_of(context, struct iso_context, context);
-       struct db_descriptor *db = (struct db_descriptor *) d;
-       __le32 *ir_header;
-       size_t header_length;
-       void *p, *end;
-
-       if (db->first_res_count != 0 && db->second_res_count != 0) {
-               if (ctx->excess_bytes <= le16_to_cpu(db->second_req_count)) {
-                       /* This descriptor isn't done yet, stop iteration. */
-                       return 0;
-               }
-               ctx->excess_bytes -= le16_to_cpu(db->second_req_count);
-       }
-
-       header_length = le16_to_cpu(db->first_req_count) -
-               le16_to_cpu(db->first_res_count);
-
-       p = db + 1;
-       end = p + header_length;
-       while (p < end) {
-               copy_iso_headers(ctx, p);
-               ctx->excess_bytes +=
-                       (le32_to_cpu(*(__le32 *)(p + 4)) >> 16) & 0xffff;
-               p += max(ctx->base.header_size, (size_t)8);
-       }
-
-       ctx->excess_bytes -= le16_to_cpu(db->second_req_count) -
-               le16_to_cpu(db->second_res_count);
-
-       if (le16_to_cpu(db->control) & DESCRIPTOR_IRQ_ALWAYS) {
-               ir_header = (__le32 *) (db + 1);
-               ctx->base.callback(&ctx->base,
-                                  le32_to_cpu(ir_header[0]) & 0xffff,
-                                  ctx->header_length, ctx->header,
-                                  ctx->base.callback_data);
-               ctx->header_length = 0;
-       }
-
-       return 1;
-}
-
 static int handle_ir_packet_per_buffer(struct context *context,
                                       struct descriptor *d,
                                       struct descriptor *last)
@@ -1960,10 +2267,7 @@ static struct fw_iso_context *ohci_allocate_iso_context(struct fw_card *card,
                channels = &ohci->ir_context_channels;
                mask = &ohci->ir_context_mask;
                list = ohci->ir_context_list;
-               if (ohci->use_dualbuffer)
-                       callback = handle_ir_dualbuffer_packet;
-               else
-                       callback = handle_ir_packet_per_buffer;
+               callback = handle_ir_packet_per_buffer;
        }
 
        spin_lock_irqsave(&ohci->lock, flags);
@@ -2026,8 +2330,6 @@ static int ohci_start_iso(struct fw_iso_context *base,
        } else {
                index = ctx - ohci->ir_context_list;
                control = IR_CONTEXT_ISOCH_HEADER;
-               if (ohci->use_dualbuffer)
-                       control |= IR_CONTEXT_DUAL_BUFFER_MODE;
                match = (tags << 28) | (sync << 8) | ctx->base.channel;
                if (cycle >= 0) {
                        match |= (cycle & 0x07fff) << 12;
@@ -2101,11 +2403,6 @@ static int ohci_queue_iso_transmit(struct fw_iso_context *base,
        u32 payload_index, payload_end_index, next_page_index;
        int page, end_page, i, length, offset;
 
-       /*
-        * FIXME: Cycle lost behavior should be configurable: lose
-        * packet, retransmit or terminate..
-        */
-
        p = packet;
        payload_index = payload;
 
@@ -2135,6 +2432,14 @@ static int ohci_queue_iso_transmit(struct fw_iso_context *base,
        if (!p->skip) {
                d[0].control   = cpu_to_le16(DESCRIPTOR_KEY_IMMEDIATE);
                d[0].req_count = cpu_to_le16(8);
+               /*
+                * Link the skip address to this descriptor itself.  This causes
+                * a context to skip a cycle whenever lost cycles or FIFO
+                * overruns occur, without dropping the data.  The application
+                * should then decide whether this is an error condition or not.
+                * FIXME:  Make the context's cycle-lost behaviour configurable?
+                */
+               d[0].branch_address = cpu_to_le32(d_bus | z);
 
                header = (__le32 *) &d[1];
                header[0] = cpu_to_le32(IT_HEADER_SY(p->sy) |
@@ -2185,92 +2490,6 @@ static int ohci_queue_iso_transmit(struct fw_iso_context *base,
        return 0;
 }
 
-static int ohci_queue_iso_receive_dualbuffer(struct fw_iso_context *base,
-                                            struct fw_iso_packet *packet,
-                                            struct fw_iso_buffer *buffer,
-                                            unsigned long payload)
-{
-       struct iso_context *ctx = container_of(base, struct iso_context, base);
-       struct db_descriptor *db = NULL;
-       struct descriptor *d;
-       struct fw_iso_packet *p;
-       dma_addr_t d_bus, page_bus;
-       u32 z, header_z, length, rest;
-       int page, offset, packet_count, header_size;
-
-       /*
-        * FIXME: Cycle lost behavior should be configurable: lose
-        * packet, retransmit or terminate..
-        */
-
-       p = packet;
-       z = 2;
-
-       /*
-        * The OHCI controller puts the isochronous header and trailer in the
-        * buffer, so we need at least 8 bytes.
-        */
-       packet_count = p->header_length / ctx->base.header_size;
-       header_size = packet_count * max(ctx->base.header_size, (size_t)8);
-
-       /* Get header size in number of descriptors. */
-       header_z = DIV_ROUND_UP(header_size, sizeof(*d));
-       page     = payload >> PAGE_SHIFT;
-       offset   = payload & ~PAGE_MASK;
-       rest     = p->payload_length;
-       /*
-        * The controllers I've tested have not worked correctly when
-        * second_req_count is zero.  Rather than do something we know won't
-        * work, return an error
-        */
-       if (rest == 0)
-               return -EINVAL;
-
-       while (rest > 0) {
-               d = context_get_descriptors(&ctx->context,
-                                           z + header_z, &d_bus);
-               if (d == NULL)
-                       return -ENOMEM;
-
-               db = (struct db_descriptor *) d;
-               db->control = cpu_to_le16(DESCRIPTOR_STATUS |
-                                         DESCRIPTOR_BRANCH_ALWAYS);
-               db->first_size =
-                   cpu_to_le16(max(ctx->base.header_size, (size_t)8));
-               if (p->skip && rest == p->payload_length) {
-                       db->control |= cpu_to_le16(DESCRIPTOR_WAIT);
-                       db->first_req_count = db->first_size;
-               } else {
-                       db->first_req_count = cpu_to_le16(header_size);
-               }
-               db->first_res_count = db->first_req_count;
-               db->first_buffer = cpu_to_le32(d_bus + sizeof(*db));
-
-               if (p->skip && rest == p->payload_length)
-                       length = 4;
-               else if (offset + rest < PAGE_SIZE)
-                       length = rest;
-               else
-                       length = PAGE_SIZE - offset;
-
-               db->second_req_count = cpu_to_le16(length);
-               db->second_res_count = db->second_req_count;
-               page_bus = page_private(buffer->pages[page]);
-               db->second_buffer = cpu_to_le32(page_bus + offset);
-
-               if (p->interrupt && length == rest)
-                       db->control |= cpu_to_le16(DESCRIPTOR_IRQ_ALWAYS);
-
-               context_append(&ctx->context, d, z, header_z);
-               offset = (offset + length) & ~PAGE_MASK;
-               rest -= length;
-               if (offset == 0)
-                       page++;
-       }
-
-       return 0;
-}
-
 static int ohci_queue_iso_receive_packet_per_buffer(struct fw_iso_context *base,
                                        struct fw_iso_packet *packet,
                                        struct fw_iso_buffer *buffer,
@@ -2361,9 +2580,6 @@ static int ohci_queue_iso(struct fw_iso_context *base,
        spin_lock_irqsave(&ctx->context.ohci->lock, flags);
        if (base->type == FW_ISO_CONTEXT_TRANSMIT)
                ret = ohci_queue_iso_transmit(base, packet, buffer, payload);
-       else if (ctx->context.ohci->use_dualbuffer)
-               ret = ohci_queue_iso_receive_dualbuffer(base, packet,
-                                                       buffer, payload);
        else
                ret = ohci_queue_iso_receive_packet_per_buffer(base, packet,
                                                        buffer, payload);
@@ -2374,13 +2590,15 @@ static int ohci_queue_iso(struct fw_iso_context *base,
 
 static const struct fw_card_driver ohci_driver = {
        .enable                 = ohci_enable,
+       .read_phy_reg           = ohci_read_phy_reg,
        .update_phy_reg         = ohci_update_phy_reg,
        .set_config_rom         = ohci_set_config_rom,
        .send_request           = ohci_send_request,
        .send_response          = ohci_send_response,
        .cancel_packet          = ohci_cancel_packet,
        .enable_phys_dma        = ohci_enable_phys_dma,
-       .get_bus_time           = ohci_get_bus_time,
+       .read_csr               = ohci_read_csr,
+       .write_csr              = ohci_write_csr,
 
        .allocate_iso_context   = ohci_allocate_iso_context,
        .free_iso_context       = ohci_free_iso_context,
@@ -2390,7 +2608,7 @@ static const struct fw_card_driver ohci_driver = {
 };
 
 #ifdef CONFIG_PPC_PMAC
-static void ohci_pmac_on(struct pci_dev *dev)
+static void pmac_ohci_on(struct pci_dev *dev)
 {
        if (machine_is(powermac)) {
                struct device_node *ofn = pci_device_to_OF_node(dev);
@@ -2402,7 +2620,7 @@ static void ohci_pmac_on(struct pci_dev *dev)
        }
 }
 
-static void ohci_pmac_off(struct pci_dev *dev)
+static void pmac_ohci_off(struct pci_dev *dev)
 {
        if (machine_is(powermac)) {
                struct device_node *ofn = pci_device_to_OF_node(dev);
@@ -2414,20 +2632,17 @@ static void ohci_pmac_off(struct pci_dev *dev)
        }
 }
 #else
-#define ohci_pmac_on(dev)
-#define ohci_pmac_off(dev)
+static inline void pmac_ohci_on(struct pci_dev *dev) {}
+static inline void pmac_ohci_off(struct pci_dev *dev) {}
 #endif /* CONFIG_PPC_PMAC */
 
-#define PCI_VENDOR_ID_AGERE            PCI_VENDOR_ID_ATT
-#define PCI_DEVICE_ID_AGERE_FW643      0x5901
-
 static int __devinit pci_probe(struct pci_dev *dev,
                               const struct pci_device_id *ent)
 {
        struct fw_ohci *ohci;
-       u32 bus_options, max_receive, link_speed, version;
+       u32 bus_options, max_receive, link_speed, version, link_enh;
        u64 guid;
-       int err;
+       int i, err, n_ir, n_it;
        size_t size;
 
        ohci = kzalloc(sizeof(*ohci), GFP_KERNEL);
@@ -2438,7 +2653,7 @@ static int __devinit pci_probe(struct pci_dev *dev,
 
        fw_card_initialize(&ohci->card, &ohci_driver, &dev->dev);
 
-       ohci_pmac_on(dev);
+       pmac_ohci_on(dev);
 
        err = pci_enable_device(dev);
        if (err) {
@@ -2451,6 +2666,7 @@ static int __devinit pci_probe(struct pci_dev *dev,
        pci_set_drvdata(dev, ohci);
 
        spin_lock_init(&ohci->lock);
+       mutex_init(&ohci->phy_reg_mutex);
 
        tasklet_init(&ohci->bus_reset_tasklet,
                     bus_reset_tasklet, (unsigned long)ohci);
@@ -2468,35 +2684,32 @@ static int __devinit pci_probe(struct pci_dev *dev,
                goto fail_iomem;
        }
 
-       version = reg_read(ohci, OHCI1394_Version) & 0x00ff00ff;
-#if 0
-       /* FIXME: make it a context option or remove dual-buffer mode */
-       ohci->use_dualbuffer = version >= OHCI_VERSION_1_1;
-#endif
+       for (i = 0; i < ARRAY_SIZE(ohci_quirks); i++)
+               if (ohci_quirks[i].vendor == dev->vendor &&
+                   (ohci_quirks[i].device == dev->device ||
+                    ohci_quirks[i].device == (unsigned short)PCI_ANY_ID)) {
+                       ohci->quirks = ohci_quirks[i].flags;
+                       break;
+               }
+       if (param_quirks)
+               ohci->quirks = param_quirks;
 
-       /* dual-buffer mode is broken if more than one IR context is active */
-       if (dev->vendor == PCI_VENDOR_ID_AGERE &&
-           dev->device == PCI_DEVICE_ID_AGERE_FW643)
-               ohci->use_dualbuffer = false;
-
-       /* dual-buffer mode is broken */
-       if (dev->vendor == PCI_VENDOR_ID_RICOH &&
-           dev->device == PCI_DEVICE_ID_RICOH_R5C832)
-               ohci->use_dualbuffer = false;
-
-/* x86-32 currently doesn't use highmem for dma_alloc_coherent */
-#if !defined(CONFIG_X86_32)
-       /* dual-buffer mode is broken with descriptor addresses above 2G */
-       if (dev->vendor == PCI_VENDOR_ID_TI &&
-           dev->device == PCI_DEVICE_ID_TI_TSB43AB22)
-               ohci->use_dualbuffer = false;
-#endif
+       /* TI OHCI-Lynx and compatible: set recommended configuration bits. */
+       if (dev->vendor == PCI_VENDOR_ID_TI) {
+               pci_read_config_dword(dev, PCI_CFG_TI_LinkEnh, &link_enh);
 
-#if defined(CONFIG_PPC_PMAC) && defined(CONFIG_PPC32)
-       ohci->old_uninorth = dev->vendor == PCI_VENDOR_ID_APPLE &&
-                            dev->device == PCI_DEVICE_ID_APPLE_UNI_N_FW;
-#endif
-       ohci->bus_reset_packet_quirk = dev->vendor == PCI_VENDOR_ID_TI;
+               /* adjust latency of ATx FIFO: use 1.7 KB threshold */
+               link_enh &= ~TI_LinkEnh_atx_thresh_mask;
+               link_enh |= TI_LinkEnh_atx_thresh_1_7K;
+
+               /* use priority arbitration for asynchronous responses */
+               link_enh |= TI_LinkEnh_enab_unfair;
+
+               /* required for aPhyEnhanceEnable to work */
+               link_enh |= TI_LinkEnh_enab_accel;
+
+               pci_write_config_dword(dev, PCI_CFG_TI_LinkEnh, link_enh);
+       }
 
        ar_context_init(&ohci->ar_request_ctx, ohci,
                        OHCI1394_AsReqRcvContextControlSet);
@@ -2511,17 +2724,19 @@ static int __devinit pci_probe(struct pci_dev *dev,
                     OHCI1394_AsRspTrContextControlSet, handle_at_packet);
 
        reg_write(ohci, OHCI1394_IsoRecvIntMaskSet, ~0);
-       ohci->it_context_mask = reg_read(ohci, OHCI1394_IsoRecvIntMaskSet);
+       ohci->ir_context_channels = ~0ULL;
+       ohci->ir_context_mask = reg_read(ohci, OHCI1394_IsoRecvIntMaskSet);
        reg_write(ohci, OHCI1394_IsoRecvIntMaskClear, ~0);
-       size = sizeof(struct iso_context) * hweight32(ohci->it_context_mask);
-       ohci->it_context_list = kzalloc(size, GFP_KERNEL);
+       n_ir = hweight32(ohci->ir_context_mask);
+       size = sizeof(struct iso_context) * n_ir;
+       ohci->ir_context_list = kzalloc(size, GFP_KERNEL);
 
        reg_write(ohci, OHCI1394_IsoXmitIntMaskSet, ~0);
-       ohci->ir_context_channels = ~0ULL;
-       ohci->ir_context_mask = reg_read(ohci, OHCI1394_IsoXmitIntMaskSet);
+       ohci->it_context_mask = reg_read(ohci, OHCI1394_IsoXmitIntMaskSet);
        reg_write(ohci, OHCI1394_IsoXmitIntMaskClear, ~0);
-       size = sizeof(struct iso_context) * hweight32(ohci->ir_context_mask);
-       ohci->ir_context_list = kzalloc(size, GFP_KERNEL);
+       n_it = hweight32(ohci->it_context_mask);
+       size = sizeof(struct iso_context) * n_it;
+       ohci->it_context_list = kzalloc(size, GFP_KERNEL);
 
        if (ohci->it_context_list == NULL || ohci->ir_context_list == NULL) {
                err = -ENOMEM;
@@ -2548,8 +2763,11 @@ static int __devinit pci_probe(struct pci_dev *dev,
        if (err)
                goto fail_self_id;
 
-       fw_notify("Added fw-ohci device %s, OHCI version %x.%x\n",
-                 dev_name(&dev->dev), version >> 16, version & 0xff);
+       version = reg_read(ohci, OHCI1394_Version) & 0x00ff00ff;
+       fw_notify("Added fw-ohci device %s, OHCI v%x.%x, "
+                 "%d IR + %d IT contexts, quirks 0x%x\n",
+                 dev_name(&dev->dev), version >> 16, version & 0xff,
+                 n_ir, n_it, ohci->quirks);
 
        return 0;
 
@@ -2570,7 +2788,7 @@ static int __devinit pci_probe(struct pci_dev *dev,
        pci_disable_device(dev);
  fail_free:
        kfree(&ohci->card);
-       ohci_pmac_off(dev);
+       pmac_ohci_off(dev);
  fail:
        if (err == -ENOMEM)
                fw_error("Out of memory\n");
@@ -2609,11 +2827,12 @@ static void pci_remove(struct pci_dev *dev)
        context_release(&ohci->at_response_ctx);
        kfree(ohci->it_context_list);
        kfree(ohci->ir_context_list);
+       pci_disable_msi(dev);
        pci_iounmap(dev, ohci->registers);
        pci_release_region(dev, 0);
        pci_disable_device(dev);
        kfree(&ohci->card);
-       ohci_pmac_off(dev);
+       pmac_ohci_off(dev);
 
        fw_notify("Removed fw-ohci device.\n");
 }
@@ -2626,6 +2845,7 @@ static int pci_suspend(struct pci_dev *dev, pm_message_t state)
 
        software_reset(ohci);
        free_irq(dev->irq, ohci);
+       pci_disable_msi(dev);
        err = pci_save_state(dev);
        if (err) {
                fw_error("pci_save_state failed\n");
@@ -2634,7 +2854,7 @@ static int pci_suspend(struct pci_dev *dev, pm_message_t state)
        err = pci_set_power_state(dev, pci_choose_state(dev, state));
        if (err)
                fw_error("pci_set_power_state failed with %d\n", err);
-       ohci_pmac_off(dev);
+       pmac_ohci_off(dev);
 
        return 0;
 }
@@ -2644,7 +2864,7 @@ static int pci_resume(struct pci_dev *dev)
        struct fw_ohci *ohci = pci_get_drvdata(dev);
        int err;
 
-       ohci_pmac_on(dev);
+       pmac_ohci_on(dev);
        pci_set_power_state(dev, PCI_D0);
        pci_restore_state(dev);
        err = pci_enable_device(dev);
@@ -2657,7 +2877,7 @@ static int pci_resume(struct pci_dev *dev)
 }
 #endif
 
-static struct pci_device_id pci_table[] = {
+static const struct pci_device_id pci_table[] = {
        { PCI_DEVICE_CLASS(PCI_CLASS_SERIAL_FIREWIRE_OHCI, ~0) },
        { }
 };