Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
torvalds
GitHub Repository: torvalds/linux
Path: blob/master/drivers/dpll/zl3073x/spi.c
26282 views
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, spi_get_device_match_data(spi));
26
}
27
28
static const struct spi_device_id zl3073x_spi_id[] = {
29
{
30
.name = "zl30731",
31
.driver_data = (kernel_ulong_t)&zl30731_chip_info
32
},
33
{
34
.name = "zl30732",
35
.driver_data = (kernel_ulong_t)&zl30732_chip_info,
36
},
37
{
38
.name = "zl30733",
39
.driver_data = (kernel_ulong_t)&zl30733_chip_info,
40
},
41
{
42
.name = "zl30734",
43
.driver_data = (kernel_ulong_t)&zl30734_chip_info,
44
},
45
{
46
.name = "zl30735",
47
.driver_data = (kernel_ulong_t)&zl30735_chip_info,
48
},
49
{ /* sentinel */ }
50
};
51
MODULE_DEVICE_TABLE(spi, zl3073x_spi_id);
52
53
static const struct of_device_id zl3073x_spi_of_match[] = {
54
{ .compatible = "microchip,zl30731", .data = &zl30731_chip_info },
55
{ .compatible = "microchip,zl30732", .data = &zl30732_chip_info },
56
{ .compatible = "microchip,zl30733", .data = &zl30733_chip_info },
57
{ .compatible = "microchip,zl30734", .data = &zl30734_chip_info },
58
{ .compatible = "microchip,zl30735", .data = &zl30735_chip_info },
59
{ /* sentinel */ }
60
};
61
MODULE_DEVICE_TABLE(of, zl3073x_spi_of_match);
62
63
static struct spi_driver zl3073x_spi_driver = {
64
.driver = {
65
.name = "zl3073x-spi",
66
.of_match_table = zl3073x_spi_of_match,
67
},
68
.probe = zl3073x_spi_probe,
69
.id_table = zl3073x_spi_id,
70
};
71
module_spi_driver(zl3073x_spi_driver);
72
73
MODULE_AUTHOR("Ivan Vecera <[email protected]>");
74
MODULE_DESCRIPTION("Microchip ZL3073x SPI driver");
75
MODULE_IMPORT_NS("ZL3073X");
76
MODULE_LICENSE("GPL");
77
78