diff options
Diffstat (limited to 'sound/soc/codecs/wm8753.c')
-rw-r--r-- | sound/soc/codecs/wm8753.c | 75 |
1 files changed, 70 insertions, 5 deletions
diff --git a/sound/soc/codecs/wm8753.c b/sound/soc/codecs/wm8753.c index 8c4df44f3345..d426eaa22185 100644 --- a/sound/soc/codecs/wm8753.c +++ b/sound/soc/codecs/wm8753.c | |||
@@ -2,8 +2,7 @@ | |||
2 | * wm8753.c -- WM8753 ALSA Soc Audio driver | 2 | * wm8753.c -- WM8753 ALSA Soc Audio driver |
3 | * | 3 | * |
4 | * Copyright 2003 Wolfson Microelectronics PLC. | 4 | * Copyright 2003 Wolfson Microelectronics PLC. |
5 | * Author: Liam Girdwood | 5 | * Author: Liam Girdwood <lrg@slimlogic.co.uk> |
6 | * liam.girdwood@wolfsonmicro.com or linux@wolfsonmicro.com | ||
7 | * | 6 | * |
8 | * This program is free software; you can redistribute it and/or modify it | 7 | * This program is free software; you can redistribute it and/or modify it |
9 | * under the terms of the GNU General Public License as published by the | 8 | * under the terms of the GNU General Public License as published by the |
@@ -40,6 +39,7 @@ | |||
40 | #include <linux/pm.h> | 39 | #include <linux/pm.h> |
41 | #include <linux/i2c.h> | 40 | #include <linux/i2c.h> |
42 | #include <linux/platform_device.h> | 41 | #include <linux/platform_device.h> |
42 | #include <linux/spi/spi.h> | ||
43 | #include <sound/core.h> | 43 | #include <sound/core.h> |
44 | #include <sound/pcm.h> | 44 | #include <sound/pcm.h> |
45 | #include <sound/pcm_params.h> | 45 | #include <sound/pcm_params.h> |
@@ -51,7 +51,6 @@ | |||
51 | 51 | ||
52 | #include "wm8753.h" | 52 | #include "wm8753.h" |
53 | 53 | ||
54 | #define AUDIO_NAME "wm8753" | ||
55 | #define WM8753_VERSION "0.16" | 54 | #define WM8753_VERSION "0.16" |
56 | 55 | ||
57 | static int caps_charge = 2000; | 56 | static int caps_charge = 2000; |
@@ -1719,6 +1718,63 @@ err_driver: | |||
1719 | } | 1718 | } |
1720 | #endif | 1719 | #endif |
1721 | 1720 | ||
1721 | #if defined(CONFIG_SPI_MASTER) | ||
1722 | static int __devinit wm8753_spi_probe(struct spi_device *spi) | ||
1723 | { | ||
1724 | struct snd_soc_device *socdev = wm8753_socdev; | ||
1725 | struct snd_soc_codec *codec = socdev->codec; | ||
1726 | int ret; | ||
1727 | |||
1728 | codec->control_data = spi; | ||
1729 | |||
1730 | ret = wm8753_init(socdev); | ||
1731 | if (ret < 0) | ||
1732 | dev_err(&spi->dev, "failed to initialise WM8753\n"); | ||
1733 | |||
1734 | return ret; | ||
1735 | } | ||
1736 | |||
1737 | static int __devexit wm8753_spi_remove(struct spi_device *spi) | ||
1738 | { | ||
1739 | return 0; | ||
1740 | } | ||
1741 | |||
1742 | static struct spi_driver wm8753_spi_driver = { | ||
1743 | .driver = { | ||
1744 | .name = "wm8753", | ||
1745 | .bus = &spi_bus_type, | ||
1746 | .owner = THIS_MODULE, | ||
1747 | }, | ||
1748 | .probe = wm8753_spi_probe, | ||
1749 | .remove = __devexit_p(wm8753_spi_remove), | ||
1750 | }; | ||
1751 | |||
1752 | static int wm8753_spi_write(struct spi_device *spi, const char *data, int len) | ||
1753 | { | ||
1754 | struct spi_transfer t; | ||
1755 | struct spi_message m; | ||
1756 | u8 msg[2]; | ||
1757 | |||
1758 | if (len <= 0) | ||
1759 | return 0; | ||
1760 | |||
1761 | msg[0] = data[0]; | ||
1762 | msg[1] = data[1]; | ||
1763 | |||
1764 | spi_message_init(&m); | ||
1765 | memset(&t, 0, (sizeof t)); | ||
1766 | |||
1767 | t.tx_buf = &msg[0]; | ||
1768 | t.len = len; | ||
1769 | |||
1770 | spi_message_add_tail(&t, &m); | ||
1771 | spi_sync(spi, &m); | ||
1772 | |||
1773 | return len; | ||
1774 | } | ||
1775 | #endif | ||
1776 | |||
1777 | |||
1722 | static int wm8753_probe(struct platform_device *pdev) | 1778 | static int wm8753_probe(struct platform_device *pdev) |
1723 | { | 1779 | { |
1724 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | 1780 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); |
@@ -1753,8 +1809,14 @@ static int wm8753_probe(struct platform_device *pdev) | |||
1753 | codec->hw_write = (hw_write_t)i2c_master_send; | 1809 | codec->hw_write = (hw_write_t)i2c_master_send; |
1754 | ret = wm8753_add_i2c_device(pdev, setup); | 1810 | ret = wm8753_add_i2c_device(pdev, setup); |
1755 | } | 1811 | } |
1756 | #else | 1812 | #endif |
1757 | /* Add other interfaces here */ | 1813 | #if defined(CONFIG_SPI_MASTER) |
1814 | if (setup->spi) { | ||
1815 | codec->hw_write = (hw_write_t)wm8753_spi_write; | ||
1816 | ret = spi_register_driver(&wm8753_spi_driver); | ||
1817 | if (ret != 0) | ||
1818 | printk(KERN_ERR "can't add spi driver"); | ||
1819 | } | ||
1758 | #endif | 1820 | #endif |
1759 | 1821 | ||
1760 | if (ret != 0) { | 1822 | if (ret != 0) { |
@@ -1798,6 +1860,9 @@ static int wm8753_remove(struct platform_device *pdev) | |||
1798 | i2c_unregister_device(codec->control_data); | 1860 | i2c_unregister_device(codec->control_data); |
1799 | i2c_del_driver(&wm8753_i2c_driver); | 1861 | i2c_del_driver(&wm8753_i2c_driver); |
1800 | #endif | 1862 | #endif |
1863 | #if defined(CONFIG_SPI_MASTER) | ||
1864 | spi_unregister_driver(&wm8753_spi_driver); | ||
1865 | #endif | ||
1801 | kfree(codec->private_data); | 1866 | kfree(codec->private_data); |
1802 | kfree(codec); | 1867 | kfree(codec); |
1803 | 1868 | ||