diff options
author | Clemens Ladisch <clemens@ladisch.de> | 2010-04-04 09:19:52 -0400 |
---|---|---|
committer | Stefan Richter <stefanr@s5r6.in-berlin.de> | 2010-04-10 10:51:14 -0400 |
commit | 4a96b4fcd6b35e9233df07b3c9ab38091edcfe7e (patch) | |
tree | 9a1e7500b64d98845607266b8f15b7a5384aa60f /drivers/firewire/ohci.c | |
parent | ca658b1e29d6be939207532e337fb640eb697f71 (diff) |
firewire: ohci: add a function for reading PHY registers
Move the register reading code from ohci_update_phy_reg() into
a function which can be used separately.
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Diffstat (limited to 'drivers/firewire/ohci.c')
-rw-r--r-- | drivers/firewire/ohci.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c index e33917bf97d2..8ebccda94df9 100644 --- a/drivers/firewire/ohci.c +++ b/drivers/firewire/ohci.c | |||
@@ -460,22 +460,36 @@ static inline void flush_writes(const struct fw_ohci *ohci) | |||
460 | reg_read(ohci, OHCI1394_Version); | 460 | reg_read(ohci, OHCI1394_Version); |
461 | } | 461 | } |
462 | 462 | ||
463 | static int ohci_update_phy_reg(struct fw_card *card, int addr, | 463 | static int read_phy_reg(struct fw_card *card, int addr, u32 *value) |
464 | int clear_bits, int set_bits) | ||
465 | { | 464 | { |
466 | struct fw_ohci *ohci = fw_ohci(card); | 465 | struct fw_ohci *ohci = fw_ohci(card); |
467 | u32 val, old; | 466 | u32 val; |
468 | 467 | ||
469 | reg_write(ohci, OHCI1394_PhyControl, OHCI1394_PhyControl_Read(addr)); | 468 | reg_write(ohci, OHCI1394_PhyControl, OHCI1394_PhyControl_Read(addr)); |
470 | flush_writes(ohci); | 469 | flush_writes(ohci); |
471 | msleep(2); | 470 | msleep(2); |
472 | val = reg_read(ohci, OHCI1394_PhyControl); | 471 | val = reg_read(ohci, OHCI1394_PhyControl); |
473 | if ((val & OHCI1394_PhyControl_ReadDone) == 0) { | 472 | if ((val & OHCI1394_PhyControl_ReadDone) == 0) { |
474 | fw_error("failed to set phy reg bits.\n"); | 473 | fw_error("failed to read phy reg bits\n"); |
475 | return -EBUSY; | 474 | return -EBUSY; |
476 | } | 475 | } |
477 | 476 | ||
478 | old = OHCI1394_PhyControl_ReadData(val); | 477 | *value = OHCI1394_PhyControl_ReadData(val); |
478 | |||
479 | return 0; | ||
480 | } | ||
481 | |||
482 | static int ohci_update_phy_reg(struct fw_card *card, int addr, | ||
483 | int clear_bits, int set_bits) | ||
484 | { | ||
485 | struct fw_ohci *ohci = fw_ohci(card); | ||
486 | u32 old; | ||
487 | int err; | ||
488 | |||
489 | err = read_phy_reg(card, addr, &old); | ||
490 | if (err < 0) | ||
491 | return err; | ||
492 | |||
479 | old = (old & ~clear_bits) | set_bits; | 493 | old = (old & ~clear_bits) | set_bits; |
480 | reg_write(ohci, OHCI1394_PhyControl, | 494 | reg_write(ohci, OHCI1394_PhyControl, |
481 | OHCI1394_PhyControl_Write(addr, old)); | 495 | OHCI1394_PhyControl_Write(addr, old)); |