xref: /linux/drivers/dpll/zl3073x/spi.c (revision 53597deca0e38c30e6cd4ba2114fa42d2bcd85bb)
1 // SPDX-License-Identifier: GPL-2.0-only
2 
3 #include <linux/dev_printk.h>
4 #include <linux/err.h>
5 #include <linux/module.h>
6 #include <linux/regmap.h>
7 #include <linux/spi/spi.h>
8 
9 #include "core.h"
10 
11 static int zl3073x_spi_probe(struct spi_device *spi)
12 {
13 	struct device *dev = &spi->dev;
14 	struct zl3073x_dev *zldev;
15 
16 	zldev = zl3073x_devm_alloc(dev);
17 	if (IS_ERR(zldev))
18 		return PTR_ERR(zldev);
19 
20 	zldev->regmap = devm_regmap_init_spi(spi, &zl3073x_regmap_config);
21 	if (IS_ERR(zldev->regmap))
22 		return dev_err_probe(dev, PTR_ERR(zldev->regmap),
23 				     "Failed to initialize regmap\n");
24 
25 	return zl3073x_dev_probe(zldev);
26 }
27 
28 static const struct spi_device_id zl3073x_spi_id[] = {
29 	{ "zl30731" },
30 	{ "zl30732" },
31 	{ "zl30733" },
32 	{ "zl30734" },
33 	{ "zl30735" },
34 	{ /* sentinel */ }
35 };
36 MODULE_DEVICE_TABLE(spi, zl3073x_spi_id);
37 
38 static const struct of_device_id zl3073x_spi_of_match[] = {
39 	{ .compatible = "microchip,zl30731" },
40 	{ .compatible = "microchip,zl30732" },
41 	{ .compatible = "microchip,zl30733" },
42 	{ .compatible = "microchip,zl30734" },
43 	{ .compatible = "microchip,zl30735" },
44 	{ /* sentinel */ }
45 };
46 MODULE_DEVICE_TABLE(of, zl3073x_spi_of_match);
47 
48 static struct spi_driver zl3073x_spi_driver = {
49 	.driver = {
50 		.name = "zl3073x-spi",
51 		.of_match_table = zl3073x_spi_of_match,
52 	},
53 	.probe = zl3073x_spi_probe,
54 	.id_table = zl3073x_spi_id,
55 };
56 module_spi_driver(zl3073x_spi_driver);
57 
58 MODULE_AUTHOR("Ivan Vecera <ivecera@redhat.com>");
59 MODULE_DESCRIPTION("Microchip ZL3073x SPI driver");
60 MODULE_IMPORT_NS("ZL3073X");
61 MODULE_LICENSE("GPL");
62