|
@@ -2105,6 +2105,24 @@ static const struct regmap_config wm8904_regmap = {
|
|
.num_reg_defaults = ARRAY_SIZE(wm8904_reg_defaults),
|
|
.num_reg_defaults = ARRAY_SIZE(wm8904_reg_defaults),
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+#ifdef CONFIG_OF
|
|
|
|
+static enum wm8904_type wm8904_data = WM8904;
|
|
|
|
+static enum wm8904_type wm8912_data = WM8912;
|
|
|
|
+
|
|
|
|
+static const struct of_device_id wm8904_of_match[] = {
|
|
|
|
+ {
|
|
|
|
+ .compatible = "wlf,wm8904",
|
|
|
|
+ .data = &wm8904_data,
|
|
|
|
+ }, {
|
|
|
|
+ .compatible = "wlf,wm8912",
|
|
|
|
+ .data = &wm8912_data,
|
|
|
|
+ }, {
|
|
|
|
+ /* sentinel */
|
|
|
|
+ }
|
|
|
|
+};
|
|
|
|
+MODULE_DEVICE_TABLE(of, wm8904_of_match);
|
|
|
|
+#endif
|
|
|
|
+
|
|
static int wm8904_i2c_probe(struct i2c_client *i2c,
|
|
static int wm8904_i2c_probe(struct i2c_client *i2c,
|
|
const struct i2c_device_id *id)
|
|
const struct i2c_device_id *id)
|
|
{
|
|
{
|
|
@@ -2132,7 +2150,17 @@ static int wm8904_i2c_probe(struct i2c_client *i2c,
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
|
|
- wm8904->devtype = id->driver_data;
|
|
|
|
|
|
+ if (i2c->dev.of_node) {
|
|
|
|
+ const struct of_device_id *match;
|
|
|
|
+
|
|
|
|
+ match = of_match_node(wm8904_of_match, i2c->dev.of_node);
|
|
|
|
+ if (match == NULL)
|
|
|
|
+ return -EINVAL;
|
|
|
|
+ wm8904->devtype = *((enum wm8904_type *)match->data);
|
|
|
|
+ } else {
|
|
|
|
+ wm8904->devtype = id->driver_data;
|
|
|
|
+ }
|
|
|
|
+
|
|
i2c_set_clientdata(i2c, wm8904);
|
|
i2c_set_clientdata(i2c, wm8904);
|
|
wm8904->pdata = i2c->dev.platform_data;
|
|
wm8904->pdata = i2c->dev.platform_data;
|
|
|
|
|
|
@@ -2266,6 +2294,7 @@ static struct i2c_driver wm8904_i2c_driver = {
|
|
.driver = {
|
|
.driver = {
|
|
.name = "wm8904",
|
|
.name = "wm8904",
|
|
.owner = THIS_MODULE,
|
|
.owner = THIS_MODULE,
|
|
|
|
+ .of_match_table = of_match_ptr(wm8904_of_match),
|
|
},
|
|
},
|
|
.probe = wm8904_i2c_probe,
|
|
.probe = wm8904_i2c_probe,
|
|
.remove = wm8904_i2c_remove,
|
|
.remove = wm8904_i2c_remove,
|