0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <linux/device.h>
0010 #include <linux/module.h>
0011 #include <linux/i2c.h>
0012 #include <linux/regmap.h>
0013
0014 #include "cs35l45.h"
0015
0016 static int cs35l45_i2c_probe(struct i2c_client *client)
0017 {
0018 struct cs35l45_private *cs35l45;
0019 struct device *dev = &client->dev;
0020 int ret;
0021
0022 cs35l45 = devm_kzalloc(dev, sizeof(struct cs35l45_private), GFP_KERNEL);
0023 if (!cs35l45)
0024 return -ENOMEM;
0025
0026 i2c_set_clientdata(client, cs35l45);
0027 cs35l45->regmap = devm_regmap_init_i2c(client, &cs35l45_i2c_regmap);
0028 if (IS_ERR(cs35l45->regmap)) {
0029 ret = PTR_ERR(cs35l45->regmap);
0030 dev_err(dev, "Failed to allocate register map: %d\n", ret);
0031 return ret;
0032 }
0033
0034 cs35l45->dev = dev;
0035
0036 return cs35l45_probe(cs35l45);
0037 }
0038
0039 static int cs35l45_i2c_remove(struct i2c_client *client)
0040 {
0041 struct cs35l45_private *cs35l45 = i2c_get_clientdata(client);
0042
0043 cs35l45_remove(cs35l45);
0044
0045 return 0;
0046 }
0047
0048 static const struct of_device_id cs35l45_of_match[] = {
0049 { .compatible = "cirrus,cs35l45" },
0050 {},
0051 };
0052 MODULE_DEVICE_TABLE(of, cs35l45_of_match);
0053
0054 static const struct i2c_device_id cs35l45_id_i2c[] = {
0055 { "cs35l45", 0 },
0056 {}
0057 };
0058 MODULE_DEVICE_TABLE(i2c, cs35l45_id_i2c);
0059
0060 static struct i2c_driver cs35l45_i2c_driver = {
0061 .driver = {
0062 .name = "cs35l45",
0063 .of_match_table = cs35l45_of_match,
0064 .pm = &cs35l45_pm_ops,
0065 },
0066 .id_table = cs35l45_id_i2c,
0067 .probe_new = cs35l45_i2c_probe,
0068 .remove = cs35l45_i2c_remove,
0069 };
0070 module_i2c_driver(cs35l45_i2c_driver);
0071
0072 MODULE_DESCRIPTION("I2C CS35L45 driver");
0073 MODULE_AUTHOR("James Schulman, Cirrus Logic Inc, <james.schulman@cirrus.com>");
0074 MODULE_LICENSE("Dual BSD/GPL");
0075 MODULE_IMPORT_NS(SND_SOC_CS35L45);
0076 MODULE_IMPORT_NS(SND_SOC_CS35L45_TABLES);