aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Zhang <benzh@chromium.org>2015-06-22 14:13:00 -0400
committerMark Brown <broonie@kernel.org>2015-07-07 08:34:03 -0400
commit9bfde72157036f4eaa44f3e8982217ce1b3e14b6 (patch)
tree5c162a1f043e5ad803431007dc3dfa98e2ace299
parentefd901ee4bc8312e3bbf5561fdab8e3765e26334 (diff)
ASoC: rt5677: Switch to use unified device property API
This patch makes the driver use the unified device property API so that platform data can be provided by Device Tree, ACPI or board files. Signed-off-by: Ben Zhang <benzh@chromium.org> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--sound/soc/codecs/rt5677.c57
1 files changed, 25 insertions, 32 deletions
diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c
index 232243009e1e..13b871f11023 100644
--- a/sound/soc/codecs/rt5677.c
+++ b/sound/soc/codecs/rt5677.c
@@ -20,6 +20,7 @@
20#include <linux/platform_device.h> 20#include <linux/platform_device.h>
21#include <linux/spi/spi.h> 21#include <linux/spi/spi.h>
22#include <linux/firmware.h> 22#include <linux/firmware.h>
23#include <linux/property.h>
23#include <sound/core.h> 24#include <sound/core.h>
24#include <sound/pcm.h> 25#include <sound/pcm.h>
25#include <sound/pcm_params.h> 26#include <sound/pcm_params.h>
@@ -5021,27 +5022,29 @@ static const struct i2c_device_id rt5677_i2c_id[] = {
5021}; 5022};
5022MODULE_DEVICE_TABLE(i2c, rt5677_i2c_id); 5023MODULE_DEVICE_TABLE(i2c, rt5677_i2c_id);
5023 5024
5024static int rt5677_parse_dt(struct rt5677_priv *rt5677, struct device_node *np) 5025static void rt5677_read_device_properties(struct rt5677_priv *rt5677,
5026 struct device *dev)
5025{ 5027{
5026 rt5677->pdata.in1_diff = of_property_read_bool(np, 5028 rt5677->pdata.in1_diff = device_property_read_bool(dev,
5027 "realtek,in1-differential"); 5029 "realtek,in1-differential");
5028 rt5677->pdata.in2_diff = of_property_read_bool(np, 5030 rt5677->pdata.in2_diff = device_property_read_bool(dev,
5029 "realtek,in2-differential"); 5031 "realtek,in2-differential");
5030 rt5677->pdata.lout1_diff = of_property_read_bool(np, 5032 rt5677->pdata.lout1_diff = device_property_read_bool(dev,
5031 "realtek,lout1-differential"); 5033 "realtek,lout1-differential");
5032 rt5677->pdata.lout2_diff = of_property_read_bool(np, 5034 rt5677->pdata.lout2_diff = device_property_read_bool(dev,
5033 "realtek,lout2-differential"); 5035 "realtek,lout2-differential");
5034 rt5677->pdata.lout3_diff = of_property_read_bool(np, 5036 rt5677->pdata.lout3_diff = device_property_read_bool(dev,
5035 "realtek,lout3-differential"); 5037 "realtek,lout3-differential");
5036 5038
5037 of_property_read_u8_array(np, "realtek,gpio-config", 5039 device_property_read_u8_array(dev, "realtek,gpio-config",
5038 rt5677->pdata.gpio_config, RT5677_GPIO_NUM); 5040 rt5677->pdata.gpio_config, RT5677_GPIO_NUM);
5039 5041
5040 of_property_read_u32(np, "realtek,jd1-gpio", &rt5677->pdata.jd1_gpio); 5042 device_property_read_u32(dev, "realtek,jd1-gpio",
5041 of_property_read_u32(np, "realtek,jd2-gpio", &rt5677->pdata.jd2_gpio); 5043 &rt5677->pdata.jd1_gpio);
5042 of_property_read_u32(np, "realtek,jd3-gpio", &rt5677->pdata.jd3_gpio); 5044 device_property_read_u32(dev, "realtek,jd2-gpio",
5043 5045 &rt5677->pdata.jd2_gpio);
5044 return 0; 5046 device_property_read_u32(dev, "realtek,jd3-gpio",
5047 &rt5677->pdata.jd3_gpio);
5045} 5048}
5046 5049
5047static struct regmap_irq rt5677_irqs[] = { 5050static struct regmap_irq rt5677_irqs[] = {
@@ -5124,18 +5127,8 @@ static int rt5677_i2c_probe(struct i2c_client *i2c,
5124 5127
5125 if (pdata) 5128 if (pdata)
5126 rt5677->pdata = *pdata; 5129 rt5677->pdata = *pdata;
5127 5130 else
5128 if (i2c->dev.of_node) { 5131 rt5677_read_device_properties(rt5677, &i2c->dev);
5129 ret = rt5677_parse_dt(rt5677, i2c->dev.of_node);
5130 if (ret) {
5131 dev_err(&i2c->dev, "Failed to parse device tree: %d\n",
5132 ret);
5133 return ret;
5134 }
5135 } else {
5136 rt5677->pow_ldo2 = -EINVAL;
5137 rt5677->reset_pin = -EINVAL;
5138 }
5139 5132
5140 /* pow-ldo2 and reset are optional. The codec pins may be statically 5133 /* pow-ldo2 and reset are optional. The codec pins may be statically
5141 * connected on the board without gpios. If the gpio device property 5134 * connected on the board without gpios. If the gpio device property