linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / drivers / pci / hotplug / ibmphp_hpc.c
index 105dc70..1a3eb8d 100644 (file)
@@ -29,6 +29,7 @@
 
 #include <linux/wait.h>
 #include <linux/time.h>
+#include <linux/delay.h>
 #include <linux/module.h>
 #include <linux/pci.h>
 #include <linux/smp_lock.h>
@@ -63,7 +64,7 @@ static int to_debug = FALSE;
 #define WPG_I2C_OR             0x2000  // I2C OR operation
 
 //----------------------------------------------------------------------------
-// Command set for I2C Master Operation Setup Regisetr
+// Command set for I2C Master Operation Setup Register
 //----------------------------------------------------------------------------
 #define WPG_READATADDR_MASK    0x00010000      // read,bytes,I2C shifted,index
 #define WPG_WRITEATADDR_MASK   0x40010000      // write,bytes,I2C shifted,index
@@ -107,8 +108,8 @@ static struct semaphore sem_exit;   // make sure polling thread goes away
 //----------------------------------------------------------------------------
 // local function prototypes
 //----------------------------------------------------------------------------
-static u8 i2c_ctrl_read (struct controller *, void *, u8);
-static u8 i2c_ctrl_write (struct controller *, void *, u8, u8);
+static u8 i2c_ctrl_read (struct controller *, void __iomem *, u8);
+static u8 i2c_ctrl_write (struct controller *, void __iomem *, u8, u8);
 static u8 hpc_writecmdtoindex (u8, u8);
 static u8 hpc_readcmdtoindex (u8, u8);
 static void get_hpc_access (void);
@@ -117,7 +118,7 @@ static void poll_hpc (void);
 static int process_changeinstatus (struct slot *, struct slot *);
 static int process_changeinlatch (u8, u8, struct controller *);
 static int hpc_poll_thread (void *);
-static int hpc_wait_ctlr_notworking (int, struct controller *, void *, u8 *);
+static int hpc_wait_ctlr_notworking (int, struct controller *, void __iomem *, u8 *);
 //----------------------------------------------------------------------------
 
 
@@ -146,11 +147,11 @@ void __init ibmphp_hpc_initvars (void)
 * Action:  read from HPC over I2C
 *
 *---------------------------------------------------------------------*/
