forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-11 04dd17822334871b23ea2862f7798fb0e0007777
kernel/drivers/usb/early/xhci-dbc.c
....@@ -1,5 +1,5 @@
11 // SPDX-License-Identifier: GPL-2.0
2
-/**
2
+/*
33 * xhci-dbc.c - xHCI debug capability early driver
44 *
55 * Copyright (C) 2016 Intel Corporation
....@@ -12,16 +12,16 @@
1212 #include <linux/console.h>
1313 #include <linux/pci_regs.h>
1414 #include <linux/pci_ids.h>
15
-#include <linux/bootmem.h>
15
+#include <linux/memblock.h>
1616 #include <linux/io.h>
1717 #include <asm/pci-direct.h>
1818 #include <asm/fixmap.h>
1919 #include <linux/bcd.h>
2020 #include <linux/export.h>
21
-#include <linux/version.h>
2221 #include <linux/module.h>
2322 #include <linux/delay.h>
2423 #include <linux/kthread.h>
24
+#include <linux/usb/xhci-dbgp.h>
2525
2626 #include "../host/xhci.h"
2727 #include "xhci-dbc.h"
....@@ -94,7 +94,7 @@
9494 {
9595 void *virt;
9696
97
- virt = alloc_bootmem_pages_nopanic(PAGE_SIZE);
97
+ virt = memblock_alloc(PAGE_SIZE, PAGE_SIZE);
9898 if (!virt)
9999 return NULL;
100100
....@@ -135,6 +135,7 @@
135135 {
136136 u32 result;
137137
138
+ /* Can not use readl_poll_timeout_atomic() for early boot things */
138139 do {
139140 result = readl(ptr);
140141 result &= mask;
....@@ -191,7 +192,7 @@
191192 if (!seg)
192193 return;
193194
194
- free_bootmem(seg->dma, PAGE_SIZE);
195
+ memblock_free(seg->dma, PAGE_SIZE);
195196 ring->segment = NULL;
196197 }
197198
....@@ -533,8 +534,6 @@
533534
534535 xdbc_mem_init();
535536
536
- mmiowb();
537
-
538537 ret = xdbc_start();
539538 if (ret < 0)
540539 goto reset_out;
....@@ -586,8 +585,6 @@
586585 return ret;
587586
588587 xdbc_mem_init();
589
-
590
- mmiowb();
591588
592589 ret = xdbc_start();
593590 if (ret < 0) {
....@@ -675,10 +672,10 @@
675672 xdbc_free_ring(&xdbc.in_ring);
676673
677674 if (xdbc.table_dma)
678
- free_bootmem(xdbc.table_dma, PAGE_SIZE);
675
+ memblock_free(xdbc.table_dma, PAGE_SIZE);
679676
680677 if (xdbc.out_dma)
681
- free_bootmem(xdbc.out_dma, PAGE_SIZE);
678
+ memblock_free(xdbc.out_dma, PAGE_SIZE);
682679
683680 xdbc.table_base = NULL;
684681 xdbc.out_buf = NULL;
....@@ -717,17 +714,14 @@
717714
718715 static void xdbc_handle_tx_event(struct xdbc_trb *evt_trb)
719716 {
720
- size_t remain_length;
721717 u32 comp_code;
722718 int ep_id;
723719
724720 comp_code = GET_COMP_CODE(le32_to_cpu(evt_trb->field[2]));
725
- remain_length = EVENT_TRB_LEN(le32_to_cpu(evt_trb->field[2]));
726721 ep_id = TRB_TO_EP_ID(le32_to_cpu(evt_trb->field[3]));
727722
728723 switch (comp_code) {
729724 case COMP_SUCCESS:
730
- remain_length = 0;
731725 case COMP_SHORT_PACKET:
732726 break;
733727 case COMP_TRB_ERROR:
....@@ -978,7 +972,7 @@
978972 goto free_and_quit;
979973 }
980974
981
- base = ioremap_nocache(xdbc.xhci_start, xdbc.xhci_length);
975
+ base = ioremap(xdbc.xhci_start, xdbc.xhci_length);
982976 if (!base) {
983977 xdbc_trace("failed to remap the io address\n");
984978 ret = -ENOMEM;
....@@ -1000,8 +994,8 @@
1000994 xdbc_free_ring(&xdbc.evt_ring);
1001995 xdbc_free_ring(&xdbc.out_ring);
1002996 xdbc_free_ring(&xdbc.in_ring);
1003
- free_bootmem(xdbc.table_dma, PAGE_SIZE);
1004
- free_bootmem(xdbc.out_dma, PAGE_SIZE);
997
+ memblock_free(xdbc.table_dma, PAGE_SIZE);
998
+ memblock_free(xdbc.out_dma, PAGE_SIZE);
1005999 writel(0, &xdbc.xdbc_reg->control);
10061000 early_iounmap(xdbc.xhci_base, xdbc.xhci_length);
10071001