#include <linux/sysfs.h>
#include "./common.h"
+/*
+ * image of renesas_usbhs
+ *
+ * ex) gadget case
+
+ * mod.c
+ * mod_gadget.c
+ * mod_host.c pipe.c fifo.c
+ *
+ * +-------+ +-----------+
+ * | pipe0 |------>| fifo pio |
+ * +------------+ +-------+ +-----------+
+ * | mod_gadget |=====> | pipe1 |--+
+ * +------------+ +-------+ | +-----------+
+ * | pipe2 | | +-| fifo dma0 |
+ * +------------+ +-------+ | | +-----------+
+ * | mod_host | | pipe3 |<-|--+
+ * +------------+ +-------+ | +-----------+
+ * | .... | +--->| fifo dma1 |
+ * | .... | +-----------+
+ */
+
+
#define USBHSF_RUNTIME_PWCTRL (1 << 0)
/* status */
#define usbhsf_fifo_is_busy(f) ((f)->pipe) /* see usbhs_pipe_select_fifo */
/*
- * packet info function
+ * packet initialize
+ */
+void usbhs_pkt_init(struct usbhs_pkt *pkt)
+{
+ pkt->dma = DMA_ADDR_INVALID;
+ INIT_LIST_HEAD(&pkt->node);
+}
+
+/*
+ * packet control function
*/
static int usbhsf_null_handle(struct usbhs_pkt *pkt, int *is_done)
{
.try_run = usbhsf_null_handle,
};
-void usbhs_pkt_init(struct usbhs_pkt *pkt)
-{
- pkt->dma = DMA_ADDR_INVALID;
- INIT_LIST_HEAD(&pkt->node);
-}
-
void usbhs_pkt_push(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt,
struct usbhs_pkt_handle *handler,
void *buf, int len, int zero)
}
/*
- * PIO fifo functions
+ * PIO push handler
*/
static int usbhsf_pio_try_push(struct usbhs_pkt *pkt, int *is_done)
{
.try_run = usbhsf_pio_try_push,
};
+/*
+ * PIO pop handler
+ */
static int usbhsf_prepare_pop(struct usbhs_pkt *pkt, int *is_done)
{
struct usbhs_pipe *pipe = pkt->pipe;
};
/*
- * handler function
+ * DCP ctrol statge handler
*/
static int usbhsf_ctrl_stage_end(struct usbhs_pkt *pkt, int *is_done)
{
dma_async_issue_pending(chan);
}
+/*
+ * DMA push handler
+ */
static int usbhsf_dma_prepare_push(struct usbhs_pkt *pkt, int *is_done)
{
struct usbhs_pipe *pipe = pkt->pipe;
.dma_done = usbhsf_dma_push_done,
};
+/*
+ * DMA pop handler
+ */
static int usbhsf_dma_try_pop(struct usbhs_pkt *pkt, int *is_done)
{
struct usbhs_pipe *pipe = pkt->pipe;
#define usbhsg_status_has(gp, b) (gp->status & b)
/*
- * list push/pop
+ * queue push/pop
*/
static void usbhsg_queue_push(struct usbhsg_uep *uep,
struct usbhsg_request *ureq)
usbhsg_queue_pop(uep, ureq, 0);
}
+/*
+ * dma map/unmap
+ */
static int usbhsg_dma_map(struct device *dev,
struct usbhs_pkt *pkt,
enum dma_data_direction dir)
uep->pipe = pipe;
pipe->mod_private = uep;
+ /*
+ * usbhs_fifo_dma_push/pop_handler try to
+ * use dmaengine if possible.
+ * It will use pio handler if impossible.
+ */
if (usb_endpoint_dir_in(desc))
uep->handler = &usbhs_fifo_dma_push_handler;
else