Lines Matching refs:mgr
36 static int retrieve_msg_frame(struct mixart_mgr *mgr, u32 *msg_frame) in retrieve_msg_frame() argument
41 tailptr = readl_be(MIXART_MEM(mgr, MSG_OUTBOUND_POST_TAIL)); in retrieve_msg_frame()
42 headptr = readl_be(MIXART_MEM(mgr, MSG_OUTBOUND_POST_HEAD)); in retrieve_msg_frame()
52 *msg_frame = readl_be(MIXART_MEM(mgr, tailptr)); in retrieve_msg_frame()
58 writel_be(tailptr, MIXART_MEM(mgr, MSG_OUTBOUND_POST_TAIL)); in retrieve_msg_frame()
63 static int get_msg(struct mixart_mgr *mgr, struct mixart_msg *resp, in get_msg() argument
76 …size = readl_be(MIXART_MEM(mgr, msg_frame_address)); /* size of descriptor +… in get_msg()
77 resp->message_id = readl_be(MIXART_MEM(mgr, msg_frame_address + 4)); /* dwMessageID */ in get_msg()
78 resp->uid.object_id = readl_be(MIXART_MEM(mgr, msg_frame_address + 8)); /* uidDest */ in get_msg()
79 resp->uid.desc = readl_be(MIXART_MEM(mgr, msg_frame_address + 12)); /* */ in get_msg()
83 dev_err(&mgr->pci->dev, in get_msg()
89 memcpy_fromio(resp->data, MIXART_MEM(mgr, msg_frame_address + MSG_HEADER_SIZE ), size); in get_msg()
103 headptr = readl_be(MIXART_MEM(mgr, MSG_OUTBOUND_FREE_HEAD)); in get_msg()
111 writel_be(msg_frame_address, MIXART_MEM(mgr, headptr)); in get_msg()
118 writel_be(headptr, MIXART_MEM(mgr, MSG_OUTBOUND_FREE_HEAD)); in get_msg()
129 static int send_msg( struct mixart_mgr *mgr, in send_msg() argument
143 tailptr = readl_be(MIXART_MEM(mgr, MSG_INBOUND_FREE_TAIL)); in send_msg()
144 headptr = readl_be(MIXART_MEM(mgr, MSG_INBOUND_FREE_HEAD)); in send_msg()
147 dev_err(&mgr->pci->dev, "error: no message frame available\n"); in send_msg()
155 msg_frame_address = readl_be(MIXART_MEM(mgr, tailptr)); in send_msg()
156 writel(0, MIXART_MEM(mgr, tailptr)); /* set address to zero on this fifo position */ in send_msg()
163 writel_be(tailptr, MIXART_MEM(mgr, MSG_INBOUND_FREE_TAIL)); in send_msg()
168 …writel_be( msg->size + MSG_DESCRIPTOR_SIZE, MIXART_MEM(mgr, msg_frame_address) ); /* siz… in send_msg()
169 …writel_be( msg->message_id , MIXART_MEM(mgr, msg_frame_address + 4) ); /* dwM… in send_msg()
170 …writel_be( msg->uid.object_id, MIXART_MEM(mgr, msg_frame_address + 8) ); /* uid… in send_msg()
171 writel_be( msg->uid.desc, MIXART_MEM(mgr, msg_frame_address + 12) ); /* */ in send_msg()
172 …writel_be( MSG_DESCRIPTOR_SIZE, MIXART_MEM(mgr, msg_frame_address + 16) ); /* Siz… in send_msg()
173 …writel_be( MSG_DESCRIPTOR_SIZE, MIXART_MEM(mgr, msg_frame_address + 20) ); /* Off… in send_msg()
174 …writel_be( msg->size, MIXART_MEM(mgr, msg_frame_address + 24) ); /* Siz… in send_msg()
175 …writel_be( MSG_DESCRIPTOR_SIZE, MIXART_MEM(mgr, msg_frame_address + 28) ); /* Off… in send_msg()
176 …writel_be( 0, MIXART_MEM(mgr, msg_frame_address + 32) ); /* Siz… in send_msg()
177 …writel_be( MSG_DESCRIPTOR_SIZE + max_answersize, MIXART_MEM(mgr, msg_frame_address + 36) ); /* dwE… in send_msg()
181 writel_be( *(u32*)(msg->data + i), MIXART_MEM(mgr, MSG_HEADER_SIZE + msg_frame_address + i) ); in send_msg()
187 mgr->pending_event = *msg_event; in send_msg()
191 mgr->pending_event = msg_frame_address; in send_msg()
202 headptr = readl_be(MIXART_MEM(mgr, MSG_INBOUND_POST_HEAD)); in send_msg()
208 writel_be(msg_frame_address, MIXART_MEM(mgr, headptr)); in send_msg()
215 writel_be(headptr, MIXART_MEM(mgr, MSG_INBOUND_POST_HEAD)); in send_msg()
221 int snd_mixart_send_msg(struct mixart_mgr *mgr, struct mixart_msg *request, int max_resp_size, void… in snd_mixart_send_msg() argument
231 mutex_lock(&mgr->msg_lock); in snd_mixart_send_msg()
233 err = send_msg(mgr, request, max_resp_size, 1, &msg_frame); /* send and mark the answer pending */ in snd_mixart_send_msg()
235 mutex_unlock(&mgr->msg_lock); in snd_mixart_send_msg()
240 add_wait_queue(&mgr->msg_sleep, &wait); in snd_mixart_send_msg()
241 mutex_unlock(&mgr->msg_lock); in snd_mixart_send_msg()
243 remove_wait_queue(&mgr->msg_sleep, &wait); in snd_mixart_send_msg()
247 dev_err(&mgr->pci->dev, in snd_mixart_send_msg()
258 mutex_lock(&mgr->msg_lock); in snd_mixart_send_msg()
259 err = get_msg(mgr, &resp, msg_frame); in snd_mixart_send_msg()
260 mutex_unlock(&mgr->msg_lock); in snd_mixart_send_msg()
263 dev_err(&mgr->pci->dev, "RESPONSE ERROR!\n"); in snd_mixart_send_msg()
269 int snd_mixart_send_msg_wait_notif(struct mixart_mgr *mgr, in snd_mixart_send_msg_wait_notif() argument
285 mutex_lock(&mgr->msg_lock); in snd_mixart_send_msg_wait_notif()
287 …err = send_msg(mgr, request, MSG_DEFAULT_SIZE, 1, ¬if_event); /* send and mark the notificatio… in snd_mixart_send_msg_wait_notif()
289 mutex_unlock(&mgr->msg_lock); in snd_mixart_send_msg_wait_notif()
294 add_wait_queue(&mgr->msg_sleep, &wait); in snd_mixart_send_msg_wait_notif()
295 mutex_unlock(&mgr->msg_lock); in snd_mixart_send_msg_wait_notif()
297 remove_wait_queue(&mgr->msg_sleep, &wait); in snd_mixart_send_msg_wait_notif()
301 dev_err(&mgr->pci->dev, in snd_mixart_send_msg_wait_notif()
310 int snd_mixart_send_msg_nonblock(struct mixart_mgr *mgr, struct mixart_msg *request) in snd_mixart_send_msg_nonblock() argument
316 mutex_lock(&mgr->msg_lock); in snd_mixart_send_msg_nonblock()
317 err = send_msg(mgr, request, MSG_DEFAULT_SIZE, 0, &message_frame); in snd_mixart_send_msg_nonblock()
318 mutex_unlock(&mgr->msg_lock); in snd_mixart_send_msg_nonblock()
321 atomic_inc(&mgr->msg_processed); in snd_mixart_send_msg_nonblock()
331 static void snd_mixart_process_msg(struct mixart_mgr *mgr) in snd_mixart_process_msg() argument
337 while (mgr->msg_fifo_readptr != mgr->msg_fifo_writeptr) { in snd_mixart_process_msg()
338 msg = mgr->msg_fifo[mgr->msg_fifo_readptr]; in snd_mixart_process_msg()
339 mgr->msg_fifo_readptr++; in snd_mixart_process_msg()
340 mgr->msg_fifo_readptr %= MSG_FIFO_SIZE; in snd_mixart_process_msg()
352 err = get_msg(mgr, &resp, addr); in snd_mixart_process_msg()
354 dev_err(&mgr->pci->dev, in snd_mixart_process_msg()
366 dev_err(&mgr->pci->dev, in snd_mixart_process_msg()
371 dev_dbg(&mgr->pci->dev, in snd_mixart_process_msg()
382 dev_err(&mgr->pci->dev, in snd_mixart_process_msg()
388 atomic_dec(&mgr->msg_processed); in snd_mixart_process_msg()
396 struct mixart_mgr *mgr = dev_id; in snd_mixart_interrupt() local
399 it_reg = readl_le(MIXART_REG(mgr, MIXART_PCI_OMISR_OFFSET)); in snd_mixart_interrupt()
406 writel_le(MIXART_HOST_ALL_INTERRUPT_MASKED, MIXART_REG(mgr, MIXART_PCI_OMIMR_OFFSET)); in snd_mixart_interrupt()
409 it_reg = readl(MIXART_REG(mgr, MIXART_PCI_ODBR_OFFSET)); in snd_mixart_interrupt()
410 writel(it_reg, MIXART_REG(mgr, MIXART_PCI_ODBR_OFFSET)); in snd_mixart_interrupt()
413 writel_le( MIXART_OIDI, MIXART_REG(mgr, MIXART_PCI_OMISR_OFFSET) ); in snd_mixart_interrupt()
420 struct mixart_mgr *mgr = dev_id; in snd_mixart_threaded_irq() local
425 mutex_lock(&mgr->lock); in snd_mixart_threaded_irq()
427 while (retrieve_msg_frame(mgr, &msg)) { in snd_mixart_threaded_irq()
434 err = get_msg(mgr, &resp, msg & ~MSG_TYPE_MASK); in snd_mixart_threaded_irq()
436 dev_err(&mgr->pci->dev, in snd_mixart_threaded_irq()
455 struct snd_mixart *chip = mgr->chip[chip_number]; in snd_mixart_threaded_irq()
458 …if ((chip_number >= mgr->num_cards) || (pcm_number >= MIXART_PCM_TOTAL) || (sub_number >= MIXART_P… in snd_mixart_threaded_irq()
459 dev_err(&mgr->pci->dev, in snd_mixart_threaded_irq()
494 mutex_unlock(&mgr->lock); in snd_mixart_threaded_irq()
496 mutex_lock(&mgr->lock); in snd_mixart_threaded_irq()
512 dev_dbg(&mgr->pci->dev, in snd_mixart_threaded_irq()
519 dev_dbg(&mgr->pci->dev, "command %x not handled\n", in snd_mixart_threaded_irq()
526 dev_err(&mgr->pci->dev, in snd_mixart_threaded_irq()
532 mutex_lock(&mgr->msg_lock); in snd_mixart_threaded_irq()
533 if( (msg & ~MSG_TYPE_MASK) == mgr->pending_event ) { in snd_mixart_threaded_irq()
534 wake_up(&mgr->msg_sleep); in snd_mixart_threaded_irq()
535 mgr->pending_event = 0; in snd_mixart_threaded_irq()
539 mgr->msg_fifo[mgr->msg_fifo_writeptr] = msg; in snd_mixart_threaded_irq()
540 mgr->msg_fifo_writeptr++; in snd_mixart_threaded_irq()
541 mgr->msg_fifo_writeptr %= MSG_FIFO_SIZE; in snd_mixart_threaded_irq()
542 snd_mixart_process_msg(mgr); in snd_mixart_threaded_irq()
544 mutex_unlock(&mgr->msg_lock); in snd_mixart_threaded_irq()
548 dev_dbg(&mgr->pci->dev, in snd_mixart_threaded_irq()
556 writel_le( MIXART_ALLOW_OUTBOUND_DOORBELL, MIXART_REG( mgr, MIXART_PCI_OMIMR_OFFSET)); in snd_mixart_threaded_irq()
558 mutex_unlock(&mgr->lock); in snd_mixart_threaded_irq()
564 void snd_mixart_init_mailbox(struct mixart_mgr *mgr) in snd_mixart_init_mailbox() argument
566 writel( 0, MIXART_MEM( mgr, MSG_HOST_RSC_PROTECTION ) ); in snd_mixart_init_mailbox()
567 writel( 0, MIXART_MEM( mgr, MSG_AGENT_RSC_PROTECTION ) ); in snd_mixart_init_mailbox()
570 if(mgr->irq >= 0) { in snd_mixart_init_mailbox()
571 writel_le( MIXART_ALLOW_OUTBOUND_DOORBELL, MIXART_REG( mgr, MIXART_PCI_OMIMR_OFFSET)); in snd_mixart_init_mailbox()
576 void snd_mixart_exit_mailbox(struct mixart_mgr *mgr) in snd_mixart_exit_mailbox() argument
579 writel_le( MIXART_HOST_ALL_INTERRUPT_MASKED, MIXART_REG( mgr, MIXART_PCI_OMIMR_OFFSET)); in snd_mixart_exit_mailbox()
583 void snd_mixart_reset_board(struct mixart_mgr *mgr) in snd_mixart_reset_board() argument
586 writel_be( 1, MIXART_REG(mgr, MIXART_BA1_BRUTAL_RESET_OFFSET) ); in snd_mixart_reset_board()