0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <linux/device.h>
0010 #include <linux/module.h>
0011 #include <linux/regmap.h>
0012 #include <linux/spi/spi.h>
0013
0014 #include "cs35l45.h"
0015
0016 static int cs35l45_spi_probe(struct spi_device *spi)
0017 {
0018 struct cs35l45_private *cs35l45;
0019 struct device *dev = &spi->dev;
0020 int ret;
0021
0022 cs35l45 = devm_kzalloc(dev, sizeof(struct cs35l45_private), GFP_KERNEL);
0023 if (cs35l45 == NULL)
0024 return -ENOMEM;
0025
0026 spi_set_drvdata(spi, cs35l45);
0027 cs35l45->regmap = devm_regmap_init_spi(spi, &cs35l45_spi_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 void cs35l45_spi_remove(struct spi_device *spi)
0040 {
0041 struct cs35l45_private *cs35l45 = spi_get_drvdata(spi);
0042
0043 cs35l45_remove(cs35l45);
0044 }
0045
0046 static const struct of_device_id cs35l45_of_match[] = {
0047 { .compatible = "cirrus,cs35l45" },
0048 {},
0049 };
0050 MODULE_DEVICE_TABLE(of, cs35l45_of_match);
0051
0052 static const struct spi_device_id cs35l45_id_spi[] = {
0053 { "cs35l45", 0 },
0054 {}
0055 };
0056 MODULE_DEVICE_TABLE(spi, cs35l45_id_spi);
0057
0058 static struct spi_driver cs35l45_spi_driver = {
0059 .driver = {
0060 .name = "cs35l45",
0061 .of_match_table = cs35l45_of_match,
0062 .pm = &cs35l45_pm_ops,
0063 },
0064 .id_table = cs35l45_id_spi,
0065 .probe = cs35l45_spi_probe,
0066 .remove = cs35l45_spi_remove,
0067 };
0068 module_spi_driver(cs35l45_spi_driver);
0069
0070 MODULE_DESCRIPTION("SPI CS35L45 driver");
0071 MODULE_AUTHOR("James Schulman, Cirrus Logic Inc, <james.schulman@cirrus.com>");
0072 MODULE_LICENSE("Dual BSD/GPL");
0073 MODULE_IMPORT_NS(SND_SOC_CS35L45);
0074 MODULE_IMPORT_NS(SND_SOC_CS35L45_TABLES);