Lines Matching +full:dsp +full:- +full:reset

1 // SPDX-License-Identifier: GPL-2.0-only
5 Copyright (C) 1997-2014 AudioScience Inc. <support@audioscience.com>
11 TMS320C6205 PCI bus mastering DSP,
12 and (except ASI50xx) TI TMS320C6xxx floating point DSP
17 (C) Copyright AudioScience Inc. 1998-2010
61 /* Host-to-DSP Control Register (HDCR) bitfields */
65 /* DSP Page Register (DSPP) bitfields, */
70 * BAR1 maps to non-prefetchable 8 Mbyte memory block
71 * of DSP memory mapped registers (starting at 0x01800000).
80 /* used to control LED (revA) and reset C6713 (revB) */
114 /* a non-NULL handle means there is an HPI allocated buffer */
117 /* non-zero size means a buffer exists, may be external */
224 switch (phm->function) { in subsys_message()
229 phr->error = HPI_ERROR_INVALID_FUNC; in subsys_message()
238 struct hpi_hw_obj *phw = pao->priv; in control_message()
241 switch (phm->function) { in control_message()
243 if (pao->has_control_cache) { in control_message()
244 rmb(); /* make sure we see updates DMAed from DSP */ in control_message()
245 if (hpi_check_control_cache(phw->p_cache, phm, phr)) { in control_message()
247 } else if (phm->u.c.attribute == HPI_METER_PEAK) { in control_message()
253 if (pending_cache_error && !phr->error) in control_message()
254 phr->error = pending_cache_error; in control_message()
261 if (pao->has_control_cache) in control_message()
262 hpi_cmn_control_cache_sync_to_msg(phw->p_cache, phm, in control_message()
266 phr->error = HPI_ERROR_INVALID_FUNC; in control_message()
274 switch (phm->function) { in adapter_message()
288 if (phm->obj_index >= HPI_MAX_STREAMS) { in outstream_message()
289 phr->error = HPI_ERROR_INVALID_OBJ_INDEX; in outstream_message()
292 "on adapter index %d\n", phm->obj_index, in outstream_message()
293 phm->adapter_index); in outstream_message()
297 switch (phm->function) { in outstream_message()
332 if (phm->obj_index >= HPI_MAX_STREAMS) { in instream_message()
333 phr->error = HPI_ERROR_INVALID_OBJ_INDEX; in instream_message()
336 "on adapter index %d\n", phm->obj_index, in instream_message()
337 phm->adapter_index); in instream_message()
341 switch (phm->function) { in instream_message()
374 if (pao && (pao->dsp_crashed >= 10) in _HPI_6205()
375 && (phm->function != HPI_ADAPTER_DEBUG_READ)) { in _HPI_6205()
377 hpi_init_response(phr, phm->object, phm->function, in _HPI_6205()
379 HPI_DEBUG_LOG(WARNING, " %d,%d dsp crashed.\n", phm->object, in _HPI_6205()
380 phm->function); in _HPI_6205()
385 if (phm->function != HPI_SUBSYS_CREATE_ADAPTER) in _HPI_6205()
386 phr->error = HPI_ERROR_PROCESSING_MESSAGE; in _HPI_6205()
389 switch (phm->type) { in _HPI_6205()
391 switch (phm->object) { in _HPI_6205()
419 phr->error = HPI_ERROR_INVALID_TYPE; in _HPI_6205()
428 if (phm->object != HPI_OBJ_SUBSYSTEM) { in HPI_6205()
430 pao = hpi_find_adapter(phm->adapter_index); in HPI_6205()
433 phr->error = HPI_ERROR_INVALID_OBJ_INDEX; in HPI_6205()
440 hpi_init_response(phr, phm->object, phm->function, in HPI_6205()
449 * *** NOTE - you cannot use this function AND the FindAdapters function at the
467 phr->error = HPI_ERROR_MEMORY_ALLOC; in subsys_create_adapter()
471 ao.pci = *phm->u.s.resource.r.pci; in subsys_create_adapter()
476 phr->error = HPI_ERROR_DSP_BOOTLOAD; in subsys_create_adapter()
477 phr->specific_error = err; in subsys_create_adapter()
479 phr->error = err; in subsys_create_adapter()
481 phr->u.s.data = os_error_code; in subsys_create_adapter()
485 phr->u.s.adapter_type = ao.type; in subsys_create_adapter()
486 phr->u.s.adapter_index = ao.index; in subsys_create_adapter()
487 phr->error = 0; in subsys_create_adapter()
490 /** delete an adapter - required by WDM driver */
497 phr->error = HPI_ERROR_INVALID_OBJ_INDEX; in adapter_delete()
500 phw = pao->priv; in adapter_delete()
501 /* reset adapter h/w */ in adapter_delete()
502 /* Reset C6713 #1 */ in adapter_delete()
504 /* reset C6205 */ in adapter_delete()
505 iowrite32(C6205_HDCR_WARMRESET, phw->prHDCR); in adapter_delete()
509 phr->error = 0; in adapter_delete()
518 struct hpi_hw_obj *phw = pao->priv; in create_adapter_obj()
525 pao->dsp_crashed = 0; in create_adapter_obj()
528 phw->flag_outstream_just_reset[i] = 1; in create_adapter_obj()
530 /* The C6205 memory area 1 is 8Mbyte window into DSP registers */ in create_adapter_obj()
531 phw->prHSR = in create_adapter_obj()
532 pao->pci.ap_mem_base[1] + in create_adapter_obj()
533 C6205_BAR1_HSR / sizeof(*pao->pci.ap_mem_base[1]); in create_adapter_obj()
534 phw->prHDCR = in create_adapter_obj()
535 pao->pci.ap_mem_base[1] + in create_adapter_obj()
536 C6205_BAR1_HDCR / sizeof(*pao->pci.ap_mem_base[1]); in create_adapter_obj()
537 phw->prDSPP = in create_adapter_obj()
538 pao->pci.ap_mem_base[1] + in create_adapter_obj()
539 C6205_BAR1_DSPP / sizeof(*pao->pci.ap_mem_base[1]); in create_adapter_obj()
541 pao->has_control_cache = 0; in create_adapter_obj()
543 if (hpios_locked_mem_alloc(&phw->h_locked_mem, in create_adapter_obj()
545 pao->pci.pci_dev)) in create_adapter_obj()
546 phw->p_interface_buffer = NULL; in create_adapter_obj()
547 else if (hpios_locked_mem_get_virt_addr(&phw->h_locked_mem, in create_adapter_obj()
548 (void *)&phw->p_interface_buffer)) in create_adapter_obj()
549 phw->p_interface_buffer = NULL; in create_adapter_obj()
552 phw->p_interface_buffer); in create_adapter_obj()
554 if (phw->p_interface_buffer) { in create_adapter_obj()
555 memset((void *)phw->p_interface_buffer, 0, in create_adapter_obj()
557 phw->p_interface_buffer->dsp_ack = H620_HIF_UNKNOWN; in create_adapter_obj()
562 HPI_DEBUG_LOG(ERROR, "DSP code load failed\n"); in create_adapter_obj()
567 HPI_DEBUG_LOG(INFO, "load DSP code OK\n"); in create_adapter_obj()
570 if (!phw->p_interface_buffer) in create_adapter_obj()
573 interface = phw->p_interface_buffer; in create_adapter_obj()
575 /* make sure the DSP has started ok */ in create_adapter_obj()
577 HPI_DEBUG_LOG(ERROR, "timed out waiting reset state \n"); in create_adapter_obj()
582 * Allocate bus mastering control cache buffer and tell the DSP about it in create_adapter_obj()
584 if (interface->control_cache.number_of_controls) { in create_adapter_obj()
587 err = hpios_locked_mem_alloc(&phw->h_control_cache, in create_adapter_obj()
588 interface->control_cache.size_in_bytes, in create_adapter_obj()
589 pao->pci.pci_dev); in create_adapter_obj()
591 err = hpios_locked_mem_get_virt_addr(&phw-> in create_adapter_obj()
596 interface->control_cache.size_in_bytes); in create_adapter_obj()
598 phw->p_cache = in create_adapter_obj()
599 hpi_alloc_control_cache(interface-> in create_adapter_obj()
601 interface->control_cache.size_in_bytes, in create_adapter_obj()
604 if (!phw->p_cache) in create_adapter_obj()
608 err = hpios_locked_mem_get_phys_addr(&phw-> in create_adapter_obj()
610 interface->control_cache.physical_address32 = in create_adapter_obj()
615 pao->has_control_cache = 1; in create_adapter_obj()
617 if (hpios_locked_mem_valid(&phw->h_control_cache)) in create_adapter_obj()
618 hpios_locked_mem_free(&phw->h_control_cache); in create_adapter_obj()
619 pao->has_control_cache = 0; in create_adapter_obj()
648 pao->type = hr.u.ax.info.adapter_type; in create_adapter_obj()
649 pao->index = hr.u.ax.info.adapter_index; in create_adapter_obj()
657 if (phw->p_cache) in create_adapter_obj()
658 phw->p_cache->adap_idx = pao->index; in create_adapter_obj()
660 HPI_DEBUG_LOG(INFO, "bootload DSP OK\n"); in create_adapter_obj()
662 pao->irq_query_and_clear = adapter_irq_query_and_clear; in create_adapter_obj()
663 pao->instream_host_buffer_status = in create_adapter_obj()
664 phw->p_interface_buffer->instream_host_buffer_status; in create_adapter_obj()
665 pao->outstream_host_buffer_status = in create_adapter_obj()
666 phw->p_interface_buffer->outstream_host_buffer_status; in create_adapter_obj()
677 struct hpi_hw_obj *phw = pao->priv; in delete_adapter_obj()
680 if (hpios_locked_mem_valid(&phw->h_control_cache)) { in delete_adapter_obj()
681 hpios_locked_mem_free(&phw->h_control_cache); in delete_adapter_obj()
682 hpi_free_control_cache(phw->p_cache); in delete_adapter_obj()
685 if (hpios_locked_mem_valid(&phw->h_locked_mem)) { in delete_adapter_obj()
686 hpios_locked_mem_free(&phw->h_locked_mem); in delete_adapter_obj()
687 phw->p_interface_buffer = NULL; in delete_adapter_obj()
691 if (hpios_locked_mem_valid(&phw->instream_host_buffers[i])) { in delete_adapter_obj()
692 hpios_locked_mem_free(&phw->instream_host_buffers[i]); in delete_adapter_obj()
693 /*?phw->InStreamHostBuffers[i] = NULL; */ in delete_adapter_obj()
694 phw->instream_host_buffer_size[i] = 0; in delete_adapter_obj()
698 if (hpios_locked_mem_valid(&phw->outstream_host_buffers[i])) { in delete_adapter_obj()
699 hpios_locked_mem_free(&phw->outstream_host_buffers in delete_adapter_obj()
701 phw->outstream_host_buffer_size[i] = 0; in delete_adapter_obj()
711 struct hpi_hw_obj *phw = pao->priv; in adapter_irq_query_and_clear()
714 hsr = ioread32(phw->prHSR); in adapter_irq_query_and_clear()
716 /* reset the interrupt from the DSP */ in adapter_irq_query_and_clear()
717 iowrite32(C6205_HSR_INTSRC, phw->prHSR); in adapter_irq_query_and_clear()
733 u32 command = phm->u.d.u.buffer.command; in outstream_host_buffer_allocate()
734 struct hpi_hw_obj *phw = pao->priv; in outstream_host_buffer_allocate()
735 struct bus_master_interface *interface = phw->p_interface_buffer; in outstream_host_buffer_allocate()
737 hpi_init_response(phr, phm->object, phm->function, 0); in outstream_host_buffer_allocate()
744 phm->u.d.u.buffer.buffer_size = in outstream_host_buffer_allocate()
745 roundup_pow_of_two(phm->u.d.u.buffer.buffer_size); in outstream_host_buffer_allocate()
748 phr->u.d.u.stream_info.data_available = in outstream_host_buffer_allocate()
749 phw->outstream_host_buffer_size[phm->obj_index]; in outstream_host_buffer_allocate()
750 phr->u.d.u.stream_info.buffer_size = in outstream_host_buffer_allocate()
751 phm->u.d.u.buffer.buffer_size; in outstream_host_buffer_allocate()
753 if (phw->outstream_host_buffer_size[phm->obj_index] == in outstream_host_buffer_allocate()
754 phm->u.d.u.buffer.buffer_size) { in outstream_host_buffer_allocate()
759 if (hpios_locked_mem_valid(&phw->outstream_host_buffers[phm-> in outstream_host_buffer_allocate()
761 hpios_locked_mem_free(&phw->outstream_host_buffers in outstream_host_buffer_allocate()
762 [phm->obj_index]); in outstream_host_buffer_allocate()
764 err = hpios_locked_mem_alloc(&phw->outstream_host_buffers in outstream_host_buffer_allocate()
765 [phm->obj_index], phm->u.d.u.buffer.buffer_size, in outstream_host_buffer_allocate()
766 pao->pci.pci_dev); in outstream_host_buffer_allocate()
769 phr->error = HPI_ERROR_INVALID_DATASIZE; in outstream_host_buffer_allocate()
770 phw->outstream_host_buffer_size[phm->obj_index] = 0; in outstream_host_buffer_allocate()
775 (&phw->outstream_host_buffers[phm->obj_index], in outstream_host_buffer_allocate()
776 &phm->u.d.u.buffer.pci_address); in outstream_host_buffer_allocate()
781 phr->u.d.u.stream_info.auxiliary_data_available = in outstream_host_buffer_allocate()
782 phm->u.d.u.buffer.pci_address; in outstream_host_buffer_allocate()
785 hpios_locked_mem_free(&phw->outstream_host_buffers in outstream_host_buffer_allocate()
786 [phm->obj_index]); in outstream_host_buffer_allocate()
787 phw->outstream_host_buffer_size[phm->obj_index] = 0; in outstream_host_buffer_allocate()
788 phr->error = HPI_ERROR_MEMORY_ALLOC; in outstream_host_buffer_allocate()
795 /* GRANT phase. Set up the BBM status, tell the DSP about in outstream_host_buffer_allocate()
800 if (phm->u.d.u.buffer.buffer_size & (phm->u.d.u.buffer. in outstream_host_buffer_allocate()
801 buffer_size - 1)) { in outstream_host_buffer_allocate()
804 phm->u.d.u.buffer.buffer_size); in outstream_host_buffer_allocate()
805 phr->error = HPI_ERROR_INVALID_DATASIZE; in outstream_host_buffer_allocate()
808 phw->outstream_host_buffer_size[phm->obj_index] = in outstream_host_buffer_allocate()
809 phm->u.d.u.buffer.buffer_size; in outstream_host_buffer_allocate()
810 status = &interface->outstream_host_buffer_status[phm-> in outstream_host_buffer_allocate()
812 status->samples_processed = 0; in outstream_host_buffer_allocate()
813 status->stream_state = HPI_STATE_STOPPED; in outstream_host_buffer_allocate()
814 status->dsp_index = 0; in outstream_host_buffer_allocate()
815 status->host_index = status->dsp_index; in outstream_host_buffer_allocate()
816 status->size_in_bytes = phm->u.d.u.buffer.buffer_size; in outstream_host_buffer_allocate()
817 status->auxiliary_data_available = 0; in outstream_host_buffer_allocate()
821 if (phr->error in outstream_host_buffer_allocate()
822 && hpios_locked_mem_valid(&phw-> in outstream_host_buffer_allocate()
823 outstream_host_buffers[phm->obj_index])) { in outstream_host_buffer_allocate()
824 hpios_locked_mem_free(&phw->outstream_host_buffers in outstream_host_buffer_allocate()
825 [phm->obj_index]); in outstream_host_buffer_allocate()
826 phw->outstream_host_buffer_size[phm->obj_index] = 0; in outstream_host_buffer_allocate()
834 struct hpi_hw_obj *phw = pao->priv; in outstream_host_buffer_get_info()
835 struct bus_master_interface *interface = phw->p_interface_buffer; in outstream_host_buffer_get_info()
839 if (hpios_locked_mem_valid(&phw->outstream_host_buffers[phm-> in outstream_host_buffer_get_info()
841 if (hpios_locked_mem_get_virt_addr(&phw-> in outstream_host_buffer_get_info()
842 outstream_host_buffers[phm->obj_index], in outstream_host_buffer_get_info()
844 phr->error = HPI_ERROR_INVALID_OPERATION; in outstream_host_buffer_get_info()
847 status = &interface->outstream_host_buffer_status[phm-> in outstream_host_buffer_get_info()
851 phr->u.d.u.hostbuffer_info.p_buffer = p_bbm_data; in outstream_host_buffer_get_info()
852 phr->u.d.u.hostbuffer_info.p_status = status; in outstream_host_buffer_get_info()
863 struct hpi_hw_obj *phw = pao->priv; in outstream_host_buffer_free()
864 u32 command = phm->u.d.u.buffer.command; in outstream_host_buffer_free()
866 if (phw->outstream_host_buffer_size[phm->obj_index]) { in outstream_host_buffer_free()
869 phw->outstream_host_buffer_size[phm->obj_index] = 0; in outstream_host_buffer_free()
875 hpios_locked_mem_free(&phw->outstream_host_buffers in outstream_host_buffer_free()
876 [phm->obj_index]); in outstream_host_buffer_free()
888 return status->size_in_bytes - (status->host_index - in outstream_get_space_available()
889 status->dsp_index); in outstream_get_space_available()
895 struct hpi_hw_obj *phw = pao->priv; in outstream_write()
896 struct bus_master_interface *interface = phw->p_interface_buffer; in outstream_write()
900 if (!phw->outstream_host_buffer_size[phm->obj_index]) { in outstream_write()
906 hpi_init_response(phr, phm->object, phm->function, 0); in outstream_write()
907 status = &interface->outstream_host_buffer_status[phm->obj_index]; in outstream_write()
910 if (space_available < phm->u.d.u.data.data_size) { in outstream_write()
911 phr->error = HPI_ERROR_INVALID_DATASIZE; in outstream_write()
917 if (phm->u.d.u.data.pb_data in outstream_write()
918 && hpios_locked_mem_valid(&phw->outstream_host_buffers[phm-> in outstream_write()
922 u8 *p_app_data = (u8 *)phm->u.d.u.data.pb_data; in outstream_write()
924 if (hpios_locked_mem_get_virt_addr(&phw-> in outstream_write()
925 outstream_host_buffers[phm->obj_index], in outstream_write()
927 phr->error = HPI_ERROR_INVALID_OPERATION; in outstream_write()
934 min(phm->u.d.u.data.data_size, in outstream_write()
935 status->size_in_bytes - in outstream_write()
936 (status->host_index & (status->size_in_bytes - 1))); in outstream_write()
939 (status->host_index & (status->size_in_bytes - 1)), in outstream_write()
943 phm->u.d.u.data.data_size - l_first_write); in outstream_write()
947 * This version relies on the DSP code triggering an OStream buffer in outstream_write()
949 * already written data into the BBM buffer, but the DSP won't know in outstream_write()
952 if (phw->flag_outstream_just_reset[phm->obj_index]) { in outstream_write()
953 /* Format can only change after reset. Must tell DSP. */ in outstream_write()
954 u16 function = phm->function; in outstream_write()
955 phw->flag_outstream_just_reset[phm->obj_index] = 0; in outstream_write()
956 phm->function = HPI_OSTREAM_SET_FORMAT; in outstream_write()
957 hw_message(pao, phm, phr); /* send the format to the DSP */ in outstream_write()
958 phm->function = function; in outstream_write()
959 if (phr->error) in outstream_write()
963 status->host_index += phm->u.d.u.data.data_size; in outstream_write()
969 struct hpi_hw_obj *phw = pao->priv; in outstream_get_info()
970 struct bus_master_interface *interface = phw->p_interface_buffer; in outstream_get_info()
973 if (!phw->outstream_host_buffer_size[phm->obj_index]) { in outstream_get_info()
978 hpi_init_response(phr, phm->object, phm->function, 0); in outstream_get_info()
980 status = &interface->outstream_host_buffer_status[phm->obj_index]; in outstream_get_info()
982 phr->u.d.u.stream_info.state = (u16)status->stream_state; in outstream_get_info()
983 phr->u.d.u.stream_info.samples_transferred = in outstream_get_info()
984 status->samples_processed; in outstream_get_info()
985 phr->u.d.u.stream_info.buffer_size = status->size_in_bytes; in outstream_get_info()
986 phr->u.d.u.stream_info.data_available = in outstream_get_info()
987 status->size_in_bytes - outstream_get_space_available(status); in outstream_get_info()
988 phr->u.d.u.stream_info.auxiliary_data_available = in outstream_get_info()
989 status->auxiliary_data_available; in outstream_get_info()
1001 struct hpi_hw_obj *phw = pao->priv; in outstream_reset()
1002 phw->flag_outstream_just_reset[phm->obj_index] = 1; in outstream_reset()
1019 u32 command = phm->u.d.u.buffer.command; in instream_host_buffer_allocate()
1020 struct hpi_hw_obj *phw = pao->priv; in instream_host_buffer_allocate()
1021 struct bus_master_interface *interface = phw->p_interface_buffer; in instream_host_buffer_allocate()
1023 hpi_init_response(phr, phm->object, phm->function, 0); in instream_host_buffer_allocate()
1028 phm->u.d.u.buffer.buffer_size = in instream_host_buffer_allocate()
1029 roundup_pow_of_two(phm->u.d.u.buffer.buffer_size); in instream_host_buffer_allocate()
1030 phr->u.d.u.stream_info.data_available = in instream_host_buffer_allocate()
1031 phw->instream_host_buffer_size[phm->obj_index]; in instream_host_buffer_allocate()
1032 phr->u.d.u.stream_info.buffer_size = in instream_host_buffer_allocate()
1033 phm->u.d.u.buffer.buffer_size; in instream_host_buffer_allocate()
1035 if (phw->instream_host_buffer_size[phm->obj_index] == in instream_host_buffer_allocate()
1036 phm->u.d.u.buffer.buffer_size) { in instream_host_buffer_allocate()
1041 if (hpios_locked_mem_valid(&phw->instream_host_buffers[phm-> in instream_host_buffer_allocate()
1043 hpios_locked_mem_free(&phw->instream_host_buffers in instream_host_buffer_allocate()
1044 [phm->obj_index]); in instream_host_buffer_allocate()
1046 err = hpios_locked_mem_alloc(&phw->instream_host_buffers[phm-> in instream_host_buffer_allocate()
1047 obj_index], phm->u.d.u.buffer.buffer_size, in instream_host_buffer_allocate()
1048 pao->pci.pci_dev); in instream_host_buffer_allocate()
1051 phr->error = HPI_ERROR_INVALID_DATASIZE; in instream_host_buffer_allocate()
1052 phw->instream_host_buffer_size[phm->obj_index] = 0; in instream_host_buffer_allocate()
1057 (&phw->instream_host_buffers[phm->obj_index], in instream_host_buffer_allocate()
1058 &phm->u.d.u.buffer.pci_address); in instream_host_buffer_allocate()
1061 phr->u.d.u.stream_info.auxiliary_data_available = in instream_host_buffer_allocate()
1062 phm->u.d.u.buffer.pci_address; in instream_host_buffer_allocate()
1064 hpios_locked_mem_free(&phw->instream_host_buffers in instream_host_buffer_allocate()
1065 [phm->obj_index]); in instream_host_buffer_allocate()
1066 phw->instream_host_buffer_size[phm->obj_index] = 0; in instream_host_buffer_allocate()
1067 phr->error = HPI_ERROR_MEMORY_ALLOC; in instream_host_buffer_allocate()
1076 if (phm->u.d.u.buffer.buffer_size & (phm->u.d.u.buffer. in instream_host_buffer_allocate()
1077 buffer_size - 1)) { in instream_host_buffer_allocate()
1080 phm->u.d.u.buffer.buffer_size); in instream_host_buffer_allocate()
1081 phr->error = HPI_ERROR_INVALID_DATASIZE; in instream_host_buffer_allocate()
1085 phw->instream_host_buffer_size[phm->obj_index] = in instream_host_buffer_allocate()
1086 phm->u.d.u.buffer.buffer_size; in instream_host_buffer_allocate()
1087 status = &interface->instream_host_buffer_status[phm-> in instream_host_buffer_allocate()
1089 status->samples_processed = 0; in instream_host_buffer_allocate()
1090 status->stream_state = HPI_STATE_STOPPED; in instream_host_buffer_allocate()
1091 status->dsp_index = 0; in instream_host_buffer_allocate()
1092 status->host_index = status->dsp_index; in instream_host_buffer_allocate()
1093 status->size_in_bytes = phm->u.d.u.buffer.buffer_size; in instream_host_buffer_allocate()
1094 status->auxiliary_data_available = 0; in instream_host_buffer_allocate()
1098 if (phr->error in instream_host_buffer_allocate()
1099 && hpios_locked_mem_valid(&phw-> in instream_host_buffer_allocate()
1100 instream_host_buffers[phm->obj_index])) { in instream_host_buffer_allocate()
1101 hpios_locked_mem_free(&phw->instream_host_buffers in instream_host_buffer_allocate()
1102 [phm->obj_index]); in instream_host_buffer_allocate()
1103 phw->instream_host_buffer_size[phm->obj_index] = 0; in instream_host_buffer_allocate()
1111 struct hpi_hw_obj *phw = pao->priv; in instream_host_buffer_get_info()
1112 struct bus_master_interface *interface = phw->p_interface_buffer; in instream_host_buffer_get_info()
1116 if (hpios_locked_mem_valid(&phw->instream_host_buffers[phm-> in instream_host_buffer_get_info()
1118 if (hpios_locked_mem_get_virt_addr(&phw-> in instream_host_buffer_get_info()
1119 instream_host_buffers[phm->obj_index], in instream_host_buffer_get_info()
1121 phr->error = HPI_ERROR_INVALID_OPERATION; in instream_host_buffer_get_info()
1124 status = &interface->instream_host_buffer_status[phm-> in instream_host_buffer_get_info()
1128 phr->u.d.u.hostbuffer_info.p_buffer = p_bbm_data; in instream_host_buffer_get_info()
1129 phr->u.d.u.hostbuffer_info.p_status = status; in instream_host_buffer_get_info()
1140 struct hpi_hw_obj *phw = pao->priv; in instream_host_buffer_free()
1141 u32 command = phm->u.d.u.buffer.command; in instream_host_buffer_free()
1143 if (phw->instream_host_buffer_size[phm->obj_index]) { in instream_host_buffer_free()
1146 phw->instream_host_buffer_size[phm->obj_index] = 0; in instream_host_buffer_free()
1152 hpios_locked_mem_free(&phw->instream_host_buffers in instream_host_buffer_free()
1153 [phm->obj_index]); in instream_host_buffer_free()
1173 return status->dsp_index - status->host_index; in instream_get_bytes_available()
1179 struct hpi_hw_obj *phw = pao->priv; in instream_read()
1180 struct bus_master_interface *interface = phw->p_interface_buffer; in instream_read()
1185 u8 *p_app_data = (u8 *)phm->u.d.u.data.pb_data; in instream_read()
1187 if (!phw->instream_host_buffer_size[phm->obj_index]) { in instream_read()
1191 hpi_init_response(phr, phm->object, phm->function, 0); in instream_read()
1193 status = &interface->instream_host_buffer_status[phm->obj_index]; in instream_read()
1195 if (data_available < phm->u.d.u.data.data_size) { in instream_read()
1196 phr->error = HPI_ERROR_INVALID_DATASIZE; in instream_read()
1200 if (hpios_locked_mem_valid(&phw->instream_host_buffers[phm-> in instream_read()
1202 if (hpios_locked_mem_get_virt_addr(&phw-> in instream_read()
1203 instream_host_buffers[phm->obj_index], in instream_read()
1205 phr->error = HPI_ERROR_INVALID_OPERATION; in instream_read()
1212 min(phm->u.d.u.data.data_size, in instream_read()
1213 status->size_in_bytes - in instream_read()
1214 (status->host_index & (status->size_in_bytes - 1))); in instream_read()
1218 (status->host_index & (status->size_in_bytes - 1)), in instream_read()
1222 phm->u.d.u.data.data_size - l_first_read); in instream_read()
1224 status->host_index += phm->u.d.u.data.data_size; in instream_read()
1230 struct hpi_hw_obj *phw = pao->priv; in instream_get_info()
1231 struct bus_master_interface *interface = phw->p_interface_buffer; in instream_get_info()
1233 if (!phw->instream_host_buffer_size[phm->obj_index]) { in instream_get_info()
1238 status = &interface->instream_host_buffer_status[phm->obj_index]; in instream_get_info()
1240 hpi_init_response(phr, phm->object, phm->function, 0); in instream_get_info()
1242 phr->u.d.u.stream_info.state = (u16)status->stream_state; in instream_get_info()
1243 phr->u.d.u.stream_info.samples_transferred = in instream_get_info()
1244 status->samples_processed; in instream_get_info()
1245 phr->u.d.u.stream_info.buffer_size = status->size_in_bytes; in instream_get_info()
1246 phr->u.d.u.stream_info.data_available = in instream_get_info()
1248 phr->u.d.u.stream_info.auxiliary_data_available = in instream_get_info()
1249 status->auxiliary_data_available; in instream_get_info()
1253 /* LOW-LEVEL */
1259 struct hpi_hw_obj *phw = pao->priv; in adapter_boot_load_dsp()
1263 int dsp = 0, i = 0; in adapter_boot_load_dsp() local
1268 boot_code_id[1] = pao->pci.pci_dev->subsystem_device; in adapter_boot_load_dsp()
1294 /* reset DSP by writing a 1 to the WARMRESET bit */ in adapter_boot_load_dsp()
1296 iowrite32(temp, phw->prHDCR); in adapter_boot_load_dsp()
1300 temp = ioread32(phw->prHSR); in adapter_boot_load_dsp()
1306 iowrite32(temp, phw->prHSR); in adapter_boot_load_dsp()
1309 temp = ioread32(phw->prHDCR); in adapter_boot_load_dsp()
1313 /* try writing a few numbers to the DSP page register */ in adapter_boot_load_dsp()
1316 iowrite32(temp, phw->prDSPP); in adapter_boot_load_dsp()
1317 if ((temp | C6205_DSPP_MAP1) != ioread32(phw->prDSPP)) in adapter_boot_load_dsp()
1320 iowrite32(temp, phw->prDSPP); in adapter_boot_load_dsp()
1321 if ((temp | C6205_DSPP_MAP1) != ioread32(phw->prDSPP)) in adapter_boot_load_dsp()
1324 iowrite32(temp, phw->prDSPP); in adapter_boot_load_dsp()
1325 if ((temp | C6205_DSPP_MAP1) != ioread32(phw->prDSPP)) in adapter_boot_load_dsp()
1327 /* reset DSP page to the correct number */ in adapter_boot_load_dsp()
1329 iowrite32(temp, phw->prDSPP); in adapter_boot_load_dsp()
1330 if ((temp | C6205_DSPP_MAP1) != ioread32(phw->prDSPP)) in adapter_boot_load_dsp()
1332 phw->dsp_page = 0; in adapter_boot_load_dsp()
1334 /* release 6713 from reset before 6205 is bootloaded. in adapter_boot_load_dsp()
1339 /* DSP 1 is a C6713 */ in adapter_boot_load_dsp()
1340 /* CLKX0 <- '1' release the C6205 bootmode pulldowns */ in adapter_boot_load_dsp()
1343 /* Reset the 6713 #1 - revB */ in adapter_boot_load_dsp()
1345 /* value of bit 3 is unknown after DSP reset, other bits shoudl be 0 */ in adapter_boot_load_dsp()
1351 /* Release C6713 from reset - revB */ in adapter_boot_load_dsp()
1359 for (dsp = 0; dsp < HPI6205_MAX_FILES_TO_LOAD; dsp++) { in adapter_boot_load_dsp()
1360 /* is there a DSP to load? */ in adapter_boot_load_dsp()
1361 if (boot_code_id[dsp] == 0) in adapter_boot_load_dsp()
1364 err = boot_loader_config_emif(pao, dsp); in adapter_boot_load_dsp()
1368 err = boot_loader_test_internal_memory(pao, dsp); in adapter_boot_load_dsp()
1372 err = boot_loader_test_external_memory(pao, dsp); in adapter_boot_load_dsp()
1376 err = boot_loader_test_pld(pao, dsp); in adapter_boot_load_dsp()
1380 /* write the DSP code down into the DSPs memory */ in adapter_boot_load_dsp()
1381 err = hpi_dsp_code_open(boot_code_id[dsp], pao->pci.pci_dev, in adapter_boot_load_dsp()
1409 boot_loader_write_mem32(pao, dsp, address, in adapter_boot_load_dsp()
1414 boot_loader_read_mem32(pao, dsp, in adapter_boot_load_dsp()
1444 data = boot_loader_read_mem32(pao, dsp, in adapter_boot_load_dsp()
1464 if (phw->p_interface_buffer) { in adapter_boot_load_dsp()
1468 phw->p_interface_buffer; in adapter_boot_load_dsp()
1472 /* set ack so we know when DSP is ready to go */ in adapter_boot_load_dsp()
1474 interface->dsp_ack = H620_HIF_UNKNOWN; in adapter_boot_load_dsp()
1475 wmb(); /* ensure ack is written before dsp writes back */ in adapter_boot_load_dsp()
1477 err = hpios_locked_mem_get_phys_addr(&phw->h_locked_mem, in adapter_boot_load_dsp()
1480 /* locate the host mailbox on the DSP. */ in adapter_boot_load_dsp()
1483 && time_out--) { in adapter_boot_load_dsp()
1494 temp = ioread32(phw->prHSR); in adapter_boot_load_dsp()
1496 iowrite32(temp, phw->prHSR); in adapter_boot_load_dsp()
1499 temp = ioread32(phw->prHDCR); in adapter_boot_load_dsp()
1501 iowrite32(temp, phw->prHDCR); in adapter_boot_load_dsp()
1503 /* give the DSP 10ms to start up */ in adapter_boot_load_dsp()
1515 struct hpi_hw_obj *phw = pao->priv; in boot_loader_read_mem32()
1520 /* DSP 0 is always C6205 */ in boot_loader_read_mem32()
1523 p_data = pao->pci.ap_mem_base[1] + in boot_loader_read_mem32()
1525 sizeof(*pao->pci.ap_mem_base[1]); in boot_loader_read_mem32()
1530 if (dw4M_page != phw->dsp_page) { in boot_loader_read_mem32()
1531 phw->dsp_page = dw4M_page; in boot_loader_read_mem32()
1533 iowrite32(phw->dsp_page, phw->prDSPP); in boot_loader_read_mem32()
1534 /* *INDENT-ON* */ in boot_loader_read_mem32()
1538 p_data = pao->pci.ap_mem_base[0] + in boot_loader_read_mem32()
1543 /* DSP 1 is a C6713 */ in boot_loader_read_mem32()
1557 struct hpi_hw_obj *phw = pao->priv; in boot_loader_write_mem32()
1562 /* DSP 0 is always C6205 */ in boot_loader_write_mem32()
1564 /* BAR1 - DSP register access using */ in boot_loader_write_mem32()
1565 /* Non-prefetchable PCI access */ in boot_loader_write_mem32()
1566 p_data = pao->pci.ap_mem_base[1] + in boot_loader_write_mem32()
1568 sizeof(*pao->pci.ap_mem_base[1]); in boot_loader_write_mem32()
1570 /* BAR0 access - all of DSP memory using */ in boot_loader_write_mem32()
1571 /* pre-fetchable PCI access */ in boot_loader_write_mem32()
1573 if (dw4M_page != phw->dsp_page) { in boot_loader_write_mem32()
1574 phw->dsp_page = dw4M_page; in boot_loader_write_mem32()
1575 /* *INDENT-OFF* */ in boot_loader_write_mem32()
1576 iowrite32(phw->dsp_page, phw->prDSPP); in boot_loader_write_mem32()
1577 /* *INDENT-ON* */ in boot_loader_write_mem32()
1580 p_data = pao->pci.ap_mem_base[0] + in boot_loader_write_mem32()
1585 /* DSP 1 is a C6713 */ in boot_loader_write_mem32()
1605 /* DSP 0 is always C6205 */ in boot_loader_config_emif()
1609 /* 00000000-0000FFFF 16Kx32 internal program */ in boot_loader_config_emif()
1610 /* 00400000-00BFFFFF CE0 2Mx32 SDRAM running @ 100MHz */ in boot_loader_config_emif()
1613 /*------------ */ in boot_loader_config_emif()
1624 /* EMIF CE0 setup - 2Mx32 Sync DRAM on ASI5000 cards only */ in boot_loader_config_emif()
1631 /* EMIF CE1 setup - 32 bit async. This is 6713 #1 HPI, */ in boot_loader_config_emif()
1644 /* EMIF CE2 setup - 32 bit async. This is 6713 #2 HPI, */ in boot_loader_config_emif()
1656 /* EMIF CE3 setup - 32 bit async. */ in boot_loader_config_emif()
1668 /* need to use this else DSP code crashes? */ in boot_loader_config_emif()
1693 /* HPIA - walking ones test */ in boot_loader_config_emif()
1721 * gives a DSP speed of 189MHz in boot_loader_config_emif()
1735 /* FSX0 <- '1' (GPO3) */ in boot_loader_config_emif()
1740 /* FSX0 <- '0' (GPO3) */ in boot_loader_config_emif()
1743 /* 6205 EMIF CE1 resetup - 32 bit async. */ in boot_loader_config_emif()
1763 /* EMIF CE0 setup - 2Mx32 Sync DRAM in boot_loader_config_emif()
1768 15..14 - in boot_loader_config_emif()
1779 31-21 0000b 0000b 000b in boot_loader_config_emif()
1780 20 WR2RD = 2cycles-1 = 1b in boot_loader_config_emif()
1782 19-18 WR2DEAC = 3cycle-1 = 10b in boot_loader_config_emif()
1783 17 WR2WR = 2cycle-1 = 1b in boot_loader_config_emif()
1784 16-15 R2WDQM = 4cycle-1 = 11b in boot_loader_config_emif()
1785 14-12 RD2WR = 6cycles-1 = 101b in boot_loader_config_emif()
1787 11-10 RD2DEAC = 4cycle-1 = 11b in boot_loader_config_emif()
1788 9 RD2RD = 2cycle-1 = 1b in boot_loader_config_emif()
1789 8-7 THZP = 3cycle-1 = 10b in boot_loader_config_emif()
1790 6-5 TWR = 2cycle-1 = 01b (tWR = 17ns) in boot_loader_config_emif()
1792 3-1 TRAS = 5cycle-1 = 100b (Tras=42ns) in boot_loader_config_emif()
1794 (for Micron 2M32-7 operating at 100MHz) in boot_loader_config_emif()
1799 /* EMIF SDRAM control - set up for a 2Mx32 SDRAM (512x32x4 bank) in boot_loader_config_emif()
1800 31 - 0b - in boot_loader_config_emif()
1808 23..20 TRCD 0001b (Trcd/Tcyc)-1 = (20/10)-1 = 1 in boot_loader_config_emif()
1810 19..16 TRP 0001b (Trp/Tcyc)-1 = (20/10)-1 = 1 in boot_loader_config_emif()
1812 15..12 TRC 0110b (Trc/Tcyc)-1 = (70/10)-1 = 6 in boot_loader_config_emif()
1814 11..0 - 0000b 0000b 0000b in boot_loader_config_emif()
1827 /* DSP 2 is a C6713 */ in boot_loader_config_emif()
1898 /* DSP 0 is a C6205 */ in boot_loader_test_internal_memory()
1907 /* DSP 1 is a C6713 */ in boot_loader_test_internal_memory()
1931 if (pao->pci.pci_dev->subsystem_device == 0x5000) { in boot_loader_test_external_memory()
1932 /* DSP 0 is always C6205 */ in boot_loader_test_external_memory()
1939 /* DSP 1 is a C6713 */ in boot_loader_test_external_memory()
1956 if (pao->pci.pci_dev->subsystem_device == 0x5000) { in boot_loader_test_pld()
1968 /* DSP 1 is a C6713 */ in boot_loader_test_pld()
1969 if (pao->pci.pci_dev->subsystem_device == 0x8700) { in boot_loader_test_pld()
1975 /* 8713 - LED on */ in boot_loader_test_pld()
1983 /** Transfer data to or from DSP
1989 struct hpi_hw_obj *phw = pao->priv; in hpi6205_transfer_data()
1993 struct bus_master_interface *interface = phw->p_interface_buffer; in hpi6205_transfer_data()
2005 u32 this_copy = data_size - data_transferred; in hpi6205_transfer_data()
2011 memcpy((void *)&interface->u.b_data[0], in hpi6205_transfer_data()
2014 interface->transfer_size_in_bytes = this_copy; in hpi6205_transfer_data()
2016 /* DSP must change this back to nOperation */ in hpi6205_transfer_data()
2017 interface->dsp_ack = H620_HIF_IDLE; in hpi6205_transfer_data()
2022 HPI6205_TIMEOUT - temp2, this_copy); in hpi6205_transfer_data()
2028 operation, interface->dsp_ack); in hpi6205_transfer_data()
2034 (void *)&interface->u.b_data[0], this_copy); in hpi6205_transfer_data()
2038 if (interface->dsp_ack != operation) in hpi6205_transfer_data()
2039 HPI_DEBUG_LOG(DEBUG, "interface->dsp_ack=%d, expected %d\n", in hpi6205_transfer_data()
2040 interface->dsp_ack, operation); in hpi6205_transfer_data()
2048 /* wait for up to timeout_us microseconds for the DSP
2053 struct bus_master_interface *interface = phw->p_interface_buffer; in wait_dsp_ack()
2056 rmb(); /* ensure interface->dsp_ack is up to date */ in wait_dsp_ack()
2057 while ((interface->dsp_ack != state) && --t) { in wait_dsp_ack()
2059 rmb(); /* DSP changes dsp_ack by DMA */ in wait_dsp_ack()
2062 /*HPI_DEBUG_LOG(VERBOSE, "Spun %d for %d\n", timeout_us/4-t, state); */ in wait_dsp_ack()
2066 /* set the busmaster interface to cmd, then interrupt the DSP */
2069 struct bus_master_interface *interface = phw->p_interface_buffer; in send_dsp_command()
2072 interface->host_cmd = cmd; in send_dsp_command()
2073 wmb(); /* DSP gets state by DMA, make sure it is written to memory */ in send_dsp_command()
2074 /* before we interrupt the DSP */ in send_dsp_command()
2075 r = ioread32(phw->prHDCR); in send_dsp_command()
2077 iowrite32(r, phw->prHDCR); in send_dsp_command()
2079 iowrite32(r, phw->prHDCR); in send_dsp_command()
2088 struct hpi_hw_obj *phw = pao->priv; in message_response_sequence()
2089 struct bus_master_interface *interface = phw->p_interface_buffer; in message_response_sequence()
2093 if (phm->size > sizeof(interface->u.message_buffer)) { in message_response_sequence()
2094 phr->error = HPI_ERROR_MESSAGE_BUFFER_TOO_SMALL; in message_response_sequence()
2095 phr->specific_error = sizeof(interface->u.message_buffer); in message_response_sequence()
2096 phr->size = sizeof(struct hpi_response_header); in message_response_sequence()
2098 "message len %d too big for buffer %zd \n", phm->size, in message_response_sequence()
2099 sizeof(interface->u.message_buffer)); in message_response_sequence()
2111 memcpy(&interface->u.message_buffer, phm, phm->size); in message_response_sequence()
2120 message_count, interface->dsp_ack); in message_response_sequence()
2124 message_count, HPI6205_TIMEOUT - time_out2); in message_response_sequence()
2131 if (interface->u.response_buffer.response.size <= phr->size) in message_response_sequence()
2132 memcpy(phr, &interface->u.response_buffer, in message_response_sequence()
2133 interface->u.response_buffer.response.size); in message_response_sequence()
2137 interface->u.response_buffer.response.size, in message_response_sequence()
2138 phr->size); in message_response_sequence()
2139 memcpy(phr, &interface->u.response_buffer, in message_response_sequence()
2141 phr->error = HPI_ERROR_RESPONSE_BUFFER_TOO_SMALL; in message_response_sequence()
2142 phr->specific_error = in message_response_sequence()
2143 interface->u.response_buffer.response.size; in message_response_sequence()
2144 phr->size = sizeof(struct hpi_response_header); in message_response_sequence()
2154 /* special case for adapter close - */ in message_response_sequence()
2155 /* wait for the DSP to indicate it is idle */ in message_response_sequence()
2156 if (phm->function == HPI_ADAPTER_CLOSE) { in message_response_sequence()
2180 /* something failed in the HPI/DSP interface */ in hw_message()
2182 phr->error = HPI_ERROR_DSP_COMMUNICATION; in hw_message()
2183 phr->specific_error = err; in hw_message()
2185 phr->error = err; in hw_message()
2188 pao->dsp_crashed++; in hw_message()
2191 phr->size = sizeof(struct hpi_response_header); in hw_message()
2194 pao->dsp_crashed = 0; in hw_message()
2196 if (phr->error != 0) /* something failed in the DSP */ in hw_message()
2199 switch (phm->function) { in hw_message()
2202 err = hpi6205_transfer_data(pao, phm->u.d.u.data.pb_data, in hw_message()
2203 phm->u.d.u.data.data_size, H620_HIF_SEND_DATA); in hw_message()
2208 err = hpi6205_transfer_data(pao, phm->u.d.u.data.pb_data, in hw_message()
2209 phm->u.d.u.data.data_size, H620_HIF_GET_DATA); in hw_message()
2213 phr->error = err; in hw_message()