kirkwood-i2s.c (3ccdf5bbdf5f2488e4a36692d055ba9c43ae6717) kirkwood-i2s.c (dbc517bf32985f2438ff706204a6dd1476b3dc98)
1/*
2 * kirkwood-i2s.c
3 *
4 * (c) 2010 Arnaud Patard <apatard@mandriva.com>
5 * (c) 2010 Arnaud Patard <arnaud.patard@rtp-net.org>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the

--- 392 unchanged lines hidden (view full) ---

401static __devinit int kirkwood_i2s_dev_probe(struct platform_device *pdev)
402{
403 struct resource *mem;
404 struct kirkwood_asoc_platform_data *data =
405 pdev->dev.platform_data;
406 struct kirkwood_dma_data *priv;
407 int err;
408
1/*
2 * kirkwood-i2s.c
3 *
4 * (c) 2010 Arnaud Patard <apatard@mandriva.com>
5 * (c) 2010 Arnaud Patard <arnaud.patard@rtp-net.org>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the

--- 392 unchanged lines hidden (view full) ---

401static __devinit int kirkwood_i2s_dev_probe(struct platform_device *pdev)
402{
403 struct resource *mem;
404 struct kirkwood_asoc_platform_data *data =
405 pdev->dev.platform_data;
406 struct kirkwood_dma_data *priv;
407 int err;
408
409 priv = kzalloc(sizeof(struct kirkwood_dma_data), GFP_KERNEL);
409 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
410 if (!priv) {
411 dev_err(&pdev->dev, "allocation failed\n");
410 if (!priv) {
411 dev_err(&pdev->dev, "allocation failed\n");
412 err = -ENOMEM;
413 goto error;
412 return -ENOMEM;
414 }
415 dev_set_drvdata(&pdev->dev, priv);
416
417 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
418 if (!mem) {
419 dev_err(&pdev->dev, "platform_get_resource failed\n");
413 }
414 dev_set_drvdata(&pdev->dev, priv);
415
416 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
417 if (!mem) {
418 dev_err(&pdev->dev, "platform_get_resource failed\n");
420 err = -ENXIO;
421 goto err_alloc;
419 return -ENXIO;
422 }
423
420 }
421
424 priv->mem = request_mem_region(mem->start, SZ_16K, DRV_NAME);
425 if (!priv->mem) {
426 dev_err(&pdev->dev, "request_mem_region failed\n");
427 err = -EBUSY;
428 goto err_alloc;
429 }
430
431 priv->io = ioremap(priv->mem->start, SZ_16K);
422 priv->io = devm_request_and_ioremap(&pdev->dev, mem);
432 if (!priv->io) {
423 if (!priv->io) {
433 dev_err(&pdev->dev, "ioremap failed\n");
434 err = -ENOMEM;
435 goto err_iomem;
424 dev_err(&pdev->dev, "devm_request_and_ioremap failed\n");
425 return -ENOMEM;
436 }
437
438 priv->irq = platform_get_irq(pdev, 0);
439 if (priv->irq <= 0) {
440 dev_err(&pdev->dev, "platform_get_irq failed\n");
426 }
427
428 priv->irq = platform_get_irq(pdev, 0);
429 if (priv->irq <= 0) {
430 dev_err(&pdev->dev, "platform_get_irq failed\n");
441 err = -ENXIO;
442 goto err_ioremap;
431 return -ENXIO;
443 }
444
445 if (!data) {
446 dev_err(&pdev->dev, "no platform data ?!\n");
432 }
433
434 if (!data) {
435 dev_err(&pdev->dev, "no platform data ?!\n");
447 err = -EINVAL;
448 goto err_ioremap;
436 return -EINVAL;
449 }
450
451 priv->burst = data->burst;
452
437 }
438
439 priv->burst = data->burst;
440
453 priv->clk = clk_get(&pdev->dev, NULL);
441 priv->clk = devm_clk_get(&pdev->dev, NULL);
454 if (IS_ERR(priv->clk)) {
455 dev_err(&pdev->dev, "no clock\n");
442 if (IS_ERR(priv->clk)) {
443 dev_err(&pdev->dev, "no clock\n");
456 err = PTR_ERR(priv->clk);
457 goto err_ioremap;
444 return PTR_ERR(priv->clk);
458 }
445 }
459 clk_prepare_enable(priv->clk);
460
446
447 err = clk_prepare_enable(priv->clk);
448 if (err < 0)
449 return err;
450
461 err = snd_soc_register_dai(&pdev->dev, &kirkwood_i2s_dai);
462 if (!err)
463 return 0;
464 dev_err(&pdev->dev, "snd_soc_register_dai failed\n");
465
466 clk_disable_unprepare(priv->clk);
451 err = snd_soc_register_dai(&pdev->dev, &kirkwood_i2s_dai);
452 if (!err)
453 return 0;
454 dev_err(&pdev->dev, "snd_soc_register_dai failed\n");
455
456 clk_disable_unprepare(priv->clk);
467 clk_put(priv->clk);
468
457
469err_ioremap:
470 iounmap(priv->io);
471err_iomem:
472 release_mem_region(priv->mem->start, SZ_16K);
473err_alloc:
474 kfree(priv);
475error:
476 return err;
477}
478
479static __devexit int kirkwood_i2s_dev_remove(struct platform_device *pdev)
480{
481 struct kirkwood_dma_data *priv = dev_get_drvdata(&pdev->dev);
482
483 snd_soc_unregister_dai(&pdev->dev);
484
485 clk_disable_unprepare(priv->clk);
458 return err;
459}
460
461static __devexit int kirkwood_i2s_dev_remove(struct platform_device *pdev)
462{
463 struct kirkwood_dma_data *priv = dev_get_drvdata(&pdev->dev);
464
465 snd_soc_unregister_dai(&pdev->dev);
466
467 clk_disable_unprepare(priv->clk);
486 clk_put(priv->clk);
487
468
488 iounmap(priv->io);
489 release_mem_region(priv->mem->start, SZ_16K);
490 kfree(priv);
491
492 return 0;
493}
494
495static struct platform_driver kirkwood_i2s_driver = {
496 .probe = kirkwood_i2s_dev_probe,
497 .remove = __devexit_p(kirkwood_i2s_dev_remove),
498 .driver = {
499 .name = DRV_NAME,
500 .owner = THIS_MODULE,
501 },
502};
503
504module_platform_driver(kirkwood_i2s_driver);
505
506/* Module information */
507MODULE_AUTHOR("Arnaud Patard, <arnaud.patard@rtp-net.org>");
508MODULE_DESCRIPTION("Kirkwood I2S SoC Interface");
509MODULE_LICENSE("GPL");
510MODULE_ALIAS("platform:kirkwood-i2s");
469 return 0;
470}
471
472static struct platform_driver kirkwood_i2s_driver = {
473 .probe = kirkwood_i2s_dev_probe,
474 .remove = __devexit_p(kirkwood_i2s_dev_remove),
475 .driver = {
476 .name = DRV_NAME,
477 .owner = THIS_MODULE,
478 },
479};
480
481module_platform_driver(kirkwood_i2s_driver);
482
483/* Module information */
484MODULE_AUTHOR("Arnaud Patard, <arnaud.patard@rtp-net.org>");
485MODULE_DESCRIPTION("Kirkwood I2S SoC Interface");
486MODULE_LICENSE("GPL");
487MODULE_ALIAS("platform:kirkwood-i2s");