1 // SPDX-License-Identifier: GPL-2.0
3 * CS40L50 Advanced Haptic Driver with waveform memory,
4 * integrated DSP, and closed-loop algorithms
6 * Copyright 2024 Cirrus Logic, Inc.
8 * Author: James Ogletree <james.ogletree@cirrus.com>
11 #include <linux/i2c.h>
12 #include <linux/mfd/cs40l50.h>
14 static int cs40l50_i2c_probe(struct i2c_client
*i2c
)
16 struct cs40l50
*cs40l50
;
18 cs40l50
= devm_kzalloc(&i2c
->dev
, sizeof(*cs40l50
), GFP_KERNEL
);
22 i2c_set_clientdata(i2c
, cs40l50
);
24 cs40l50
->dev
= &i2c
->dev
;
25 cs40l50
->irq
= i2c
->irq
;
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");
32 return cs40l50_probe(cs40l50
);
35 static void cs40l50_i2c_remove(struct i2c_client
*i2c
)
37 struct cs40l50
*cs40l50
= i2c_get_clientdata(i2c
);
39 cs40l50_remove(cs40l50
);
42 static const struct i2c_device_id cs40l50_id_i2c
[] = {
46 MODULE_DEVICE_TABLE(i2c
, cs40l50_id_i2c
);
48 static const struct of_device_id cs40l50_of_match
[] = {
49 { .compatible
= "cirrus,cs40l50" },
52 MODULE_DEVICE_TABLE(of
, cs40l50_of_match
);
54 static struct i2c_driver cs40l50_i2c_driver
= {
57 .of_match_table
= cs40l50_of_match
,
58 .pm
= pm_ptr(&cs40l50_pm_ops
),
60 .id_table
= cs40l50_id_i2c
,
61 .probe
= cs40l50_i2c_probe
,
62 .remove
= cs40l50_i2c_remove
,
64 module_i2c_driver(cs40l50_i2c_driver
);
66 MODULE_DESCRIPTION("CS40L50 I2C Driver");
67 MODULE_AUTHOR("James Ogletree, Cirrus Logic Inc. <james.ogletree@cirrus.com>");
68 MODULE_LICENSE("GPL");