-static u8 i2c_ctrl_read (struct controller *ctlr_ptr, void *WPGBbar, u8 index)
+static u8 i2c_ctrl_read (struct controller *ctlr_ptr, void __iomem *WPGBbar, u8 index)
 {
        u8 status;
        int i;
-       void *wpg_addr;         // base addr + offset
+       void __iomem *wpg_addr; // base addr + offset
        unsigned long wpg_data; // data to/from WPG LOHI format
        unsigned long ultemp;
        unsigned long data;     // actual data HILO format
@@ -205,7 +206,7 @@ static u8 i2c_ctrl_read (struct controller *ctlr_ptr, void *WPGBbar, u8 index)
        // READ - step 4 : wait until start operation bit clears
        i = CMD_COMPLETE_TOUT_SEC;
        while (i) {
-               long_delay (1 * HZ / 100);
+               msleep(10);
                wpg_addr = WPGBbar + WPG_I2CMCNTL_OFFSET;
                wpg_data = readl (wpg_addr);
                data = swab32 (wpg_data);
@@ -221,7 +222,7 @@ static u8 i2c_ctrl_read (struct controller *ctlr_ptr, void *WPGBbar, u8 index)
        // READ - step 5 : read I2C status register
        i = CMD_COMPLETE_TOUT_SEC;
        while (i) {
-               long_delay (1 * HZ / 100);
+               msleep(10);
                wpg_addr = WPGBbar + WPG_I2CSTAT_OFFSET;
                wpg_data = readl (wpg_addr);
                data = swab32 (wpg_data);
@@ -254,10 +255,10 @@ static u8 i2c_ctrl_read (struct controller *ctlr_ptr, void *WPGBbar, u8 index)
 *
 * Return   0 or error codes
 *---------------------------------------------------------------------*/
-static u8 i2c_ctrl_write (struct controller *ctlr_ptr, void *WPGBbar, u8 index, u8 cmd)
+static u8 i2c_ctrl_write (struct controller *ctlr_ptr, void __iomem *WPGBbar, u8 index, u8 cmd)
 {
        u8 rc;
-       void *wpg_addr;         // base addr + offset
+       void __iomem *wpg_addr; // base addr + offset
        unsigned long wpg_data; // data to/from WPG LOHI format 
        unsigned long ultemp;
        unsigned long data;     // actual data HILO format
@@ -316,7 +317,7 @@ static u8 i2c_ctrl_write (struct controller *ctlr_ptr, void *WPGBbar, u8 index,
        // WRITE - step 4 : wait until start operation bit clears
        i = CMD_COMPLETE_TOUT_SEC;
        while (i) {
-               long_delay (1 * HZ / 100);
+               msleep(10);
                wpg_addr = WPGBbar + WPG_I2CMCNTL_OFFSET;
                wpg_data = readl (wpg_addr);
                data = swab32 (wpg_data);
@@ -333,7 +334,7 @@ static u8 i2c_ctrl_write (struct controller *ctlr_ptr, void *WPGBbar, u8 index,
        // WRITE - step 5 : read I2C status register
        i = CMD_COMPLETE_TOUT_SEC;
        while (i) {
-               long_delay (1 * HZ / 100);
+               msleep(10);
                wpg_addr = WPGBbar + WPG_I2CSTAT_OFFSET;
                wpg_data = readl (wpg_addr);
                data = swab32 (wpg_data);
@@ -398,7 +399,7 @@ static u8 pci_ctrl_write (struct controller *ctrl, u8 offset, u8 data)
        return rc;
 }
 
-static u8 ctrl_read (struct controller *ctlr, void *base, u8 offset)
+static u8 ctrl_read (struct controller *ctlr, void __iomem *base, u8 offset)
 {
        u8 rc;
        switch (ctlr->ctlr_type) {
@@ -418,7 +419,7 @@ static u8 ctrl_read (struct controller *ctlr, void *base, u8 offset)
        return rc;
 }
 
-static u8 ctrl_write (struct controller *ctlr, void *base, u8 offset, u8 data)
+static u8 ctrl_write (struct controller *ctlr, void __iomem *base, u8 offset, u8 data)
 {
        u8 rc = 0;
        switch (ctlr->ctlr_type) {
@@ -535,7 +536,7 @@ static u8 hpc_readcmdtoindex (u8 cmd, u8 index)
 *---------------------------------------------------------------------*/
 int ibmphp_hpc_readslot (struct slot * pslot, u8 cmd, u8 * pstatus)
 {
-       void *wpg_bbar = NULL;
+       void __iomem *wpg_bbar = NULL;
        struct controller *ctlr_ptr;
        struct list_head *pslotlist;
        u8 index, status;
@@ -659,7 +660,7 @@ int ibmphp_hpc_readslot (struct slot * pslot, u8 cmd, u8 * pstatus)
        
        // remove physical to logical address mapping
        if ((ctlr_ptr->ctlr_type == 2) || (ctlr_ptr->ctlr_type == 4))
-               iounmap (wpg_bbar);     
+               iounmap (wpg_bbar);
        
        free_hpc_access ();
 
@@ -674,7 +675,7 @@ int ibmphp_hpc_readslot (struct slot * pslot, u8 cmd, u8 * pstatus)
 *---------------------------------------------------------------------*/
 int ibmphp_hpc_writeslot (struct slot * pslot, u8 cmd)
 {
-       void *wpg_bbar = NULL;
+       void __iomem *wpg_bbar = NULL;
        struct controller *ctlr_ptr;
        u8 index, status;
        int busindex;
@@ -748,7 +749,7 @@ int ibmphp_hpc_writeslot (struct slot * pslot, u8 cmd)
                                        done = TRUE;
                        }
                        if (!done) {
-                               long_delay (1 * HZ);
+                               msleep(1000);
                                if (timeout < 1) {
                                        done = TRUE;
                                        err ("%s - Error command complete timeout\n", __FUNCTION__);
@@ -763,7 +764,7 @@ int ibmphp_hpc_writeslot (struct slot * pslot, u8 cmd)
 
        // remove physical to logical address mapping
        if ((ctlr_ptr->ctlr_type == 2) || (ctlr_ptr->ctlr_type == 4))
-               iounmap (wpg_bbar);     
+               iounmap (wpg_bbar);
        free_hpc_access ();
 
        debug_polling ("%s - Exit rc[%d]\n", __FUNCTION__, rc);
@@ -834,7 +835,7 @@ static void poll_hpc (void)
                if (ibmphp_shutdown) 
                        break;
                
-               /* try to get the lock to do some kind of harware access */
+               /* try to get the lock to do some kind of hardware access */
                down (&semOperations);
 
                switch (poll_state) {
@@ -891,7 +892,7 @@ static void poll_hpc (void)
                case POLL_SLEEP:
                        /* don't sleep with a lock on the hardware */
                        up (&semOperations);
-                       long_delay (POLL_INTERVAL_SEC * HZ);
+                       msleep(POLL_INTERVAL_SEC * 1000);
 
                        if (ibmphp_shutdown) 
                                break;
@@ -905,11 +906,10 @@ static void poll_hpc (void)
                                poll_state = POLL_LATCH_REGISTER;
                        break;
                }       
-               /* give up the harware semaphore */
+               /* give up the hardware semaphore */
                up (&semOperations);
                /* sleep for a short time just for good measure */
-               set_current_state (TASK_INTERRUPTIBLE);
-               schedule_timeout (HZ/10);
+               msleep(100);
        }
        up (&sem_exit);
        debug ("%s - Exit\n", __FUNCTION__);
@@ -974,7 +974,7 @@ static int process_changeinstatus (struct slot *pslot, struct slot *poldslot)
                        if (SLOT_PWRGD (pslot->status)) {
                                // power goes on and off after closing latch
                                // check again to make sure power is still ON
-                               long_delay (1 * HZ);
+                               msleep(1000);
                                rc = ibmphp_hpc_readslot (pslot, READ_SLOTSTATUS, &status);
                                if (SLOT_PWRGD (status))
                                        update = TRUE;
@@ -1130,7 +1130,7 @@ void __exit ibmphp_hpc_stop_poll_thread (void)
 * Return   0, HPC_ERROR
 * Value:
 *---------------------------------------------------------------------*/
-static int hpc_wait_ctlr_notworking (int timeout, struct controller *ctlr_ptr, void *wpg_bbar,
+static int hpc_wait_ctlr_notworking (int timeout, struct controller *ctlr_ptr, void __iomem *wpg_bbar,
                                    u8 * pstatus)
 {
        int rc = 0;
@@ -1147,7 +1147,7 @@ static int hpc_wait_ctlr_notworking (int timeout, struct controller *ctlr_ptr, v
                if (CTLR_WORKING (*pstatus) == HPC_CTLR_WORKING_NO)
                        done = TRUE;
                if (!done) {
-                       long_delay (1 * HZ);
+                       msleep(1000);
                        if (timeout < 1) {
                                done = TRUE;
                                err ("HPCreadslot - Error ctlr timeout\n");