diff options
Diffstat (limited to 'drivers/usb/dwc3/core.h')
-rw-r--r-- | drivers/usb/dwc3/core.h | 62 |
1 files changed, 57 insertions, 5 deletions
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 29a8e1679e12..9e57f8e9bf17 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h | |||
@@ -41,6 +41,7 @@ | |||
41 | 41 | ||
42 | #include <linux/device.h> | 42 | #include <linux/device.h> |
43 | #include <linux/spinlock.h> | 43 | #include <linux/spinlock.h> |
44 | #include <linux/ioport.h> | ||
44 | #include <linux/list.h> | 45 | #include <linux/list.h> |
45 | #include <linux/dma-mapping.h> | 46 | #include <linux/dma-mapping.h> |
46 | #include <linux/mm.h> | 47 | #include <linux/mm.h> |
@@ -52,7 +53,6 @@ | |||
52 | /* Global constants */ | 53 | /* Global constants */ |
53 | #define DWC3_ENDPOINTS_NUM 32 | 54 | #define DWC3_ENDPOINTS_NUM 32 |
54 | 55 | ||
55 | #define DWC3_EVENT_BUFFERS_NUM 2 | ||
56 | #define DWC3_EVENT_BUFFERS_SIZE PAGE_SIZE | 56 | #define DWC3_EVENT_BUFFERS_SIZE PAGE_SIZE |
57 | #define DWC3_EVENT_TYPE_MASK 0xfe | 57 | #define DWC3_EVENT_TYPE_MASK 0xfe |
58 | 58 | ||
@@ -153,6 +153,7 @@ | |||
153 | #define DWC3_GCTL_CLK_PIPEHALF (2) | 153 | #define DWC3_GCTL_CLK_PIPEHALF (2) |
154 | #define DWC3_GCTL_CLK_MASK (3) | 154 | #define DWC3_GCTL_CLK_MASK (3) |
155 | 155 | ||
156 | #define DWC3_GCTL_PRTCAP(n) (((n) & (3 << 12)) >> 12) | ||
156 | #define DWC3_GCTL_PRTCAPDIR(n) (n << 12) | 157 | #define DWC3_GCTL_PRTCAPDIR(n) (n << 12) |
157 | #define DWC3_GCTL_PRTCAP_HOST 1 | 158 | #define DWC3_GCTL_PRTCAP_HOST 1 |
158 | #define DWC3_GCTL_PRTCAP_DEVICE 2 | 159 | #define DWC3_GCTL_PRTCAP_DEVICE 2 |
@@ -347,6 +348,7 @@ struct dwc3_ep { | |||
347 | u32 free_slot; | 348 | u32 free_slot; |
348 | u32 busy_slot; | 349 | u32 busy_slot; |
349 | const struct usb_endpoint_descriptor *desc; | 350 | const struct usb_endpoint_descriptor *desc; |
351 | const struct usb_ss_ep_comp_descriptor *comp_desc; | ||
350 | struct dwc3 *dwc; | 352 | struct dwc3 *dwc; |
351 | 353 | ||
352 | unsigned flags; | 354 | unsigned flags; |
@@ -536,6 +538,31 @@ struct dwc3_hwparams { | |||
536 | u32 hwparams8; | 538 | u32 hwparams8; |
537 | }; | 539 | }; |
538 | 540 | ||
541 | /* HWPARAMS0 */ | ||
542 | #define DWC3_MODE(n) ((n) & 0x7) | ||
543 | |||
544 | #define DWC3_MODE_DEVICE 0 | ||
545 | #define DWC3_MODE_HOST 1 | ||
546 | #define DWC3_MODE_DRD 2 | ||
547 | #define DWC3_MODE_HUB 3 | ||
548 | |||
549 | /* HWPARAMS1 */ | ||
550 | #define DWC3_NUM_INT(n) (((n) & (0x3f << 15)) >> 15) | ||
551 | |||
552 | struct dwc3_request { | ||
553 | struct usb_request request; | ||
554 | struct list_head list; | ||
555 | struct dwc3_ep *dep; | ||
556 | |||
557 | u8 epnum; | ||
558 | struct dwc3_trb_hw *trb; | ||
559 | dma_addr_t trb_dma; | ||
560 | |||
561 | unsigned direction:1; | ||
562 | unsigned mapped:1; | ||
563 | unsigned queued:1; | ||
564 | }; | ||
565 | |||
539 | /** | 566 | /** |
540 | * struct dwc3 - representation of our controller | 567 | * struct dwc3 - representation of our controller |
541 | * @ctrl_req: usb control request which is used for ep0 | 568 | * @ctrl_req: usb control request which is used for ep0 |
@@ -549,19 +576,24 @@ struct dwc3_hwparams { | |||
549 | * @ep0_bounce_addr: dma address of ep0_bounce | 576 | * @ep0_bounce_addr: dma address of ep0_bounce |
550 | * @lock: for synchronizing | 577 | * @lock: for synchronizing |
551 | * @dev: pointer to our struct device | 578 | * @dev: pointer to our struct device |
579 | * @xhci: pointer to our xHCI child | ||
552 | * @event_buffer_list: a list of event buffers | 580 | * @event_buffer_list: a list of event buffers |
553 | * @gadget: device side representation of the peripheral controller | 581 | * @gadget: device side representation of the peripheral controller |
554 | * @gadget_driver: pointer to the gadget driver | 582 | * @gadget_driver: pointer to the gadget driver |
555 | * @regs: base address for our registers | 583 | * @regs: base address for our registers |
556 | * @regs_size: address space size | 584 | * @regs_size: address space size |
557 | * @irq: IRQ number | 585 | * @irq: IRQ number |
586 | * @num_event_buffers: calculated number of event buffers | ||
587 | * @u1u2: only used on revisions <1.83a for workaround | ||
588 | * @maximum_speed: maximum speed requested (mainly for testing purposes) | ||
558 | * @revision: revision register contents | 589 | * @revision: revision register contents |
590 | * @mode: mode of operation | ||
559 | * @is_selfpowered: true when we are selfpowered | 591 | * @is_selfpowered: true when we are selfpowered |
560 | * @three_stage_setup: set if we perform a three phase setup | 592 | * @three_stage_setup: set if we perform a three phase setup |
561 | * @ep0_status_pending: ep0 status response without a req is pending | ||
562 | * @ep0_bounced: true when we used bounce buffer | 593 | * @ep0_bounced: true when we used bounce buffer |
563 | * @ep0_expect_in: true when we expect a DATA IN transfer | 594 | * @ep0_expect_in: true when we expect a DATA IN transfer |
564 | * @start_config_issued: true when StartConfig command has been issued | 595 | * @start_config_issued: true when StartConfig command has been issued |
596 | * @setup_packet_pending: true when there's a Setup Packet in FIFO. Workaround | ||
565 | * @ep0_next_event: hold the next expected event | 597 | * @ep0_next_event: hold the next expected event |
566 | * @ep0state: state of endpoint zero | 598 | * @ep0state: state of endpoint zero |
567 | * @link_state: link state | 599 | * @link_state: link state |
@@ -579,12 +611,15 @@ struct dwc3 { | |||
579 | dma_addr_t ep0_trb_addr; | 611 | dma_addr_t ep0_trb_addr; |
580 | dma_addr_t setup_buf_addr; | 612 | dma_addr_t setup_buf_addr; |
581 | dma_addr_t ep0_bounce_addr; | 613 | dma_addr_t ep0_bounce_addr; |
582 | struct usb_request ep0_usb_req; | 614 | struct dwc3_request ep0_usb_req; |
583 | /* device lock */ | 615 | /* device lock */ |
584 | spinlock_t lock; | 616 | spinlock_t lock; |
585 | struct device *dev; | 617 | struct device *dev; |
586 | 618 | ||
587 | struct dwc3_event_buffer *ev_buffs[DWC3_EVENT_BUFFERS_NUM]; | 619 | struct platform_device *xhci; |
620 | struct resource *res; | ||
621 | |||
622 | struct dwc3_event_buffer **ev_buffs; | ||
588 | struct dwc3_ep *eps[DWC3_ENDPOINTS_NUM]; | 623 | struct dwc3_ep *eps[DWC3_ENDPOINTS_NUM]; |
589 | 624 | ||
590 | struct usb_gadget gadget; | 625 | struct usb_gadget gadget; |
@@ -595,7 +630,11 @@ struct dwc3 { | |||
595 | 630 | ||
596 | int irq; | 631 | int irq; |
597 | 632 | ||
633 | u32 num_event_buffers; | ||
634 | u32 u1u2; | ||
635 | u32 maximum_speed; | ||
598 | u32 revision; | 636 | u32 revision; |
637 | u32 mode; | ||
599 | 638 | ||
600 | #define DWC3_REVISION_173A 0x5533173a | 639 | #define DWC3_REVISION_173A 0x5533173a |
601 | #define DWC3_REVISION_175A 0x5533175a | 640 | #define DWC3_REVISION_175A 0x5533175a |
@@ -607,10 +646,11 @@ struct dwc3 { | |||
607 | 646 | ||
608 | unsigned is_selfpowered:1; | 647 | unsigned is_selfpowered:1; |
609 | unsigned three_stage_setup:1; | 648 | unsigned three_stage_setup:1; |
610 | unsigned ep0_status_pending:1; | ||
611 | unsigned ep0_bounced:1; | 649 | unsigned ep0_bounced:1; |
612 | unsigned ep0_expect_in:1; | 650 | unsigned ep0_expect_in:1; |
613 | unsigned start_config_issued:1; | 651 | unsigned start_config_issued:1; |
652 | unsigned setup_packet_pending:1; | ||
653 | unsigned delayed_status:1; | ||
614 | 654 | ||
615 | enum dwc3_ep0_next ep0_next_event; | 655 | enum dwc3_ep0_next ep0_next_event; |
616 | enum dwc3_ep0_state ep0state; | 656 | enum dwc3_ep0_state ep0state; |
@@ -765,4 +805,16 @@ union dwc3_event { | |||
765 | #define DWC3_HAS_XHCI BIT(1) | 805 | #define DWC3_HAS_XHCI BIT(1) |
766 | #define DWC3_HAS_OTG BIT(3) | 806 | #define DWC3_HAS_OTG BIT(3) |
767 | 807 | ||
808 | /* prototypes */ | ||
809 | void dwc3_set_mode(struct dwc3 *dwc, u32 mode); | ||
810 | |||
811 | int dwc3_host_init(struct dwc3 *dwc); | ||
812 | void dwc3_host_exit(struct dwc3 *dwc); | ||
813 | |||
814 | int dwc3_gadget_init(struct dwc3 *dwc); | ||
815 | void dwc3_gadget_exit(struct dwc3 *dwc); | ||
816 | |||
817 | extern int dwc3_get_device_id(void); | ||
818 | extern void dwc3_put_device_id(int id); | ||
819 | |||
768 | #endif /* __DRIVERS_USB_DWC3_CORE_H */ | 820 | #endif /* __DRIVERS_USB_DWC3_CORE_H */ |