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
;
30 cs35l56
->base
.can_hibernate
= true;
32 i2c_set_clientdata(client
, cs35l56
);
33 cs35l56
->base
.regmap
= devm_regmap_init_i2c(client
, regmap_config
);
34 if (IS_ERR(cs35l56
->base
.regmap
)) {
35 ret
= PTR_ERR(cs35l56
->base
.regmap
);
36 return dev_err_probe(cs35l56
->base
.dev
, ret
, "Failed to allocate register map\n");
39 ret
= cs35l56_common_probe(cs35l56
);
43 ret
= cs35l56_init(cs35l56
);
45 ret
= cs35l56_irq_request(&cs35l56
->base
, client
->irq
);
47 cs35l56_remove(cs35l56
);
52 static void cs35l56_i2c_remove(struct i2c_client
*client
)
54 struct cs35l56_private
*cs35l56
= i2c_get_clientdata(client
);
56 cs35l56_remove(cs35l56
);
59 static const struct i2c_device_id cs35l56_id_i2c
[] = {
63 MODULE_DEVICE_TABLE(i2c
, cs35l56_id_i2c
);
66 static const struct acpi_device_id cs35l56_asoc_acpi_match
[] = {
70 MODULE_DEVICE_TABLE(acpi
, cs35l56_asoc_acpi_match
);
73 static struct i2c_driver cs35l56_i2c_driver
= {
76 .pm
= pm_ptr(&cs35l56_pm_ops_i2c_spi
),
77 .acpi_match_table
= ACPI_PTR(cs35l56_asoc_acpi_match
),
79 .id_table
= cs35l56_id_i2c
,
80 .probe
= cs35l56_i2c_probe
,
81 .remove
= cs35l56_i2c_remove
,
84 module_i2c_driver(cs35l56_i2c_driver
);
86 MODULE_DESCRIPTION("ASoC CS35L56 I2C driver");
87 MODULE_IMPORT_NS(SND_SOC_CS35L56_CORE
);
88 MODULE_IMPORT_NS(SND_SOC_CS35L56_SHARED
);
89 MODULE_AUTHOR("Richard Fitzgerald <rf@opensource.cirrus.com>");
90 MODULE_AUTHOR("Simon Trimmer <simont@opensource.cirrus.com>");
91 MODULE_LICENSE("GPL");