Commit d815c703 authored by Sascha Hauer's avatar Sascha Hauer Committed by Mark Brown

ASoC: ak4642: Add driver data and driver private struct

Currently unused, this is done to let the driver distinguish between
the different supported codec types in later patches.
Signed-off-by: default avatarSascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: default avatarMark Brown <broonie@linaro.org>
parent 370f83a1
...@@ -134,6 +134,14 @@ ...@@ -134,6 +134,14 @@
/* MD_CTL4 */ /* MD_CTL4 */
#define DACH (1 << 0) #define DACH (1 << 0)
struct ak4642_drvdata {
const struct regmap_config *regmap_config;
};
struct ak4642_priv {
const struct ak4642_drvdata *drvdata;
};
/* /*
* Playback Volume (table 39) * Playback Volume (table 39)
* *
...@@ -507,30 +515,51 @@ static const struct regmap_config ak4648_regmap = { ...@@ -507,30 +515,51 @@ static const struct regmap_config ak4648_regmap = {
.num_reg_defaults = ARRAY_SIZE(ak4648_reg), .num_reg_defaults = ARRAY_SIZE(ak4648_reg),
}; };
static const struct ak4642_drvdata ak4642_drvdata = {
.regmap_config = &ak4642_regmap,
};
static const struct ak4642_drvdata ak4643_drvdata = {
.regmap_config = &ak4642_regmap,
};
static const struct ak4642_drvdata ak4648_drvdata = {
.regmap_config = &ak4648_regmap,
};
static struct of_device_id ak4642_of_match[]; static struct of_device_id ak4642_of_match[];
static int ak4642_i2c_probe(struct i2c_client *i2c, static int ak4642_i2c_probe(struct i2c_client *i2c,
const struct i2c_device_id *id) const struct i2c_device_id *id)
{ {
struct device_node *np = i2c->dev.of_node; struct device_node *np = i2c->dev.of_node;
const struct regmap_config *regmap_config = NULL; const struct ak4642_drvdata *drvdata = NULL;
struct regmap *regmap; struct regmap *regmap;
struct ak4642_priv *priv;
if (np) { if (np) {
const struct of_device_id *of_id; const struct of_device_id *of_id;
of_id = of_match_device(ak4642_of_match, &i2c->dev); of_id = of_match_device(ak4642_of_match, &i2c->dev);
if (of_id) if (of_id)
regmap_config = of_id->data; drvdata = of_id->data;
} else { } else {
regmap_config = (const struct regmap_config *)id->driver_data; drvdata = (const struct ak4642_drvdata *)id->driver_data;
} }
if (!regmap_config) { if (!drvdata) {
dev_err(&i2c->dev, "Unknown device type\n"); dev_err(&i2c->dev, "Unknown device type\n");
return -EINVAL; return -EINVAL;
} }
regmap = devm_regmap_init_i2c(i2c, regmap_config); priv = devm_kzalloc(&i2c->dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
priv->drvdata = drvdata;
i2c_set_clientdata(i2c, priv);
regmap = devm_regmap_init_i2c(i2c, drvdata->regmap_config);
if (IS_ERR(regmap)) if (IS_ERR(regmap))
return PTR_ERR(regmap); return PTR_ERR(regmap);
...@@ -545,17 +574,17 @@ static int ak4642_i2c_remove(struct i2c_client *client) ...@@ -545,17 +574,17 @@ static int ak4642_i2c_remove(struct i2c_client *client)
} }
static struct of_device_id ak4642_of_match[] = { static struct of_device_id ak4642_of_match[] = {
{ .compatible = "asahi-kasei,ak4642", .data = &ak4642_regmap}, { .compatible = "asahi-kasei,ak4642", .data = &ak4642_drvdata},
{ .compatible = "asahi-kasei,ak4643", .data = &ak4642_regmap}, { .compatible = "asahi-kasei,ak4643", .data = &ak4643_drvdata},
{ .compatible = "asahi-kasei,ak4648", .data = &ak4648_regmap}, { .compatible = "asahi-kasei,ak4648", .data = &ak4648_drvdata},
{}, {},
}; };
MODULE_DEVICE_TABLE(of, ak4642_of_match); MODULE_DEVICE_TABLE(of, ak4642_of_match);
static const struct i2c_device_id ak4642_i2c_id[] = { static const struct i2c_device_id ak4642_i2c_id[] = {
{ "ak4642", (kernel_ulong_t)&ak4642_regmap }, { "ak4642", (kernel_ulong_t)&ak4642_drvdata },
{ "ak4643", (kernel_ulong_t)&ak4642_regmap }, { "ak4643", (kernel_ulong_t)&ak4643_drvdata },
{ "ak4648", (kernel_ulong_t)&ak4648_regmap }, { "ak4648", (kernel_ulong_t)&ak4648_drvdata },
{ } { }
}; };
MODULE_DEVICE_TABLE(i2c, ak4642_i2c_id); MODULE_DEVICE_TABLE(i2c, ak4642_i2c_id);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment