]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
orinoco: Add function to execute Hermes initialisation commands synchronously
authorDavid Kilroy <kilroyd@gmail.com>
Thu, 21 Aug 2008 22:27:50 +0000 (23:27 +0100)
committerJohn W. Linville <linville@tuxdriver.com>
Fri, 22 Aug 2008 23:28:04 +0000 (19:28 -0400)
The current synchronous execution function doesn't work
for certain Hermes commands which clear the MAGIC number from
SWSUPPORT0. These commands seem to be related to initialisation or
programming, for example HERMES_CMD_INIT.

Replicate hermes_docmd_wait for commands which clear the MAGIC number
from SWSUPPORT0. This version accepts two extra arguments which are
passed straight to the firmware.

Functionality copied out of hermes_init.

Signed-off-by: David Kilroy <kilroyd@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/hermes.c
drivers/net/wireless/hermes.h

index 240118f335850bb04c3a92b3c274687e4f0684dc..bfa375369df3fc517cd639c2db190b7518b9d782 100644 (file)
@@ -116,6 +116,61 @@ static int hermes_issue_cmd(hermes_t *hw, u16 cmd, u16 param0,
  * Function definitions
  */
 
+/* For doing cmds that wipe the magic constant in SWSUPPORT0 */
+int hermes_doicmd_wait(hermes_t *hw, u16 cmd,
+                      u16 parm0, u16 parm1, u16 parm2,
+                      struct hermes_response *resp)
+{
+       int err = 0;
+       int k;
+       u16 status, reg;
+
+       err = hermes_issue_cmd(hw, cmd, parm0, parm1, parm2);
+       if (err)
+               return err;
+
+       reg = hermes_read_regn(hw, EVSTAT);
+       k = CMD_INIT_TIMEOUT;
+       while ((!(reg & HERMES_EV_CMD)) && k) {
+               k--;
+               udelay(10);
+               reg = hermes_read_regn(hw, EVSTAT);
+       }
+
+       hermes_write_regn(hw, SWSUPPORT0, HERMES_MAGIC);
+
+       if (!hermes_present(hw)) {
+               DEBUG(0, "hermes @ 0x%x: Card removed during reset.\n",
+                      hw->iobase);
+               err = -ENODEV;
+               goto out;
+       }
+
+       if (!(reg & HERMES_EV_CMD)) {
+               printk(KERN_ERR "hermes @ %p: "
+                      "Timeout waiting for card to reset (reg=0x%04x)!\n",
+                      hw->iobase, reg);
+               err = -ETIMEDOUT;
+               goto out;
+       }
+
+       status = hermes_read_regn(hw, STATUS);
+       if (resp) {
+               resp->status = status;
+               resp->resp0 = hermes_read_regn(hw, RESP0);
+               resp->resp1 = hermes_read_regn(hw, RESP1);
+               resp->resp2 = hermes_read_regn(hw, RESP2);
+       }
+
+       hermes_write_regn(hw, EVACK, HERMES_EV_CMD);
+
+       if (status & HERMES_STATUS_RESULT)
+               err = -EIO;
+out:
+       return err;
+}
+EXPORT_SYMBOL(hermes_doicmd_wait);
+
 void hermes_struct_init(hermes_t *hw, void __iomem *address, int reg_spacing)
 {
        hw->iobase = address;
@@ -126,7 +181,7 @@ EXPORT_SYMBOL(hermes_struct_init);
 
 int hermes_init(hermes_t *hw)
 {
-       u16 status, reg;
+       u16 reg;
        int err = 0;
        int k;
 
@@ -164,43 +219,8 @@ int hermes_init(hermes_t *hw)
 
        /* We don't use hermes_docmd_wait here, because the reset wipes
           the magic constant in SWSUPPORT0 away, and it gets confused */
-       err = hermes_issue_cmd(hw, HERMES_CMD_INIT, 0, 0, 0);
-       if (err)
-               return err;
-
-       reg = hermes_read_regn(hw, EVSTAT);
-       k = CMD_INIT_TIMEOUT;
-       while ( (! (reg & HERMES_EV_CMD)) && k) {
-               k--;
-               udelay(10);
-               reg = hermes_read_regn(hw, EVSTAT);
-       }
-
-       hermes_write_regn(hw, SWSUPPORT0, HERMES_MAGIC);
-
-       if (! hermes_present(hw)) {
-               DEBUG(0, "hermes @ 0x%x: Card removed during reset.\n",
-                      hw->iobase);
-               err = -ENODEV;
-               goto out;
-       }
-               
-       if (! (reg & HERMES_EV_CMD)) {
-               printk(KERN_ERR "hermes @ %p: " 
-                      "Timeout waiting for card to reset (reg=0x%04x)!\n",
-                      hw->iobase, reg);
-               err = -ETIMEDOUT;
-               goto out;
-       }
-
-       status = hermes_read_regn(hw, STATUS);
-
-       hermes_write_regn(hw, EVACK, HERMES_EV_CMD);
+       err = hermes_doicmd_wait(hw, HERMES_CMD_INIT, 0, 0, 0, NULL);
 
-       if (status & HERMES_STATUS_RESULT)
-               err = -EIO;
-
- out:
        return err;
 }
 EXPORT_SYMBOL(hermes_init);
index 8e3f0e3edb58f57e6a20aef2187c8317acb8ddc3..287f5363fda298bb0f0fc8b1148f44252a5eab83 100644 (file)
@@ -353,6 +353,9 @@ void hermes_struct_init(hermes_t *hw, void __iomem *address, int reg_spacing);
 int hermes_init(hermes_t *hw);
 int hermes_docmd_wait(hermes_t *hw, u16 cmd, u16 parm0,
                      struct hermes_response *resp);
+int hermes_doicmd_wait(hermes_t *hw, u16 cmd,
+                      u16 parm0, u16 parm1, u16 parm2,
+                      struct hermes_response *resp);
 int hermes_allocate(hermes_t *hw, u16 size, u16 *fid);
 
 int hermes_bap_pread(hermes_t *hw, int bap, void *buf, int len,