diff options
author | Bard Liao <bardliao@realtek.com> | 2015-12-23 05:24:09 -0500 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2015-12-23 07:21:14 -0500 |
commit | 3ae08dc0fc805bc15c5629f9794599c1171dc571 (patch) | |
tree | 8e414baccd6e120f04c0147a160837545ca6e422 /sound | |
parent | 8005c49d9aea74d382f474ce11afbbc7d7130bec (diff) |
ASoC: rt5651: add ACPI and OF support
Add required tables and the binding document for ACPI and OF matching.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Bard Liao <bardliao@realtek.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/soc/codecs/rt5651.c | 31 |
1 files changed, 31 insertions, 0 deletions
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, |