]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
usb: dwc3: Remove of dep->regs
authorPrashanth K <prashanth.k@oss.qualcomm.com>
Wed, 14 Jan 2026 10:07:46 +0000 (15:37 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 16 Jan 2026 12:47:02 +0000 (13:47 +0100)
Remove dep->regs from struct dwc3_ep and reuse dwc->regs instead.
Thus eliminating redundant iomem addresses and making register
access more consistent across the driver.

Signed-off-by: Prashanth K <prashanth.k@oss.qualcomm.com>
Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Link: https://patch.msgid.link/20260114100748.2950103-2-prashanth.k@oss.qualcomm.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/dwc3/core.h
drivers/usb/dwc3/debugfs.c
drivers/usb/dwc3/gadget.c
drivers/usb/dwc3/gadget.h

index a5fc92c4ffa3bc280960e81594ae5cfb401f233a..23188b9105281b1fc040b5cf80771501c64968c0 100644 (file)
 #define DWC3_DCFG1             0xc740 /* DWC_usb32 only */
 
 #define DWC3_DEP_BASE(n)       (0xc800 + ((n) * 0x10))
-#define DWC3_DEPCMDPAR2                0x00
-#define DWC3_DEPCMDPAR1                0x04
-#define DWC3_DEPCMDPAR0                0x08
-#define DWC3_DEPCMD            0x0c
+#define DWC3_DEPCMDPAR2(n)     (DWC3_DEP_BASE(n) + 0x00)
+#define DWC3_DEPCMDPAR1(n)     (DWC3_DEP_BASE(n) + 0x04)
+#define DWC3_DEPCMDPAR0(n)     (DWC3_DEP_BASE(n) + 0x08)
+#define DWC3_DEPCMD(n)         (DWC3_DEP_BASE(n) + 0x0c)
 
 #define DWC3_DEV_IMOD(n)       (0xca00 + ((n) * 0x4))
 
@@ -749,8 +749,6 @@ struct dwc3_ep {
        struct list_head        pending_list;
        struct list_head        started_list;
 
-       void __iomem            *regs;
-
        struct dwc3_trb         *trb_pool;
        dma_addr_t              trb_pool_dma;
        struct dwc3             *dwc;
index d18bf5e32cc8c9cd30088a14330208ed833fd5e1..0b45ff16f575b8461e6e8596ccdd7dd7ecb10f35 100644 (file)
 #define dump_ep_register_set(n)                        \
        {                                       \
                .name = "DEPCMDPAR2("__stringify(n)")", \
-               .offset = DWC3_DEP_BASE(n) +    \
-                       DWC3_DEPCMDPAR2,        \
+               .offset = DWC3_DEPCMDPAR2(n),   \
        },                                      \
        {                                       \
                .name = "DEPCMDPAR1("__stringify(n)")", \
-               .offset = DWC3_DEP_BASE(n) +    \
-                       DWC3_DEPCMDPAR1,        \
+               .offset = DWC3_DEPCMDPAR1(n),   \
        },                                      \
        {                                       \
                .name = "DEPCMDPAR0("__stringify(n)")", \
-               .offset = DWC3_DEP_BASE(n) +    \
-                       DWC3_DEPCMDPAR0,        \
+               .offset = DWC3_DEPCMDPAR0(n),   \
        },                                      \
        {                                       \
                .name = "DEPCMD("__stringify(n)")",     \
-               .offset = DWC3_DEP_BASE(n) +    \
-                       DWC3_DEPCMD,            \
+               .offset = DWC3_DEPCMD(n),               \
        }
 
 
index 8a35a6901db7d750a8abf05339a19c30bad2b7bb..ce087cbc4a530f837ba778c4b665337ff87f7894 100644 (file)
@@ -320,6 +320,7 @@ int dwc3_send_gadget_ep_cmd(struct dwc3_ep *dep, unsigned int cmd,
 
        int                     cmd_status = 0;
        int                     ret = -EINVAL;
+       u8                      epnum = dep->number;
 
        /*
         * When operating in USB 2.0 speeds (HS/FS), if GUSB2PHYCFG.ENBLSLPM or
@@ -355,9 +356,9 @@ int dwc3_send_gadget_ep_cmd(struct dwc3_ep *dep, unsigned int cmd,
         * improve performance.
         */
        if (DWC3_DEPCMD_CMD(cmd) != DWC3_DEPCMD_UPDATETRANSFER) {
-               dwc3_writel(dep->regs, DWC3_DEPCMDPAR0, params->param0);
-               dwc3_writel(dep->regs, DWC3_DEPCMDPAR1, params->param1);
-               dwc3_writel(dep->regs, DWC3_DEPCMDPAR2, params->param2);
+               dwc3_writel(dwc->regs, DWC3_DEPCMDPAR0(epnum), params->param0);
+               dwc3_writel(dwc->regs, DWC3_DEPCMDPAR1(epnum), params->param1);
+               dwc3_writel(dwc->regs, DWC3_DEPCMDPAR2(epnum), params->param2);
        }
 
        /*
@@ -381,7 +382,7 @@ int dwc3_send_gadget_ep_cmd(struct dwc3_ep *dep, unsigned int cmd,
        else
                cmd |= DWC3_DEPCMD_CMDACT;
 
-       dwc3_writel(dep->regs, DWC3_DEPCMD, cmd);
+       dwc3_writel(dwc->regs, DWC3_DEPCMD(epnum), cmd);
 
        if (!(cmd & DWC3_DEPCMD_CMDACT) ||
                (DWC3_DEPCMD_CMD(cmd) == DWC3_DEPCMD_ENDTRANSFER &&
@@ -391,7 +392,7 @@ int dwc3_send_gadget_ep_cmd(struct dwc3_ep *dep, unsigned int cmd,
        }
 
        do {
-               reg = dwc3_readl(dep->regs, DWC3_DEPCMD);
+               reg = dwc3_readl(dwc->regs, DWC3_DEPCMD(epnum));
                if (!(reg & DWC3_DEPCMD_CMDACT)) {
                        cmd_status = DWC3_DEPCMD_STATUS(reg);
 
@@ -3381,7 +3382,6 @@ static int dwc3_gadget_init_endpoint(struct dwc3 *dwc, u8 epnum)
        dep->dwc = dwc;
        dep->number = epnum;
        dep->direction = direction;
-       dep->regs = dwc->regs + DWC3_DEP_BASE(epnum);
        dwc->eps[epnum] = dep;
        dep->combo_num = 0;
        dep->start_cmd_status = 0;
index d73e735e40810807e5a09750aafb36ed318eee48..c3aa9638b7a53ace8714a86b30b8ca243e55a284 100644 (file)
@@ -132,7 +132,7 @@ static inline void dwc3_gadget_ep_get_transfer_index(struct dwc3_ep *dep)
 {
        u32                     res_id;
 
-       res_id = dwc3_readl(dep->regs, DWC3_DEPCMD);
+       res_id = dwc3_readl(dep->dwc->regs, DWC3_DEPCMD(dep->number));
        dep->resource_index = DWC3_DEPCMD_GET_RSC_IDX(res_id);
 }