1 // SPDX-License-Identifier: GPL-2.0-only
3 // CS35L56 ALSA SoC audio driver I2C binding
5 // Copyright (C) 2023 Cirrus Logic, Inc. and
6 // Cirrus Logic International Semiconductor Ltd.
8 #include <linux/acpi.h>
10 #include <linux/module.h>
11 #include <linux/moduleparam.h>
12 #include <linux/regmap.h>
13 #include <linux/slab.h>
14 #include <linux/types.h>
18 static int cs35l56_i2c_probe(struct i2c_client *client)
20 struct cs35l56_private *cs35l56;
21 struct device *dev = &client->dev;
22 const struct regmap_config *regmap_config = &cs35l56_regmap_i2c;
25 cs35l56 = devm_kzalloc(dev, sizeof(struct cs35l56_private), GFP_KERNEL);
29 cs35l56->base.dev = dev;
31 i2c_set_clientdata(client, cs35l56);
32 cs35l56->base.regmap = devm_regmap_init_i2c(client, regmap_config);
33 if (IS_ERR(cs35l56->base.regmap)) {
34 ret = PTR_ERR(cs35l56->base.regmap);
35 return dev_err_probe(cs35l56->base.dev, ret, "Failed to allocate register map\n");
38 ret = cs35l56_common_probe(cs35l56);
42 ret = cs35l56_init(cs35l56);
44 ret = cs35l56_irq_request(&cs35l56->base, client->irq);
46 cs35l56_remove(cs35l56);
51 static void cs35l56_i2c_remove(struct i2c_client *client)
53 struct cs35l56_private *cs35l56 = i2c_get_clientdata(client);
55 cs35l56_remove(cs35l56);
58 static const struct i2c_device_id cs35l56_id_i2c[] = {
62 MODULE_DEVICE_TABLE(i2c, cs35l56_id_i2c);
65 static const struct acpi_device_id cs35l56_asoc_acpi_match[] = {
69 MODULE_DEVICE_TABLE(acpi, cs35l56_asoc_acpi_match);
72 static struct i2c_driver cs35l56_i2c_driver = {
75 .pm = &cs35l56_pm_ops_i2c_spi,
76 .acpi_match_table = ACPI_PTR(cs35l56_asoc_acpi_match),
78 .id_table = cs35l56_id_i2c,
79 .probe = cs35l56_i2c_probe,
80 .remove = cs35l56_i2c_remove,
83 module_i2c_driver(cs35l56_i2c_driver);
85 MODULE_DESCRIPTION("ASoC CS35L56 I2C driver");
86 MODULE_IMPORT_NS(SND_SOC_CS35L56_CORE);
87 MODULE_IMPORT_NS(SND_SOC_CS35L56_SHARED);
88 MODULE_AUTHOR("Richard Fitzgerald <rf@opensource.cirrus.com>");
89 MODULE_AUTHOR("Simon Trimmer <simont@opensource.cirrus.com>");
90 MODULE_LICENSE("GPL");