firewire: add CSR NODE_IDS support
authorClemens Ladisch <clemens@ladisch.de>
Thu, 10 Jun 2010 06:25:19 +0000 (08:25 +0200)
committerClemens Ladisch <clemens@ladisch.de>
Thu, 10 Jun 2010 06:25:19 +0000 (08:25 +0200)
The NODE_IDS register, and especially its bus_id field, is quite
useless because 1394.1 requires that the bus_id field always stays
0x3ff.  However, the 1394 specification requires this register on all
transaction capable nodes, and the Base 1394 Test Suite tests for it,
so we better implement it.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
drivers/firewire/core-transaction.c
drivers/firewire/core.h
drivers/firewire/ohci.c

index a4d8109edec29ead1c75c96e48a61260b40e66fd..16ffa27d23b747033c08ddc85ac0b1449291fb7d 100644 (file)
@@ -1023,6 +1023,17 @@ static void handle_registers(struct fw_card *card, struct fw_request *request,
                }
                break;
 
+       case CSR_NODE_IDS:
+               if (tcode == TCODE_READ_QUADLET_REQUEST)
+                       *data = cpu_to_be32(card->driver->
+                                       read_csr_reg(card, CSR_NODE_IDS));
+               else if (tcode == TCODE_WRITE_QUADLET_REQUEST)
+                       card->driver->write_csr_reg(card, CSR_NODE_IDS,
+                                                   be32_to_cpu(*data));
+               else
+                       rcode = RCODE_TYPE_ERROR;
+               break;
+
        case CSR_CYCLE_TIME:
                if (TCODE_IS_READ_REQUEST(tcode) && length == 4)
                        *data = cpu_to_be32(card->driver->
index c19e9873e433f998f62e04be061a6e166b0da831..efcdeb2e31e6a1dd1fd005a1a39793629b9fef29 100644 (file)
@@ -76,6 +76,7 @@ struct fw_card_driver {
                               int node_id, int generation);
 
        u32 (*read_csr_reg)(struct fw_card *card, int csr_offset);
+       void (*write_csr_reg)(struct fw_card *card, int csr_offset, u32 value);
 
        struct fw_iso_context *
        (*allocate_iso_context)(struct fw_card *card,
index a8093a9a3fc8e55001c885e599a75f589bc7144c..a55fbbce9e79785bd015c07db5988005757184d5 100644 (file)
@@ -1974,6 +1974,9 @@ static u32 ohci_read_csr_reg(struct fw_card *card, int csr_offset)
        struct fw_ohci *ohci = fw_ohci(card);
 
        switch (csr_offset) {
+       case CSR_NODE_IDS:
+               return reg_read(ohci, OHCI1394_NodeID) << 16;
+
        case CSR_CYCLE_TIME:
                return get_cycle_time(ohci);
 
@@ -1983,6 +1986,22 @@ static u32 ohci_read_csr_reg(struct fw_card *card, int csr_offset)
        }
 }
 
+static void ohci_write_csr_reg(struct fw_card *card, int csr_offset, u32 value)
+{
+       struct fw_ohci *ohci = fw_ohci(card);
+
+       switch (csr_offset) {
+       case CSR_NODE_IDS:
+               reg_write(ohci, OHCI1394_NodeID, value >> 16);
+               flush_writes(ohci);
+               break;
+
+       default:
+               WARN_ON(1);
+               break;
+       }
+}
+
 static void copy_iso_headers(struct iso_context *ctx, void *p)
 {
        int i = ctx->header_length;
@@ -2421,6 +2440,7 @@ static const struct fw_card_driver ohci_driver = {
        .cancel_packet          = ohci_cancel_packet,
        .enable_phys_dma        = ohci_enable_phys_dma,
        .read_csr_reg           = ohci_read_csr_reg,
+       .write_csr_reg          = ohci_write_csr_reg,
 
        .allocate_iso_context   = ohci_allocate_iso_context,
        .free_iso_context       = ohci_free_iso_context,