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);
915 writew(misc, ctrl->hpc_reg + MISC);
918 misc = readw(ctrl->hpc_reg + MISC);
921 wake_up_interruptible(&ctrl->queue);
926 Diff = readl(ctrl->hpc_reg + INT_INPUT_CLEAR) ^ ctrl->ctrl_int_comp;
928 ctrl->ctrl_int_comp = readl(ctrl->hpc_reg + INT_INPUT_CLEAR);
931 writel(Diff, ctrl->hpc_reg + INT_INPUT_CLEAR);
934 temp_dword = readl(ctrl->hpc_reg + INT_INPUT_CLEAR);
938 writel(0xFFFFFFFF, ctrl->hpc_reg + INT_INPUT_CLEAR);
940 schedule_flag += handle_switch_change((u8)(Diff & 0xFFL), ctrl);
941 schedule_flag += handle_presence_change((u16)((Diff & 0xFFFF0000L) >> 16), ctrl);
942 schedule_flag += handle_power_fault((u8)((Diff & 0xFF00L) >> 8), ctrl);
945 reset = readb(ctrl->hpc_reg + RESET_FREQ_MODE);
949 writeb(reset, ctrl->hpc_reg + RESET_FREQ_MODE);
950 reset = readb(ctrl->hpc_reg + RESET_FREQ_MODE);
951 wake_up_interruptible(&ctrl->queue);
1122 * @ctrl: controller to change frequency/mode for.
1129 static u8 set_controller_speed(struct controller *ctrl, u8 adapter_speed, u8 hp_slot)
1132 struct pci_bus *bus = ctrl->pci_bus;
1134 u8 slot_power = readb(ctrl->hpc_reg + SLOT_POWER);
1136 u32 leds = readl(ctrl->hpc_reg + LED_CONTROL);
1144 for (slot = ctrl->slot; slot; slot = slot->next) {
1145 if (slot->device == (hp_slot + ctrl->slot_device_offset))
1164 if ((bus->cur_bus_speed > adapter_speed) && (!ctrl->pcix_speed_capability))
1168 if ((bus->cur_bus_speed < adapter_speed) && (!ctrl->pcix_speed_capability))
1180 writel(0x0L, ctrl->hpc_reg + LED_CONTROL);
1181 writeb(0x00, ctrl->hpc_reg + SLOT_ENABLE);
1183 set_SOGO(ctrl);
1184 wait_for_ctrl_irq(ctrl);
1190 pci_write_config_byte(ctrl->pci_dev, 0x41, reg);
1192 reg16 = readw(ctrl->hpc_reg + NEXT_CURR_FREQ);
1217 writew(reg16, ctrl->hpc_reg + NEXT_CURR_FREQ);
1222 writel(0, ctrl->hpc_reg + INT_MASK);
1224 pci_write_config_byte(ctrl->pci_dev, 0x41, reg);
1228 pci_read_config_byte(ctrl->pci_dev, 0x43, &reg);
1229 pci_write_config_byte(ctrl->pci_dev, 0x43, reg);
1234 set_SOGO(ctrl);
1236 wait_for_ctrl_irq(ctrl);
1240 writel(leds, ctrl->hpc_reg + LED_CONTROL);
1241 writeb(slot_power, ctrl->hpc_reg + SLOT_ENABLE);
1243 set_SOGO(ctrl);
1244 wait_for_ctrl_irq(ctrl);
1247 slot = cpqhp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
1262 * @ctrl: hotplug controller
1270 static u32 board_replaced(struct pci_func *func, struct controller *ctrl)
1272 struct pci_bus *bus = ctrl->pci_bus;
1278 hp_slot = func->device - ctrl->slot_device_offset;
1283 if (readl(ctrl->hpc_reg + INT_INPUT_CLEAR) & (0x01L << hp_slot))
1288 else if (is_slot_enabled (ctrl, hp_slot))
1291 mutex_lock(&ctrl->crit_sect);
1294 enable_slot_power (ctrl, hp_slot);
1296 set_SOGO(ctrl);
1299 wait_for_ctrl_irq (ctrl);
1303 temp_byte = readb(ctrl->hpc_reg + SLOT_POWER);
1304 writeb(0x00, ctrl->hpc_reg + SLOT_POWER);
1305 writeb(temp_byte, ctrl->hpc_reg + SLOT_POWER);
1307 set_SOGO(ctrl);
1310 wait_for_ctrl_irq (ctrl);
1312 adapter_speed = get_adapter_speed(ctrl, hp_slot);
1314 if (set_controller_speed(ctrl, adapter_speed, hp_slot))
1318 disable_slot_power (ctrl, hp_slot);
1320 set_SOGO(ctrl);
1323 wait_for_ctrl_irq (ctrl);
1325 mutex_unlock(&ctrl->crit_sect);
1330 mutex_lock(&ctrl->crit_sect);
1332 slot_enable (ctrl, hp_slot);
1333 green_LED_blink (ctrl, hp_slot);
1335 amber_LED_off (ctrl, hp_slot);
1337 set_SOGO(ctrl);
1340 wait_for_ctrl_irq (ctrl);
1342 mutex_unlock(&ctrl->crit_sect);
1353 rc = cpqhp_valid_replace(ctrl, func);
1358 rc = cpqhp_configure_board(ctrl, func);
1367 mutex_lock(&ctrl->crit_sect);
1369 amber_LED_on (ctrl, hp_slot);
1370 green_LED_off (ctrl, hp_slot);
1371 slot_disable (ctrl, hp_slot);
1373 set_SOGO(ctrl);
1376 wait_for_ctrl_irq (ctrl);
1378 mutex_unlock(&ctrl->crit_sect);
1393 mutex_lock(&ctrl->crit_sect);
1395 amber_LED_on (ctrl, hp_slot);
1396 green_LED_off (ctrl, hp_slot);
1397 slot_disable (ctrl, hp_slot);
1399 set_SOGO(ctrl);
1402 wait_for_ctrl_irq (ctrl);
1404 mutex_unlock(&ctrl->crit_sect);
1416 * @ctrl: hotplug controller
1421 static u32 board_added(struct pci_func *func, struct controller *ctrl)
1430 struct pci_bus *bus = ctrl->pci_bus;
1434 hp_slot = func->device - ctrl->slot_device_offset;
1436 __func__, func->device, ctrl->slot_device_offset, hp_slot);
1438 mutex_lock(&ctrl->crit_sect);
1441 enable_slot_power(ctrl, hp_slot);
1443 set_SOGO(ctrl);
1446 wait_for_ctrl_irq (ctrl);
1451 temp_byte = readb(ctrl->hpc_reg + SLOT_POWER);
1452 writeb(0x00, ctrl->hpc_reg + SLOT_POWER);
1453 writeb(temp_byte, ctrl->hpc_reg + SLOT_POWER);
1455 set_SOGO(ctrl);
1458 wait_for_ctrl_irq (ctrl);
1460 adapter_speed = get_adapter_speed(ctrl, hp_slot);
1462 if (set_controller_speed(ctrl, adapter_speed, hp_slot))
1466 disable_slot_power (ctrl, hp_slot);
1468 set_SOGO(ctrl);
1471 wait_for_ctrl_irq(ctrl);
1473 mutex_unlock(&ctrl->crit_sect);
1478 p_slot = cpqhp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
1483 mutex_lock(&ctrl->crit_sect);
1487 slot_enable (ctrl, hp_slot);
1490 green_LED_blink (ctrl, hp_slot);
1493 amber_LED_off (ctrl, hp_slot);
1496 set_SOGO(ctrl);
1500 wait_for_ctrl_irq (ctrl);
1504 mutex_unlock(&ctrl->crit_sect);
1522 ctrl->pci_bus->number = func->bus;
1523 rc = pci_bus_read_config_dword (ctrl->pci_bus, PCI_DEVFN(func->device, func->function), PCI_VENDOR_ID, &temp_register);
1538 res_lists.io_head = ctrl->io_head;
1539 res_lists.mem_head = ctrl->mem_head;
1540 res_lists.p_mem_head = ctrl->p_mem_head;
1541 res_lists.bus_head = ctrl->bus_head;
1544 rc = configure_new_device(ctrl, func, 0, &res_lists);
1547 ctrl->io_head = res_lists.io_head;
1548 ctrl->mem_head = res_lists.mem_head;
1549 ctrl->p_mem_head = res_lists.p_mem_head;
1550 ctrl->bus_head = res_lists.bus_head;
1552 cpqhp_resource_sort_and_combine(&(ctrl->mem_head));
1553 cpqhp_resource_sort_and_combine(&(ctrl->p_mem_head));
1554 cpqhp_resource_sort_and_combine(&(ctrl->io_head));
1555 cpqhp_resource_sort_and_combine(&(ctrl->bus_head));
1558 mutex_lock(&ctrl->crit_sect);
1560 amber_LED_on (ctrl, hp_slot);
1561 green_LED_off (ctrl, hp_slot);
1562 slot_disable (ctrl, hp_slot);
1564 set_SOGO(ctrl);
1567 wait_for_ctrl_irq (ctrl);
1569 mutex_unlock(&ctrl->crit_sect);
1572 cpqhp_save_slot_config(ctrl, func);
1585 new_slot = cpqhp_slot_find(ctrl->bus, func->device, index++);
1587 cpqhp_configure_device(ctrl, new_slot);
1590 mutex_lock(&ctrl->crit_sect);
1592 green_LED_on (ctrl, hp_slot);
1594 set_SOGO(ctrl);
1597 wait_for_ctrl_irq (ctrl);
1599 mutex_unlock(&ctrl->crit_sect);
1601 mutex_lock(&ctrl->crit_sect);
1603 amber_LED_on (ctrl, hp_slot);
1604 green_LED_off (ctrl, hp_slot);
1605 slot_disable (ctrl, hp_slot);
1607 set_SOGO(ctrl);
1610 wait_for_ctrl_irq (ctrl);
1612 mutex_unlock(&ctrl->crit_sect);
1624 * @ctrl: target controller
1626 static u32 remove_board(struct pci_func *func, u32 replace_flag, struct controller *ctrl)
1642 hp_slot = func->device - ctrl->slot_device_offset;
1647 if (replace_flag || !ctrl->add_support)
1648 rc = cpqhp_save_base_addr_length(ctrl, func);
1666 rc = cpqhp_save_used_resources(ctrl, func);
1673 mutex_lock(&ctrl->crit_sect);
1675 green_LED_off (ctrl, hp_slot);
1676 slot_disable (ctrl, hp_slot);
1678 set_SOGO(ctrl);
1681 temp_byte = readb(ctrl->hpc_reg + SLOT_SERR);
1683 writeb(temp_byte, ctrl->hpc_reg + SLOT_SERR);
1686 wait_for_ctrl_irq (ctrl);
1688 mutex_unlock(&ctrl->crit_sect);
1690 if (!replace_flag && ctrl->add_support) {
1692 res_lists.io_head = ctrl->io_head;
1693 res_lists.mem_head = ctrl->mem_head;
1694 res_lists.p_mem_head = ctrl->p_mem_head;
1695 res_lists.bus_head = ctrl->bus_head;
1699 ctrl->io_head = res_lists.io_head;
1700 ctrl->mem_head = res_lists.mem_head;
1701 ctrl->p_mem_head = res_lists.p_mem_head;
1702 ctrl->bus_head = res_lists.bus_head;
1704 cpqhp_resource_sort_and_combine(&(ctrl->mem_head));
1705 cpqhp_resource_sort_and_combine(&(ctrl->p_mem_head));
1706 cpqhp_resource_sort_and_combine(&(ctrl->io_head));
1707 cpqhp_resource_sort_and_combine(&(ctrl->bus_head));
1714 func = cpqhp_slot_find(ctrl->bus, device, 0);
1718 func = cpqhp_slot_create(ctrl->bus);
1723 func->bus = ctrl->bus;
1745 struct controller *ctrl;
1758 for (ctrl = cpqhp_ctrl_list; ctrl; ctrl=ctrl->next)
1759 interrupt_event_handler(ctrl);
1783 static int update_slot_info(struct controller *ctrl, struct slot *slot)
1792 info->power_status = get_slot_enabled(ctrl, slot);
1793 info->attention_status = cpq_get_attention_status(ctrl, slot);
1794 info->latch_status = cpq_get_latch_status(ctrl, slot);
1795 info->adapter_status = get_presence_status(ctrl, slot);
1801 static void interrupt_event_handler(struct controller *ctrl)
1814 if (ctrl->event_queue[loop].event_type != 0) {
1815 hp_slot = ctrl->event_queue[loop].hp_slot;
1817 func = cpqhp_slot_find(ctrl->bus, (hp_slot + ctrl->slot_device_offset), 0);
1821 p_slot = cpqhp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
1828 if (ctrl->event_queue[loop].event_type == INT_BUTTON_PRESS) {
1830 } else if (ctrl->event_queue[loop].event_type ==
1835 mutex_lock(&ctrl->crit_sect);
1840 green_LED_on (ctrl, hp_slot);
1844 green_LED_off (ctrl, hp_slot);
1851 amber_LED_off (ctrl, hp_slot);
1853 set_SOGO(ctrl);
1856 wait_for_ctrl_irq (ctrl);
1858 mutex_unlock(&ctrl->crit_sect);
1861 else if (ctrl->event_queue[loop].event_type == INT_BUTTON_RELEASE) {
1864 if (is_slot_enabled (ctrl, hp_slot)) {
1873 mutex_lock(&ctrl->crit_sect);
1877 amber_LED_off (ctrl, hp_slot);
1878 green_LED_blink (ctrl, hp_slot);
1880 set_SOGO(ctrl);
1883 wait_for_ctrl_irq (ctrl);
1885 mutex_unlock(&ctrl->crit_sect);
1888 p_slot->ctrl = ctrl;
1898 else if (ctrl->event_queue[loop].event_type == INT_POWER_FAULT) {
1902 update_slot_info(ctrl, p_slot);
1905 ctrl->event_queue[loop].event_type = 0;
1929 struct controller *ctrl = (struct controller *) p_slot->ctrl;
1936 if (is_slot_enabled(ctrl, hp_slot)) {
1940 dbg("In power_down_board, func = %p, ctrl = %p\n", func, ctrl);
1946 if (cpqhp_process_SS(ctrl, func) != 0) {
1947 amber_LED_on(ctrl, hp_slot);
1948 green_LED_on(ctrl, hp_slot);
1950 set_SOGO(ctrl);
1953 wait_for_ctrl_irq(ctrl);
1962 dbg("In add_board, func = %p, ctrl = %p\n", func, ctrl);
1968 if (ctrl != NULL) {
1969 if (cpqhp_process_SI(ctrl, func) != 0) {
1970 amber_LED_on(ctrl, hp_slot);
1971 green_LED_off(ctrl, hp_slot);
1973 set_SOGO(ctrl);
1976 wait_for_ctrl_irq (ctrl);
1987 int cpqhp_process_SI(struct controller *ctrl, struct pci_func *func)
1999 hp_slot = device - ctrl->slot_device_offset;
2000 p_slot = cpqhp_find_slot(ctrl, device);
2005 tempdword = readl(ctrl->hpc_reg + INT_INPUT_CLEAR);
2011 rc = board_replaced(func, ctrl);
2016 func = cpqhp_slot_create(ctrl->bus);
2020 func->bus = ctrl->bus;
2027 temp_word = ctrl->ctrl_int_comp >> 16;
2031 if (ctrl->ctrl_int_comp & (0x1L << hp_slot)) {
2037 rc = board_added(func, ctrl);
2045 func = cpqhp_slot_create(ctrl->bus);
2050 func->bus = ctrl->bus;
2057 temp_word = ctrl->ctrl_int_comp >> 16;
2062 if (ctrl->ctrl_int_comp & (0x1L << hp_slot)) {
2074 update_slot_info(ctrl, p_slot);
2080 int cpqhp_process_SS(struct controller *ctrl, struct pci_func *func)
2088 struct pci_bus *pci_bus = ctrl->pci_bus;
2092 func = cpqhp_slot_find(ctrl->bus, device, index++);
2093 p_slot = cpqhp_find_slot(ctrl, device);
2129 func = cpqhp_slot_find(ctrl->bus, device, index++);
2132 func = cpqhp_slot_find(ctrl->bus, device, 0);
2135 replace_flag = !(ctrl->add_support);
2136 rc = remove_board(func, replace_flag, ctrl);
2142 update_slot_info(ctrl, p_slot);
2149 * @ctrl: controller to use
2154 static void switch_leds(struct controller *ctrl, const int num_of_slots,
2164 writel(*work_LED, ctrl->hpc_reg + LED_CONTROL);
2166 set_SOGO(ctrl);
2169 wait_for_ctrl_irq(ctrl);
2178 * @ctrl: target controller
2181 * For hot plug ctrl folks to play with.
2183 int cpqhp_hardware_test(struct controller *ctrl, int test_num)
2190 num_of_slots = readb(ctrl->hpc_reg + SLOT_MASK) & 0x0f;
2198 save_LED = readl(ctrl->hpc_reg + LED_CONTROL);
2200 switch_leds(ctrl, num_of_slots, &work_LED, 0);
2201 switch_leds(ctrl, num_of_slots, &work_LED, 1);
2202 switch_leds(ctrl, num_of_slots, &work_LED, 0);
2203 switch_leds(ctrl, num_of_slots, &work_LED, 1);
2206 writel(work_LED, ctrl->hpc_reg + LED_CONTROL);
2207 switch_leds(ctrl, num_of_slots, &work_LED, 0);
2208 switch_leds(ctrl, num_of_slots, &work_LED, 1);
2210 writel(work_LED, ctrl->hpc_reg + LED_CONTROL);
2211 switch_leds(ctrl, num_of_slots, &work_LED, 0);
2212 switch_leds(ctrl, num_of_slots, &work_LED, 1);
2215 writel(work_LED, ctrl->hpc_reg + LED_CONTROL);
2217 set_SOGO(ctrl);
2220 wait_for_ctrl_irq (ctrl);
2225 writel(work_LED, ctrl->hpc_reg + LED_CONTROL);
2227 set_SOGO(ctrl);
2230 wait_for_ctrl_irq (ctrl);
2235 writel(work_LED, ctrl->hpc_reg + LED_CONTROL);
2237 writel(work_LED, ctrl->hpc_reg + LED_CONTROL);
2241 writel(save_LED, ctrl->hpc_reg + LED_CONTROL);
2243 set_SOGO(ctrl);
2246 wait_for_ctrl_irq (ctrl);
2261 * @ctrl: pointer to controller structure
2268 static u32 configure_new_device(struct controller *ctrl, struct pci_func *func,
2281 ctrl->pci_bus->number = func->bus;
2282 rc = pci_bus_read_config_byte (ctrl->pci_bus, PCI_DEVFN(func->device, func->function), 0x0E, &temp_byte);
2296 rc = configure_new_function(ctrl, new_slot, behind_bridge, resources);
2320 pci_bus_read_config_dword (ctrl->pci_bus, PCI_DEVFN(func->device, function), 0x00, &ID);
2356 * @ctrl: pointer to controller structure
2364 static int configure_new_function(struct controller *ctrl, struct pci_func *func,
2394 pci_bus = ctrl->pci_bus;
2581 rc = configure_new_device(ctrl, new_slot, 1, &temp_resources);