linux/sound/soc/codecs/pcm1789-i2c.c
<<
>>
Prefs
   1// SPDX-License-Identifier: GPL-2.0
   2// Audio driver for PCM1789 I2C
   3// Copyright (C) 2018 Bootlin
   4// Mylène Josserand <mylene.josserand@bootlin.com>
   5
   6#include <linux/clk.h>
   7#include <linux/delay.h>
   8#include <linux/i2c.h>
   9#include <linux/module.h>
  10#include <linux/of.h>
  11#include <linux/regmap.h>
  12
  13#include "pcm1789.h"
  14
  15static int pcm1789_i2c_probe(struct i2c_client *client,
  16                             const struct i2c_device_id *id)
  17{
  18        struct regmap *regmap;
  19        int ret;
  20
  21        regmap = devm_regmap_init_i2c(client, &pcm1789_regmap_config);
  22        if (IS_ERR(regmap)) {
  23                ret = PTR_ERR(regmap);
  24                dev_err(&client->dev, "Failed to allocate regmap: %d\n", ret);
  25                return ret;
  26        }
  27
  28        return pcm1789_common_init(&client->dev, regmap);
  29}
  30
  31static int pcm1789_i2c_remove(struct i2c_client *client)
  32{
  33        return pcm1789_common_exit(&client->dev);
  34}
  35
  36static const struct of_device_id pcm1789_of_match[] = {
  37        { .compatible = "ti,pcm1789", },
  38        { }
  39};
  40MODULE_DEVICE_TABLE(of, pcm1789_of_match);
  41
  42static const struct i2c_device_id pcm1789_i2c_ids[] = {
  43        { "pcm1789", 0 },
  44        { }
  45};
  46MODULE_DEVICE_TABLE(i2c, pcm1789_i2c_ids);
  47
  48static struct i2c_driver pcm1789_i2c_driver = {
  49        .driver = {
  50                .name   = "pcm1789",
  51                .of_match_table = of_match_ptr(pcm1789_of_match),
  52        },
  53        .id_table       = pcm1789_i2c_ids,
  54        .probe          = pcm1789_i2c_probe,
  55        .remove = pcm1789_i2c_remove,
  56};
  57
  58module_i2c_driver(pcm1789_i2c_driver);
  59
  60MODULE_DESCRIPTION("ASoC PCM1789 I2C driver");
  61MODULE_AUTHOR("Mylène Josserand <mylene.josserand@bootlin.com>");
  62MODULE_LICENSE("GPL");
  63