20 #include <linux/device.h>
23 #include <linux/module.h>
25 #include <linux/slab.h>
57 static int compute_wdsize(
size_t wdsize)
108 void (*tx_callback)(
void *),
void *tx_data)
116 void (*rx_callback)(
void *),
void *rx_data)
123 static void setup_desc(
struct dmasg *
desc,
void *
buf,
int fragcount,
124 size_t fragsize,
unsigned int cfg,
125 unsigned int count,
size_t wdsize)
130 for (i = 0; i < fragcount; ++
i) {
145 int fragcount,
size_t fragsize)
151 count = fragsize/sport->
wdsize;
158 fragcount *
sizeof(
struct dmasg), &addr, 0);
168 setup_desc(sport->
tx_desc, buf, fragcount, fragsize,
176 int fragcount,
size_t fragsize)
182 count = fragsize/sport->
wdsize;
189 fragcount *
sizeof(
struct dmasg), &addr, 0);
197 cfg = DMAFLOW_LIST |
DI_EN | compute_wdsize(sport->
wdsize)
200 setup_desc(sport->
rx_desc, buf, fragcount, fragsize,
211 return (
unsigned char *)curr - sport->
tx_buf;
219 return (
unsigned char *)curr - sport->
rx_buf;
226 static unsigned long status;
238 static irqreturn_t sport_rx_irq(
int irq,
void *dev_id)
253 static irqreturn_t sport_err_irq(
int irq,
void *dev_id)
259 dev_err(dev,
"sport error: TUVF\n");
261 dev_err(dev,
"sport error: ROVF\n");
266 static int sport_get_resource(
struct sport_device *sport)
274 dev_err(dev,
"No platform data\n");
281 dev_err(dev,
"No tx MEM resource\n");
288 dev_err(dev,
"No rx MEM resource\n");
295 dev_err(dev,
"No tx DMA resource\n");
302 dev_err(dev,
"No rx DMA resource\n");
309 dev_err(dev,
"No tx error irq resource\n");
316 dev_err(dev,
"No rx error irq resource\n");
324 static int sport_request_resource(
struct sport_device *sport)
331 dev_err(dev,
"Unable to request sport pin\n");
337 dev_err(dev,
"Unable to allocate DMA channel for sport tx\n");
344 dev_err(dev,
"Unable to allocate DMA channel for sport rx\n");
350 0,
"SPORT TX ERROR", sport);
352 dev_err(dev,
"Unable to allocate tx error IRQ for sport\n");
357 0,
"SPORT RX ERROR", sport);
359 dev_err(dev,
"Unable to allocate rx error IRQ for sport\n");
375 static void sport_free_resource(
struct sport_device *sport)
392 dev_err(dev,
"Unable to allocate memory for sport device\n");
397 ret = sport_get_resource(sport);
403 ret = sport_request_resource(sport);
409 dev_dbg(dev,
"SPORT create success\n");
422 sport_free_resource(sport);