Lines Matching +full:ch +full:- +full:func
1 // SPDX-License-Identifier: GPL-2.0
28 #include <asm/pci-direct.h>
68 u32 func; member
82 dbgp_printk(" Debug control: %08x", readl(&ehci_debug->control)); in dbgp_ehci_status()
83 dbgp_printk(" ehci cmd : %08x", readl(&ehci_regs->command)); in dbgp_ehci_status()
85 readl(&ehci_regs->configured_flag)); in dbgp_ehci_status()
86 dbgp_printk(" ehci status : %08x", readl(&ehci_regs->status)); in dbgp_ehci_status()
88 readl(&ehci_regs->port_status[dbgp_phys_port - 1])); in dbgp_ehci_status()
167 ret = readl_poll_timeout_atomic(&ehci_debug->control, ctrl, in dbgp_wait_until_complete()
170 return -DBGP_TIMEOUT; in dbgp_wait_until_complete()
176 writel(ctrl | DBGP_DONE, &ehci_debug->control); in dbgp_wait_until_complete()
177 return (ctrl & DBGP_ERROR) ? -DBGP_ERRCODE(ctrl) : DBGP_LEN(ctrl); in dbgp_wait_until_complete()
184 while (ms--) { in dbgp_mdelay()
201 writel(ctrl | DBGP_GO, &ehci_debug->control); in dbgp_wait_until_done()
203 pids = readl(&ehci_debug->pids); in dbgp_wait_until_done()
207 /* A -DBGP_TIMEOUT failure here means the device has in dbgp_wait_until_done()
213 if (ret == -DBGP_TIMEOUT && !dbgp_not_safe) in dbgp_wait_until_done()
215 if (ret == -DBGP_ERR_BAD && --loop > 0) in dbgp_wait_until_done()
229 if (--loop > 0) in dbgp_wait_until_done()
246 hi |= bytes[i] << (8*(i - 4)); in dbgp_set_data()
247 writel(lo, &ehci_debug->data03); in dbgp_set_data()
248 writel(hi, &ehci_debug->data47); in dbgp_set_data()
257 lo = readl(&ehci_debug->data03); in dbgp_get_data()
258 hi = readl(&ehci_debug->data47); in dbgp_get_data()
262 bytes[i] = (hi >> (8*(i - 4))) & 0xff; in dbgp_get_data()
273 return -1; in dbgp_bulk_write()
277 pids = readl(&ehci_debug->pids); in dbgp_bulk_write()
280 ctrl = readl(&ehci_debug->control); in dbgp_bulk_write()
286 writel(addr, &ehci_debug->address); in dbgp_bulk_write()
287 writel(pids, &ehci_debug->pids); in dbgp_bulk_write()
300 return -1; in dbgp_bulk_read()
304 pids = readl(&ehci_debug->pids); in dbgp_bulk_read()
307 ctrl = readl(&ehci_debug->control); in dbgp_bulk_read()
312 writel(addr, &ehci_debug->address); in dbgp_bulk_read()
313 writel(pids, &ehci_debug->pids); in dbgp_bulk_read()
334 return -1; in dbgp_control_msg()
346 ctrl = readl(&ehci_debug->control); in dbgp_control_msg()
353 writel(addr, &ehci_debug->address); in dbgp_control_msg()
354 writel(pids, &ehci_debug->pids); in dbgp_control_msg()
364 static u32 __init find_cap(u32 num, u32 slot, u32 func, int cap) in find_cap() argument
369 if (!(read_pci_config_16(num, slot, func, PCI_STATUS) & in find_cap()
373 pos = read_pci_config_byte(num, slot, func, PCI_CAPABILITY_LIST); in find_cap()
378 id = read_pci_config_byte(num, slot, func, pos+PCI_CAP_LIST_ID); in find_cap()
384 pos = read_pci_config_byte(num, slot, func, in find_cap()
390 static u32 __init __find_dbgp(u32 bus, u32 slot, u32 func) in __find_dbgp() argument
394 class = read_pci_config(bus, slot, func, PCI_CLASS_REVISION); in __find_dbgp()
398 return find_cap(bus, slot, func, PCI_CAP_ID_EHCI_DEBUG); in __find_dbgp()
403 u32 bus, slot, func; in find_dbgp() local
407 for (func = 0; func < 8; func++) { in find_dbgp()
410 cap = __find_dbgp(bus, slot, func); in find_dbgp()
414 if (ehci_num-- != 0) in find_dbgp()
418 *rfunc = func; in find_dbgp()
432 ctrl = readl(&ehci_debug->control); in dbgp_ehci_startup()
435 writel(ctrl, &ehci_debug->control); in dbgp_ehci_startup()
440 cmd = readl(&ehci_regs->command); in dbgp_ehci_startup()
443 writel(cmd, &ehci_regs->command); in dbgp_ehci_startup()
446 writel(FLAG_CF, &ehci_regs->configured_flag); in dbgp_ehci_startup()
451 status = readl(&ehci_regs->status); in dbgp_ehci_startup()
455 } while (--loop > 0); in dbgp_ehci_startup()
459 return -ENODEV; in dbgp_ehci_startup()
471 cmd = readl(&ehci_regs->command); in dbgp_ehci_controller_reset()
473 writel(cmd, &ehci_regs->command); in dbgp_ehci_controller_reset()
475 cmd = readl(&ehci_regs->command); in dbgp_ehci_controller_reset()
476 } while ((cmd & CMD_RESET) && (--loop > 0)); in dbgp_ehci_controller_reset()
480 return -1; in dbgp_ehci_controller_reset()
487 * Return -ENODEV for any general failure
488 * Return -EIO if wait for port fails
509 portsc = readl(&ehci_regs->port_status[dbg_port - 1]); in _dbgp_external_startup()
515 cmd = readl(&ehci_regs->command); in _dbgp_external_startup()
517 writel(cmd, &ehci_regs->command); in _dbgp_external_startup()
518 portsc = readl(&ehci_regs->port_status[dbg_port - 1]); in _dbgp_external_startup()
520 writel(portsc, &ehci_regs->port_status[dbg_port - 1]); in _dbgp_external_startup()
525 } else if (reset_port_tries--) { in _dbgp_external_startup()
529 return -EIO; in _dbgp_external_startup()
534 ctrl = readl(&ehci_debug->control); in _dbgp_external_startup()
536 writel(ctrl, &ehci_debug->control); in _dbgp_external_startup()
537 ctrl = readl(&ehci_debug->control); in _dbgp_external_startup()
540 writel(ctrl & ~DBGP_CLAIM, &ehci_debug->control); in _dbgp_external_startup()
541 return -ENODEV; in _dbgp_external_startup()
546 portsc = readl(&ehci_regs->port_status[dbg_port - 1]); in _dbgp_external_startup()
548 writel(portsc, &ehci_regs->port_status[dbg_port - 1]); in _dbgp_external_startup()
603 if (tries--) in _dbgp_external_startup()
605 return -ENODEV; in _dbgp_external_startup()
616 portsc = readl(&ehci_regs->port_status[port - 1]); in ehci_reset_port()
619 writel(portsc, &ehci_regs->port_status[port - 1]); in ehci_reset_port()
625 portsc = readl(&ehci_regs->port_status[port - 1]); in ehci_reset_port()
633 &ehci_regs->port_status[port - 1]); in ehci_reset_port()
636 portsc = readl(&ehci_regs->port_status[port-1]); in ehci_reset_port()
637 } while ((portsc & PORT_RESET) && (--loop > 0)); in ehci_reset_port()
642 return -ENOTCONN; in ehci_reset_port()
646 return -EINVAL; in ehci_reset_port()
651 return -EBUSY; in ehci_reset_port()
660 status = readl(&ehci_regs->status); in ehci_wait_for_port()
668 return -ENOTCONN; in ehci_wait_for_port()
682 dword = read_pci_config(ehci_dev.bus, ehci_dev.slot, ehci_dev.func, in nvidia_set_debug_port()
686 write_pci_config(ehci_dev.bus, ehci_dev.slot, ehci_dev.func, 0x74, in nvidia_set_debug_port()
695 vendorid = read_pci_config(ehci_dev.bus, ehci_dev.slot, ehci_dev.func, in detect_set_debug_port()
711 u32 hcc_params = readl(&ehci_caps->hcc_params); in early_ehci_bios_handoff()
720 ehci_dev.func, offset); in early_ehci_bios_handoff()
726 ehci_dev.func, offset + 3, 1); in early_ehci_bios_handoff()
733 msec -= 10; in early_ehci_bios_handoff()
735 ehci_dev.func, offset); in early_ehci_bios_handoff()
743 ehci_dev.func, offset + 2, 0); in early_ehci_bios_handoff()
747 write_pci_config_byte(ehci_dev.bus, ehci_dev.slot, ehci_dev.func, in early_ehci_bios_handoff()
766 hcs_params = readl(&ehci_caps->hcs_params); in ehci_setup()
776 portsc = readl(&ehci_regs->port_status[i-1]); in ehci_setup()
781 if (--playtimes) { in ehci_setup()
785 return -1; in ehci_setup()
790 if (!(readl(&ehci_regs->configured_flag) & FLAG_CF)) { in ehci_setup()
792 return -1; in ehci_setup()
794 dbgp_ehci_status("ehci skip - already configured"); in ehci_setup()
798 if (ret == -EIO) in ehci_setup()
803 ctrl = readl(&ehci_debug->control); in ehci_setup()
805 writel(ctrl, &ehci_debug->control); in ehci_setup()
806 return -1; in ehci_setup()
811 port_map_tried |= (1<<(debug_port - 1)); in ehci_setup()
812 new_debug_port = ((debug_port-1+1)%n_ports) + 1; in ehci_setup()
813 if (port_map_tried != ((1<<n_ports) - 1)) { in ehci_setup()
817 if (--playtimes) { in ehci_setup()
822 return -1; in ehci_setup()
828 u32 bus, slot, func, cap; in early_dbgp_init() local
837 return -1; in early_dbgp_init()
844 cap = find_dbgp(dbgp_num, &bus, &slot, &func); in early_dbgp_init()
846 return -1; in early_dbgp_init()
849 func); in early_dbgp_init()
851 debug_port = read_pci_config(bus, slot, func, cap); in early_dbgp_init()
859 return -1; in early_dbgp_init()
862 bar_val = read_pci_config(bus, slot, func, PCI_BASE_ADDRESS_0); in early_dbgp_init()
867 return -1; in early_dbgp_init()
871 byte = read_pci_config_byte(bus, slot, func, 0x04); in early_dbgp_init()
874 write_pci_config_byte(bus, slot, func, 0x04, byte); in early_dbgp_init()
888 ehci_regs = ehci_bar + EARLY_HC_LENGTH(readl(&ehci_caps->hc_capbase)); in early_dbgp_init()
892 ehci_dev.func = func; in early_dbgp_init()
901 return -1; in early_dbgp_init()
919 cmd = readl(&ehci_regs->command); in early_dbgp_write()
924 ctrl = readl(&ehci_debug->control); in early_dbgp_write()
930 writel(cmd, &ehci_regs->command); in early_dbgp_write()
936 str++, chunk++, n--) { in early_dbgp_write()
940 str--; in early_dbgp_write()
954 cmd = readl(&ehci_regs->command); in early_dbgp_write()
956 writel(cmd, &ehci_regs->command); in early_dbgp_write()
964 .index = -1,
980 if ((early_dbgp_console.index != -1 && in dbgp_reset_prep()
987 ctrl = readl(&ehci_debug->control); in dbgp_reset_prep()
990 writel(ctrl, &ehci_debug->control); in dbgp_reset_prep()
1015 char ch = kgdbdbgp_buf[kgdbdbgp_buf_idx++]; in kgdbdbgp_read_char() local
1016 return ch; in kgdbdbgp_read_char()
1048 return -1; in kgdbdbgp_parse_config()
1056 if (early_dbgp_console.index != -1) in kgdbdbgp_parse_config()
1067 while (readl(&ehci_debug->control) & DBGP_ENABLED) { in kgdbdbgp_reader_thread()
1074 kgdbdbgp_buf_idx--; in kgdbdbgp_reader_thread()