From: Alexandre Bailon <abailon-rdvid1DuHRBWk0Htik3J/w@public.gmane.org>
To: b-liu-l0cyMroinI0@public.gmane.org
Cc: linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
nsekhar-l0cyMroinI0@public.gmane.org,
ptitiano-rdvid1DuHRBWk0Htik3J/w@public.gmane.org,
sergei.shtylyov-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org,
linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Alexandre Bailon
<abailon-rdvid1DuHRBWk0Htik3J/w@public.gmane.org>
Subject: [PATCH 2/2] usb: musb: musb_cppi41: Fix cppi41_set_dma_mode() for DA8xx
Date: Sun, 13 Aug 2017 14:04:23 +0200 [thread overview]
Message-ID: <20170813120423.16371-3-abailon@baylibre.com> (raw)
In-Reply-To: <20170813120423.16371-1-abailon-rdvid1DuHRBWk0Htik3J/w@public.gmane.org>
The way to configure the DMA mode on DA8xx is different from DSPS.
Add a new function to configure DMA mode on DA8xx and use a callback
to call the right function based on the platform.
Signed-off-by: Alexandre Bailon <abailon-rdvid1DuHRBWk0Htik3J/w@public.gmane.org>
---
drivers/usb/musb/musb_cppi41.c | 40 +++++++++++++++++++++++++++++++++++++---
1 file changed, 37 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c
index dbff0e0a4ff5..7284ec7ecff7 100644
--- a/drivers/usb/musb/musb_cppi41.c
+++ b/drivers/usb/musb/musb_cppi41.c
@@ -26,6 +26,7 @@
#define MUSB_DMA_NUM_CHANNELS 15
+#define DA8XX_USB_MODE_REG 0x10
#define DA8XX_USB_AUTOREQ_REG 0x14
#define DA8XX_USB_TEARDOWN_REG 0x1c
@@ -41,6 +42,9 @@ struct cppi41_dma_controller {
u32 tdown_reg;
u32 autoreq_reg;
+
+ void (*set_dma_mode)(struct cppi41_dma_channel *cppi41_channel,
+ unsigned int mode);
};
static void save_rx_toggle(struct cppi41_dma_channel *cppi41_channel)
@@ -355,6 +359,32 @@ static void cppi41_set_dma_mode(struct cppi41_dma_channel *cppi41_channel,
}
}
+static void da8xx_set_dma_mode(struct cppi41_dma_channel *cppi41_channel,
+ unsigned int mode)
+{
+ struct cppi41_dma_controller *controller = cppi41_channel->controller;
+ struct musb *musb = controller->controller.musb;
+ unsigned int shift;
+ u32 port;
+ u32 new_mode;
+ u32 old_mode;
+
+ old_mode = controller->tx_mode;
+ port = cppi41_channel->port_num;
+
+ shift = (port - 1) * 4;
+ if (!cppi41_channel->is_tx)
+ shift += 16;
+ new_mode = old_mode & ~(3 << shift);
+ new_mode |= mode << shift;
+
+ if (new_mode == old_mode)
+ return;
+ controller->tx_mode = new_mode;
+ musb_writel(musb->ctrl_base, DA8XX_USB_MODE_REG, new_mode);
+}
+
+
static void cppi41_set_autoreq_mode(struct cppi41_dma_channel *cppi41_channel,
unsigned mode)
{
@@ -379,6 +409,7 @@ static bool cppi41_configure_channel(struct dma_channel *channel,
dma_addr_t dma_addr, u32 len)
{
struct cppi41_dma_channel *cppi41_channel = channel->private_data;
+ struct cppi41_dma_controller *controller = cppi41_channel->controller;
struct dma_chan *dc = cppi41_channel->dc;
struct dma_async_tx_descriptor *dma_desc;
enum dma_transfer_direction direction;
@@ -404,7 +435,7 @@ static bool cppi41_configure_channel(struct dma_channel *channel,
musb_writel(musb->ctrl_base,
RNDIS_REG(cppi41_channel->port_num), len);
/* gen rndis */
- cppi41_set_dma_mode(cppi41_channel,
+ controller->set_dma_mode(cppi41_channel,
EP_MODE_DMA_GEN_RNDIS);
/* auto req */
@@ -413,14 +444,15 @@ static bool cppi41_configure_channel(struct dma_channel *channel,
} else {
musb_writel(musb->ctrl_base,
RNDIS_REG(cppi41_channel->port_num), 0);
- cppi41_set_dma_mode(cppi41_channel,
+ controller->set_dma_mode(cppi41_channel,
EP_MODE_DMA_TRANSPARENT);
cppi41_set_autoreq_mode(cppi41_channel,
EP_MODE_AUTOREQ_NONE);
}
} else {
/* fallback mode */
- cppi41_set_dma_mode(cppi41_channel, EP_MODE_DMA_TRANSPARENT);
+ controller->set_dma_mode(cppi41_channel,
+ EP_MODE_DMA_TRANSPARENT);
cppi41_set_autoreq_mode(cppi41_channel, EP_MODE_AUTOREQ_NONE);
len = min_t(u32, packet_sz, len);
}
@@ -737,9 +769,11 @@ cppi41_dma_controller_create(struct musb *musb, void __iomem *base)
if (musb->io.quirks & MUSB_DA8XX) {
controller->tdown_reg = DA8XX_USB_TEARDOWN_REG;
controller->autoreq_reg = DA8XX_USB_AUTOREQ_REG;
+ controller->set_dma_mode = da8xx_set_dma_mode;
} else {
controller->tdown_reg = USB_TDOWN;
controller->autoreq_reg = USB_CTRL_AUTOREQ;
+ controller->set_dma_mode = cppi41_set_dma_mode;
}
ret = cppi41_dma_controller_start(controller);
--
2.13.0
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2017-08-13 12:04 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-13 12:04 [PATCH 0/2] Update MUSB CPPI 4.1 driver to correctly manage the DA8xx Alexandre Bailon
[not found] ` <20170813120423.16371-1-abailon-rdvid1DuHRBWk0Htik3J/w@public.gmane.org>
2017-08-13 12:04 ` [PATCH 1/2] usb: musb: musb_cppi41: Fix the address of teardown and autoreq registers Alexandre Bailon
[not found] ` <20170813120423.16371-2-abailon-rdvid1DuHRBWk0Htik3J/w@public.gmane.org>
2017-08-14 13:31 ` Sekhar Nori
[not found] ` <7ee74cb1-19aa-5323-5325-ef9cc3410762-l0cyMroinI0@public.gmane.org>
2017-08-14 13:36 ` Sekhar Nori
[not found] ` <abce1d79-bc75-2018-2112-d701a8ca69d5-l0cyMroinI0@public.gmane.org>
2017-09-04 13:02 ` Sekhar Nori
[not found] ` <868405c0-0731-7546-509c-8270eb20f30e-l0cyMroinI0@public.gmane.org>
2017-09-07 17:16 ` Bin Liu
[not found] ` <20170907171602.GB21905-zlS79ln5qqxp6PWD+TyudpdHMjK6IpyN@public.gmane.org>
2017-09-12 6:42 ` Alexandre Bailon
2017-08-15 10:12 ` Sergei Shtylyov
[not found] ` <6e5b0e12-d298-b698-bc06-d9c3ae8fb5c3-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>
2017-09-12 6:49 ` Alexandre Bailon
2017-08-13 12:04 ` Alexandre Bailon [this message]
[not found] ` <20170813120423.16371-3-abailon-rdvid1DuHRBWk0Htik3J/w@public.gmane.org>
2017-08-15 10:23 ` [PATCH 2/2] usb: musb: musb_cppi41: Fix cppi41_set_dma_mode() for DA8xx Sergei Shtylyov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170813120423.16371-3-abailon@baylibre.com \
--to=abailon-rdvid1duhrbwk0htik3j/w@public.gmane.org \
--cc=b-liu-l0cyMroinI0@public.gmane.org \
--cc=linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=nsekhar-l0cyMroinI0@public.gmane.org \
--cc=ptitiano-rdvid1DuHRBWk0Htik3J/w@public.gmane.org \
--cc=sergei.shtylyov-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox