]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
usb: xhci: use macros with parameter to fill ep_info2
authorChunfeng Yun <chunfeng.yun@mediatek.com>
Tue, 8 Sep 2020 17:00:02 +0000 (19:00 +0200)
committerMarek Vasut <marex@denx.de>
Thu, 1 Oct 2020 17:43:05 +0000 (19:43 +0200)
Use macros with parameter to fill ep_info2, then some macros
for MASK and SHIFT can be removed

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
drivers/usb/host/xhci-mem.c
drivers/usb/host/xhci.c
include/usb/xhci.h

index d627aa555560d5289539624720fcfcf5d5859f94..0b49614995668d639449a17f74fba59d64f6bf50 100644 (file)
@@ -825,25 +825,22 @@ void xhci_setup_addressable_virt_dev(struct xhci_ctrl *ctrl,
 
        /* Step 4 - ring already allocated */
        /* Step 5 */
-       ep0_ctx->ep_info2 = cpu_to_le32(CTRL_EP << EP_TYPE_SHIFT);
+       ep0_ctx->ep_info2 = cpu_to_le32(EP_TYPE(CTRL_EP));
        debug("SPEED = %d\n", speed);
 
        switch (speed) {
        case USB_SPEED_SUPER:
-               ep0_ctx->ep_info2 |= cpu_to_le32(((512 & MAX_PACKET_MASK) <<
-                                       MAX_PACKET_SHIFT));
+               ep0_ctx->ep_info2 |= cpu_to_le32(MAX_PACKET(512));
                debug("Setting Packet size = 512bytes\n");
                break;
        case USB_SPEED_HIGH:
        /* USB core guesses at a 64-byte max packet first for FS devices */
        case USB_SPEED_FULL:
-               ep0_ctx->ep_info2 |= cpu_to_le32(((64 & MAX_PACKET_MASK) <<
-                                       MAX_PACKET_SHIFT));
+               ep0_ctx->ep_info2 |= cpu_to_le32(MAX_PACKET(64));
                debug("Setting Packet size = 64bytes\n");
                break;
        case USB_SPEED_LOW:
-               ep0_ctx->ep_info2 |= cpu_to_le32(((8 & MAX_PACKET_MASK) <<
-                                       MAX_PACKET_SHIFT));
+               ep0_ctx->ep_info2 |= cpu_to_le32(MAX_PACKET(8));
                debug("Setting Packet size = 8bytes\n");
                break;
        default:
@@ -852,9 +849,7 @@ void xhci_setup_addressable_virt_dev(struct xhci_ctrl *ctrl,
        }
 
        /* EP 0 can handle "burst" sizes of 1, so Max Burst Size field is 0 */
-       ep0_ctx->ep_info2 |=
-                       cpu_to_le32(((0 & MAX_BURST_MASK) << MAX_BURST_SHIFT) |
-                       ((3 & ERROR_COUNT_MASK) << ERROR_COUNT_SHIFT));
+       ep0_ctx->ep_info2 |= cpu_to_le32(MAX_BURST(0) | ERROR_COUNT(3));
 
        trb_64 = virt_to_phys(virt_dev->eps[0].ring->first_seg->trbs);
        ep0_ctx->deq = cpu_to_le64(trb_64 | virt_dev->eps[0].ring->cycle_state);
index 5f3a0fba4b56092f0e9f4eb569751fb316f73718..fe30101d938eff2f099ba20ccdf8662df611c9b2 100644 (file)
@@ -618,8 +618,7 @@ static int xhci_set_configuration(struct usb_device *udev)
                        cpu_to_le32(EP_MAX_ESIT_PAYLOAD_HI(max_esit_payload) |
                        EP_INTERVAL(interval) | EP_MULT(mult));
 
-               ep_ctx[ep_index]->ep_info2 =
-                       cpu_to_le32(ep_type << EP_TYPE_SHIFT);
+               ep_ctx[ep_index]->ep_info2 = cpu_to_le32(EP_TYPE(ep_type));
                ep_ctx[ep_index]->ep_info2 |=
                        cpu_to_le32(MAX_PACKET
                        (get_unaligned(&endpt_desc->wMaxPacketSize)));
@@ -832,8 +831,7 @@ int xhci_check_maxpacket(struct usb_device *udev)
                                ctrl->devs[slot_id]->out_ctx, ep_index);
                in_ctx = ctrl->devs[slot_id]->in_ctx;
                ep_ctx = xhci_get_ep_ctx(ctrl, in_ctx, ep_index);
-               ep_ctx->ep_info2 &= cpu_to_le32(~((0xffff & MAX_PACKET_MASK)
-                                               << MAX_PACKET_SHIFT));
+               ep_ctx->ep_info2 &= cpu_to_le32(~MAX_PACKET(MAX_PACKET_MASK));
                ep_ctx->ep_info2 |= cpu_to_le32(MAX_PACKET(max_packet_size));
 
                /*
index 07b1aebc69277d1a15c3e14728e2e8beb383de48..e1d382369a392a758c8f30f50d7651d9a175d2d7 100644 (file)
@@ -632,11 +632,8 @@ struct xhci_ep_ctx {
  */
 #define        FORCE_EVENT             (0x1)
 #define ERROR_COUNT(p)         (((p) & 0x3) << 1)
-#define ERROR_COUNT_SHIFT      (1)
-#define ERROR_COUNT_MASK       (0x3)
 #define CTX_TO_EP_TYPE(p)      (((p) >> 3) & 0x7)
 #define EP_TYPE(p)             ((p) << 3)
-#define EP_TYPE_SHIFT          (3)
 #define ISOC_OUT_EP            1
 #define BULK_OUT_EP            2
 #define INT_OUT_EP             3
@@ -647,13 +644,10 @@ struct xhci_ep_ctx {
 /* bit 6 reserved */
 /* bit 7 is Host Initiate Disable - for disabling stream selection */
 #define MAX_BURST(p)           (((p)&0xff) << 8)
-#define MAX_BURST_MASK         (0xff)
-#define MAX_BURST_SHIFT                (8)
 #define CTX_TO_MAX_BURST(p)    (((p) >> 8) & 0xff)
 #define MAX_PACKET(p)          (((p)&0xffff) << 16)
 #define MAX_PACKET_MASK                (0xffff)
 #define MAX_PACKET_DECODED(p)  (((p) >> 16) & 0xffff)
-#define MAX_PACKET_SHIFT       (16)
 
 /* Get max packet size from ep desc. Bit 10..0 specify the max packet size.
  * USB2.0 spec 9.6.6.