static int bf5xx_ac97_resume(struct snd_soc_dai *dai) { int ret; struct sport_device *sport = (struct sport_device *)dai->private_data; pr_debug("%s : sport %d\n", __func__, dai->id); if (!dai->active) return 0; #if defined(CONFIG_SND_BF5XX_MULTICHAN_SUPPORT) ret = sport_set_multichannel(sport, 16, 0x3FF, 1); #else ret = sport_set_multichannel(sport, 16, 0x1F, 1); #endif if (ret) { pr_err("SPORT is busy!\n"); return -EBUSY; } ret = sport_config_rx(sport, IRFS, 0xF, 0, (16*16-1)); if (ret) { pr_err("SPORT is busy!\n"); return -EBUSY; } ret = sport_config_tx(sport, ITFS, 0xF, 0, (16*16-1)); if (ret) { pr_err("SPORT is busy!\n"); return -EBUSY; } return 0; }
static int bf5xx_tdm_resume(struct snd_soc_dai *dai) { int ret; struct sport_device *sport = dai->private_data; if (!dai->active) return 0; ret = sport_set_multichannel(sport, 8, 0xFF, 1); if (ret) { pr_err("SPORT is busy!\n"); ret = -EBUSY; } ret = sport_config_rx(sport, IRFS, 0x1F, 0, 0); if (ret) { pr_err("SPORT is busy!\n"); ret = -EBUSY; } ret = sport_config_tx(sport, ITFS, 0x1F, 0, 0); if (ret) { pr_err("SPORT is busy!\n"); ret = -EBUSY; } return 0; }
static int bf5xx_ac97_resume(struct snd_soc_dai *dai) { int ret; struct sport_device *sport = (struct sport_device *)dai->private_data; pr_debug("%s : sport %d\n", __func__, dai->id); if (!dai->active) return 0; ret = sport_set_multichannel(sport_handle, 16, 0x1F, 1); if (ret) { pr_err("SPORT is busy!\n"); return -EBUSY; } ret = sport_config_rx(sport_handle, IRFS, 0xF, 0, (16*16-1)); if (ret) { pr_err("SPORT is busy!\n"); return -EBUSY; } ret = sport_config_tx(sport_handle, ITFS, 0xF, 0, (16*16-1)); if (ret) { pr_err("SPORT is busy!\n"); return -EBUSY; } if (dai->capture.active) sport_rx_start(sport); if (dai->playback.active) sport_tx_start(sport); return 0; }
static int bf5xx_tdm_resume(struct snd_soc_dai *dai) { int ret; struct sport_device *sport = snd_soc_dai_get_drvdata(dai); ret = sport_set_multichannel(sport, 8, 0xFF, 1); if (ret) { pr_err("SPORT is busy!\n"); ret = -EBUSY; } ret = sport_config_rx(sport, 0, 0x1F, 0, 0); if (ret) { pr_err("SPORT is busy!\n"); ret = -EBUSY; } ret = sport_config_tx(sport, 0, 0x1F, 0, 0); if (ret) { pr_err("SPORT is busy!\n"); ret = -EBUSY; } peripheral_request_list(sport->pin_req, "soc-audio"); return 0; }
static int bf5xx_i2s_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { struct sport_device *sport_handle = snd_soc_dai_get_drvdata(dai); struct bf5xx_i2s_port *bf5xx_i2s = sport_handle->private_data; int ret = 0; bf5xx_i2s->tcr2 &= ~0x1f; bf5xx_i2s->rcr2 &= ~0x1f; switch (params_format(params)) { case SNDRV_PCM_FORMAT_S8: bf5xx_i2s->tcr2 |= 7; bf5xx_i2s->rcr2 |= 7; sport_handle->wdsize = 1; case SNDRV_PCM_FORMAT_S16_LE: bf5xx_i2s->tcr2 |= 15; bf5xx_i2s->rcr2 |= 15; sport_handle->wdsize = 2; break; case SNDRV_PCM_FORMAT_S24_LE: bf5xx_i2s->tcr2 |= 23; bf5xx_i2s->rcr2 |= 23; sport_handle->wdsize = 3; break; case SNDRV_PCM_FORMAT_S32_LE: bf5xx_i2s->tcr2 |= 31; bf5xx_i2s->rcr2 |= 31; sport_handle->wdsize = 4; break; } if (!bf5xx_i2s->configured) { /* * TX and RX are not independent,they are enabled at the * same time, even if only one side is running. So, we * need to configure both of them at the time when the first * stream is opened. * * CPU DAI:slave mode. */ bf5xx_i2s->configured = 1; ret = sport_config_rx(sport_handle, bf5xx_i2s->rcr1, bf5xx_i2s->rcr2, 0, 0); if (ret) { pr_err("SPORT is busy!\n"); return -EBUSY; } ret = sport_config_tx(sport_handle, bf5xx_i2s->tcr1, bf5xx_i2s->tcr2, 0, 0); if (ret) { pr_err("SPORT is busy!\n"); return -EBUSY; } } return 0; }
static int __devinit bfin_tdm_probe(struct platform_device *pdev) { int ret = 0; if (peripheral_request_list(&sport_req[sport_num][0], "soc-audio")) { pr_err("Requesting Peripherals failed\n"); return -EFAULT; } /* request DMA for SPORT */ sport_handle = sport_init(&sport_params[sport_num], 4, \ 8 * sizeof(u32), NULL); if (!sport_handle) { peripheral_free_list(&sport_req[sport_num][0]); return -ENODEV; } /* SPORT works in TDM mode */ ret = sport_set_multichannel(sport_handle, 8, 0xFF, 1); if (ret) { pr_err("SPORT is busy!\n"); ret = -EBUSY; goto sport_config_err; } ret = sport_config_rx(sport_handle, IRFS, 0x1F, 0, 0); if (ret) { pr_err("SPORT is busy!\n"); ret = -EBUSY; goto sport_config_err; } ret = sport_config_tx(sport_handle, ITFS, 0x1F, 0, 0); if (ret) { pr_err("SPORT is busy!\n"); ret = -EBUSY; goto sport_config_err; } ret = snd_soc_register_dai(&bf5xx_tdm_dai); if (ret) { pr_err("Failed to register DAI: %d\n", ret); goto sport_config_err; } sport_handle->private_data = &bf5xx_tdm; return 0; sport_config_err: peripheral_free_list(&sport_req[sport_num][0]); return ret; }
static int bf5xx_i2s_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { struct sport_device *sport_handle = snd_soc_dai_get_drvdata(dai); struct bf5xx_i2s_port *bf5xx_i2s = sport_handle->private_data; int ret = 0; bf5xx_i2s->tcr2 &= ~0x1f; bf5xx_i2s->rcr2 &= ~0x1f; switch (params_format(params)) { case SNDRV_PCM_FORMAT_S8: bf5xx_i2s->tcr2 |= 7; bf5xx_i2s->rcr2 |= 7; sport_handle->wdsize = 1; case SNDRV_PCM_FORMAT_S16_LE: bf5xx_i2s->tcr2 |= 15; bf5xx_i2s->rcr2 |= 15; sport_handle->wdsize = 2; break; case SNDRV_PCM_FORMAT_S24_LE: bf5xx_i2s->tcr2 |= 23; bf5xx_i2s->rcr2 |= 23; sport_handle->wdsize = 3; break; case SNDRV_PCM_FORMAT_S32_LE: bf5xx_i2s->tcr2 |= 31; bf5xx_i2s->rcr2 |= 31; sport_handle->wdsize = 4; break; } if (!bf5xx_i2s->configured) { bf5xx_i2s->configured = 1; ret = sport_config_rx(sport_handle, bf5xx_i2s->rcr1, bf5xx_i2s->rcr2, 0, 0); if (ret) { pr_err("SPORT is busy!\n"); return -EBUSY; } ret = sport_config_tx(sport_handle, bf5xx_i2s->tcr1, bf5xx_i2s->tcr2, 0, 0); if (ret) { pr_err("SPORT is busy!\n"); return -EBUSY; } } return 0; }
static int bf5xx_tdm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { struct sport_device *sport_handle = snd_soc_dai_get_drvdata(dai); struct bf5xx_tdm_port *bf5xx_tdm = sport_handle->private_data; int ret = 0; bf5xx_tdm->tcr2 &= ~0x1f; bf5xx_tdm->rcr2 &= ~0x1f; switch (params_format(params)) { case SNDRV_PCM_FORMAT_S32_LE: bf5xx_tdm->tcr2 |= 31; bf5xx_tdm->rcr2 |= 31; sport_handle->wdsize = 4; break; /* at present, we only support 32bit transfer */ default: pr_err("not supported PCM format yet\n"); return -EINVAL; break; } if (!bf5xx_tdm->configured) { /* * TX and RX are not independent,they are enabled at the * same time, even if only one side is running. So, we * need to configure both of them at the time when the first * stream is opened. * * CPU DAI:slave mode. */ ret = sport_config_rx(sport_handle, bf5xx_tdm->rcr1, bf5xx_tdm->rcr2, 0, 0); if (ret) { pr_err("SPORT is busy!\n"); return -EBUSY; } ret = sport_config_tx(sport_handle, bf5xx_tdm->tcr1, bf5xx_tdm->tcr2, 0, 0); if (ret) { pr_err("SPORT is busy!\n"); return -EBUSY; } bf5xx_tdm->configured = 1; } return 0; }
static int __devinit bfin_tdm_probe(struct platform_device *pdev) { struct sport_device *sport_handle; int ret; /* configure SPORT for TDM */ sport_handle = sport_init(pdev, 4, 8 * sizeof(u32), sizeof(struct bf5xx_tdm_port)); if (!sport_handle) return -ENODEV; /* SPORT works in TDM mode */ ret = sport_set_multichannel(sport_handle, 8, 0xFF, 1); if (ret) { pr_err("SPORT is busy!\n"); ret = -EBUSY; goto sport_config_err; } ret = sport_config_rx(sport_handle, 0, 0x1F, 0, 0); if (ret) { pr_err("SPORT is busy!\n"); ret = -EBUSY; goto sport_config_err; } ret = sport_config_tx(sport_handle, 0, 0x1F, 0, 0); if (ret) { pr_err("SPORT is busy!\n"); ret = -EBUSY; goto sport_config_err; } ret = snd_soc_register_dai(&pdev->dev, &bf5xx_tdm_dai); if (ret) { pr_err("Failed to register DAI: %d\n", ret); goto sport_config_err; } return 0; sport_config_err: sport_done(sport_handle); return ret; }
static int bf5xx_probe(struct platform_device *pdev) { u16 sport_req[][7] = {PIN_REQ_SPORT_0, PIN_REQ_SPORT_1}; if (peripheral_request_list(&sport_req[sport_num][0], "soc-audio")) { printk(KERN_ERR "Requesting Peripherals faild\n"); return -EFAULT; } #ifdef CONFIG_SND_BF5XX_HAVE_COLD_RESET /* Request PB3 as reset pin */ if (gpio_request(CONFIG_SND_BF5XX_RESET_GPIO_NUM, "SND_AD198x RESET")) { printk(KERN_ERR "Failed to request GPIO_%d for reset\n", CONFIG_SND_BF5XX_RESET_GPIO_NUM); peripheral_free_list(&sport_req[sport_num][0]); return -1; } gpio_direction_output(CONFIG_SND_BF5XX_RESET_GPIO_NUM); gpio_set_value(CONFIG_SND_BF5XX_RESET_GPIO_NUM, 1); #endif sport_handle = sport_init(&sport_params[sport_num], 2, \ 10 * sizeof(struct ac97_frame), NULL); if (!sport_handle) { peripheral_free_list(&sport_req[sport_num][0]); #ifdef CONFIG_SND_BF5XX_HAVE_COLD_RESET gpio_free(CONFIG_SND_BF5XX_RESET_GPIO_NUM); #endif return -ENODEV; } sport_set_multichannel(sport_handle, 16, 0x1F, 1); sport_config_rx(sport_handle, IRFS, 0xF, 0, (16*16-1)); sport_config_tx(sport_handle, ITFS, 0xF, 0, (16*16-1)); return 0; }
static int bf5xx_i2s_resume(struct snd_soc_dai *dai) { struct sport_device *sport_handle = snd_soc_dai_get_drvdata(dai); struct bf5xx_i2s_port *bf5xx_i2s = sport_handle->private_data; int ret; pr_debug("%s : sport %d\n", __func__, dai->id); ret = sport_config_rx(sport_handle, bf5xx_i2s->rcr1, bf5xx_i2s->rcr2, 0, 0); if (ret) { pr_err("SPORT is busy!\n"); return -EBUSY; } ret = sport_config_tx(sport_handle, bf5xx_i2s->tcr1, bf5xx_i2s->tcr2, 0, 0); if (ret) { pr_err("SPORT is busy!\n"); return -EBUSY; } return 0; }
static int bf5xx_ac97_probe(struct platform_device *pdev, struct snd_soc_dai *dai) { int ret = 0; cmd_count = (int *)get_zeroed_page(GFP_KERNEL); if (cmd_count == NULL) return -ENOMEM; if (peripheral_request_list(sport_req[sport_num], "soc-audio")) { pr_err("Requesting Peripherals failed\n"); ret = -EFAULT; goto peripheral_err; } #ifdef CONFIG_SND_BF5XX_HAVE_COLD_RESET /* Request PB3 as reset pin */ if (gpio_request(CONFIG_SND_BF5XX_RESET_GPIO_NUM, "SND_AD198x RESET")) { pr_err("Failed to request GPIO_%d for reset\n", CONFIG_SND_BF5XX_RESET_GPIO_NUM); ret = -1; goto gpio_err; } gpio_direction_output(CONFIG_SND_BF5XX_RESET_GPIO_NUM, 1); #endif sport_handle = sport_init(&sport_params[sport_num], 2, \ sizeof(struct ac97_frame), NULL); if (!sport_handle) { ret = -ENODEV; goto sport_err; } /*SPORT works in TDM mode to simulate AC97 transfers*/ #if defined(CONFIG_SND_BF5XX_MULTICHAN_SUPPORT) ret = sport_set_multichannel(sport_handle, 16, 0x3FF, 1); #else ret = sport_set_multichannel(sport_handle, 16, 0x1F, 1); #endif if (ret) { pr_err("SPORT is busy!\n"); ret = -EBUSY; goto sport_config_err; } ret = sport_config_rx(sport_handle, IRFS, 0xF, 0, (16*16-1)); if (ret) { pr_err("SPORT is busy!\n"); ret = -EBUSY; goto sport_config_err; } ret = sport_config_tx(sport_handle, ITFS, 0xF, 0, (16*16-1)); if (ret) { pr_err("SPORT is busy!\n"); ret = -EBUSY; goto sport_config_err; } return 0; sport_config_err: kfree(sport_handle); sport_err: #ifdef CONFIG_SND_BF5XX_HAVE_COLD_RESET gpio_free(CONFIG_SND_BF5XX_RESET_GPIO_NUM); gpio_err: #endif peripheral_free_list(sport_req[sport_num]); peripheral_err: free_page((unsigned long)cmd_count); cmd_count = NULL; return ret; }
static int __devinit asoc_bfin_ac97_probe(struct platform_device *pdev) { struct sport_device *sport_handle; int ret; #ifdef CONFIG_SND_BF5XX_HAVE_COLD_RESET /* Request PB3 as reset pin */ if (gpio_request(CONFIG_SND_BF5XX_RESET_GPIO_NUM, "SND_AD198x RESET")) { pr_err("Failed to request GPIO_%d for reset\n", CONFIG_SND_BF5XX_RESET_GPIO_NUM); ret = -1; goto gpio_err; } gpio_direction_output(CONFIG_SND_BF5XX_RESET_GPIO_NUM, 1); #endif sport_handle = sport_init(pdev, 2, sizeof(struct ac97_frame), PAGE_SIZE); if (!sport_handle) { ret = -ENODEV; goto sport_err; } /*SPORT works in TDM mode to simulate AC97 transfers*/ #if defined(CONFIG_SND_BF5XX_MULTICHAN_SUPPORT) ret = sport_set_multichannel(sport_handle, 16, 0x3FF, 1); #else ret = sport_set_multichannel(sport_handle, 16, 0x1F, 1); #endif if (ret) { pr_err("SPORT is busy!\n"); ret = -EBUSY; goto sport_config_err; } ret = sport_config_rx(sport_handle, IRFS, 0xF, 0, (16*16-1)); if (ret) { pr_err("SPORT is busy!\n"); ret = -EBUSY; goto sport_config_err; } ret = sport_config_tx(sport_handle, ITFS, 0xF, 0, (16*16-1)); if (ret) { pr_err("SPORT is busy!\n"); ret = -EBUSY; goto sport_config_err; } ret = snd_soc_register_dai(&pdev->dev, &bfin_ac97_dai); if (ret) { pr_err("Failed to register DAI: %d\n", ret); goto sport_config_err; } ac97_sport_handle = sport_handle; return 0; sport_config_err: sport_done(sport_handle); sport_err: #ifdef CONFIG_SND_BF5XX_HAVE_COLD_RESET gpio_free(CONFIG_SND_BF5XX_RESET_GPIO_NUM); gpio_err: #endif return ret; }