0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef __MUSB_DMA_H__
0011 #define __MUSB_DMA_H__
0012
0013 struct musb_hw_ep;
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038 #define MUSB_HSDMA_BASE 0x200
0039 #define MUSB_HSDMA_INTR (MUSB_HSDMA_BASE + 0)
0040 #define MUSB_HSDMA_CONTROL 0x4
0041 #define MUSB_HSDMA_ADDRESS 0x8
0042 #define MUSB_HSDMA_COUNT 0xc
0043
0044 #define DMA_ADDR_INVALID (~(dma_addr_t)0)
0045
0046 #ifdef CONFIG_MUSB_PIO_ONLY
0047 #define is_dma_capable() (0)
0048 #else
0049 #define is_dma_capable() (1)
0050 #endif
0051
0052 #ifdef CONFIG_USB_UX500_DMA
0053 #define musb_dma_ux500(musb) (musb->ops->quirks & MUSB_DMA_UX500)
0054 #else
0055 #define musb_dma_ux500(musb) 0
0056 #endif
0057
0058 #ifdef CONFIG_USB_TI_CPPI41_DMA
0059 #define musb_dma_cppi41(musb) (musb->ops->quirks & MUSB_DMA_CPPI41)
0060 #else
0061 #define musb_dma_cppi41(musb) 0
0062 #endif
0063
0064 #ifdef CONFIG_USB_TI_CPPI_DMA
0065 #define musb_dma_cppi(musb) (musb->ops->quirks & MUSB_DMA_CPPI)
0066 #else
0067 #define musb_dma_cppi(musb) 0
0068 #endif
0069
0070 #ifdef CONFIG_USB_TUSB_OMAP_DMA
0071 #define tusb_dma_omap(musb) (musb->ops->quirks & MUSB_DMA_TUSB_OMAP)
0072 #else
0073 #define tusb_dma_omap(musb) 0
0074 #endif
0075
0076 #ifdef CONFIG_USB_INVENTRA_DMA
0077 #define musb_dma_inventra(musb) (musb->ops->quirks & MUSB_DMA_INVENTRA)
0078 #else
0079 #define musb_dma_inventra(musb) 0
0080 #endif
0081
0082 #if defined(CONFIG_USB_TI_CPPI_DMA) || defined(CONFIG_USB_TI_CPPI41_DMA)
0083 #define is_cppi_enabled(musb) \
0084 (musb_dma_cppi(musb) || musb_dma_cppi41(musb))
0085 #else
0086 #define is_cppi_enabled(musb) 0
0087 #endif
0088
0089
0090
0091
0092
0093 enum dma_channel_status {
0094
0095 MUSB_DMA_STATUS_UNKNOWN,
0096
0097 MUSB_DMA_STATUS_FREE,
0098
0099 MUSB_DMA_STATUS_BUSY,
0100
0101 MUSB_DMA_STATUS_BUS_ABORT,
0102
0103 MUSB_DMA_STATUS_CORE_ABORT
0104 };
0105
0106 struct dma_controller;
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120 struct dma_channel {
0121 void *private_data;
0122
0123 size_t max_len;
0124 size_t actual_len;
0125 enum dma_channel_status status;
0126 bool desired_mode;
0127 bool rx_packet_done;
0128 };
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138 static inline enum dma_channel_status
0139 dma_channel_status(struct dma_channel *c)
0140 {
0141 return (is_dma_capable() && c) ? c->status : MUSB_DMA_STATUS_UNKNOWN;
0142 }
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160 struct dma_controller {
0161 struct musb *musb;
0162 struct dma_channel *(*channel_alloc)(struct dma_controller *,
0163 struct musb_hw_ep *, u8 is_tx);
0164 void (*channel_release)(struct dma_channel *);
0165 int (*channel_program)(struct dma_channel *channel,
0166 u16 maxpacket, u8 mode,
0167 dma_addr_t dma_addr,
0168 u32 length);
0169 int (*channel_abort)(struct dma_channel *);
0170 int (*is_compatible)(struct dma_channel *channel,
0171 u16 maxpacket,
0172 void *buf, u32 length);
0173 void (*dma_callback)(struct dma_controller *);
0174 };
0175
0176
0177 extern void musb_dma_completion(struct musb *musb, u8 epnum, u8 transmit);
0178
0179 #ifdef CONFIG_MUSB_PIO_ONLY
0180 static inline struct dma_controller *
0181 musb_dma_controller_create(struct musb *m, void __iomem *io)
0182 {
0183 return NULL;
0184 }
0185
0186 static inline void musb_dma_controller_destroy(struct dma_controller *d) { }
0187
0188 #else
0189
0190 extern struct dma_controller *
0191 (*musb_dma_controller_create)(struct musb *, void __iomem *);
0192
0193 extern void (*musb_dma_controller_destroy)(struct dma_controller *);
0194 #endif
0195
0196
0197 extern struct dma_controller *
0198 musbhs_dma_controller_create(struct musb *musb, void __iomem *base);
0199 extern void musbhs_dma_controller_destroy(struct dma_controller *c);
0200 extern struct dma_controller *
0201 musbhs_dma_controller_create_noirq(struct musb *musb, void __iomem *base);
0202 extern irqreturn_t dma_controller_irq(int irq, void *private_data);
0203
0204 extern struct dma_controller *
0205 tusb_dma_controller_create(struct musb *musb, void __iomem *base);
0206 extern void tusb_dma_controller_destroy(struct dma_controller *c);
0207
0208 extern struct dma_controller *
0209 cppi_dma_controller_create(struct musb *musb, void __iomem *base);
0210 extern void cppi_dma_controller_destroy(struct dma_controller *c);
0211
0212 extern struct dma_controller *
0213 cppi41_dma_controller_create(struct musb *musb, void __iomem *base);
0214 extern void cppi41_dma_controller_destroy(struct dma_controller *c);
0215
0216 extern struct dma_controller *
0217 ux500_dma_controller_create(struct musb *musb, void __iomem *base);
0218 extern void ux500_dma_controller_destroy(struct dma_controller *c);
0219
0220 #endif