Linux Audio

Check our new training course

Loading...
v6.13.7
 1/*
 2 * Cirrus Logic CS42448/CS42888 Audio CODEC DAI I2C driver
 3 *
 4 * Copyright (C) 2014 Freescale Semiconductor, Inc.
 5 *
 6 * Author: Nicolin Chen <Guangyu.Chen@freescale.com>
 7 *
 8 * This file is licensed under the terms of the GNU General Public License
 9 * version 2. This program is licensed "as is" without any warranty of any
10 * kind, whether express or implied.
11 */
12
13#include <linux/i2c.h>
14#include <linux/module.h>
15#include <linux/mod_devicetable.h>
16#include <linux/pm_runtime.h>
17#include <sound/soc.h>
18
19#include "cs42xx8.h"
20
21static int cs42xx8_i2c_probe(struct i2c_client *i2c)
 
22{
23	int ret;
24	struct cs42xx8_driver_data *drvdata;
25
26	drvdata = (struct cs42xx8_driver_data *)i2c_get_match_data(i2c);
27	if (!drvdata)
28		return dev_err_probe(&i2c->dev, -EINVAL,
29				     "failed to find driver data\n");
30
31	ret = cs42xx8_probe(&i2c->dev,
32		devm_regmap_init_i2c(i2c, &cs42xx8_regmap_config), drvdata);
33	if (ret)
34		return ret;
35
36	pm_runtime_enable(&i2c->dev);
37	pm_request_idle(&i2c->dev);
38
39	return 0;
40}
41
42static void cs42xx8_i2c_remove(struct i2c_client *i2c)
43{
 
44	pm_runtime_disable(&i2c->dev);
45}
46
47static const struct of_device_id cs42xx8_of_match[] = {
48	{ .compatible = "cirrus,cs42448", .data = &cs42448_data, },
49	{ .compatible = "cirrus,cs42888", .data = &cs42888_data, },
50	{ /* sentinel */ }
51};
52MODULE_DEVICE_TABLE(of, cs42xx8_of_match);
53
54static const struct i2c_device_id cs42xx8_i2c_id[] = {
55	{"cs42448", (kernel_ulong_t)&cs42448_data},
56	{"cs42888", (kernel_ulong_t)&cs42888_data},
57	{}
58};
59MODULE_DEVICE_TABLE(i2c, cs42xx8_i2c_id);
60
61static struct i2c_driver cs42xx8_i2c_driver = {
62	.driver = {
63		.name = "cs42xx8",
 
64		.pm = &cs42xx8_pm,
65		.of_match_table = cs42xx8_of_match,
66	},
67	.probe = cs42xx8_i2c_probe,
68	.remove = cs42xx8_i2c_remove,
69	.id_table = cs42xx8_i2c_id,
70};
71
72module_i2c_driver(cs42xx8_i2c_driver);
73
74MODULE_DESCRIPTION("Cirrus Logic CS42448/CS42888 ALSA SoC Codec I2C Driver");
75MODULE_AUTHOR("Freescale Semiconductor, Inc.");
76MODULE_LICENSE("GPL");
v3.15
 1/*
 2 * Cirrus Logic CS42448/CS42888 Audio CODEC DAI I2C driver
 3 *
 4 * Copyright (C) 2014 Freescale Semiconductor, Inc.
 5 *
 6 * Author: Nicolin Chen <Guangyu.Chen@freescale.com>
 7 *
 8 * This file is licensed under the terms of the GNU General Public License
 9 * version 2. This program is licensed "as is" without any warranty of any
10 * kind, whether express or implied.
11 */
12
13#include <linux/i2c.h>
14#include <linux/module.h>
 
15#include <linux/pm_runtime.h>
16#include <sound/soc.h>
17
18#include "cs42xx8.h"
19
20static int cs42xx8_i2c_probe(struct i2c_client *i2c,
21			     const struct i2c_device_id *id)
22{
23	u32 ret = cs42xx8_probe(&i2c->dev,
24			devm_regmap_init_i2c(i2c, &cs42xx8_regmap_config));
 
 
 
 
 
 
 
 
25	if (ret)
26		return ret;
27
28	pm_runtime_enable(&i2c->dev);
29	pm_request_idle(&i2c->dev);
30
31	return 0;
32}
33
34static int cs42xx8_i2c_remove(struct i2c_client *i2c)
35{
36	snd_soc_unregister_codec(&i2c->dev);
37	pm_runtime_disable(&i2c->dev);
 
38
39	return 0;
40}
 
 
 
 
41
42static struct i2c_device_id cs42xx8_i2c_id[] = {
43	{"cs42448", (kernel_ulong_t)&cs42448_data},
44	{"cs42888", (kernel_ulong_t)&cs42888_data},
45	{}
46};
47MODULE_DEVICE_TABLE(i2c, cs42xx8_i2c_id);
48
49static struct i2c_driver cs42xx8_i2c_driver = {
50	.driver = {
51		.name = "cs42xx8",
52		.owner = THIS_MODULE,
53		.pm = &cs42xx8_pm,
 
54	},
55	.probe = cs42xx8_i2c_probe,
56	.remove = cs42xx8_i2c_remove,
57	.id_table = cs42xx8_i2c_id,
58};
59
60module_i2c_driver(cs42xx8_i2c_driver);
61
62MODULE_DESCRIPTION("Cirrus Logic CS42448/CS42888 ALSA SoC Codec I2C Driver");
63MODULE_AUTHOR("Freescale Semiconductor, Inc.");
64MODULE_LICENSE("GPL");