aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/hotplug/ibmphp_hpc.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pci/hotplug/ibmphp_hpc.c')
-rw-r--r--drivers/pci/hotplug/ibmphp_hpc.c64
1 files changed, 33 insertions, 31 deletions
diff --git a/drivers/pci/hotplug/ibmphp_hpc.c b/drivers/pci/hotplug/ibmphp_hpc.c
index 1a3eb8d3d4cb..c3ac98a0a6a6 100644
--- a/drivers/pci/hotplug/ibmphp_hpc.c
+++ b/drivers/pci/hotplug/ibmphp_hpc.c
@@ -34,9 +34,11 @@
34#include <linux/pci.h> 34#include <linux/pci.h>
35#include <linux/smp_lock.h> 35#include <linux/smp_lock.h>
36#include <linux/init.h> 36#include <linux/init.h>
37#include <linux/mutex.h>
38
37#include "ibmphp.h" 39#include "ibmphp.h"
38 40
39static int to_debug = FALSE; 41static int to_debug = 0;
40#define debug_polling(fmt, arg...) do { if (to_debug) debug (fmt, arg); } while (0) 42#define debug_polling(fmt, arg...) do { if (to_debug) debug (fmt, arg); } while (0)
41 43
42//---------------------------------------------------------------------------- 44//----------------------------------------------------------------------------
@@ -93,15 +95,15 @@ static int to_debug = FALSE;
93//---------------------------------------------------------------------------- 95//----------------------------------------------------------------------------
94// macro utilities 96// macro utilities
95//---------------------------------------------------------------------------- 97//----------------------------------------------------------------------------
96// if bits 20,22,25,26,27,29,30 are OFF return TRUE 98// if bits 20,22,25,26,27,29,30 are OFF return 1
97#define HPC_I2CSTATUS_CHECK(s) ((u8)((s & 0x00000A76) ? FALSE : TRUE)) 99#define HPC_I2CSTATUS_CHECK(s) ((u8)((s & 0x00000A76) ? 0 : 1))
98 100
99//---------------------------------------------------------------------------- 101//----------------------------------------------------------------------------
100// global variables 102// global variables
101//---------------------------------------------------------------------------- 103//----------------------------------------------------------------------------
102static int ibmphp_shutdown; 104static int ibmphp_shutdown;
103static int tid_poll; 105static int tid_poll;
104static struct semaphore sem_hpcaccess; // lock access to HPC 106static struct mutex sem_hpcaccess; // lock access to HPC
105static struct semaphore semOperations; // lock all operations and 107static struct semaphore semOperations; // lock all operations and
106 // access to data structures 108 // access to data structures
107static struct semaphore sem_exit; // make sure polling thread goes away 109static struct semaphore sem_exit; // make sure polling thread goes away
@@ -131,11 +133,11 @@ void __init ibmphp_hpc_initvars (void)
131{ 133{
132 debug ("%s - Entry\n", __FUNCTION__); 134 debug ("%s - Entry\n", __FUNCTION__);
133 135
134 init_MUTEX (&sem_hpcaccess); 136 mutex_init(&sem_hpcaccess);
135 init_MUTEX (&semOperations); 137 init_MUTEX (&semOperations);
136 init_MUTEX_LOCKED (&sem_exit); 138 init_MUTEX_LOCKED (&sem_exit);
137 to_debug = FALSE; 139 to_debug = 0;
138 ibmphp_shutdown = FALSE; 140 ibmphp_shutdown = 0;
139 tid_poll = 0; 141 tid_poll = 0;
140 142
141 debug ("%s - Exit\n", __FUNCTION__); 143 debug ("%s - Exit\n", __FUNCTION__);
@@ -737,21 +739,21 @@ int ibmphp_hpc_writeslot (struct slot * pslot, u8 cmd)
737 // check controller is still not working on the command 739 // check controller is still not working on the command
738 //-------------------------------------------------------------------- 740 //--------------------------------------------------------------------
739 timeout = CMD_COMPLETE_TOUT_SEC; 741 timeout = CMD_COMPLETE_TOUT_SEC;
740 done = FALSE; 742 done = 0;
741 while (!done) { 743 while (!done) {
742 rc = hpc_wait_ctlr_notworking (HPC_CTLR_WORKING_TOUT, ctlr_ptr, wpg_bbar, 744 rc = hpc_wait_ctlr_notworking (HPC_CTLR_WORKING_TOUT, ctlr_ptr, wpg_bbar,
743 &status); 745 &status);
744 if (!rc) { 746 if (!rc) {
745 if (NEEDTOCHECK_CMDSTATUS (cmd)) { 747 if (NEEDTOCHECK_CMDSTATUS (cmd)) {
746 if (CTLR_FINISHED (status) == HPC_CTLR_FINISHED_YES) 748 if (CTLR_FINISHED (status) == HPC_CTLR_FINISHED_YES)
747 done = TRUE; 749 done = 1;
748 } else 750 } else
749 done = TRUE; 751 done = 1;
750 } 752 }
751 if (!done) { 753 if (!done) {
752 msleep(1000); 754 msleep(1000);
753 if (timeout < 1) { 755 if (timeout < 1) {
754 done = TRUE; 756 done = 1;
755 err ("%s - Error command complete timeout\n", __FUNCTION__); 757 err ("%s - Error command complete timeout\n", __FUNCTION__);
756 rc = -EFAULT; 758 rc = -EFAULT;
757 } else 759 } else
@@ -778,7 +780,7 @@ int ibmphp_hpc_writeslot (struct slot * pslot, u8 cmd)
778*---------------------------------------------------------------------*/ 780*---------------------------------------------------------------------*/
779static void get_hpc_access (void) 781static void get_hpc_access (void)
780{ 782{
781 down (&sem_hpcaccess); 783 mutex_lock(&sem_hpcaccess);
782} 784}
783 785
784/*---------------------------------------------------------------------- 786/*----------------------------------------------------------------------
@@ -786,7 +788,7 @@ static void get_hpc_access (void)
786*---------------------------------------------------------------------*/ 788*---------------------------------------------------------------------*/
787void free_hpc_access (void) 789void free_hpc_access (void)
788{ 790{
789 up (&sem_hpcaccess); 791 mutex_unlock(&sem_hpcaccess);
790} 792}
791 793
792/*---------------------------------------------------------------------- 794/*----------------------------------------------------------------------
@@ -797,7 +799,7 @@ void free_hpc_access (void)
797void ibmphp_lock_operations (void) 799void ibmphp_lock_operations (void)
798{ 800{
799 down (&semOperations); 801 down (&semOperations);
800 to_debug = TRUE; 802 to_debug = 1;
801} 803}
802 804
803/*---------------------------------------------------------------------- 805/*----------------------------------------------------------------------
@@ -807,7 +809,7 @@ void ibmphp_unlock_operations (void)
807{ 809{
808 debug ("%s - Entry\n", __FUNCTION__); 810 debug ("%s - Entry\n", __FUNCTION__);
809 up (&semOperations); 811 up (&semOperations);
810 to_debug = FALSE; 812 to_debug = 0;
811 debug ("%s - Exit\n", __FUNCTION__); 813 debug ("%s - Exit\n", __FUNCTION__);
812} 814}
813 815
@@ -935,40 +937,40 @@ static int process_changeinstatus (struct slot *pslot, struct slot *poldslot)
935{ 937{
936 u8 status; 938 u8 status;
937 int rc = 0; 939 int rc = 0;
938 u8 disable = FALSE; 940 u8 disable = 0;
939 u8 update = FALSE; 941 u8 update = 0;
940 942
941 debug ("process_changeinstatus - Entry pslot[%p], poldslot[%p]\n", pslot, poldslot); 943 debug ("process_changeinstatus - Entry pslot[%p], poldslot[%p]\n", pslot, poldslot);
942 944
943 // bit 0 - HPC_SLOT_POWER 945 // bit 0 - HPC_SLOT_POWER
944 if ((pslot->status & 0x01) != (poldslot->status & 0x01)) 946 if ((pslot->status & 0x01) != (poldslot->status & 0x01))
945 update = TRUE; 947 update = 1;
946 948
947 // bit 1 - HPC_SLOT_CONNECT 949 // bit 1 - HPC_SLOT_CONNECT
948 // ignore 950 // ignore
949 951
950 // bit 2 - HPC_SLOT_ATTN 952 // bit 2 - HPC_SLOT_ATTN
951 if ((pslot->status & 0x04) != (poldslot->status & 0x04)) 953 if ((pslot->status & 0x04) != (poldslot->status & 0x04))
952 update = TRUE; 954 update = 1;
953 955
954 // bit 3 - HPC_SLOT_PRSNT2 956 // bit 3 - HPC_SLOT_PRSNT2
955 // bit 4 - HPC_SLOT_PRSNT1 957 // bit 4 - HPC_SLOT_PRSNT1
956 if (((pslot->status & 0x08) != (poldslot->status & 0x08)) 958 if (((pslot->status & 0x08) != (poldslot->status & 0x08))
957 || ((pslot->status & 0x10) != (poldslot->status & 0x10))) 959 || ((pslot->status & 0x10) != (poldslot->status & 0x10)))
958 update = TRUE; 960 update = 1;
959 961
960 // bit 5 - HPC_SLOT_PWRGD 962 // bit 5 - HPC_SLOT_PWRGD
961 if ((pslot->status & 0x20) != (poldslot->status & 0x20)) 963 if ((pslot->status & 0x20) != (poldslot->status & 0x20))
962 // OFF -> ON: ignore, ON -> OFF: disable slot 964 // OFF -> ON: ignore, ON -> OFF: disable slot
963 if ((poldslot->status & 0x20) && (SLOT_CONNECT (poldslot->status) == HPC_SLOT_CONNECTED) && (SLOT_PRESENT (poldslot->status))) 965 if ((poldslot->status & 0x20) && (SLOT_CONNECT (poldslot->status) == HPC_SLOT_CONNECTED) && (SLOT_PRESENT (poldslot->status)))
964 disable = TRUE; 966 disable = 1;
965 967
966 // bit 6 - HPC_SLOT_BUS_SPEED 968 // bit 6 - HPC_SLOT_BUS_SPEED
967 // ignore 969 // ignore
968 970
969 // bit 7 - HPC_SLOT_LATCH 971 // bit 7 - HPC_SLOT_LATCH
970 if ((pslot->status & 0x80) != (poldslot->status & 0x80)) { 972 if ((pslot->status & 0x80) != (poldslot->status & 0x80)) {
971 update = TRUE; 973 update = 1;
972 // OPEN -> CLOSE 974 // OPEN -> CLOSE
973 if (pslot->status & 0x80) { 975 if (pslot->status & 0x80) {
974 if (SLOT_PWRGD (pslot->status)) { 976 if (SLOT_PWRGD (pslot->status)) {
@@ -977,7 +979,7 @@ static int process_changeinstatus (struct slot *pslot, struct slot *poldslot)
977 msleep(1000); 979 msleep(1000);
978 rc = ibmphp_hpc_readslot (pslot, READ_SLOTSTATUS, &status); 980 rc = ibmphp_hpc_readslot (pslot, READ_SLOTSTATUS, &status);
979 if (SLOT_PWRGD (status)) 981 if (SLOT_PWRGD (status))
980 update = TRUE; 982 update = 1;
981 else // overwrite power in pslot to OFF 983 else // overwrite power in pslot to OFF
982 pslot->status &= ~HPC_SLOT_POWER; 984 pslot->status &= ~HPC_SLOT_POWER;
983 } 985 }
@@ -985,17 +987,17 @@ static int process_changeinstatus (struct slot *pslot, struct slot *poldslot)
985 // CLOSE -> OPEN 987 // CLOSE -> OPEN
986 else if ((SLOT_PWRGD (poldslot->status) == HPC_SLOT_PWRGD_GOOD) 988 else if ((SLOT_PWRGD (poldslot->status) == HPC_SLOT_PWRGD_GOOD)
987 && (SLOT_CONNECT (poldslot->status) == HPC_SLOT_CONNECTED) && (SLOT_PRESENT (poldslot->status))) { 989 && (SLOT_CONNECT (poldslot->status) == HPC_SLOT_CONNECTED) && (SLOT_PRESENT (poldslot->status))) {
988 disable = TRUE; 990 disable = 1;
989 } 991 }
990 // else - ignore 992 // else - ignore
991 } 993 }
992 // bit 4 - HPC_SLOT_BLINK_ATTN 994 // bit 4 - HPC_SLOT_BLINK_ATTN
993 if ((pslot->ext_status & 0x08) != (poldslot->ext_status & 0x08)) 995 if ((pslot->ext_status & 0x08) != (poldslot->ext_status & 0x08))
994 update = TRUE; 996 update = 1;
995 997
996 if (disable) { 998 if (disable) {
997 debug ("process_changeinstatus - disable slot\n"); 999 debug ("process_changeinstatus - disable slot\n");
998 pslot->flag = FALSE; 1000 pslot->flag = 0;
999 rc = ibmphp_do_disable_slot (pslot); 1001 rc = ibmphp_do_disable_slot (pslot);
1000 } 1002 }
1001 1003
@@ -1100,7 +1102,7 @@ void __exit ibmphp_hpc_stop_poll_thread (void)
1100{ 1102{
1101 debug ("%s - Entry\n", __FUNCTION__); 1103 debug ("%s - Entry\n", __FUNCTION__);
1102 1104
1103 ibmphp_shutdown = TRUE; 1105 ibmphp_shutdown = 1;
1104 debug ("before locking operations \n"); 1106 debug ("before locking operations \n");
1105 ibmphp_lock_operations (); 1107 ibmphp_lock_operations ();
1106 debug ("after locking operations \n"); 1108 debug ("after locking operations \n");
@@ -1134,7 +1136,7 @@ static int hpc_wait_ctlr_notworking (int timeout, struct controller *ctlr_ptr, v
1134 u8 * pstatus) 1136 u8 * pstatus)
1135{ 1137{
1136 int rc = 0; 1138 int rc = 0;
1137 u8 done = FALSE; 1139 u8 done = 0;
1138 1140
1139 debug_polling ("hpc_wait_ctlr_notworking - Entry timeout[%d]\n", timeout); 1141 debug_polling ("hpc_wait_ctlr_notworking - Entry timeout[%d]\n", timeout);
1140 1142
@@ -1142,14 +1144,14 @@ static int hpc_wait_ctlr_notworking (int timeout, struct controller *ctlr_ptr, v
1142 *pstatus = ctrl_read (ctlr_ptr, wpg_bbar, WPG_CTLR_INDEX); 1144 *pstatus = ctrl_read (ctlr_ptr, wpg_bbar, WPG_CTLR_INDEX);
1143 if (*pstatus == HPC_ERROR) { 1145 if (*pstatus == HPC_ERROR) {
1144 rc = HPC_ERROR; 1146 rc = HPC_ERROR;
1145 done = TRUE; 1147 done = 1;
1146 } 1148 }
1147 if (CTLR_WORKING (*pstatus) == HPC_CTLR_WORKING_NO) 1149 if (CTLR_WORKING (*pstatus) == HPC_CTLR_WORKING_NO)
1148 done = TRUE; 1150 done = 1;
1149 if (!done) { 1151 if (!done) {
1150 msleep(1000); 1152 msleep(1000);
1151 if (timeout < 1) { 1153 if (timeout < 1) {
1152 done = TRUE; 1154 done = 1;
1153 err ("HPCreadslot - Error ctlr timeout\n"); 1155 err ("HPCreadslot - Error ctlr timeout\n");
1154 rc = HPC_ERROR; 1156 rc = HPC_ERROR;
1155 } else 1157 } else