18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * ALSA SoC TLV320AIC23 codec driver I2C interface
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Author:      Arun KS, <arunks@mistralsolutions.com>
68c2ecf20Sopenharmony_ci * Copyright:   (C) 2008 Mistral Solutions Pvt Ltd.,
78c2ecf20Sopenharmony_ci *
88c2ecf20Sopenharmony_ci * Based on sound/soc/codecs/wm8731.c by Richard Purdie
98c2ecf20Sopenharmony_ci */
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#include <linux/i2c.h>
128c2ecf20Sopenharmony_ci#include <linux/module.h>
138c2ecf20Sopenharmony_ci#include <linux/of.h>
148c2ecf20Sopenharmony_ci#include <linux/regmap.h>
158c2ecf20Sopenharmony_ci#include <sound/soc.h>
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci#include "tlv320aic23.h"
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_cistatic int tlv320aic23_i2c_probe(struct i2c_client *i2c,
208c2ecf20Sopenharmony_ci				 const struct i2c_device_id *i2c_id)
218c2ecf20Sopenharmony_ci{
228c2ecf20Sopenharmony_ci	struct regmap *regmap;
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci	if (!i2c_check_functionality(i2c->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
258c2ecf20Sopenharmony_ci		return -EINVAL;
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci	regmap = devm_regmap_init_i2c(i2c, &tlv320aic23_regmap);
288c2ecf20Sopenharmony_ci	return tlv320aic23_probe(&i2c->dev, regmap);
298c2ecf20Sopenharmony_ci}
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_cistatic const struct i2c_device_id tlv320aic23_id[] = {
328c2ecf20Sopenharmony_ci	{"tlv320aic23", 0},
338c2ecf20Sopenharmony_ci	{}
348c2ecf20Sopenharmony_ci};
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(i2c, tlv320aic23_id);
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_cistatic const struct of_device_id tlv320aic23_of_match[] = {
398c2ecf20Sopenharmony_ci	{ .compatible = "ti,tlv320aic23", },
408c2ecf20Sopenharmony_ci	{ }
418c2ecf20Sopenharmony_ci};
428c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(of, tlv320aic23_of_match);
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_cistatic struct i2c_driver tlv320aic23_i2c_driver = {
458c2ecf20Sopenharmony_ci	.driver = {
468c2ecf20Sopenharmony_ci		   .name = "tlv320aic23-codec",
478c2ecf20Sopenharmony_ci		   .of_match_table = of_match_ptr(tlv320aic23_of_match),
488c2ecf20Sopenharmony_ci		   },
498c2ecf20Sopenharmony_ci	.probe = tlv320aic23_i2c_probe,
508c2ecf20Sopenharmony_ci	.id_table = tlv320aic23_id,
518c2ecf20Sopenharmony_ci};
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_cimodule_i2c_driver(tlv320aic23_i2c_driver);
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("ASoC TLV320AIC23 codec driver I2C");
568c2ecf20Sopenharmony_ciMODULE_AUTHOR("Arun KS <arunks@mistralsolutions.com>");
578c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL");
58