1 // SPDX-License-Identifier: GPL-2.0 2 /* 3 * CS40L50 Advanced Haptic Driver with waveform memory, 4 * integrated DSP, and closed-loop algorithms 5 * 6 * Copyright 2024 Cirrus Logic, Inc. 7 * 8 * Author: James Ogletree <james.ogletree@cirrus.com> 9 */ 10 11 #include <linux/mfd/cs40l50.h> 12 #include <linux/spi/spi.h> 13 14 static int cs40l50_spi_probe(struct spi_device *spi) 15 { 16 struct cs40l50 *cs40l50; 17 18 cs40l50 = devm_kzalloc(&spi->dev, sizeof(*cs40l50), GFP_KERNEL); 19 if (!cs40l50) 20 return -ENOMEM; 21 22 spi_set_drvdata(spi, cs40l50); 23 24 cs40l50->dev = &spi->dev; 25 cs40l50->irq = spi->irq; 26 27 cs40l50->regmap = devm_regmap_init_spi(spi, &cs40l50_regmap); 28 if (IS_ERR(cs40l50->regmap)) 29 return dev_err_probe(cs40l50->dev, PTR_ERR(cs40l50->regmap), 30 "Failed to initialize register map\n"); 31 32 return cs40l50_probe(cs40l50); 33 } 34 35 static void cs40l50_spi_remove(struct spi_device *spi) 36 { 37 struct cs40l50 *cs40l50 = spi_get_drvdata(spi); 38 39 cs40l50_remove(cs40l50); 40 } 41 42 static const struct spi_device_id cs40l50_id_spi[] = { 43 { "cs40l50" }, 44 {} 45 }; 46 MODULE_DEVICE_TABLE(spi, cs40l50_id_spi); 47 48 static const struct of_device_id cs40l50_of_match[] = { 49 { .compatible = "cirrus,cs40l50" }, 50 {} 51 }; 52 MODULE_DEVICE_TABLE(of, cs40l50_of_match); 53 54 static struct spi_driver cs40l50_spi_driver = { 55 .driver = { 56 .name = "cs40l50", 57 .of_match_table = cs40l50_of_match, 58 .pm = pm_ptr(&cs40l50_pm_ops), 59 }, 60 .id_table = cs40l50_id_spi, 61 .probe = cs40l50_spi_probe, 62 .remove = cs40l50_spi_remove, 63 }; 64 module_spi_driver(cs40l50_spi_driver); 65 66 MODULE_DESCRIPTION("CS40L50 SPI Driver"); 67 MODULE_AUTHOR("James Ogletree, Cirrus Logic Inc. <james.ogletree@cirrus.com>"); 68 MODULE_LICENSE("GPL"); 69