Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * wm8731.c  --  WM8731 ALSA SoC Audio driver
0004  *
0005  * Copyright 2005 Openedhand Ltd.
0006  * Copyright 2006-12 Wolfson Microelectronics, plc
0007  *
0008  * Author: Richard Purdie <richard@openedhand.com>
0009  *
0010  * Based on wm8753.c by Liam Girdwood
0011  */
0012 
0013 #include <linux/spi/spi.h>
0014 #include <linux/module.h>
0015 #include <linux/of_device.h>
0016 
0017 #include "wm8731.h"
0018 
0019 static const struct of_device_id wm8731_of_match[] = {
0020     { .compatible = "wlf,wm8731", },
0021     { }
0022 };
0023 MODULE_DEVICE_TABLE(of, wm8731_of_match);
0024 
0025 static int wm8731_spi_probe(struct spi_device *spi)
0026 {
0027     struct wm8731_priv *wm8731;
0028     int ret;
0029 
0030     wm8731 = devm_kzalloc(&spi->dev, sizeof(*wm8731), GFP_KERNEL);
0031     if (wm8731 == NULL)
0032         return -ENOMEM;
0033 
0034     spi_set_drvdata(spi, wm8731);
0035 
0036     wm8731->regmap = devm_regmap_init_spi(spi, &wm8731_regmap);
0037     if (IS_ERR(wm8731->regmap)) {
0038         ret = PTR_ERR(wm8731->regmap);
0039         dev_err(&spi->dev, "Failed to allocate register map: %d\n",
0040             ret);
0041         return ret;
0042     }
0043 
0044     return wm8731_init(&spi->dev, wm8731);
0045 }
0046 
0047 static struct spi_driver wm8731_spi_driver = {
0048     .driver = {
0049         .name   = "wm8731",
0050         .of_match_table = wm8731_of_match,
0051     },
0052     .probe      = wm8731_spi_probe,
0053 };
0054 
0055 module_spi_driver(wm8731_spi_driver);
0056 
0057 MODULE_DESCRIPTION("ASoC WM8731 driver - SPI");
0058 MODULE_AUTHOR("Richard Purdie");
0059 MODULE_LICENSE("GPL");