Lines Matching refs:ctrl

42 static u32 configure_new_device(struct controller* ctrl, struct pci_func *func,
44 static int configure_new_function(struct controller* ctrl, struct pci_func *func,
46 static void interrupt_event_handler(struct controller *ctrl);
67 static u8 handle_switch_change(u8 change, struct controller * ctrl)
86 func = cpqhp_slot_find(ctrl->bus,
87 (hp_slot + ctrl->slot_device_offset), 0);
92 taskInfo = &(ctrl->event_queue[ctrl->next_event]);
93 ctrl->next_event = (ctrl->next_event + 1) % 10;
98 temp_word = ctrl->ctrl_int_comp >> 16;
102 if (ctrl->ctrl_int_comp & (0x1L << hp_slot)) {
127 * @ctrl: scan lots of this controller
130 static struct slot *cpqhp_find_slot(struct controller *ctrl, u8 device)
132 struct slot *slot = ctrl->slot;
141 static u8 handle_presence_change(u16 change, struct controller * ctrl)
165 func = cpqhp_slot_find(ctrl->bus,
166 (hp_slot + ctrl->slot_device_offset), 0);
168 taskInfo = &(ctrl->event_queue[ctrl->next_event]);
169 ctrl->next_event = (ctrl->next_event + 1) % 10;
174 p_slot = cpqhp_find_slot(ctrl, hp_slot + (readb(ctrl->hpc_reg + SLOT_MASK) >> 4));
181 if (func->switch_save && (ctrl->push_button == 1)) {
182 temp_word = ctrl->ctrl_int_comp >> 16;
215 temp_word = ctrl->ctrl_int_comp >> 16;
219 if ((!(ctrl->ctrl_int_comp & (0x010000 << hp_slot))) ||
220 (!(ctrl->ctrl_int_comp & (0x01000000 << hp_slot)))) {
235 static u8 handle_power_fault(u8 change, struct controller * ctrl)
256 func = cpqhp_slot_find(ctrl->bus,
257 (hp_slot + ctrl->slot_device_offset), 0);
259 taskInfo = &(ctrl->event_queue[ctrl->next_event]);
260 ctrl->next_event = (ctrl->next_event + 1) % 10;
265 if (ctrl->ctrl_int_comp & (0x00000100 << hp_slot)) {
278 if (ctrl->rev < 4) {
279 amber_LED_on (ctrl, hp_slot);
280 green_LED_off (ctrl, hp_slot);
281 set_SOGO (ctrl);
288 simulated_NMI(hp_slot, ctrl); */
893 struct controller *ctrl = data;
901 misc = readw(ctrl->hpc_reg + MISC);
916 writew(misc, ctrl->hpc_reg + MISC);
919 misc = readw(ctrl->hpc_reg + MISC);
922 wake_up_interruptible(&ctrl->queue);
927 Diff = readl(ctrl->hpc_reg + INT_INPUT_CLEAR) ^ ctrl->ctrl_int_comp;
929 ctrl->ctrl_int_comp = readl(ctrl->hpc_reg + INT_INPUT_CLEAR);
932 writel(Diff, ctrl->hpc_reg + INT_INPUT_CLEAR);
935 temp_dword = readl(ctrl->hpc_reg + INT_INPUT_CLEAR);
939 writel(0xFFFFFFFF, ctrl->hpc_reg + INT_INPUT_CLEAR);
941 schedule_flag += handle_switch_change((u8)(Diff & 0xFFL), ctrl);
942 schedule_flag += handle_presence_change((u16)((Diff & 0xFFFF0000L) >> 16), ctrl);
943 schedule_flag += handle_power_fault((u8)((Diff & 0xFF00L) >> 8), ctrl);
946 reset = readb(ctrl->hpc_reg + RESET_FREQ_MODE);
950 writeb(reset, ctrl->hpc_reg + RESET_FREQ_MODE);
951 reset = readb(ctrl->hpc_reg + RESET_FREQ_MODE);
952 wake_up_interruptible(&ctrl->queue);
1123 * @ctrl: controller to change frequency/mode for.
1130 static u8 set_controller_speed(struct controller *ctrl, u8 adapter_speed, u8 hp_slot)
1133 struct pci_bus *bus = ctrl->pci_bus;
1135 u8 slot_power = readb(ctrl->hpc_reg + SLOT_POWER);
1137 u32 leds = readl(ctrl->hpc_reg + LED_CONTROL);
1145 for(slot = ctrl->slot; slot; slot = slot->next) {
1146 if (slot->device == (hp_slot + ctrl->slot_device_offset))
1165 if ((bus->cur_bus_speed > adapter_speed) && (!ctrl->pcix_speed_capability))
1169 if ((bus->cur_bus_speed < adapter_speed) && (!ctrl->pcix_speed_capability))
1181 writel(0x0L, ctrl->hpc_reg + LED_CONTROL);
1182 writeb(0x00, ctrl->hpc_reg + SLOT_ENABLE);
1184 set_SOGO(ctrl);
1185 wait_for_ctrl_irq(ctrl);
1191 pci_write_config_byte(ctrl->pci_dev, 0x41, reg);
1193 reg16 = readw(ctrl->hpc_reg + NEXT_CURR_FREQ);
1218 writew(reg16, ctrl->hpc_reg + NEXT_CURR_FREQ);
1223 writel(0, ctrl->hpc_reg + INT_MASK);
1225 pci_write_config_byte(ctrl->pci_dev, 0x41, reg);
1229 pci_read_config_byte(ctrl->pci_dev, 0x43, &reg);
1230 pci_write_config_byte(ctrl->pci_dev, 0x43, reg);
1235 set_SOGO(ctrl);
1237 wait_for_ctrl_irq(ctrl);
1241 writel(leds, ctrl->hpc_reg + LED_CONTROL);
1242 writeb(slot_power, ctrl->hpc_reg + SLOT_ENABLE);
1244 set_SOGO(ctrl);
1245 wait_for_ctrl_irq(ctrl);
1248 slot = cpqhp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
1263 * @ctrl: hotplug controller
1271 static u32 board_replaced(struct pci_func *func, struct controller *ctrl)
1273 struct pci_bus *bus = ctrl->pci_bus;
1279 hp_slot = func->device - ctrl->slot_device_offset;
1284 if (readl(ctrl->hpc_reg + INT_INPUT_CLEAR) & (0x01L << hp_slot))
1289 else if (is_slot_enabled (ctrl, hp_slot))
1292 mutex_lock(&ctrl->crit_sect);
1295 enable_slot_power (ctrl, hp_slot);
1297 set_SOGO(ctrl);
1300 wait_for_ctrl_irq (ctrl);
1304 temp_byte = readb(ctrl->hpc_reg + SLOT_POWER);
1305 writeb(0x00, ctrl->hpc_reg + SLOT_POWER);
1306 writeb(temp_byte, ctrl->hpc_reg + SLOT_POWER);
1308 set_SOGO(ctrl);
1311 wait_for_ctrl_irq (ctrl);
1313 adapter_speed = get_adapter_speed(ctrl, hp_slot);
1315 if (set_controller_speed(ctrl, adapter_speed, hp_slot))
1319 disable_slot_power (ctrl, hp_slot);
1321 set_SOGO(ctrl);
1324 wait_for_ctrl_irq (ctrl);
1326 mutex_unlock(&ctrl->crit_sect);
1331 mutex_lock(&ctrl->crit_sect);
1333 slot_enable (ctrl, hp_slot);
1334 green_LED_blink (ctrl, hp_slot);
1336 amber_LED_off (ctrl, hp_slot);
1338 set_SOGO(ctrl);
1341 wait_for_ctrl_irq (ctrl);
1343 mutex_unlock(&ctrl->crit_sect);
1354 rc = cpqhp_valid_replace(ctrl, func);
1359 rc = cpqhp_configure_board(ctrl, func);
1368 mutex_lock(&ctrl->crit_sect);
1370 amber_LED_on (ctrl, hp_slot);
1371 green_LED_off (ctrl, hp_slot);
1372 slot_disable (ctrl, hp_slot);
1374 set_SOGO(ctrl);
1377 wait_for_ctrl_irq (ctrl);
1379 mutex_unlock(&ctrl->crit_sect);
1394 mutex_lock(&ctrl->crit_sect);
1396 amber_LED_on (ctrl, hp_slot);
1397 green_LED_off (ctrl, hp_slot);
1398 slot_disable (ctrl, hp_slot);
1400 set_SOGO(ctrl);
1403 wait_for_ctrl_irq (ctrl);
1405 mutex_unlock(&ctrl->crit_sect);
1417 * @ctrl: hotplug controller
1422 static u32 board_added(struct pci_func *func, struct controller *ctrl)
1431 struct pci_bus *bus = ctrl->pci_bus;
1435 hp_slot = func->device - ctrl->slot_device_offset;
1437 __func__, func->device, ctrl->slot_device_offset, hp_slot);
1439 mutex_lock(&ctrl->crit_sect);
1442 enable_slot_power(ctrl, hp_slot);
1444 set_SOGO(ctrl);
1447 wait_for_ctrl_irq (ctrl);
1452 temp_byte = readb(ctrl->hpc_reg + SLOT_POWER);
1453 writeb(0x00, ctrl->hpc_reg + SLOT_POWER);
1454 writeb(temp_byte, ctrl->hpc_reg + SLOT_POWER);
1456 set_SOGO(ctrl);
1459 wait_for_ctrl_irq (ctrl);
1461 adapter_speed = get_adapter_speed(ctrl, hp_slot);
1463 if (set_controller_speed(ctrl, adapter_speed, hp_slot))
1467 disable_slot_power (ctrl, hp_slot);
1469 set_SOGO(ctrl);
1472 wait_for_ctrl_irq(ctrl);
1474 mutex_unlock(&ctrl->crit_sect);
1479 p_slot = cpqhp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
1484 mutex_lock(&ctrl->crit_sect);
1488 slot_enable (ctrl, hp_slot);
1491 green_LED_blink (ctrl, hp_slot);
1494 amber_LED_off (ctrl, hp_slot);
1497 set_SOGO(ctrl);
1501 wait_for_ctrl_irq (ctrl);
1505 mutex_unlock(&ctrl->crit_sect);
1523 ctrl->pci_bus->number = func->bus;
1524 rc = pci_bus_read_config_dword (ctrl->pci_bus, PCI_DEVFN(func->device, func->function), PCI_VENDOR_ID, &temp_register);
1539 res_lists.io_head = ctrl->io_head;
1540 res_lists.mem_head = ctrl->mem_head;
1541 res_lists.p_mem_head = ctrl->p_mem_head;
1542 res_lists.bus_head = ctrl->bus_head;
1545 rc = configure_new_device(ctrl, func, 0, &res_lists);
1548 ctrl->io_head = res_lists.io_head;
1549 ctrl->mem_head = res_lists.mem_head;
1550 ctrl->p_mem_head = res_lists.p_mem_head;
1551 ctrl->bus_head = res_lists.bus_head;
1553 cpqhp_resource_sort_and_combine(&(ctrl->mem_head));
1554 cpqhp_resource_sort_and_combine(&(ctrl->p_mem_head));
1555 cpqhp_resource_sort_and_combine(&(ctrl->io_head));
1556 cpqhp_resource_sort_and_combine(&(ctrl->bus_head));
1559 mutex_lock(&ctrl->crit_sect);
1561 amber_LED_on (ctrl, hp_slot);
1562 green_LED_off (ctrl, hp_slot);
1563 slot_disable (ctrl, hp_slot);
1565 set_SOGO(ctrl);
1568 wait_for_ctrl_irq (ctrl);
1570 mutex_unlock(&ctrl->crit_sect);
1573 cpqhp_save_slot_config(ctrl, func);
1586 new_slot = cpqhp_slot_find(ctrl->bus, func->device, index++);
1588 cpqhp_configure_device(ctrl, new_slot);
1591 mutex_lock(&ctrl->crit_sect);
1593 green_LED_on (ctrl, hp_slot);
1595 set_SOGO(ctrl);
1598 wait_for_ctrl_irq (ctrl);
1600 mutex_unlock(&ctrl->crit_sect);
1602 mutex_lock(&ctrl->crit_sect);
1604 amber_LED_on (ctrl, hp_slot);
1605 green_LED_off (ctrl, hp_slot);
1606 slot_disable (ctrl, hp_slot);
1608 set_SOGO(ctrl);
1611 wait_for_ctrl_irq (ctrl);
1613 mutex_unlock(&ctrl->crit_sect);
1625 * @ctrl: target controller
1627 static u32 remove_board(struct pci_func * func, u32 replace_flag, struct controller * ctrl)
1643 hp_slot = func->device - ctrl->slot_device_offset;
1648 if (replace_flag || !ctrl->add_support)
1649 rc = cpqhp_save_base_addr_length(ctrl, func);
1667 rc = cpqhp_save_used_resources(ctrl, func);
1674 mutex_lock(&ctrl->crit_sect);
1676 green_LED_off (ctrl, hp_slot);
1677 slot_disable (ctrl, hp_slot);
1679 set_SOGO(ctrl);
1682 temp_byte = readb(ctrl->hpc_reg + SLOT_SERR);
1684 writeb(temp_byte, ctrl->hpc_reg + SLOT_SERR);
1687 wait_for_ctrl_irq (ctrl);
1689 mutex_unlock(&ctrl->crit_sect);
1691 if (!replace_flag && ctrl->add_support) {
1693 res_lists.io_head = ctrl->io_head;
1694 res_lists.mem_head = ctrl->mem_head;
1695 res_lists.p_mem_head = ctrl->p_mem_head;
1696 res_lists.bus_head = ctrl->bus_head;
1700 ctrl->io_head = res_lists.io_head;
1701 ctrl->mem_head = res_lists.mem_head;
1702 ctrl->p_mem_head = res_lists.p_mem_head;
1703 ctrl->bus_head = res_lists.bus_head;
1705 cpqhp_resource_sort_and_combine(&(ctrl->mem_head));
1706 cpqhp_resource_sort_and_combine(&(ctrl->p_mem_head));
1707 cpqhp_resource_sort_and_combine(&(ctrl->io_head));
1708 cpqhp_resource_sort_and_combine(&(ctrl->bus_head));
1715 func = cpqhp_slot_find(ctrl->bus, device, 0);
1719 func = cpqhp_slot_create(ctrl->bus);
1724 func->bus = ctrl->bus;
1746 struct controller *ctrl;
1759 for (ctrl = cpqhp_ctrl_list; ctrl; ctrl=ctrl->next)
1760 interrupt_event_handler(ctrl);
1784 static int update_slot_info(struct controller *ctrl, struct slot *slot)
1793 info->power_status = get_slot_enabled(ctrl, slot);
1794 info->attention_status = cpq_get_attention_status(ctrl, slot);
1795 info->latch_status = cpq_get_latch_status(ctrl, slot);
1796 info->adapter_status = get_presence_status(ctrl, slot);
1802 static void interrupt_event_handler(struct controller *ctrl)
1815 if (ctrl->event_queue[loop].event_type != 0) {
1816 hp_slot = ctrl->event_queue[loop].hp_slot;
1818 func = cpqhp_slot_find(ctrl->bus, (hp_slot + ctrl->slot_device_offset), 0);
1822 p_slot = cpqhp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
1829 if (ctrl->event_queue[loop].event_type == INT_BUTTON_PRESS) {
1831 } else if (ctrl->event_queue[loop].event_type ==
1836 mutex_lock(&ctrl->crit_sect);
1841 green_LED_on (ctrl, hp_slot);
1845 green_LED_off (ctrl, hp_slot);
1852 amber_LED_off (ctrl, hp_slot);
1854 set_SOGO(ctrl);
1857 wait_for_ctrl_irq (ctrl);
1859 mutex_unlock(&ctrl->crit_sect);
1862 else if (ctrl->event_queue[loop].event_type == INT_BUTTON_RELEASE) {
1865 if (is_slot_enabled (ctrl, hp_slot)) {
1874 mutex_lock(&ctrl->crit_sect);
1878 amber_LED_off (ctrl, hp_slot);
1879 green_LED_blink (ctrl, hp_slot);
1881 set_SOGO(ctrl);
1884 wait_for_ctrl_irq (ctrl);
1886 mutex_unlock(&ctrl->crit_sect);
1889 p_slot->ctrl = ctrl;
1899 else if (ctrl->event_queue[loop].event_type == INT_POWER_FAULT) {
1904 update_slot_info(ctrl, p_slot);
1907 ctrl->event_queue[loop].event_type = 0;
1931 struct controller *ctrl = (struct controller *) p_slot->ctrl;
1938 if (is_slot_enabled(ctrl, hp_slot)) {
1942 dbg("In power_down_board, func = %p, ctrl = %p\n", func, ctrl);
1948 if (cpqhp_process_SS(ctrl, func) != 0) {
1949 amber_LED_on(ctrl, hp_slot);
1950 green_LED_on(ctrl, hp_slot);
1952 set_SOGO(ctrl);
1955 wait_for_ctrl_irq(ctrl);
1964 dbg("In add_board, func = %p, ctrl = %p\n", func, ctrl);
1970 if (ctrl != NULL) {
1971 if (cpqhp_process_SI(ctrl, func) != 0) {
1972 amber_LED_on(ctrl, hp_slot);
1973 green_LED_off(ctrl, hp_slot);
1975 set_SOGO(ctrl);
1978 wait_for_ctrl_irq (ctrl);
1989 int cpqhp_process_SI(struct controller *ctrl, struct pci_func *func)
2001 hp_slot = device - ctrl->slot_device_offset;
2002 p_slot = cpqhp_find_slot(ctrl, device);
2007 tempdword = readl(ctrl->hpc_reg + INT_INPUT_CLEAR);
2014 rc = board_replaced(func, ctrl);
2019 func = cpqhp_slot_create(ctrl->bus);
2023 func->bus = ctrl->bus;
2030 temp_word = ctrl->ctrl_int_comp >> 16;
2034 if (ctrl->ctrl_int_comp & (0x1L << hp_slot)) {
2040 rc = board_added(func, ctrl);
2048 func = cpqhp_slot_create(ctrl->bus);
2053 func->bus = ctrl->bus;
2060 temp_word = ctrl->ctrl_int_comp >> 16;
2065 if (ctrl->ctrl_int_comp & (0x1L << hp_slot)) {
2078 update_slot_info(ctrl, p_slot);
2084 int cpqhp_process_SS(struct controller *ctrl, struct pci_func *func)
2092 struct pci_bus *pci_bus = ctrl->pci_bus;
2096 func = cpqhp_slot_find(ctrl->bus, device, index++);
2097 p_slot = cpqhp_find_slot(ctrl, device);
2134 func = cpqhp_slot_find(ctrl->bus, device, index++);
2137 func = cpqhp_slot_find(ctrl->bus, device, 0);
2140 replace_flag = !(ctrl->add_support);
2141 rc = remove_board(func, replace_flag, ctrl);
2147 update_slot_info(ctrl, p_slot);
2154 * @ctrl: controller to use
2159 static void switch_leds(struct controller *ctrl, const int num_of_slots,
2169 writel(*work_LED, ctrl->hpc_reg + LED_CONTROL);
2171 set_SOGO(ctrl);
2174 wait_for_ctrl_irq(ctrl);
2183 * @ctrl: target controller
2186 * For hot plug ctrl folks to play with.
2188 int cpqhp_hardware_test(struct controller *ctrl, int test_num)
2195 num_of_slots = readb(ctrl->hpc_reg + SLOT_MASK) & 0x0f;
2203 save_LED = readl(ctrl->hpc_reg + LED_CONTROL);
2205 switch_leds(ctrl, num_of_slots, &work_LED, 0);
2206 switch_leds(ctrl, num_of_slots, &work_LED, 1);
2207 switch_leds(ctrl, num_of_slots, &work_LED, 0);
2208 switch_leds(ctrl, num_of_slots, &work_LED, 1);
2211 writel(work_LED, ctrl->hpc_reg + LED_CONTROL);
2212 switch_leds(ctrl, num_of_slots, &work_LED, 0);
2213 switch_leds(ctrl, num_of_slots, &work_LED, 1);
2215 writel(work_LED, ctrl->hpc_reg + LED_CONTROL);
2216 switch_leds(ctrl, num_of_slots, &work_LED, 0);
2217 switch_leds(ctrl, num_of_slots, &work_LED, 1);
2220 writel(work_LED, ctrl->hpc_reg + LED_CONTROL);
2222 set_SOGO(ctrl);
2225 wait_for_ctrl_irq (ctrl);
2230 writel(work_LED, ctrl->hpc_reg + LED_CONTROL);
2232 set_SOGO(ctrl);
2235 wait_for_ctrl_irq (ctrl);
2240 writel(work_LED, ctrl->hpc_reg + LED_CONTROL);
2242 writel(work_LED, ctrl->hpc_reg + LED_CONTROL);
2246 writel(save_LED, ctrl->hpc_reg + LED_CONTROL);
2248 set_SOGO(ctrl);
2251 wait_for_ctrl_irq (ctrl);
2266 * @ctrl: pointer to controller structure
2273 static u32 configure_new_device(struct controller * ctrl, struct pci_func * func,
2286 ctrl->pci_bus->number = func->bus;
2287 rc = pci_bus_read_config_byte (ctrl->pci_bus, PCI_DEVFN(func->device, func->function), 0x0E, &temp_byte);
2301 rc = configure_new_function(ctrl, new_slot, behind_bridge, resources);
2325 pci_bus_read_config_dword (ctrl->pci_bus, PCI_DEVFN(func->device, function), 0x00, &ID);
2361 * @ctrl: pointer to controller structure
2369 static int configure_new_function(struct controller *ctrl, struct pci_func *func,
2399 pci_bus = ctrl->pci_bus;
2602 rc = configure_new_device(ctrl, new_slot, 1, &temp_resources);