Lines Matching full:-
1 // SPDX-License-Identifier: GPL-2.0+
7 * Copyright (C) 2001-2003 IBM Corp.
31 //----------------------------------------------------------------------------
33 //----------------------------------------------------------------------------
40 //----------------------------------------------------------------------------
42 //----------------------------------------------------------------------------
49 //----------------------------------------------------------------------------
51 //----------------------------------------------------------------------------
55 //----------------------------------------------------------------------------
57 //----------------------------------------------------------------------------
64 //----------------------------------------------------------------------------
66 //----------------------------------------------------------------------------
69 //----------------------------------------------------------------------------
71 //----------------------------------------------------------------------------
74 //----------------------------------------------------------------------------
76 //----------------------------------------------------------------------------
77 #define WPG_1ST_SLOT_INDEX 0x01 // index - 1st slot for ctlr
78 #define WPG_CTLR_INDEX 0x0F // index - ctlr
79 #define WPG_1ST_EXTSLOT_INDEX 0x10 // index - 1st ext slot for ctlr
80 #define WPG_1ST_BUS_INDEX 0x1F // index - 1st bus for ctlr
82 //----------------------------------------------------------------------------
84 //----------------------------------------------------------------------------
88 //----------------------------------------------------------------------------
90 //----------------------------------------------------------------------------
96 //----------------------------------------------------------------------------
98 //----------------------------------------------------------------------------
109 //----------------------------------------------------------------------------
112 /*----------------------------------------------------------------------
117 *---------------------------------------------------------------------*/
127 debug_polling("%s - Entry WPGBbar[%p] index[%x] \n", __func__, WPGBbar, index); in i2c_ctrl_read()
129 //-------------------------------------------------------------------- in i2c_ctrl_read()
130 // READ - step 1 in i2c_ctrl_read()
133 if (ctlr_ptr->ctlr_type == 0x02) { in i2c_ctrl_read()
136 ultemp = (unsigned long)ctlr_ptr->u.wpeg_ctlr.i2c_addr; in i2c_ctrl_read()
142 } else if (ctlr_ptr->ctlr_type == 0x04) { in i2c_ctrl_read()
158 //-------------------------------------------------------------------- in i2c_ctrl_read()
159 // READ - step 2 : clear the message buffer in i2c_ctrl_read()
165 //-------------------------------------------------------------------- in i2c_ctrl_read()
166 // READ - step 3 : issue start operation, I2C master control bit 30:ON in i2c_ctrl_read()
173 //-------------------------------------------------------------------- in i2c_ctrl_read()
174 // READ - step 4 : wait until start operation bit clears in i2c_ctrl_read()
183 i--; in i2c_ctrl_read()
186 debug("%s - Error : WPG timeout\n", __func__); in i2c_ctrl_read()
189 //-------------------------------------------------------------------- in i2c_ctrl_read()
190 // READ - step 5 : read I2C status register in i2c_ctrl_read()
199 i--; in i2c_ctrl_read()
202 debug("ctrl_read - Exit Error:I2C timeout\n"); in i2c_ctrl_read()
206 //-------------------------------------------------------------------- in i2c_ctrl_read()
207 // READ - step 6 : get DATA in i2c_ctrl_read()
214 debug_polling("%s - Exit index[%x] status[%x]\n", __func__, index, status); in i2c_ctrl_read()
219 /*----------------------------------------------------------------------
225 *---------------------------------------------------------------------*/
235 debug_polling("%s - Entry WPGBbar[%p] index[%x] cmd[%x]\n", __func__, WPGBbar, index, cmd); in i2c_ctrl_write()
238 //-------------------------------------------------------------------- in i2c_ctrl_write()
239 // WRITE - step 1 in i2c_ctrl_write()
244 if (ctlr_ptr->ctlr_type == 0x02) { in i2c_ctrl_write()
247 ultemp = (unsigned long)ctlr_ptr->u.wpeg_ctlr.i2c_addr; in i2c_ctrl_write()
253 } else if (ctlr_ptr->ctlr_type == 0x04) { in i2c_ctrl_write()
269 //-------------------------------------------------------------------- in i2c_ctrl_write()
270 // WRITE - step 2 : clear the message buffer in i2c_ctrl_write()
276 //-------------------------------------------------------------------- in i2c_ctrl_write()
277 // WRITE - step 3 : issue start operation,I2C master control bit 30:ON in i2c_ctrl_write()
284 //-------------------------------------------------------------------- in i2c_ctrl_write()
285 // WRITE - step 4 : wait until start operation bit clears in i2c_ctrl_write()
294 i--; in i2c_ctrl_write()
297 debug("%s - Exit Error:WPG timeout\n", __func__); in i2c_ctrl_write()
301 //-------------------------------------------------------------------- in i2c_ctrl_write()
302 // WRITE - step 5 : read I2C status register in i2c_ctrl_write()
311 i--; in i2c_ctrl_write()
314 debug("ctrl_read - Error : I2C timeout\n"); in i2c_ctrl_write()
322 //------------------------------------------------------------
324 //------------------------------------------------------------
331 start_address = ctlr_ptr->u.isa_ctlr.io_start; in isa_ctrl_read()
332 end_address = ctlr_ptr->u.isa_ctlr.io_end; in isa_ctrl_read()
337 //--------------------------------------------------------------
339 //--------------------------------------------------------------
345 start_address = ctlr_ptr->u.isa_ctlr.io_start; in isa_ctrl_write()
354 if (ctrl->ctrl_dev) in pci_ctrl_read()
355 pci_read_config_byte(ctrl->ctrl_dev, HPC_PCI_OFFSET + offset, &data); in pci_ctrl_read()
361 u8 rc = -ENODEV; in pci_ctrl_write()
363 if (ctrl->ctrl_dev) { in pci_ctrl_write()
364 pci_write_config_byte(ctrl->ctrl_dev, HPC_PCI_OFFSET + offset, data); in pci_ctrl_write()
373 switch (ctlr->ctlr_type) { in ctrl_read()
385 return -ENODEV; in ctrl_read()
393 switch (ctlr->ctlr_type) { in ctrl_write()
405 return -ENODEV; in ctrl_write()
409 /*----------------------------------------------------------------------
415 *---------------------------------------------------------------------*/
431 case HPC_SLOT_OFF: // 0x02.Y.0-14 in hpc_writecmdtoindex()
432 case HPC_SLOT_ON: // 0x03.Y.0-14 in hpc_writecmdtoindex()
433 case HPC_SLOT_ATTNOFF: // 0x04.N.0-14 in hpc_writecmdtoindex()
434 case HPC_SLOT_ATTNON: // 0x05.N.0-14 in hpc_writecmdtoindex()
435 case HPC_SLOT_BLINKLED: // 0x13.N.0-14 in hpc_writecmdtoindex()
444 rc = index + WPG_1ST_BUS_INDEX - 1; in hpc_writecmdtoindex()
448 err("hpc_writecmdtoindex - Error invalid cmd[%x]\n", cmd); in hpc_writecmdtoindex()
455 /*----------------------------------------------------------------------
461 *---------------------------------------------------------------------*/
478 rc = index + WPG_1ST_BUS_INDEX - 1; in hpc_readcmdtoindex()
495 /*----------------------------------------------------------------------
500 * Input: pslot - cannot be NULL for READ_ALLSTAT
501 * pstatus - can be NULL for READ_ALLSTAT
504 *---------------------------------------------------------------------*/
513 debug_polling("%s - Entry pslot[%p] cmd[%x] pstatus[%p]\n", __func__, pslot, cmd, pstatus); in ibmphp_hpc_readslot()
517 rc = -EINVAL; in ibmphp_hpc_readslot()
518 err("%s - Error invalid pointer, rc[%d]\n", __func__, rc); in ibmphp_hpc_readslot()
523 busindex = ibmphp_get_bus_index(pslot->bus); in ibmphp_hpc_readslot()
525 rc = -EINVAL; in ibmphp_hpc_readslot()
526 err("%s - Exit Error:invalid bus, rc[%d]\n", __func__, rc); in ibmphp_hpc_readslot()
531 index = pslot->ctlr_index; in ibmphp_hpc_readslot()
536 rc = -EINVAL; in ibmphp_hpc_readslot()
537 err("%s - Exit Error:invalid index, rc[%d]\n", __func__, rc); in ibmphp_hpc_readslot()
541 ctlr_ptr = pslot->ctrl; in ibmphp_hpc_readslot()
545 //-------------------------------------------------------------------- in ibmphp_hpc_readslot()
547 //-------------------------------------------------------------------- in ibmphp_hpc_readslot()
548 if ((ctlr_ptr->ctlr_type == 2) || (ctlr_ptr->ctlr_type == 4)) in ibmphp_hpc_readslot()
549 wpg_bbar = ioremap(ctlr_ptr->u.wpeg_ctlr.wpegbbar, WPG_I2C_IOREMAP_SIZE); in ibmphp_hpc_readslot()
551 //-------------------------------------------------------------------- in ibmphp_hpc_readslot()
553 //-------------------------------------------------------------------- in ibmphp_hpc_readslot()
559 pslot->ctrl->status = status; in ibmphp_hpc_readslot()
560 pslot->status = ctrl_read(ctlr_ptr, wpg_bbar, index); in ibmphp_hpc_readslot()
564 pslot->ext_status = ctrl_read(ctlr_ptr, wpg_bbar, index + WPG_1ST_EXTSLOT_INDEX); in ibmphp_hpc_readslot()
584 pslot->busstatus = ctrl_read(ctlr_ptr, wpg_bbar, index); in ibmphp_hpc_readslot()
601 index = pslot->ctlr_index; in ibmphp_hpc_readslot()
605 pslot->status = ctrl_read(ctlr_ptr, wpg_bbar, index); in ibmphp_hpc_readslot()
609 pslot->ext_status = in ibmphp_hpc_readslot()
613 err("%s - Error ctrl_read failed\n", __func__); in ibmphp_hpc_readslot()
614 rc = -EINVAL; in ibmphp_hpc_readslot()
620 rc = -EINVAL; in ibmphp_hpc_readslot()
624 //-------------------------------------------------------------------- in ibmphp_hpc_readslot()
626 //-------------------------------------------------------------------- in ibmphp_hpc_readslot()
629 if ((ctlr_ptr->ctlr_type == 2) || (ctlr_ptr->ctlr_type == 4)) in ibmphp_hpc_readslot()
634 debug_polling("%s - Exit rc[%d]\n", __func__, rc); in ibmphp_hpc_readslot()
638 /*----------------------------------------------------------------------
642 *---------------------------------------------------------------------*/
653 debug_polling("%s - Entry pslot[%p] cmd[%x]\n", __func__, pslot, cmd); in ibmphp_hpc_writeslot()
655 rc = -EINVAL; in ibmphp_hpc_writeslot()
656 err("%s - Error Exit rc[%d]\n", __func__, rc); in ibmphp_hpc_writeslot()
663 busindex = ibmphp_get_bus_index(pslot->bus); in ibmphp_hpc_writeslot()
665 rc = -EINVAL; in ibmphp_hpc_writeslot()
666 err("%s - Exit Error:invalid bus, rc[%d]\n", __func__, rc); in ibmphp_hpc_writeslot()
671 index = pslot->ctlr_index; in ibmphp_hpc_writeslot()
676 rc = -EINVAL; in ibmphp_hpc_writeslot()
677 err("%s - Error Exit rc[%d]\n", __func__, rc); in ibmphp_hpc_writeslot()
681 ctlr_ptr = pslot->ctrl; in ibmphp_hpc_writeslot()
685 //-------------------------------------------------------------------- in ibmphp_hpc_writeslot()
687 //-------------------------------------------------------------------- in ibmphp_hpc_writeslot()
688 if ((ctlr_ptr->ctlr_type == 2) || (ctlr_ptr->ctlr_type == 4)) { in ibmphp_hpc_writeslot()
689 wpg_bbar = ioremap(ctlr_ptr->u.wpeg_ctlr.wpegbbar, WPG_I2C_IOREMAP_SIZE); in ibmphp_hpc_writeslot()
691 debug("%s - ctlr id[%x] physical[%lx] logical[%lx] i2c[%x]\n", __func__, in ibmphp_hpc_writeslot()
692 ctlr_ptr->ctlr_id, (ulong) (ctlr_ptr->u.wpeg_ctlr.wpegbbar), (ulong) wpg_bbar, in ibmphp_hpc_writeslot()
693 ctlr_ptr->u.wpeg_ctlr.i2c_addr); in ibmphp_hpc_writeslot()
695 //-------------------------------------------------------------------- in ibmphp_hpc_writeslot()
697 //-------------------------------------------------------------------- in ibmphp_hpc_writeslot()
703 //-------------------------------------------------------------------- in ibmphp_hpc_writeslot()
705 //-------------------------------------------------------------------- in ibmphp_hpc_writeslot()
722 err("%s - Error command complete timeout\n", __func__); in ibmphp_hpc_writeslot()
723 rc = -EFAULT; in ibmphp_hpc_writeslot()
725 timeout--; in ibmphp_hpc_writeslot()
728 ctlr_ptr->status = status; in ibmphp_hpc_writeslot()
733 if ((ctlr_ptr->ctlr_type == 2) || (ctlr_ptr->ctlr_type == 4)) in ibmphp_hpc_writeslot()
737 debug_polling("%s - Exit rc[%d]\n", __func__, rc); in ibmphp_hpc_writeslot()
741 /*----------------------------------------------------------------------
745 *---------------------------------------------------------------------*/
751 /*----------------------------------------------------------------------
753 *---------------------------------------------------------------------*/
759 /*----------------------------------------------------------------------
763 *---------------------------------------------------------------------*/
770 /*----------------------------------------------------------------------
772 *---------------------------------------------------------------------*/
775 debug("%s - Entry\n", __func__); in ibmphp_unlock_operations()
778 debug("%s - Exit\n", __func__); in ibmphp_unlock_operations()
781 /*----------------------------------------------------------------------
783 *---------------------------------------------------------------------*/
798 debug("%s - Entry\n", __func__); in poll_hpc()
812 if (pslot->ctrl->ctlr_relative_id == ctrl_count) { in poll_hpc()
814 if (READ_SLOT_LATCH(pslot->ctrl)) { in poll_hpc()
821 pslot->ctrl); in poll_hpc()
835 if ((myslot.status != pslot->status) in poll_hpc()
836 || (myslot.ext_status != pslot->ext_status)) in poll_hpc()
844 if (pslot->ctrl->ctlr_relative_id == ctrl_count) { in poll_hpc()
846 if (READ_SLOT_LATCH(pslot->ctrl)) in poll_hpc()
879 debug("%s - Exit\n", __func__); in poll_hpc()
884 /*----------------------------------------------------------------------
898 *---------------------------------------------------------------------*/
906 debug("process_changeinstatus - Entry pslot[%p], poldslot[%p]\n", pslot, poldslot); in process_changeinstatus()
908 // bit 0 - HPC_SLOT_POWER in process_changeinstatus()
909 if ((pslot->status & 0x01) != (poldslot->status & 0x01)) in process_changeinstatus()
912 // bit 1 - HPC_SLOT_CONNECT in process_changeinstatus()
915 // bit 2 - HPC_SLOT_ATTN in process_changeinstatus()
916 if ((pslot->status & 0x04) != (poldslot->status & 0x04)) in process_changeinstatus()
919 // bit 3 - HPC_SLOT_PRSNT2 in process_changeinstatus()
920 // bit 4 - HPC_SLOT_PRSNT1 in process_changeinstatus()
921 if (((pslot->status & 0x08) != (poldslot->status & 0x08)) in process_changeinstatus()
922 || ((pslot->status & 0x10) != (poldslot->status & 0x10))) in process_changeinstatus()
925 // bit 5 - HPC_SLOT_PWRGD in process_changeinstatus()
926 if ((pslot->status & 0x20) != (poldslot->status & 0x20)) in process_changeinstatus()
927 // OFF -> ON: ignore, ON -> OFF: disable slot in process_changeinstatus()
928 …if ((poldslot->status & 0x20) && (SLOT_CONNECT(poldslot->status) == HPC_SLOT_CONNECTED) && (SLOT_P… in process_changeinstatus()
931 // bit 6 - HPC_SLOT_BUS_SPEED in process_changeinstatus()
934 // bit 7 - HPC_SLOT_LATCH in process_changeinstatus()
935 if ((pslot->status & 0x80) != (poldslot->status & 0x80)) { in process_changeinstatus()
937 // OPEN -> CLOSE in process_changeinstatus()
938 if (pslot->status & 0x80) { in process_changeinstatus()
939 if (SLOT_PWRGD(pslot->status)) { in process_changeinstatus()
947 pslot->status &= ~HPC_SLOT_POWER; in process_changeinstatus()
950 // CLOSE -> OPEN in process_changeinstatus()
951 else if ((SLOT_PWRGD(poldslot->status) == HPC_SLOT_PWRGD_GOOD) in process_changeinstatus()
952 && (SLOT_CONNECT(poldslot->status) == HPC_SLOT_CONNECTED) && (SLOT_PRESENT(poldslot->status))) { in process_changeinstatus()
955 // else - ignore in process_changeinstatus()
957 // bit 4 - HPC_SLOT_BLINK_ATTN in process_changeinstatus()
958 if ((pslot->ext_status & 0x08) != (poldslot->ext_status & 0x08)) in process_changeinstatus()
962 debug("process_changeinstatus - disable slot\n"); in process_changeinstatus()
963 pslot->flag = 0; in process_changeinstatus()
970 debug("%s - Exit rc[%d] disable[%x] update[%x]\n", __func__, rc, disable, update); in process_changeinstatus()
975 /*----------------------------------------------------------------------
984 *---------------------------------------------------------------------*/
992 debug("%s - Entry old[%x], new[%x]\n", __func__, old, new); in process_changeinlatch()
993 // bit 0 reserved, 0 is LSB, check bit 1-6 for 6 slots in process_changeinlatch()
995 for (i = ctrl->starting_slot_num; i <= ctrl->ending_slot_num; i++) { in process_changeinlatch()
1002 debug("%s - call process_changeinstatus for slot[%d]\n", __func__, i); in process_changeinlatch()
1005 rc = -EINVAL; in process_changeinlatch()
1006 err("%s - Error bad pointer for slot[%d]\n", __func__, i); in process_changeinlatch()
1010 debug("%s - Exit rc[%d]\n", __func__, rc); in process_changeinlatch()
1014 /*----------------------------------------------------------------------
1018 *---------------------------------------------------------------------*/
1021 debug("%s - Entry\n", __func__); in ibmphp_hpc_start_poll_thread()
1025 err("%s - Error, thread not started\n", __func__); in ibmphp_hpc_start_poll_thread()
1031 /*----------------------------------------------------------------------
1035 *---------------------------------------------------------------------*/
1038 debug("%s - Entry\n", __func__); in ibmphp_hpc_stop_poll_thread()
1057 debug("%s - Exit\n", __func__); in ibmphp_hpc_stop_poll_thread()
1060 /*----------------------------------------------------------------------
1067 *---------------------------------------------------------------------*/
1074 debug_polling("hpc_wait_ctlr_notworking - Entry timeout[%d]\n", timeout); in hpc_wait_ctlr_notworking()
1088 err("HPCreadslot - Error ctlr timeout\n"); in hpc_wait_ctlr_notworking()
1091 timeout--; in hpc_wait_ctlr_notworking()
1094 debug_polling("hpc_wait_ctlr_notworking - Exit rc[%x] status[%x]\n", rc, *pstatus); in hpc_wait_ctlr_notworking()