Loading...
Note: File does not exist in v5.9.
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/i2c.h>
12#include <linux/mfd/cs40l50.h>
13
14static int cs40l50_i2c_probe(struct i2c_client *i2c)
15{
16 struct cs40l50 *cs40l50;
17
18 cs40l50 = devm_kzalloc(&i2c->dev, sizeof(*cs40l50), GFP_KERNEL);
19 if (!cs40l50)
20 return -ENOMEM;
21
22 i2c_set_clientdata(i2c, cs40l50);
23
24 cs40l50->dev = &i2c->dev;
25 cs40l50->irq = i2c->irq;
26
27 cs40l50->regmap = devm_regmap_init_i2c(i2c, &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
35static void cs40l50_i2c_remove(struct i2c_client *i2c)
36{
37 struct cs40l50 *cs40l50 = i2c_get_clientdata(i2c);
38
39 cs40l50_remove(cs40l50);
40}
41
42static const struct i2c_device_id cs40l50_id_i2c[] = {
43 { "cs40l50" },
44 {}
45};
46MODULE_DEVICE_TABLE(i2c, cs40l50_id_i2c);
47
48static const struct of_device_id cs40l50_of_match[] = {
49 { .compatible = "cirrus,cs40l50" },
50 {}
51};
52MODULE_DEVICE_TABLE(of, cs40l50_of_match);
53
54static struct i2c_driver cs40l50_i2c_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_i2c,
61 .probe = cs40l50_i2c_probe,
62 .remove = cs40l50_i2c_remove,
63};
64module_i2c_driver(cs40l50_i2c_driver);
65
66MODULE_DESCRIPTION("CS40L50 I2C Driver");
67MODULE_AUTHOR("James Ogletree, Cirrus Logic Inc. <james.ogletree@cirrus.com>");
68MODULE_LICENSE("GPL");