aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Morozov <linux@meltdown.ru>2015-01-26 22:36:39 -0500
committerMark Brown <broonie@kernel.org>2015-01-28 14:30:12 -0500
commitb1a5fad5f8c063abfd9bd22f7de8de82927c7d54 (patch)
treea31d39521b72a5d13f6e5483bd8786eeee9b1d37
parent97bf6af1f928216fd6c5a66e8a57bfa95a659672 (diff)
ASoC: wm8904: add dt ids table
The WM8904 and WM8918 has the same data type, while the WM8912 has different data type. So, use the data in dt ids table to distinguish them. Signed-off-by: Alexander Morozov <linux@meltdown.ru> [voice.shen@atmel.com: add code to distinguish device type] Signed-off-by: Bo Shen <voice.shen@atmel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--sound/soc/codecs/wm8904.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/sound/soc/codecs/wm8904.c b/sound/soc/codecs/wm8904.c
index 4d2d2b1380d5..a80bc528431a 100644
--- a/sound/soc/codecs/wm8904.c
+++ b/sound/soc/codecs/wm8904.c
@@ -2098,6 +2098,24 @@ static const struct regmap_config wm8904_regmap = {
2098 .num_reg_defaults = ARRAY_SIZE(wm8904_reg_defaults), 2098 .num_reg_defaults = ARRAY_SIZE(wm8904_reg_defaults),
2099}; 2099};
2100 2100
2101#ifdef CONFIG_OF
2102static enum wm8904_type wm8904_data = WM8904;
2103static enum wm8904_type wm8912_data = WM8912;
2104
2105static const struct of_device_id wm8904_of_match[] = {
2106 {
2107 .compatible = "wlf,wm8904",
2108 .data = &wm8904_data,
2109 }, {
2110 .compatible = "wlf,wm8912",
2111 .data = &wm8912_data,
2112 }, {
2113 /* sentinel */
2114 }
2115};
2116MODULE_DEVICE_TABLE(of, wm8904_of_match);
2117#endif
2118
2101static int wm8904_i2c_probe(struct i2c_client *i2c, 2119static int wm8904_i2c_probe(struct i2c_client *i2c,
2102 const struct i2c_device_id *id) 2120 const struct i2c_device_id *id)
2103{ 2121{
@@ -2125,7 +2143,17 @@ static int wm8904_i2c_probe(struct i2c_client *i2c,
2125 return ret; 2143 return ret;
2126 } 2144 }
2127 2145
2128 wm8904->devtype = id->driver_data; 2146 if (i2c->dev.of_node) {
2147 const struct of_device_id *match;
2148
2149 match = of_match_node(wm8904_of_match, i2c->dev.of_node);
2150 if (match == NULL)
2151 return -EINVAL;
2152 wm8904->devtype = *((enum wm8904_type *)match->data);
2153 } else {
2154 wm8904->devtype = id->driver_data;
2155 }
2156
2129 i2c_set_clientdata(i2c, wm8904); 2157 i2c_set_clientdata(i2c, wm8904);
2130 wm8904->pdata = i2c->dev.platform_data; 2158 wm8904->pdata = i2c->dev.platform_data;
2131 2159
@@ -2259,6 +2287,7 @@ static struct i2c_driver wm8904_i2c_driver = {
2259 .driver = { 2287 .driver = {
2260 .name = "wm8904", 2288 .name = "wm8904",
2261 .owner = THIS_MODULE, 2289 .owner = THIS_MODULE,
2290 .of_match_table = of_match_ptr(wm8904_of_match),
2262 }, 2291 },
2263 .probe = wm8904_i2c_probe, 2292 .probe = wm8904_i2c_probe,
2264 .remove = wm8904_i2c_remove, 2293 .remove = wm8904_i2c_remove,