Lines Matching refs:dev

197 	struct device				*dev;  member
211 struct atmel_i2s_dev *dev = dev_id; in atmel_i2s_interrupt() local
215 regmap_read(dev->regmap, ATMEL_I2SC_SR, &sr); in atmel_i2s_interrupt()
216 regmap_read(dev->regmap, ATMEL_I2SC_IMR, &imr); in atmel_i2s_interrupt()
228 dev_err(dev->dev, in atmel_i2s_interrupt()
232 regmap_write(dev->regmap, ATMEL_I2SC_SCR, mask); in atmel_i2s_interrupt()
242 dev_err(dev->dev, in atmel_i2s_interrupt()
246 regmap_write(dev->regmap, ATMEL_I2SC_SCR, mask); in atmel_i2s_interrupt()
265 struct atmel_i2s_dev *dev = snd_soc_dai_get_drvdata(dai); in atmel_i2s_set_dai_fmt() local
267 dev->fmt = fmt; in atmel_i2s_set_dai_fmt()
274 struct atmel_i2s_dev *dev = snd_soc_dai_get_drvdata(dai); in atmel_i2s_prepare() local
279 regmap_read(dev->regmap, ATMEL_I2SC_SR, &sr); in atmel_i2s_prepare()
286 dev_dbg(dev->dev, "RXRDY is set\n"); in atmel_i2s_prepare()
287 regmap_read(dev->regmap, ATMEL_I2SC_RHR, &rhr); in atmel_i2s_prepare()
294 static int atmel_i2s_get_gck_param(struct atmel_i2s_dev *dev, int fs) in atmel_i2s_get_gck_param() argument
298 if (!dev->gclk) { in atmel_i2s_get_gck_param()
299 dev_err(dev->dev, "cannot generate the I2S Master Clock\n"); in atmel_i2s_get_gck_param()
307 dev->gck_param = NULL; in atmel_i2s_get_gck_param()
315 dev->gck_param = gck_param; in atmel_i2s_get_gck_param()
326 struct atmel_i2s_dev *dev = snd_soc_dai_get_drvdata(dai); in atmel_i2s_hw_params() local
338 switch (dev->fmt & SND_SOC_DAIFMT_FORMAT_MASK) { in atmel_i2s_hw_params()
344 dev_err(dev->dev, "unsupported bus format\n"); in atmel_i2s_hw_params()
348 switch (dev->fmt & SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK) { in atmel_i2s_hw_params()
352 ret = atmel_i2s_get_gck_param(dev, params_rate(params)); in atmel_i2s_hw_params()
360 dev->gck_param = NULL; in atmel_i2s_hw_params()
364 dev_err(dev->dev, "unsupported master/slave mode\n"); in atmel_i2s_hw_params()
378 dev_err(dev->dev, "unsupported number of audio channels\n"); in atmel_i2s_hw_params()
412 dev_err(dev->dev, "unsupported size/endianness for audio samples\n"); in atmel_i2s_hw_params()
416 return regmap_update_bits(dev->regmap, ATMEL_I2SC_MR, mr_mask, mr); in atmel_i2s_hw_params()
419 static int atmel_i2s_switch_mck_generator(struct atmel_i2s_dev *dev, in atmel_i2s_switch_mck_generator() argument
433 ret = regmap_write(dev->regmap, ATMEL_I2SC_CR, in atmel_i2s_switch_mck_generator()
439 ret = regmap_update_bits(dev->regmap, ATMEL_I2SC_MR, in atmel_i2s_switch_mck_generator()
445 clk_disable_unprepare(dev->gclk); in atmel_i2s_switch_mck_generator()
450 if (!dev->gck_param) in atmel_i2s_switch_mck_generator()
453 gclk_rate = dev->gck_param->mck * (dev->gck_param->imckdiv + 1); in atmel_i2s_switch_mck_generator()
455 ret = clk_set_rate(dev->gclk, gclk_rate); in atmel_i2s_switch_mck_generator()
459 ret = clk_prepare_enable(dev->gclk); in atmel_i2s_switch_mck_generator()
464 mr |= ATMEL_I2SC_MR_IMCKDIV(dev->gck_param->imckdiv); in atmel_i2s_switch_mck_generator()
465 mr |= ATMEL_I2SC_MR_IMCKFS(dev->gck_param->imckfs); in atmel_i2s_switch_mck_generator()
467 ret = regmap_update_bits(dev->regmap, ATMEL_I2SC_MR, mr_mask, mr); in atmel_i2s_switch_mck_generator()
472 return regmap_write(dev->regmap, ATMEL_I2SC_CR, in atmel_i2s_switch_mck_generator()
479 struct atmel_i2s_dev *dev = snd_soc_dai_get_drvdata(dai); in atmel_i2s_trigger() local
503 err = regmap_read(dev->regmap, ATMEL_I2SC_MR, &mr); in atmel_i2s_trigger()
510 if (!dev->clk_use_no) { in atmel_i2s_trigger()
511 err = atmel_i2s_switch_mck_generator(dev, true); in atmel_i2s_trigger()
515 dev->clk_use_no++; in atmel_i2s_trigger()
518 err = regmap_write(dev->regmap, ATMEL_I2SC_CR, cr); in atmel_i2s_trigger()
524 if (dev->clk_use_no == 1) { in atmel_i2s_trigger()
525 err = atmel_i2s_switch_mck_generator(dev, false); in atmel_i2s_trigger()
529 dev->clk_use_no--; in atmel_i2s_trigger()
537 struct atmel_i2s_dev *dev = snd_soc_dai_get_drvdata(dai); in atmel_i2s_dai_probe() local
539 snd_soc_dai_init_dma_data(dai, &dev->playback, &dev->capture); in atmel_i2s_dai_probe()
574 static int atmel_i2s_sama5d2_mck_init(struct atmel_i2s_dev *dev, in atmel_i2s_sama5d2_mck_init() argument
580 if (!dev->gclk) in atmel_i2s_sama5d2_mck_init()
584 muxclk = devm_clk_get(dev->dev, "muxclk"); in atmel_i2s_sama5d2_mck_init()
589 dev_dbg(dev->dev, in atmel_i2s_sama5d2_mck_init()
594 return clk_set_parent(muxclk, dev->gclk); in atmel_i2s_sama5d2_mck_init()
614 struct device_node *np = pdev->dev.of_node; in atmel_i2s_probe()
616 struct atmel_i2s_dev *dev; in atmel_i2s_probe() local
626 dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL); in atmel_i2s_probe()
627 if (!dev) in atmel_i2s_probe()
633 dev->caps = match->data; in atmel_i2s_probe()
640 regmap = devm_regmap_init_mmio(&pdev->dev, base, in atmel_i2s_probe()
650 err = devm_request_irq(&pdev->dev, irq, atmel_i2s_interrupt, 0, in atmel_i2s_probe()
651 dev_name(&pdev->dev), dev); in atmel_i2s_probe()
656 dev->pclk = devm_clk_get(&pdev->dev, "pclk"); in atmel_i2s_probe()
657 if (IS_ERR(dev->pclk)) { in atmel_i2s_probe()
658 err = PTR_ERR(dev->pclk); in atmel_i2s_probe()
659 dev_err(&pdev->dev, in atmel_i2s_probe()
665 dev->gclk = devm_clk_get(&pdev->dev, "gclk"); in atmel_i2s_probe()
666 if (IS_ERR(dev->gclk)) { in atmel_i2s_probe()
667 if (PTR_ERR(dev->gclk) == -EPROBE_DEFER) in atmel_i2s_probe()
670 dev->gclk = NULL; in atmel_i2s_probe()
672 dev->dev = &pdev->dev; in atmel_i2s_probe()
673 dev->regmap = regmap; in atmel_i2s_probe()
674 platform_set_drvdata(pdev, dev); in atmel_i2s_probe()
677 if (dev->caps && dev->caps->mck_init) { in atmel_i2s_probe()
678 err = dev->caps->mck_init(dev, np); in atmel_i2s_probe()
684 err = clk_prepare_enable(dev->pclk); in atmel_i2s_probe()
689 regmap_read(dev->regmap, ATMEL_I2SC_VERSION, &version); in atmel_i2s_probe()
690 dev_info(&pdev->dev, "hw version: %#x\n", version); in atmel_i2s_probe()
693 regmap_write(dev->regmap, ATMEL_I2SC_IER, in atmel_i2s_probe()
696 err = devm_snd_soc_register_component(&pdev->dev, in atmel_i2s_probe()
700 dev_err(&pdev->dev, "failed to register DAI: %d\n", err); in atmel_i2s_probe()
701 clk_disable_unprepare(dev->pclk); in atmel_i2s_probe()
706 dev->playback.addr = (dma_addr_t)mem->start + ATMEL_I2SC_THR; in atmel_i2s_probe()
707 dev->playback.maxburst = 1; in atmel_i2s_probe()
708 dev->capture.addr = (dma_addr_t)mem->start + ATMEL_I2SC_RHR; in atmel_i2s_probe()
709 dev->capture.maxburst = 1; in atmel_i2s_probe()
713 err = devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, pcm_flags); in atmel_i2s_probe()
715 dev_err(&pdev->dev, "failed to register PCM: %d\n", err); in atmel_i2s_probe()
716 clk_disable_unprepare(dev->pclk); in atmel_i2s_probe()
725 struct atmel_i2s_dev *dev = platform_get_drvdata(pdev); in atmel_i2s_remove() local
727 clk_disable_unprepare(dev->pclk); in atmel_i2s_remove()