1 // SPDX-License-Identifier: GPL-2.0-only
3 // CS35L56 ALSA SoC audio driver SPI binding
5 // Copyright (C) 2023 Cirrus Logic, Inc. and
6 // Cirrus Logic International Semiconductor Ltd.
8 #include <linux/acpi.h>
9 #include <linux/module.h>
10 #include <linux/moduleparam.h>
11 #include <linux/regmap.h>
12 #include <linux/spi/spi.h>
13 #include <linux/types.h>
17 static int cs35l56_spi_probe(struct spi_device
*spi
)
19 const struct regmap_config
*regmap_config
= &cs35l56_regmap_spi
;
20 struct cs35l56_private
*cs35l56
;
23 cs35l56
= devm_kzalloc(&spi
->dev
, sizeof(struct cs35l56_private
), GFP_KERNEL
);
27 spi_set_drvdata(spi
, cs35l56
);
28 cs35l56
->base
.regmap
= devm_regmap_init_spi(spi
, regmap_config
);
29 if (IS_ERR(cs35l56
->base
.regmap
)) {
30 ret
= PTR_ERR(cs35l56
->base
.regmap
);
31 return dev_err_probe(&spi
->dev
, ret
, "Failed to allocate register map\n");
34 cs35l56
->base
.dev
= &spi
->dev
;
35 cs35l56
->base
.can_hibernate
= true;
37 ret
= cs35l56_common_probe(cs35l56
);
41 ret
= cs35l56_init(cs35l56
);
43 ret
= cs35l56_irq_request(&cs35l56
->base
, spi
->irq
);
45 cs35l56_remove(cs35l56
);
50 static void cs35l56_spi_remove(struct spi_device
*spi
)
52 struct cs35l56_private
*cs35l56
= spi_get_drvdata(spi
);
54 cs35l56_remove(cs35l56
);
57 static const struct spi_device_id cs35l56_id_spi
[] = {
61 MODULE_DEVICE_TABLE(spi
, cs35l56_id_spi
);
64 static const struct acpi_device_id cs35l56_asoc_acpi_match
[] = {
68 MODULE_DEVICE_TABLE(acpi
, cs35l56_asoc_acpi_match
);
71 static struct spi_driver cs35l56_spi_driver
= {
74 .pm
= pm_ptr(&cs35l56_pm_ops_i2c_spi
),
75 .acpi_match_table
= ACPI_PTR(cs35l56_asoc_acpi_match
),
77 .id_table
= cs35l56_id_spi
,
78 .probe
= cs35l56_spi_probe
,
79 .remove
= cs35l56_spi_remove
,
82 module_spi_driver(cs35l56_spi_driver
);
84 MODULE_DESCRIPTION("ASoC CS35L56 SPI driver");
85 MODULE_IMPORT_NS("SND_SOC_CS35L56_CORE");
86 MODULE_IMPORT_NS("SND_SOC_CS35L56_SHARED");
87 MODULE_AUTHOR("Richard Fitzgerald <rf@opensource.cirrus.com>");
88 MODULE_AUTHOR("Simon Trimmer <simont@opensource.cirrus.com>");
89 MODULE_LICENSE("GPL");