diff options
author | Mark Brown <broonie@kernel.org> | 2016-01-11 08:54:39 -0500 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2016-01-11 08:54:39 -0500 |
commit | d5221ab6b289da82dcf73b475aaee6a3da5c4ca5 (patch) | |
tree | 4d5a9e0b928a19af5368ba6172b30a43a2b18545 | |
parent | 5450487a0954f87607b14d52a71d44c147d2d0d5 (diff) | |
parent | 3ae08dc0fc805bc15c5629f9794599c1171dc571 (diff) |
Merge remote-tracking branch 'asoc/topic/rt5651' into asoc-next
-rw-r--r-- | Documentation/devicetree/bindings/sound/rt5651.txt | 41 | ||||
-rw-r--r-- | sound/soc/codecs/rt5651.c | 31 |
2 files changed, 72 insertions, 0 deletions
diff --git a/Documentation/devicetree/bindings/sound/rt5651.txt b/Documentation/devicetree/bindings/sound/rt5651.txt new file mode 100644 index 000000000000..3875233095f5 --- /dev/null +++ b/Documentation/devicetree/bindings/sound/rt5651.txt | |||
@@ -0,0 +1,41 @@ | |||
1 | RT5651 audio CODEC | ||
2 | |||
3 | This device supports I2C only. | ||
4 | |||
5 | Required properties: | ||
6 | |||
7 | - compatible : "realtek,rt5651". | ||
8 | |||
9 | - reg : The I2C address of the device. | ||
10 | |||
11 | Optional properties: | ||
12 | |||
13 | - realtek,in2-differential | ||
14 | Boolean. Indicate MIC2 input are differential, rather than single-ended. | ||
15 | |||
16 | - realtek,dmic-en | ||
17 | Boolean. true if dmic is used. | ||
18 | |||
19 | Pins on the device (for linking into audio routes) for RT5651: | ||
20 | |||
21 | * DMIC L1 | ||
22 | * DMIC R1 | ||
23 | * IN1P | ||
24 | * IN2P | ||
25 | * IN2N | ||
26 | * IN3P | ||
27 | * HPOL | ||
28 | * HPOR | ||
29 | * LOUTL | ||
30 | * LOUTR | ||
31 | * PDML | ||
32 | * PDMR | ||
33 | |||
34 | Example: | ||
35 | |||
36 | codec: rt5651@1a { | ||
37 | compatible = "realtek,rt5651"; | ||
38 | reg = <0x1a>; | ||
39 | realtek,dmic-en = "true"; | ||
40 | realtek,in2-diff = "false"; | ||
41 | }; | ||
diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index 1d4031818966..7a6197042423 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/regmap.h> | 18 | #include <linux/regmap.h> |
19 | #include <linux/platform_device.h> | 19 | #include <linux/platform_device.h> |
20 | #include <linux/spi/spi.h> | 20 | #include <linux/spi/spi.h> |
21 | #include <linux/acpi.h> | ||
21 | #include <sound/core.h> | 22 | #include <sound/core.h> |
22 | #include <sound/pcm.h> | 23 | #include <sound/pcm.h> |
23 | #include <sound/pcm_params.h> | 24 | #include <sound/pcm_params.h> |
@@ -1735,12 +1736,38 @@ static const struct regmap_config rt5651_regmap = { | |||
1735 | .num_ranges = ARRAY_SIZE(rt5651_ranges), | 1736 | .num_ranges = ARRAY_SIZE(rt5651_ranges), |
1736 | }; | 1737 | }; |
1737 | 1738 | ||
1739 | #if defined(CONFIG_OF) | ||
1740 | static const struct of_device_id rt5651_of_match[] = { | ||
1741 | { .compatible = "realtek,rt5651", }, | ||
1742 | {}, | ||
1743 | }; | ||
1744 | MODULE_DEVICE_TABLE(of, rt5651_of_match); | ||
1745 | #endif | ||
1746 | |||
1747 | #ifdef CONFIG_ACPI | ||
1748 | static const struct acpi_device_id rt5651_acpi_match[] = { | ||
1749 | { "10EC5651", 0 }, | ||
1750 | { }, | ||
1751 | }; | ||
1752 | MODULE_DEVICE_TABLE(acpi, rt5651_acpi_match); | ||
1753 | #endif | ||
1754 | |||
1738 | static const struct i2c_device_id rt5651_i2c_id[] = { | 1755 | static const struct i2c_device_id rt5651_i2c_id[] = { |
1739 | { "rt5651", 0 }, | 1756 | { "rt5651", 0 }, |
1740 | { } | 1757 | { } |
1741 | }; | 1758 | }; |
1742 | MODULE_DEVICE_TABLE(i2c, rt5651_i2c_id); | 1759 | MODULE_DEVICE_TABLE(i2c, rt5651_i2c_id); |
1743 | 1760 | ||
1761 | static int rt5651_parse_dt(struct rt5651_priv *rt5651, struct device_node *np) | ||
1762 | { | ||
1763 | rt5651->pdata.in2_diff = of_property_read_bool(np, | ||
1764 | "realtek,in2-differential"); | ||
1765 | rt5651->pdata.dmic_en = of_property_read_bool(np, | ||
1766 | "realtek,dmic-en"); | ||
1767 | |||
1768 | return 0; | ||
1769 | } | ||
1770 | |||
1744 | static int rt5651_i2c_probe(struct i2c_client *i2c, | 1771 | static int rt5651_i2c_probe(struct i2c_client *i2c, |
1745 | const struct i2c_device_id *id) | 1772 | const struct i2c_device_id *id) |
1746 | { | 1773 | { |
@@ -1757,6 +1784,8 @@ static int rt5651_i2c_probe(struct i2c_client *i2c, | |||
1757 | 1784 | ||
1758 | if (pdata) | 1785 | if (pdata) |
1759 | rt5651->pdata = *pdata; | 1786 | rt5651->pdata = *pdata; |
1787 | else if (i2c->dev.of_node) | ||
1788 | rt5651_parse_dt(rt5651, i2c->dev.of_node); | ||
1760 | 1789 | ||
1761 | rt5651->regmap = devm_regmap_init_i2c(i2c, &rt5651_regmap); | 1790 | rt5651->regmap = devm_regmap_init_i2c(i2c, &rt5651_regmap); |
1762 | if (IS_ERR(rt5651->regmap)) { | 1791 | if (IS_ERR(rt5651->regmap)) { |
@@ -1806,6 +1835,8 @@ static int rt5651_i2c_remove(struct i2c_client *i2c) | |||
1806 | static struct i2c_driver rt5651_i2c_driver = { | 1835 | static struct i2c_driver rt5651_i2c_driver = { |
1807 | .driver = { | 1836 | .driver = { |
1808 | .name = "rt5651", | 1837 | .name = "rt5651", |
1838 | .acpi_match_table = ACPI_PTR(rt5651_acpi_match), | ||
1839 | .of_match_table = of_match_ptr(rt5651_of_match), | ||
1809 | }, | 1840 | }, |
1810 | .probe = rt5651_i2c_probe, | 1841 | .probe = rt5651_i2c_probe, |
1811 | .remove = rt5651_i2c_remove, | 1842 | .remove = rt5651_i2c_remove, |