Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 //
0003 // CS35l41 HDA SPI driver
0004 //
0005 // Copyright 2021 Cirrus Logic, Inc.
0006 //
0007 // Author: Lucas Tanure <tanureal@opensource.cirrus.com>
0008 
0009 #include <linux/mod_devicetable.h>
0010 #include <linux/module.h>
0011 #include <linux/spi/spi.h>
0012 
0013 #include "cs35l41_hda.h"
0014 
0015 static int cs35l41_hda_spi_probe(struct spi_device *spi)
0016 {
0017     const char *device_name;
0018 
0019     /*
0020      * Compare against the device name so it works for SPI, normal ACPI
0021      * and for ACPI by serial-multi-instantiate matching cases.
0022      */
0023     if (strstr(dev_name(&spi->dev), "CSC3551"))
0024         device_name = "CSC3551";
0025     else
0026         return -ENODEV;
0027 
0028     return cs35l41_hda_probe(&spi->dev, device_name, spi->chip_select, spi->irq,
0029                  devm_regmap_init_spi(spi, &cs35l41_regmap_spi));
0030 }
0031 
0032 static void cs35l41_hda_spi_remove(struct spi_device *spi)
0033 {
0034     cs35l41_hda_remove(&spi->dev);
0035 }
0036 
0037 static const struct spi_device_id cs35l41_hda_spi_id[] = {
0038     { "cs35l41-hda", 0 },
0039     {}
0040 };
0041 
0042 static const struct acpi_device_id cs35l41_acpi_hda_match[] = {
0043     { "CSC3551", 0 },
0044     {}
0045 };
0046 MODULE_DEVICE_TABLE(acpi, cs35l41_acpi_hda_match);
0047 
0048 static struct spi_driver cs35l41_spi_driver = {
0049     .driver = {
0050         .name       = "cs35l41-hda",
0051         .acpi_match_table = cs35l41_acpi_hda_match,
0052         .pm     = &cs35l41_hda_pm_ops,
0053     },
0054     .id_table   = cs35l41_hda_spi_id,
0055     .probe      = cs35l41_hda_spi_probe,
0056     .remove     = cs35l41_hda_spi_remove,
0057 };
0058 module_spi_driver(cs35l41_spi_driver);
0059 
0060 MODULE_DESCRIPTION("HDA CS35L41 driver");
0061 MODULE_IMPORT_NS(SND_HDA_SCODEC_CS35L41);
0062 MODULE_AUTHOR("Lucas Tanure <tanureal@opensource.cirrus.com>");
0063 MODULE_LICENSE("GPL");