2019-06-04 16:11:33 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2014-04-16 04:49:33 +08:00
|
|
|
/*
|
|
|
|
* cs42l56.c -- CS42L51 ALSA SoC I2C audio driver
|
|
|
|
*
|
|
|
|
* Copyright 2014 CirrusLogic, Inc.
|
|
|
|
*
|
|
|
|
* Author: Brian Austin <brian.austin@cirrus.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/i2c.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <sound/soc.h>
|
|
|
|
|
|
|
|
#include "cs42l51.h"
|
|
|
|
|
|
|
|
static struct i2c_device_id cs42l51_i2c_id[] = {
|
|
|
|
{"cs42l51", 0},
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(i2c, cs42l51_i2c_id);
|
|
|
|
|
2023-07-25 20:09:17 +08:00
|
|
|
static const struct of_device_id cs42l51_of_match[] = {
|
ASoC: cs42l51: fix driver to properly autoload with automatic module loading
In commit 2cb1e0259f50 ("ASoC: cs42l51: re-hook of_match_table
pointer"), 9 years ago, some random guy fixed the cs42l51 after it was
split into a core part and an I2C part to properly match based on a
Device Tree compatible string.
However, the fix in this commit is wrong: the MODULE_DEVICE_TABLE(of,
....) is in the core part of the driver, not the I2C part. Therefore,
automatic module loading based on module.alias, based on matching with
the DT compatible string, loads the core part of the driver, but not
the I2C part. And threfore, the i2c_driver is not registered, and the
codec is not known to the system, nor matched with a DT node with the
corresponding compatible string.
In order to fix that, we move the MODULE_DEVICE_TABLE(of, ...) into
the I2C part of the driver. The cs42l51_of_match[] array is also moved
as well, as it is not possible to have this definition in one file,
and the MODULE_DEVICE_TABLE(of, ...) invocation in another file, due
to how MODULE_DEVICE_TABLE works.
Thanks to this commit, the I2C part of the driver now properly
autoloads, and thanks to its dependency on the core part, the core
part gets autoloaded as well, resulting in a functional sound card
without having to manually load kernel modules.
Fixes: 2cb1e0259f50 ("ASoC: cs42l51: re-hook of_match_table pointer")
Cc: stable@vger.kernel.org
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Link: https://lore.kernel.org/r/20230713112112.778576-1-thomas.petazzoni@bootlin.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-07-13 19:21:12 +08:00
|
|
|
{ .compatible = "cirrus,cs42l51", },
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(of, cs42l51_of_match);
|
|
|
|
|
2022-03-26 01:07:34 +08:00
|
|
|
static int cs42l51_i2c_probe(struct i2c_client *i2c)
|
2014-04-16 04:49:33 +08:00
|
|
|
{
|
|
|
|
struct regmap_config config;
|
|
|
|
|
|
|
|
config = cs42l51_regmap;
|
|
|
|
|
|
|
|
return cs42l51_probe(&i2c->dev, devm_regmap_init_i2c(i2c, &config));
|
|
|
|
}
|
|
|
|
|
2022-08-15 16:02:30 +08:00
|
|
|
static void cs42l51_i2c_remove(struct i2c_client *i2c)
|
2019-04-03 21:23:32 +08:00
|
|
|
{
|
2022-01-10 15:18:32 +08:00
|
|
|
cs42l51_remove(&i2c->dev);
|
2019-04-03 21:23:32 +08:00
|
|
|
}
|
|
|
|
|
2019-04-03 21:23:36 +08:00
|
|
|
static const struct dev_pm_ops cs42l51_pm_ops = {
|
|
|
|
SET_SYSTEM_SLEEP_PM_OPS(cs42l51_suspend, cs42l51_resume)
|
|
|
|
};
|
|
|
|
|
2014-04-16 04:49:33 +08:00
|
|
|
static struct i2c_driver cs42l51_i2c_driver = {
|
|
|
|
.driver = {
|
|
|
|
.name = "cs42l51",
|
2014-11-12 22:40:44 +08:00
|
|
|
.of_match_table = cs42l51_of_match,
|
2019-04-03 21:23:36 +08:00
|
|
|
.pm = &cs42l51_pm_ops,
|
2014-04-16 04:49:33 +08:00
|
|
|
},
|
2023-04-25 17:57:16 +08:00
|
|
|
.probe = cs42l51_i2c_probe,
|
2019-04-03 21:23:32 +08:00
|
|
|
.remove = cs42l51_i2c_remove,
|
2014-04-16 04:49:33 +08:00
|
|
|
.id_table = cs42l51_i2c_id,
|
|
|
|
};
|
|
|
|
|
|
|
|
module_i2c_driver(cs42l51_i2c_driver);
|
|
|
|
|
|
|
|
MODULE_DESCRIPTION("ASoC CS42L51 I2C Driver");
|
|
|
|
MODULE_AUTHOR("Brian Austin, Cirrus Logic Inc, <brian.austin@cirrus.com>");
|
|
|
|
MODULE_LICENSE("GPL");
|