forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/usb/early/ehci-dbgp.c
....@@ -15,6 +15,7 @@
1515 #include <linux/console.h>
1616 #include <linux/errno.h>
1717 #include <linux/init.h>
18
+#include <linux/iopoll.h>
1819 #include <linux/pci_regs.h>
1920 #include <linux/pci_ids.h>
2021 #include <linux/usb/ch9.h>
....@@ -161,17 +162,11 @@
161162 static int dbgp_wait_until_complete(void)
162163 {
163164 u32 ctrl;
164
- int loop = DBGP_TIMEOUT;
165
+ int ret;
165166
166
- do {
167
- ctrl = readl(&ehci_debug->control);
168
- /* Stop when the transaction is finished */
169
- if (ctrl & DBGP_DONE)
170
- break;
171
- udelay(1);
172
- } while (--loop > 0);
173
-
174
- if (!loop)
167
+ ret = readl_poll_timeout_atomic(&ehci_debug->control, ctrl,
168
+ (ctrl & DBGP_DONE), 1, DBGP_TIMEOUT);
169
+ if (ret)
175170 return -DBGP_TIMEOUT;
176171
177172 /*
....@@ -631,28 +626,28 @@
631626 if (!(portsc & PORT_RESET))
632627 break;
633628 }
634
- if (portsc & PORT_RESET) {
635
- /* force reset to complete */
636
- loop = 100 * 1000;
637
- writel(portsc & ~(PORT_RWC_BITS | PORT_RESET),
638
- &ehci_regs->port_status[port - 1]);
639
- do {
640
- udelay(1);
641
- portsc = readl(&ehci_regs->port_status[port-1]);
642
- } while ((portsc & PORT_RESET) && (--loop > 0));
643
- }
629
+ if (portsc & PORT_RESET) {
630
+ /* force reset to complete */
631
+ loop = 100 * 1000;
632
+ writel(portsc & ~(PORT_RWC_BITS | PORT_RESET),
633
+ &ehci_regs->port_status[port - 1]);
634
+ do {
635
+ udelay(1);
636
+ portsc = readl(&ehci_regs->port_status[port-1]);
637
+ } while ((portsc & PORT_RESET) && (--loop > 0));
638
+ }
644639
645
- /* Device went away? */
646
- if (!(portsc & PORT_CONNECT))
647
- return -ENOTCONN;
640
+ /* Device went away? */
641
+ if (!(portsc & PORT_CONNECT))
642
+ return -ENOTCONN;
648643
649
- /* bomb out completely if something weird happened */
650
- if ((portsc & PORT_CSC))
651
- return -EINVAL;
644
+ /* bomb out completely if something weird happened */
645
+ if ((portsc & PORT_CSC))
646
+ return -EINVAL;
652647
653
- /* If we've finished resetting, then break out of the loop */
654
- if (!(portsc & PORT_RESET) && (portsc & PORT_PE))
655
- return 0;
648
+ /* If we've finished resetting, then break out of the loop */
649
+ if (!(portsc & PORT_RESET) && (portsc & PORT_PE))
650
+ return 0;
656651 return -EBUSY;
657652 }
658653
....@@ -912,7 +907,7 @@
912907
913908 static void early_dbgp_write(struct console *con, const char *str, u32 n)
914909 {
915
- int chunk, ret;
910
+ int chunk;
916911 char buf[DBGP_MAX_PACKET];
917912 int use_cr = 0;
918913 u32 cmd, ctrl;
....@@ -951,8 +946,8 @@
951946 buf[chunk] = *str;
952947 }
953948 if (chunk > 0) {
954
- ret = dbgp_bulk_write(USB_DEBUG_DEVNUM,
955
- dbgp_endpoint_out, buf, chunk);
949
+ dbgp_bulk_write(USB_DEBUG_DEVNUM,
950
+ dbgp_endpoint_out, buf, chunk);
956951 }
957952 }
958953 if (unlikely(reset_run)) {
....@@ -1058,7 +1053,8 @@
10581053 kgdbdbgp_wait_time = simple_strtoul(ptr, &ptr, 10);
10591054 }
10601055 kgdb_register_io_module(&kgdbdbgp_io_ops);
1061
- kgdbdbgp_io_ops.is_console = early_dbgp_console.index != -1;
1056
+ if (early_dbgp_console.index != -1)
1057
+ kgdbdbgp_io_ops.cons = &early_dbgp_console;
10621058
10631059 return 0;
10641060 }