Skip to content

Commit cff84bd

Browse files
tmlindFelipe Balbi
authored andcommitted
usb: musb: Remove ifdefs for musb_host_rx in musb_host.c part3
Remove ifdefs for musb_host_rx to get closer to building in all the DMA drivers. Signed-off-by: Tony Lindgren <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
1 parent 557d543 commit cff84bd

File tree

1 file changed

+74
-50
lines changed

1 file changed

+74
-50
lines changed

drivers/usb/musb/musb_host.c

Lines changed: 74 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1572,8 +1572,8 @@ static inline int musb_rx_dma_iso_cppi41(struct dma_controller *dma,
15721572
}
15731573
#endif
15741574

1575-
#ifdef CONFIG_USB_INVENTRA_DMA
1576-
1575+
#if defined(CONFIG_USB_INVENTRA_DMA) || defined(CONFIG_USB_UX500_DMA) || \
1576+
defined(CONFIG_USB_TI_CPPI41_DMA)
15771577
/* Host side RX (IN) using Mentor DMA works as follows:
15781578
submit_urb ->
15791579
- if queue was empty, ProgramEndpoint
@@ -1608,7 +1608,68 @@ static inline int musb_rx_dma_iso_cppi41(struct dma_controller *dma,
16081608
* thus be a great candidate for using mode 1 ... for all but the
16091609
* last packet of one URB's transfer.
16101610
*/
1611+
static int musb_rx_dma_inventra_cppi41(struct dma_controller *dma,
1612+
struct musb_hw_ep *hw_ep,
1613+
struct musb_qh *qh,
1614+
struct urb *urb,
1615+
size_t len)
1616+
{
1617+
struct dma_channel *channel = hw_ep->rx_channel;
1618+
void __iomem *epio = hw_ep->regs;
1619+
u16 val;
1620+
int pipe;
1621+
bool done;
1622+
1623+
pipe = urb->pipe;
1624+
1625+
if (usb_pipeisoc(pipe)) {
1626+
struct usb_iso_packet_descriptor *d;
1627+
1628+
d = urb->iso_frame_desc + qh->iso_idx;
1629+
d->actual_length = len;
1630+
1631+
/* even if there was an error, we did the dma
1632+
* for iso_frame_desc->length
1633+
*/
1634+
if (d->status != -EILSEQ && d->status != -EOVERFLOW)
1635+
d->status = 0;
1636+
1637+
if (++qh->iso_idx >= urb->number_of_packets) {
1638+
done = true;
1639+
} else {
1640+
/* REVISIT: Why ignore return value here? */
1641+
if (musb_dma_cppi41(hw_ep->musb))
1642+
done = musb_rx_dma_iso_cppi41(dma, hw_ep, qh,
1643+
urb, len);
1644+
done = false;
1645+
}
1646+
1647+
} else {
1648+
/* done if urb buffer is full or short packet is recd */
1649+
done = (urb->actual_length + len >=
1650+
urb->transfer_buffer_length
1651+
|| channel->actual_len < qh->maxpacket
1652+
|| channel->rx_packet_done);
1653+
}
1654+
1655+
/* send IN token for next packet, without AUTOREQ */
1656+
if (!done) {
1657+
val = musb_readw(epio, MUSB_RXCSR);
1658+
val |= MUSB_RXCSR_H_REQPKT;
1659+
musb_writew(epio, MUSB_RXCSR, MUSB_RXCSR_H_WZC_BITS | val);
1660+
}
16111661

1662+
return done;
1663+
}
1664+
#else
1665+
static inline int musb_rx_dma_inventra_cppi41(struct dma_controller *dma,
1666+
struct musb_hw_ep *hw_ep,
1667+
struct musb_qh *qh,
1668+
struct urb *urb,
1669+
size_t len)
1670+
{
1671+
return false;
1672+
}
16121673
#endif
16131674

16141675
/*
@@ -1619,6 +1680,7 @@ void musb_host_rx(struct musb *musb, u8 epnum)
16191680
{
16201681
struct urb *urb;
16211682
struct musb_hw_ep *hw_ep = musb->endpoints + epnum;
1683+
struct dma_controller *c = musb->dma_controller;
16221684
void __iomem *epio = hw_ep->regs;
16231685
struct musb_qh *qh = hw_ep->in_qh;
16241686
size_t xfer_len;
@@ -1766,56 +1828,18 @@ void musb_host_rx(struct musb *musb, u8 epnum)
17661828
| MUSB_RXCSR_RXPKTRDY);
17671829
musb_writew(hw_ep->regs, MUSB_RXCSR, val);
17681830

1769-
#if defined(CONFIG_USB_INVENTRA_DMA) || defined(CONFIG_USB_UX500_DMA) || \
1770-
defined(CONFIG_USB_TI_CPPI41_DMA)
1771-
if (usb_pipeisoc(pipe)) {
1772-
struct usb_iso_packet_descriptor *d;
1773-
1774-
d = urb->iso_frame_desc + qh->iso_idx;
1775-
d->actual_length = xfer_len;
1776-
1777-
/* even if there was an error, we did the dma
1778-
* for iso_frame_desc->length
1779-
*/
1780-
if (d->status != -EILSEQ && d->status != -EOVERFLOW)
1781-
d->status = 0;
1782-
1783-
if (++qh->iso_idx >= urb->number_of_packets) {
1784-
done = true;
1785-
} else {
1786-
struct dma_controller *c = musb->dma_controller;
1787-
1788-
/* REVISIT: Why ignore return value here? */
1789-
if (musb_dma_cppi41(musb))
1790-
done = musb_rx_dma_iso_cppi41(c, hw_ep,
1791-
qh, urb,
1792-
xfer_len);
1793-
1794-
done = false;
1795-
}
1796-
1797-
} else {
1798-
/* done if urb buffer is full or short packet is recd */
1799-
done = (urb->actual_length + xfer_len >=
1800-
urb->transfer_buffer_length
1801-
|| dma->actual_len < qh->maxpacket
1802-
|| dma->rx_packet_done);
1803-
}
1804-
1805-
/* send IN token for next packet, without AUTOREQ */
1806-
if (!done) {
1807-
val |= MUSB_RXCSR_H_REQPKT;
1808-
musb_writew(epio, MUSB_RXCSR,
1809-
MUSB_RXCSR_H_WZC_BITS | val);
1831+
if (musb_dma_inventra(musb) || musb_dma_ux500(musb) ||
1832+
musb_dma_cppi41(musb)) {
1833+
done = musb_rx_dma_inventra_cppi41(c, hw_ep, qh, urb, xfer_len);
1834+
dev_dbg(hw_ep->musb->controller,
1835+
"ep %d dma %s, rxcsr %04x, rxcount %d\n",
1836+
epnum, done ? "off" : "reset",
1837+
musb_readw(epio, MUSB_RXCSR),
1838+
musb_readw(epio, MUSB_RXCOUNT));
1839+
} else {
1840+
done = true;
18101841
}
18111842

1812-
dev_dbg(musb->controller, "ep %d dma %s, rxcsr %04x, rxcount %d\n", epnum,
1813-
done ? "off" : "reset",
1814-
musb_readw(epio, MUSB_RXCSR),
1815-
musb_readw(epio, MUSB_RXCOUNT));
1816-
#else
1817-
done = true;
1818-
#endif
18191843
} else if (urb->status == -EINPROGRESS) {
18201844
/* if no errors, be sure a packet is ready for unloading */
18211845
if (unlikely(!(rx_csr & MUSB_RXCSR_RXPKTRDY))) {

0 commit comments

Comments
 (0)