0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef __LINUX_CDNSP_GADGET_H
0013 #define __LINUX_CDNSP_GADGET_H
0014
0015 #include <linux/io-64-nonatomic-lo-hi.h>
0016 #include <linux/usb/gadget.h>
0017 #include <linux/irq.h>
0018
0019
0020 #define CDNSP_DEV_MAX_SLOTS 1
0021
0022 #define CDNSP_EP0_SETUP_SIZE 512
0023
0024
0025 #define CDNSP_ENDPOINTS_NUM 31
0026
0027
0028 #define CDNSP_DEFAULT_BESL 0
0029
0030
0031 #define CDNSP_CMD_TIMEOUT (15 * 1000)
0032
0033
0034 #define CDNSP_MAX_HALT_USEC (16 * 1000)
0035
0036 #define CDNSP_CTX_SIZE 2112
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054 struct cdnsp_cap_regs {
0055 __le32 hc_capbase;
0056 __le32 hcs_params1;
0057 __le32 hcs_params2;
0058 __le32 hcs_params3;
0059 __le32 hcc_params;
0060 __le32 db_off;
0061 __le32 run_regs_off;
0062 __le32 hcc_params2;
0063
0064 };
0065
0066
0067
0068 #define HC_LENGTH(p) (((p) >> 00) & GENMASK(7, 0))
0069
0070 #define HC_VERSION(p) (((p) >> 16) & GENMASK(15, 1))
0071
0072
0073
0074 #define HCS_ENDPOINTS_MASK GENMASK(7, 0)
0075 #define HCS_ENDPOINTS(p) (((p) & HCS_ENDPOINTS_MASK) >> 0)
0076
0077
0078 #define HCC_PARAMS_OFFSET 0x10
0079
0080
0081
0082 #define HCC_64BIT_ADDR(p) ((p) & BIT(0))
0083
0084 #define HCC_64BYTE_CONTEXT(p) ((p) & BIT(2))
0085
0086 #define HCC_MAX_PSA(p) ((((p) >> 12) & 0xf) + 1)
0087
0088 #define HCC_EXT_CAPS(p) (((p) & GENMASK(31, 16)) >> 16)
0089
0090 #define CTX_SIZE(_hcc) (HCC_64BYTE_CONTEXT(_hcc) ? 64 : 32)
0091
0092
0093 #define DBOFF_MASK GENMASK(31, 2)
0094
0095
0096 #define RTSOFF_MASK GENMASK(31, 5)
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115 struct cdnsp_op_regs {
0116 __le32 command;
0117 __le32 status;
0118 __le32 page_size;
0119 __le32 reserved1;
0120 __le32 reserved2;
0121 __le32 dnctrl;
0122 __le64 cmd_ring;
0123
0124 __le32 reserved3[4];
0125 __le64 dcbaa_ptr;
0126 __le32 config_reg;
0127
0128 __le32 reserved4[241];
0129
0130 __le32 port_reg_base;
0131 };
0132
0133
0134 #define NUM_PORT_REGS 4
0135
0136
0137
0138
0139
0140
0141
0142 struct cdnsp_port_regs {
0143 __le32 portsc;
0144 __le32 portpmsc;
0145 __le32 portli;
0146 __le32 reserved;
0147 };
0148
0149
0150
0151
0152
0153
0154
0155 #define CDNSP_PORT_RO (PORT_CONNECT | DEV_SPEED_MASK)
0156
0157
0158
0159
0160
0161 #define CDNSP_PORT_RWS (PORT_PLS_MASK | PORT_WKCONN_E | PORT_WKDISC_E)
0162
0163
0164
0165
0166
0167
0168 #define CDNSP_PORT_RW1CS (PORT_PED | PORT_CSC | PORT_RC | PORT_PLC)
0169
0170
0171
0172 #define CMD_R_S BIT(0)
0173
0174
0175
0176
0177 #define CMD_RESET BIT(1)
0178
0179 #define CMD_INTE BIT(2)
0180
0181
0182
0183
0184 #define CMD_DSEIE BIT(3)
0185
0186 #define CMD_CSS BIT(8)
0187 #define CMD_CRS BIT(9)
0188
0189
0190
0191
0192 #define CMD_EWE BIT(10)
0193
0194 #define CMD_DEVEN BIT(17)
0195
0196
0197
0198 #define CDNSP_IRQS (CMD_INTE | CMD_DSEIE | CMD_EWE)
0199
0200
0201
0202 #define STS_HALT BIT(0)
0203
0204
0205
0206
0207 #define STS_FATAL BIT(2)
0208
0209 #define STS_EINT BIT(3)
0210
0211 #define STS_PCD BIT(4)
0212
0213 #define STS_SSS BIT(8)
0214
0215 #define STS_RSS BIT(9)
0216
0217 #define STS_SRE BIT(10)
0218
0219 #define STS_CNR BIT(11)
0220
0221 #define STS_HCE BIT(12)
0222
0223
0224
0225 #define CMD_RING_CS BIT(0)
0226
0227 #define CMD_RING_ABORT BIT(2)
0228
0229
0230
0231
0232
0233 #define CMD_RING_BUSY(p) ((p) & BIT(4))
0234
0235 #define CMD_RING_RUNNING BIT(3)
0236
0237 #define CMD_RING_RSVD_BITS GENMASK(5, 0)
0238
0239
0240
0241 #define MAX_DEVS GENMASK(7, 0)
0242
0243 #define CONFIG_U3E BIT(8)
0244
0245
0246
0247 #define PORT_CONNECT BIT(0)
0248
0249 #define PORT_PED BIT(1)
0250
0251 #define PORT_RESET BIT(4)
0252
0253
0254
0255
0256
0257 #define PORT_PLS_MASK GENMASK(8, 5)
0258 #define XDEV_U0 (0x0 << 5)
0259 #define XDEV_U1 (0x1 << 5)
0260 #define XDEV_U2 (0x2 << 5)
0261 #define XDEV_U3 (0x3 << 5)
0262 #define XDEV_DISABLED (0x4 << 5)
0263 #define XDEV_RXDETECT (0x5 << 5)
0264 #define XDEV_INACTIVE (0x6 << 5)
0265 #define XDEV_POLLING (0x7 << 5)
0266 #define XDEV_RECOVERY (0x8 << 5)
0267 #define XDEV_HOT_RESET (0x9 << 5)
0268 #define XDEV_COMP_MODE (0xa << 5)
0269 #define XDEV_TEST_MODE (0xb << 5)
0270 #define XDEV_RESUME (0xf << 5)
0271
0272 #define PORT_POWER BIT(9)
0273
0274
0275
0276
0277
0278
0279
0280
0281
0282
0283 #define DEV_SPEED_MASK GENMASK(13, 10)
0284 #define XDEV_FS (0x1 << 10)
0285 #define XDEV_HS (0x3 << 10)
0286 #define XDEV_SS (0x4 << 10)
0287 #define XDEV_SSP (0x5 << 10)
0288 #define DEV_UNDEFSPEED(p) (((p) & DEV_SPEED_MASK) == (0x0 << 10))
0289 #define DEV_FULLSPEED(p) (((p) & DEV_SPEED_MASK) == XDEV_FS)
0290 #define DEV_HIGHSPEED(p) (((p) & DEV_SPEED_MASK) == XDEV_HS)
0291 #define DEV_SUPERSPEED(p) (((p) & DEV_SPEED_MASK) == XDEV_SS)
0292 #define DEV_SUPERSPEEDPLUS(p) (((p) & DEV_SPEED_MASK) == XDEV_SSP)
0293 #define DEV_SUPERSPEED_ANY(p) (((p) & DEV_SPEED_MASK) >= XDEV_SS)
0294 #define DEV_PORT_SPEED(p) (((p) >> 10) & 0x0f)
0295
0296 #define PORT_LINK_STROBE BIT(16)
0297
0298 #define PORT_CSC BIT(17)
0299
0300 #define PORT_WRC BIT(19)
0301
0302 #define PORT_RC BIT(21)
0303
0304
0305
0306
0307
0308
0309
0310
0311
0312
0313
0314
0315
0316
0317 #define PORT_PLC BIT(22)
0318
0319 #define PORT_CEC BIT(23)
0320
0321 #define PORT_WKCONN_E BIT(25)
0322
0323 #define PORT_WKDISC_E BIT(26)
0324
0325 #define PORT_WR BIT(31)
0326
0327 #define PORT_CHANGE_BITS (PORT_CSC | PORT_WRC | PORT_RC | PORT_PLC | PORT_CEC)
0328
0329
0330
0331 #define PORT_U1_TIMEOUT_MASK GENMASK(7, 0)
0332 #define PORT_U1_TIMEOUT(p) ((p) & PORT_U1_TIMEOUT_MASK)
0333
0334 #define PORT_U2_TIMEOUT_MASK GENMASK(14, 8)
0335 #define PORT_U2_TIMEOUT(p) (((p) << 8) & PORT_U2_TIMEOUT_MASK)
0336
0337
0338 #define PORT_L1S_MASK GENMASK(2, 0)
0339 #define PORT_L1S(p) ((p) & PORT_L1S_MASK)
0340 #define PORT_L1S_ACK PORT_L1S(1)
0341 #define PORT_L1S_NYET PORT_L1S(2)
0342 #define PORT_L1S_STALL PORT_L1S(3)
0343 #define PORT_L1S_TIMEOUT PORT_L1S(4)
0344
0345 #define PORT_RWE BIT(3)
0346
0347 #define PORT_BESL(p) (((p) << 4) & GENMASK(7, 4))
0348
0349 #define PORT_HLE BIT(16)
0350
0351 #define PORT_RRBESL(p) (((p) & GENMASK(20, 17)) >> 17)
0352
0353 #define PORT_TEST_MODE_MASK GENMASK(31, 28)
0354 #define PORT_TEST_MODE(p) (((p) << 28) & PORT_TEST_MODE_MASK)
0355
0356
0357
0358
0359
0360
0361
0362
0363
0364
0365
0366
0367
0368
0369
0370
0371
0372
0373 struct cdnsp_intr_reg {
0374 __le32 irq_pending;
0375 __le32 irq_control;
0376 __le32 erst_size;
0377 __le32 rsvd;
0378 __le64 erst_base;
0379 __le64 erst_dequeue;
0380 };
0381
0382
0383 #define IMAN_IE BIT(1)
0384 #define IMAN_IP BIT(0)
0385
0386 #define IMAN_IE_SET(p) ((p) | IMAN_IE)
0387 #define IMAN_IE_CLEAR(p) ((p) & ~IMAN_IE)
0388
0389
0390
0391
0392
0393
0394
0395 #define IMOD_INTERVAL_MASK GENMASK(15, 0)
0396
0397 #define IMOD_COUNTER_MASK GENMASK(31, 16)
0398 #define IMOD_DEFAULT_INTERVAL 0
0399
0400
0401
0402 #define ERST_SIZE_MASK GENMASK(31, 16)
0403
0404
0405
0406
0407
0408
0409 #define ERST_DESI_MASK GENMASK(2, 0)
0410
0411 #define ERST_EHB BIT(3)
0412 #define ERST_PTR_MASK GENMASK(3, 0)
0413
0414
0415
0416
0417
0418
0419
0420
0421
0422
0423 struct cdnsp_run_regs {
0424 __le32 microframe_index;
0425 __le32 rsvd[7];
0426 struct cdnsp_intr_reg ir_set[128];
0427 };
0428
0429
0430
0431
0432
0433
0434
0435
0436
0437
0438
0439 struct cdnsp_20port_cap {
0440 __le32 ext_cap;
0441 __le32 port_reg1;
0442 __le32 port_reg2;
0443 __le32 port_reg3;
0444 __le32 port_reg4;
0445 __le32 port_reg5;
0446 __le32 port_reg6;
0447 };
0448
0449
0450 #define EXT_CAPS_ID(p) (((p) >> 0) & GENMASK(7, 0))
0451 #define EXT_CAPS_NEXT(p) (((p) >> 8) & GENMASK(7, 0))
0452
0453 #define EXT_CAPS_PROTOCOL 2
0454
0455
0456 #define EXT_CAP_CFG_DEV_20PORT_CAP_ID 0xC1
0457
0458
0459
0460
0461 #define PORT_REG6_L1_L0_HW_EN BIT(1)
0462
0463
0464
0465
0466 #define PORT_REG6_FORCE_FS BIT(0)
0467
0468
0469
0470
0471
0472
0473
0474 struct cdnsp_3xport_cap {
0475 __le32 ext_cap;
0476 __le32 mode_addr;
0477 __le32 reserved[52];
0478 __le32 mode_2;
0479 };
0480
0481
0482 #define D_XEC_CFG_3XPORT_CAP 0xC0
0483 #define CFG_3XPORT_SSP_SUPPORT BIT(31)
0484 #define CFG_3XPORT_U1_PIPE_CLK_GATE_EN BIT(0)
0485
0486
0487 #define RTL_REV_CAP 0xC4
0488 #define RTL_REV_CAP_RX_BUFF_CMD_SIZE BITMASK(31, 24)
0489 #define RTL_REV_CAP_RX_BUFF_SIZE BITMASK(15, 0)
0490 #define RTL_REV_CAP_TX_BUFF_CMD_SIZE BITMASK(31, 24)
0491 #define RTL_REV_CAP_TX_BUFF_SIZE BITMASK(15, 0)
0492
0493 #define CDNSP_VER_1 0x00000000
0494 #define CDNSP_VER_2 0x10000000
0495
0496 #define CDNSP_IF_EP_EXIST(pdev, ep_num, dir) \
0497 (readl(&(pdev)->rev_cap->ep_supported) & \
0498 (BIT(ep_num) << ((dir) ? 0 : 16)))
0499
0500
0501
0502
0503
0504
0505
0506
0507
0508
0509 struct cdnsp_rev_cap {
0510 __le32 ext_cap;
0511 __le32 rtl_revision;
0512 __le32 rx_buff_size;
0513 __le32 tx_buff_size;
0514 __le32 ep_supported;
0515 __le32 ctrl_revision;
0516 };
0517
0518
0519 #define D_XEC_PRE_REGS_CAP 0xC8
0520 #define REG_CHICKEN_BITS_2_OFFSET 0x48
0521 #define CHICKEN_XDMA_2_TP_CACHE_DIS BIT(28)
0522
0523
0524 #define XBUF_CAP_ID 0xCB
0525 #define XBUF_RX_TAG_MASK_0_OFFSET 0x1C
0526 #define XBUF_RX_TAG_MASK_1_OFFSET 0x24
0527 #define XBUF_TX_CMD_OFFSET 0x2C
0528
0529
0530
0531
0532
0533
0534
0535
0536
0537 struct cdnsp_doorbell_array {
0538 __le32 cmd_db;
0539 __le32 ep_db;
0540 };
0541
0542 #define DB_VALUE(ep, stream) ((((ep) + 1) & 0xff) | ((stream) << 16))
0543 #define DB_VALUE_EP0_OUT(ep, stream) ((ep) & 0xff)
0544 #define DB_VALUE_CMD 0x00000000
0545
0546
0547
0548
0549
0550
0551
0552
0553
0554
0555
0556
0557 struct cdnsp_container_ctx {
0558 unsigned int type;
0559 #define CDNSP_CTX_TYPE_DEVICE 0x1
0560 #define CDNSP_CTX_TYPE_INPUT 0x2
0561 int size;
0562 int ctx_size;
0563 dma_addr_t dma;
0564 u8 *bytes;
0565 };
0566
0567
0568
0569
0570
0571
0572
0573
0574
0575
0576
0577
0578 struct cdnsp_slot_ctx {
0579 __le32 dev_info;
0580 __le32 dev_port;
0581 __le32 int_target;
0582 __le32 dev_state;
0583
0584 __le32 reserved[4];
0585 };
0586
0587
0588 #define SLOT_SPEED_FS (XDEV_FS << 10)
0589 #define SLOT_SPEED_HS (XDEV_HS << 10)
0590 #define SLOT_SPEED_SS (XDEV_SS << 10)
0591 #define SLOT_SPEED_SSP (XDEV_SSP << 10)
0592
0593
0594
0595 #define DEV_SPEED GENMASK(23, 20)
0596 #define GET_DEV_SPEED(n) (((n) & DEV_SPEED) >> 20)
0597
0598 #define LAST_CTX_MASK ((unsigned int)GENMASK(31, 27))
0599 #define LAST_CTX(p) ((p) << 27)
0600 #define LAST_CTX_TO_EP_NUM(p) (((p) >> 27) - 1)
0601 #define SLOT_FLAG BIT(0)
0602 #define EP0_FLAG BIT(1)
0603
0604
0605
0606 #define DEV_PORT(p) (((p) & 0xff) << 16)
0607
0608
0609
0610 #define DEV_ADDR_MASK GENMASK(7, 0)
0611
0612 #define SLOT_STATE GENMASK(31, 27)
0613 #define GET_SLOT_STATE(p) (((p) & SLOT_STATE) >> 27)
0614
0615 #define SLOT_STATE_DISABLED 0
0616 #define SLOT_STATE_ENABLED SLOT_STATE_DISABLED
0617 #define SLOT_STATE_DEFAULT 1
0618 #define SLOT_STATE_ADDRESSED 2
0619 #define SLOT_STATE_CONFIGURED 3
0620
0621
0622
0623
0624
0625
0626
0627
0628
0629
0630
0631
0632
0633
0634
0635
0636
0637
0638
0639 struct cdnsp_ep_ctx {
0640 __le32 ep_info;
0641 __le32 ep_info2;
0642 __le64 deq;
0643 __le32 tx_info;
0644
0645 __le32 reserved[3];
0646 };
0647
0648
0649
0650
0651
0652
0653
0654
0655
0656
0657
0658 #define EP_STATE_MASK GENMASK(3, 0)
0659 #define EP_STATE_DISABLED 0
0660 #define EP_STATE_RUNNING 1
0661 #define EP_STATE_HALTED 2
0662 #define EP_STATE_STOPPED 3
0663 #define EP_STATE_ERROR 4
0664 #define GET_EP_CTX_STATE(ctx) (le32_to_cpu((ctx)->ep_info) & EP_STATE_MASK)
0665
0666
0667 #define EP_MULT(p) (((p) << 8) & GENMASK(9, 8))
0668 #define CTX_TO_EP_MULT(p) (((p) & GENMASK(9, 8)) >> 8)
0669
0670
0671
0672 #define EP_INTERVAL(p) (((p) << 16) & GENMASK(23, 16))
0673 #define EP_INTERVAL_TO_UFRAMES(p) (1 << (((p) & GENMASK(23, 16)) >> 16))
0674 #define CTX_TO_EP_INTERVAL(p) (((p) & GENMASK(23, 16)) >> 16)
0675 #define EP_MAXPSTREAMS_MASK GENMASK(14, 10)
0676 #define EP_MAXPSTREAMS(p) (((p) << 10) & EP_MAXPSTREAMS_MASK)
0677 #define CTX_TO_EP_MAXPSTREAMS(p) (((p) & EP_MAXPSTREAMS_MASK) >> 10)
0678
0679 #define EP_HAS_LSA BIT(15)
0680
0681
0682 #define ERROR_COUNT(p) (((p) & 0x3) << 1)
0683 #define CTX_TO_EP_TYPE(p) (((p) >> 3) & 0x7)
0684 #define EP_TYPE(p) ((p) << 3)
0685 #define ISOC_OUT_EP 1
0686 #define BULK_OUT_EP 2
0687 #define INT_OUT_EP 3
0688 #define CTRL_EP 4
0689 #define ISOC_IN_EP 5
0690 #define BULK_IN_EP 6
0691 #define INT_IN_EP 7
0692
0693
0694 #define MAX_BURST(p) (((p) << 8) & GENMASK(15, 8))
0695 #define CTX_TO_MAX_BURST(p) (((p) & GENMASK(15, 8)) >> 8)
0696 #define MAX_PACKET(p) (((p) << 16) & GENMASK(31, 16))
0697 #define MAX_PACKET_MASK GENMASK(31, 16)
0698 #define MAX_PACKET_DECODED(p) (((p) & GENMASK(31, 16)) >> 16)
0699
0700
0701 #define EP_AVG_TRB_LENGTH(p) ((p) & GENMASK(15, 0))
0702 #define EP_MAX_ESIT_PAYLOAD_LO(p) (((p) << 16) & GENMASK(31, 16))
0703 #define EP_MAX_ESIT_PAYLOAD_HI(p) ((((p) & GENMASK(23, 16)) >> 16) << 24)
0704 #define CTX_TO_MAX_ESIT_PAYLOAD_LO(p) (((p) & GENMASK(31, 16)) >> 16)
0705 #define CTX_TO_MAX_ESIT_PAYLOAD_HI(p) (((p) & GENMASK(31, 24)) >> 24)
0706
0707
0708 #define EP_CTX_CYCLE_MASK BIT(0)
0709 #define CTX_DEQ_MASK (~0xfL)
0710
0711
0712
0713
0714
0715
0716
0717
0718 struct cdnsp_input_control_ctx {
0719 __le32 drop_flags;
0720 __le32 add_flags;
0721 __le32 rsvd2[6];
0722 };
0723
0724
0725
0726
0727
0728
0729
0730
0731 struct cdnsp_command {
0732
0733 struct cdnsp_container_ctx *in_ctx;
0734 u32 status;
0735 union cdnsp_trb *command_trb;
0736 };
0737
0738
0739
0740
0741
0742
0743
0744 struct cdnsp_stream_ctx {
0745 __le64 stream_ring;
0746 __le32 reserved[2];
0747 };
0748
0749
0750 #define SCT_FOR_CTX(p) (((p) << 1) & GENMASK(3, 1))
0751
0752 #define SCT_SEC_TR 0
0753
0754 #define SCT_PRI_TR 1
0755
0756
0757
0758
0759
0760
0761
0762
0763
0764
0765
0766
0767
0768
0769
0770
0771
0772 struct cdnsp_stream_info {
0773 struct cdnsp_ring **stream_rings;
0774 unsigned int num_streams;
0775 struct cdnsp_stream_ctx *stream_ctx_array;
0776 unsigned int num_stream_ctxs;
0777 dma_addr_t ctx_array_dma;
0778 struct radix_tree_root trb_address_map;
0779 int td_count;
0780 u8 first_prime_det;
0781 #define STREAM_DRBL_FIFO_DEPTH 2
0782 u8 drbls_count;
0783 };
0784
0785 #define STREAM_LOG_STREAMS 4
0786 #define STREAM_NUM_STREAMS BIT(STREAM_LOG_STREAMS)
0787
0788 #if STREAM_LOG_STREAMS > 16 && STREAM_LOG_STREAMS < 1
0789 #error "Not suupported stream value"
0790 #endif
0791
0792
0793
0794
0795
0796
0797
0798
0799
0800
0801
0802
0803
0804
0805
0806
0807
0808
0809
0810
0811
0812
0813
0814
0815 struct cdnsp_ep {
0816 struct usb_ep endpoint;
0817 struct list_head pending_list;
0818 struct cdnsp_device *pdev;
0819 u8 number;
0820 u8 idx;
0821 u32 interval;
0822 char name[20];
0823 u8 direction;
0824 u8 buffering;
0825 u8 buffering_period;
0826 struct cdnsp_ep_ctx *in_ctx;
0827 struct cdnsp_ep_ctx *out_ctx;
0828 struct cdnsp_ring *ring;
0829 struct cdnsp_stream_info stream_info;
0830 unsigned int ep_state;
0831 #define EP_ENABLED BIT(0)
0832 #define EP_DIS_IN_RROGRESS BIT(1)
0833 #define EP_HALTED BIT(2)
0834 #define EP_STOPPED BIT(3)
0835 #define EP_WEDGE BIT(4)
0836 #define EP0_HALTED_STATUS BIT(5)
0837 #define EP_HAS_STREAMS BIT(6)
0838 #define EP_UNCONFIGURED BIT(7)
0839
0840 bool skip;
0841 };
0842
0843
0844
0845
0846
0847
0848 struct cdnsp_device_context_array {
0849 __le64 dev_context_ptrs[CDNSP_DEV_MAX_SLOTS + 1];
0850 dma_addr_t dma;
0851 };
0852
0853
0854
0855
0856
0857
0858
0859 struct cdnsp_transfer_event {
0860 __le64 buffer;
0861 __le32 transfer_len;
0862 __le32 flags;
0863 };
0864
0865
0866 #define TRB_EVENT_INVALIDATE 8
0867
0868
0869
0870 #define EVENT_TRB_LEN(p) ((p) & GENMASK(23, 0))
0871
0872 #define COMP_CODE_MASK (0xff << 24)
0873 #define GET_COMP_CODE(p) (((p) & COMP_CODE_MASK) >> 24)
0874 #define COMP_INVALID 0
0875 #define COMP_SUCCESS 1
0876 #define COMP_DATA_BUFFER_ERROR 2
0877 #define COMP_BABBLE_DETECTED_ERROR 3
0878 #define COMP_TRB_ERROR 5
0879 #define COMP_RESOURCE_ERROR 7
0880 #define COMP_NO_SLOTS_AVAILABLE_ERROR 9
0881 #define COMP_INVALID_STREAM_TYPE_ERROR 10
0882 #define COMP_SLOT_NOT_ENABLED_ERROR 11
0883 #define COMP_ENDPOINT_NOT_ENABLED_ERROR 12
0884 #define COMP_SHORT_PACKET 13
0885 #define COMP_RING_UNDERRUN 14
0886 #define COMP_RING_OVERRUN 15
0887 #define COMP_VF_EVENT_RING_FULL_ERROR 16
0888 #define COMP_PARAMETER_ERROR 17
0889 #define COMP_CONTEXT_STATE_ERROR 19
0890 #define COMP_EVENT_RING_FULL_ERROR 21
0891 #define COMP_INCOMPATIBLE_DEVICE_ERROR 22
0892 #define COMP_MISSED_SERVICE_ERROR 23
0893 #define COMP_COMMAND_RING_STOPPED 24
0894 #define COMP_COMMAND_ABORTED 25
0895 #define COMP_STOPPED 26
0896 #define COMP_STOPPED_LENGTH_INVALID 27
0897 #define COMP_STOPPED_SHORT_PACKET 28
0898 #define COMP_MAX_EXIT_LATENCY_TOO_LARGE_ERROR 29
0899 #define COMP_ISOCH_BUFFER_OVERRUN 31
0900 #define COMP_EVENT_LOST_ERROR 32
0901 #define COMP_UNDEFINED_ERROR 33
0902 #define COMP_INVALID_STREAM_ID_ERROR 34
0903
0904
0905 #define TRB_TO_DEV_STREAM(p) ((p) & GENMASK(16, 0))
0906 #define TRB_TO_HOST_STREAM(p) ((p) & GENMASK(16, 0))
0907 #define STREAM_PRIME_ACK 0xFFFE
0908 #define STREAM_REJECTED 0xFFFF
0909
0910
0911 #define TRB_TO_EP_ID(p) (((p) & GENMASK(20, 16)) >> 16)
0912
0913
0914
0915
0916
0917
0918
0919 struct cdnsp_link_trb {
0920 __le64 segment_ptr;
0921 __le32 intr_target;
0922 __le32 control;
0923 };
0924
0925
0926 #define LINK_TOGGLE BIT(1)
0927
0928
0929
0930
0931
0932
0933
0934 struct cdnsp_event_cmd {
0935 __le64 cmd_trb;
0936 __le32 status;
0937 __le32 flags;
0938 };
0939
0940
0941
0942
0943 #define TRB_BSR BIT(9)
0944
0945
0946 #define TRB_DC BIT(9)
0947
0948
0949 #define TRB_FH_TO_PACKET_TYPE(p) ((p) & GENMASK(4, 0))
0950 #define TRB_FH_TR_PACKET 0x4
0951 #define TRB_FH_TO_DEVICE_ADDRESS(p) (((p) << 25) & GENMASK(31, 25))
0952 #define TRB_FH_TR_PACKET_DEV_NOT 0x6
0953 #define TRB_FH_TO_NOT_TYPE(p) (((p) << 4) & GENMASK(7, 4))
0954 #define TRB_FH_TR_PACKET_FUNCTION_WAKE 0x1
0955 #define TRB_FH_TO_INTERFACE(p) (((p) << 8) & GENMASK(15, 8))
0956
0957 enum cdnsp_setup_dev {
0958 SETUP_CONTEXT_ONLY,
0959 SETUP_CONTEXT_ADDRESS,
0960 };
0961
0962
0963 #define TRB_TO_SLOT_ID(p) (((p) & GENMASK(31, 24)) >> 24)
0964 #define SLOT_ID_FOR_TRB(p) (((p) << 24) & GENMASK(31, 24))
0965
0966
0967 #define TRB_TO_EP_INDEX(p) (((p) >> 16) & 0x1f)
0968
0969 #define EP_ID_FOR_TRB(p) ((((p) + 1) << 16) & GENMASK(20, 16))
0970
0971 #define SUSPEND_PORT_FOR_TRB(p) (((p) & 1) << 23)
0972 #define TRB_TO_SUSPEND_PORT(p) (((p) >> 23) & 0x1)
0973 #define LAST_EP_INDEX 30
0974
0975
0976 #define TRB_TO_STREAM_ID(p) ((((p) & GENMASK(31, 16)) >> 16))
0977 #define STREAM_ID_FOR_TRB(p) ((((p)) << 16) & GENMASK(31, 16))
0978 #define SCT_FOR_TRB(p) (((p) << 1) & 0x7)
0979
0980
0981 #define TRB_TC BIT(1)
0982
0983
0984
0985 #define GET_PORT_ID(p) (((p) & GENMASK(31, 24)) >> 24)
0986 #define SET_PORT_ID(p) (((p) << 24) & GENMASK(31, 24))
0987 #define EVENT_DATA BIT(2)
0988
0989
0990
0991 #define TRB_LEN(p) ((p) & GENMASK(16, 0))
0992
0993 #define TRB_TD_SIZE(p) (min((p), (u32)31) << 17)
0994 #define GET_TD_SIZE(p) (((p) & GENMASK(21, 17)) >> 17)
0995
0996
0997
0998
0999 #define TRB_TD_SIZE_TBC(p) (min((p), (u32)31) << 17)
1000
1001 #define TRB_INTR_TARGET(p) (((p) << 22) & GENMASK(31, 22))
1002 #define GET_INTR_TARGET(p) (((p) & GENMASK(31, 22)) >> 22)
1003
1004
1005
1006
1007 #define TRB_TBC(p) (((p) & 0x3) << 7)
1008 #define TRB_TLBPC(p) (((p) & 0xf) << 16)
1009
1010
1011 #define TRB_CYCLE BIT(0)
1012
1013
1014
1015
1016 #define TRB_ENT BIT(1)
1017
1018 #define TRB_ISP BIT(2)
1019
1020 #define TRB_NO_SNOOP BIT(3)
1021
1022 #define TRB_CHAIN BIT(4)
1023
1024 #define TRB_IOC BIT(5)
1025
1026 #define TRB_IDT BIT(6)
1027
1028 #define TRB_STAT BIT(7)
1029
1030 #define TRB_BEI BIT(9)
1031
1032
1033 #define TRB_DIR_IN BIT(16)
1034
1035
1036 #define TRB_SETUPID_BITMASK GENMASK(9, 8)
1037 #define TRB_SETUPID(p) ((p) << 8)
1038 #define TRB_SETUPID_TO_TYPE(p) (((p) & TRB_SETUPID_BITMASK) >> 8)
1039
1040 #define TRB_SETUP_SPEEDID_USB3 0x1
1041 #define TRB_SETUP_SPEEDID_USB2 0x0
1042 #define TRB_SETUP_SPEEDID(p) ((p) & (1 << 7))
1043
1044 #define TRB_SETUPSTAT_ACK 0x1
1045 #define TRB_SETUPSTAT_STALL 0x0
1046 #define TRB_SETUPSTAT(p) ((p) << 6)
1047
1048
1049 #define TRB_SIA BIT(31)
1050 #define TRB_FRAME_ID(p) (((p) << 20) & GENMASK(30, 20))
1051
1052 struct cdnsp_generic_trb {
1053 __le32 field[4];
1054 };
1055
1056 union cdnsp_trb {
1057 struct cdnsp_link_trb link;
1058 struct cdnsp_transfer_event trans_event;
1059 struct cdnsp_event_cmd event_cmd;
1060 struct cdnsp_generic_trb generic;
1061 };
1062
1063
1064 #define TRB_TYPE_BITMASK GENMASK(15, 10)
1065 #define TRB_TYPE(p) ((p) << 10)
1066 #define TRB_FIELD_TO_TYPE(p) (((p) & TRB_TYPE_BITMASK) >> 10)
1067
1068
1069
1070 #define TRB_NORMAL 1
1071
1072 #define TRB_SETUP 2
1073
1074 #define TRB_DATA 3
1075
1076 #define TRB_STATUS 4
1077
1078 #define TRB_ISOC 5
1079
1080 #define TRB_LINK 6
1081 #define TRB_EVENT_DATA 7
1082
1083 #define TRB_TR_NOOP 8
1084
1085
1086
1087 #define TRB_ENABLE_SLOT 9
1088
1089 #define TRB_DISABLE_SLOT 10
1090
1091 #define TRB_ADDR_DEV 11
1092
1093 #define TRB_CONFIG_EP 12
1094
1095 #define TRB_EVAL_CONTEXT 13
1096
1097 #define TRB_RESET_EP 14
1098
1099 #define TRB_STOP_RING 15
1100
1101 #define TRB_SET_DEQ 16
1102
1103 #define TRB_RESET_DEV 17
1104
1105 #define TRB_FORCE_EVENT 18
1106
1107 #define TRB_FORCE_HEADER 22
1108
1109 #define TRB_CMD_NOOP 23
1110
1111
1112
1113
1114 #define TRB_TRANSFER 32
1115
1116 #define TRB_COMPLETION 33
1117
1118 #define TRB_PORT_STATUS 34
1119
1120 #define TRB_HC_EVENT 37
1121
1122 #define TRB_MFINDEX_WRAP 39
1123
1124
1125 #define TRB_ENDPOINT_NRDY 48
1126
1127
1128 #define TRB_HALT_ENDPOINT 54
1129
1130 #define TRB_DRB_OVERFLOW 57
1131
1132 #define TRB_FLUSH_ENDPOINT 58
1133
1134 #define TRB_TYPE_LINK(x) (((x) & TRB_TYPE_BITMASK) == TRB_TYPE(TRB_LINK))
1135 #define TRB_TYPE_LINK_LE32(x) (((x) & cpu_to_le32(TRB_TYPE_BITMASK)) == \
1136 cpu_to_le32(TRB_TYPE(TRB_LINK)))
1137 #define TRB_TYPE_NOOP_LE32(x) (((x) & cpu_to_le32(TRB_TYPE_BITMASK)) == \
1138 cpu_to_le32(TRB_TYPE(TRB_TR_NOOP)))
1139
1140
1141
1142
1143
1144 #define TRBS_PER_SEGMENT 256
1145 #define TRBS_PER_EVENT_SEGMENT 256
1146 #define TRBS_PER_EV_DEQ_UPDATE 100
1147 #define TRB_SEGMENT_SIZE (TRBS_PER_SEGMENT * 16)
1148 #define TRB_SEGMENT_SHIFT (ilog2(TRB_SEGMENT_SIZE))
1149
1150 #define TRB_MAX_BUFF_SHIFT 16
1151 #define TRB_MAX_BUFF_SIZE BIT(TRB_MAX_BUFF_SHIFT)
1152
1153 #define TRB_BUFF_LEN_UP_TO_BOUNDARY(addr) (TRB_MAX_BUFF_SIZE - \
1154 ((addr) & (TRB_MAX_BUFF_SIZE - 1)))
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166 struct cdnsp_segment {
1167 union cdnsp_trb *trbs;
1168 struct cdnsp_segment *next;
1169 dma_addr_t dma;
1170
1171 dma_addr_t bounce_dma;
1172 void *bounce_buf;
1173 unsigned int bounce_offs;
1174 unsigned int bounce_len;
1175 };
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189 struct cdnsp_td {
1190 struct list_head td_list;
1191 struct cdnsp_request *preq;
1192 struct cdnsp_segment *start_seg;
1193 union cdnsp_trb *first_trb;
1194 union cdnsp_trb *last_trb;
1195 struct cdnsp_segment *bounce_seg;
1196 bool request_length_set;
1197 bool drbl;
1198 };
1199
1200
1201
1202
1203
1204
1205
1206
1207 struct cdnsp_dequeue_state {
1208 struct cdnsp_segment *new_deq_seg;
1209 union cdnsp_trb *new_deq_ptr;
1210 int new_cycle_state;
1211 unsigned int stream_id;
1212 };
1213
1214 enum cdnsp_ring_type {
1215 TYPE_CTRL = 0,
1216 TYPE_ISOC,
1217 TYPE_BULK,
1218 TYPE_INTR,
1219 TYPE_STREAM,
1220 TYPE_COMMAND,
1221 TYPE_EVENT,
1222 };
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249 struct cdnsp_ring {
1250 struct cdnsp_segment *first_seg;
1251 struct cdnsp_segment *last_seg;
1252 union cdnsp_trb *enqueue;
1253 struct cdnsp_segment *enq_seg;
1254 union cdnsp_trb *dequeue;
1255 struct cdnsp_segment *deq_seg;
1256 struct list_head td_list;
1257 u32 cycle_state;
1258 unsigned int stream_id;
1259 unsigned int stream_active;
1260 unsigned int stream_rejected;
1261 int num_tds;
1262 unsigned int num_segs;
1263 unsigned int num_trbs_free;
1264 unsigned int bounce_buf_len;
1265 enum cdnsp_ring_type type;
1266 bool last_td_was_short;
1267 struct radix_tree_root *trb_address_map;
1268 };
1269
1270
1271
1272
1273
1274
1275 struct cdnsp_erst_entry {
1276 __le64 seg_addr;
1277 __le32 seg_size;
1278
1279 __le32 rsvd;
1280 };
1281
1282
1283
1284
1285
1286
1287
1288 struct cdnsp_erst {
1289 struct cdnsp_erst_entry *entries;
1290 unsigned int num_entries;
1291 dma_addr_t erst_dma_addr;
1292 };
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304 struct cdnsp_request {
1305 struct cdnsp_td td;
1306 struct usb_request request;
1307 struct list_head list;
1308 struct cdnsp_ep *pep;
1309 u8 epnum;
1310 unsigned direction:1;
1311 };
1312
1313 #define ERST_NUM_SEGS 1
1314
1315
1316 enum cdnsp_ep0_stage {
1317 CDNSP_SETUP_STAGE,
1318 CDNSP_DATA_STAGE,
1319 CDNSP_STATUS_STAGE,
1320 };
1321
1322
1323
1324
1325
1326
1327
1328
1329 struct cdnsp_port {
1330 struct cdnsp_port_regs __iomem *regs;
1331 u8 port_num;
1332 u8 exist;
1333 u8 maj_rev;
1334 u8 min_rev;
1335 };
1336
1337 #define CDNSP_EXT_PORT_MAJOR(x) (((x) >> 24) & 0xff)
1338 #define CDNSP_EXT_PORT_MINOR(x) (((x) >> 16) & 0xff)
1339 #define CDNSP_EXT_PORT_OFF(x) ((x) & 0xff)
1340 #define CDNSP_EXT_PORT_COUNT(x) (((x) >> 8) & 0xff)
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392 struct cdnsp_device {
1393 struct device *dev;
1394 struct usb_gadget gadget;
1395 struct usb_gadget_driver *gadget_driver;
1396 unsigned int irq;
1397 void __iomem *regs;
1398
1399
1400 struct cdnsp_cap_regs __iomem *cap_regs;
1401 struct cdnsp_op_regs __iomem *op_regs;
1402 struct cdnsp_run_regs __iomem *run_regs;
1403 struct cdnsp_doorbell_array __iomem *dba;
1404 struct cdnsp_intr_reg __iomem *ir_set;
1405 struct cdnsp_20port_cap __iomem *port20_regs;
1406 struct cdnsp_3xport_cap __iomem *port3x_regs;
1407 struct cdnsp_rev_cap __iomem *rev_cap;
1408
1409
1410 __u32 hcs_params1;
1411 __u32 hcs_params3;
1412 __u32 hcc_params;
1413
1414 spinlock_t lock;
1415 struct usb_ctrlrequest setup;
1416 struct cdnsp_request ep0_preq;
1417 enum cdnsp_ep0_stage ep0_stage;
1418 u8 three_stage_setup;
1419 u8 ep0_expect_in;
1420 u8 setup_id;
1421 u8 setup_speed;
1422 void *setup_buf;
1423 u8 device_address;
1424 int may_wakeup;
1425 u16 hci_version;
1426
1427
1428 struct cdnsp_device_context_array *dcbaa;
1429 struct cdnsp_ring *cmd_ring;
1430 struct cdnsp_command cmd;
1431 struct cdnsp_ring *event_ring;
1432 struct cdnsp_erst erst;
1433 int slot_id;
1434
1435
1436
1437
1438
1439
1440
1441 struct cdnsp_container_ctx out_ctx;
1442 struct cdnsp_container_ctx in_ctx;
1443 struct cdnsp_ep eps[CDNSP_ENDPOINTS_NUM];
1444 u8 usb2_hw_lpm_capable:1;
1445 u8 u1_allowed:1;
1446 u8 u2_allowed:1;
1447
1448
1449 struct dma_pool *device_pool;
1450 struct dma_pool *segment_pool;
1451
1452 #define CDNSP_STATE_HALTED BIT(1)
1453 #define CDNSP_STATE_DYING BIT(2)
1454 #define CDNSP_STATE_DISCONNECT_PENDING BIT(3)
1455 #define CDNSP_WAKEUP_PENDING BIT(4)
1456 unsigned int cdnsp_state;
1457 unsigned int link_state;
1458
1459 struct cdnsp_port usb2_port;
1460 struct cdnsp_port usb3_port;
1461 struct cdnsp_port *active_port;
1462 u16 test_mode;
1463 };
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473 static inline u64 cdnsp_read_64(__le64 __iomem *regs)
1474 {
1475 return lo_hi_readq(regs);
1476 }
1477
1478 static inline void cdnsp_write_64(const u64 val, __le64 __iomem *regs)
1479 {
1480 lo_hi_writeq(val, regs);
1481 }
1482
1483
1484 void cdnsp_mem_cleanup(struct cdnsp_device *pdev);
1485 int cdnsp_mem_init(struct cdnsp_device *pdev);
1486 int cdnsp_setup_addressable_priv_dev(struct cdnsp_device *pdev);
1487 void cdnsp_copy_ep0_dequeue_into_input_ctx(struct cdnsp_device *pdev);
1488 void cdnsp_endpoint_zero(struct cdnsp_device *pdev, struct cdnsp_ep *ep);
1489 int cdnsp_endpoint_init(struct cdnsp_device *pdev,
1490 struct cdnsp_ep *pep,
1491 gfp_t mem_flags);
1492 int cdnsp_ring_expansion(struct cdnsp_device *pdev,
1493 struct cdnsp_ring *ring,
1494 unsigned int num_trbs, gfp_t flags);
1495 struct cdnsp_ring *cdnsp_dma_to_transfer_ring(struct cdnsp_ep *ep, u64 address);
1496 int cdnsp_alloc_stream_info(struct cdnsp_device *pdev,
1497 struct cdnsp_ep *pep,
1498 unsigned int num_stream_ctxs,
1499 unsigned int num_streams);
1500 int cdnsp_alloc_streams(struct cdnsp_device *pdev, struct cdnsp_ep *pep);
1501 void cdnsp_free_endpoint_rings(struct cdnsp_device *pdev, struct cdnsp_ep *pep);
1502
1503
1504 int cdnsp_find_next_ext_cap(void __iomem *base, u32 start, int id);
1505 int cdnsp_halt(struct cdnsp_device *pdev);
1506 void cdnsp_died(struct cdnsp_device *pdev);
1507 int cdnsp_reset(struct cdnsp_device *pdev);
1508 irqreturn_t cdnsp_irq_handler(int irq, void *priv);
1509 int cdnsp_setup_device(struct cdnsp_device *pdev, enum cdnsp_setup_dev setup);
1510 void cdnsp_set_usb2_hardware_lpm(struct cdnsp_device *usbsssp_data,
1511 struct usb_request *req, int enable);
1512 irqreturn_t cdnsp_thread_irq_handler(int irq, void *data);
1513
1514
1515 dma_addr_t cdnsp_trb_virt_to_dma(struct cdnsp_segment *seg,
1516 union cdnsp_trb *trb);
1517 bool cdnsp_last_trb_on_seg(struct cdnsp_segment *seg, union cdnsp_trb *trb);
1518 bool cdnsp_last_trb_on_ring(struct cdnsp_ring *ring,
1519 struct cdnsp_segment *seg,
1520 union cdnsp_trb *trb);
1521 int cdnsp_wait_for_cmd_compl(struct cdnsp_device *pdev);
1522 void cdnsp_update_erst_dequeue(struct cdnsp_device *pdev,
1523 union cdnsp_trb *event_ring_deq,
1524 u8 clear_ehb);
1525 void cdnsp_initialize_ring_info(struct cdnsp_ring *ring);
1526 void cdnsp_ring_cmd_db(struct cdnsp_device *pdev);
1527 void cdnsp_queue_slot_control(struct cdnsp_device *pdev, u32 trb_type);
1528 void cdnsp_queue_address_device(struct cdnsp_device *pdev,
1529 dma_addr_t in_ctx_ptr,
1530 enum cdnsp_setup_dev setup);
1531 void cdnsp_queue_stop_endpoint(struct cdnsp_device *pdev,
1532 unsigned int ep_index);
1533 int cdnsp_queue_ctrl_tx(struct cdnsp_device *pdev, struct cdnsp_request *preq);
1534 int cdnsp_queue_bulk_tx(struct cdnsp_device *pdev, struct cdnsp_request *preq);
1535 int cdnsp_queue_isoc_tx_prepare(struct cdnsp_device *pdev,
1536 struct cdnsp_request *preq);
1537 void cdnsp_queue_configure_endpoint(struct cdnsp_device *pdev,
1538 dma_addr_t in_ctx_ptr);
1539 void cdnsp_queue_reset_ep(struct cdnsp_device *pdev, unsigned int ep_index);
1540 void cdnsp_queue_halt_endpoint(struct cdnsp_device *pdev,
1541 unsigned int ep_index);
1542 void cdnsp_queue_flush_endpoint(struct cdnsp_device *pdev,
1543 unsigned int ep_index);
1544 void cdnsp_force_header_wakeup(struct cdnsp_device *pdev, int intf_num);
1545 void cdnsp_queue_reset_device(struct cdnsp_device *pdev);
1546 void cdnsp_queue_new_dequeue_state(struct cdnsp_device *pdev,
1547 struct cdnsp_ep *pep,
1548 struct cdnsp_dequeue_state *deq_state);
1549 void cdnsp_ring_doorbell_for_active_rings(struct cdnsp_device *pdev,
1550 struct cdnsp_ep *pep);
1551 void cdnsp_inc_deq(struct cdnsp_device *pdev, struct cdnsp_ring *ring);
1552 void cdnsp_set_link_state(struct cdnsp_device *pdev,
1553 __le32 __iomem *port_regs, u32 link_state);
1554 u32 cdnsp_port_state_to_neutral(u32 state);
1555
1556
1557 int cdnsp_enable_slot(struct cdnsp_device *pdev);
1558 int cdnsp_disable_slot(struct cdnsp_device *pdev);
1559 struct cdnsp_input_control_ctx
1560 *cdnsp_get_input_control_ctx(struct cdnsp_container_ctx *ctx);
1561 struct cdnsp_slot_ctx *cdnsp_get_slot_ctx(struct cdnsp_container_ctx *ctx);
1562 struct cdnsp_ep_ctx *cdnsp_get_ep_ctx(struct cdnsp_container_ctx *ctx,
1563 unsigned int ep_index);
1564
1565 void cdnsp_suspend_gadget(struct cdnsp_device *pdev);
1566 void cdnsp_resume_gadget(struct cdnsp_device *pdev);
1567 void cdnsp_disconnect_gadget(struct cdnsp_device *pdev);
1568 void cdnsp_gadget_giveback(struct cdnsp_ep *pep, struct cdnsp_request *preq,
1569 int status);
1570 int cdnsp_ep_enqueue(struct cdnsp_ep *pep, struct cdnsp_request *preq);
1571 int cdnsp_ep_dequeue(struct cdnsp_ep *pep, struct cdnsp_request *preq);
1572 unsigned int cdnsp_port_speed(unsigned int port_status);
1573 void cdnsp_irq_reset(struct cdnsp_device *pdev);
1574 int cdnsp_halt_endpoint(struct cdnsp_device *pdev,
1575 struct cdnsp_ep *pep, int value);
1576 int cdnsp_cmd_stop_ep(struct cdnsp_device *pdev, struct cdnsp_ep *pep);
1577 int cdnsp_cmd_flush_ep(struct cdnsp_device *pdev, struct cdnsp_ep *pep);
1578 void cdnsp_setup_analyze(struct cdnsp_device *pdev);
1579 int cdnsp_status_stage(struct cdnsp_device *pdev);
1580 int cdnsp_reset_device(struct cdnsp_device *pdev);
1581
1582
1583
1584
1585
1586
1587
1588
1589 static inline struct cdnsp_request *next_request(struct list_head *list)
1590 {
1591 return list_first_entry_or_null(list, struct cdnsp_request, list);
1592 }
1593
1594 #define to_cdnsp_ep(ep) (container_of(ep, struct cdnsp_ep, endpoint))
1595 #define gadget_to_cdnsp(g) (container_of(g, struct cdnsp_device, gadget))
1596 #define request_to_cdnsp_request(r) (container_of(r, struct cdnsp_request, \
1597 request))
1598 #define to_cdnsp_request(r) (container_of(r, struct cdnsp_request, request))
1599 int cdnsp_remove_request(struct cdnsp_device *pdev, struct cdnsp_request *preq,
1600 struct cdnsp_ep *pep);
1601
1602 #endif