0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <linux/acpi.h>
0010 #include <linux/delay.h>
0011 #include <linux/i2c.h>
0012 #include <linux/init.h>
0013 #include <linux/kernel.h>
0014 #include <linux/module.h>
0015 #include <linux/moduleparam.h>
0016 #include <linux/of_device.h>
0017 #include <linux/platform_device.h>
0018 #include <linux/slab.h>
0019
0020 #include "cs35l41.h"
0021
0022 static const struct i2c_device_id cs35l41_id_i2c[] = {
0023 { "cs35l40", 0 },
0024 { "cs35l41", 0 },
0025 { "cs35l51", 0 },
0026 { "cs35l53", 0 },
0027 {}
0028 };
0029
0030 MODULE_DEVICE_TABLE(i2c, cs35l41_id_i2c);
0031
0032 static int cs35l41_i2c_probe(struct i2c_client *client)
0033 {
0034 struct cs35l41_private *cs35l41;
0035 struct device *dev = &client->dev;
0036 struct cs35l41_hw_cfg *hw_cfg = dev_get_platdata(dev);
0037 const struct regmap_config *regmap_config = &cs35l41_regmap_i2c;
0038 int ret;
0039
0040 cs35l41 = devm_kzalloc(dev, sizeof(struct cs35l41_private), GFP_KERNEL);
0041
0042 if (!cs35l41)
0043 return -ENOMEM;
0044
0045 cs35l41->dev = dev;
0046 cs35l41->irq = client->irq;
0047
0048 i2c_set_clientdata(client, cs35l41);
0049 cs35l41->regmap = devm_regmap_init_i2c(client, regmap_config);
0050 if (IS_ERR(cs35l41->regmap)) {
0051 ret = PTR_ERR(cs35l41->regmap);
0052 dev_err(cs35l41->dev, "Failed to allocate register map: %d\n", ret);
0053 return ret;
0054 }
0055
0056 return cs35l41_probe(cs35l41, hw_cfg);
0057 }
0058
0059 static int cs35l41_i2c_remove(struct i2c_client *client)
0060 {
0061 struct cs35l41_private *cs35l41 = i2c_get_clientdata(client);
0062
0063 cs35l41_remove(cs35l41);
0064
0065 return 0;
0066 }
0067
0068 #ifdef CONFIG_OF
0069 static const struct of_device_id cs35l41_of_match[] = {
0070 { .compatible = "cirrus,cs35l40" },
0071 { .compatible = "cirrus,cs35l41" },
0072 {},
0073 };
0074 MODULE_DEVICE_TABLE(of, cs35l41_of_match);
0075 #endif
0076
0077 #ifdef CONFIG_ACPI
0078 static const struct acpi_device_id cs35l41_acpi_match[] = {
0079 { "CSC3541", 0 },
0080 {},
0081 };
0082 MODULE_DEVICE_TABLE(acpi, cs35l41_acpi_match);
0083 #endif
0084
0085 static struct i2c_driver cs35l41_i2c_driver = {
0086 .driver = {
0087 .name = "cs35l41",
0088 .pm = &cs35l41_pm_ops,
0089 .of_match_table = of_match_ptr(cs35l41_of_match),
0090 .acpi_match_table = ACPI_PTR(cs35l41_acpi_match),
0091 },
0092 .id_table = cs35l41_id_i2c,
0093 .probe_new = cs35l41_i2c_probe,
0094 .remove = cs35l41_i2c_remove,
0095 };
0096
0097 module_i2c_driver(cs35l41_i2c_driver);
0098
0099 MODULE_DESCRIPTION("I2C CS35L41 driver");
0100 MODULE_AUTHOR("David Rhodes, Cirrus Logic Inc, <david.rhodes@cirrus.com>");
0101 MODULE_LICENSE("GPL");