static void sof(void) { if (head != tail) { /* Set DMA mode and enable DMA. */ dma_setup_channel(DMA_TIM7_UP, (u32)queue[head], (u32)&DAC_DHR12LD, data_len[head], DMA_M_32BIT | DMA_P_32BIT | DMA_M_INC | DMA_M_TO_P | DMA_COMPLETE | DMA_ENABLE); /* Set counter. */ tim_set_counter(TIM7, TIMX_CLK_APB1 / SAMPLING_FREQ - 1); /* Enable counter. */ tim_enable_counter(TIM7); } }
static int __devinit spi_probe(struct platform_device *pdev) { struct spi_stellaris_master *platform_info; struct spi_master *master; struct spi_stellaris_data *priv; struct resource *res; int ret; platform_info = dev_get_platdata(&pdev->dev); if (!platform_info) { dev_err(&pdev->dev, "can't get the platform data\n"); return -EINVAL; } master = spi_alloc_master(&pdev->dev, sizeof(struct spi_stellaris_data)); if (!master) return -ENOMEM; platform_set_drvdata(pdev, master); master->bus_num = pdev->id; master->num_chipselect = platform_info->num_chipselect; priv = spi_master_get_devdata(master); priv->bitbang.master = spi_master_get(master); priv->chipselect = platform_info->chipselect; #ifdef CONFIG_STELLARIS_DMA priv->dma_tx_buffer = platform_info->dma_tx_buffer; priv->dma_rx_buffer = platform_info->dma_rx_buffer; priv->dma_tx_channel = platform_info->dma_tx_channel; priv->dma_rx_channel = platform_info->dma_rx_channel; dma_setup_channel(priv->dma_tx_channel, DMA_DEFAULT_CONFIG); dma_setup_channel(priv->dma_rx_channel, DMA_DEFAULT_CONFIG); #endif priv->bitbang.chipselect = spi_chipselect; priv->bitbang.setup_transfer = spi_setupxfer; priv->bitbang.txrx_bufs = spi_transfer; priv->bitbang.master->setup = stellaris_spi_setup; priv->bitbang.master->cleanup = spi_cleanup; priv->bitbang.master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH; init_completion(&priv->xfer_done); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { dev_err(&pdev->dev, "can't get platform resource\n"); ret = -ENOMEM; goto out_master_put; } if (!request_mem_region(res->start, resource_size(res), pdev->name)) { dev_err(&pdev->dev, "request_mem_region failed\n"); ret = -EBUSY; goto out_master_put; } priv->base = ioremap(res->start, resource_size(res)); if (!priv->base) { ret = -EINVAL; goto out_release_mem; } priv->irq = platform_get_irq(pdev, 0); if (priv->irq <= 0) { ret = -EINVAL; goto out_iounmap; } #ifndef POLLING_MODE ret = request_irq(priv->irq, spi_isr, 0, DRIVER_NAME, priv); if (ret) { dev_err(&pdev->dev, "can't get irq%d: %d\n", priv->irq, ret); goto out_iounmap; } #endif enable_ssi_clock(); #ifdef CONFIG_STELLARIS_DMA #ifdef CONFIG_ARCH_TM4C ssi_putreg(priv, STLR_SSI_IM_OFFSET, SSI_IM_DMARX | SSI_IM_DMATX); #else putreg32(priv, STLR_SSI_DMACTL_OFFSET, SSI_DMACTL_RXDMAE | SSI_DMACTL_TXDMAE); #endif #endif ret = spi_bitbang_start(&priv->bitbang); if (ret) { dev_err(&pdev->dev, "bitbang start failed with %d\n", ret); goto out_free_irq; } dev_info(&pdev->dev, "probed\n"); return ret; out_free_irq: #ifndef POLLING_MODE free_irq(priv->irq, priv); #endif out_iounmap: iounmap(priv->base); out_release_mem: release_mem_region(res->start, resource_size(res)); out_master_put: spi_master_put(master); kfree(master); platform_set_drvdata(pdev, NULL); return ret; }