1 /*
2 * Driver for Digigram miXart soundcards
3 *
4 * low level interface with interrupt handling and mail box implementation
5 *
6 * Copyright (c) 2003 by Digigram <alsa@digigram.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
23 #include <linux/interrupt.h>
24 #include <linux/mutex.h>
25 #include <linux/pci.h>
26 #include <linux/io.h>
27
28 #include <sound/core.h>
29 #include "mixart.h"
30 #include "mixart_hwdep.h"
31 #include "mixart_core.h"
32
33
34 #define MSG_TIMEOUT_JIFFIES (400 * HZ) / 1000 /* 400 ms */
35
36 #define MSG_DESCRIPTOR_SIZE 0x24
37 #define MSG_HEADER_SIZE (MSG_DESCRIPTOR_SIZE + 4)
38
39 #define MSG_DEFAULT_SIZE 512
40
41 #define MSG_TYPE_MASK 0x00000003 /* mask for following types */
42 #define MSG_TYPE_NOTIFY 0 /* embedded -> driver (only notification, do not get_msg() !) */
43 #define MSG_TYPE_COMMAND 1 /* driver <-> embedded (a command has no answer) */
44 #define MSG_TYPE_REQUEST 2 /* driver -> embedded (request will get an answer back) */
45 #define MSG_TYPE_ANSWER 3 /* embedded -> driver */
46 #define MSG_CANCEL_NOTIFY_MASK 0x80000000 /* this bit is set for a notification that has been canceled */
47
48
retrieve_msg_frame(struct mixart_mgr * mgr,u32 * msg_frame)49 static int retrieve_msg_frame(struct mixart_mgr *mgr, u32 *msg_frame)
50 {
51 /* read the message frame fifo */
52 u32 headptr, tailptr;
53
54 tailptr = readl_be(MIXART_MEM(mgr, MSG_OUTBOUND_POST_TAIL));
55 headptr = readl_be(MIXART_MEM(mgr, MSG_OUTBOUND_POST_HEAD));
56
57 if (tailptr == headptr)
58 return 0; /* no message posted */
59
60 if (tailptr < MSG_OUTBOUND_POST_STACK)
61 return 0; /* error */
62 if (tailptr >= MSG_OUTBOUND_POST_STACK + MSG_BOUND_STACK_SIZE)
63 return 0; /* error */
64
65 *msg_frame = readl_be(MIXART_MEM(mgr, tailptr));
66
67 /* increment the tail index */
68 tailptr += 4;
69 if( tailptr >= (MSG_OUTBOUND_POST_STACK+MSG_BOUND_STACK_SIZE) )
70 tailptr = MSG_OUTBOUND_POST_STACK;
71 writel_be(tailptr, MIXART_MEM(mgr, MSG_OUTBOUND_POST_TAIL));
72
73 return 1;
74 }
75
get_msg(struct mixart_mgr * mgr,struct mixart_msg * resp,u32 msg_frame_address)76 static int get_msg(struct mixart_mgr *mgr, struct mixart_msg *resp,
77 u32 msg_frame_address )
78 {
79 u32 headptr;
80 u32 size;
81 int err;
82 #ifndef __BIG_ENDIAN
83 unsigned int i;
84 #endif
85
86 err = 0;
87
88 /* copy message descriptor from miXart to driver */
89 size = readl_be(MIXART_MEM(mgr, msg_frame_address)); /* size of descriptor + response */
90 resp->message_id = readl_be(MIXART_MEM(mgr, msg_frame_address + 4)); /* dwMessageID */
91 resp->uid.object_id = readl_be(MIXART_MEM(mgr, msg_frame_address + 8)); /* uidDest */
92 resp->uid.desc = readl_be(MIXART_MEM(mgr, msg_frame_address + 12)); /* */
93
94 if( (size < MSG_DESCRIPTOR_SIZE) || (resp->size < (size - MSG_DESCRIPTOR_SIZE))) {
95 err = -EINVAL;
96 dev_err(&mgr->pci->dev,
97 "problem with response size = %d\n", size);
98 goto _clean_exit;
99 }
100 size -= MSG_DESCRIPTOR_SIZE;
101
102 memcpy_fromio(resp->data, MIXART_MEM(mgr, msg_frame_address + MSG_HEADER_SIZE ), size);
103 resp->size = size;
104
105 /* swap if necessary */
106 #ifndef __BIG_ENDIAN
107 size /= 4; /* u32 size */
108 for(i=0; i < size; i++) {
109 ((u32*)resp->data)[i] = be32_to_cpu(((u32*)resp->data)[i]);
110 }
111 #endif
112
113 /*
114 * free message frame address
115 */
116 headptr = readl_be(MIXART_MEM(mgr, MSG_OUTBOUND_FREE_HEAD));
117
118 if( (headptr < MSG_OUTBOUND_FREE_STACK) || ( headptr >= (MSG_OUTBOUND_FREE_STACK+MSG_BOUND_STACK_SIZE))) {
119 err = -EINVAL;
120 goto _clean_exit;
121 }
122
123 /* give address back to outbound fifo */
124 writel_be(msg_frame_address, MIXART_MEM(mgr, headptr));
125
126 /* increment the outbound free head */
127 headptr += 4;
128 if( headptr >= (MSG_OUTBOUND_FREE_STACK+MSG_BOUND_STACK_SIZE) )
129 headptr = MSG_OUTBOUND_FREE_STACK;
130
131 writel_be(headptr, MIXART_MEM(mgr, MSG_OUTBOUND_FREE_HEAD));
132
133 _clean_exit:
134 return err;
135 }
136
137
138 /*
139 * send a message to miXart. return: the msg_frame used for this message
140 */
141 /* call with mgr->msg_lock held! */
send_msg(struct mixart_mgr * mgr,struct mixart_msg * msg,int max_answersize,int mark_pending,u32 * msg_event)142 static int send_msg( struct mixart_mgr *mgr,
143 struct mixart_msg *msg,
144 int max_answersize,
145 int mark_pending,
146 u32 *msg_event)
147 {
148 u32 headptr, tailptr;
149 u32 msg_frame_address;
150 int i;
151
152 if (snd_BUG_ON(msg->size % 4))
153 return -EINVAL;
154
155 /* get message frame address */
156 tailptr = readl_be(MIXART_MEM(mgr, MSG_INBOUND_FREE_TAIL));
157 headptr = readl_be(MIXART_MEM(mgr, MSG_INBOUND_FREE_HEAD));
158
159 if (tailptr == headptr) {
160 dev_err(&mgr->pci->dev, "error: no message frame available\n");
161 return -EBUSY;
162 }
163
164 if( (tailptr < MSG_INBOUND_FREE_STACK) || (tailptr >= (MSG_INBOUND_FREE_STACK+MSG_BOUND_STACK_SIZE))) {
165 return -EINVAL;
166 }
167
168 msg_frame_address = readl_be(MIXART_MEM(mgr, tailptr));
169 writel(0, MIXART_MEM(mgr, tailptr)); /* set address to zero on this fifo position */
170
171 /* increment the inbound free tail */
172 tailptr += 4;
173 if( tailptr >= (MSG_INBOUND_FREE_STACK+MSG_BOUND_STACK_SIZE) )
174 tailptr = MSG_INBOUND_FREE_STACK;
175
176 writel_be(tailptr, MIXART_MEM(mgr, MSG_INBOUND_FREE_TAIL));
177
178 /* TODO : use memcpy_toio() with intermediate buffer to copy the message */
179
180 /* copy message descriptor to card memory */
181 writel_be( msg->size + MSG_DESCRIPTOR_SIZE, MIXART_MEM(mgr, msg_frame_address) ); /* size of descriptor + request */
182 writel_be( msg->message_id , MIXART_MEM(mgr, msg_frame_address + 4) ); /* dwMessageID */
183 writel_be( msg->uid.object_id, MIXART_MEM(mgr, msg_frame_address + 8) ); /* uidDest */
184 writel_be( msg->uid.desc, MIXART_MEM(mgr, msg_frame_address + 12) ); /* */
185 writel_be( MSG_DESCRIPTOR_SIZE, MIXART_MEM(mgr, msg_frame_address + 16) ); /* SizeHeader */
186 writel_be( MSG_DESCRIPTOR_SIZE, MIXART_MEM(mgr, msg_frame_address + 20) ); /* OffsetDLL_T16 */
187 writel_be( msg->size, MIXART_MEM(mgr, msg_frame_address + 24) ); /* SizeDLL_T16 */
188 writel_be( MSG_DESCRIPTOR_SIZE, MIXART_MEM(mgr, msg_frame_address + 28) ); /* OffsetDLL_DRV */
189 writel_be( 0, MIXART_MEM(mgr, msg_frame_address + 32) ); /* SizeDLL_DRV */
190 writel_be( MSG_DESCRIPTOR_SIZE + max_answersize, MIXART_MEM(mgr, msg_frame_address + 36) ); /* dwExpectedAnswerSize */
191
192 /* copy message data to card memory */
193 for( i=0; i < msg->size; i+=4 ) {
194 writel_be( *(u32*)(msg->data + i), MIXART_MEM(mgr, MSG_HEADER_SIZE + msg_frame_address + i) );
195 }
196
197 if( mark_pending ) {
198 if( *msg_event ) {
199 /* the pending event is the notification we wait for ! */
200 mgr->pending_event = *msg_event;
201 }
202 else {
203 /* the pending event is the answer we wait for (same address than the request)! */
204 mgr->pending_event = msg_frame_address;
205
206 /* copy address back to caller */
207 *msg_event = msg_frame_address;
208 }
209 }
210
211 /* mark the frame as a request (will have an answer) */
212 msg_frame_address |= MSG_TYPE_REQUEST;
213
214 /* post the frame */
215 headptr = readl_be(MIXART_MEM(mgr, MSG_INBOUND_POST_HEAD));
216
217 if( (headptr < MSG_INBOUND_POST_STACK) || (headptr >= (MSG_INBOUND_POST_STACK+MSG_BOUND_STACK_SIZE))) {
218 return -EINVAL;
219 }
220
221 writel_be(msg_frame_address, MIXART_MEM(mgr, headptr));
222
223 /* increment the inbound post head */
224 headptr += 4;
225 if( headptr >= (MSG_INBOUND_POST_STACK+MSG_BOUND_STACK_SIZE) )
226 headptr = MSG_INBOUND_POST_STACK;
227
228 writel_be(headptr, MIXART_MEM(mgr, MSG_INBOUND_POST_HEAD));
229
230 return 0;
231 }
232
233
snd_mixart_send_msg(struct mixart_mgr * mgr,struct mixart_msg * request,int max_resp_size,void * resp_data)234 int snd_mixart_send_msg(struct mixart_mgr *mgr, struct mixart_msg *request, int max_resp_size, void *resp_data)
235 {
236 struct mixart_msg resp;
237 u32 msg_frame = 0; /* set to 0, so it's no notification to wait for, but the answer */
238 int err;
239 wait_queue_t wait;
240 long timeout;
241
242 init_waitqueue_entry(&wait, current);
243
244 mutex_lock(&mgr->msg_lock);
245 /* send the message */
246 err = send_msg(mgr, request, max_resp_size, 1, &msg_frame); /* send and mark the answer pending */
247 if (err) {
248 mutex_unlock(&mgr->msg_lock);
249 return err;
250 }
251
252 set_current_state(TASK_UNINTERRUPTIBLE);
253 add_wait_queue(&mgr->msg_sleep, &wait);
254 mutex_unlock(&mgr->msg_lock);
255 timeout = schedule_timeout(MSG_TIMEOUT_JIFFIES);
256 remove_wait_queue(&mgr->msg_sleep, &wait);
257
258 if (! timeout) {
259 /* error - no ack */
260 dev_err(&mgr->pci->dev,
261 "error: no response on msg %x\n", msg_frame);
262 return -EIO;
263 }
264
265 /* retrieve the answer into the same struct mixart_msg */
266 resp.message_id = 0;
267 resp.uid = (struct mixart_uid){0,0};
268 resp.data = resp_data;
269 resp.size = max_resp_size;
270
271 mutex_lock(&mgr->msg_lock);
272 err = get_msg(mgr, &resp, msg_frame);
273 mutex_unlock(&mgr->msg_lock);
274
275 if( request->message_id != resp.message_id )
276 dev_err(&mgr->pci->dev, "RESPONSE ERROR!\n");
277
278 return err;
279 }
280
281
snd_mixart_send_msg_wait_notif(struct mixart_mgr * mgr,struct mixart_msg * request,u32 notif_event)282 int snd_mixart_send_msg_wait_notif(struct mixart_mgr *mgr,
283 struct mixart_msg *request, u32 notif_event)
284 {
285 int err;
286 wait_queue_t wait;
287 long timeout;
288
289 if (snd_BUG_ON(!notif_event))
290 return -EINVAL;
291 if (snd_BUG_ON((notif_event & MSG_TYPE_MASK) != MSG_TYPE_NOTIFY))
292 return -EINVAL;
293 if (snd_BUG_ON(notif_event & MSG_CANCEL_NOTIFY_MASK))
294 return -EINVAL;
295
296 init_waitqueue_entry(&wait, current);
297
298 mutex_lock(&mgr->msg_lock);
299 /* send the message */
300 err = send_msg(mgr, request, MSG_DEFAULT_SIZE, 1, ¬if_event); /* send and mark the notification event pending */
301 if(err) {
302 mutex_unlock(&mgr->msg_lock);
303 return err;
304 }
305
306 set_current_state(TASK_UNINTERRUPTIBLE);
307 add_wait_queue(&mgr->msg_sleep, &wait);
308 mutex_unlock(&mgr->msg_lock);
309 timeout = schedule_timeout(MSG_TIMEOUT_JIFFIES);
310 remove_wait_queue(&mgr->msg_sleep, &wait);
311
312 if (! timeout) {
313 /* error - no ack */
314 dev_err(&mgr->pci->dev,
315 "error: notification %x not received\n", notif_event);
316 return -EIO;
317 }
318
319 return 0;
320 }
321
322
snd_mixart_send_msg_nonblock(struct mixart_mgr * mgr,struct mixart_msg * request)323 int snd_mixart_send_msg_nonblock(struct mixart_mgr *mgr, struct mixart_msg *request)
324 {
325 u32 message_frame;
326 int err;
327
328 /* just send the message (do not mark it as a pending one) */
329 mutex_lock(&mgr->msg_lock);
330 err = send_msg(mgr, request, MSG_DEFAULT_SIZE, 0, &message_frame);
331 mutex_unlock(&mgr->msg_lock);
332
333 /* the answer will be handled by snd_struct mixart_msgasklet() */
334 atomic_inc(&mgr->msg_processed);
335
336 return err;
337 }
338
339
340 /* common buffer of interrupt to send/receive messages */
341 static u32 mixart_msg_data[MSG_DEFAULT_SIZE / 4];
342
343
snd_mixart_process_msg(struct mixart_mgr * mgr)344 static void snd_mixart_process_msg(struct mixart_mgr *mgr)
345 {
346 struct mixart_msg resp;
347 u32 msg, addr, type;
348 int err;
349
350 while (mgr->msg_fifo_readptr != mgr->msg_fifo_writeptr) {
351 msg = mgr->msg_fifo[mgr->msg_fifo_readptr];
352 mgr->msg_fifo_readptr++;
353 mgr->msg_fifo_readptr %= MSG_FIFO_SIZE;
354
355 /* process the message ... */
356 addr = msg & ~MSG_TYPE_MASK;
357 type = msg & MSG_TYPE_MASK;
358
359 switch (type) {
360 case MSG_TYPE_ANSWER:
361 /* answer to a message on that we did not wait for (send_msg_nonblock) */
362 resp.message_id = 0;
363 resp.data = mixart_msg_data;
364 resp.size = sizeof(mixart_msg_data);
365 err = get_msg(mgr, &resp, addr);
366 if( err < 0 ) {
367 dev_err(&mgr->pci->dev,
368 "error(%d) reading mf %x\n",
369 err, msg);
370 break;
371 }
372
373 switch(resp.message_id) {
374 case MSG_STREAM_START_INPUT_STAGE_PACKET:
375 case MSG_STREAM_START_OUTPUT_STAGE_PACKET:
376 case MSG_STREAM_STOP_INPUT_STAGE_PACKET:
377 case MSG_STREAM_STOP_OUTPUT_STAGE_PACKET:
378 if(mixart_msg_data[0])
379 dev_err(&mgr->pci->dev,
380 "error MSG_STREAM_ST***_***PUT_STAGE_PACKET status=%x\n",
381 mixart_msg_data[0]);
382 break;
383 default:
384 dev_dbg(&mgr->pci->dev,
385 "received mf(%x) : msg_id(%x) uid(%x, %x) size(%zd)\n",
386 msg, resp.message_id, resp.uid.object_id, resp.uid.desc, resp.size);
387 break;
388 }
389 break;
390 case MSG_TYPE_NOTIFY:
391 /* msg contains no address ! do not get_msg() ! */
392 case MSG_TYPE_COMMAND:
393 /* get_msg() necessary */
394 default:
395 dev_err(&mgr->pci->dev,
396 "doesn't know what to do with message %x\n",
397 msg);
398 } /* switch type */
399
400 /* decrement counter */
401 atomic_dec(&mgr->msg_processed);
402
403 } /* while there is a msg in fifo */
404 }
405
406
snd_mixart_interrupt(int irq,void * dev_id)407 irqreturn_t snd_mixart_interrupt(int irq, void *dev_id)
408 {
409 struct mixart_mgr *mgr = dev_id;
410 u32 it_reg;
411
412 it_reg = readl_le(MIXART_REG(mgr, MIXART_PCI_OMISR_OFFSET));
413 if( !(it_reg & MIXART_OIDI) ) {
414 /* this device did not cause the interrupt */
415 return IRQ_NONE;
416 }
417
418 /* mask all interrupts */
419 writel_le(MIXART_HOST_ALL_INTERRUPT_MASKED, MIXART_REG(mgr, MIXART_PCI_OMIMR_OFFSET));
420
421 /* outdoorbell register clear */
422 it_reg = readl(MIXART_REG(mgr, MIXART_PCI_ODBR_OFFSET));
423 writel(it_reg, MIXART_REG(mgr, MIXART_PCI_ODBR_OFFSET));
424
425 /* clear interrupt */
426 writel_le( MIXART_OIDI, MIXART_REG(mgr, MIXART_PCI_OMISR_OFFSET) );
427
428 return IRQ_WAKE_THREAD;
429 }
430
snd_mixart_threaded_irq(int irq,void * dev_id)431 irqreturn_t snd_mixart_threaded_irq(int irq, void *dev_id)
432 {
433 struct mixart_mgr *mgr = dev_id;
434 int err;
435 struct mixart_msg resp;
436 u32 msg;
437
438 mutex_lock(&mgr->lock);
439 /* process interrupt */
440 while (retrieve_msg_frame(mgr, &msg)) {
441
442 switch (msg & MSG_TYPE_MASK) {
443 case MSG_TYPE_COMMAND:
444 resp.message_id = 0;
445 resp.data = mixart_msg_data;
446 resp.size = sizeof(mixart_msg_data);
447 err = get_msg(mgr, &resp, msg & ~MSG_TYPE_MASK);
448 if( err < 0 ) {
449 dev_err(&mgr->pci->dev,
450 "interrupt: error(%d) reading mf %x\n",
451 err, msg);
452 break;
453 }
454
455 if(resp.message_id == MSG_SERVICES_TIMER_NOTIFY) {
456 int i;
457 struct mixart_timer_notify *notify;
458 notify = (struct mixart_timer_notify *)mixart_msg_data;
459
460 for(i=0; i<notify->stream_count; i++) {
461
462 u32 buffer_id = notify->streams[i].buffer_id;
463 unsigned int chip_number = (buffer_id & MIXART_NOTIFY_CARD_MASK) >> MIXART_NOTIFY_CARD_OFFSET; /* card0 to 3 */
464 unsigned int pcm_number = (buffer_id & MIXART_NOTIFY_PCM_MASK ) >> MIXART_NOTIFY_PCM_OFFSET; /* pcm0 to 3 */
465 unsigned int sub_number = buffer_id & MIXART_NOTIFY_SUBS_MASK; /* 0 to MIXART_PLAYBACK_STREAMS */
466 unsigned int is_capture = ((buffer_id & MIXART_NOTIFY_CAPT_MASK) != 0); /* playback == 0 / capture == 1 */
467
468 struct snd_mixart *chip = mgr->chip[chip_number];
469 struct mixart_stream *stream;
470
471 if ((chip_number >= mgr->num_cards) || (pcm_number >= MIXART_PCM_TOTAL) || (sub_number >= MIXART_PLAYBACK_STREAMS)) {
472 dev_err(&mgr->pci->dev,
473 "error MSG_SERVICES_TIMER_NOTIFY buffer_id (%x) pos(%d)\n",
474 buffer_id, notify->streams[i].sample_pos_low_part);
475 break;
476 }
477
478 if (is_capture)
479 stream = &chip->capture_stream[pcm_number];
480 else
481 stream = &chip->playback_stream[pcm_number][sub_number];
482
483 if (stream->substream && (stream->status == MIXART_STREAM_STATUS_RUNNING)) {
484 struct snd_pcm_runtime *runtime = stream->substream->runtime;
485 int elapsed = 0;
486 u64 sample_count = ((u64)notify->streams[i].sample_pos_high_part) << 32;
487 sample_count |= notify->streams[i].sample_pos_low_part;
488
489 while (1) {
490 u64 new_elapse_pos = stream->abs_period_elapsed + runtime->period_size;
491
492 if (new_elapse_pos > sample_count) {
493 break; /* while */
494 }
495 else {
496 elapsed = 1;
497 stream->buf_periods++;
498 if (stream->buf_periods >= runtime->periods)
499 stream->buf_periods = 0;
500
501 stream->abs_period_elapsed = new_elapse_pos;
502 }
503 }
504 stream->buf_period_frag = (u32)( sample_count - stream->abs_period_elapsed );
505
506 if(elapsed) {
507 mutex_unlock(&mgr->lock);
508 snd_pcm_period_elapsed(stream->substream);
509 mutex_lock(&mgr->lock);
510 }
511 }
512 }
513 break;
514 }
515 if(resp.message_id == MSG_SERVICES_REPORT_TRACES) {
516 if(resp.size > 1) {
517 #ifndef __BIG_ENDIAN
518 /* Traces are text: the swapped msg_data has to be swapped back ! */
519 int i;
520 for(i=0; i<(resp.size/4); i++) {
521 (mixart_msg_data)[i] = cpu_to_be32((mixart_msg_data)[i]);
522 }
523 #endif
524 ((char*)mixart_msg_data)[resp.size - 1] = 0;
525 dev_dbg(&mgr->pci->dev,
526 "MIXART TRACE : %s\n",
527 (char *)mixart_msg_data);
528 }
529 break;
530 }
531
532 dev_dbg(&mgr->pci->dev, "command %x not handled\n",
533 resp.message_id);
534 break;
535
536 case MSG_TYPE_NOTIFY:
537 if(msg & MSG_CANCEL_NOTIFY_MASK) {
538 msg &= ~MSG_CANCEL_NOTIFY_MASK;
539 dev_err(&mgr->pci->dev,
540 "canceled notification %x !\n", msg);
541 }
542 /* no break, continue ! */
543 case MSG_TYPE_ANSWER:
544 /* answer or notification to a message we are waiting for*/
545 mutex_lock(&mgr->msg_lock);
546 if( (msg & ~MSG_TYPE_MASK) == mgr->pending_event ) {
547 wake_up(&mgr->msg_sleep);
548 mgr->pending_event = 0;
549 }
550 /* answer to a message we did't want to wait for */
551 else {
552 mgr->msg_fifo[mgr->msg_fifo_writeptr] = msg;
553 mgr->msg_fifo_writeptr++;
554 mgr->msg_fifo_writeptr %= MSG_FIFO_SIZE;
555 snd_mixart_process_msg(mgr);
556 }
557 mutex_unlock(&mgr->msg_lock);
558 break;
559 case MSG_TYPE_REQUEST:
560 default:
561 dev_dbg(&mgr->pci->dev,
562 "interrupt received request %x\n", msg);
563 /* TODO : are there things to do here ? */
564 break;
565 } /* switch on msg type */
566 } /* while there are msgs */
567
568 /* allow interrupt again */
569 writel_le( MIXART_ALLOW_OUTBOUND_DOORBELL, MIXART_REG( mgr, MIXART_PCI_OMIMR_OFFSET));
570
571 mutex_unlock(&mgr->lock);
572
573 return IRQ_HANDLED;
574 }
575
576
snd_mixart_init_mailbox(struct mixart_mgr * mgr)577 void snd_mixart_init_mailbox(struct mixart_mgr *mgr)
578 {
579 writel( 0, MIXART_MEM( mgr, MSG_HOST_RSC_PROTECTION ) );
580 writel( 0, MIXART_MEM( mgr, MSG_AGENT_RSC_PROTECTION ) );
581
582 /* allow outbound messagebox to generate interrupts */
583 if(mgr->irq >= 0) {
584 writel_le( MIXART_ALLOW_OUTBOUND_DOORBELL, MIXART_REG( mgr, MIXART_PCI_OMIMR_OFFSET));
585 }
586 return;
587 }
588
snd_mixart_exit_mailbox(struct mixart_mgr * mgr)589 void snd_mixart_exit_mailbox(struct mixart_mgr *mgr)
590 {
591 /* no more interrupts on outbound messagebox */
592 writel_le( MIXART_HOST_ALL_INTERRUPT_MASKED, MIXART_REG( mgr, MIXART_PCI_OMIMR_OFFSET));
593 return;
594 }
595
snd_mixart_reset_board(struct mixart_mgr * mgr)596 void snd_mixart_reset_board(struct mixart_mgr *mgr)
597 {
598 /* reset miXart */
599 writel_be( 1, MIXART_REG(mgr, MIXART_BA1_BRUTAL_RESET_OFFSET) );
600 return;
601 }
602