Lines Matching +full:- +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 //------------------------------------------------------------
330 start_address = ctlr_ptr->u.isa_ctlr.io_start; in isa_ctrl_read()
335 //--------------------------------------------------------------
337 //--------------------------------------------------------------
343 start_address = ctlr_ptr->u.isa_ctlr.io_start; in isa_ctrl_write()
352 if (ctrl->ctrl_dev) in pci_ctrl_read()
353 pci_read_config_byte(ctrl->ctrl_dev, HPC_PCI_OFFSET + offset, &data); in pci_ctrl_read()
359 u8 rc = -ENODEV; in pci_ctrl_write()
361 if (ctrl->ctrl_dev) { in pci_ctrl_write()
362 pci_write_config_byte(ctrl->ctrl_dev, HPC_PCI_OFFSET + offset, data); in pci_ctrl_write()
371 switch (ctlr->ctlr_type) { in ctrl_read()
383 return -ENODEV; in ctrl_read()
391 switch (ctlr->ctlr_type) { in ctrl_write()
403 return -ENODEV; in ctrl_write()
407 /*----------------------------------------------------------------------
413 *---------------------------------------------------------------------*/
429 case HPC_SLOT_OFF: // 0x02.Y.0-14 in hpc_writecmdtoindex()
430 case HPC_SLOT_ON: // 0x03.Y.0-14 in hpc_writecmdtoindex()
431 case HPC_SLOT_ATTNOFF: // 0x04.N.0-14 in hpc_writecmdtoindex()
432 case HPC_SLOT_ATTNON: // 0x05.N.0-14 in hpc_writecmdtoindex()
433 case HPC_SLOT_BLINKLED: // 0x13.N.0-14 in hpc_writecmdtoindex()
442 rc = index + WPG_1ST_BUS_INDEX - 1; in hpc_writecmdtoindex()
446 err("hpc_writecmdtoindex - Error invalid cmd[%x]\n", cmd); in hpc_writecmdtoindex()
453 /*----------------------------------------------------------------------
459 *---------------------------------------------------------------------*/
476 rc = index + WPG_1ST_BUS_INDEX - 1; in hpc_readcmdtoindex()
493 /*----------------------------------------------------------------------
498 * Input: pslot - cannot be NULL for READ_ALLSTAT
499 * pstatus - can be NULL for READ_ALLSTAT
502 *---------------------------------------------------------------------*/
511 debug_polling("%s - Entry pslot[%p] cmd[%x] pstatus[%p]\n", __func__, pslot, cmd, pstatus); in ibmphp_hpc_readslot()
515 rc = -EINVAL; in ibmphp_hpc_readslot()
516 err("%s - Error invalid pointer, rc[%d]\n", __func__, rc); in ibmphp_hpc_readslot()
521 busindex = ibmphp_get_bus_index(pslot->bus); in ibmphp_hpc_readslot()
523 rc = -EINVAL; in ibmphp_hpc_readslot()
524 err("%s - Exit Error:invalid bus, rc[%d]\n", __func__, rc); in ibmphp_hpc_readslot()
529 index = pslot->ctlr_index; in ibmphp_hpc_readslot()
534 rc = -EINVAL; in ibmphp_hpc_readslot()
535 err("%s - Exit Error:invalid index, rc[%d]\n", __func__, rc); in ibmphp_hpc_readslot()
539 ctlr_ptr = pslot->ctrl; in ibmphp_hpc_readslot()
543 //-------------------------------------------------------------------- in ibmphp_hpc_readslot()
545 //-------------------------------------------------------------------- in ibmphp_hpc_readslot()
546 if ((ctlr_ptr->ctlr_type == 2) || (ctlr_ptr->ctlr_type == 4)) in ibmphp_hpc_readslot()
547 wpg_bbar = ioremap(ctlr_ptr->u.wpeg_ctlr.wpegbbar, WPG_I2C_IOREMAP_SIZE); in ibmphp_hpc_readslot()
549 //-------------------------------------------------------------------- in ibmphp_hpc_readslot()
551 //-------------------------------------------------------------------- in ibmphp_hpc_readslot()
557 pslot->ctrl->status = status; in ibmphp_hpc_readslot()
558 pslot->status = ctrl_read(ctlr_ptr, wpg_bbar, index); in ibmphp_hpc_readslot()
562 pslot->ext_status = ctrl_read(ctlr_ptr, wpg_bbar, index + WPG_1ST_EXTSLOT_INDEX); in ibmphp_hpc_readslot()
582 pslot->busstatus = ctrl_read(ctlr_ptr, wpg_bbar, index); in ibmphp_hpc_readslot()
599 index = pslot->ctlr_index; in ibmphp_hpc_readslot()
603 pslot->status = ctrl_read(ctlr_ptr, wpg_bbar, index); in ibmphp_hpc_readslot()
607 pslot->ext_status = in ibmphp_hpc_readslot()
611 err("%s - Error ctrl_read failed\n", __func__); in ibmphp_hpc_readslot()
612 rc = -EINVAL; in ibmphp_hpc_readslot()
618 rc = -EINVAL; in ibmphp_hpc_readslot()
622 //-------------------------------------------------------------------- in ibmphp_hpc_readslot()
624 //-------------------------------------------------------------------- in ibmphp_hpc_readslot()
627 if ((ctlr_ptr->ctlr_type == 2) || (ctlr_ptr->ctlr_type == 4)) in ibmphp_hpc_readslot()
632 debug_polling("%s - Exit rc[%d]\n", __func__, rc); in ibmphp_hpc_readslot()
636 /*----------------------------------------------------------------------
640 *---------------------------------------------------------------------*/
651 debug_polling("%s - Entry pslot[%p] cmd[%x]\n", __func__, pslot, cmd); in ibmphp_hpc_writeslot()
653 rc = -EINVAL; in ibmphp_hpc_writeslot()
654 err("%s - Error Exit rc[%d]\n", __func__, rc); in ibmphp_hpc_writeslot()
661 busindex = ibmphp_get_bus_index(pslot->bus); in ibmphp_hpc_writeslot()
663 rc = -EINVAL; in ibmphp_hpc_writeslot()
664 err("%s - Exit Error:invalid bus, rc[%d]\n", __func__, rc); in ibmphp_hpc_writeslot()
669 index = pslot->ctlr_index; in ibmphp_hpc_writeslot()
674 rc = -EINVAL; in ibmphp_hpc_writeslot()
675 err("%s - Error Exit rc[%d]\n", __func__, rc); in ibmphp_hpc_writeslot()
679 ctlr_ptr = pslot->ctrl; in ibmphp_hpc_writeslot()
683 //-------------------------------------------------------------------- in ibmphp_hpc_writeslot()
685 //-------------------------------------------------------------------- in ibmphp_hpc_writeslot()
686 if ((ctlr_ptr->ctlr_type == 2) || (ctlr_ptr->ctlr_type == 4)) { in ibmphp_hpc_writeslot()
687 wpg_bbar = ioremap(ctlr_ptr->u.wpeg_ctlr.wpegbbar, WPG_I2C_IOREMAP_SIZE); in ibmphp_hpc_writeslot()
689 debug("%s - ctlr id[%x] physical[%lx] logical[%lx] i2c[%x]\n", __func__, in ibmphp_hpc_writeslot()
690 ctlr_ptr->ctlr_id, (ulong) (ctlr_ptr->u.wpeg_ctlr.wpegbbar), (ulong) wpg_bbar, in ibmphp_hpc_writeslot()
691 ctlr_ptr->u.wpeg_ctlr.i2c_addr); in ibmphp_hpc_writeslot()
693 //-------------------------------------------------------------------- in ibmphp_hpc_writeslot()
695 //-------------------------------------------------------------------- in ibmphp_hpc_writeslot()
701 //-------------------------------------------------------------------- in ibmphp_hpc_writeslot()
703 //-------------------------------------------------------------------- in ibmphp_hpc_writeslot()
720 err("%s - Error command complete timeout\n", __func__); in ibmphp_hpc_writeslot()
721 rc = -EFAULT; in ibmphp_hpc_writeslot()
723 timeout--; in ibmphp_hpc_writeslot()
726 ctlr_ptr->status = status; in ibmphp_hpc_writeslot()
731 if ((ctlr_ptr->ctlr_type == 2) || (ctlr_ptr->ctlr_type == 4)) in ibmphp_hpc_writeslot()
735 debug_polling("%s - Exit rc[%d]\n", __func__, rc); in ibmphp_hpc_writeslot()
739 /*----------------------------------------------------------------------
743 *---------------------------------------------------------------------*/
749 /*----------------------------------------------------------------------
751 *---------------------------------------------------------------------*/
757 /*----------------------------------------------------------------------
761 *---------------------------------------------------------------------*/
768 /*----------------------------------------------------------------------
770 *---------------------------------------------------------------------*/
773 debug("%s - Entry\n", __func__); in ibmphp_unlock_operations()
776 debug("%s - Exit\n", __func__); in ibmphp_unlock_operations()
779 /*----------------------------------------------------------------------
781 *---------------------------------------------------------------------*/
796 debug("%s - Entry\n", __func__); in poll_hpc()
810 if (pslot->ctrl->ctlr_relative_id == ctrl_count) { in poll_hpc()
812 if (READ_SLOT_LATCH(pslot->ctrl)) { in poll_hpc()
819 pslot->ctrl); in poll_hpc()
833 if ((myslot.status != pslot->status) in poll_hpc()
834 || (myslot.ext_status != pslot->ext_status)) in poll_hpc()
842 if (pslot->ctrl->ctlr_relative_id == ctrl_count) { in poll_hpc()
844 if (READ_SLOT_LATCH(pslot->ctrl)) in poll_hpc()
877 debug("%s - Exit\n", __func__); in poll_hpc()
882 /*----------------------------------------------------------------------
896 *---------------------------------------------------------------------*/
904 debug("process_changeinstatus - Entry pslot[%p], poldslot[%p]\n", pslot, poldslot); in process_changeinstatus()
906 // bit 0 - HPC_SLOT_POWER in process_changeinstatus()
907 if ((pslot->status & 0x01) != (poldslot->status & 0x01)) in process_changeinstatus()
910 // bit 1 - HPC_SLOT_CONNECT in process_changeinstatus()
913 // bit 2 - HPC_SLOT_ATTN in process_changeinstatus()
914 if ((pslot->status & 0x04) != (poldslot->status & 0x04)) in process_changeinstatus()
917 // bit 3 - HPC_SLOT_PRSNT2 in process_changeinstatus()
918 // bit 4 - HPC_SLOT_PRSNT1 in process_changeinstatus()
919 if (((pslot->status & 0x08) != (poldslot->status & 0x08)) in process_changeinstatus()
920 || ((pslot->status & 0x10) != (poldslot->status & 0x10))) in process_changeinstatus()
923 // bit 5 - HPC_SLOT_PWRGD in process_changeinstatus()
924 if ((pslot->status & 0x20) != (poldslot->status & 0x20)) in process_changeinstatus()
925 // OFF -> ON: ignore, ON -> OFF: disable slot in process_changeinstatus()
926 …if ((poldslot->status & 0x20) && (SLOT_CONNECT(poldslot->status) == HPC_SLOT_CONNECTED) && (SLOT_P… in process_changeinstatus()
929 // bit 6 - HPC_SLOT_BUS_SPEED in process_changeinstatus()
932 // bit 7 - HPC_SLOT_LATCH in process_changeinstatus()
933 if ((pslot->status & 0x80) != (poldslot->status & 0x80)) { in process_changeinstatus()
935 // OPEN -> CLOSE in process_changeinstatus()
936 if (pslot->status & 0x80) { in process_changeinstatus()
937 if (SLOT_PWRGD(pslot->status)) { in process_changeinstatus()
945 pslot->status &= ~HPC_SLOT_POWER; in process_changeinstatus()
948 // CLOSE -> OPEN in process_changeinstatus()
949 else if ((SLOT_PWRGD(poldslot->status) == HPC_SLOT_PWRGD_GOOD) in process_changeinstatus()
950 && (SLOT_CONNECT(poldslot->status) == HPC_SLOT_CONNECTED) && (SLOT_PRESENT(poldslot->status))) { in process_changeinstatus()
953 // else - ignore in process_changeinstatus()
955 // bit 4 - HPC_SLOT_BLINK_ATTN in process_changeinstatus()
956 if ((pslot->ext_status & 0x08) != (poldslot->ext_status & 0x08)) in process_changeinstatus()
960 debug("process_changeinstatus - disable slot\n"); in process_changeinstatus()
961 pslot->flag = 0; in process_changeinstatus()
968 debug("%s - Exit rc[%d] disable[%x] update[%x]\n", __func__, rc, disable, update); in process_changeinstatus()
973 /*----------------------------------------------------------------------
982 *---------------------------------------------------------------------*/
990 debug("%s - Entry old[%x], new[%x]\n", __func__, old, new); in process_changeinlatch()
991 // bit 0 reserved, 0 is LSB, check bit 1-6 for 6 slots in process_changeinlatch()
993 for (i = ctrl->starting_slot_num; i <= ctrl->ending_slot_num; i++) { in process_changeinlatch()
1000 debug("%s - call process_changeinstatus for slot[%d]\n", __func__, i); in process_changeinlatch()
1003 rc = -EINVAL; in process_changeinlatch()
1004 err("%s - Error bad pointer for slot[%d]\n", __func__, i); in process_changeinlatch()
1008 debug("%s - Exit rc[%d]\n", __func__, rc); in process_changeinlatch()
1012 /*----------------------------------------------------------------------
1016 *---------------------------------------------------------------------*/
1019 debug("%s - Entry\n", __func__); in ibmphp_hpc_start_poll_thread()
1023 err("%s - Error, thread not started\n", __func__); in ibmphp_hpc_start_poll_thread()
1029 /*----------------------------------------------------------------------
1033 *---------------------------------------------------------------------*/
1036 debug("%s - Entry\n", __func__); in ibmphp_hpc_stop_poll_thread()
1055 debug("%s - Exit\n", __func__); in ibmphp_hpc_stop_poll_thread()
1058 /*----------------------------------------------------------------------
1065 *---------------------------------------------------------------------*/
1072 debug_polling("hpc_wait_ctlr_notworking - Entry timeout[%d]\n", timeout); in hpc_wait_ctlr_notworking()
1086 err("HPCreadslot - Error ctlr timeout\n"); in hpc_wait_ctlr_notworking()
1089 timeout--; in hpc_wait_ctlr_notworking()
1092 debug_polling("hpc_wait_ctlr_notworking - Exit rc[%x] status[%x]\n", rc, *pstatus); in hpc_wait_ctlr_notworking()