Lines Matching +full:local +full:- +full:cap +full:- +full:size
1 // SPDX-License-Identifier: GPL-2.0
28 #include <asm/pci-direct.h>
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()
107 /* Local version of HC_LENGTH macro as ehci struct is not available here */
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()
236 static inline void dbgp_set_data(const void *buf, int size) in dbgp_set_data() argument
243 for (i = 0; i < 4 && i < size; i++) in dbgp_set_data()
245 for (; i < 8 && i < size; i++) in dbgp_set_data()
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()
251 static inline void dbgp_get_data(void *buf, int size) in dbgp_get_data() argument
257 lo = readl(&ehci_debug->data03); in dbgp_get_data()
258 hi = readl(&ehci_debug->data47); in dbgp_get_data()
259 for (i = 0; i < 4 && i < size; i++) in dbgp_get_data()
261 for (; i < 8 && i < size; i++) in dbgp_get_data()
262 bytes[i] = (hi >> (8*(i - 4))) & 0xff; in dbgp_get_data()
266 const char *bytes, int size) in dbgp_bulk_write() argument
272 if (size > DBGP_MAX_PACKET) in dbgp_bulk_write()
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()
281 ctrl = dbgp_len_update(ctrl, size); in dbgp_bulk_write()
285 dbgp_set_data(bytes, size); in dbgp_bulk_write()
286 writel(addr, &ehci_debug->address); in dbgp_bulk_write()
287 writel(pids, &ehci_debug->pids); in dbgp_bulk_write()
294 int size, int loops) in dbgp_bulk_read() argument
299 if (size > DBGP_MAX_PACKET) in dbgp_bulk_read()
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()
308 ctrl = dbgp_len_update(ctrl, size); in dbgp_bulk_read()
312 writel(addr, &ehci_debug->address); in dbgp_bulk_read()
313 writel(pids, &ehci_debug->pids); in dbgp_bulk_read()
318 if (size > ret) in dbgp_bulk_read()
319 size = ret; in dbgp_bulk_read()
320 dbgp_get_data(data, size); in dbgp_bulk_read()
325 int request, int value, int index, void *data, int size) in dbgp_control_msg() argument
333 if (size > (read ? DBGP_MAX_PACKET : 0)) in dbgp_control_msg()
334 return -1; in dbgp_control_msg()
341 req.wLength = cpu_to_le16(size); 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()
360 return dbgp_bulk_read(devnum, 0, data, size, DBGP_LOOPS); in dbgp_control_msg()
364 static u32 __init find_cap(u32 num, u32 slot, u32 func, int cap) in find_cap() argument
381 if (id == cap) in find_cap()
408 unsigned cap; in find_dbgp() local
410 cap = __find_dbgp(bus, slot, func); in find_dbgp()
412 if (!cap) in find_dbgp()
414 if (ehci_num-- != 0) in find_dbgp()
419 return cap; 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()
711 u32 hcc_params = readl(&ehci_caps->hcc_params); in early_ehci_bios_handoff()
713 u32 cap; in early_ehci_bios_handoff() local
719 cap = read_pci_config(ehci_dev.bus, ehci_dev.slot, in early_ehci_bios_handoff()
721 dbgp_printk("dbgp: ehci BIOS state %08x\n", cap); in early_ehci_bios_handoff()
723 if ((cap & 0xff) == 1 && (cap & EHCI_USBLEGSUP_BIOS)) { in early_ehci_bios_handoff()
731 while ((cap & EHCI_USBLEGSUP_BIOS) && (msec > 0)) { in early_ehci_bios_handoff()
733 msec -= 10; in early_ehci_bios_handoff()
734 cap = read_pci_config(ehci_dev.bus, ehci_dev.slot, in early_ehci_bios_handoff()
738 if (cap & EHCI_USBLEGSUP_BIOS) { in early_ehci_bios_handoff()
741 dbgp_printk("dbgp: BIOS handoff failed: %08x\n", cap); 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()
845 if (!cap) in early_dbgp_init()
846 return -1; 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()
867 return -1; in early_dbgp_init()
879 * FIXME I don't have the bar size so just guess PAGE_SIZE is more in early_dbgp_init()
888 ehci_regs = ehci_bar + EARLY_HC_LENGTH(readl(&ehci_caps->hc_capbase)); 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()
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()