1 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
3 // cs35l45-i2c.c -- CS35L45 I2C driver
5 // Copyright 2019-2022 Cirrus Logic, Inc.
7 // Author: James Schulman <james.schulman@cirrus.com>
9 #include <linux/device.h>
10 #include <linux/module.h>
11 #include <linux/i2c.h>
12 #include <linux/regmap.h>
16 static int cs35l45_i2c_probe(struct i2c_client *client)
18 struct cs35l45_private *cs35l45;
19 struct device *dev = &client->dev;
22 cs35l45 = devm_kzalloc(dev, sizeof(struct cs35l45_private), GFP_KERNEL);
26 i2c_set_clientdata(client, cs35l45);
27 cs35l45->regmap = devm_regmap_init_i2c(client, &cs35l45_i2c_regmap);
28 if (IS_ERR(cs35l45->regmap)) {
29 ret = PTR_ERR(cs35l45->regmap);
30 dev_err(dev, "Failed to allocate register map: %d\n", ret);
36 return cs35l45_probe(cs35l45);
39 static int cs35l45_i2c_remove(struct i2c_client *client)
41 struct cs35l45_private *cs35l45 = i2c_get_clientdata(client);
43 return cs35l45_remove(cs35l45);
46 static const struct of_device_id cs35l45_of_match[] = {
47 { .compatible = "cirrus,cs35l45" },
50 MODULE_DEVICE_TABLE(of, cs35l45_of_match);
52 static const struct i2c_device_id cs35l45_id_i2c[] = {
56 MODULE_DEVICE_TABLE(i2c, cs35l45_id_i2c);
58 static struct i2c_driver cs35l45_i2c_driver = {
61 .of_match_table = cs35l45_of_match,
62 .pm = &cs35l45_pm_ops,
64 .id_table = cs35l45_id_i2c,
65 .probe_new = cs35l45_i2c_probe,
66 .remove = cs35l45_i2c_remove,
68 module_i2c_driver(cs35l45_i2c_driver);
70 MODULE_DESCRIPTION("I2C CS35L45 driver");
71 MODULE_AUTHOR("James Schulman, Cirrus Logic Inc, <james.schulman@cirrus.com>");
72 MODULE_LICENSE("Dual BSD/GPL");
73 MODULE_IMPORT_NS(SND_SOC_CS35L45);
74 MODULE_IMPORT_NS(SND_SOC_CS35L45_TABLES);