diff options
author | Vardan Mikayelyan <mvardan@synopsys.com> | 2016-05-25 21:07:10 -0400 |
---|---|---|
committer | Felipe Balbi <felipe.balbi@linux.intel.com> | 2016-06-21 03:49:37 -0400 |
commit | 326015887b6a1321fd61f7a16816241ad841a03c (patch) | |
tree | d6ffb46c2d8ed913edbcae584450cb2dc19116aa /drivers/usb/dwc2 | |
parent | 142bd33fcd185d850178f7f8697ecbeaaa18e257 (diff) |
usb: dwc2: gadget: Add dwc2_gadget_read_ep_interrupts function
Reads and returns interrupts for given endpoint, by masking epint_reg
with corresponding mask.
Tested-by: John Keeping <john@metanate.com>
Signed-off-by: Vardan Mikayelyan <mvardan@synopsys.com>
Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Diffstat (limited to 'drivers/usb/dwc2')
-rw-r--r-- | drivers/usb/dwc2/gadget.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 2cef7a9cb527..8139efdf00fb 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c | |||
@@ -1947,6 +1947,34 @@ static void dwc2_hsotg_complete_in(struct dwc2_hsotg *hsotg, | |||
1947 | } | 1947 | } |
1948 | 1948 | ||
1949 | /** | 1949 | /** |
1950 | * dwc2_gadget_read_ep_interrupts - reads interrupts for given ep | ||
1951 | * @hsotg: The device state. | ||
1952 | * @idx: Index of ep. | ||
1953 | * @dir_in: Endpoint direction 1-in 0-out. | ||
1954 | * | ||
1955 | * Reads for endpoint with given index and direction, by masking | ||
1956 | * epint_reg with coresponding mask. | ||
1957 | */ | ||
1958 | static u32 dwc2_gadget_read_ep_interrupts(struct dwc2_hsotg *hsotg, | ||
1959 | unsigned int idx, int dir_in) | ||
1960 | { | ||
1961 | u32 epmsk_reg = dir_in ? DIEPMSK : DOEPMSK; | ||
1962 | u32 epint_reg = dir_in ? DIEPINT(idx) : DOEPINT(idx); | ||
1963 | u32 ints; | ||
1964 | u32 mask; | ||
1965 | u32 diepempmsk; | ||
1966 | |||
1967 | mask = dwc2_readl(hsotg->regs + epmsk_reg); | ||
1968 | diepempmsk = dwc2_readl(hsotg->regs + DIEPEMPMSK); | ||
1969 | mask |= ((diepempmsk >> idx) & 0x1) ? DIEPMSK_TXFIFOEMPTY : 0; | ||
1970 | mask |= DXEPINT_SETUP_RCVD; | ||
1971 | |||
1972 | ints = dwc2_readl(hsotg->regs + epint_reg); | ||
1973 | ints &= mask; | ||
1974 | return ints; | ||
1975 | } | ||
1976 | |||
1977 | /** | ||
1950 | * dwc2_hsotg_epint - handle an in/out endpoint interrupt | 1978 | * dwc2_hsotg_epint - handle an in/out endpoint interrupt |
1951 | * @hsotg: The driver state | 1979 | * @hsotg: The driver state |
1952 | * @idx: The index for the endpoint (0..15) | 1980 | * @idx: The index for the endpoint (0..15) |
@@ -1964,7 +1992,7 @@ static void dwc2_hsotg_epint(struct dwc2_hsotg *hsotg, unsigned int idx, | |||
1964 | u32 ints; | 1992 | u32 ints; |
1965 | u32 ctrl; | 1993 | u32 ctrl; |
1966 | 1994 | ||
1967 | ints = dwc2_readl(hsotg->regs + epint_reg); | 1995 | ints = dwc2_gadget_read_ep_interrupts(hsotg, idx, dir_in); |
1968 | ctrl = dwc2_readl(hsotg->regs + epctl_reg); | 1996 | ctrl = dwc2_readl(hsotg->regs + epctl_reg); |
1969 | 1997 | ||
1970 | /* Clear endpoint interrupts */ | 1998 | /* Clear endpoint interrupts */ |