/** * De-initialize BAM DMA module * */ void sps_dma_de_init(void) { int n; /* De-initialize the BAM devices */ for (n = 0; n < num_bams; n++) sps_deregister_bam_device(bam_handles[n]); /* Clear local data */ memset(&bam_dma_dev, 0, sizeof(bam_dma_dev)); num_bams = 0; memset(bam_handles, 0, sizeof(bam_handles)); }
void sps_dma_de_init(void) { int n; for (n = 0; n < num_bams; n++) sps_deregister_bam_device(bam_handles[n]); memset(&bam_dma_dev, 0, sizeof(bam_dma_dev)); num_bams = 0; memset(bam_handles, 0, sizeof(bam_handles)); }
static void bam_init(struct work_struct *work) { u32 h; dma_addr_t dma_addr; int ret; void *a2_virt_addr; /* init BAM */ a2_virt_addr = ioremap_nocache(A2_PHYS_BASE, A2_PHYS_SIZE); if (!a2_virt_addr) { pr_err("%s: ioremap failed\n", __func__); ret = -ENOMEM; goto register_bam_failed; } a2_props.phys_addr = A2_PHYS_BASE; a2_props.virt_addr = a2_virt_addr; a2_props.virt_size = A2_PHYS_SIZE; a2_props.irq = A2_BAM_IRQ; a2_props.num_pipes = A2_NUM_PIPES; a2_props.summing_threshold = A2_SUMMING_THRESHOLD; /* need to free on tear down */ ret = sps_register_bam_device(&a2_props, &h); if (ret < 0) { pr_err("%s: register bam error %d\n", __func__, ret); goto register_bam_failed; } bam_tx_pipe = sps_alloc_endpoint(); if (bam_tx_pipe == NULL) { pr_err("%s: tx alloc endpoint failed\n", __func__); ret = -ENOMEM; goto register_bam_failed; } ret = sps_get_config(bam_tx_pipe, &tx_connection); if (ret) { pr_err("%s: tx get config failed %d\n", __func__, ret); goto tx_get_config_failed; } tx_connection.source = SPS_DEV_HANDLE_MEM; tx_connection.src_pipe_index = 0; tx_connection.destination = h; tx_connection.dest_pipe_index = 4; tx_connection.mode = SPS_MODE_DEST; tx_connection.options = SPS_O_AUTO_ENABLE | SPS_O_EOT | SPS_O_ACK_TRANSFERS; tx_desc_mem_buf.size = 0x800; /* 2k */ tx_desc_mem_buf.base = dma_alloc_coherent(NULL, tx_desc_mem_buf.size, &dma_addr, 0); if (tx_desc_mem_buf.base == NULL) { pr_err("%s: tx memory alloc failed\n", __func__); ret = -ENOMEM; goto tx_mem_failed; } tx_desc_mem_buf.phys_base = dma_addr; memset(tx_desc_mem_buf.base, 0x0, tx_desc_mem_buf.size); tx_connection.desc = tx_desc_mem_buf; tx_connection.event_thresh = 0x10; ret = sps_connect(bam_tx_pipe, &tx_connection); if (ret < 0) { pr_err("%s: tx connect error %d\n", __func__, ret); goto tx_connect_failed; } bam_rx_pipe = sps_alloc_endpoint(); if (bam_rx_pipe == NULL) { pr_err("%s: rx alloc endpoint failed\n", __func__); ret = -ENOMEM; goto tx_connect_failed; } ret = sps_get_config(bam_rx_pipe, &rx_connection); if (ret) { pr_err("%s: rx get config failed %d\n", __func__, ret); goto rx_get_config_failed; } rx_connection.source = h; rx_connection.src_pipe_index = 5; rx_connection.destination = SPS_DEV_HANDLE_MEM; rx_connection.dest_pipe_index = 1; rx_connection.mode = SPS_MODE_SRC; rx_connection.options = SPS_O_AUTO_ENABLE | SPS_O_EOT | SPS_O_ACK_TRANSFERS; rx_desc_mem_buf.size = 0x800; /* 2k */ rx_desc_mem_buf.base = dma_alloc_coherent(NULL, rx_desc_mem_buf.size, &dma_addr, 0); if (rx_desc_mem_buf.base == NULL) { pr_err("%s: rx memory alloc failed\n", __func__); ret = -ENOMEM; goto rx_mem_failed; } rx_desc_mem_buf.phys_base = dma_addr; memset(rx_desc_mem_buf.base, 0x0, rx_desc_mem_buf.size); rx_connection.desc = rx_desc_mem_buf; rx_connection.event_thresh = 0x10; ret = sps_connect(bam_rx_pipe, &rx_connection); if (ret < 0) { pr_err("%s: rx connect error %d\n", __func__, ret); goto rx_connect_failed; } tx_register_event.options = SPS_O_EOT; tx_register_event.mode = SPS_TRIGGER_CALLBACK; tx_register_event.xfer_done = NULL; tx_register_event.callback = bam_mux_tx_notify; tx_register_event.user = NULL; ret = sps_register_event(bam_tx_pipe, &tx_register_event); if (ret < 0) { pr_err("%s: tx register event error %d\n", __func__, ret); goto rx_event_reg_failed; } rx_register_event.options = SPS_O_EOT; rx_register_event.mode = SPS_TRIGGER_CALLBACK; rx_register_event.xfer_done = NULL; rx_register_event.callback = bam_mux_rx_notify; rx_register_event.user = NULL; ret = sps_register_event(bam_rx_pipe, &rx_register_event); if (ret < 0) { pr_err("%s: tx register event error %d\n", __func__, ret); goto rx_event_reg_failed; } bam_mux_initialized = 1; queue_rx(); return; rx_event_reg_failed: sps_disconnect(bam_rx_pipe); rx_connect_failed: dma_free_coherent(NULL, rx_desc_mem_buf.size, rx_desc_mem_buf.base, rx_desc_mem_buf.phys_base); rx_mem_failed: sps_disconnect(bam_tx_pipe); rx_get_config_failed: sps_free_endpoint(bam_rx_pipe); tx_connect_failed: dma_free_coherent(NULL, tx_desc_mem_buf.size, tx_desc_mem_buf.base, tx_desc_mem_buf.phys_base); tx_get_config_failed: sps_free_endpoint(bam_tx_pipe); tx_mem_failed: sps_deregister_bam_device(h); register_bam_failed: /*destroy_workqueue(bam_mux_workqueue);*/ /*return ret;*/ return; }