wm8731.c (22d22ee5146ae823b1e93fe2887a7cba56015091) | wm8731.c (a8035c8f04477895207b92915b908344749be336) |
---|---|
1/* 2 * wm8731.c -- WM8731 ALSA SoC Audio driver 3 * 4 * Copyright 2005 Openedhand Ltd. 5 * 6 * Author: Richard Purdie <richard@openedhand.com> 7 * 8 * Based on wm8753.c by Liam Girdwood --- 22 unchanged lines hidden (view full) --- 31 32struct snd_soc_codec_device soc_codec_dev_wm8731; 33 34/* codec private data */ 35struct wm8731_priv { 36 unsigned int sysclk; 37}; 38 | 1/* 2 * wm8731.c -- WM8731 ALSA SoC Audio driver 3 * 4 * Copyright 2005 Openedhand Ltd. 5 * 6 * Author: Richard Purdie <richard@openedhand.com> 7 * 8 * Based on wm8753.c by Liam Girdwood --- 22 unchanged lines hidden (view full) --- 31 32struct snd_soc_codec_device soc_codec_dev_wm8731; 33 34/* codec private data */ 35struct wm8731_priv { 36 unsigned int sysclk; 37}; 38 |
39#ifdef CONFIG_SPI_MASTER 40static int wm8731_spi_write(struct spi_device *spi, const char *data, int len); 41static struct spi_driver wm8731_spi_driver; 42#endif 43 |
|
39/* 40 * wm8731 register cache 41 * We can't read the WM8731 register space when we are 42 * using 2 wire for device control, so we cache them instead. 43 * There is no point in caching the reset register 44 */ 45static const u16 wm8731_reg[WM8731_CACHEREGNUM] = { 46 0x0097, 0x0097, 0x0079, 0x0079, --- 492 unchanged lines hidden (view full) --- 539 snd_soc_dapm_free(socdev); 540pcm_err: 541 kfree(codec->reg_cache); 542 return ret; 543} 544 545static struct snd_soc_device *wm8731_socdev; 546 | 44/* 45 * wm8731 register cache 46 * We can't read the WM8731 register space when we are 47 * using 2 wire for device control, so we cache them instead. 48 * There is no point in caching the reset register 49 */ 50static const u16 wm8731_reg[WM8731_CACHEREGNUM] = { 51 0x0097, 0x0097, 0x0079, 0x0079, --- 492 unchanged lines hidden (view full) --- 544 snd_soc_dapm_free(socdev); 545pcm_err: 546 kfree(codec->reg_cache); 547 return ret; 548} 549 550static struct snd_soc_device *wm8731_socdev; 551 |
552 |
|
547#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 553#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) |
554static struct i2c_driver wm8731_i2c_driver; |
|
548 | 555 |
549/* 550 * WM8731 2 wire address is determined by GPIO5 551 * state during powerup. 552 * low = 0x1a 553 * high = 0x1b 554 */ 555 556static int wm8731_i2c_probe(struct i2c_client *i2c, 557 const struct i2c_device_id *id) 558{ 559 struct snd_soc_device *socdev = wm8731_socdev; 560 struct snd_soc_codec *codec = socdev->card->codec; 561 int ret; 562 563 i2c_set_clientdata(i2c, codec); 564 codec->control_data = i2c; 565 566 ret = wm8731_init(socdev); 567 if (ret < 0) 568 pr_err("failed to initialise WM8731\n"); 569 570 return ret; 571} 572 573static int wm8731_i2c_remove(struct i2c_client *client) 574{ 575 struct snd_soc_codec *codec = i2c_get_clientdata(client); 576 kfree(codec->reg_cache); 577 return 0; 578} 579 580static const struct i2c_device_id wm8731_i2c_id[] = { 581 { "wm8731", 0 }, 582 { } 583}; 584MODULE_DEVICE_TABLE(i2c, wm8731_i2c_id); 585 586static struct i2c_driver wm8731_i2c_driver = { 587 .driver = { 588 .name = "WM8731 I2C Codec", 589 .owner = THIS_MODULE, 590 }, 591 .probe = wm8731_i2c_probe, 592 .remove = wm8731_i2c_remove, 593 .id_table = wm8731_i2c_id, 594}; 595 | |
596static int wm8731_add_i2c_device(struct platform_device *pdev, 597 const struct wm8731_setup_data *setup) 598{ 599 struct i2c_board_info info; 600 struct i2c_adapter *adapter; 601 struct i2c_client *client; 602 int ret; 603 --- 25 unchanged lines hidden (view full) --- 629 return 0; 630 631err_driver: 632 i2c_del_driver(&wm8731_i2c_driver); 633 return -ENODEV; 634} 635#endif 636 | 556static int wm8731_add_i2c_device(struct platform_device *pdev, 557 const struct wm8731_setup_data *setup) 558{ 559 struct i2c_board_info info; 560 struct i2c_adapter *adapter; 561 struct i2c_client *client; 562 int ret; 563 --- 25 unchanged lines hidden (view full) --- 589 return 0; 590 591err_driver: 592 i2c_del_driver(&wm8731_i2c_driver); 593 return -ENODEV; 594} 595#endif 596 |
637#if defined(CONFIG_SPI_MASTER) 638static int __devinit wm8731_spi_probe(struct spi_device *spi) 639{ 640 struct snd_soc_device *socdev = wm8731_socdev; 641 struct snd_soc_codec *codec = socdev->card->codec; 642 int ret; 643 644 codec->control_data = spi; 645 646 ret = wm8731_init(socdev); 647 if (ret < 0) 648 dev_err(&spi->dev, "failed to initialise WM8731\n"); 649 650 return ret; 651} 652 653static int __devexit wm8731_spi_remove(struct spi_device *spi) 654{ 655 return 0; 656} 657 658static struct spi_driver wm8731_spi_driver = { 659 .driver = { 660 .name = "wm8731", 661 .bus = &spi_bus_type, 662 .owner = THIS_MODULE, 663 }, 664 .probe = wm8731_spi_probe, 665 .remove = __devexit_p(wm8731_spi_remove), 666}; 667 668static int wm8731_spi_write(struct spi_device *spi, const char *data, int len) 669{ 670 struct spi_transfer t; 671 struct spi_message m; 672 u8 msg[2]; 673 674 if (len <= 0) 675 return 0; 676 677 msg[0] = data[0]; 678 msg[1] = data[1]; 679 680 spi_message_init(&m); 681 memset(&t, 0, (sizeof t)); 682 683 t.tx_buf = &msg[0]; 684 t.len = len; 685 686 spi_message_add_tail(&t, &m); 687 spi_sync(spi, &m); 688 689 return len; 690} 691#endif /* CONFIG_SPI_MASTER */ 692 | |
693static int wm8731_probe(struct platform_device *pdev) 694{ 695 struct snd_soc_device *socdev = platform_get_drvdata(pdev); 696 struct wm8731_setup_data *setup; 697 struct snd_soc_codec *codec; 698 struct wm8731_priv *wm8731; 699 int ret = 0; 700 --- 66 unchanged lines hidden (view full) --- 767struct snd_soc_codec_device soc_codec_dev_wm8731 = { 768 .probe = wm8731_probe, 769 .remove = wm8731_remove, 770 .suspend = wm8731_suspend, 771 .resume = wm8731_resume, 772}; 773EXPORT_SYMBOL_GPL(soc_codec_dev_wm8731); 774 | 597static int wm8731_probe(struct platform_device *pdev) 598{ 599 struct snd_soc_device *socdev = platform_get_drvdata(pdev); 600 struct wm8731_setup_data *setup; 601 struct snd_soc_codec *codec; 602 struct wm8731_priv *wm8731; 603 int ret = 0; 604 --- 66 unchanged lines hidden (view full) --- 671struct snd_soc_codec_device soc_codec_dev_wm8731 = { 672 .probe = wm8731_probe, 673 .remove = wm8731_remove, 674 .suspend = wm8731_suspend, 675 .resume = wm8731_resume, 676}; 677EXPORT_SYMBOL_GPL(soc_codec_dev_wm8731); 678 |
679#if defined(CONFIG_SPI_MASTER) 680static int __devinit wm8731_spi_probe(struct spi_device *spi) 681{ 682 struct snd_soc_device *socdev = wm8731_socdev; 683 struct snd_soc_codec *codec = socdev->card->codec; 684 int ret; 685 686 codec->control_data = spi; 687 688 ret = wm8731_init(socdev); 689 if (ret < 0) 690 dev_err(&spi->dev, "failed to initialise WM8731\n"); 691 692 return ret; 693} 694 695static int __devexit wm8731_spi_remove(struct spi_device *spi) 696{ 697 return 0; 698} 699 700static struct spi_driver wm8731_spi_driver = { 701 .driver = { 702 .name = "wm8731", 703 .bus = &spi_bus_type, 704 .owner = THIS_MODULE, 705 }, 706 .probe = wm8731_spi_probe, 707 .remove = __devexit_p(wm8731_spi_remove), 708}; 709 710static int wm8731_spi_write(struct spi_device *spi, const char *data, int len) 711{ 712 struct spi_transfer t; 713 struct spi_message m; 714 u8 msg[2]; 715 716 if (len <= 0) 717 return 0; 718 719 msg[0] = data[0]; 720 msg[1] = data[1]; 721 722 spi_message_init(&m); 723 memset(&t, 0, (sizeof t)); 724 725 t.tx_buf = &msg[0]; 726 t.len = len; 727 728 spi_message_add_tail(&t, &m); 729 spi_sync(spi, &m); 730 731 return len; 732} 733#endif /* CONFIG_SPI_MASTER */ 734 735#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 736/* 737 * WM8731 2 wire address is determined by GPIO5 738 * state during powerup. 739 * low = 0x1a 740 * high = 0x1b 741 */ 742 743static int wm8731_i2c_probe(struct i2c_client *i2c, 744 const struct i2c_device_id *id) 745{ 746 struct snd_soc_device *socdev = wm8731_socdev; 747 struct snd_soc_codec *codec = socdev->card->codec; 748 int ret; 749 750 i2c_set_clientdata(i2c, codec); 751 codec->control_data = i2c; 752 753 ret = wm8731_init(socdev); 754 if (ret < 0) 755 pr_err("failed to initialise WM8731\n"); 756 757 return ret; 758} 759 760static int wm8731_i2c_remove(struct i2c_client *client) 761{ 762 struct snd_soc_codec *codec = i2c_get_clientdata(client); 763 kfree(codec->reg_cache); 764 return 0; 765} 766 767static const struct i2c_device_id wm8731_i2c_id[] = { 768 { "wm8731", 0 }, 769 { } 770}; 771MODULE_DEVICE_TABLE(i2c, wm8731_i2c_id); 772 773static struct i2c_driver wm8731_i2c_driver = { 774 .driver = { 775 .name = "WM8731 I2C Codec", 776 .owner = THIS_MODULE, 777 }, 778 .probe = wm8731_i2c_probe, 779 .remove = wm8731_i2c_remove, 780 .id_table = wm8731_i2c_id, 781}; 782#endif 783 |
|
775static int __init wm8731_modinit(void) 776{ 777 return snd_soc_register_dai(&wm8731_dai); 778} 779module_init(wm8731_modinit); 780 781static void __exit wm8731_exit(void) 782{ 783 snd_soc_unregister_dai(&wm8731_dai); 784} 785module_exit(wm8731_exit); 786 787MODULE_DESCRIPTION("ASoC WM8731 driver"); 788MODULE_AUTHOR("Richard Purdie"); 789MODULE_LICENSE("GPL"); | 784static int __init wm8731_modinit(void) 785{ 786 return snd_soc_register_dai(&wm8731_dai); 787} 788module_init(wm8731_modinit); 789 790static void __exit wm8731_exit(void) 791{ 792 snd_soc_unregister_dai(&wm8731_dai); 793} 794module_exit(wm8731_exit); 795 796MODULE_DESCRIPTION("ASoC WM8731 driver"); 797MODULE_AUTHOR("Richard Purdie"); 798MODULE_LICENSE("GPL"); |