19dc15f81SMark Brown // SPDX-License-Identifier: GPL-2.0-only
29dc15f81SMark Brown /*
39dc15f81SMark Brown * wm8731.c -- WM8731 ALSA SoC Audio driver
49dc15f81SMark Brown *
59dc15f81SMark Brown * Copyright 2005 Openedhand Ltd.
69dc15f81SMark Brown * Copyright 2006-12 Wolfson Microelectronics, plc
79dc15f81SMark Brown *
89dc15f81SMark Brown * Author: Richard Purdie <richard@openedhand.com>
99dc15f81SMark Brown *
109dc15f81SMark Brown * Based on wm8753.c by Liam Girdwood
119dc15f81SMark Brown */
129dc15f81SMark Brown
139dc15f81SMark Brown #include <linux/spi/spi.h>
14*340d79a1SRob Herring #include <linux/mod_devicetable.h>
159dc15f81SMark Brown #include <linux/module.h>
169dc15f81SMark Brown
179dc15f81SMark Brown #include "wm8731.h"
189dc15f81SMark Brown
199dc15f81SMark Brown static const struct of_device_id wm8731_of_match[] = {
209dc15f81SMark Brown { .compatible = "wlf,wm8731", },
219dc15f81SMark Brown { }
229dc15f81SMark Brown };
239dc15f81SMark Brown MODULE_DEVICE_TABLE(of, wm8731_of_match);
249dc15f81SMark Brown
wm8731_spi_probe(struct spi_device * spi)259dc15f81SMark Brown static int wm8731_spi_probe(struct spi_device *spi)
269dc15f81SMark Brown {
279dc15f81SMark Brown struct wm8731_priv *wm8731;
289dc15f81SMark Brown int ret;
299dc15f81SMark Brown
309dc15f81SMark Brown wm8731 = devm_kzalloc(&spi->dev, sizeof(*wm8731), GFP_KERNEL);
319dc15f81SMark Brown if (wm8731 == NULL)
329dc15f81SMark Brown return -ENOMEM;
339dc15f81SMark Brown
349dc15f81SMark Brown spi_set_drvdata(spi, wm8731);
359dc15f81SMark Brown
369dc15f81SMark Brown wm8731->regmap = devm_regmap_init_spi(spi, &wm8731_regmap);
379dc15f81SMark Brown if (IS_ERR(wm8731->regmap)) {
389dc15f81SMark Brown ret = PTR_ERR(wm8731->regmap);
399dc15f81SMark Brown dev_err(&spi->dev, "Failed to allocate register map: %d\n",
409dc15f81SMark Brown ret);
419dc15f81SMark Brown return ret;
429dc15f81SMark Brown }
439dc15f81SMark Brown
449dc15f81SMark Brown return wm8731_init(&spi->dev, wm8731);
459dc15f81SMark Brown }
469dc15f81SMark Brown
479dc15f81SMark Brown static struct spi_driver wm8731_spi_driver = {
489dc15f81SMark Brown .driver = {
499dc15f81SMark Brown .name = "wm8731",
509dc15f81SMark Brown .of_match_table = wm8731_of_match,
519dc15f81SMark Brown },
529dc15f81SMark Brown .probe = wm8731_spi_probe,
539dc15f81SMark Brown };
549dc15f81SMark Brown
559dc15f81SMark Brown module_spi_driver(wm8731_spi_driver);
569dc15f81SMark Brown
579dc15f81SMark Brown MODULE_DESCRIPTION("ASoC WM8731 driver - SPI");
589dc15f81SMark Brown MODULE_AUTHOR("Richard Purdie");
599dc15f81SMark Brown MODULE_LICENSE("GPL");
60